marble
#include <GeoPainter.h>
Public Member Functions | |
GeoPainter (QPaintDevice *paintDevice, const ViewportParams *viewportParams, MapQuality mapQuality=NormalQuality) | |
~GeoPainter () | |
void | drawAnnotation (const GeoDataCoordinates &position, const QString &text, QSizeF bubbleSize=QSizeF(130, 100), qreal bubbleOffsetX=-10, qreal bubbleOffsetY=-30, qreal xRnd=5, qreal yRnd=5) |
void | drawEllipse (const GeoDataCoordinates ¢erPosition, qreal width, qreal height, bool isGeoProjected=false) |
void | drawImage (const GeoDataCoordinates ¢erPosition, const QImage &image) |
void | drawPixmap (const GeoDataCoordinates ¢erPosition, const QPixmap &pixmap) |
void | drawPoint (const GeoDataCoordinates &position) |
void | drawPoint (const GeoDataPoint &point) |
void | drawPolygon (const GeoDataLinearRing &linearRing, Qt::FillRule fillRule=Qt::OddEvenFill) |
void | drawPolygon (const GeoDataPolygon &polygon, Qt::FillRule fillRule=Qt::OddEvenFill) |
void | drawPolyline (const GeoDataLineString &lineString, const QString &labelText=QString(), LabelPositionFlags labelPositionFlags=LineCenter) |
void | drawRect (const GeoDataCoordinates ¢erPosition, qreal width, qreal height, bool isGeoProjected=false) |
void | drawRoundRect (const GeoDataCoordinates ¢erPosition, int width, int height, int xRnd=25, int yRnd=25) |
void | drawText (const GeoDataCoordinates &position, const QString &text) |
MapQuality | mapQuality () const |
QRegion | regionFromEllipse (const GeoDataCoordinates ¢erPosition, qreal width, qreal height, bool isGeoProjected=false, qreal strokeWidth=3) const |
QRegion | regionFromPoint (const GeoDataCoordinates &position, qreal strokeWidth=3) const |
QRegion | regionFromPoint (const GeoDataPoint &point, qreal strokeWidth=3) const |
QRegion | regionFromPolygon (const GeoDataLinearRing &linearRing, Qt::FillRule fillRule, qreal strokeWidth=3) const |
QRegion | regionFromPolyline (const GeoDataLineString &lineString, qreal strokeWidth=3) const |
QRegion | regionFromRect (const GeoDataCoordinates ¢erPosition, qreal width, qreal height, bool isGeoProjected=false, qreal strokeWidth=3) const |
Public Member Functions inherited from Marble::ClipPainter | |
ClipPainter () | |
ClipPainter (QPaintDevice *, bool) | |
~ClipPainter () | |
void | drawPolygon (const QPolygonF &, Qt::FillRule fillRule=Qt::OddEvenFill) |
void | drawPolyline (const QPolygonF &) |
void | drawPolyline (const QPolygonF &, QVector< QPointF > &labelNodes, LabelPositionFlags labelPositionFlag=LineCenter) |
bool | isClipping () const |
void | setClipping (bool enable) |
Detailed Description
A painter that allows to draw geometric primitives on the map.
This class allows application developers to draw simple geometric shapes and objects onto the map.
The API is modeled after the QPainter API.
The GeoPainter provides a wide range of methods that are using geographic ("geodesic") coordinates to position the item. For example a point or the nodes of a polygon can fully be described in geographic coordinates.
In all these cases the position of the object is specified in geographic coordinates.
There are however some cases where there are two viable cases:
- the shape of the object could still use screen coordinates (like a label or an icon).
- Alternatively the shape of the object can get projected according to the current projection (e.g. a texture projected onto the spherical surface)
If screen coordinates are used then e.g. width and height are assumed to be expressed in pixels, otherwise degrees are used.
Painter transformations (e.g. translate) always happen in screen coordinates.
Like in QPainter drawing objects onto a widget should always considered to be a volatile operation. This means that e.g. placemarks don't get added to the globe permanently. So the drawing needs to be done on every repaint to prevent that drawings will disappear during the next paint event.
So if you want to add placemarks to your map widget permanently (i.e. you don't want to take care of repainting) then you need to use other solutions such as the KML import of the Marble framework or Marble's GeoGraphicsItems.
- Note
- By default the GeoPainter automatically filters geographical content in order to provide fast painting:
- Geographically positioned objects which are outside the viewport are not drawn at all. Parts of objects which are specified through geographic coordinates (like polygons, ellipses etc.) get cut off if they are not placed within the viewport.
- Objects which have a shape that is specified through geographic coordinates get filtered according to the viewport resolution: If the object is much smaller than a pixel then it won't get drawn at all.
Definition at line 98 of file GeoPainter.h.
Constructor & Destructor Documentation
GeoPainter::GeoPainter | ( | QPaintDevice * | paintDevice, |
const ViewportParams * | viewportParams, | ||
MapQuality | mapQuality = NormalQuality |
||
) |
Creates a new geo painter.
To create a geo painter it's necessary to provide paintDevice as a canvas and the viewportParams to specify the map projection inside the viewport.
Definition at line 176 of file GeoPainter.cpp.
GeoPainter::~GeoPainter | ( | ) |
Destroys the geo painter.
Definition at line 185 of file GeoPainter.cpp.
Member Function Documentation
void GeoPainter::drawAnnotation | ( | const GeoDataCoordinates & | position, |
const QString & | text, | ||
QSizeF | bubbleSize = QSizeF( 130, 100 ) , |
||
qreal | bubbleOffsetX = -10 , |
||
qreal | bubbleOffsetY = -30 , |
||
qreal | xRnd = 5 , |
||
qreal | yRnd = 5 |
||
) |
Draws a text annotation that points to a geodesic position.
The annotation consists of a bubble with the specified text inside. By choosing an appropriate pen for the painter it's possible to change the color and line style of the bubble outline and the text. The brush chosen for the painter is used to paint the background of the bubble
The optional parameters which describe the layout of the bubble are similar to those used by QPainter::drawRoundRect(). Unlike in QPainter the rounded corners are not specified in percentage but in pixels to provide for optimal aesthetics. By choosing a positive or negative bubbleOffset it's possible to place the annotation on top, bottom, left or right of the annotated position.
- Parameters
-
position The geodesic position text The text contained by the bubble bubbleSize The size of the bubble that holds the annotation text. A height of 0 can be used to have the height calculated automatically to fit the needed text height. bubbleOffsetX The x-axis offset between the annotated position and the "root" of the speech bubble's "arrow". bubbleOffsetY The y-axis offset between the annotated position and the "root" of the speech bubble's "arrow". xRnd Specifies the geometry of the rounded corners in pixels along the x-axis. yRnd Specifies the geometry of the rounded corners in pixels along the y-axis.
- See also
- GeoDataCoordinates
Definition at line 197 of file GeoPainter.cpp.
void GeoPainter::drawEllipse | ( | const GeoDataCoordinates & | centerPosition, |
qreal | width, | ||
qreal | height, | ||
bool | isGeoProjected = false |
||
) |
Draws an ellipse at the given position. The ellipse is placed with its center located at the given centerPosition.
For the outline it uses the painter's pen and for the background the painter's brush.
If isGeoProjected is true then the outline of the ellipse is drawn in geographic coordinates. In this case the width and the height are interpreted to be degrees. If isGeoProjected is false then the outline of the ellipse is drawn in screen coordinates. In this case the width and the height are interpreted to be pixels.
- See also
- GeoDataCoordinates
Definition at line 289 of file GeoPainter.cpp.
void GeoPainter::drawImage | ( | const GeoDataCoordinates & | centerPosition, |
const QImage & | image | ||
) |
Draws an image at the given position. The image is placed with its center located at the given centerPosition.
The image rendering is performed in screen coordinates and is not subject to the current projection.
- See also
- GeoDataCoordinates
Definition at line 428 of file GeoPainter.cpp.
void GeoPainter::drawPixmap | ( | const GeoDataCoordinates & | centerPosition, |
const QPixmap & | pixmap | ||
) |
Draws a pixmap at the given position. The pixmap is placed with its center located at the given centerPosition.
The image rendering is performed in screen coordinates and is not subject to the current projection.
- See also
- GeoDataCoordinates
Definition at line 452 of file GeoPainter.cpp.
void GeoPainter::drawPoint | ( | const GeoDataCoordinates & | position | ) |
Draws a single point at a given geographic position. The point is drawn using the painter's pen color.
- See also
- GeoDataCoordinates
Definition at line 227 of file GeoPainter.cpp.
void GeoPainter::drawPoint | ( | const GeoDataPoint & | point | ) |
Draws a single point at a given geographic position. The point is drawn using the painter's pen color.
- See also
- GeoDataPoint
Definition at line 251 of file GeoPainter.cpp.
void GeoPainter::drawPolygon | ( | const GeoDataLinearRing & | linearRing, |
Qt::FillRule | fillRule = Qt::OddEvenFill |
||
) |
Draws a given linear ring (a "polygon without holes").
The outline of the linearRing is drawn using the current pen. The background is painted using the current brush of the painter. Like in QPainter::drawPolygon() the fillRule specifies the fill algorithm that is used to fill the polygon.
- See also
- GeoDataLinearRing
Definition at line 560 of file GeoPainter.cpp.
void GeoPainter::drawPolygon | ( | const GeoDataPolygon & | polygon, |
Qt::FillRule | fillRule = Qt::OddEvenFill |
||
) |
Draws a given polygon (which may contain holes).
The outline of the polygon is drawn using the current pen. The background is painted using the current brush of the painter. Like in QPainter::drawPolygon() the fillRule specifies the fill algorithm that is used to fill the polygon.
- See also
- GeoDataPolygon
Definition at line 628 of file GeoPainter.cpp.
void GeoPainter::drawPolyline | ( | const GeoDataLineString & | lineString, |
const QString & | labelText = QString() , |
||
LabelPositionFlags | labelPositionFlags = LineCenter |
||
) |
Draws a given line string (a "polyline").
The lineString is drawn using the current pen. It's possible to provide a labelText for the lineString. The text is rendered using the painter's font property. The position of the labelText can be specified using the labelPositionFlags.
- See also
- GeoDataLineString
Definition at line 474 of file GeoPainter.cpp.
void GeoPainter::drawRect | ( | const GeoDataCoordinates & | centerPosition, |
qreal | width, | ||
qreal | height, | ||
bool | isGeoProjected = false |
||
) |
Draws a rectangle at the given position. The rectangle is placed with its center located at the given centerPosition.
For the outline it uses the painter's pen and for the background the painter's brush.
If isGeoProjected is true then the outline of the rectangle is drawn in geographic coordinates. In this case the width and the height are interpreted to be degrees. If isGeoProjected is false then the outline of the rectangle is drawn in screen coordinates. In this case the width and the height are interpreted to be pixels.
- See also
- GeoDataCoordinates
Definition at line 700 of file GeoPainter.cpp.
void GeoPainter::drawRoundRect | ( | const GeoDataCoordinates & | centerPosition, |
int | width, | ||
int | height, | ||
int | xRnd = 25 , |
||
int | yRnd = 25 |
||
) |
Draws a rectangle with rounded corners at the given position. The rectangle is placed with its center located at the given centerPosition.
For the outline it uses the painter's pen and for the background the painter's brush. Unlike in QPainter::drawRoundedRect() the rounded corners are not specified in percentage but in pixels to provide for optimal aesthetics.
- Parameters
-
width Width of the rectangle in pixels height Height of the rectangle in pixels xRnd Specifies the geometry of the rounded corners in pixels along the x-axis. yRnd Specifies the geometry of the rounded corners in pixels along the y-axis.
- See also
- GeoDataCoordinates
Definition at line 759 of file GeoPainter.cpp.
void GeoPainter::drawText | ( | const GeoDataCoordinates & | position, |
const QString & | text | ||
) |
Draws the given text at a given geographic position. The text is drawn starting at the given position using the painter's font property. The text rendering is performed in screen coordinates and is not subject to the current projection.
Definition at line 264 of file GeoPainter.cpp.
MapQuality GeoPainter::mapQuality | ( | ) | const |
Returns the map quality.
- Returns
- The map quality that got assigned to the painter.
Definition at line 191 of file GeoPainter.cpp.
QRegion GeoPainter::regionFromEllipse | ( | const GeoDataCoordinates & | centerPosition, |
qreal | width, | ||
qreal | height, | ||
bool | isGeoProjected = false , |
||
qreal | strokeWidth = 3 |
||
) | const |
Creates a region for an ellipse at a given position.
A QRegion object is created that represents the area covered by GeoPainter::drawEllipse(). As such it can be used e.g. for input event handling for objects that have been painted using GeoPainter::drawEllipse().
The strokeWidth allows to extrude the QRegion by half the amount of "stroke width" pixels. For input event handling it's always advisable to use a width that is slightly bigger than the width of the painter's pen.
- See also
- GeoDataCoordinates
Definition at line 356 of file GeoPainter.cpp.
QRegion GeoPainter::regionFromPoint | ( | const GeoDataCoordinates & | position, |
qreal | strokeWidth = 3 |
||
) | const |
Creates a region for a given geographic position.
A QRegion object is created that represents the area covered by GeoPainter::drawPoint( GeoDataCoordinates ). It can be used e.g. for input event handling of objects that have been painted using GeoPainter::drawPoint( GeoDataCoordinates ).
The width allows to set the "stroke width" for the region. For input event handling it's always advisable to use a width that is slightly bigger than the width of the painter's pen.
- See also
- GeoDataCoordinates
Definition at line 244 of file GeoPainter.cpp.
QRegion GeoPainter::regionFromPoint | ( | const GeoDataPoint & | point, |
qreal | strokeWidth = 3 |
||
) | const |
Create a region for a given geographic position.
A QRegion object is created that represents the area covered by GeoPainter::drawPoint( GeoDataPoint ). It can be used e.g. for input event handling of objects that have been painted using GeoPainter::drawPoint( GeoDataPoint ).
The width allows to set the "stroke width" for the region. For input event handling it's always advisable to use a width that is slightly bigger than the width of the painter's pen.
Definition at line 257 of file GeoPainter.cpp.
QRegion GeoPainter::regionFromPolygon | ( | const GeoDataLinearRing & | linearRing, |
Qt::FillRule | fillRule, | ||
qreal | strokeWidth = 3 |
||
) | const |
Creates a region for a given linear ring (a "polygon without holes").
A QRegion object is created that represents the area covered by GeoPainter::drawPolygon( GeoDataLinearRing ). As such it can be used e.g. for input event handling for objects that have been painted using GeoPainter::drawPolygon( GeoDataLinearRing ).
Like in drawPolygon() the fillRule specifies the fill algorithm that is used to fill the polygon.
The strokeWidth allows to extrude the QRegion by half the amount of "stroke width" pixels. For input event handling it's always advisable to use a width that is slightly bigger than the width of the painter's pen.
For the polygon case a "cosmetic" strokeWidth of zero should provide the best performance.
- See also
- GeoDataLinearRing
Definition at line 585 of file GeoPainter.cpp.
QRegion GeoPainter::regionFromPolyline | ( | const GeoDataLineString & | lineString, |
qreal | strokeWidth = 3 |
||
) | const |
Creates a region for a given line string (a "polyline").
A QRegion object is created that represents the area covered by GeoPainter::drawPolyline( GeoDataLineString ). As such it can be used e.g. for input event handling for objects that have been painted using GeoPainter::drawPolyline( GeoDataLineString ).
The strokeWidth allows to extrude the QRegion by half the amount of "stroke width" pixels. For input event handling it's always advisable to use a width that is slightly bigger than the width of the painter's pen.
- See also
- GeoDataLineString
Definition at line 526 of file GeoPainter.cpp.
QRegion GeoPainter::regionFromRect | ( | const GeoDataCoordinates & | centerPosition, |
qreal | width, | ||
qreal | height, | ||
bool | isGeoProjected = false , |
||
qreal | strokeWidth = 3 |
||
) | const |
Creates a region for a rectangle at a given position.
A QRegion object is created that represents the area covered by GeoPainter::drawRect(). This can be used e.g. for input event handling for objects that have been painted using GeoPainter::drawRect().
The isGeoProjected parameter is used the same way as for GeoPainter::drawRect().
The strokeWidth allows to extrude the QRegion by half the amount of "stroke width" pixels. For input event handling it's always advisable to use a width that is slightly bigger than the width of the painter's pen. This is especially true for small objects.
- See also
- GeoDataCoordinates
Definition at line 726 of file GeoPainter.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:56 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.