dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
opmapgadgetwidget.h
Go to the documentation of this file.
1 
15 /*
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation; either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful, but
22  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24  * for more details.
25  *
26  * You should have received a copy of the GNU General Public License along
27  * with this program; if not, see <http://www.gnu.org/licenses/>
28  *
29  * Additional note on redistribution: The copyright and license notices above
30  * must be maintained in each individual source file that is a derivative work
31  * of this source file; otherwise redistribution is prohibited.
32  */
33 
34 #ifndef OPMAP_GADGETWIDGET_H_
35 #define OPMAP_GADGETWIDGET_H_
36 
37 // ******************************************************
38 
39 #include "modelmapproxy.h"
40 
41 #include <QWidget>
42 #include <QMenu>
43 #include <QStringList>
44 #include <QStandardItemModel>
45 #include <QList>
46 #include <QPointF>
47 
49 
51 #include "opmap_statusbar_widget.h"
52 
54 
58 #include "uavobjects/uavobject.h"
59 #include "objectpersistence.h"
60 #include <QItemSelectionModel>
61 
62 #include "../pathplanner/flightdatamodel.h"
63 
64 #include "homeeditor.h"
65 
66 // ******************************************************
67 
68 namespace Ui {
69 class OPMap_Widget;
70 }
71 
72 using namespace mapcontrol;
73 
74 // ******************************************************
75 
76 typedef struct t_home
77 {
79  double altitude;
80  bool locked;
81 } t_home;
82 
83 // ******************************************************
84 
86 
87 // ******************************************************
88 
89 class WindVelocityActual;
90 
91 class OPMapGadgetWidget : public QFrame
92 {
93  Q_OBJECT
94 
95 public:
96  OPMapGadgetWidget(QWidget *parent = nullptr);
98 
104  void setHome(QPointF pos);
105  void setHome(internals::PointLatLng pos_lat_lon, double altitude);
106  void goHome();
107  void setZoom(int zoom);
108  void setPosition(QPointF pos);
109  void setMapProvider(QString provider);
110  void setShowTileGridLines(bool showTileGridLines);
111  void setAccessMode(QString accessMode);
112  void setUseMemoryCache(bool useMemoryCache);
113  void setCacheLocation(QString cacheLocation);
114  void setMapMode(opMapModeType mode);
115  void SetUavPic(QString UAVPic);
116  void setMaxUpdateRate(int update_rate);
117  void setHomePosition(QPointF pos);
118  void setOverlayOpacity(qreal value);
119  void setUserImageLocation(QString userImageLocation);
120  void setUserImageHorizontalScale(double userImageHorizontalScale);
121  void setUserImageVerticalScale(double userImageVerticalScale);
122  bool getGPSPosition(double &latitude, double &longitude, double &altitude);
123  void setGeoCodingLanguage(QString language);
124 signals:
125  void defaultLocationAndZoomChanged(double lng, double lat, double zoom);
126  void overlayOpacityChanged(qreal);
127 
128 public slots:
129  void homePositionUpdated(UAVObject *);
130  void onTelemetryConnect();
131  void onTelemetryDisconnect();
132 
133 protected:
134  void resizeEvent(QResizeEvent *event);
135  void mouseMoveEvent(QMouseEvent *event);
136  void contextMenuEvent(QContextMenuEvent *event);
137  void closeEvent(QCloseEvent *);
138 private slots:
139  void wpDoubleClickEvent(WayPointItem *wp);
140  void updatePosition();
141 
142  void updateMousePos();
143 
144  void zoomIn();
145  void zoomOut();
146  void updateWindspeed(UAVObject *obj);
147 
153  void on_toolButtonZoomM_clicked();
154  void on_toolButtonZoomP_clicked();
155  void on_toolButtonMapHome_clicked();
156  void on_toolButtonMapUAV_clicked();
157  void on_toolButtonMapUAVheading_clicked();
158  void on_horizontalSliderZoom_sliderMoved(int position);
159  void on_toolButtonMagicWaypointMapMode_clicked();
160  void on_toolButtonNormalMapMode_clicked();
161  void on_toolButtonHomeWaypoint_clicked();
162  void on_toolButtonMoveToWP_clicked();
163 
167  void zoomChanged(double zoomt, double zoom, double zoomd);
168  void OnCurrentPositionChanged(internals::PointLatLng point);
169  void OnTileLoadComplete();
170  void OnTileLoadStart();
171  void OnTilesStillToLoad(int number);
172 
176  void onReloadAct_triggered();
177  void onRipAct_triggered();
178  void onCopyMouseLatLonToClipAct_triggered();
179  void onCopyMouseLatToClipAct_triggered();
180  void onCopyMouseLonToClipAct_triggered();
181  void onShowCompassRoseAct_toggled(bool show);
182  void onShowWindCompassAction_toggled(bool show);
183  void onShowDiagnostics_toggled(bool show);
184  void onShowUAVInfo_toggled(bool show);
185  void onShowUAVAct_toggled(bool show);
186  void onShowHomeAct_toggled(bool show);
187  void onShowTrailLineAct_toggled(bool show);
188  void onShowTrailAct_toggled(bool show);
189  void onGoZoomInAct_triggered();
190  void onGoZoomOutAct_triggered();
191  void onGoMouseClickAct_triggered();
192  void onSetHomeAct_triggered();
193  void onGoHomeAct_triggered();
194  void onGoUAVAct_triggered();
195  void onFollowUAVpositionAct_toggled(bool checked);
196  void onFollowUAVheadingAct_toggled(bool checked);
197 
198  void onOpenWayPointEditorAct_triggered();
199  void onAddWayPointAct_triggeredFromContextMenu();
200  void onAddWayPointAct_triggeredFromThis();
201  void onAddWayPointAct_triggered(internals::PointLatLng coord);
202 
204  void onEditWayPointAct_triggered();
205  void onLockWayPointAct_triggered();
206  void onDeleteWayPointAct_triggered();
207  void onClearWayPointsAct_triggered();
208 
209  void onMapModeActGroup_triggered(QAction *action);
210  void onZoomActGroup_triggered(QAction *action);
211  void onHomeMagicWaypointAct_triggered();
212  void onShowSafeAreaAct_toggled(bool show);
213  void onSafeAreaActGroup_triggered(QAction *action);
214  void onUAVTrailTypeActGroup_triggered(QAction *action);
215  void onClearUAVtrailAct_triggered();
216  void onUAVTrailTimeActGroup_triggered(QAction *action);
217  void onUAVTrailDistanceActGroup_triggered(QAction *action);
218  void onMaxUpdateRateActGroup_triggered(QAction *action);
219  void onChangeDefaultLocalAndZoom();
220  void on_tbFind_clicked();
221  void onHomeDoubleClick(HomeItem *);
222  void onOverlayOpacityActGroup_triggered(QAction *action);
223  void on_leFind_returnPressed();
224 
225 private:
226  int m_min_zoom;
227  int m_max_zoom;
228  double m_heading; // uav heading
229  internals::PointLatLng m_mouse_lat_lon;
230  internals::PointLatLng m_context_menu_lat_lon;
231  int m_prev_tile_number;
232  opMapModeType m_map_mode;
233  int m_maxUpdateRate;
234  t_home m_home_position;
235  QStringList findPlaceWordList;
236  QCompleter *findPlaceCompleter;
237  QTimer *m_updateTimer;
238  QTimer *m_statusUpdateTimer;
239  Ui::OPMap_Widget *m_widget;
242  UAVObjectManager *uavo_mgr;
243  UAVObjectUtilManager *uavo_util_mgr;
244 
245  QStandardItemModel wayPoint_treeView_model;
246  mapcontrol::WayPointItem *m_mouse_waypoint;
247  bool m_telemetry_connected;
248  QAction *closeAct1;
249  QAction *closeAct2;
250  QAction *reloadAct;
251  QAction *ripAct;
252  QAction *copyMouseLatLonToClipAct;
253  QAction *copyMouseLatToClipAct;
254  QAction *copyMouseLonToClipAct;
255  QAction *showCompassRoseAct;
256  QAction *showWindCompassAction;
257  QAction *showDiagnostics;
258  QAction *showUAVInfo;
259  QAction *showHomeAct;
260  QAction *showUAVAct;
261  QAction *zoomInAct;
262  QAction *zoomOutAct;
263  QAction *goMouseClickAct;
264  QAction *setHomeAct;
265  QAction *goHomeAct;
266  QAction *goUAVAct;
267  QAction *followUAVpositionAct;
268  QAction *followUAVheadingAct;
269 
270  QAction *wayPointEditorAct;
271  QAction *addWayPointActFromThis;
272  QAction *addWayPointActFromContextMenu;
273  QAction *editWayPointAct;
274  QAction *lockWayPointAct;
275  QAction *deleteWayPointAct;
276  QAction *clearWayPointsAct;
277 
278  QAction *homeMagicWaypointAct;
279 
280  QAction *showSafeAreaAct;
281  QAction *changeDefaultLocalAndZoom;
282  QActionGroup *safeAreaActGroup;
283  QList<QAction *> safeAreaAct;
284 
285  QActionGroup *uavTrailTypeActGroup;
286  QList<QAction *> uavTrailTypeAct;
287  QAction *clearUAVtrailAct;
288  QActionGroup *uavTrailTimeActGroup;
289  QAction *showTrailLineAct;
290  QAction *showTrailAct;
291  QList<QAction *> uavTrailTimeAct;
292  QActionGroup *uavTrailDistanceActGroup;
293  QList<QAction *> uavTrailDistanceAct;
294 
295  QActionGroup *mapModeActGroup;
296  QList<QAction *> mapModeAct;
297 
298  QActionGroup *zoomActGroup;
299  QActionGroup *overlayOpacityActGroup;
300  QList<QAction *> zoomAct;
301  QList<QAction *> overlayOpacityAct;
302 
303  QActionGroup *maxUpdateRateActGroup;
304  QList<QAction *> maxUpdateRateAct;
305 
306  void createActions();
307  void homeMagicWaypoint();
308  void moveToMagicWaypointPosition();
309  void hideMagicWaypointControls();
310  void showMagicWaypointControls();
311  void keepMagicWaypointWithInSafeArea();
312 
313  double distance(internals::PointLatLng from, internals::PointLatLng to);
314  double bearing(internals::PointLatLng from, internals::PointLatLng to);
315  internals::PointLatLng destPoint(internals::PointLatLng source, double bear, double dist);
316 
317  bool getUAVPosition(double &latitude, double &longitude, double &altitude);
318  double getUAV_Yaw();
319 
320  void setMapFollowingMode();
321 
322  bool setHomeLocationObject();
323  internals::PointLatLng lastLatLngMouse;
324  WayPointItem *magicWayPoint;
325 
326  QPointer<FlightDataModel> model;
327  QPointer<QDialog> pathPlannerDialog;
328  QPointer<ModelMapProxy> mapProxy;
329  QPointer<QItemSelectionModel> selectionModel;
330 };
331 
332 #endif /* OPMAP_GADGETWIDGET_H_ */
Core plugin system that manages the plugins, their life cycle and their registered objects...
Definition: pluginmanager.h:53
opMapModeType
struct t_home t_home
double altitude
A QGraphicsItem representing a WayPoint.
Definition: waypointitem.h:41
internals::PointLatLng coord