Views
Maps Package API Reference Guide
Product Documentation:
Views Documentation Home
List of all members | Public Member Functions | Static Public Member Functions
IlvMapLabel Class Reference

This class implements an IlvLabel adapted to map applications. More...

#include <ilviews/maps/graphics/maplabel.h>

Inheritance diagram for IlvMapLabel:
IlvLabel IlvSimpleGraphic IlvGraphic IlvValueInterface

Public Member Functions

 IlvMapLabel (IlvDisplay *display, const IlvPoint &anchor, const IlvPoint &offset, IlvPosition position, IlvDim maxLabelLength, const char *label, IlvPalette *palette=0)
 Initializes a new IlvMapLabel instance. More...
 
virtual void drawMinimizedRect (IlvPort *dst, const IlvRect &minimizedRect) const
 Draws the map label in its minimized form. More...
 
IlvPoint getAnchor () const
 Returns the anchor point of this label. More...
 
IlvDim getMaxLabelLength () const
 Returns the maximum length of this label. More...
 
IlvPoint getOffset () const
 Returns the offset of this label. More...
 
IlvPosition getPosition () const
 Returns the position of this label. More...
 
void setAttachment (const IlvPoint &anchor, const IlvPoint &offset, IlvPosition position)
 Specifies the position of the label. More...
 
void setMaxLabelLength (IlvDim length)
 Sets the maximum length of this label in the manager coordinate system. More...
 

Static Public Member Functions

static IlvDim GetLength (IlvDisplay *display, IlvDim height, const char *label, IlvPalette *palette=0)
 Computes the length of a label if it is displayed with a specified height. More...
 

Detailed Description

This class implements an IlvLabel adapted to map applications.

Library: ilvmaps

This class is a special version of the Rogue Wave Views IlvLabel class. It has been adapted to fit the needs of map applications.

A map label is displayed with a fixed size font specified by its palette, but by a zoom factor inferior to its display limit in text form. Consequently, the map label appears on the screen as a rectangle at first and becomes readable as text after zooming.

The position of a map label is specified relative to an anchored point and to an offset in pixels relative to this anchored point. Therefore, the distance from the anchor point is independent of the zoom factor.

Constructor & Destructor Documentation

◆ IlvMapLabel()

IlvMapLabel::IlvMapLabel ( IlvDisplay display,
const IlvPoint anchor,
const IlvPoint offset,
IlvPosition  position,
IlvDim  maxLabelLength,
const char *  label,
IlvPalette palette = 0 
)

Initializes a new IlvMapLabel instance.

The location at which the label is drawn is the translation of anchor by the offset offset. The offset allows you, for example, to specify that a label is drawn below a particular point (the summit of a mountain for example). However, the distance between the point and the label is maintained when the view is zoomed in.

Parameters
displayThe display of the map label.
anchorThe anchor point of the map label in the manager coordinate system.
offsetThe offset specified in pixels.
positionThe position of the label relative to the translated anchor.
maxLabelLengthThe maximum label length in the manager coordinate system. If the length of the string to display exceeds this size, the map label draws itself in a minimized mode.
labelThe label to be displayed.
paletteThe palette to draw this label. If not specified, this label is drawn using the default palette from its display.

Member Function Documentation

◆ drawMinimizedRect()

virtual void IlvMapLabel::drawMinimizedRect ( IlvPort dst,
const IlvRect minimizedRect 
) const
virtual

Draws the map label in its minimized form.

This method is called to display the map label in its minimized form. By default, it draws a filled rectangle.

Parameters
dstThe destination port on which the label is drawn.
minimizedRectThe rectangle in which the minimized label should be drawn.

◆ getAnchor()

IlvPoint IlvMapLabel::getAnchor ( ) const

Returns the anchor point of this label.

Returns
The anchor point of this label.

◆ GetLength()

static IlvDim IlvMapLabel::GetLength ( IlvDisplay display,
IlvDim  height,
const char *  label,
IlvPalette palette = 0 
)
static

Computes the length of a label if it is displayed with a specified height.

Parameters
displayThe display on which label is to be displayed.
heightThe height of the label.
labelThe label to be displayed.
paletteThe palette with which the label is to be drawn.
Returns
The length of the label.

◆ getMaxLabelLength()

IlvDim IlvMapLabel::getMaxLabelLength ( ) const

Returns the maximum length of this label.

Returns
The maximum length of this label.

◆ getOffset()

IlvPoint IlvMapLabel::getOffset ( ) const

Returns the offset of this label.

Returns
The offset of this label.

◆ getPosition()

IlvPosition IlvMapLabel::getPosition ( ) const

Returns the position of this label.

Returns
The position of this label.

◆ setAttachment()

void IlvMapLabel::setAttachment ( const IlvPoint anchor,
const IlvPoint offset,
IlvPosition  position 
)

Specifies the position of the label.

The location at which the label is drawn is the translation of anchor by the offset offset. The offset allows you, for example, to specify that a label is drawn below a particular point (the summit of a mountain for example). However, the distance between the point and the label is maintained when the view is zoomed in.

Parameters
anchorThe anchor point of the map label in the manager coordinate system.
offsetThe offset specified in pixels.
positionThe position of the label relative to the translated anchor.

◆ setMaxLabelLength()

void IlvMapLabel::setMaxLabelLength ( IlvDim  length)

Sets the maximum length of this label in the manager coordinate system.

For example, if you want to display a label that will not exceed 10km when displayed on your map, you can use the following code:

IlvUnitConverter* converter = mapInfo->getUnitConverter();
IlDouble maxLengthMeters = converter->toMeters(10000);
IlvDim maxLength = (IlvDim)mapInfo->getAdapter()->toViews(maxLengthMeteres);
mapLabel->setMaxLabelLength(maxLength);
Parameters
lengthThe maximum length of this label.
IlvUnitConverter::toMeters
IlDouble toMeters(IlDouble units) const
This method converts a measurement unit to meters.
Definition: unitconv.h:78
IlvUnitConverter
This class provides facilities to convert Cartesian data to various measurement units.
Definition: unitconv.h:53
IlvDim
uint32 IlvDim
IlDouble
double IlDouble