QtMobility Reference Documentation

QGeoMapCustomObject Class Reference

The QGeoMapCustomObject class is a QGeoMapObject used to draw a QGraphicsItem on a map. More...

 #include <QGeoMapCustomObject>

Inherits: QGeoMapObject.

This class was introduced in Qt Mobility 1.2.

Properties

Public Functions

QGeoMapCustomObject ()
QGeoMapCustomObject ( const QGeoCoordinate & coordinate, const QPoint & offset = QPoint( 0, 0 ) )
~QGeoMapCustomObject ()
QGraphicsItem * graphicsItem () const
QPoint offset () const
void setGraphicsItem ( QGraphicsItem * graphicsItem )
void setOffset ( const QPoint & offset )
void setOrigin ( const QGeoCoordinate & origin )
void setTransformType ( const TransformType & type )
void setUnits ( const CoordinateUnit & unit )
void update ()

Reimplemented Public Functions

virtual QGeoMapObject::Type type () const

Signals

void graphicsItemChanged ( QGraphicsItem * graphicsItem )
void offsetChanged ( const QPoint & offset )
void triggerUpdate ()

Additional Inherited Members

  • 1 public slot inherited from QObject
  • 1 public variable inherited from QObject
  • 4 static public members inherited from QObject
  • 3 protected functions inherited from QGeoMapObject
  • 7 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

Detailed Description

The QGeoMapCustomObject class is a QGeoMapObject used to draw a QGraphicsItem on a map.

Any arbitrary QGraphicsItem can be associated with a QGeoMapCustomObject, and to this end it contains support for interpreting the coordinates of the QGraphicsItem in a variety of different ways.

For example, the following code creates a QGraphicsEllipseItem and a QGeoMapCustomObject to display it. The EllipseItem extends from the origin point, out 20 meters to the east and 30 metres south.

 QGraphicsEllipseItem *ellipseItem = new QGraphicsEllipseItem;
 ellipseItem->setRect(0, 0, 20, 30);

 QGeoMapCustomObject *mapObject = new QGeoMapCustomObject;
 mapObject->setGraphicsItem(ellipseItem);
 mapObject->setUnits(QGeoMapObject::MeterUnit);
 mapObject->setOrigin(QGeoCoordinate(-27.5796, 153.1));

Units and coordinates

The local units and coordinates of the QGraphicsItem are transformed onto the map based on the units, origin, transformType and transform properties. Several systems are available, including pixels, meters and seconds of arc.

It should be noted that both pixel and meter coordinate systems are south- oriented (ie, positive Y axis faces south on the map). However, the RelativeArcSeconds unit system faces north to align with the standard latitude grid. The Y axis can be flipped if necessary by making use of the GraphicsItem's transform property

 QTransform northFlip;
 northFlip.scale(0, -1);

 ellipseItem->setTransform(northFlip);

Transform methods

Normally, the GraphicsItem will be transformed into map coordinates using a bilinear interpolation. Another option is the ExactTransform, which converts the GraphicsItem exactly into map coordinates, but is only available for certain subclasses of QGraphicsItem. Other interpolation methods may be provided in future for greater accuracy near poles and in different map projections, without the limitations of ExactTransform.

Calling setUnits() or setting the units property will result in the default value of transformType being restored. See QGeoMapObject::transformType for more details.

Caveats

Other than the coordinate system features, there are a few differences with using QGraphicsItems on a map compared to using them on a standard QGraphicsScene. One of the most important of these is the use of the update() function. When an application changes anything that has an effect upon the appearance, size, shape etc of the QGraphicsItem, it must call QGeoMapCustomObject::update() to ensure that the map is updated.

Another is the use of child items of a QGraphicsItem. These are supported in more or less the same manner as in QGraphicsScene, with the exception of use in concert with ExactTransform -- any object with transformType set to ExactTransform will not have children of its QGraphicsItem drawn on the map.

Property Documentation

graphicsItem : QGraphicsItem *

This property holds the graphics item which will be drawn by this custom object.

If the graphics item is 0 then nothing will be drawn.

This property was introduced in Qt Mobility 1.2.

Access functions:

QGraphicsItem * graphicsItem () const
void setGraphicsItem ( QGraphicsItem * graphicsItem )

Notifier signal:

void graphicsItemChanged ( QGraphicsItem * graphicsItem )

offset : QPoint

This property holds the offset in pixels at which the graphics item will be drawn by this custom object.

The default value of this property is QPoint(0, 0). If this value is not changed the upper left coordinate of the graphics item will be drawn at the coordinate specified by QGeoMapCustomObject::coordinate.

The offset is in pixels and is independent of the zoom level of the map.

This property was introduced in Qt Mobility 1.2.

Access functions:

QPoint offset () const
void setOffset ( const QPoint & offset )

Notifier signal:

void offsetChanged ( const QPoint & offset )

Member Function Documentation

QGeoMapCustomObject::QGeoMapCustomObject ()

Constructs a new custom object.

QGeoMapCustomObject::QGeoMapCustomObject ( const QGeoCoordinate & coordinate, const QPoint & offset = QPoint( 0, 0 ) )

Constructs a new custom object which will draw a QGraphicsItem at an offset of offset pixels from the coordinate coordinate.

This function was introduced in Qt Mobility 1.2.

QGeoMapCustomObject::~QGeoMapCustomObject ()

Destroys this custom object.

void QGeoMapCustomObject::graphicsItemChanged ( QGraphicsItem * graphicsItem ) [signal]

This signal is emitted when the graphics item which this custom object draws is changed.

The new value will be graphicsItem.

This function was introduced in Qt Mobility 1.2.

void QGeoMapCustomObject::offsetChanged ( const QPoint & offset ) [signal]

This signal is emitted when the on-screen offset from the coordinate at which this custom object should be drawn has changed.

The new value will be offset.

This function was introduced in Qt Mobility 1.2.

void QGeoMapCustomObject::setOrigin ( const QGeoCoordinate & origin )

Sets the origin of the object to origin.

This function was introduced in Qt Mobility 1.2.

void QGeoMapCustomObject::setTransformType ( const TransformType & type )

Sets the transform type of the object to type.

This function was introduced in Qt Mobility 1.2.

void QGeoMapCustomObject::setUnits ( const CoordinateUnit & unit )

Sets the coordinate units of the object to unit.

Note that setting this property will reset the transformType property to the default for the units given. For PixelUnit, this is ExactTransform, and for all others, BilinearTransform.

This function was introduced in Qt Mobility 1.2.

void QGeoMapCustomObject::triggerUpdate () [signal]

This signal indicates that the graphics item has changed and that the map needs to be updated.

This function was introduced in Qt Mobility 1.2.

QGeoMapObject::Type QGeoMapCustomObject::type () const [virtual]

Reimplemented from QGeoMapObject::type().

This function was introduced in Qt Mobility 1.2.

void QGeoMapCustomObject::update ()

If the graphics item is modified this method should be called immediately afterwards to inform the map that an update is required. .

This method causes the triggerUpdate() signal to be emitted.

This function was introduced in Qt Mobility 1.2.

X

Thank you for giving your feedback.

Make sure it is related to this specific page. For more general bugs and requests, please use the Qt Bug Tracker.