map2d_widget
waypointitem.h
Go to the documentation of this file.
1 
12 /*
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * for more details.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 */
27 #ifndef WAYPOINTITEM_H
28 #define WAYPOINTITEM_H
29 
30 #include <QGraphicsItem>
31 #include <QPainter>
32 #include <QLabel>
33 #include "../internals/pointlatlng.h"
34 #include "mapgraphicitem.h"
35 #include <QObject>
36 namespace mapcontrol
37 {
43 class WayPointItem:public QObject,public QGraphicsItem
44 {
45  Q_OBJECT
46  Q_INTERFACES(QGraphicsItem)
47 public:
48  enum { Type = UserType + 1 };
57  WayPointItem(internals::PointLatLng const& coord,int const& altitude,MapGraphicItem* map);
67  WayPointItem(internals::PointLatLng const& coord,int const& altitude,QString const& description,MapGraphicItem* map);
73  QString Description(){return description;}
79  void SetDescription(QString const& value);
85  bool Reached(){return reached;}
91  void SetReached(bool const& value);
96  int Number(){return number;}
102  void SetNumber(int const& value);
107  internals::PointLatLng Coord(){return coord;}
113  void SetCoord(internals::PointLatLng const& value);
118  bool ShowNumber(){return shownumber;}
124  void SetShowNumber(bool const& value);
130  int Altitude(){return altitude;}
136  void SetAltitude(int const& value);
137  int type() const;
138  QRectF boundingRect() const;
139  void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
140  QWidget *widget);
141  void RefreshPos();
142  void RefreshToolTip();
143  QPixmap picture;
144 ~WayPointItem();
145 
146  static int snumber;
147 protected:
148  void mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
149  void mousePressEvent ( QGraphicsSceneMouseEvent * event );
150  void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
151 
152 
153 private:
154  internals::PointLatLng coord;//coordinates of this WayPoint
155  bool reached;
156  QString description;
157  bool shownumber;
158  bool isDragging;
159  int altitude;
160  MapGraphicItem* map;
161  int number;
162 
163 
164  QGraphicsSimpleTextItem* text;
165  QGraphicsRectItem* textBG;
166  QGraphicsSimpleTextItem* numberI;
167  QGraphicsRectItem* numberIBG;
168  QTransform transf;
169 
170 public slots:
176  void WPDeleted(int const& number);
184  void WPRenumbered(int const& oldnumber,int const& newnumber,WayPointItem* waypoint);
191  void WPInserted(int const& number,WayPointItem* waypoint);
192 signals:
200  void WPNumberChanged(int const& oldnumber,int const& newnumber,WayPointItem* waypoint);
206  void WPValuesChanged(WayPointItem* waypoint);
207 
208 };
209 }
210 #endif // WAYPOINTITEM_H
void SetDescription(QString const &value)
Sets the WayPoint description.
Definition: waypointitem.cpp:140
void mousePressEvent(QGraphicsSceneMouseEvent *event)
Definition: waypointitem.cpp:75
A QGraphicsItem representing a WayPoint.
Definition: waypointitem.h:43
WayPointItem(internals::PointLatLng const &coord, int const &altitude, MapGraphicItem *map)
Constructer.
Definition: waypointitem.cpp:30
void WPValuesChanged(WayPointItem *waypoint)
Fired when the description, altitude or coordinates change.
Definition: waypointitem.h:48
void WPDeleted(int const &number)
Called when a WayPoint is deleted.
Definition: waypointitem.cpp:190
void RefreshToolTip()
Definition: waypointitem.cpp:250
void SetShowNumber(bool const &value)
Used to set if WayPoint number is to be drawn on screen.
Definition: waypointitem.cpp:167
void SetReached(bool const &value)
Sets if WayPoint is Reached.
Definition: waypointitem.cpp:156
Definition: pointlatlng.h:35
bool ShowNumber()
Used if WayPoint number is to be drawn on screen.
Definition: waypointitem.h:118
void SetNumber(int const &value)
Sets WayPoint number.
Definition: waypointitem.cpp:147
The main graphicsItem used on the widget, contains the map and map logic.
void WPNumberChanged(int const &oldnumber, int const &newnumber, WayPointItem *waypoint)
fires when this WayPoint number changes (not fired if due to a auto-renumbering)
int Altitude()
Returns the WayPoint altitude.
Definition: waypointitem.h:130
void SetAltitude(int const &value)
Sets the WayPoint Altitude.
Definition: waypointitem.cpp:124
internals::PointLatLng Coord()
Returns WayPoint LatLng coordinate.
Definition: waypointitem.h:107
QRectF boundingRect() const
Definition: waypointitem.cpp:63
QString Description()
Returns the WayPoint description.
Definition: waypointitem.h:73
~WayPointItem()
Definition: waypointitem.cpp:241
int Number()
Returns the WayPoint number.
Definition: waypointitem.h:96
void WPRenumbered(int const &oldnumber, int const &newnumber, WayPointItem *waypoint)
Called when a WayPoint is renumbered.
Definition: waypointitem.cpp:208
void WPInserted(int const &number, WayPointItem *waypoint)
Called when a WayPoint is inserted.
Definition: waypointitem.cpp:198
void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
Definition: waypointitem.cpp:110
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
Definition: waypointitem.cpp:67
void SetCoord(internals::PointLatLng const &value)
Sets WayPoint LatLng coordinate.
Definition: waypointitem.cpp:132
int type() const
Definition: waypointitem.cpp:235
void RefreshPos()
Definition: waypointitem.cpp:245
QPixmap picture
Definition: waypointitem.h:143
The main graphicsItem used on the widget, contains the map and map logic.
Definition: mapgraphicitem.h:51
Definition: core.h:60
bool Reached()
Returns true if WayPoint is Reached.
Definition: waypointitem.h:85
static int snumber
Definition: waypointitem.h:146
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
Definition: waypointitem.cpp:96