Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
0198993e
Commit
0198993e
authored
Dec 29, 2010
by
pixhawk
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'experimental' of pixhawk.ethz.ch:qgroundcontrol into experimental
parents
d5f5922c
1d560d9c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
394 additions
and
320 deletions
+394
-320
earth.html
images/earth.html
+26
-21
qgroundcontrol.pri
qgroundcontrol.pri
+4
-2
QGCGoogleEarthView.cc
src/ui/map3D/QGCGoogleEarthView.cc
+345
-295
QGCGoogleEarthView.h
src/ui/map3D/QGCGoogleEarthView.h
+19
-2
No files found.
images/earth.html
View file @
0198993e
...
...
@@ -13,12 +13,13 @@ google.load("earth", "1", { 'language': 'en'});
var
ge
=
null
;
var
initialized
=
false
;
var
aircraft
=
new
Array
();
var
currAircraft
=
220
;
var
follow
Enabled
=
false
;
var
follow
Aircraft
=
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)
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() {
function
setCurrAircraft
(
id
)
{
currAircraft
=
id
;
}
function
setGCSHome
(
lat
,
lon
,
alt
)
{
...
...
@@ -98,6 +90,13 @@ function setGCSHome(lat, lon, alt)
{
homeGroundLevel
=
alt
;
}
goHome
();
}
function
createAircraft
(
id
,
type
,
color
)
...
...
@@ -205,19 +204,17 @@ 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
);
planeLoc
.
setLatitude
(
lat
);
planeLoc
.
setLongitude
(
lon
);
planeLoc
.
setAltitude
(
alt
);
planeLoc
.
setLatitude
(
lat
);
planeLoc
.
setLongitude
(
lon
);
planeLoc
.
setAltitude
(
alt
);
}
...
...
@@ -249,16 +246,24 @@ 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
)
...
...
qgroundcontrol.pri
View file @
0198993e
...
...
@@ -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++ {
debug {
#DESTDIR = $$BUILDDIR/debug
CONFIG += console
}
release {
...
...
src/ui/map3D/QGCGoogleEarthView.cc
View file @
0198993e
#include <QApplication>
#include <QDir>
#include <QShowEvent>
#include <QSettings>
#include <QDebug>
#include "UASManager.h"
#ifdef Q_OS_MAC
#include <QWebFrame>
#include <QWebPage>
#include "QGCWebPage.h"
#endif
#include <QApplication>
#include <QDir>
#include <QShowEvent>
#include <QSettings>
#include <QAxObject>
#include <QUuid>
#include <QDebug>
#include <QFile>
#include <QTextStream>
#include "UASManager.h"
#ifdef Q_OS_MAC
#include <QWebFrame>
#include <QWebPage>
#include "QGCWebPage.h"
#endif
#include "QGC.h"
#include "ui_QGCGoogleEarthView.h"
#include "QGCGoogleEarthView.h"
#define QGCGOOGLEEARTHVIEWSETTINGS QString("GoogleEarthViewSettings_")
QGCGoogleEarthView
::
QGCGoogleEarthView
(
QWidget
*
parent
)
:
QWidget
(
parent
),
updateTimer
(
new
QTimer
(
this
)),
refreshRateMs
(
80
),
mav
(
NULL
),
followCamera
(
true
),
trailEnabled
(
true
),
webViewInitialized
(
false
),
gEarthInitialized
(
false
),
#if (defined Q_OS_MAC)
webViewMac
(
new
QWebView
(
this
)),
#endif
#ifdef _MSC_VER
webViewWin
(
new
QGCWebAxWidget
(
this
)),
#endif
#if (defined _MSC_VER)
ui
(
new
Ui
::
QGCGoogleEarthView
)
#else
ui
(
new
Ui
::
QGCGoogleEarthView
)
#endif
{
#ifdef _MSC_VER
// Create layout and attach webViewWin
#else
#endif
// Load settings
QSettings
settings
;
followCamera
=
settings
.
value
(
QGCGOOGLEEARTHVIEWSETTINGS
+
"follow"
,
followCamera
).
toBool
();
trailEnabled
=
settings
.
value
(
QGCGOOGLEEARTHVIEWSETTINGS
+
"trail"
,
trailEnabled
).
toBool
();
ui
->
setupUi
(
this
);
#if (defined Q_OS_MAC)
ui
->
webViewLayout
->
addWidget
(
webViewMac
);
connect
(
webViewMac
,
SIGNAL
(
loadFinished
(
bool
)),
this
,
SLOT
(
initializeGoogleEarth
(
bool
)));
#endif
#ifdef _MSC_VER
ui
->
webViewLayout
->
addWidget
(
webViewWin
);
#endif
connect
(
UASManager
::
instance
(),
SIGNAL
(
activeUASSet
(
UASInterface
*
)),
this
,
SLOT
(
setActiveUAS
(
UASInterface
*
)));
connect
(
updateTimer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
updateState
()));
// Follow checkbox
ui
->
followAirplaneCheckbox
->
setChecked
(
followCamera
);
connect
(
ui
->
followAirplaneCheckbox
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
follow
(
bool
)));
// Trail checkbox
ui
->
trailCheckbox
->
setChecked
(
trailEnabled
);
connect
(
ui
->
trailCheckbox
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
showTrail
(
bool
)));
// Go home
connect
(
ui
->
goHomeButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
goHome
()));
}
QGCGoogleEarthView
::~
QGCGoogleEarthView
()
{
QSettings
settings
;
settings
.
setValue
(
QGCGOOGLEEARTHVIEWSETTINGS
+
"follow"
,
followCamera
);
settings
.
setValue
(
QGCGOOGLEEARTHVIEWSETTINGS
+
"trail"
,
trailEnabled
);
settings
.
sync
();
delete
ui
;
}
void
QGCGoogleEarthView
::
addUAS
(
UASInterface
*
uas
)
{
#ifdef Q_OS_MAC
#include "ui_QGCGoogleEarthView.h"
#include "QGCGoogleEarthView.h"
#define QGCGOOGLEEARTHVIEWSETTINGS QString("GoogleEarthViewSettings_")
QGCGoogleEarthView
::
QGCGoogleEarthView
(
QWidget
*
parent
)
:
QWidget
(
parent
),
updateTimer
(
new
QTimer
(
this
)),
refreshRateMs
(
80
),
mav
(
NULL
),
followCamera
(
true
),
trailEnabled
(
true
),
webViewInitialized
(
false
),
gEarthInitialized
(
false
),
#if (defined Q_OS_MAC)
webViewMac
(
new
QWebView
(
this
)),
#endif
#ifdef _MSC_VER
webViewWin
(
new
QGCWebAxWidget
(
this
)),
#endif
#if (defined _MSC_VER)
ui
(
new
Ui
::
QGCGoogleEarthView
)
#else
ui
(
new
Ui
::
QGCGoogleEarthView
)
#endif
{
#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
// Load settings
QSettings
settings
;
followCamera
=
settings
.
value
(
QGCGOOGLEEARTHVIEWSETTINGS
+
"follow"
,
followCamera
).
toBool
();
trailEnabled
=
settings
.
value
(
QGCGOOGLEEARTHVIEWSETTINGS
+
"trail"
,
trailEnabled
).
toBool
();
ui
->
setupUi
(
this
);
#if (defined Q_OS_MAC)
ui
->
webViewLayout
->
addWidget
(
webViewMac
);
connect
(
webViewMac
,
SIGNAL
(
loadFinished
(
bool
)),
this
,
SLOT
(
initializeGoogleEarth
(
bool
)));
#endif
#ifdef _MSC_VER
ui
->
webViewLayout
->
addWidget
(
webViewWin
);
#endif
connect
(
UASManager
::
instance
(),
SIGNAL
(
activeUASSet
(
UASInterface
*
)),
this
,
SLOT
(
setActiveUAS
(
UASInterface
*
)));
connect
(
updateTimer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
updateState
()));
// Follow checkbox
ui
->
followAirplaneCheckbox
->
setChecked
(
followCamera
);
connect
(
ui
->
followAirplaneCheckbox
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
follow
(
bool
)));
// Trail checkbox
ui
->
trailCheckbox
->
setChecked
(
trailEnabled
);
connect
(
ui
->
trailCheckbox
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
showTrail
(
bool
)));
// Go home
connect
(
ui
->
goHomeButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
goHome
()));
}
QGCGoogleEarthView
::~
QGCGoogleEarthView
()
{
QSettings
settings
;
settings
.
setValue
(
QGCGOOGLEEARTHVIEWSETTINGS
+
"follow"
,
followCamera
);
settings
.
setValue
(
QGCGOOGLEEARTHVIEWSETTINGS
+
"trail"
,
trailEnabled
);
settings
.
sync
();
delete
ui
;
}
void
QGCGoogleEarthView
::
addUAS
(
UASInterface
*
uas
)
{
#ifdef Q_OS_MAC
// uasid, type, color (in aarrbbgg format)
webViewMac
->
page
()
->
currentFrame
()
->
evaluateJavaScript
(
QString
(
"createAircraft(%1, %2, %3);"
).
arg
(
uas
->
getUASID
()).
arg
(
uas
->
getSystemType
()).
arg
(
uas
->
getColor
().
name
().
remove
(
0
,
1
).
prepend
(
"50"
)));
#endif
#ifdef _MSC_VER
//if (webViewMac->page()->currentFrame()->evaluateJavaScript("isInitialized();").toBool())
#endif
// Automatically receive further position updates
connect
(
uas
,
SIGNAL
(
globalPositionChanged
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)),
this
,
SLOT
(
updateGlobalPosition
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)));
}
void
QGCGoogleEarthView
::
setActiveUAS
(
UASInterface
*
uas
)
{
if
(
uas
)
{
mav
=
uas
;
#ifdef Q_OS_MAC
if
(
webViewMac
->
page
()
->
currentFrame
()
->
evaluateJavaScript
(
"isInitialized();"
).
toBool
())
{
webViewMac
->
page
()
->
currentFrame
()
->
evaluateJavaScript
(
QString
(
"setCurrAircraft(%1);"
).
arg
(
uas
->
getUASID
()));
}
#endif
#ifdef _MSC_VER
//if (webViewMac->page()->currentFrame()->evaluateJavaScript("isInitialized();").toBool())
#endif
}
}
void
QGCGoogleEarthView
::
updateGlobalPosition
(
UASInterface
*
uas
,
double
lat
,
double
lon
,
double
alt
,
quint64
usec
)
{
Q_UNUSED
(
usec
);
#ifdef Q_OS_MAC
webViewMac
->
page
()
->
currentFrame
()
->
evaluateJavaScript
(
QString
(
"addTrailPosition(%1, %2, %3, %4);"
).
arg
(
uas
->
getUASID
()).
arg
(
lat
,
0
,
'f'
,
15
).
arg
(
lon
,
0
,
'f'
,
15
).
arg
(
alt
,
0
,
'f'
,
15
));
#endif
#ifdef _MSC_VER
//if (webViewMac->page()->currentFrame()->evaluateJavaScript("isInitialized();").toBool())
#endif
// Automatically receive further position updates
connect
(
uas
,
SIGNAL
(
globalPositionChanged
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)),
this
,
SLOT
(
updateGlobalPosition
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)));
}
void
QGCGoogleEarthView
::
setActiveUAS
(
UASInterface
*
uas
)
{
if
(
uas
)
{
mav
=
uas
;
#ifdef Q_OS_MAC
if
(
webViewMac
->
page
()
->
currentFrame
()
->
evaluateJavaScript
(
"isInitialized();"
).
toBool
())
{
webViewMac
->
page
()
->
currentFrame
()
->
evaluateJavaScript
(
QString
(
"setCurrAircraft(%1);"
).
arg
(
uas
->
getUASID
()));
}
#endif
#ifdef _MSC_VER
//if (webViewMac->page()->currentFrame()->evaluateJavaScript("isInitialized();").toBool())
#endif
}
}
void
QGCGoogleEarthView
::
updateGlobalPosition
(
UASInterface
*
uas
,
double
lat
,
double
lon
,
double
alt
,
quint64
usec
)
{
Q_UNUSED
(
usec
);
#ifdef Q_OS_MAC
webViewMac
->
page
()
->
currentFrame
()
->
evaluateJavaScript
(
QString
(
"addTrailPosition(%1, %2, %3, %4);"
).
arg
(
uas
->
getUASID
()).
arg
(
lat
,
0
,
'f'
,
15
).
arg
(
lon
,
0
,
'f'
,
15
).
arg
(
alt
,
0
,
'f'
,
15
));
//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);
#endif
#ifdef _MSC_VER
//if (webViewMac->page()->currentFrame()->evaluateJavaScript("isInitialized();").toBool())
#endif
}
void
QGCGoogleEarthView
::
showTrail
(
bool
state
)
{
ui
->
trailCheckbox
->
setChecked
(
state
);
}
void
QGCGoogleEarthView
::
showWaypoints
(
bool
state
)
{
}
void
QGCGoogleEarthView
::
follow
(
bool
follow
)
{
ui
->
followAirplaneCheckbox
->
setChecked
(
follow
);
followCamera
=
follow
;
}
void
QGCGoogleEarthView
::
goHome
()
{
// Disable follow and update
follow
(
false
);
updateState
();
// Go to home location
#ifdef Q_OS_MAC
webViewMac
->
page
()
->
currentFrame
()
->
evaluateJavaScript
(
"goHome();"
);
#endif
#ifdef _MSC_VER
webViewWin
.
dynamicCall
(
"InvokeScript(
\"
goHome
\"
);"
);
#endif
}
void
QGCGoogleEarthView
::
setHome
(
double
lat
,
double
lon
,
double
alt
)
{
#ifdef Q_OS_MAC
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
));
#endif
}
#endif
#ifdef _MSC_VER
//if (webViewMac->page()->currentFrame()->evaluateJavaScript("isInitialized();").toBool())
#endif
}
void
QGCGoogleEarthView
::
showTrail
(
bool
state
)
{
ui
->
trailCheckbox
->
setChecked
(
state
);
}
void
QGCGoogleEarthView
::
showWaypoints
(
bool
state
)
{
}
void
QGCGoogleEarthView
::
follow
(
bool
follow
)
{
ui
->
followAirplaneCheckbox
->
setChecked
(
follow
);
followCamera
=
follow
;
}
void
QGCGoogleEarthView
::
goHome
()
{
// Disable follow and update
follow
(
false
);
updateState
();
// Go to home location
#ifdef Q_OS_MAC
webViewMac
->
page
()
->
currentFrame
()
->
evaluateJavaScript
(
"goHome();"
);
#endif
#ifdef _MSC_VER
webViewWin
->
dynamicCall
(
"InvokeScript(
\"
goHome
\"
);"
);
#endif
}
void
QGCGoogleEarthView
::
setHome
(
double
lat
,
double
lon
,
double
alt
)
{
#ifdef Q_OS_MAC
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
)).
toStdString
().
c_str
());
#endif
}
void
QGCGoogleEarthView
::
hideEvent
(
QHideEvent
*
event
)
{
Q_UNUSED
(
event
)
updateTimer
->
stop
();
}
void
QGCGoogleEarthView
::
showEvent
(
QShowEvent
*
event
)
{
// React only to internal (pre-display)
// events
void
QGCGoogleEarthView
::
showEvent
(
QShowEvent
*
event
)
{
// React only to internal (pre-display)
// events
Q_UNUSED
(
event
)
{
// Enable widget, initialize on first run
if
(
!
webViewInitialized
)
{
#if (defined Q_OS_MAC)
webViewMac
->
setPage
(
new
QGCWebPage
(
webViewMac
));
webViewMac
->
settings
()
->
setAttribute
(
QWebSettings
::
PluginsEnabled
,
true
);
webViewMac
->
load
(
QUrl
(
"earth.html"
));
#endif
#ifdef _MSC_VER
//webViewWin->dynamicCall("GoHome()");
webViewWin
->
dynamicCall
(
"Navigate(const QString&)"
,
QApplication
::
applicationDirPath
()
+
"/earth.html"
);
#endif
webViewInitialized
=
true
;
// Reloading the webpage, this resets Google Earth
gEarthInitialized
=
false
;
QTimer
::
singleShot
(
1000
,
this
,
SLOT
(
initializeGoogleEarth
()));
updateTimer
->
start
(
refreshRateMs
);
}
}
}
void
QGCGoogleEarthView
::
initializeGoogleEarth
()
{
if
(
!
gEarthInitialized
)
{
#ifdef Q_OS_MAC
if
(
!
webViewMac
->
page
()
->
currentFrame
()
->
evaluateJavaScript
(
"isInitialized();"
).
toBool
())
#endif
#ifdef _MSC_VER
//if (!webViewMac->page()->currentFrame()->evaluateJavaScript("isInitialized();").toBool())
#endif
{
QTimer
::
singleShot
(
200
,
this
,
SLOT
(
initializeGoogleEarth
()));
}
else
{
// Set home location
setHome
(
47.3769
,
8.549444
,
500
);
// Move to home location
goHome
();
// Set current UAS
setActiveUAS
(
mav
);
// Add all MAVs
QList
<
UASInterface
*>
mavs
=
UASManager
::
instance
()
->
getUASList
();
foreach
(
UASInterface
*
mav
,
mavs
)
{
addUAS
(
mav
);
}
// Add any further MAV automatically
connect
(
UASManager
::
instance
(),
SIGNAL
(
UASCreated
(
UASInterface
*
)),
this
,
SLOT
(
addUAS
(
UASInterface
*
)));
gEarthInitialized
=
true
;
}
}
}
void
QGCGoogleEarthView
::
updateState
()
{
{
// Enable widget, initialize on first run
if
(
!
webViewInitialized
)
{
#if (defined Q_OS_MAC)
webViewMac
->
setPage
(
new
QGCWebPage
(
webViewMac
));
webViewMac
->
settings
()
->
setAttribute
(
QWebSettings
::
PluginsEnabled
,
true
);
webViewMac
->
load
(
QUrl
(
"earth.html"
));
#endif
#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
;
// Reloading the webpage, this resets Google Earth
gEarthInitialized
=
false
;
QTimer
::
singleShot
(
1000
,
this
,
SLOT
(
initializeGoogleEarth
()));
updateTimer
->
start
(
refreshRateMs
);
}
}
}
void
QGCGoogleEarthView
::
initializeGoogleEarth
()
{
if
(
!
gEarthInitialized
)
{
#ifdef Q_OS_MAC
if
(
!
webViewMac
->
page
()
->
currentFrame
()
->
evaluateJavaScript
(
"isInitialized();"
).
toBool
())
#endif
#ifdef _MSC_VER
if
(
!
webViewWin
->
dynamicCall
(
"InvokeScript(const QString&)"
,
QString
(
"isInitialized"
)).
toBool
())
#endif
{
QTimer
::
singleShot
(
200
,
this
,
SLOT
(
initializeGoogleEarth
()));
}
else
{
// Set home location
setHome
(
47.3769
,
8.549444
,
500
);
// Move to home location
goHome
();
// Set current UAS
setActiveUAS
(
mav
);
// Add all MAVs
QList
<
UASInterface
*>
mavs
=
UASManager
::
instance
()
->
getUASList
();
foreach
(
UASInterface
*
mav
,
mavs
)
{
addUAS
(
mav
);
}
// Add any further MAV automatically
connect
(
UASManager
::
instance
(),
SIGNAL
(
UASCreated
(
UASInterface
*
)),
this
,
SLOT
(
addUAS
(
UASInterface
*
)));
gEarthInitialized
=
true
;
}
}
}
void
QGCGoogleEarthView
::
updateState
()
{
#if (QGC_EVENTLOOP_DEBUG)
qDebug
()
<<
"EVENTLOOP:"
<<
__FILE__
<<
__LINE__
;
#endif
if
(
gEarthInitialized
)
{
int
uasId
=
0
;
double
lat
=
47.3769
;
double
lon
=
8.549444
;
double
alt
=
470.0
;
float
roll
=
0.0
f
;
float
pitch
=
0.0
f
;
float
yaw
=
0.0
f
;
// Update all MAVs
QList
<
UASInterface
*>
mavs
=
UASManager
::
instance
()
->
getUASList
();
foreach
(
UASInterface
*
mav
,
mavs
)
{
uasId
=
mav
->
getUASID
();
lat
=
mav
->
getLatitude
();
lon
=
mav
->
getLongitude
();
alt
=
mav
->
getAltitude
();
roll
=
mav
->
getRoll
();
pitch
=
mav
->
getPitch
();
yaw
=
mav
->
getYaw
();
#ifdef Q_OS_MAC
webViewMac
->
page
()
->
currentFrame
()
->
evaluateJavaScript
(
QString
(
"setAircraftPositionAttitude(%1, %2, %3, %4, %6, %7, %8);"
)
.
arg
(
uasId
)
.
arg
(
lat
)
.
arg
(
lon
)
.
arg
(
alt
+
500
)
.
arg
(
roll
)
.
arg
(
pitch
)
.
arg
(
yaw
));
#endif
#ifdef _MSC_VER
#endif
}
if
(
followCamera
)
{
#ifdef Q_OS_MAC
webViewMac
->
page
()
->
currentFrame
()
->
evaluateJavaScript
(
QString
(
"updateFollowAircraft()"
));
#endif
#ifdef _MSC_VER
#endif
}
}
}
void
QGCGoogleEarthView
::
changeEvent
(
QEvent
*
e
)
{
QWidget
::
changeEvent
(
e
);
switch
(
e
->
type
())
{
case
QEvent
:
:
LanguageChange
:
ui
->
retranslateUi
(
this
);
break
;
default:
break
;
}
}
if
(
gEarthInitialized
)
{
int
uasId
=
0
;
double
lat
=
47.3769
;
double
lon
=
8.549444
;
double
alt
=
470.0
;
float
roll
=
0.0
f
;
float
pitch
=
0.0
f
;
float
yaw
=
0.0
f
;
// Update all MAVs
QList
<
UASInterface
*>
mavs
=
UASManager
::
instance
()
->
getUASList
();
foreach
(
UASInterface
*
mav
,
mavs
)
{
uasId
=
mav
->
getUASID
();
lat
=
mav
->
getLatitude
();
lon
=
mav
->
getLongitude
();
alt
=
mav
->
getAltitude
();
roll
=
mav
->
getRoll
();
pitch
=
mav
->
getPitch
();
yaw
=
mav
->
getYaw
();
#ifdef Q_OS_MAC
webViewMac
->
page
()
->
currentFrame
()
->
evaluateJavaScript
(
QString
(
"setAircraftPositionAttitude(%1, %2, %3, %4, %6, %7, %8);"
)
.
arg
(
uasId
)
.
arg
(
lat
)
.
arg
(
lon
)
.
arg
(
alt
+
500
)
.
arg
(
roll
)
.
arg
(
pitch
)
.
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
}
if
(
followCamera
)
{
#ifdef Q_OS_MAC
webViewMac
->
page
()
->
currentFrame
()
->
evaluateJavaScript
(
QString
(
"updateFollowAircraft()"
));
#endif
#ifdef _MSC_VER
webViewWin
->
dynamicCall
(
"InvokeScript(
\"
updateFollowAircraft
\"
);"
);
#endif
}
}
}
void
QGCGoogleEarthView
::
changeEvent
(
QEvent
*
e
)
{
QWidget
::
changeEvent
(
e
);
switch
(
e
->
type
())
{
case
QEvent
:
:
LanguageChange
:
ui
->
retranslateUi
(
this
);
break
;
default:
break
;
}
}
src/ui/map3D/QGCGoogleEarthView.h
View file @
0198993e
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment