map2d_widget
opmapwidget.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 OPMAPWIDGET_H
28 #define OPMAPWIDGET_H
29 
30 #include "../mapwidget/mapgraphicitem.h"
31 #include "../core/geodecoderstatus.h"
32 #include "../core/maptype.h"
33 #include "../core/languagetype.h"
34 #include "../core/diagnostics.h"
35 #include "configuration.h"
36 #include <QObject>
37 #include <QtOpenGL/QGLWidget>
38 #include "waypointitem.h"
39 #include "QtSvg/QGraphicsSvgItem"
40 #include "uavitem.h"
41 #include "gpsitem.h"
42 #include "homeitem.h"
43 #include "mapripper.h"
44 namespace mapcontrol
45 {
46  class UAVItem;
47  class GPSItem;
48  class HomeItem;
55  class Helper
56  {
57  public:
64  static MapType::Types MapTypeFromString(QString const& value){return MapType::TypeByStr(value);}
68  static QString StrFromMapType(MapType::Types const& value){return MapType::StrByType(value);}
72  static QStringList MapTypes(){return MapType::TypesList();}
73 
77  static GeoCoderStatusCode::Types GeoCoderStatusCodeFromString(QString const& value){return GeoCoderStatusCode::TypeByStr(value);}
81  static QString StrFromGeoCoderStatusCode(GeoCoderStatusCode::Types const& value){return GeoCoderStatusCode::StrByType(value);}
85  static QStringList GeoCoderTypes(){return GeoCoderStatusCode::TypesList();}
86 
110  static QStringList LanguageTypes(){return core::LanguageType::TypesList();}
114  static core::AccessMode::Types AccessModeFromString(QString const& value){return core::AccessMode::TypeByStr(value);}
118  static QString StrFromAccessMode(core::AccessMode::Types const& value){return core::AccessMode::StrByType(value);}
122  static QStringList AccessModeTypes(){return core::AccessMode::TypesList();}
123 
131  static QString StrFromUAVMapFollow(UAVMapFollowType::Types const& value){return UAVMapFollowType::StrByType(value);}
135  static QStringList UAVMapFollowTypes(){return UAVMapFollowType::TypesList();}
139  static UAVTrailType::Types UAVTrailTypeFromString(QString const& value){return UAVTrailType::TypeByStr(value);}
143  static QString StrFromUAVTrailType(UAVTrailType::Types const& value){return UAVTrailType::StrByType(value);}
147  static QStringList UAVTrailTypes(){return UAVTrailType::TypesList();}
148  };
149 
150  class OPMapWidget:public QGraphicsView
151  {
152  Q_OBJECT
153 
154  // Q_PROPERTY(int MaxZoom READ MaxZoom WRITE SetMaxZoom)
155  Q_PROPERTY(int MinZoom READ MinZoom WRITE SetMinZoom)
157  Q_PROPERTY(double Zoom READ ZoomTotal WRITE SetZoom)
158  Q_PROPERTY(qreal Rotate READ Rotate WRITE SetRotate)
159  Q_ENUMS(internals::MouseWheelZoomType::Types)
160  Q_ENUMS(internals::GeoCoderStatusCode::Types)
161 
162  public:
163  QSize sizeHint() const;
171  OPMapWidget(QWidget *parent=0,Configuration *config=new Configuration);
172  ~OPMapWidget();
173 
179  bool ShowTileGridLines()const {return map->showTileGridLines;}
180 
187  void SetShowTileGridLines(bool const& value){map->showTileGridLines=value;map->update();}
188 
193  int MaxZoom()const{return map->MaxZoom();}
194 
195  // void SetMaxZoom(int const& value){map->maxZoom = value;}
196 
201  int MinZoom()const{return map->minZoom;}
207  void SetMinZoom(int const& value){map->minZoom = value;}
208 
211  // void SetMouseWheelZoomTypeByStr(const QString &value){map->core->SetMouseWheelZoomType(internals::MouseWheelZoomType::TypeByStr(value));}
212  // QString GetMouseWheelZoomTypeStr(){return map->GetMouseWheelZoomTypeStr();}
213 
214  internals::RectLatLng SelectedArea()const{return map->selectedArea;}
215  void SetSelectedArea(internals::RectLatLng const& value){ map->selectedArea = value;this->update();}
216 
217  bool CanDragMap()const{return map->CanDragMap();}
218  void SetCanDragMap(bool const& value){map->SetCanDragMap(value);}
219 
221  void SetCurrentPosition(internals::PointLatLng const& value){map->core->SetCurrentPosition(value);}
222 
223  double ZoomReal(){return map->Zoom();}
224  double ZoomDigi(){return map->ZoomDigi();}
225  double ZoomTotal(){return map->ZoomTotal();}
226  void SetZoom(double const& value){map->SetZoom(value);}
227 
228  qreal Rotate(){return map->rotation;}
229  void SetRotate(qreal const& value);
230 
231  void ReloadMap(){map->ReloadMap(); map->resize();}
232 
233  GeoCoderStatusCode::Types SetCurrentPositionByKeywords(QString const& keys){return map->SetCurrentPositionByKeywords(keys);}
234 
235  bool UseOpenGL(){return useOpenGL;}
236  void SetUseOpenGL(bool const& value);
237 
238  MapType::Types GetMapType(){return map->core->GetMapType();}
239  void SetMapType(MapType::Types const& value){map->lastimage=QImage(); map->core->SetMapType(value);}
240 
241  bool isStarted(){return map->core->isStarted();}
242 
244 
246 
247  void SetFollowMouse(bool const& value){followmouse=value;this->setMouseTracking(followmouse);}
248  bool FollowMouse(){return followmouse;}
249 
250  internals::PointLatLng GetFromLocalToLatLng(QPointF p) {return map->FromLocalToLatLng(p.x(),p.y());}
251 
263  void WPCreate(WayPointItem* item);
271  WayPointItem* WPCreate(internals::PointLatLng const& coord,int const& altitude);
280  WayPointItem* WPCreate(internals::PointLatLng const& coord,int const& altitude, QString const& description);
287  WayPointItem* WPInsert(int const& position);
294  void WPInsert(WayPointItem* item,int const& position);
303  WayPointItem* WPInsert(internals::PointLatLng const& coord,int const& altitude,int const& position);
313  WayPointItem* WPInsert(internals::PointLatLng const& coord,int const& altitude, QString const& description,int const& position);
314 
320  void WPDelete(WayPointItem* item);
325  void WPDeleteAll();
331  QList<WayPointItem*> WPSelected();
332 
339  void WPRenumber(WayPointItem* item,int const& newnumber);
340 
341  void SetShowCompass(bool const& value);
342 
346  void SetShowUAV(bool const& value);
347  bool ShowUAV()const{return showuav;}
348  void SetShowHome(bool const& value);
349  bool ShowHome()const{return showhome;}
350  void SetShowDiagnostics(bool const& value);
351  void SetUavPic(QString UAVPic);
352  private:
353  internals::Core *core;
354  MapGraphicItem *map;
355  QGraphicsScene mscene;
356  bool useOpenGL;
358  MapType y;
359  core::AccessMode xx;
360  internals::PointLatLng currentmouseposition;
361  bool followmouse;
362  void ConnectWP(WayPointItem* item);
363  QGraphicsSvgItem *compass;
364  bool showuav;
365  bool showhome;
366  QTimer * diagTimer;
367  QGraphicsTextItem * diagGraphItem;
368  bool showDiag;
369  private slots:
370  void diagRefresh();
371  // WayPointItem* item;//apagar
372  protected:
373  void resizeEvent(QResizeEvent *event);
374  void showEvent ( QShowEvent * event );
375  void closeEvent(QCloseEvent *event);
376  void mouseMoveEvent ( QMouseEvent * event );
377  // private slots:
378  signals:
379  void zoomChanged(double zoomt,double zoom, double zoomd);
387  void WPNumberChanged(int const& oldnumber,int const& newnumber,WayPointItem* waypoint);
393  void WPValuesChanged(WayPointItem* waypoint);
400  void WPReached(WayPointItem* waypoint);
407  void WPInserted(int const& number,WayPointItem* waypoint);
413  void WPDeleted(int const& number);
419  void UAVReachedWayPoint(int const& waypointnumber,WayPointItem* waypoint);
425  void UAVLeftSafetyBouble(internals::PointLatLng const& position);
426 
437  void OnTileLoadComplete();
442  void OnTileLoadStart();
447  void OnMapDrag();
452  void OnMapZoomChanged();
458  void OnMapTypeChanged(MapType::Types type);
465  void OnEmptyTileError(int zoom, core::Point pos);
471  void OnTilesStillToLoad(int number);
472  public slots:
476  void RipMap();
477 
478  };
479 }
480 #endif // OPMAPWIDGET_H
Definition: opmapwidget.h:150
void SetUseOpenGL(bool const &value)
Definition: opmapwidget.cpp:179
int MaxZoom() const
Returns the maximum zoom for the map.
Definition: opmapwidget.h:193
A graphicsItem representing a WayPoint.
double ZoomDigi()
Definition: opmapwidget.h:224
A graphicsItem representing a WayPoint.
bool CanDragMap() const
Definition: opmapwidget.h:217
static QString StrByType(Types const &value)
Definition: mousewheelzoomtype.h:58
static QStringList LanguageTypes()
Returns QStringList with string representing all the enum values.
Definition: opmapwidget.h:110
static QString StrFromUAVMapFollow(UAVMapFollowType::Types const &value)
Converts from Type to String.
Definition: opmapwidget.h:131
void SetUavPic(QString UAVPic)
Definition: opmapwidget.cpp:82
bool isStarted()
Definition: core.h:193
double Zoom()
Definition: mapgraphicitem.cpp:469
static QString StrFromLanguageType(core::LanguageType::Types const &value)
Converts from Type to String.
Definition: opmapwidget.h:106
void OnTilesStillToLoad(int number)
Fires when the number of tiles in the load queue changes.
static internals::MouseWheelZoomType::Types MouseWheelZoomTypeFromString(QString const &value)
Converts from String to Type.
Definition: opmapwidget.h:90
void RipMap()
Ripps the current selection to the DB.
Definition: opmapwidget.cpp:352
void WPDeleted(int const &number)
Fires When a WayPoint is deleted.
double Zoom
Definition: opmapwidget.h:157
Definition: rectlatlng.h:37
void SetRotate(qreal const &value)
Definition: opmapwidget.cpp:345
static MapType::Types MapTypeFromString(QString const &value)
Converts from String to Type.
Definition: opmapwidget.h:64
A QGraphicsItem representing a WayPoint.
Definition: waypointitem.h:43
QList< WayPointItem * > WPSelected()
Returns the currently selected WayPoints.
Definition: opmapwidget.cpp:276
void WPDeleteAll()
deletes all WayPoints
Definition: opmapwidget.cpp:267
void mouseMoveEvent(QMouseEvent *event)
Definition: opmapwidget.cpp:193
Types
Definition: maptype.h:39
A QGraphicsItem representing the UAV.
Definition: uavitem.h:52
static Types TypeByStr(QString const &value)
Definition: mousewheelzoomtype.h:65
void OnCurrentPositionChanged(internals::PointLatLng point)
Fires when map position changes.
void SetShowCompass(bool const &value)
Definition: opmapwidget.cpp:324
void OnTileLoadComplete()
Fires when there are no more tiles to load.
bool ShowUAV() const
Definition: opmapwidget.h:347
bool ShowTileGridLines() const
Returns true if map is showing gridlines.
Definition: opmapwidget.h:179
void resizeEvent(QResizeEvent *event)
Definition: opmapwidget.cpp:142
void OnMapTypeChanged(MapType::Types type)
Fires when map type changes.
void SetCanDragMap(bool const &value)
Definition: opmapwidget.h:218
static QString StrByType(Types const &value)
Definition: uavtrailtype.h:61
void SetCurrentPosition(internals::PointLatLng const &value)
Definition: opmapwidget.h:221
static Types TypeByStr(QString const &value)
Definition: uavtrailtype.h:68
void zoomChanged(double zoomt, double zoom, double zoomd)
Definition: pointlatlng.h:35
static GeoCoderStatusCode::Types GeoCoderStatusCodeFromString(QString const &value)
Converts from String to Type.
Definition: opmapwidget.h:77
QImage lastimage
Definition: mapgraphicitem.h:94
MapType::Types GetMapType()
Definition: core.h:150
void WPRenumber(WayPointItem *item, int const &newnumber)
Renumbers the WayPoint and all others as needed.
Definition: opmapwidget.cpp:287
Definition: core.h:68
Types
Definition: uavtrailtype.h:40
WayPointItem * WPInsert(int const &position)
Inserts a new WayPoint on the specified position.
Definition: opmapwidget.cpp:227
void ReloadMap()
Definition: opmapwidget.h:231
Configuration * configuration
Definition: opmapwidget.h:243
Types
Definition: languagetype.h:42
bool ShowHome() const
Definition: opmapwidget.h:349
void SetSelectedArea(internals::RectLatLng const &value)
Definition: opmapwidget.h:215
void WPDelete(WayPointItem *item)
Deletes the WayPoint.
Definition: opmapwidget.cpp:262
internals::PointLatLng FromLocalToLatLng(int x, int y)
Converts from local item coordinates to LatLong point.
Definition: mapgraphicitem.cpp:456
MouseWheelZoomType::Types GetMouseWheelZoomType()
Definition: core.h:106
void SetMouseWheelZoomType(internals::MouseWheelZoomType::Types const &value)
Definition: opmapwidget.h:210
static QString StrFromGeoCoderStatusCode(GeoCoderStatusCode::Types const &value)
Converts from Type to String.
Definition: opmapwidget.h:81
Types
Definition: mousewheelzoomtype.h:40
static QStringList AccessModeTypes()
Returns QStringList with string representing all the enum values.
Definition: opmapwidget.h:122
Definition: point.h:35
void SetMinZoom(int const &value)
Definition: opmapwidget.h:207
void SetFollowMouse(bool const &value)
Definition: opmapwidget.h:247
Definition: homeitem.h:39
void WPInserted(int const &number, WayPointItem *waypoint)
Fires when a new WayPoint is inserted.
static QString StrByType(Types const &value)
Definition: accessmode.h:58
bool isStarted()
Definition: opmapwidget.h:241
void SetShowDiagnostics(bool const &value)
Definition: opmapwidget.cpp:58
double ZoomTotal()
Definition: opmapwidget.h:225
double ZoomReal()
Definition: opmapwidget.h:223
static UAVMapFollowType::Types UAVMapFollowFromString(QString const &value)
Converts from String to Type.
Definition: opmapwidget.h:127
A class that centralizes most of the mapcontrol configurations.
A class that allows ripping of a selection of the map.
void OnTileLoadStart()
Fires when tiles loading begins.
static QString StrFromMapType(MapType::Types const &value)
Converts from Type to String.
Definition: opmapwidget.h:68
GeoCoderStatusCode::Types SetCurrentPositionByKeywords(QString const &keys)
Definition: opmapwidget.h:233
void showEvent(QShowEvent *event)
Definition: opmapwidget.cpp:156
static Types TypeByStr(QString const &value)
Definition: uavmapfollowtype.h:64
void resize(QRectF const &rect=QRectF())
To be called when the scene size changes.
Definition: mapgraphicitem.cpp:53
A graphicsItem representing a WayPoint.
A class that centralizes most of the mapcontrol configurations.
Definition: configuration.h:46
void SetShowUAV(bool const &value)
Definition: opmapwidget.cpp:91
Types
Definition: geodecoderstatus.h:40
Types
Definition: uavmapfollowtype.h:40
static QStringList UAVTrailTypes()
Returns QStringList with string representing all the enum values.
Definition: opmapwidget.h:147
PointLatLng CurrentPosition() const
Definition: core.h:78
static QStringList TypesList()
Definition: accessmode.h:72
void SetCurrentPosition(const PointLatLng &value)
Definition: core.cpp:261
Collection of static functions to help dealing with various enums used Contains functions for enumToS...
Definition: opmapwidget.h:55
bool FollowMouse()
Definition: opmapwidget.h:248
Definition: maptype.h:34
void UAVLeftSafetyBouble(internals::PointLatLng const &position)
Fires When the UAV lives the safety bouble.
static QStringList GeoCoderTypes()
Returns QStringList with string representing all the enum values.
Definition: opmapwidget.h:85
static core::AccessMode::Types AccessModeFromString(QString const &value)
Converts from String to Type.
Definition: opmapwidget.h:114
internals::PointLatLng CurrentPosition() const
Definition: opmapwidget.h:220
UAVItem * UAV
Definition: opmapwidget.h:343
qreal Rotate()
Definition: opmapwidget.h:228
void SetShowTileGridLines(bool const &value)
Defines if map is to show gridlines.
Definition: opmapwidget.h:187
static QStringList TypesList()
Definition: languagetype.h:114
double ZoomTotal()
Definition: mapgraphicitem.cpp:477
GPSItem * GPS
Definition: opmapwidget.h:344
void SetShowHome(bool const &value)
Definition: opmapwidget.cpp:124
Types
Definition: accessmode.h:41
QSize sizeHint() const
Definition: opmapwidget.cpp:152
HomeItem * Home
Definition: opmapwidget.h:345
internals::MouseWheelZoomType::Types GetMouseWheelZoomType()
Definition: opmapwidget.h:209
void SetMouseWheelZoomType(const MouseWheelZoomType::Types &value)
Definition: core.h:107
static QStringList TypesList()
Definition: uavmapfollowtype.h:71
static QString StrByType(Types const &value)
Definition: languagetype.h:100
internals::RectLatLng SelectedArea() const
Definition: opmapwidget.h:214
void OnMapDrag()
Fires when the map is dragged.
bool UseOpenGL()
Definition: opmapwidget.h:235
static Types TypeByStr(QString const &value)
Definition: accessmode.h:65
void SetMapType(MapType::Types const &value)
Definition: core.cpp:285
A graphicsItem representing a WayPoint.
static QStringList TypesList()
Definition: mousewheelzoomtype.h:72
Definition: accessmode.h:36
double ZoomDigi()
Definition: mapgraphicitem.cpp:473
void WPValuesChanged(WayPointItem *waypoint)
Fired when the description, altitude or coordinates of a WayPoint changed.
Definition: geodecoderstatus.h:35
void SetZoom(double const &value)
Definition: opmapwidget.h:226
static QStringList TypesList()
Definition: uavtrailtype.h:75
static Types TypeByStr(QString const &value)
Definition: languagetype.h:107
static QString StrFromMouseWheelZoomType(internals::MouseWheelZoomType::Types const &value)
Converts from Type to String.
Definition: opmapwidget.h:94
void WPNumberChanged(int const &oldnumber, int const &newnumber, WayPointItem *waypoint)
fires when one of the WayPoints numbers changes (not fired if due to a auto-renumbering) ...
void UAVReachedWayPoint(int const &waypointnumber, WayPointItem *waypoint)
Fires When a WayPoint is Reached.
static QString StrByType(Types const &value)
Definition: uavmapfollowtype.h:57
static core::LanguageType::Types LanguageTypeFromString(QString const &value)
Converts from String to Type.
Definition: opmapwidget.h:102
Definition: gpsitem.h:52
WayPointItem * WPCreate()
Creates a new WayPoint on the center of the map.
Definition: opmapwidget.cpp:201
void OnEmptyTileError(int zoom, core::Point pos)
Fires when an error ocurred while loading a tile.
static QStringList UAVMapFollowTypes()
Returns QStringList with string representing all the enum values.
Definition: opmapwidget.h:135
static QStringList MouseWheelZoomTypes()
Returns QStringList with string representing all the enum values.
Definition: opmapwidget.h:98
static QStringList MapTypes()
Returns QStringList with string representing all the enum values.
Definition: opmapwidget.h:72
The main graphicsItem used on the widget, contains the map and map logic.
Definition: mapgraphicitem.h:51
void SetMapType(MapType::Types const &value)
Definition: opmapwidget.h:239
internals::PointLatLng currentMousePosition()
Definition: opmapwidget.cpp:188
internals::PointLatLng GetFromLocalToLatLng(QPointF p)
Definition: opmapwidget.h:250
static QString StrFromAccessMode(core::AccessMode::Types const &value)
Converts from Type to String.
Definition: opmapwidget.h:118
void OnMapZoomChanged()
Fires when map zoom changes.
static QString StrFromUAVTrailType(UAVTrailType::Types const &value)
Converts from Type to String.
Definition: opmapwidget.h:143
MapType::Types GetMapType()
Definition: opmapwidget.h:238
static UAVTrailType::Types UAVTrailTypeFromString(QString const &value)
Converts from String to Type.
Definition: opmapwidget.h:139
void closeEvent(QCloseEvent *event)
Definition: opmapwidget.cpp:174
void WPReached(WayPointItem *waypoint)
Fires when a new WayPoint is inserted.
int MinZoom() const
Definition: opmapwidget.h:201