diff --git a/images/earth.html b/images/earth.html
index 41d7d6a822e06237717374e07ba44bf632c0fd5f..ee4242812d710cfd06b534532bb7f2fb894cb5bf 100644
--- a/images/earth.html
+++ b/images/earth.html
@@ -102,7 +102,7 @@ function setDistanceMode(mode)
function setDraggingAllowed(allowed)
{
- //draggingAllowed = allowed;
+ draggingAllowed = allowed;
}
function setNewWaypointPending(pending)
@@ -369,6 +369,18 @@ trailsVisible[id] = false;
}
function clearTrail(id)
+{
+ ge.getFeatures().removeChild(trailPlacemarks[id]);
+ trailPlacemarks[id] = null;
+ var isVisible = trailsVisible[id];
+ createTrail(id, trailColors[id]);
+ if (isVisible)
+ {
+ showTrail(id);
+ }
+}
+
+function hideTrail(id)
{
trailsVisible[id] = false;
ge.getFeatures().removeChild(trailPlacemarks[id]);
@@ -501,16 +513,14 @@ function setCurrentAircraft(id)
*/
function setViewMode(mode)
{
- viewMode = mode;
-
var currView = ge.getView().copyAsLookAt(ge.ALTITUDE_ABSOLUTE);
if (mode == 0)
{
- currView.setTilt(0);
- currView.setHeading(0);
+ currView.setTilt(lastTilt);
+ currView.setHeading(lastHeading);
}
- if (mode == 1)
+ if (mode == 1 && viewMode != mode)
{
lastTilt = currView.getTilt();
lastHeading = currView.getHeading();
@@ -524,6 +534,8 @@ function setViewMode(mode)
currView.setAltitude(lastAlt2);
}
+ viewMode = mode;
+
ge.getView().setAbstractView(currView);
}
@@ -532,11 +544,22 @@ function updateFollowAircraft()
currView = ge.getView().copyAsLookAt(ge.ALTITUDE_ABSOLUTE);
currView.setLatitude(lastLat);
currView.setLongitude(lastLon);
- currView.setAltitude(lastAlt);
+
+ if (distanceMode == 1)
+ {
+ var groundAltitude = ge.getGlobe().getGroundAltitude(lastLat, lastLon);
+ currView.setAltitude(groundAltitude);
+ }
+
+ if (distanceMode == 0) currView.setAltitude(lastAlt);
currView.setRange(currViewRange);
- currView.setTilt(currFollowTilt);
- currView.setHeading(currFollowHeading);
+
+ if (viewMode != 3) // VIEW_MODE_CHASE_FREE
+ {
+ currView.setTilt(currFollowTilt);
+ currView.setHeading(currFollowHeading);
+ }
ge.getView().setAbstractView(currView);
}
diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro
index bbcfd5fd495b5f88d6428cd566a514486d4a0c85..40b68c247fca9be0caf0683fe7b88d8019402dbe 100644
--- a/qgroundcontrol.pro
+++ b/qgroundcontrol.pro
@@ -144,7 +144,6 @@ 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/SlugsDataSensorView.ui \
src/ui/SlugsHilSim.ui \
src/ui/SlugsPIDControl.ui \
diff --git a/src/ui/map3D/QGCGoogleEarthView.cc b/src/ui/map3D/QGCGoogleEarthView.cc
index f2a50bc3b6bee6f94d4d5946ad505b02c259e6fd..591479235ebf8824fc0ed3d6212ef6e181238c4b 100644
--- a/src/ui/map3D/QGCGoogleEarthView.cc
+++ b/src/ui/map3D/QGCGoogleEarthView.cc
@@ -83,6 +83,7 @@ QGCGoogleEarthView::QGCGoogleEarthView(QWidget *parent) :
connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateState()));
connect(ui->resetButton, SIGNAL(clicked()), this, SLOT(reloadHTML()));
connect(ui->changeViewButton, SIGNAL(clicked()), this, SLOT(toggleViewMode()));
+ connect(ui->clearTrailsButton, SIGNAL(clicked()), this, SLOT(clearTrails()));
}
QGCGoogleEarthView::~QGCGoogleEarthView()
@@ -205,6 +206,7 @@ void QGCGoogleEarthView::setActiveUAS(UASInterface* uas)
{
mav = uas;
javaScript(QString("setCurrAircraft(%1);").arg(uas->getUASID()));
+ updateWaypointList(uas->getUASID());
}
}
@@ -271,6 +273,15 @@ void QGCGoogleEarthView::updateGlobalPosition(UASInterface* uas, double lat, dou
//qDebug() << QString("addTrailPosition(%1, %2, %3, %4);").arg(uas->getUASID()).arg(lat, 0, 'f', 15).arg(lon, 0, 'f', 15).arg(alt, 0, 'f', 15);
}
+void QGCGoogleEarthView::clearTrails()
+{
+ QList mavs = UASManager::instance()->getUASList();
+ foreach (UASInterface* currMav, mavs)
+ {
+ javaScript(QString("clearTrail(%1);").arg(currMav->getUASID()));
+ }
+}
+
void QGCGoogleEarthView::showTrail(bool state)
{
// Check if the current trail has to be hidden
@@ -304,8 +315,19 @@ void QGCGoogleEarthView::showWaypoints(bool state)
void QGCGoogleEarthView::follow(bool follow)
{
ui->followAirplaneCheckbox->setChecked(follow);
+ if (follow != followCamera)
+ {
+ if (follow)
+ {
+ setViewMode(VIEW_MODE_CHASE_LOCKED);
+ }
+ else
+ {
+ setViewMode(VIEW_MODE_SIDE);
+ }
+ }
followCamera = follow;
- if (gEarthInitialized) javaScript(QString("setFollowEnabled(%1)").arg(follow));
+ javaScript(QString("setFollowEnabled(%1)").arg(follow));
}
void QGCGoogleEarthView::goHome()
@@ -368,7 +390,14 @@ void QGCGoogleEarthView::printWinException(int no, QString str1, QString str2, Q
QVariant QGCGoogleEarthView::javaScript(QString javaScript)
{
#ifdef Q_OS_MAC
- return webViewMac->page()->currentFrame()->evaluateJavaScript(javaScript);
+ if (!gEarthInitialized)
+ {
+ return QVariant(false);
+ }
+ else
+ {
+ return webViewMac->page()->currentFrame()->evaluateJavaScript(javaScript);
+ }
#endif
#ifdef _MSC_VER
if(!jScriptInitialized)
@@ -381,7 +410,8 @@ QVariant QGCGoogleEarthView::javaScript(QString javaScript)
QVariantList params;
params.append(javaScript);
params.append("JScript");
- return jScriptWin->dynamicCall("execScript(QString, QString)", params);
+ QVariant result = jScriptWin->dynamicCall("execScript(QString, QString)", params);
+ return result;
}
#endif
}
@@ -391,7 +421,6 @@ QVariant QGCGoogleEarthView::documentElement(QString name)
#ifdef Q_OS_MAC
QString javaScript("getGlobal(%1)");
QVariant result = webViewMac->page()->currentFrame()->evaluateJavaScript(javaScript.arg(name));
- //qDebug() << "DOC ELEM:" << name << ":" << result;
return result;
#endif
#ifdef _MSC_VER
@@ -402,20 +431,22 @@ QVariant QGCGoogleEarthView::documentElement(QString name)
}
else
{
- if (documentWin)
- {
- // Get HTMLElement object
- QVariantList params;
- params.append(name);
- //QAxObject* elementWin = documentWin->dynamicCall("getElementById(QString)", params);
- QVariant result =documentWin->dynamicCall("toString()");
- qDebug() << "GOT RESULT" << result;
- return QVariant(0);//QVariant(result);
- }
- //QVariantList params;
- //params.append(javaScript);
- //params.append("JScript");
- //return jScriptWin->dynamicCall("execScript(QString, QString)", params);
+ QVariantList params;
+ QString javaScript("getGlobal(%1)");
+ params.append(javaScript.arg(name));
+ params.append("JScript");
+ QVariant result = jScriptWin->dynamicCall("execScript(QString, QString)", params);
+ qDebug() << "JScript result: " << result << result.toDouble();
+// if (documentWin)
+// {
+// // Get HTMLElement object
+// QVariantList params;
+// params.append(name);
+// //QAxObject* elementWin = documentWin->dynamicCall("getElementById(QString)", params);
+// QVariant result =documentWin->dynamicCall("toString()");
+// qDebug() << "GOT RESULT" << result;
+// return QVariant(0);//QVariant(result);
+// }
}
#endif
}
@@ -469,6 +500,8 @@ void QGCGoogleEarthView::initializeGoogleEarth()
}
else
{
+ gEarthInitialized = true;
+
// Set home location
setHome(47.3769, 8.549444, 500);
@@ -522,8 +555,6 @@ void QGCGoogleEarthView::initializeGoogleEarth()
setDistanceMode(ui->camDistanceComboBox->currentIndex());
enableEditMode(ui->editButton->isChecked());
follow(this->followCamera);
-
- gEarthInitialized = true;
}
}
}
diff --git a/src/ui/map3D/QGCGoogleEarthView.h b/src/ui/map3D/QGCGoogleEarthView.h
index 183d85891f23f9fa5521afc43993f0f82c5b1d76..a86deee370cf999c86f0b8c4b865706fa270b537 100644
--- a/src/ui/map3D/QGCGoogleEarthView.h
+++ b/src/ui/map3D/QGCGoogleEarthView.h
@@ -73,7 +73,7 @@ public:
enum VIEW_MODE
{
- VIEW_MODE_SIDE, ///< View from above, orientation is free
+ 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
@@ -94,6 +94,8 @@ public slots:
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 */
diff --git a/src/ui/map3D/QGCGoogleEarthView.ui b/src/ui/map3D/QGCGoogleEarthView.ui
index 81140f1d2c1934ebf97a3b7d07fadc8bfe0fbdce..15ebd3c4e0a99b8086fdb391f3bd4f69ca8c5456 100644
--- a/src/ui/map3D/QGCGoogleEarthView.ui
+++ b/src/ui/map3D/QGCGoogleEarthView.ui
@@ -13,7 +13,7 @@
Form
-
+
8
@@ -23,7 +23,7 @@
2
- -
+
-
-
@@ -58,7 +58,7 @@
- -
+
-
Qt::Horizontal
@@ -71,7 +71,7 @@
- -
+
-
Distance of the chase camera to the MAV
@@ -96,23 +96,7 @@
- -
-
-
- Show waypoints
-
-
- Show waypoints
-
-
- Show waypoints
-
-
- WPs
-
-
-
- -
+
-
Chase the MAV
@@ -128,7 +112,7 @@
- -
+
-
Select the MAV to chase
@@ -141,38 +125,38 @@
-
- Ground Distance
+ MAV Distance
-
- MAV Distance
+ Ground Distance
- -
+
-
Qt::Vertical
- -
+
-
Reset
- -
+
-
Overhead
- -
+
-
Delete all waypoints
@@ -188,7 +172,7 @@
- -
+
-
Qt::Vertical
diff --git a/src/ui/map3D/QGCGoogleEarthViewWin.ui b/src/ui/map3D/QGCGoogleEarthViewWin.ui
deleted file mode 100644
index 6191eaebb2358c8b8934b41f4dd4fc5307842172..0000000000000000000000000000000000000000
--- a/src/ui/map3D/QGCGoogleEarthViewWin.ui
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
- QGCGoogleEarthViewWin
-
-
-
- 0
- 0
- 400
- 300
-
-
-
- Form
-
-
-
-
-