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
56ac4e92
Commit
56ac4e92
authored
Dec 29, 2010
by
pixhawk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaned up line indendation, validated Google Earth on Mac
parent
14609cb8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
89 additions
and
89 deletions
+89
-89
QGCGoogleEarthView.cc
src/ui/map3D/QGCGoogleEarthView.cc
+89
-89
No files found.
src/ui/map3D/QGCGoogleEarthView.cc
View file @
56ac4e92
...
@@ -34,7 +34,7 @@ QGCGoogleEarthView::QGCGoogleEarthView(QWidget *parent) :
...
@@ -34,7 +34,7 @@ QGCGoogleEarthView::QGCGoogleEarthView(QWidget *parent) :
followCamera
(
true
),
followCamera
(
true
),
trailEnabled
(
true
),
trailEnabled
(
true
),
webViewInitialized
(
false
),
webViewInitialized
(
false
),
jScriptInitialized
(
false
),
jScriptInitialized
(
false
),
gEarthInitialized
(
false
),
gEarthInitialized
(
false
),
#if (defined Q_OS_MAC)
#if (defined Q_OS_MAC)
webViewMac
(
new
QWebView
(
this
)),
webViewMac
(
new
QWebView
(
this
)),
...
@@ -51,16 +51,16 @@ QGCGoogleEarthView::QGCGoogleEarthView(QWidget *parent) :
...
@@ -51,16 +51,16 @@ QGCGoogleEarthView::QGCGoogleEarthView(QWidget *parent) :
#ifdef _MSC_VER
#ifdef _MSC_VER
// Create layout and attach webViewWin
// 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
);
QFile
file
(
"doc.html"
);
out
<<
webViewWin
->
generateDocumentation
();
if
(
!
file
.
open
(
QIODevice
::
WriteOnly
|
QIODevice
::
Text
))
out
.
flush
();
qDebug
()
<<
__FILE__
<<
__LINE__
<<
"Could not open log file"
;
file
.
flush
();
file
.
close
();
QTextStream
out
(
&
file
);
out
<<
webViewWin
->
generateDocumentation
();
out
.
flush
();
file
.
flush
();
file
.
close
();
#else
#else
...
@@ -108,7 +108,7 @@ QGCGoogleEarthView::~QGCGoogleEarthView()
...
@@ -108,7 +108,7 @@ QGCGoogleEarthView::~QGCGoogleEarthView()
void
QGCGoogleEarthView
::
addUAS
(
UASInterface
*
uas
)
void
QGCGoogleEarthView
::
addUAS
(
UASInterface
*
uas
)
{
{
// uasid, type, color (in aarrbbgg format)
// 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")));
//javaScript(QString("createAircraft(%1, %2, %3);").arg(uas->getUASID()).arg(uas->getSystemType()).arg(uas->getColor().name().remove(0, 1).prepend("50")));
javaScript
(
QString
(
"createAircraft(%1, %2, %3);"
).
arg
(
uas
->
getUASID
()).
arg
(
uas
->
getSystemType
()).
arg
(
"0"
));
javaScript
(
QString
(
"createAircraft(%1, %2, %3);"
).
arg
(
uas
->
getUASID
()).
arg
(
uas
->
getSystemType
()).
arg
(
"0"
));
// Automatically receive further position updates
// Automatically receive further position updates
connect
(
uas
,
SIGNAL
(
globalPositionChanged
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)),
this
,
SLOT
(
updateGlobalPosition
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)));
connect
(
uas
,
SIGNAL
(
globalPositionChanged
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)),
this
,
SLOT
(
updateGlobalPosition
(
UASInterface
*
,
double
,
double
,
double
,
quint64
)));
...
@@ -119,16 +119,16 @@ void QGCGoogleEarthView::setActiveUAS(UASInterface* uas)
...
@@ -119,16 +119,16 @@ void QGCGoogleEarthView::setActiveUAS(UASInterface* uas)
if
(
uas
)
if
(
uas
)
{
{
mav
=
uas
;
mav
=
uas
;
javaScript
(
QString
(
"setCurrAircraft(%1);"
).
arg
(
uas
->
getUASID
()));
javaScript
(
QString
(
"setCurrAircraft(%1);"
).
arg
(
uas
->
getUASID
()));
}
}
}
}
void
QGCGoogleEarthView
::
updateGlobalPosition
(
UASInterface
*
uas
,
double
lat
,
double
lon
,
double
alt
,
quint64
usec
)
void
QGCGoogleEarthView
::
updateGlobalPosition
(
UASInterface
*
uas
,
double
lat
,
double
lon
,
double
alt
,
quint64
usec
)
{
{
Q_UNUSED
(
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
));
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
));
//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);
//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
::
showTrail
(
bool
state
)
void
QGCGoogleEarthView
::
showTrail
(
bool
state
)
...
@@ -158,7 +158,7 @@ void QGCGoogleEarthView::goHome()
...
@@ -158,7 +158,7 @@ void QGCGoogleEarthView::goHome()
void
QGCGoogleEarthView
::
setHome
(
double
lat
,
double
lon
,
double
alt
)
void
QGCGoogleEarthView
::
setHome
(
double
lat
,
double
lon
,
double
alt
)
{
{
javaScript
(
QString
(
"setGCSHome(%1,%2,%3);"
).
arg
(
lat
,
0
,
'f'
,
15
).
arg
(
lon
,
0
,
'f'
,
15
).
arg
(
alt
,
0
,
'f'
,
15
));
javaScript
(
QString
(
"setGCSHome(%1,%2,%3);"
).
arg
(
lat
,
0
,
'f'
,
15
).
arg
(
lon
,
0
,
'f'
,
15
).
arg
(
alt
,
0
,
'f'
,
15
));
}
}
void
QGCGoogleEarthView
::
hideEvent
(
QHideEvent
*
event
)
void
QGCGoogleEarthView
::
hideEvent
(
QHideEvent
*
event
)
...
@@ -172,102 +172,102 @@ void QGCGoogleEarthView::showEvent(QShowEvent* event)
...
@@ -172,102 +172,102 @@ void QGCGoogleEarthView::showEvent(QShowEvent* event)
// events
// events
Q_UNUSED
(
event
)
Q_UNUSED
(
event
)
{
{
// Enable widget, initialize on first run
// Enable widget, initialize on first run
if
(
!
webViewInitialized
)
if
(
!
webViewInitialized
)
{
{
#if (defined Q_OS_MAC)
#if (defined Q_OS_MAC)
webViewMac
->
setPage
(
new
QGCWebPage
(
webViewMac
));
webViewMac
->
setPage
(
new
QGCWebPage
(
webViewMac
));
webViewMac
->
settings
()
->
setAttribute
(
QWebSettings
::
PluginsEnabled
,
true
);
webViewMac
->
settings
()
->
setAttribute
(
QWebSettings
::
PluginsEnabled
,
true
);
webViewMac
->
load
(
QUrl
(
"earth.html"
));
webViewMac
->
load
(
QUrl
(
"earth.html"
));
#endif
#endif
#ifdef _MSC_VER
#ifdef _MSC_VER
//webViewWin->dynamicCall("GoHome()");
//webViewWin->dynamicCall("GoHome()");
webViewWin
->
dynamicCall
(
"Navigate(const QString&)"
,
QApplication
::
applicationDirPath
()
+
"/earth.html"
);
webViewWin
->
dynamicCall
(
"Navigate(const QString&)"
,
QApplication
::
applicationDirPath
()
+
"/earth.html"
);
#endif
#endif
webViewInitialized
=
true
;
webViewInitialized
=
true
;
// Reloading the webpage, this resets Google Earth
// Reloading the webpage, this resets Google Earth
gEarthInitialized
=
false
;
gEarthInitialized
=
false
;
QTimer
::
singleShot
(
2000
,
this
,
SLOT
(
initializeGoogleEarth
()));
QTimer
::
singleShot
(
2000
,
this
,
SLOT
(
initializeGoogleEarth
()));
updateTimer
->
start
(
refreshRateMs
);
updateTimer
->
start
(
refreshRateMs
);
}
}
}
}
}
}
void
QGCGoogleEarthView
::
printWinException
(
int
no
,
QString
str1
,
QString
str2
,
QString
str3
)
void
QGCGoogleEarthView
::
printWinException
(
int
no
,
QString
str1
,
QString
str2
,
QString
str3
)
{
{
qDebug
()
<<
no
<<
str1
<<
str2
<<
str3
;
qDebug
()
<<
no
<<
str1
<<
str2
<<
str3
;
}
}
QVariant
QGCGoogleEarthView
::
javaScript
(
QString
javaScript
)
QVariant
QGCGoogleEarthView
::
javaScript
(
QString
javaScript
)
{
{
#ifdef Q_OS_MAC
#ifdef Q_OS_MAC
return
webViewMac
->
page
()
->
currentFrame
()
->
evaluateJavaScript
(
javaScript
);
return
webViewMac
->
page
()
->
currentFrame
()
->
evaluateJavaScript
(
javaScript
);
#endif
#endif
#ifdef _MSC_VER
#ifdef _MSC_VER
if
(
!
jScriptInitialized
)
if
(
!
jScriptInitialized
)
{
{
qDebug
()
<<
"TOO EARLY JAVASCRIPT CALL, ABORTING"
;
qDebug
()
<<
"TOO EARLY JAVASCRIPT CALL, ABORTING"
;
return
QVariant
(
false
);
return
QVariant
(
false
);
}
}
else
else
{
{
QVariantList
params
;
QVariantList
params
;
params
.
append
(
javaScript
);
params
.
append
(
javaScript
);
params
.
append
(
"JScript"
);
params
.
append
(
"JScript"
);
return
jScriptWin
->
dynamicCall
(
"execScript(QString, QString)"
,
params
);
return
jScriptWin
->
dynamicCall
(
"execScript(QString, QString)"
,
params
);
}
}
#endif
#endif
}
}
void
QGCGoogleEarthView
::
initializeGoogleEarth
()
void
QGCGoogleEarthView
::
initializeGoogleEarth
()
{
{
if
(
!
jScriptInitialized
)
if
(
!
jScriptInitialized
)
{
{
#ifdef Q_OS_MAC
#ifdef Q_OS_MAC
jScriptInitialized
=
true
;
jScriptInitialized
=
true
;
#endif
#endif
#ifdef _MSC_VER
#ifdef _MSC_VER
QAxObject
*
doc
=
webViewWin
->
querySubObject
(
"Document()"
);
QAxObject
*
doc
=
webViewWin
->
querySubObject
(
"Document()"
);
IDispatch
*
Disp
;
IDispatch
*
Disp
;
IDispatch
*
winDoc
=
NULL
;
IDispatch
*
winDoc
=
NULL
;
//332C4425-26CB-11D0-B483-00C04FD90119 IHTMLDocument2
//332C4425-26CB-11D0-B483-00C04FD90119 IHTMLDocument2
//25336920-03F9-11CF-8FD0-00AA00686F13 HTMLDocument
//25336920-03F9-11CF-8FD0-00AA00686F13 HTMLDocument
doc
->
queryInterface
(
QUuid
(
"{332C4425-26CB-11D0-B483-00C04FD90119}"
),
(
void
**
)(
&
winDoc
));
doc
->
queryInterface
(
QUuid
(
"{332C4425-26CB-11D0-B483-00C04FD90119}"
),
(
void
**
)(
&
winDoc
));
if
(
winDoc
)
if
(
winDoc
)
{
{
// Security:
// Security:
// CoInternetSetFeatureEnabled
// CoInternetSetFeatureEnabled
// (FEATURE_LOCALMACHINE_LOCKDOWN, SET_FEATURE_ON_PROCESS, TRUE);
// (FEATURE_LOCALMACHINE_LOCKDOWN, SET_FEATURE_ON_PROCESS, TRUE);
//
//
IHTMLDocument2
*
document
=
NULL
;
IHTMLDocument2
*
document
=
NULL
;
winDoc
->
QueryInterface
(
IID_IHTMLDocument2
,
(
void
**
)
&
document
);
winDoc
->
QueryInterface
(
IID_IHTMLDocument2
,
(
void
**
)
&
document
);
IHTMLWindow2
*
window
=
NULL
;
IHTMLWindow2
*
window
=
NULL
;
document
->
get_parentWindow
(
&
window
);
document
->
get_parentWindow
(
&
window
);
jScriptWin
=
new
QAxObject
(
window
,
webViewWin
);
jScriptWin
=
new
QAxObject
(
window
,
webViewWin
);
connect
(
jScriptWin
,
SIGNAL
(
exception
(
int
,
QString
,
QString
,
QString
)),
this
,
SLOT
(
printWinException
(
int
,
QString
,
QString
,
QString
)));
connect
(
jScriptWin
,
SIGNAL
(
exception
(
int
,
QString
,
QString
,
QString
)),
this
,
SLOT
(
printWinException
(
int
,
QString
,
QString
,
QString
)));
jScriptInitialized
=
true
;
jScriptInitialized
=
true
;
}
}
else
else
{
{
qDebug
()
<<
"COULD NOT GET DOCUMENT OBJECT! Aborting"
;
qDebug
()
<<
"COULD NOT GET DOCUMENT OBJECT! Aborting"
;
}
}
#endif
#endif
QTimer
::
singleShot
(
2500
,
this
,
SLOT
(
initializeGoogleEarth
()));
QTimer
::
singleShot
(
2500
,
this
,
SLOT
(
initializeGoogleEarth
()));
return
;
return
;
}
}
if
(
!
gEarthInitialized
)
if
(
!
gEarthInitialized
)
{
{
if
(
0
==
1
)
//(!javaScript("isInitialized();").toBool())
if
(
0
==
1
)
//(!javaScript("isInitialized();").toBool())
{
{
QTimer
::
singleShot
(
500
,
this
,
SLOT
(
initializeGoogleEarth
()));
QTimer
::
singleShot
(
500
,
this
,
SLOT
(
initializeGoogleEarth
()));
qDebug
()
<<
"NOT INITIALIZED, WAITING"
;
qDebug
()
<<
"NOT INITIALIZED, WAITING"
;
}
}
else
else
{
{
// Set home location
// Set home location
...
@@ -323,13 +323,13 @@ void QGCGoogleEarthView::updateState()
...
@@ -323,13 +323,13 @@ void QGCGoogleEarthView::updateState()
yaw
=
mav
->
getYaw
();
yaw
=
mav
->
getYaw
();
javaScript
(
QString
(
"setAircraftPositionAttitude(%1, %2, %3, %4, %6, %7, %8);"
)
javaScript
(
QString
(
"setAircraftPositionAttitude(%1, %2, %3, %4, %6, %7, %8);"
)
.
arg
(
uasId
)
.
arg
(
uasId
)
.
arg
(
lat
)
.
arg
(
lat
)
.
arg
(
lon
)
.
arg
(
lon
)
.
arg
(
alt
+
500
)
.
arg
(
alt
+
500
)
.
arg
(
roll
)
.
arg
(
roll
)
.
arg
(
pitch
)
.
arg
(
pitch
)
.
arg
(
yaw
));
.
arg
(
yaw
));
}
}
if
(
followCamera
)
if
(
followCamera
)
...
...
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