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 \
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 \
......
<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 @@
#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()"));
}
}
}
......
......@@ -5,6 +5,10 @@
#include <QTimer>
#include <UASInterface.h>
#if (defined Q_OS_MAC)
#include <QWebView>
#endif
#if (defined Q_OS_WIN) && !(defined __MINGW32__)
QGCWebAxWidget* webViewWin;
#include <ActiveQt/QAxWidget>
......@@ -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
};
......
......@@ -6,35 +6,72 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<width>597</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</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">
<number>0</number>
<number>2</number>
</property>
<item>
<widget class="QWebView" name="webView">
<property name="url">
<url>
<string>about:blank</string>
</url>
<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>
</widget>
</item>
<item row="1" column="3">
<widget class="QCheckBox" name="trailCheckbox">
<property name="text">
<string>Trail</string>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QPushButton" name="clearWPButton">
<property name="text">
<string>Clear WPs</string>
</property>
</widget>
</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>
</widget>
<customwidgets>
<customwidget>
<class>QWebView</class>
<extends>QWidget</extends>
<header>QtWebKit/QWebView</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</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