Skip to content

Commit

Permalink
Added option to clear Google Earth trails
Browse files Browse the repository at this point in the history
  • Loading branch information
pixhawk-students committed Jan 26, 2011
1 parent 6f367e7 commit 6540c22
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
9 changes: 8 additions & 1 deletion images/earth.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@
aircraft[id] = planePlacemark;
attitudes[id] = planeOrient;
aircraftLocations[id] = planeLoc;
aircraftLastLocations[id] = ge.createLocation('');
aircraftLastLocations[id] = ge.createLocation('');
aircraftColors[id] = color;
//planeColor = color;

createTrail(id, color);
Expand Down Expand Up @@ -189,6 +190,12 @@
trailsVisible[id] = true;
}

function startTrail(id)
{
createTrail(id, trailColors[id]);
trailsVisible[id] = true;
}

function setViewRange(dist)
{
currViewRange = dist;
Expand Down
19 changes: 18 additions & 1 deletion src/ui/map3D/QGCGoogleEarthView.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,20 @@ void QGCGoogleEarthView::updateGlobalPosition(UASInterface* uas, double lon, 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::clearTrail()
{
// Check if the current trail has to be hidden
if (trailEnabled && !state)
{
QList<UASInterface*> mavs = UASManager::instance()->getUASList();
foreach (UASInterface* currMav, mavs)
{
javaScript(QString("clearTrail(%1);").arg(currMav->getUASID()));
javaScript(QString("startTrail(%1);").arg(currMav->getUASID()));
}
}
}

void QGCGoogleEarthView::showTrail(bool state)
{
// Check if the current trail has to be hidden
Expand All @@ -159,7 +173,7 @@ void QGCGoogleEarthView::showTrail(bool state)
QList<UASInterface*> mavs = UASManager::instance()->getUASList();
foreach (UASInterface* currMav, mavs)
{
javaScript(QString("hideTrail(%1);").arg(currMav->getUASID()));
javaScript(QString("clearTrail(%1);").arg(currMav->getUASID()));
}
}

Expand Down Expand Up @@ -344,6 +358,9 @@ void QGCGoogleEarthView::initializeGoogleEarth()
ui->trailCheckbox->setChecked(trailEnabled);
connect(ui->trailCheckbox, SIGNAL(toggled(bool)), this, SLOT(showTrail(bool)));

// Clear trail button
connect(ui->clearTrailButton, SIGNAL(clicked()), this, SLOT(clearTrail()));

// Go home
connect(ui->goHomeButton, SIGNAL(clicked()), this, SLOT(goHome()));

Expand Down
2 changes: 2 additions & 0 deletions src/ui/map3D/QGCGoogleEarthView.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public slots:
void setActiveUAS(UASInterface* uas);
/** @brief Update the global position */
void updateGlobalPosition(UASInterface* uas, double lon, double lat, double alt, quint64 usec);
/** @brief Clear the existing vehicle trails */
void clearTrail();
/** @brief Show the vehicle trail */
void showTrail(bool state);
/** @brief Show the waypoints */
Expand Down

0 comments on commit 6540c22

Please sign in to comment.