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
8838c74b
Commit
8838c74b
authored
Dec 31, 2010
by
pixhawk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Google earth working, ready for last fixes and performance testing.
parent
c664ad33
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
300 additions
and
86 deletions
+300
-86
earth.html
images/earth.html
+43
-25
qgroundcontrol.pro
qgroundcontrol.pro
+0
-1
GAudioOutput.cc
src/GAudioOutput.cc
+42
-3
GAudioOutput.h
src/GAudioOutput.h
+5
-0
MAVLinkSimulationLink.cc
src/comm/MAVLinkSimulationLink.cc
+24
-0
MAVLinkSimulationLink.h
src/comm/MAVLinkSimulationLink.h
+1
-1
ArduPilotMegaMAV.cc
src/uas/ArduPilotMegaMAV.cc
+2
-2
UASInterface.h
src/uas/UASInterface.h
+2
-2
MainWindow.cc
src/ui/MainWindow.cc
+3
-0
MainWindow.ui
src/ui/MainWindow.ui
+18
-1
QGCGoogleEarthView.cc
src/ui/map3D/QGCGoogleEarthView.cc
+89
-29
QGCGoogleEarthView.h
src/ui/map3D/QGCGoogleEarthView.h
+24
-18
QGCGoogleEarthView.ui
src/ui/map3D/QGCGoogleEarthView.ui
+47
-4
No files found.
images/earth.html
View file @
8838c74b
...
...
@@ -7,6 +7,7 @@
<!-- QGroundControl -->
<title>
QGroundControl Google Earth View
</title>
<!-- *** Replace the key below below with your own API key, available at http://code.google.com/apis/maps/signup.html *** -->
<script
type=
"text/javascript"
src=
"https://getfirebug.com/firebug-lite-beta.js"
></script>
<script
type=
"text/javascript"
src=
"http://www.google.com/jsapi?key=ABQIAAAAwbkbZLyhsmTCWXbTcjbgbRSzHs7K5SvaUdm8ua-Xxy_-2dYwMxQMhnagaawTo7L1FE1-amhuQxIlXw"
></script>
<script
type=
"text/javascript"
>
google
.
load
(
"
earth
"
,
"
1
"
,
{
'
language
'
:
'
en
'
});
...
...
@@ -46,8 +47,10 @@ var aircraft = [];
var
attitudes
=
[];
var
locations
=
[];
var
trails
=
[];
var
trail
;
var
lineStringPlacemark
;
var
trailPlacemarks
=
[];
var
trailsVisible
=
[];
var
trailColors
=
[];
//var trailPlacemarks[id];
var
lineStyle
;
// Aircraft class
...
...
@@ -133,54 +136,72 @@ function createAircraft(id, type, color)
locations
[
id
]
=
planeLoc
;
//planeColor = color;
//createTrail(id, color);
createTrail
(
id
,
color
);
console
.
log
(
color
);
}
function
createTrail
(
id
,
color
)
{
lineStringPlacemark
=
ge
.
createPlacemark
(
''
);
trailPlacemarks
[
id
]
=
ge
.
createPlacemark
(
''
);
// Create the placemark
// Create the LineString; set it to extend down to the ground
// and set the altitude mode
trail
=
ge
.
createLineString
(
''
);
lineStringPlacemark
.
setGeometry
(
trail
);
trail
.
setExtrude
(
false
);
trail
.
setAltitudeMode
(
ge
.
ALTITUDE_ABSOLUTE
);
trail
s
[
id
]
=
ge
.
createLineString
(
''
);
trailPlacemarks
[
id
].
setGeometry
(
trails
[
id
]
);
trail
s
[
id
]
.
setExtrude
(
false
);
trail
s
[
id
]
.
setAltitudeMode
(
ge
.
ALTITUDE_ABSOLUTE
);
// Add LineString points
//lineString.getCoordinates().pushLatLngAlt(48.754, -121.835, 700);
// Create a style and set width and color of line
lineStringPlacemark
.
setStyleSelector
(
ge
.
createStyle
(
''
));
lineStyle
=
lineStringPlacemark
.
getStyleSelector
().
getLineStyle
();
trailPlacemarks
[
id
]
.
setStyleSelector
(
ge
.
createStyle
(
''
));
lineStyle
=
trailPlacemarks
[
id
]
.
getStyleSelector
().
getLineStyle
();
lineStyle
.
setWidth
(
5
);
lineStyle
.
getColor
().
set
(
planeColor
);
// aabbggrr format
//lineStyle.getColor().set(color);
//lineStyle.getColor().set(color); // aabbggrr format
trailColors
[
id
]
=
color
;
lineStyle
.
getColor
().
set
(
'
00000000
'
);
// aabbggrr format
trailsVisible
[
id
]
=
false
;
// Add the feature to Earth
ge
.
getFeatures
().
appendChild
(
lineStringPlacemark
);
//ge.getFeatures().appendChild(trailPlacemarks[id]
);
}
function
hideTrail
(
id
)
{
trailsVisible
[
id
]
=
false
;
ge
.
getFeatures
().
removeChild
(
trailPlacemarks
[
id
]);
}
function
showTrail
(
id
)
{
ge
.
getFeatures
().
appendChild
(
trailPlacemarks
[
id
]);
trailsVisible
[
id
]
=
true
;
}
function
setViewRange
(
dist
)
{
currViewRange
=
dist
;
}
function
addTrailPosition
(
id
,
lat
,
lon
,
alt
)
{
trail
.
setExtrude
(
false
);
trail
.
setAltitudeMode
(
ge
.
ALTITUDE_ABSOLUTE
);
trail
s
[
id
]
.
setExtrude
(
false
);
trail
s
[
id
]
.
setAltitudeMode
(
ge
.
ALTITUDE_ABSOLUTE
);
// Add LineString points
//lineString.getCoordinates().pushLatLngAlt(48.754, -121.835, 700);
trail
.
getCoordinates
().
pushLatLngAlt
(
currLat
,
currLon
,
currAlt
);
trails
[
id
].
getCoordinates
().
pushLatLngAlt
(
lat
,
lon
,
alt
);
// Create a style and set width and color of line
lineStringPlacemark
.
setStyleSelector
(
ge
.
createStyle
(
''
));
lineStyle
=
lineStringPlacemark
.
getStyleSelector
().
getLineStyle
();
trailPlacemarks
[
id
]
.
setStyleSelector
(
ge
.
createStyle
(
''
));
lineStyle
=
trailPlacemarks
[
id
]
.
getStyleSelector
().
getLineStyle
();
lineStyle
.
setWidth
(
5
);
lineStyle
.
getColor
().
set
(
planeColor
);
// aabbggrr format
lineStyle
.
getColor
().
set
(
trailColors
[
id
]
);
// aabbggrr format
//lineStyle.getColor().set(color); // aabbggrr format
// Add the feature to Earth
ge
.
getFeatures
().
replaceChild
(
lineStringPlacemark
,
lineStringPlacemark
);
if
(
trailsVisible
[
id
]
==
true
)
ge
.
getFeatures
().
replaceChild
(
trailPlacemarks
[
id
],
trailPlacemarks
[
id
]
);
}
function
initCallback
(
object
)
...
...
@@ -198,9 +219,6 @@ function initCallback(object)
ge
.
getLayerRoot
().
enableLayerById
(
ge
.
LAYER_BORDERS
,
true
);
ge
.
getLayerRoot
().
enableLayerById
(
ge
.
LAYER_TREES
,
true
);
createTrail
(
220
,
'
bb2222ff
'
);
createAircraft
(
220
);
initialized
=
true
;
...
...
qgroundcontrol.pro
View file @
8838c74b
...
...
@@ -145,7 +145,6 @@ FORMS += src/ui/MainWindow.ui \
src
/
ui
/
QGCWebView
.
ui
\
src
/
ui
/
map3D
/
QGCGoogleEarthView
.
ui
\
src
/
ui
/
map3D
/
QGCGoogleEarthViewWin
.
ui
\
src
/
ui
/
map3D
/
QGCGoogleEarthControls
.
ui
\
src
/
ui
/
SlugsDataSensorView
.
ui
\
src
/
ui
/
SlugsHilSim
.
ui
\
src
/
ui
/
SlugsPIDControl
.
ui
\
...
...
src/GAudioOutput.cc
View file @
8838c74b
...
...
@@ -30,6 +30,7 @@ This file is part of the QGROUNDCONTROL project
*/
#include <QApplication>
#include <QSettings>
#include <QTemporaryFile>
#include "GAudioOutput.h"
#include "MG.h"
...
...
@@ -85,10 +86,19 @@ GAudioOutput* GAudioOutput::instance()
return
_instance
;
}
#define QGC_GAUDIOOUTPUT_KEY QString("QGC_AUDIOOUTPUT_")
GAudioOutput
::
GAudioOutput
(
QObject
*
parent
)
:
QObject
(
parent
),
voiceIndex
(
0
),
emergency
(
false
)
emergency
(
false
),
muted
(
false
)
{
// Load settings
QSettings
settings
;
settings
.
sync
();
muted
=
settings
.
value
(
QGC_GAUDIOOUTPUT_KEY
+
"muted"
,
muted
).
toBool
();
#ifdef Q_OS_LINUX
flite_init
();
#endif
...
...
@@ -134,13 +144,28 @@ emergency(false)
GAudioOutput
::~
GAudioOutput
()
{
QSettings
settings
;
settings
.
setValue
(
QGC_GAUDIOOUTPUT_KEY
+
"muted"
,
muted
);
settings
.
sync
();
#ifdef _MSC_VER2
::
CoUninitialize
();
#endif
}
void
GAudioOutput
::
mute
(
bool
mute
)
{
this
->
muted
=
mute
;
}
bool
GAudioOutput
::
isMuted
()
{
return
this
->
muted
;
}
bool
GAudioOutput
::
say
(
QString
text
,
int
severity
)
{
if
(
!
muted
)
{
// TODO Add severity filter
Q_UNUSED
(
severity
);
bool
res
=
false
;
...
...
@@ -183,13 +208,18 @@ bool GAudioOutput::say(QString text, int severity)
}
return
res
;
}
else
{
return
false
;
}
}
/**
* @param text This message will be played after the alert beep
*/
bool
GAudioOutput
::
alert
(
QString
text
)
{
if
(
!
emergency
)
if
(
!
emergency
||
!
muted
)
{
// Play alert sound
beep
();
...
...
@@ -205,19 +235,25 @@ bool GAudioOutput::alert(QString text)
void
GAudioOutput
::
notifyPositive
()
{
if
(
!
muted
)
{
// Use QFile to transform path for all OS
QFile
f
(
QCoreApplication
::
applicationDirPath
()
+
QString
(
"/audio/double_notify.wav"
));
m_media
->
setCurrentSource
(
Phonon
::
MediaSource
(
f
.
fileName
().
toStdString
().
c_str
()));
m_media
->
play
();
}
}
void
GAudioOutput
::
notifyNegative
()
{
if
(
!
muted
)
{
// Use QFile to transform path for all OS
QFile
f
(
QCoreApplication
::
applicationDirPath
()
+
QString
(
"/audio/flat_notify.wav"
));
m_media
->
setCurrentSource
(
Phonon
::
MediaSource
(
f
.
fileName
().
toStdString
().
c_str
()));
m_media
->
play
();
}
}
/**
* The emergency sound will be played continously during the emergency.
...
...
@@ -232,7 +268,7 @@ bool GAudioOutput::startEmergency()
{
emergency
=
true
;
// Beep immediately and then start timer
beep
();
if
(
!
muted
)
beep
();
emergencyTimer
->
start
(
1500
);
QTimer
::
singleShot
(
5000
,
this
,
SLOT
(
stopEmergency
()));
}
...
...
@@ -257,11 +293,14 @@ bool GAudioOutput::stopEmergency()
void
GAudioOutput
::
beep
()
{
if
(
!
muted
)
{
// Use QFile to transform path for all OS
QFile
f
(
QCoreApplication
::
applicationDirPath
()
+
QString
(
"/audio/alert.wav"
));
m_media
->
setCurrentSource
(
Phonon
::
MediaSource
(
f
.
fileName
().
toStdString
().
c_str
()));
m_media
->
play
();
}
}
void
GAudioOutput
::
selectFemaleVoice
()
{
...
...
src/GAudioOutput.h
View file @
8838c74b
...
...
@@ -99,6 +99,10 @@ public slots:
void
notifyPositive
();
/** @brief Notify about negative event */
void
notifyNegative
();
/** @brief Mute/unmute sound */
void
mute
(
bool
mute
);
/** @brief Get the mute state */
bool
isMuted
();
protected:
#ifdef Q_OS_MAC
...
...
@@ -112,6 +116,7 @@ protected:
Phonon
::
AudioOutput
*
m_audioOutput
;
bool
emergency
;
///< Emergency status flag
QTimer
*
emergencyTimer
;
bool
muted
;
private:
GAudioOutput
(
QObject
*
parent
=
NULL
);
~
GAudioOutput
();
...
...
src/comm/MAVLinkSimulationLink.cc
View file @
8838c74b
...
...
@@ -419,6 +419,20 @@ void MAVLinkSimulationLink::mainloop()
memcpy
(
stream
+
streampointer
,
buffer
,
bufferlength
);
streampointer
+=
bufferlength
;
// GLOBAL POSITION VEHICLE 2
mavlink_msg_global_position_int_pack
(
54
,
componentId
,
&
ret
,
(
473780.28137103
+
(
x
+
0.002
))
*
1E3
,
(
85489.9892510421
+
((
y
/
2
)
+
0.3
))
*
1E3
,
(
z
+
570.0
)
*
1000.0
,
0
*
100.0
,
0
*
100.0
,
0
*
100.0
);
bufferlength
=
mavlink_msg_to_send_buffer
(
buffer
,
&
ret
);
//add data into datastream
memcpy
(
stream
+
streampointer
,
buffer
,
bufferlength
);
streampointer
+=
bufferlength
;
// GLOBAL POSITION VEHICLE 3
mavlink_msg_global_position_int_pack
(
60
,
componentId
,
&
ret
,
(
473780.28137103
+
(
x
/
2
+
0.002
))
*
1E3
,
(
85489.9892510421
+
((
y
*
2
)
+
0.3
))
*
1E3
,
(
z
+
590.0
)
*
1000.0
,
0
*
100.0
,
0
*
100.0
,
0
*
100.0
);
bufferlength
=
mavlink_msg_to_send_buffer
(
buffer
,
&
ret
);
//add data into datastream
memcpy
(
stream
+
streampointer
,
buffer
,
bufferlength
);
streampointer
+=
bufferlength
;
static
int
rcCounter
=
0
;
if
(
rcCounter
==
2
)
{
...
...
@@ -594,6 +608,16 @@ void MAVLinkSimulationLink::mainloop()
memcpy
(
stream
+
streampointer
,
buffer
,
bufferlength
);
streampointer
+=
bufferlength
;
// HEARTBEAT VEHICLE 3
// Pack message and get size of encoded byte string
messageSize
=
mavlink_msg_heartbeat_pack
(
60
,
componentId
,
&
msg
,
MAV_FIXED_WING
,
MAV_AUTOPILOT_PIXHAWK
);
// Allocate buffer with packet data
bufferlength
=
mavlink_msg_to_send_buffer
(
buffer
,
&
msg
);
//add data into datastream
memcpy
(
stream
+
streampointer
,
buffer
,
bufferlength
);
streampointer
+=
bufferlength
;
// STATUS VEHICLE 2
mavlink_sys_status_t
status2
;
status2
.
mode
=
MAV_MODE_LOCKED
;
...
...
src/comm/MAVLinkSimulationLink.h
View file @
8838c74b
...
...
@@ -128,7 +128,7 @@ protected:
void
enqueue
(
uint8_t
*
stream
,
uint8_t
*
index
,
mavlink_message_t
*
msg
);
static
const
uint8_t
systemId
=
220
;
static
const
uint8_t
componentId
=
0
;
static
const
uint8_t
componentId
=
20
0
;
static
const
uint16_t
version
=
1000
;
signals:
...
...
src/uas/ArduPilotMegaMAV.cc
View file @
8838c74b
...
...
@@ -54,11 +54,11 @@ void ArduPilotMegaMAV::receiveMessage(LinkInterface* link, mavlink_message_t mes
{
case
MAVLINK_MSG_ID_HEARTBEAT
:
{
qDebug
()
<<
"ARDUPILOT RECEIVED HEARTBEAT"
;
//
qDebug() << "ARDUPILOT RECEIVED HEARTBEAT";
break
;
}
default:
qDebug
()
<<
"
\n
ARDUPILOT RECEIVED MESSAGE WITH ID"
<<
message
.
msgid
;
//
qDebug() << "\nARDUPILOT RECEIVED MESSAGE WITH ID" << message.msgid;
break
;
}
}
...
...
src/uas/UASInterface.h
View file @
8838c74b
...
...
@@ -126,6 +126,7 @@ public:
///> Map will start from beginning when the first 20 colors are exceeded
colors
.
append
(
QColor
(
231
,
72
,
28
));
colors
.
append
(
QColor
(
104
,
64
,
240
));
colors
.
append
(
QColor
(
203
,
254
,
121
));
colors
.
append
(
QColor
(
161
,
252
,
116
));
colors
.
append
(
QColor
(
232
,
33
,
47
));
...
...
@@ -140,11 +141,10 @@ public:
colors
.
append
(
QColor
(
87
,
231
,
246
));
colors
.
append
(
QColor
(
151
,
59
,
239
));
colors
.
append
(
QColor
(
81
,
183
,
244
));
colors
.
append
(
QColor
(
104
,
64
,
240
));
colors
.
append
(
QColor
(
75
,
133
,
243
));
colors
.
append
(
QColor
(
242
,
255
,
128
));
colors
.
append
(
QColor
(
230
,
126
,
23
));
nextColor
++
;
nextColor
=
0
;
}
return
colors
[
nextColor
++
];
}
...
...
src/ui/MainWindow.cc
View file @
8838c74b
...
...
@@ -110,6 +110,9 @@ MainWindow::MainWindow(QWidget *parent):
connectCommonActions
();
// Add option for custom widgets
connect
(
ui
.
actionNewCustomWidget
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
createCustomWidget
()));
// Allow to mute audio
ui
.
actionMuteAudioOutput
->
setChecked
(
GAudioOutput
::
instance
()
->
isMuted
());
connect
(
ui
.
actionMuteAudioOutput
,
SIGNAL
(
triggered
(
bool
)),
GAudioOutput
::
instance
(),
SLOT
(
mute
(
bool
)));
// Set dock options
setDockOptions
(
AnimatedDocks
|
AllowTabbedDocks
|
AllowNestedDocks
);
...
...
src/ui/MainWindow.ui
View file @
8838c74b
...
...
@@ -38,7 +38,7 @@
<x>
0
</x>
<y>
0
</y>
<width>
1000
</width>
<height>
2
5
</height>
<height>
2
2
</height>
</rect>
</property>
<widget
class=
"QMenu"
name=
"menuMGround"
>
...
...
@@ -47,6 +47,7 @@
</property>
<addaction
name=
"actionJoystick_Settings"
/>
<addaction
name=
"actionNewCustomWidget"
/>
<addaction
name=
"actionMuteAudioOutput"
/>
<addaction
name=
"actionSimulate"
/>
<addaction
name=
"separator"
/>
<addaction
name=
"actionExit"
/>
...
...
@@ -435,6 +436,22 @@
<string>
New Custom Widget
</string>
</property>
</action>
<action
name=
"actionMuteAudioOutput"
>
<property
name=
"checkable"
>
<bool>
true
</bool>
</property>
<property
name=
"icon"
>
<iconset
resource=
"../../mavground.qrc"
>
<normaloff>
:/images/status/audio-volume-high.svg
</normaloff>
<normalon>
:/images/status/audio-volume-muted.svg
</normalon>
<activeon>
:/images/status/audio-volume-muted.svg
</activeon>
<selectedoff>
:/images/status/audio-volume-high.svg
</selectedoff>
<selectedon>
:/images/status/audio-volume-muted.svg
</selectedon>
:/images/status/audio-volume-high.svg
</iconset>
</property>
<property
name=
"text"
>
<string>
Mute Audio Output
</string>
</property>
</action>
</widget>
<layoutdefault
spacing=
"6"
margin=
"11"
/>
<resources>
...
...
src/ui/map3D/QGCGoogleEarthView.cc
View file @
8838c74b
...
...
@@ -81,19 +81,7 @@ QGCGoogleEarthView::QGCGoogleEarthView(QWidget *parent) :
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
()
...
...
@@ -102,13 +90,45 @@ QGCGoogleEarthView::~QGCGoogleEarthView()
settings
.
setValue
(
QGCGOOGLEEARTHVIEWSETTINGS
+
"follow"
,
followCamera
);
settings
.
setValue
(
QGCGOOGLEEARTHVIEWSETTINGS
+
"trail"
,
trailEnabled
);
settings
.
sync
();
#if (defined Q_OS_MAC)
delete
webViewMac
;
#endif
#ifdef _MSC_VER
delete
webViewWin
;
#endif
delete
ui
;
}
/**
* @param range in centimeters
*/
void
QGCGoogleEarthView
::
setViewRangeScaledInt
(
int
range
)
{
setViewRange
(
range
/
100.0
f
);
}
/**
* @param range in meters (SI-units)
*/
void
QGCGoogleEarthView
::
setViewRange
(
float
range
)
{
javaScript
(
QString
(
"setViewRange(%1);"
).
arg
(
range
,
0
,
'f'
,
5
));
}
void
QGCGoogleEarthView
::
addUAS
(
UASInterface
*
uas
)
{
// uasid, type, color (in aarrbbgg format)
javaScript
(
QString
(
"createAircraft(%1, %2, %3);"
).
arg
(
uas
->
getUASID
()).
arg
(
uas
->
getSystemType
()).
arg
(
uas
->
getColor
().
name
().
remove
(
0
,
1
).
prepend
(
"50"
)));
// uasid, type, color (in #rrbbgg format)
QString
uasColor
=
uas
->
getColor
().
name
().
remove
(
0
,
1
);
// Convert to bbggrr format
QString
rChannel
=
uasColor
.
mid
(
0
,
2
);
uasColor
.
remove
(
0
,
2
);
uasColor
.
prepend
(
rChannel
);
// Set alpha value to 0x66, append JavaScript quotes ('')
uasColor
.
prepend
(
"'66"
).
append
(
"'"
);
javaScript
(
QString
(
"createAircraft(%1, %2, %3);"
).
arg
(
uas
->
getUASID
()).
arg
(
uas
->
getSystemType
()).
arg
(
uasColor
));
if
(
trailEnabled
)
javaScript
(
QString
(
"showTrail(%1);"
).
arg
(
uas
->
getUASID
()));
//javaScript(QString("createAircraft(%1, %2, %3);").arg(uas->getUASID()).arg(uas->getSystemType()).arg("0"));
// Automatically receive further position updates
connect
(
uas
,
SIGNAL
(
globalPositionChanged
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)),
this
,
SLOT
(
updateGlobalPosition
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)));
...
...
@@ -123,7 +143,7 @@ void QGCGoogleEarthView::setActiveUAS(UASInterface* uas)
}
}
void
QGCGoogleEarthView
::
updateGlobalPosition
(
UASInterface
*
uas
,
double
l
at
,
double
lon
,
double
alt
,
quint64
usec
)
void
QGCGoogleEarthView
::
updateGlobalPosition
(
UASInterface
*
uas
,
double
l
on
,
double
lat
,
double
alt
,
quint64
usec
)
{
Q_UNUSED
(
usec
);
javaScript
(
QString
(
"addTrailPosition(%1, %2, %3, %4);"
).
arg
(
uas
->
getUASID
()).
arg
(
lat
,
0
,
'f'
,
15
).
arg
(
lon
,
0
,
'f'
,
15
).
arg
(
alt
,
0
,
'f'
,
15
));
...
...
@@ -133,6 +153,26 @@ void QGCGoogleEarthView::updateGlobalPosition(UASInterface* uas, double lat, dou
void
QGCGoogleEarthView
::
showTrail
(
bool
state
)
{
// Check if the current trail has to be hidden
if
(
trailEnabled
&&
!
state
)
{
QList
<
UASInterface
*>
mavs
=
UASManager
::
instance
()
->
getUASList
();
foreach
(
UASInterface
*
currMav
,
mavs
)
{
javaScript
(
QString
(
"hideTrail(%1);"
).
arg
(
currMav
->
getUASID
()));
}
}
// Check if the current trail has to be shown
if
(
!
trailEnabled
&&
state
)
{
QList
<
UASInterface
*>
mavs
=
UASManager
::
instance
()
->
getUASList
();
foreach
(
UASInterface
*
currMav
,
mavs
)
{
javaScript
(
QString
(
"showTrail(%1);"
).
arg
(
currMav
->
getUASID
()));
}
}
trailEnabled
=
state
;
ui
->
trailCheckbox
->
setChecked
(
state
);
}
...
...
@@ -173,7 +213,9 @@ void QGCGoogleEarthView::showEvent(QShowEvent* event)
Q_UNUSED
(
event
)
{
// Enable widget, initialize on first run
if
(
!
webViewInitialized
)
// FIXME Re-inits now on every visibility change
//if (!webViewInitialized)
{
#if (defined Q_OS_MAC)
webViewMac
->
setPage
(
new
QGCWebPage
(
webViewMac
));
...
...
@@ -276,18 +318,36 @@ void QGCGoogleEarthView::initializeGoogleEarth()
// Move to home location
goHome
();
// Set current UAS
setActiveUAS
(
mav
);
// Add all MAVs
QList
<
UASInterface
*>
mavs
=
UASManager
::
instance
()
->
getUASList
();
foreach
(
UASInterface
*
m
av
,
mavs
)
foreach
(
UASInterface
*
currM
av
,
mavs
)
{
addUAS
(
m
av
);
addUAS
(
currM
av
);
}
// Set current UAS
setActiveUAS
(
UASManager
::
instance
()
->
getActiveUAS
());
// Add any further MAV automatically
connect
(
UASManager
::
instance
(),
SIGNAL
(
UASCreated
(
UASInterface
*
)),
this
,
SLOT
(
addUAS
(
UASInterface
*
)));
connect
(
UASManager
::
instance
(),
SIGNAL
(
activeUASSet
(
UASInterface
*
)),
this
,
SLOT
(
setActiveUAS
(
UASInterface
*
)));
// Connect UI signals/slots
// 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
()));
// Cam distance slider
connect
(
ui
->
camDistanceSlider
,
SIGNAL
(
valueChanged
(
int
)),
this
,
SLOT
(
setViewRangeScaledInt
(
int
)));
setViewRangeScaledInt
(
ui
->
camDistanceSlider
->
value
());
gEarthInitialized
=
true
;
}
...
...
@@ -312,15 +372,15 @@ void QGCGoogleEarthView::updateState()
// Update all MAVs
QList
<
UASInterface
*>
mavs
=
UASManager
::
instance
()
->
getUASList
();
foreach
(
UASInterface
*
m
av
,
mavs
)
foreach
(
UASInterface
*
currM
av
,
mavs
)
{
uasId
=
m
av
->
getUASID
();
lat
=
m
av
->
getLatitude
();
lon
=
m
av
->
getLongitude
();
alt
=
m
av
->
getAltitude
();
roll
=
m
av
->
getRoll
();
pitch
=
m
av
->
getPitch
();
yaw
=
m
av
->
getYaw
();
uasId
=
currM
av
->
getUASID
();
lat
=
currM
av
->
getLatitude
();
lon
=
currM
av
->
getLongitude
();
alt
=
currM
av
->
getAltitude
();
roll
=
currM
av
->
getRoll
();
pitch
=
currM
av
->
getPitch
();
yaw
=
currM
av
->
getYaw
();
javaScript
(
QString
(
"setAircraftPositionAttitude(%1, %2, %3, %4, %6, %7, %8);"
)
.
arg
(
uasId
)
...
...
src/ui/map3D/QGCGoogleEarthView.h
View file @
8838c74b
...
...
@@ -17,30 +17,30 @@
class
QGCWebAxWidget
:
public
QAxWidget
{
public:
//Q_OBJECT
//Q_OBJECT
QGCWebAxWidget
(
QWidget
*
parent
=
0
,
Qt
::
WindowFlags
f
=
0
)
:
QAxWidget
(
parent
,
f
)
/*,
_document(NULL)*/
{
// Set web browser control
setControl
(
"{8856F961-340A-11D0-A96B-00C04FD705A2}"
);
// WARNING: Makes it impossible to actually debug javascript. But useful in production mode
setProperty
(
"ScriptErrorsSuppressed"
,
true
);
// see: http://www.codeproject.com/KB/cpp/ExtendedWebBrowser.aspx?fid=285594&df=90&mpp=25&noise=3&sort=Position&view=Quick&fr=151#GoalScriptError
// Set web browser control
setControl
(
"{8856F961-340A-11D0-A96B-00C04FD705A2}"
);
// WARNING: Makes it impossible to actually debug javascript. But useful in production mode
setProperty
(
"ScriptErrorsSuppressed"
,
true
);
// see: http://www.codeproject.com/KB/cpp/ExtendedWebBrowser.aspx?fid=285594&df=90&mpp=25&noise=3&sort=Position&view=Quick&fr=151#GoalScriptError
//this->dynamicCall("setProperty(const QString&,
//QObject::connect(this, SIGNAL(DocumentComplete(IDispatch*, QVariant&)), this, SLOT(setDocument(IDispatch*, QVariant&)));
//this->dynamicCall("setProperty(const QString&,
//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()");
...
...
@@ -81,7 +81,7 @@ public slots:
/** @brief Set the currently selected UAS */
void
setActiveUAS
(
UASInterface
*
uas
);
/** @brief Update the global position */
void
updateGlobalPosition
(
UASInterface
*
uas
,
double
l
at
,
double
lon
,
double
alt
,
quint64
usec
);
void
updateGlobalPosition
(
UASInterface
*
uas
,
double
l
on
,
double
lat
,
double
alt
,
quint64
usec
);
/** @brief Show the vehicle trail */
void
showTrail
(
bool
state
);
/** @brief Show the waypoints */
...
...
@@ -92,14 +92,19 @@ public slots:
void
goHome
();
/** @brief Set the home location */
void
setHome
(
double
lat
,
double
lon
,
double
alt
);
/** @brief Set camera view range to aircraft in meters */
void
setViewRange
(
float
range
);
/** @brief Set camera view range to aircraft in centimeters */
void
setViewRangeScaledInt
(
int
range
);
/** @brief Initialize Google Earth */
void
initializeGoogleEarth
();
/** @brief Print a Windows exception */
void
printWinException
(
int
no
,
QString
str1
,
QString
str2
,
QString
str3
);
/** @brief Print a Windows exception */
void
printWinException
(
int
no
,
QString
str1
,
QString
str2
,
QString
str3
);
public:
/** @brief Execute java script inside the Google Earth window */
QVariant
javaScript
(
QString
javascript
);
/** @brief Execute java script inside the Google Earth window */
QVariant
javaScript
(
QString
javascript
);
protected:
void
changeEvent
(
QEvent
*
e
);
...
...
@@ -108,12 +113,13 @@ protected:
UASInterface
*
mav
;
bool
followCamera
;
bool
trailEnabled
;
bool
waypointsEnabled
;
bool
webViewInitialized
;
bool
jScriptInitialized
;
bool
jScriptInitialized
;
bool
gEarthInitialized
;
#ifdef _MSC_VER
QGCWebAxWidget
*
webViewWin
;
QAxObject
*
jScriptWin
;
QAxObject
*
jScriptWin
;
#endif
#if (defined Q_OS_MAC)
QWebView
*
webViewMac
;
...
...
src/ui/map3D/QGCGoogleEarthView.ui
View file @
8838c74b
...
...
@@ -6,7 +6,7 @@
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
597
</width>
<width>
828
</width>
<height>
300
</height>
</rect>
</property>
...
...
@@ -23,7 +23,7 @@
<property
name=
"margin"
>
<number>
2
</number>
</property>
<item
row=
"0"
column=
"0"
colspan=
"
6
"
>
<item
row=
"0"
column=
"0"
colspan=
"
10
"
>
<layout
class=
"QVBoxLayout"
name=
"webViewLayout"
/>
</item>
<item
row=
"1"
column=
"0"
>
...
...
@@ -50,14 +50,14 @@
</property>
</widget>
</item>
<item
row=
"1"
column=
"
4
"
>
<item
row=
"1"
column=
"
5
"
>
<widget
class=
"QPushButton"
name=
"clearWPButton"
>
<property
name=
"text"
>
<string>
Clear WPs
</string>
</property>
</widget>
</item>
<item
row=
"1"
column=
"
5
"
>
<item
row=
"1"
column=
"
9
"
>
<spacer
name=
"horizontalSpacer"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
...
...
@@ -70,6 +70,49 @@
</property>
</spacer>
</item>
<item
row=
"1"
column=
"8"
>
<widget
class=
"QSlider"
name=
"camDistanceSlider"
>
<property
name=
"minimum"
>
<number>
30
</number>
</property>
<property
name=
"maximum"
>
<number>
10000
</number>
</property>
<property
name=
"value"
>
<number>
3000
</number>
</property>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
</widget>
</item>
<item
row=
"1"
column=
"7"
>
<widget
class=
"QLabel"
name=
"camDistanceLabel"
>
<property
name=
"text"
>
<string>
Cam Distance
</string>
</property>
</widget>
</item>
<item
row=
"1"
column=
"6"
>
<spacer
name=
"horizontalSpacer_2"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
40
</width>
<height>
20
</height>
</size>
</property>
</spacer>
</item>
<item
row=
"1"
column=
"4"
>
<widget
class=
"QCheckBox"
name=
"waypointsCheckbox"
>
<property
name=
"text"
>
<string>
Waypoints
</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
...
...
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