1
/***************************************************************************
2
* Copyright (C) 2007 by Kai Winter *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19
***************************************************************************/
26
//! A geometric point to draw objects into maps
28
* This class can be used to draw your custom QPixmap or other QWidgets into maps.
29
* You can instantiate a Point with any Pixmap you want. The objects cares about collision detection (for clickable objects)
31
* When drawing a pixmap, take care you are adding the point to a GeometryLayer.
32
* You can also add a point to a MapLayer, but this should only be done, if the point is not changing its position or color etc.
33
* (GeometryLayers are assured to be repainted on any changes at the point. MapLayers only gets repainted, if a new
34
* offscreenImage is painter. This is a performance issue.)
36
* Points emit click events, if the containing layer receives clickevents (the default)
38
* You can also add a widget into maps. But keep in mind, that widgets always are drawn on top of all layers.
39
* You also have to handle click events yourself.
41
* To create "zoomable objects" (objects that increases size on zooming), a base level have to be set.
42
* The base level is the zoom level on which the point´s pixmap gets displayed on full size.
43
* On lower zoom levels it gets displayed smaller and on higher zoom levels larger.
44
* A minimal size can be set as well as a maximum size.
45
* @see setBaselevel, setMinsize, setMaxsize
47
* @author Kai Winter <kaiwinter@gmx.de>
50
class Point : public Geometry
55
friend class LineString;
57
//! sets where the point should be aligned
60
TopLeft, /*!< Align on TopLeft*/
61
TopRight, /*!< Align on TopRight*/
62
BottomLeft, /*!< Align on BottomLeft*/
63
BottomRight,/*!< Align on BottomRight*/
64
Middle /*!< Align on Middle*/
68
explicit Point(const Point&);
71
* This constructor creates a Point with no image or widget.
74
* @param name name of the point
75
* @param alignment allignment of the point (Middle or TopLeft)
77
Point(double x, double y, QString name = QString(), enum Alignment alignment=Middle);
81
* This constructor creates a point which will display the given widget.
82
* You can set an alignment on which corner the widget should be aligned to the coordinate.
83
* You have to set the size of the widget, before adding it to
84
* IMPORTANT: You have to set the QMapControl as parent for the widget!
87
* @param widget the widget which should be displayed by this point
88
* @param name name of the point
89
* @param alignment allignment of the point (Middle or TopLeft)
91
Point(double x, double y, QWidget* widget, QString name = QString(), enum Alignment alignment = Middle);
95
* This constructor creates a point which will display the give pixmap.
96
* You can set an alignment on which corner the pixmap should be aligned to the coordinate.
99
* @param pixmap the pixmap which should be displayed by this point
100
* @param name name of the point
101
* @param alignment allignment of the point (Middle or TopLeft)
103
Point(double x, double y, QPixmap* pixmap, QString name = QString(), enum Alignment alignment = Middle);
106
//! returns the bounding box of the point
108
* The Bounding contains the coordinate of the point and its size.
109
* The size is set, if the point contains a pixmap or a widget
110
* @return the bounding box of the point
112
virtual QRectF getBoundingBox();
114
//! returns the longitude of the point
116
* @return the longitude of the point
118
double getLongitude() const;
120
//! returns the latitude of the point
122
* @return the latitude of the point
124
double getLatitude() const;
126
//! returns the coordinate of the point
128
* The x component of the returned QPointF is the longitude value,
129
* the y component the latitude
130
* @return the coordinate of a point
132
QPointF getCoordinate() const;
134
virtual QList<Point*> getPoints();
136
/*! \brief returns the widget of the point
137
@return the widget of the point
139
QWidget* getWidget();
141
//! returns the pixmap of the point
143
* @return the pixmap of the point
145
QPixmap* getPixmap();
147
//! Sets the zoom level on which the point´s pixmap gets displayed on full size
149
* Use this method to set a zoom level on which the pixmap gets displayed with its real size.
150
* On zoomlevels below it will be displayed smaller, and on zoom levels thereover it will be displayed larger
151
* @see setMinsize, setMaxsize
152
* @param zoomlevel the zoomlevel on which the point will be displayed on full size
154
void setBaselevel(int zoomlevel);
156
//! sets a minimal size for the pixmap
158
* When the point´s pixmap should change its size on zooming, this method sets the minimal size.
160
* @param minsize the minimal size which the pixmap should have
162
void setMinsize(QSize minsize);
164
//! sets a maximal size for the pixmap
166
* When the point´s pixmap should change its size on zooming, this method sets the maximal size.
168
* @param maxsize the maximal size which the pixmap should have
170
void setMaxsize(QSize maxsize);
172
Point::Alignment getAlignment() const;
188
void drawWidget(const MapAdapter* mapadapter, const QPoint offset);
189
// void drawPixmap(QPainter* painter, const MapAdapter* mapadapter, const QRect &viewport, const QPoint versch);
190
virtual void draw(QPainter* painter, const MapAdapter* mapadapter, const QRect &viewport, const QPoint offset);
191
QPoint getAlignedPoint(const QPoint point) const;
193
//! returns true if the given Point touches this Point
195
* The collision detection checks for the bounding rectangulars.
196
* @param geom the other point which should be tested on collision
197
* @param mapadapter the mapadapter which is used for calculations
200
virtual bool Touches(Point* geom, const MapAdapter* mapadapter);
203
void setCoordinate(QPointF point);
204
virtual void setVisible(bool visible);