1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#ifndef QGCGOOGLEEARTHVIEW_H
#define QGCGOOGLEEARTHVIEW_H
#include <QWidget>
#include <QTimer>
#include <UASInterface.h>
#if (defined Q_OS_MAC)
#include <QWebView>
#endif
#ifdef _MSC_VER
#include <ActiveQt/QAxWidget>
#include <ActiveQt/QAxObject>
#include "windows.h"
class QGCWebAxWidget : public QAxWidget
{
public:
//Q_OBJECT
QGCWebAxWidget(QWidget* parent = 0, Qt::WindowFlags f = 0)
: QAxWidget(parent, f)/*,
_document(NULL)*/
{
// Set web browser control
setControl("{8856F961-340A-11D0-A96B-00C04FD705A2}");
// WARNING: Makes it impossible to actually debug javascript. But useful in production mode
setProperty("ScriptErrorsSuppressed", true);
// see: http://www.codeproject.com/KB/cpp/ExtendedWebBrowser.aspx?fid=285594&df=90&mpp=25&noise=3&sort=Position&view=Quick&fr=151#GoalScriptError
//this->dynamicCall("setProperty(const QString&,
//QObject::connect(this, SIGNAL(DocumentComplete(IDispatch*, QVariant&)), this, SLOT(setDocument(IDispatch*, QVariant&)));
}
/*
QAxObject* document()
{
return _document;
}*/
protected:
/*
void setDocument(IDispatch* dispatch, QVariant& variant)
{
_document = this->querySubObject("Document()");
}
QAxObject* _document;*/
virtual bool translateKeyEvent(int message, int keycode) const {
if (message >= WM_KEYFIRST && message <= WM_KEYLAST)
return true;
else
return QAxWidget::translateKeyEvent(message, keycode);
}
};
#endif
namespace Ui
{
class QGCGoogleEarthView;
}
class Waypoint;
class QGCGoogleEarthView : public QWidget
{
Q_OBJECT
public:
explicit QGCGoogleEarthView(QWidget *parent = 0);
~QGCGoogleEarthView();
enum VIEW_MODE {
VIEW_MODE_SIDE = 0, ///< View from above, orientation is free
VIEW_MODE_MAP, ///< View from above, orientation is north (map view)
VIEW_MODE_CHASE_LOCKED, ///< Locked chase camera
VIEW_MODE_CHASE_FREE, ///< Position is chasing object, but view can rotate around object
};
public slots:
/** @brief Update the internal state. Does not trigger a redraw */
void updateState();
/** @brief Add a new MAV/UAS to the visualization */
void addUAS(UASInterface* uas);
/** @brief Set the currently selected UAS */
void setActiveUAS(UASInterface* uas);
/** @brief Update the global position */
void updateGlobalPosition(UASInterface* uas, double lat, double lon, double alt, quint64 usec);
/** @brief Update a single waypoint */
void updateWaypoint(int uas, Waypoint* wp);
/** @brief Update the waypoint list */
void updateWaypointList(int uas);
/** @brief Show the vehicle trail */
void showTrail(bool state);
/** @brief Clear the current vehicle trails and start with new ones */
void clearTrails();
/** @brief Show the waypoints */
void showWaypoints(bool state);
/** @brief Follow the aircraft during flight */
void follow(bool follow);
/** @brief Go to the home location */
void goHome();
/** @brief Set the home location */
void setHome(double lat, double lon, double alt);
/** @brief Set the home location interactively in the UI */
void setHome();
/** @brief Move the view to a latitude / longitude position */
void moveToPosition();
/** @brief Allow waypoint editing */
void enableEditMode(bool mode);
/** @brief Enable daylight/night */
void enableDaylight(bool enable);
/** @brief Enable atmosphere */
void enableAtmosphere(bool enable);
/** @brief Set camera view range to aircraft in meters */
void setViewRange(float range);
/** @brief Set the distance mode - either to ground or to MAV */
void setDistanceMode(int mode);
/** @brief Set the view mode */
void setViewMode(VIEW_MODE mode);
/** @brief Toggle through the different view modes */
void toggleViewMode();
/** @brief Set camera view range to aircraft in centimeters */
void setViewRangeScaledInt(int range);
/** @brief Reset Google Earth View */
void reloadHTML();
/** @brief Initialize Google Earth */
void initializeGoogleEarth();
/** @brief Print a Windows exception */
void printWinException(int no, QString str1, QString str2, QString str3);
public:
/** @brief Execute java script inside the Google Earth window */
QVariant javaScript(QString javascript);
/** @brief Get a document element */
QVariant documentElement(QString name);
signals:
void visibilityChanged(bool visible);
protected:
void changeEvent(QEvent *e);
QTimer* updateTimer;
int refreshRateMs;
UASInterface* mav;
bool followCamera;
bool trailEnabled;
bool waypointsEnabled;
bool webViewInitialized;
bool jScriptInitialized;
bool gEarthInitialized;
VIEW_MODE currentViewMode;
#ifdef _MSC_VER
QGCWebAxWidget* webViewWin;
QAxObject* jScriptWin;
QAxObject* documentWin;
#endif
#if (defined Q_OS_MAC)
QWebView* webViewMac;
#endif
/** @brief Start widget updating */
void showEvent(QShowEvent* event);
/** @brief Stop widget updating */
void hideEvent(QHideEvent* event);
private:
#ifdef _MSC_VER
Ui::QGCGoogleEarthView* ui;
#else
Ui::QGCGoogleEarthView* ui;
#endif
};
#endif // QGCGOOGLEEARTHVIEW_H