map2d_widget
gpsitem.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 GPSITEM_H
28 #define GPSITEM_H
29 
30 #include <QGraphicsItem>
31 #include <QPainter>
32 #include <QLabel>
33 #include "../internals/pointlatlng.h"
34 #include "mapgraphicitem.h"
35 #include "waypointitem.h"
36 #include <QObject>
37 #include "uavmapfollowtype.h"
38 #include "uavtrailtype.h"
39 #include <QtSvg/QSvgRenderer>
40 #include "opmapwidget.h"
41 #include "trailitem.h"
42 #include "traillineitem.h"
43 namespace mapcontrol
44 {
45  class WayPointItem;
46  class OPMapWidget;
52  class GPSItem:public QObject,public QGraphicsItem
53  {
54  Q_OBJECT
55  Q_INTERFACES(QGraphicsItem)
56  public:
57  enum { Type = UserType + 6 };
58  GPSItem(MapGraphicItem* map,OPMapWidget* parent, QString uavPic=QString::fromUtf8(":/uavs/images/mapquad.png"));
59  ~GPSItem();
66  void SetUAVPos(internals::PointLatLng const& position,int const& altitude);
72  void SetUAVHeading(qreal const& value);
78  internals::PointLatLng UAVPos()const{return coord;}
84  void SetMapFollowType(UAVMapFollowType::Types const& value){mapfollowtype=value;}
90  void SetTrailType(UAVTrailType::Types const& value);
96  UAVMapFollowType::Types GetMapFollowType()const{return mapfollowtype;}
102  UAVTrailType::Types GetTrailType()const{return trailtype;}
103 
104  void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
105  QWidget *widget);
106  void RefreshPos();
107  QRectF boundingRect() const;
114  void SetTrailTime(int const& seconds){trailtime=seconds;}
121  int TrailTime()const{return trailtime;}
130  void SetTrailDistance(int const& distance){traildistance=distance;}
139  int TrailDistance()const{return traildistance;}
145  bool ShowTrail()const{return showtrail;}
151  bool ShowTrailLine()const{return showtrailline;}
157  void SetShowTrail(bool const& value);
163  void SetShowTrailLine(bool const& value);
167  void DeleteTrail()const;
173  bool AutoSetReached()const{return autosetreached;}
179  void SetAutoSetReached(bool const& value){autosetreached=value;}
185  double AutoSetDistance()const{return autosetdistance;}
191  void SetAutoSetDistance(double const& value){autosetdistance=value;}
192 
193  int type() const;
194 
195  void SetUavPic(QString UAVPic);
196  private:
197  MapGraphicItem* map;
198 
199  int altitude;
200  UAVMapFollowType::Types mapfollowtype;
201  UAVTrailType::Types trailtype;
203  internals::PointLatLng lastcoord;
204  QPixmap pic;
205  core::Point localposition;
206  OPMapWidget* mapwidget;
207  QGraphicsItemGroup* trail;
208  QGraphicsItemGroup * trailLine;
209  internals::PointLatLng lasttrailline;
210  QTime timer;
211  bool showtrail;
212  bool showtrailline;
213  int trailtime;
214  int traildistance;
215  bool autosetreached;
216  double Distance3D(internals::PointLatLng const& coord, int const& altitude);
217  double autosetdistance;
218  // QRectF rect;
219 
220  public slots:
221 
222  signals:
223  void UAVReachedWayPoint(int const& waypointnumber,WayPointItem* waypoint);
224  void UAVLeftSafetyBouble(internals::PointLatLng const& position);
225  };
226 }
227 #endif // GPSITEM_H
Definition: opmapwidget.h:150
A graphicsItem representing a WayPoint.
QRectF boundingRect() const
Definition: gpsitem.cpp:62
void SetUAVHeading(qreal const &value)
Sets the UAV heading.
Definition: gpsitem.cpp:149
void SetShowTrailLine(bool const &value)
Used to define if the UAV displays a trail line.
Definition: gpsitem.cpp:198
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
Definition: gpsitem.cpp:54
A QGraphicsItem representing a WayPoint.
Definition: waypointitem.h:43
A graphicsItem representing a WayPoint.
internals::PointLatLng UAVPos() const
Returns the UAV position.
Definition: gpsitem.h:78
void SetTrailDistance(int const &distance)
Sets the trail distance to be used if TrailType is ByDistance.
Definition: gpsitem.h:130
Definition: pointlatlng.h:35
int TrailDistance() const
Returns the UAV trail plot distance. If the trail type is distance diference a trail dot is plotted i...
Definition: gpsitem.h:139
The Map Widget, this is the part exposed to the user.
UAVTrailType::Types GetTrailType() const
Returns the UAV trail type. It can be plotted by time elapsed or distance.
Definition: gpsitem.h:102
Types
Definition: uavtrailtype.h:40
void SetShowTrail(bool const &value)
Used to define if the UAV displays a trail.
Definition: gpsitem.cpp:192
void SetUAVPos(internals::PointLatLng const &position, int const &altitude)
Sets the UAV position.
Definition: gpsitem.cpp:66
void SetTrailType(UAVTrailType::Types const &value)
Sets the trail type.
Definition: gpsitem.cpp:186
Definition: point.h:35
The main graphicsItem used on the widget, contains the map and map logic.
void UAVReachedWayPoint(int const &waypointnumber, WayPointItem *waypoint)
int type() const
Definition: gpsitem.cpp:162
bool AutoSetReached() const
Returns true if the UAV automaticaly sets WP reached value (changing its color)
Definition: gpsitem.h:173
A graphicsItem representing a WayPoint.
An enum representing the uav trailing modes.
void SetUavPic(QString UAVPic)
Definition: gpsitem.cpp:216
Types
Definition: uavmapfollowtype.h:40
int TrailTime() const
Returns the UAV trail time elapsed value. If the trail type is time elapsed a trail point will be plo...
Definition: gpsitem.h:121
void SetAutoSetReached(bool const &value)
Defines if the UAV can set the WP&#39;s "reached" value automaticaly.
Definition: gpsitem.h:179
double AutoSetDistance() const
Returns the 3D distance in meters necessary for the UAV to set WP&#39;s to "reached". ...
Definition: gpsitem.h:185
bool ShowTrail() const
Returns true if UAV trail is shown.
Definition: gpsitem.h:145
UAVMapFollowType::Types GetMapFollowType() const
Returns the map follow method used.
Definition: gpsitem.h:96
~GPSItem()
Definition: gpsitem.cpp:49
void SetAutoSetDistance(double const &value)
Sets the the 3D distance in meters necessary for the UAV to set WP&#39;s to "reached".
Definition: gpsitem.h:191
void UAVLeftSafetyBouble(internals::PointLatLng const &position)
bool ShowTrailLine() const
Returns true if UAV trail line is shown.
Definition: gpsitem.h:151
An enum representing the various map follow modes.
GPSItem(MapGraphicItem *map, OPMapWidget *parent, QString uavPic=QString::fromUtf8(":/uavs/images/mapquad.png"))
Definition: gpsitem.cpp:31
Definition: gpsitem.h:57
void SetMapFollowType(UAVMapFollowType::Types const &value)
Sets the Map follow type.
Definition: gpsitem.h:84
Definition: gpsitem.h:52
void SetTrailTime(int const &seconds)
Sets the trail time to be used if TrailType is ByTimeElapsed.
Definition: gpsitem.h:114
void RefreshPos()
Definition: gpsitem.cpp:168
The main graphicsItem used on the widget, contains the map and map logic.
Definition: mapgraphicitem.h:51
Definition: core.h:60
void DeleteTrail() const
Deletes all the trail points.
Definition: gpsitem.cpp:203