dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
tlmapwidget.h
Go to the documentation of this file.
1 
13 /*
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * for more details.
23 *
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, see <http://www.gnu.org/licenses/>
26 */
27 #ifndef TLMAPWIDGET_H
28 #define TLMAPWIDGET_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 "waypointitem.h"
38 #include "QtSvg/QGraphicsSvgItem"
39 #include "uavitem.h"
40 #include "gpsitem.h"
41 #include "homeitem.h"
42 #include "mapripper.h"
43 #include "mapline.h"
44 #include "mapcircle.h"
45 #include "waypointcurve.h"
46 #include "waypointitem.h"
47 #include "../core/corecommon.h"
48 #include <QGraphicsView>
49 
50 namespace mapcontrol
51 {
52  class UAVItem;
53  class GPSItem;
54  class HomeItem;
61  class Helper
62  {
63  public:
70  static MapType::Types MapTypeFromString(QString const& value){return MapType::TypeByStr(value);}
74  static QString StrFromMapType(MapType::Types const& value){return MapType::StrByType(value);}
78  static QStringList MapTypes(){return MapType::TypesList();}
79 
83  static GeoCoderStatusCode::Types GeoCoderStatusCodeFromString(QString const& value){return GeoCoderStatusCode::TypeByStr(value);}
87  static QString StrFromGeoCoderStatusCode(GeoCoderStatusCode::Types const& value){return GeoCoderStatusCode::StrByType(value);}
91  static QStringList GeoCoderTypes(){return GeoCoderStatusCode::TypesList();}
92 
96  static internals::MouseWheelZoomType::Types MouseWheelZoomTypeFromString(QString const& value){return internals::MouseWheelZoomType::TypeByStr(value);}
100  static QString StrFromMouseWheelZoomType(internals::MouseWheelZoomType::Types const& value){return internals::MouseWheelZoomType::StrByType(value);}
104  static QStringList MouseWheelZoomTypes(){return internals::MouseWheelZoomType::TypesList();}
108  static core::LanguageType::Types LanguageTypeFromString(QString const& value){return core::LanguageType::TypeByStr(value);}
112  static QString StrFromLanguageType(core::LanguageType::Types const& value){return core::LanguageType::StrByType(value);}
116  static QStringList LanguageTypes(){return core::LanguageType::TypesList();}
120  static core::AccessMode::Types AccessModeFromString(QString const& value){return core::AccessMode::TypeByStr(value);}
124  static QString StrFromAccessMode(core::AccessMode::Types const& value){return core::AccessMode::StrByType(value);}
128  static QStringList AccessModeTypes(){return core::AccessMode::TypesList();}
129 
133  static UAVMapFollowType::Types UAVMapFollowFromString(QString const& value){return UAVMapFollowType::TypeByStr(value);}
137  static QString StrFromUAVMapFollow(UAVMapFollowType::Types const& value){return UAVMapFollowType::StrByType(value);}
141  static QStringList UAVMapFollowTypes(){return UAVMapFollowType::TypesList();}
145  static UAVTrailType::Types UAVTrailTypeFromString(QString const& value){return UAVTrailType::TypeByStr(value);}
149  static QString StrFromUAVTrailType(UAVTrailType::Types const& value){return UAVTrailType::StrByType(value);}
153  static QStringList UAVTrailTypes(){return UAVTrailType::TypesList();}
154  };
155 
156  class TLMAPWIDGET_EXPORT TLMapWidget:public QGraphicsView
157  {
158  Q_OBJECT
159 
160  Q_PROPERTY(int MinZoom READ MinZoom WRITE SetMinZoom)
161  Q_PROPERTY(bool ShowTileGridLines READ ShowTileGridLines WRITE SetShowTileGridLines)
162  Q_PROPERTY(double Zoom READ ZoomTotal WRITE SetZoom)
163  Q_PROPERTY(qreal Rotate READ Rotate WRITE SetRotate)
164  Q_ENUMS(internals::MouseWheelZoomType::Types)
165  Q_ENUMS(core::GeoCoderStatusCode::Types)
166 
167  public:
168  QSize sizeHint() const;
176  TLMapWidget(QWidget *parent=nullptr,Configuration *config=new Configuration);
177  ~TLMapWidget();
183  bool ShowTileGridLines()const {return map->showTileGridLines;}
184 
191  void SetShowTileGridLines(bool const& value){map->showTileGridLines=value;map->update();}
192 
197  int MaxZoom()const{return map->MaxZoom();}
198 
199  // void SetMaxZoom(int const& value){map->maxZoom = value;}
200 
205  int MinZoom()const{return map->minZoom;}
211  void SetMinZoom(int const& value){map->minZoom = value;}
212 
213  internals::MouseWheelZoomType::Types GetMouseWheelZoomType(){return map->core->GetMouseWheelZoomType();}
214  void SetMouseWheelZoomType(internals::MouseWheelZoomType::Types const& value){map->core->SetMouseWheelZoomType(value);}
215  // void SetMouseWheelZoomTypeByStr(const QString &value){map->core->SetMouseWheelZoomType(internals::MouseWheelZoomType::TypeByStr(value));}
216  // QString GetMouseWheelZoomTypeStr(){return map->GetMouseWheelZoomTypeStr();}
217 
218  internals::RectLatLng SelectedArea()const{return map->selectedArea;}
219  void SetSelectedArea(internals::RectLatLng const& value){ map->selectedArea = value;this->update();}
220 
221  bool CanDragMap()const{return map->CanDragMap();}
222  void SetCanDragMap(bool const& value){map->SetCanDragMap(value);}
223 
224  internals::PointLatLng CurrentPosition()const{return map->core->CurrentPosition();}
225  void SetCurrentPosition(internals::PointLatLng const& value){map->core->SetCurrentPosition(value);}
226 
227  double ZoomReal(){return map->Zoom();}
228  double ZoomDigi(){return map->ZoomDigi();}
229  double ZoomTotal(){return map->ZoomTotal();}
230  void SetZoom(double const& value){map->SetZoom(value);}
231 
232  qreal Rotate(){return map->rotation;}
233  void SetRotate(qreal const& value);
234 
235  void ReloadMap(){map->ReloadMap(); map->resize();}
236 
237  GeoCoderStatusCode::Types SetCurrentPositionByKeywords(QString const& keys){return map->SetCurrentPositionByKeywords(keys);}
238 
239  MapType::Types GetMapType(){return map->core->GetMapType();}
240  void SetMapType(MapType::Types const& value){map->lastimage=QImage(); map->core->SetMapType(value);}
241  void SetUserImageHorizontalScale(double hScale){map->core->SetUserImageHorizontalScale(hScale);}
242  void SetUserImageVerticalScale(double vScale){map->core->SetUserImageVerticalScale(vScale);}
243  void SetUserImageLocation(QString location){map->core->SetUserImageLocation(location);}
244 
245  bool isStarted(){return map->core->isStarted();}
246 
248 
249  internals::PointLatLng currentMousePosition();
250 
251  void SetFollowMouse(bool const& value){followmouse=value;this->setMouseTracking(followmouse);}
252  bool FollowMouse(){return followmouse;}
253 
254  internals::PointLatLng GetFromLocalToLatLng(QPointF p) {return map->FromLocalToLatLng(p.x(),p.y());}
255 
261  WayPointItem* WPCreate();
267  void WPCreate(WayPointItem* item);
275  WayPointItem* WPCreate(internals::PointLatLng const& coord,int const& altitude);
284  WayPointItem* WPCreate(internals::PointLatLng const& coord,int const& altitude, QString const& description);
293  WayPointItem *WPCreate(const distBearingAltitude &relativeCoord, const QString &description);
300  WayPointItem* WPInsert(int const& position);
307  void WPInsert(WayPointItem* item,int const& position);
316  WayPointItem* WPInsert(internals::PointLatLng const& coord,int const& altitude,int const& position);
326  WayPointItem* WPInsert(internals::PointLatLng const& coord,int const& altitude, QString const& description,int const& position);
327  WayPointItem *WPInsert(const distBearingAltitude &relative, const QString &description, const int &position);
328 
334  void WPDelete(WayPointItem* item);
339  void WPDeleteAll();
345  QList<WayPointItem*> WPSelected();
346 
353  void WPRenumber(WayPointItem* item,int const& newnumber);
354 
355  void SetShowCompassRose(bool const& value);
356  void SetShowWindCompass(bool const& value);
357 
358  void setOverlayOpacity(qreal value);
359 
363  void SetShowUAV(bool const& value);
364  bool ShowUAV()const{return showuav;}
365  void SetShowHome(bool const& value);
366  bool ShowHome()const{return showhome;}
367  void SetShowDiagnostics(bool const& value);
368  void SetUavPic(QString UAVPic);
369 
371  MapLine *WPLineCreate(WayPointItem *from,WayPointItem *to, QColor color);
373  MapLine *WPLineCreate(HomeItem *from,WayPointItem *to, QColor color);
375  WayPointCurve *WPCurveCreate(WayPointItem *start, WayPointItem *dest, double radius, bool clockwise, QColor color);
377  MapCircle *WPCircleCreate(WayPointItem *center, WayPointItem *radius,bool clockwise,QColor color);
379  MapCircle *WPCircleCreate(HomeItem *center, WayPointItem *radius,bool clockwise,QColor color);
380 
381  void deleteAllOverlays();
382  void WPSetVisibleAll(bool value);
383  WayPointItem *magicWPCreate();
384  bool WPPresent();
385  void WPDelete(int number);
386  WayPointItem *WPFind(int number);
387  void setSelectedWP(QList<WayPointItem *> list);
388 
389  void setWindVelocity(double windVelocity_NED[3]);
390  private:
391  internals::Core *core;
392  MapGraphicItem *map;
393  GeoCoderStatusCode x;
394  MapType y;
395  core::AccessMode xx;
396  internals::PointLatLng currentmouseposition;
397  bool followmouse;
398  void ConnectWP(WayPointItem* item);
399  QGraphicsSvgItem *compassRose;
400  QGraphicsSvgItem *windCompass;
401  bool showuav;
402  bool showhome;
403  QTimer * diagTimer;
404  QGraphicsTextItem * diagGraphItem;
405  bool showDiag;
406  qreal overlayOpacity;
407 
408  QGraphicsTextItem *windspeedTxt;
409 
410  private slots:
411  void diagRefresh();
412  // WayPointItem* item;//apagar
413  protected:
414  void resizeEvent(QResizeEvent *event);
415  void showEvent ( QShowEvent * event );
416  void closeEvent(QCloseEvent *event);
417  void mouseMoveEvent ( QMouseEvent * event );
418  // private slots:
419  signals:
420  void zoomChanged(double zoomt,double zoom, double zoomd);
428  void WPNumberChanged(int const& oldnumber,int const& newnumber,WayPointItem* waypoint);
434  void WPValuesChanged(WayPointItem* waypoint);
441  void WPReached(WayPointItem* waypoint);
442 
443  void WPCreated(int const& number,WayPointItem* waypoint);
444 
451  void WPInserted(int const& number,WayPointItem* waypoint);
457  void WPDeleted(int const& number,WayPointItem* waypoint);
458 
459  void WPManualCoordChange(WayPointItem*);
465  void UAVReachedWayPoint(int const& waypointnumber,WayPointItem* waypoint);
471  void UAVLeftSafetyBouble(internals::PointLatLng const& position);
472 
478  void OnCurrentPositionChanged(internals::PointLatLng point);
483  void OnTileLoadComplete();
488  void OnTileLoadStart();
493  void OnMapDrag();
498  void OnMapZoomChanged();
504  void OnMapTypeChanged(MapType::Types type);
511  void OnEmptyTileError(int zoom, core::Point pos);
517  void OnTilesStillToLoad(int number);
518  void OnWayPointDoubleClicked(WayPointItem * waypoint);
519  void selectedWPChanged(QList<WayPointItem*>);
520  public slots:
524  void RipMap();
525  void OnSelectionChanged();
526 
527  };
528 }
529 #endif // TLMAPWIDGET_H
static QString StrFromUAVTrailType(UAVTrailType::Types const &value)
Converts from Type to String.
Definition: tlmapwidget.h:149
A graphicsItem representing a WayPoint.
void SetZoom(double const &value)
Definition: tlmapwidget.h:230
A graphicsItem representing a WayPoint.
static MapType::Types MapTypeFromString(QString const &value)
Converts from String to Type.
Definition: tlmapwidget.h:70
void SetMinZoom(int const &value)
Definition: tlmapwidget.h:211
Configuration * configuration
Definition: tlmapwidget.h:247
void SetShowTileGridLines(bool const &value)
Defines if map is to show gridlines.
Definition: tlmapwidget.h:191
void SetMouseWheelZoomType(internals::MouseWheelZoomType::Types const &value)
Definition: tlmapwidget.h:214
MapType::Types GetMapType()
Definition: tlmapwidget.h:239
static QStringList LanguageTypes()
Returns QStringList with string representing all the enum values.
Definition: tlmapwidget.h:116
int MaxZoom() const
Returns the maximum zoom for the map.
Definition: tlmapwidget.h:197
void SetUserImageVerticalScale(double vScale)
Definition: tlmapwidget.h:242
internals::PointLatLng CurrentPosition() const
Definition: tlmapwidget.h:224
void SetFollowMouse(bool const &value)
Definition: tlmapwidget.h:251
static QStringList MouseWheelZoomTypes()
Returns QStringList with string representing all the enum values.
Definition: tlmapwidget.h:104
bool CanDragMap() const
Definition: tlmapwidget.h:221
static QStringList UAVMapFollowTypes()
Returns QStringList with string representing all the enum values.
Definition: tlmapwidget.h:141
static GeoCoderStatusCode::Types GeoCoderStatusCodeFromString(QString const &value)
Converts from String to Type.
Definition: tlmapwidget.h:83
static core::LanguageType::Types LanguageTypeFromString(QString const &value)
Converts from String to Type.
Definition: tlmapwidget.h:108
A graphicsItem representing a line connecting 2 map points.
Collection of static functions to help dealing with various enums used Contains functions for enumToS...
Definition: tlmapwidget.h:61
A class that centralizes most of the mapcontrol configurations.
A class that allows ripping of a selection of the map.
void SetMapType(MapType::Types const &value)
Definition: tlmapwidget.h:240
internals::RectLatLng SelectedArea() const
Definition: tlmapwidget.h:218
A class that centralizes most of the mapcontrol configurations.
Definition: configuration.h:48
A graphicsItem representing a Home Location.
The WayPointCurve class draws an arc between two graphics items of a given radius and direction of cu...
Definition: waypointcurve.h:40
static internals::MouseWheelZoomType::Types MouseWheelZoomTypeFromString(QString const &value)
Converts from String to Type.
Definition: tlmapwidget.h:96
The main graphicsItem used on the widget, contains the map and map logic.
static QString StrFromMapType(MapType::Types const &value)
Converts from Type to String.
Definition: tlmapwidget.h:74
static QString StrFromLanguageType(core::LanguageType::Types const &value)
Converts from Type to String.
Definition: tlmapwidget.h:112
static core::AccessMode::Types AccessModeFromString(QString const &value)
Converts from String to Type.
Definition: tlmapwidget.h:120
internals::MouseWheelZoomType::Types GetMouseWheelZoomType()
Definition: tlmapwidget.h:213
void SetUserImageLocation(QString location)
Definition: tlmapwidget.h:243
A graphicsItem representing a WayPoint.
static UAVTrailType::Types UAVTrailTypeFromString(QString const &value)
Converts from String to Type.
Definition: tlmapwidget.h:145
A QGraphicsItem representing a WayPoint.
Definition: waypointitem.h:41
static QStringList UAVTrailTypes()
Returns QStringList with string representing all the enum values.
Definition: tlmapwidget.h:153
void SetSelectedArea(internals::RectLatLng const &value)
Definition: tlmapwidget.h:219
GeoCoderStatusCode::Types SetCurrentPositionByKeywords(QString const &keys)
Definition: tlmapwidget.h:237
void SetCurrentPosition(internals::PointLatLng const &value)
Definition: tlmapwidget.h:225
Definition: icore.h:39
void SetCanDragMap(bool const &value)
Definition: tlmapwidget.h:222
static UAVMapFollowType::Types UAVMapFollowFromString(QString const &value)
Converts from String to Type.
Definition: tlmapwidget.h:133
x
Definition: OPPlots.m:100
static QStringList GeoCoderTypes()
Returns QStringList with string representing all the enum values.
Definition: tlmapwidget.h:91
void SetUserImageHorizontalScale(double hScale)
Definition: tlmapwidget.h:241
static QString StrFromAccessMode(core::AccessMode::Types const &value)
Converts from Type to String.
Definition: tlmapwidget.h:124
bool ShowHome() const
Definition: tlmapwidget.h:366
static QString StrFromUAVMapFollow(UAVMapFollowType::Types const &value)
Converts from Type to String.
Definition: tlmapwidget.h:137
static QStringList AccessModeTypes()
Returns QStringList with string representing all the enum values.
Definition: tlmapwidget.h:128
bool ShowUAV() const
Definition: tlmapwidget.h:364
static QStringList MapTypes()
Returns QStringList with string representing all the enum values.
Definition: tlmapwidget.h:78
A QGraphicsItem representing the UAV.
Definition: uavitem.h:48
static QString StrFromMouseWheelZoomType(internals::MouseWheelZoomType::Types const &value)
Converts from Type to String.
Definition: tlmapwidget.h:100
static QString StrFromGeoCoderStatusCode(GeoCoderStatusCode::Types const &value)
Converts from Type to String.
Definition: tlmapwidget.h:87
A graphicsItem representing a curve connecting 2 waypoints.
A graphicsItem representing a circle connecting 2 map point.
internals::PointLatLng GetFromLocalToLatLng(QPointF p)
Definition: tlmapwidget.h:254
y
Definition: OPPlots.m:101