Commit c6c70beb authored by lm's avatar lm

Small usability fixes for the Google Earth view, is now more convenient to...

Small usability fixes for the Google Earth view, is now more convenient to use. Editing now only possible in edit mode, prevents false edits
parent bc3471de
......@@ -39,7 +39,7 @@ var currView = null;
var distanceMode = 0;
var viewMode = 0;
var lastTilt = 0;
var lastTilt = currTilt;
var lastRoll = 0;
var lastHeading = 0;
......@@ -85,6 +85,8 @@ var newWaypointLongitude = 0;
var newWaypointAltitude = 0;
var newWaypointPending = false;
var homePlacemark = null;
function getGlobal(variable)
{
return variable;
......@@ -136,13 +138,12 @@ function enableEventListener()
// listen for mousedown on the window (look specifically for point placemarks)
google.earth.addEventListener(ge.getWindow(), 'mousedown', function(event)
{
if (draggingAllowed)
{
if (event.getTarget().getType() == 'KmlPlacemark' &&
event.getTarget().getGeometry().getType() == 'KmlPoint') {
//event.preventDefault();
var placemark = event.getTarget();
event.preventDefault();
if (draggingAllowed)
{
dragInfo = {
placemark: event.getTarget(),
dragged: false
......@@ -223,14 +224,16 @@ function setGCSHome(lat, lon, alt)
homeAlt = alt;
if (homePlacemark == null)
{
var placemark = ge.createPlacemark('');
var icon = ge.createIcon('');
icon.setHref('http://google-maps-icons.googlecode.com/files/blackH.png');
var style = ge.createStyle('');
style.getIconStyle().setIcon(icon);
//style.getIconStyle().setScale(0.5);
placemark.setStyleSelector(style);
placemark.setStyleSelector(style);
placemark.setDescription('HOME');
// Set the placemark's location.
homeLocation = ge.createPoint('');
......@@ -240,7 +243,19 @@ function setGCSHome(lat, lon, alt)
placemark.setGeometry(homeLocation);
// Add the placemark to Earth.
ge.getFeatures().appendChild(placemark);
ge.getFeatures().appendChild(placemark);
homePlacemark = placemark;
}
else
{
var location = ge.createPoint('');
location.setLatitude(lat);
location.setLongitude(lon);
location.setAltitude(alt);
homePlacemark.setGeometry(location);
homePlacemark.setDescription('HOME');
}
homeGroundLevel = ge.getGlobe().getGroundAltitude(lat,lon);
if (homeGroundLevel == 0)
......@@ -490,6 +505,11 @@ function enableDaylight(enabled)
ge.getSun().setVisibility(false);
}
}
function enableAtmosphere(enabled)
{
ge.getOptions().setAtmosphereVisibility(enabled);
}
function goHome()
{
......@@ -513,7 +533,7 @@ function setCurrentAircraft(id)
*/
function setViewMode(mode)
{
var currView = ge.getView().copyAsLookAt(ge.ALTITUDE_ABSOLUTE);
var currView = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
if (mode == 0)
{
......@@ -524,14 +544,14 @@ function setViewMode(mode)
{
lastTilt = currView.getTilt();
lastHeading = currView.getHeading();
var lastLat2 = currView.getLatitude();
var lastLon2 = currView.getLongitude();
var lastAlt2 = currView.getAltitude();
//var lastLat2 = currView.getLatitude();
//var lastLon2 = currView.getLongitude();
//var lastAlt2 = currView.getAltitude();
currView.setTilt(0);
currView.setHeading(0);
currView.setLatitude(lastLat2);
currView.setLongitude(lastLon2);
currView.setAltitude(lastAlt2);
//currView.setLatitude(lastLat2);
//currView.setLongitude(lastLon2);
//currView.setAltitude(lastAlt2);
}
viewMode = mode;
......
......@@ -84,6 +84,8 @@ QGCGoogleEarthView::QGCGoogleEarthView(QWidget *parent) :
connect(ui->resetButton, SIGNAL(clicked()), this, SLOT(reloadHTML()));
connect(ui->changeViewButton, SIGNAL(clicked()), this, SLOT(toggleViewMode()));
connect(ui->clearTrailsButton, SIGNAL(clicked()), this, SLOT(clearTrails()));
connect(ui->atmosphereCheckBox, SIGNAL(clicked(bool)), this, SLOT(enableAtmosphere(bool)));
connect(ui->daylightCheckBox, SIGNAL(clicked(bool)), this, SLOT(enableDaylight(bool)));
}
QGCGoogleEarthView::~QGCGoogleEarthView()
......@@ -123,6 +125,16 @@ void QGCGoogleEarthView::enableEditMode(bool mode)
javaScript(QString("setDraggingAllowed(%1);").arg(mode));
}
void QGCGoogleEarthView::enableDaylight(bool enable)
{
javaScript(QString("enableDaylight(%1);").arg(enable));
}
void QGCGoogleEarthView::enableAtmosphere(bool enable)
{
javaScript(QString("enableAtmosphere(%1);").arg(enable));
}
/**
* @param range in meters (SI-units)
*/
......@@ -554,6 +566,8 @@ void QGCGoogleEarthView::initializeGoogleEarth()
setViewMode(currentViewMode);
setDistanceMode(ui->camDistanceComboBox->currentIndex());
enableEditMode(ui->editButton->isChecked());
enableAtmosphere(ui->atmosphereCheckBox->isChecked());
enableDaylight(ui->daylightCheckBox->isChecked());
follow(this->followCamera);
}
}
......@@ -647,31 +661,33 @@ void QGCGoogleEarthView::updateState()
coordsOk &= ok;
double altitude = documentElement("dragWaypointAltitude").toDouble(&ok);
coordsOk &= ok;
// UPDATE WAYPOINTS, HOME LOCATION AND OTHER LOCATIONS
if (coordsOk)
{
// Add new waypoint
if (mav)
QString idText = documentElement("dragWaypointIndex").toString();
if (idText == "HOME")
{
QVector<Waypoint*> wps = mav->getWaypointManager()->getGlobalFrameWaypointList();
QString idText = documentElement("dragWaypointIndex").toString();
bool ok;
int index = idText.toInt(&ok);
if (ok && index >= 0 && index < wps.count())
setHome(latitude, longitude, altitude);
}
else
{
// Update waypoint or symbol
if (mav)
{
Waypoint* wp = wps.at(index);
wp->setLatitude(latitude);
wp->setLongitude(longitude);
wp->setAltitude(altitude);
// Waypoint wp;
// wp.setFrame(MAV_FRAME_GLOBAL);
// wp.setLatitude(latitude);
// wp.setLongitude(longitude);
// wp.setAltitude(altitude);
// mav->getWaypointManager()->addWaypoint(wp);
mav->getWaypointManager()->notifyOfChange(wp);
QVector<Waypoint*> wps = mav->getWaypointManager()->getGlobalFrameWaypointList();
bool ok;
int index = idText.toInt(&ok);
if (ok && index >= 0 && index < wps.count())
{
Waypoint* wp = wps.at(index);
wp->setLatitude(latitude);
wp->setLongitude(longitude);
wp->setAltitude(altitude);
mav->getWaypointManager()->notifyOfChange(wp);
}
}
}
}
......
......@@ -106,6 +106,10 @@ public slots:
void setHome(double lat, double lon, double alt);
/** @brief Allow waypoint editing */
void enableEditMode(bool mode);
/** @brief Enable daylight/night */
void enableDaylight(bool enable);
/** @brief Enable atmosphere */
void enableAtmosphere(bool enable);
/** @brief Set camera view range to aircraft in meters */
void setViewRange(float range);
/** @brief Set the distance mode - either to ground or to MAV */
......
......@@ -6,14 +6,14 @@
<rect>
<x>0</x>
<y>0</y>
<width>828</width>
<height>300</height>
<width>1089</width>
<height>302</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout" columnstretch="1,0,0,0,0,0,0,0,0,0,0,0,0,0">
<layout class="QGridLayout" name="gridLayout" columnstretch="1,10,10,10,10,5,1,100,10,10,10,10,10,5,2,2">
<property name="horizontalSpacing">
<number>8</number>
</property>
......@@ -23,7 +23,7 @@
<property name="margin">
<number>2</number>
</property>
<item row="0" column="0" colspan="14">
<item row="0" column="0" colspan="16">
<layout class="QVBoxLayout" name="webViewLayout"/>
</item>
<item row="1" column="1">
......@@ -63,9 +63,12 @@
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>177</width>
<width>5</width>
<height>20</height>
</size>
</property>
......@@ -195,6 +198,32 @@
</property>
</widget>
</item>
<item row="1" column="14">
<widget class="QCheckBox" name="atmosphereCheckBox">
<property name="toolTip">
<string>Enable the atmosphere visualization. Not recommended for mission execution, only for visualization</string>
</property>
<property name="statusTip">
<string>Enable the atmosphere visualization. Not recommended for mission execution, only for visualization</string>
</property>
<property name="text">
<string>Sky</string>
</property>
</widget>
</item>
<item row="1" column="15">
<widget class="QCheckBox" name="daylightCheckBox">
<property name="toolTip">
<string>Enable day/night light. Not recommended for mission execution, only for visualization.</string>
</property>
<property name="statusTip">
<string>Enable day/night light. Not recommended for mission execution, only for visualization.</string>
</property>
<property name="text">
<string>Day/Night</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
......
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