From 958bd1dee89a590b22dbf201144b88807654093d Mon Sep 17 00:00:00 2001 From: pixhawk Date: Mon, 6 Dec 2010 09:05:08 +0100 Subject: [PATCH] Slight improved to Google Earth widget --- qgroundcontrol.pro | 3 +- src/ui/map3D/QGCGoogleEarthControls.ui | 21 ++++++++ src/ui/map3D/QGCGoogleEarthView.cc | 49 ++++++++++++++---- src/ui/map3D/QGCGoogleEarthView.h | 29 +++++++++-- src/ui/map3D/QGCGoogleEarthView.ui | 69 ++++++++++++++++++++------ 5 files changed, 142 insertions(+), 29 deletions(-) create mode 100644 src/ui/map3D/QGCGoogleEarthControls.ui diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 3ac311a692..abf2fa1bfe 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -142,7 +142,8 @@ FORMS += src/ui/MainWindow.ui \ src/ui/QMap3D.ui \ src/ui/QGCWebView.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 INCLUDEPATH += src \ diff --git a/src/ui/map3D/QGCGoogleEarthControls.ui b/src/ui/map3D/QGCGoogleEarthControls.ui new file mode 100644 index 0000000000..4b7d6a45fb --- /dev/null +++ b/src/ui/map3D/QGCGoogleEarthControls.ui @@ -0,0 +1,21 @@ + + + + + Form + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + diff --git a/src/ui/map3D/QGCGoogleEarthView.cc b/src/ui/map3D/QGCGoogleEarthView.cc index 7e120d3fcb..7bc7c2633b 100644 --- a/src/ui/map3D/QGCGoogleEarthView.cc +++ b/src/ui/map3D/QGCGoogleEarthView.cc @@ -6,7 +6,9 @@ #include "QGCGoogleEarthView.h" #include "QGCWebPage.h" #include "UASManager.h" +#include "ui_QGCGoogleEarthControls.h" #if (defined Q_OS_WIN) && !(defined __MINGW32__) +#include "ui_QGCGoogleEarthViewWin.h" #else #include "ui_QGCGoogleEarthView.h" #endif @@ -16,20 +18,34 @@ QGCGoogleEarthView::QGCGoogleEarthView(QWidget *parent) : updateTimer(new QTimer(this)), mav(NULL), 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)), #else ui(new Ui::QGCGoogleEarthView) #endif { -#if (defined Q_OS_WIN) && !(defined __MINGW32__) +#if (defined Q_OS_WIN) & !(defined __MINGW32__) // Create layout and attach webViewWin #else +#endif + 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(updateTimer, SIGNAL(timeout()), this, SLOT(updateState())); updateTimer->start(200); @@ -54,14 +70,29 @@ void QGCGoogleEarthView::setActiveUAS(UASInterface* uas) mav = uas; } +void QGCGoogleEarthView::showTrail(int state) +{ + +} + +void QGCGoogleEarthView::showWaypoints(int state) +{ + +} + +void QGCGoogleEarthView::follow(bool follow) +{ + +} + void QGCGoogleEarthView::updateState() { - if (ui->webView->page()->currentFrame()->evaluateJavaScript("isInitialized();").toBool()) + if (webViewMac->page()->currentFrame()->evaluateJavaScript("isInitialized();").toBool()) { static bool initialized = false; 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; } int uasId = 0; @@ -83,7 +114,7 @@ void QGCGoogleEarthView::updateState() pitch = mav->getPitch(); 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(lat) .arg(lon) @@ -94,7 +125,7 @@ void QGCGoogleEarthView::updateState() if (followCamera) { - ui->webView->page()->currentFrame()->evaluateJavaScript(QString("updateFollowAircraft()")); + webViewMac->page()->currentFrame()->evaluateJavaScript(QString("updateFollowAircraft()")); } } } diff --git a/src/ui/map3D/QGCGoogleEarthView.h b/src/ui/map3D/QGCGoogleEarthView.h index f59d9e8f7f..d7d2e9da9b 100644 --- a/src/ui/map3D/QGCGoogleEarthView.h +++ b/src/ui/map3D/QGCGoogleEarthView.h @@ -5,6 +5,10 @@ #include #include +#if (defined Q_OS_MAC) +#include +#endif + #if (defined Q_OS_WIN) && !(defined __MINGW32__) QGCWebAxWidget* webViewWin; #include @@ -30,7 +34,12 @@ protected: }; #else namespace Ui { + class QGCGoogleEarthControls; +#if (defined Q_OS_WIN) && !(defined __MINGW32__) + class QGCGoogleEarthViewWin; +#else class QGCGoogleEarthView; +#endif } #endif @@ -47,17 +56,31 @@ public slots: void updateState(); /** @brief Set the currently selected 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: void changeEvent(QEvent *e); QTimer* updateTimer; UASInterface* mav; 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: - Ui::QGCGoogleEarthView *ui; + Ui::QGCGoogleEarthControls* controls; +#if (defined Q_OS_WIN) && !(defined __MINGW32__) + Ui::QGCGoogleEarthViewWin* ui; +#else + Ui::QGCGoogleEarthView* ui; #endif }; diff --git a/src/ui/map3D/QGCGoogleEarthView.ui b/src/ui/map3D/QGCGoogleEarthView.ui index a720d9a59a..0731e9a001 100644 --- a/src/ui/map3D/QGCGoogleEarthView.ui +++ b/src/ui/map3D/QGCGoogleEarthView.ui @@ -6,35 +6,72 @@ 0 0 - 400 + 597 300 Form - + + + 10 + + + 5 + - 0 + 2 - - - - - about:blank - + + + + + + + + + + Home + + + + + + + Follow + + + + + + + Trail + + + + + + + Clear WPs + + + + Qt::Horizontal + + + + 177 + 20 + + + + - - - QWebView - QWidget -
QtWebKit/QWebView
-
-
-- GitLab