Browse Source

Merge branch 'experimental' of pixhawk.ethz.ch:qgroundcontrol into experimental

QGC4.4
pixhawk 15 years ago
parent
commit
0198993ed7
  1. 41
      images/earth.html
  2. 6
      qgroundcontrol.pri
  3. 58
      src/ui/map3D/QGCGoogleEarthView.cc
  4. 21
      src/ui/map3D/QGCGoogleEarthView.h

41
images/earth.html

@ -13,12 +13,13 @@ google.load("earth", "1", { 'language': 'en'}); @@ -13,12 +13,13 @@ google.load("earth", "1", { 'language': 'en'});
var ge = null;
var initialized = false;
var aircraft = new Array();
var currAircraft = 220;
var followEnabled = false;
var followAircraft = false;
var currLat = 47.3769;
var currLon = 8.549444;
var currAlt = 470;
var currFollowHeading = 0.0;
var homeLat = 0;
var homeLon = 0;
@ -32,17 +33,11 @@ var currTilt = 40.0; ///<< The tilt angle (in degrees) @@ -32,17 +33,11 @@ var currTilt = 40.0; ///<< The tilt angle (in degrees)
var currFollowTilt = 40.0;
var currView = null;
var M_PI = 3.14159265;
var planeOrient;
var planeLoc;
var aircraft = [];
var attitudes = [];
var locations = [];
var trails = [];
var trail;
var lineStringPlacemark;
var lineStyle;
@ -62,10 +57,7 @@ function init() { @@ -62,10 +57,7 @@ function init() {
function setCurrAircraft(id)
{
currAircraft = id;
}
function setGCSHome(lat, lon, alt)
{
@ -98,6 +90,13 @@ function setGCSHome(lat, lon, alt) @@ -98,6 +90,13 @@ function setGCSHome(lat, lon, alt)
{
homeGroundLevel = alt;
}
goHome();
}
function createAircraft(id, type, color)
@ -205,13 +204,11 @@ function setAircraftPositionAttitude(id, lat, lon, alt, roll, pitch, yaw) @@ -205,13 +204,11 @@ function setAircraftPositionAttitude(id, lat, lon, alt, roll, pitch, yaw)
currLat = lat;
currLon = lon;
currAlt = alt;
currFollowHeading = ((yaw/M_PI)+1.0)*360.0;
}
// FIXME Currently invalid conversion from right-handed z-down to z-up frame
planeOrient.setRoll(((roll/M_PI)+1.0)*360.0);
planeOrient.setTilt(((pitch/M_PI)+1.0)*360.0);
planeOrient.setHeading(((yaw/M_PI)+1.0)*360.0);
planeOrient.setRoll(roll);
planeOrient.setTilt(pitch);
planeOrient.setHeading(yaw);
@ -249,17 +246,25 @@ function setCurrentAircraft(id) @@ -249,17 +246,25 @@ function setCurrentAircraft(id)
currAircraft = id;
}
function enableFollowing(follow)
{
followEnabled = follow;
}
function updateFollowAircraft()
{
if (followEnabled)
{
currView = ge.getView().copyAsLookAt(ge.ALTITUDE_ABSOLUTE);
currView.setLatitude(currLat);
currView.setLongitude(currLon);
currView.setAltitude(currAlt);
currView.setRange(currViewRange);
currView.setTilt(currFollowTilt);
currView.setHeading(currFollowHeading-90.0);
ge.getView().setAbstractView(currView);
}
}
function failureCallback(object)
{

6
qgroundcontrol.pri

@ -300,8 +300,9 @@ win32-msvc2008 { @@ -300,8 +300,9 @@ win32-msvc2008 {
DEFINES += QT_NO_DEBUG
}
# Special settings for debug
#CONFIG += CONSOLE
debug {
CONFIG += console
}
INCLUDEPATH += $$BASEDIR/lib/sdl/msvc/include \
$$BASEDIR/lib/opal/include \
@ -379,6 +380,7 @@ win32-g++ { @@ -379,6 +380,7 @@ win32-g++ {
debug {
#DESTDIR = $$BUILDDIR/debug
CONFIG += console
}
release {

58
src/ui/map3D/QGCGoogleEarthView.cc

@ -2,8 +2,12 @@ @@ -2,8 +2,12 @@
#include <QDir>
#include <QShowEvent>
#include <QSettings>
#include <QAxObject>
#include <QUuid>
#include <QDebug>
#include <QFile>
#include <QTextStream>
#include "UASManager.h"
#ifdef Q_OS_MAC
@ -41,6 +45,19 @@ QGCGoogleEarthView::QGCGoogleEarthView(QWidget *parent) : @@ -41,6 +45,19 @@ QGCGoogleEarthView::QGCGoogleEarthView(QWidget *parent) :
{
#ifdef _MSC_VER
// Create layout and attach webViewWin
/*
QFile file("doc.html");
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
qDebug() << __FILE__ << __LINE__ << "Could not open log file";
QTextStream out(&file);
out << webViewWin->generateDocumentation();
out.flush();
file.flush();
file.close();*/
#else
#endif
@ -154,7 +171,7 @@ void QGCGoogleEarthView::goHome() @@ -154,7 +171,7 @@ void QGCGoogleEarthView::goHome()
webViewMac->page()->currentFrame()->evaluateJavaScript("goHome();");
#endif
#ifdef _MSC_VER
webViewWin.dynamicCall("InvokeScript(\"goHome\");");
webViewWin->dynamicCall("InvokeScript(\"goHome\");");
#endif
}
@ -164,7 +181,7 @@ void QGCGoogleEarthView::setHome(double lat, double lon, double alt) @@ -164,7 +181,7 @@ void QGCGoogleEarthView::setHome(double lat, double lon, double alt)
webViewMac->page()->currentFrame()->evaluateJavaScript(QString("setGCSHome(%1,%2,%3);").arg(lat, 0, 'f', 15).arg(lon, 0, 'f', 15).arg(alt, 0, 'f', 15));
#endif
#ifdef _MSC_VER
webViewWin.dynamicCall(QString("InvokeScript(\"setGCSHome\", %1, %2, %3);").arg(lat, 0, 'f', 15).arg(lon, 0, 'f', 15).arg(alt, 0, 'f', 15));
webViewWin->dynamicCall((QString("InvokeScript(\"setGCSHome\", %1, %2, %3)").arg(lat, 0, 'f', 15).arg(lon, 0, 'f', 15).arg(alt, 0, 'f', 15)).toStdString().c_str());
#endif
}
@ -191,6 +208,31 @@ void QGCGoogleEarthView::showEvent(QShowEvent* event) @@ -191,6 +208,31 @@ void QGCGoogleEarthView::showEvent(QShowEvent* event)
#ifdef _MSC_VER
//webViewWin->dynamicCall("GoHome()");
webViewWin->dynamicCall("Navigate(const QString&)", QApplication::applicationDirPath() + "/earth.html");
/*
Sleep(4000);
QAxObject* doc = webViewWin->querySubObject("Document()");
IUnknown* winDoc = NULL;
doc->queryInterface(QUuid("{25336920-03F9-11CF-8FD0-00AA00686F13}"), (void**)(&winDoc));
//if (winDoc)
{
doc = new QAxObject(winDoc, webViewWin);
}
QFile file("ie-doc.html");
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
qDebug() << __FILE__ << __LINE__ << "Could not open log file";
QTextStream out(&file);
out << doc->generateDocumentation();
out.flush();
file.flush();
file.close();
while(1);
*/
#endif
webViewInitialized = true;
@ -211,7 +253,7 @@ void QGCGoogleEarthView::initializeGoogleEarth() @@ -211,7 +253,7 @@ void QGCGoogleEarthView::initializeGoogleEarth()
if (!webViewMac->page()->currentFrame()->evaluateJavaScript("isInitialized();").toBool())
#endif
#ifdef _MSC_VER
//if (!webViewMac->page()->currentFrame()->evaluateJavaScript("isInitialized();").toBool())
if (!webViewWin->dynamicCall("InvokeScript(const QString&)", QString("isInitialized")).toBool())
#endif
{
QTimer::singleShot(200, this, SLOT(initializeGoogleEarth()));
@ -281,7 +323,14 @@ void QGCGoogleEarthView::updateState() @@ -281,7 +323,14 @@ void QGCGoogleEarthView::updateState()
.arg(yaw));
#endif
#ifdef _MSC_VER
webViewWin->dynamicCall((QString("InvokeScript(\"setAircraftPositionAttitude\", %1, %2, %3, %4, %6, %7, %8);")
.arg(uasId)
.arg(lat)
.arg(lon)
.arg(alt+500)
.arg(roll)
.arg(pitch)
.arg(yaw)).toStdString().c_str());
#endif
}
@ -291,6 +340,7 @@ void QGCGoogleEarthView::updateState() @@ -291,6 +340,7 @@ void QGCGoogleEarthView::updateState()
webViewMac->page()->currentFrame()->evaluateJavaScript(QString("updateFollowAircraft()"));
#endif
#ifdef _MSC_VER
webViewWin->dynamicCall("InvokeScript(\"updateFollowAircraft\");");
#endif
}
}

21
src/ui/map3D/QGCGoogleEarthView.h

@ -11,19 +11,36 @@ @@ -11,19 +11,36 @@
#ifdef _MSC_VER
#include <ActiveQt/QAxWidget>
#include <ActiveQt/QAxObject>
#include "windows.h"
class QGCWebAxWidget : public QAxWidget
{
public:
//Q_OBJECT
QGCWebAxWidget(QWidget* parent = 0, Qt::WindowFlags f = 0)
: QAxWidget(parent, f)
: QAxWidget(parent, f),
_document(NULL)
{
// Set web browser control
setControl("{8856F961-340A-11D0-A96B-00C04FD705A2}");
//QObject::connect(this, SIGNAL(DocumentComplete(IDispatch*, QVariant&)), this, SLOT(setDocument(IDispatch*, QVariant&)));
}
QAxObject* document()
{
return _document;
}
protected:
void setDocument(IDispatch* dispatch, QVariant& variant)
{
_document = this->querySubObject("Document()");
}
protected:
QAxObject* _document;
virtual bool translateKeyEvent(int message, int keycode) const
{
if (message >= WM_KEYFIRST && message <= WM_KEYLAST)

Loading…
Cancel
Save