Commit 958bd1de authored by pixhawk's avatar pixhawk

Slight improved to Google Earth widget

parent e2d84e55
...@@ -142,7 +142,8 @@ FORMS += src/ui/MainWindow.ui \ ...@@ -142,7 +142,8 @@ FORMS += src/ui/MainWindow.ui \
src/ui/QMap3D.ui \ src/ui/QMap3D.ui \
src/ui/QGCWebView.ui \ src/ui/QGCWebView.ui \
src/ui/map3D/QGCGoogleEarthView.ui \ src/ui/map3D/QGCGoogleEarthView.ui \
src/ui/map3D/QGCGoogleEarthViewWin.ui src/ui/map3D/QGCGoogleEarthViewWin.ui \
src/ui/map3D/QGCGoogleEarthControls.ui
# src/ui/WaypointGlobalView.ui # src/ui/WaypointGlobalView.ui
INCLUDEPATH += src \ INCLUDEPATH += src \
......
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>Form</class>
<widget class="QWidget" name="Form" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
</widget>
<pixmapfunction></pixmapfunction>
<connections/>
</ui>
...@@ -6,7 +6,9 @@ ...@@ -6,7 +6,9 @@
#include "QGCGoogleEarthView.h" #include "QGCGoogleEarthView.h"
#include "QGCWebPage.h" #include "QGCWebPage.h"
#include "UASManager.h" #include "UASManager.h"
#include "ui_QGCGoogleEarthControls.h"
#if (defined Q_OS_WIN) && !(defined __MINGW32__) #if (defined Q_OS_WIN) && !(defined __MINGW32__)
#include "ui_QGCGoogleEarthViewWin.h"
#else #else
#include "ui_QGCGoogleEarthView.h" #include "ui_QGCGoogleEarthView.h"
#endif #endif
...@@ -16,20 +18,34 @@ QGCGoogleEarthView::QGCGoogleEarthView(QWidget *parent) : ...@@ -16,20 +18,34 @@ QGCGoogleEarthView::QGCGoogleEarthView(QWidget *parent) :
updateTimer(new QTimer(this)), updateTimer(new QTimer(this)),
mav(NULL), mav(NULL),
followCamera(true), followCamera(true),
#if (defined Q_OS_WIN) && !(defined __MINGW32__) #if (defined Q_OS_MAC)
webViewMac(new QWebView(this)),
#endif
#if (defined Q_OS_WIN) & !(defined __MINGW32__)
webViewWin(new QGCWebAxWidget(this)), webViewWin(new QGCWebAxWidget(this)),
#else #else
ui(new Ui::QGCGoogleEarthView) ui(new Ui::QGCGoogleEarthView)
#endif #endif
{ {
#if (defined Q_OS_WIN) && !(defined __MINGW32__) #if (defined Q_OS_WIN) & !(defined __MINGW32__)
// Create layout and attach webViewWin // Create layout and attach webViewWin
#else #else
#endif
ui->setupUi(this); ui->setupUi(this);
ui->webView->setPage(new QGCWebPage(ui->webView));
ui->webView->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
ui->webView->load(QUrl("earth.html")); #if (defined Q_OS_MAC)
ui->webViewLayout->addWidget(webViewMac);
webViewMac->setPage(new QGCWebPage(webViewMac));
webViewMac->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
webViewMac->load(QUrl("earth.html"));
#endif
#if (defined Q_OS_WIN) & !(defined __MINGW32__)
webViewWin->load(QUrl("earth.html"));
#endif
#if ((defined Q_OS_MAC) | ((defined Q_OS_WIN) & !(defined __MINGW32__)))
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*))); connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setActiveUAS(UASInterface*)));
connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateState())); connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateState()));
updateTimer->start(200); updateTimer->start(200);
...@@ -54,14 +70,29 @@ void QGCGoogleEarthView::setActiveUAS(UASInterface* uas) ...@@ -54,14 +70,29 @@ void QGCGoogleEarthView::setActiveUAS(UASInterface* uas)
mav = uas; mav = uas;
} }
void QGCGoogleEarthView::showTrail(int state)
{
}
void QGCGoogleEarthView::showWaypoints(int state)
{
}
void QGCGoogleEarthView::follow(bool follow)
{
}
void QGCGoogleEarthView::updateState() void QGCGoogleEarthView::updateState()
{ {
if (ui->webView->page()->currentFrame()->evaluateJavaScript("isInitialized();").toBool()) if (webViewMac->page()->currentFrame()->evaluateJavaScript("isInitialized();").toBool())
{ {
static bool initialized = false; static bool initialized = false;
if (!initialized) if (!initialized)
{ {
ui->webView->page()->currentFrame()->evaluateJavaScript("setGCSHome(22.679833,8.549444, 470);"); webViewMac->page()->currentFrame()->evaluateJavaScript("setGCSHome(22.679833,8.549444, 470);");
initialized = true; initialized = true;
} }
int uasId = 0; int uasId = 0;
...@@ -83,7 +114,7 @@ void QGCGoogleEarthView::updateState() ...@@ -83,7 +114,7 @@ void QGCGoogleEarthView::updateState()
pitch = mav->getPitch(); pitch = mav->getPitch();
yaw = mav->getYaw(); yaw = mav->getYaw();
} }
ui->webView->page()->currentFrame()->evaluateJavaScript(QString("setAircraftPositionAttitude(%1, %2, %3, %4, %6, %7, %8);") webViewMac->page()->currentFrame()->evaluateJavaScript(QString("setAircraftPositionAttitude(%1, %2, %3, %4, %6, %7, %8);")
.arg(uasId) .arg(uasId)
.arg(lat) .arg(lat)
.arg(lon) .arg(lon)
...@@ -94,7 +125,7 @@ void QGCGoogleEarthView::updateState() ...@@ -94,7 +125,7 @@ void QGCGoogleEarthView::updateState()
if (followCamera) if (followCamera)
{ {
ui->webView->page()->currentFrame()->evaluateJavaScript(QString("updateFollowAircraft()")); webViewMac->page()->currentFrame()->evaluateJavaScript(QString("updateFollowAircraft()"));
} }
} }
} }
......
...@@ -5,6 +5,10 @@ ...@@ -5,6 +5,10 @@
#include <QTimer> #include <QTimer>
#include <UASInterface.h> #include <UASInterface.h>
#if (defined Q_OS_MAC)
#include <QWebView>
#endif
#if (defined Q_OS_WIN) && !(defined __MINGW32__) #if (defined Q_OS_WIN) && !(defined __MINGW32__)
QGCWebAxWidget* webViewWin; QGCWebAxWidget* webViewWin;
#include <ActiveQt/QAxWidget> #include <ActiveQt/QAxWidget>
...@@ -30,7 +34,12 @@ protected: ...@@ -30,7 +34,12 @@ protected:
}; };
#else #else
namespace Ui { namespace Ui {
class QGCGoogleEarthControls;
#if (defined Q_OS_WIN) && !(defined __MINGW32__)
class QGCGoogleEarthViewWin;
#else
class QGCGoogleEarthView; class QGCGoogleEarthView;
#endif
} }
#endif #endif
...@@ -47,17 +56,31 @@ public slots: ...@@ -47,17 +56,31 @@ public slots:
void updateState(); void updateState();
/** @brief Set the currently selected UAS */ /** @brief Set the currently selected UAS */
void setActiveUAS(UASInterface* uas); void setActiveUAS(UASInterface* uas);
/** @brief Show the vehicle trail */
void showTrail(int state);
/** @brief Show the waypoints */
void showWaypoints(int state);
/** @brief Follow the aircraft during flight */
void follow(bool follow);
protected: protected:
void changeEvent(QEvent *e); void changeEvent(QEvent *e);
QTimer* updateTimer; QTimer* updateTimer;
UASInterface* mav; UASInterface* mav;
bool followCamera; bool followCamera;
#if (defined Q_OS_WIN) && !(defined __MINGW32__)
WebAxWidget* webViewWin;
#endif
#if (defined Q_OS_MAC)
QWebView* webViewMac;
#endif
#if (defined Q_OS_WIN) && !(defined __MINGW32__)
#else
private: private:
Ui::QGCGoogleEarthView *ui; Ui::QGCGoogleEarthControls* controls;
#if (defined Q_OS_WIN) && !(defined __MINGW32__)
Ui::QGCGoogleEarthViewWin* ui;
#else
Ui::QGCGoogleEarthView* ui;
#endif #endif
}; };
......
...@@ -6,35 +6,72 @@ ...@@ -6,35 +6,72 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>597</width>
<height>300</height> <height>300</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QGridLayout" name="gridLayout">
<property name="horizontalSpacing">
<number>10</number>
</property>
<property name="verticalSpacing">
<number>5</number>
</property>
<property name="margin"> <property name="margin">
<number>0</number> <number>2</number>
</property>
<item row="0" column="0" colspan="6">
<layout class="QVBoxLayout" name="webViewLayout"/>
</item>
<item row="1" column="0">
<widget class="QComboBox" name="mavComboBox"/>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="goHomeButton">
<property name="text">
<string>Home</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QCheckBox" name="followAirplaneCheckbox">
<property name="text">
<string>Follow</string>
</property> </property>
<item> </widget>
<widget class="QWebView" name="webView"> </item>
<property name="url"> <item row="1" column="3">
<url> <widget class="QCheckBox" name="trailCheckbox">
<string>about:blank</string> <property name="text">
</url> <string>Trail</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QPushButton" name="clearWPButton">
<property name="text">
<string>Clear WPs</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="5">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>177</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>QWebView</class>
<extends>QWidget</extends>
<header>QtWebKit/QWebView</header>
</customwidget>
</customwidgets>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment