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.
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 () |
virtual QGeoMapObject::Type | type () const |
void | graphicsItemChanged ( QGraphicsItem * graphicsItem ) |
void | offsetChanged ( const QPoint & offset ) |
void | triggerUpdate () |
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));
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);
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.
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.
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 ) |
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 ) |
Constructs a new custom object.
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.
Destroys this custom object.
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.
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.
Sets the origin of the object to origin.
This function was introduced in Qt Mobility 1.2.
Sets the transform type of the object to type.
This function was introduced in Qt Mobility 1.2.
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.
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.
Reimplemented from QGeoMapObject::type().
This function was introduced in Qt Mobility 1.2.
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.
© 2008-2011 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.
All other trademarks are property of their respective owners. Privacy Policy
Licensees holding valid Qt Commercial licenses may use this document in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia.
Alternatively, this document may be used under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.