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
64a56635
Commit
64a56635
authored
Dec 03, 2010
by
Lionel Heng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-implemented 3D imagery feature in OSG. Still a few outstanding issues to resolve.
parent
2adb1f82
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
305 additions
and
405 deletions
+305
-405
qgroundcontrol.pro
qgroundcontrol.pro
+29
-32
Imagery.cc
src/ui/map3D/Imagery.cc
+46
-38
Imagery.h
src/ui/map3D/Imagery.h
+9
-11
Pixhawk3DWidget.cc
src/ui/map3D/Pixhawk3DWidget.cc
+124
-21
Pixhawk3DWidget.h
src/ui/map3D/Pixhawk3DWidget.h
+6
-11
Texture.cc
src/ui/map3D/Texture.cc
+62
-153
Texture.h
src/ui/map3D/Texture.h
+3
-20
TextureCache.cc
src/ui/map3D/TextureCache.cc
+7
-10
TextureCache.h
src/ui/map3D/TextureCache.h
+2
-3
WebImage.cc
src/ui/map3D/WebImage.cc
+6
-72
WebImage.h
src/ui/map3D/WebImage.h
+7
-13
WebImageCache.cc
src/ui/map3D/WebImageCache.cc
+3
-19
WebImageCache.h
src/ui/map3D/WebImageCache.h
+1
-2
No files found.
qgroundcontrol.pro
View file @
64a56635
...
@@ -230,8 +230,6 @@ HEADERS += src/MG.h \
...
@@ -230,8 +230,6 @@ HEADERS += src/MG.h \
src
/
ui
/
RadioCalibration
/
CurveCalibrator
.
h
\
src
/
ui
/
RadioCalibration
/
CurveCalibrator
.
h
\
src
/
ui
/
RadioCalibration
/
AbstractCalibrator
.
h
\
src
/
ui
/
RadioCalibration
/
AbstractCalibrator
.
h
\
src
/
comm
/
QGCMAVLink
.
h
src
/
comm
/
QGCMAVLink
.
h
contains
(
DEPENDENCIES_PRESENT
,
osg
)
{
contains
(
DEPENDENCIES_PRESENT
,
osg
)
{
message
(
"Including headers for OpenSceneGraph"
)
message
(
"Including headers for OpenSceneGraph"
)
...
@@ -242,23 +240,25 @@ contains(DEPENDENCIES_PRESENT, osg) {
...
@@ -242,23 +240,25 @@ contains(DEPENDENCIES_PRESENT, osg) {
src
/
ui
/
map3D
/
QOSGWidget
.
h
\
src
/
ui
/
map3D
/
QOSGWidget
.
h
\
src
/
ui
/
map3D
/
PixhawkCheetahGeode
.
h
\
src
/
ui
/
map3D
/
PixhawkCheetahGeode
.
h
\
src
/
ui
/
map3D
/
Pixhawk3DWidget
.
h
\
src
/
ui
/
map3D
/
Pixhawk3DWidget
.
h
\
src
/
ui
/
map3D
/
Q3DWidgetFactory
.
h
src
/
ui
/
map3D
/
Q3DWidgetFactory
.
h
\
src
/
ui
/
map3D
/
WebImageCache
.
h
\
contains
(
DEPENDENCIES_PRESENT
,
osgearth
)
{
src
/
ui
/
map3D
/
WebImage
.
h
\
message
(
"Including headers for OSGEARTH"
)
src
/
ui
/
map3D
/
TextureCache
.
h
\
src
/
ui
/
map3D
/
Texture
.
h
\
#
Enable
only
if
OpenSceneGraph
is
available
src
/
ui
/
map3D
/
Imagery
.
h
HEADERS
+=
src
/
ui
/
map3D
/
QMap3D
.
h
contains
(
DEPENDENCIES_PRESENT
,
osgearth
)
{
}
message
(
"Including headers for OSGEARTH"
)
#
Enable
only
if
OpenSceneGraph
is
available
HEADERS
+=
src
/
ui
/
map3D
/
QMap3D
.
h
}
}
}
contains
(
DEPENDENCIES_PRESENT
,
libfreenect
)
{
contains
(
DEPENDENCIES_PRESENT
,
libfreenect
)
{
message
(
"Including headers for libfreenect"
)
message
(
"Including headers for libfreenect"
)
#
Enable
only
if
libfreenect
is
available
#
Enable
only
if
libfreenect
is
available
HEADERS
+=
src
/
input
/
Freenect
.
h
HEADERS
+=
src
/
input
/
Freenect
.
h
}
}
SOURCES
+=
src
/
main
.
cc
\
SOURCES
+=
src
/
main
.
cc
\
src
/
Core
.
cc
\
src
/
Core
.
cc
\
src
/
uas
/
UASManager
.
cc
\
src
/
uas
/
UASManager
.
cc
\
...
@@ -328,38 +328,35 @@ SOURCES += src/main.cc \
...
@@ -328,38 +328,35 @@ SOURCES += src/main.cc \
src
/
ui
/
RadioCalibration
/
CurveCalibrator
.
cc
\
src
/
ui
/
RadioCalibration
/
CurveCalibrator
.
cc
\
src
/
ui
/
RadioCalibration
/
AbstractCalibrator
.
cc
\
src
/
ui
/
RadioCalibration
/
AbstractCalibrator
.
cc
\
src
/
ui
/
RadioCalibration
/
RadioCalibrationData
.
cc
src
/
ui
/
RadioCalibration
/
RadioCalibrationData
.
cc
contains
(
DEPENDENCIES_PRESENT
,
osg
)
{
contains
(
DEPENDENCIES_PRESENT
,
osg
)
{
message
(
"Including sources for OpenSceneGraph"
)
message
(
"Including sources for OpenSceneGraph"
)
#
Enable
only
if
OpenSceneGraph
is
available
#
Enable
only
if
OpenSceneGraph
is
available
SOURCES
+=
src
/
ui
/
map3D
/
Q3DWidget
.
cc
\
SOURCES
+=
src
/
ui
/
map3D
/
Q3DWidget
.
cc
\
src
/
ui
/
map3D
/
ImageWindowGeode
.
cc
\
src
/
ui
/
map3D
/
ImageWindowGeode
.
cc
\
src
/
ui
/
map3D
/
GCManipulator
.
cc
\
src
/
ui
/
map3D
/
GCManipulator
.
cc
\
src
/
ui
/
map3D
/
QOSGWidget
.
cc
\
src
/
ui
/
map3D
/
QOSGWidget
.
cc
\
src
/
ui
/
map3D
/
PixhawkCheetahGeode
.
cc
\
src
/
ui
/
map3D
/
PixhawkCheetahGeode
.
cc
\
src
/
ui
/
map3D
/
Pixhawk3DWidget
.
cc
\
src
/
ui
/
map3D
/
Pixhawk3DWidget
.
cc
\
src
/
ui
/
map3D
/
Q3DWidgetFactory
.
cc
src
/
ui
/
map3D
/
Q3DWidgetFactory
.
cc
\
src
/
ui
/
map3D
/
WebImageCache
.
cc
\
src
/
ui
/
map3D
/
WebImage
.
cc
\
src
/
ui
/
map3D
/
TextureCache
.
cc
\
contains
(
DEPENDENCIES_PRESENT
,
osgearth
)
{
src
/
ui
/
map3D
/
Texture
.
cc
\
message
(
"Including sources for osgEarth"
)
src
/
ui
/
map3D
/
Imagery
.
cc
contains
(
DEPENDENCIES_PRESENT
,
osgearth
)
{
#
Enable
only
if
OpenSceneGraph
is
available
message
(
"Including sources for osgEarth"
)
SOURCES
+=
src
/
ui
/
map3D
/
QMap3D
.
cc
#
Enable
only
if
OpenSceneGraph
is
available
}
SOURCES
+=
src
/
ui
/
map3D
/
QMap3D
.
cc
}
}
}
contains
(
DEPENDENCIES_PRESENT
,
libfreenect
)
{
contains
(
DEPENDENCIES_PRESENT
,
libfreenect
)
{
message
(
"Including sources for libfreenect"
)
message
(
"Including sources for libfreenect"
)
#
Enable
only
if
libfreenect
is
available
#
Enable
only
if
libfreenect
is
available
SOURCES
+=
src
/
input
/
Freenect
.
cc
SOURCES
+=
src
/
input
/
Freenect
.
cc
}
}
RESOURCES
+=
mavground
.
qrc
RESOURCES
+=
mavground
.
qrc
#
Include
RT
-
LAB
Library
#
Include
RT
-
LAB
Library
...
...
src/ui/map3D/Imagery.cc
View file @
64a56635
...
@@ -46,6 +46,12 @@ Imagery::Imagery()
...
@@ -46,6 +46,12 @@ Imagery::Imagery()
}
}
Imagery
::
ImageryType
Imagery
::
getImageryType
(
void
)
const
{
return
currentImageryType
;
}
void
void
Imagery
::
setImageryType
(
ImageryType
type
)
Imagery
::
setImageryType
(
ImageryType
type
)
{
{
...
@@ -62,7 +68,6 @@ Imagery::setOffset(double xOffset, double yOffset)
...
@@ -62,7 +68,6 @@ Imagery::setOffset(double xOffset, double yOffset)
void
void
Imagery
::
prefetch2D
(
double
windowWidth
,
double
windowHeight
,
Imagery
::
prefetch2D
(
double
windowWidth
,
double
windowHeight
,
double
zoom
,
double
xOrigin
,
double
yOrigin
,
double
zoom
,
double
xOrigin
,
double
yOrigin
,
double
viewXOffset
,
double
viewYOffset
,
const
QString
&
utmZone
)
const
QString
&
utmZone
)
{
{
double
tileResolution
;
double
tileResolution
;
...
@@ -88,10 +93,10 @@ Imagery::prefetch2D(double windowWidth, double windowHeight,
...
@@ -88,10 +93,10 @@ Imagery::prefetch2D(double windowWidth, double windowHeight,
int
zoomLevel
;
int
zoomLevel
;
tileBounds
(
tileResolution
,
tileBounds
(
tileResolution
,
xOrigin
+
viewXOffset
-
windowWidth
/
2.0
/
zoom
,
xOrigin
-
windowWidth
/
2.0
/
zoom
*
1.5
,
yOrigin
+
viewYOffset
-
windowHeight
/
2.0
/
zoom
,
yOrigin
-
windowHeight
/
2.0
/
zoom
*
1.5
,
xOrigin
+
viewXOffset
+
windowWidth
/
2.0
/
zoom
,
xOrigin
+
windowWidth
/
2.0
/
zoom
*
1.5
,
yOrigin
+
viewYOffset
+
windowHeight
/
2.0
/
zoom
,
utmZone
,
yOrigin
+
windowHeight
/
2.0
/
zoom
*
1.5
,
utmZone
,
minTileX
,
minTileY
,
maxTileX
,
maxTileY
,
zoomLevel
);
minTileX
,
minTileY
,
maxTileX
,
maxTileY
,
zoomLevel
);
for
(
int
r
=
minTileY
;
r
<=
maxTileY
;
++
r
)
for
(
int
r
=
minTileY
;
r
<=
maxTileY
;
++
r
)
...
@@ -108,7 +113,6 @@ Imagery::prefetch2D(double windowWidth, double windowHeight,
...
@@ -108,7 +113,6 @@ Imagery::prefetch2D(double windowWidth, double windowHeight,
void
void
Imagery
::
draw2D
(
double
windowWidth
,
double
windowHeight
,
Imagery
::
draw2D
(
double
windowWidth
,
double
windowHeight
,
double
zoom
,
double
xOrigin
,
double
yOrigin
,
double
zoom
,
double
xOrigin
,
double
yOrigin
,
double
viewXOffset
,
double
viewYOffset
,
const
QString
&
utmZone
)
const
QString
&
utmZone
)
{
{
double
tileResolution
;
double
tileResolution
;
...
@@ -134,12 +138,17 @@ Imagery::draw2D(double windowWidth, double windowHeight,
...
@@ -134,12 +138,17 @@ Imagery::draw2D(double windowWidth, double windowHeight,
int
zoomLevel
;
int
zoomLevel
;
tileBounds
(
tileResolution
,
tileBounds
(
tileResolution
,
xOrigin
+
viewXOffset
-
windowWidth
/
2.0
/
zoom
*
1.5
,
xOrigin
-
windowWidth
/
2.0
/
zoom
*
1.5
,
yOrigin
+
viewYOffset
-
windowHeight
/
2.0
/
zoom
*
1.5
,
yOrigin
-
windowHeight
/
2.0
/
zoom
*
1.5
,
xOrigin
+
viewXOffset
+
windowWidth
/
2.0
/
zoom
*
1.5
,
xOrigin
+
windowWidth
/
2.0
/
zoom
*
1.5
,
yOrigin
+
viewYOffset
+
windowHeight
/
2.0
/
zoom
*
1.5
,
utmZone
,
yOrigin
+
windowHeight
/
2.0
/
zoom
*
1.5
,
utmZone
,
minTileX
,
minTileY
,
maxTileX
,
maxTileY
,
zoomLevel
);
minTileX
,
minTileY
,
maxTileX
,
maxTileY
,
zoomLevel
);
if
(
getNumDrawables
()
>
0
)
{
removeDrawables
(
0
,
getNumDrawables
());
}
for
(
int
r
=
minTileY
;
r
<=
maxTileY
;
++
r
)
for
(
int
r
=
minTileY
;
r
<=
maxTileY
;
++
r
)
{
{
for
(
int
c
=
minTileX
;
c
<=
maxTileX
;
++
c
)
for
(
int
c
=
minTileX
;
c
<=
maxTileX
;
++
c
)
...
@@ -152,10 +161,11 @@ Imagery::draw2D(double windowWidth, double windowHeight,
...
@@ -152,10 +161,11 @@ Imagery::draw2D(double windowWidth, double windowHeight,
TexturePtr
t
=
textureCache
->
get
(
tileURL
);
TexturePtr
t
=
textureCache
->
get
(
tileURL
);
if
(
!
t
.
isNull
())
if
(
!
t
.
isNull
())
{
{
t
->
draw
(
x1
-
xOrigin
,
y1
-
yOrigin
,
addDrawable
(
t
->
draw
(
y1
-
yOrigin
,
x1
-
xOrigin
,
x2
-
xOrigin
,
y2
-
yOrigin
,
y2
-
yOrigin
,
x2
-
xOrigin
,
x3
-
xOrigin
,
y3
-
yOrigin
,
y3
-
yOrigin
,
x3
-
xOrigin
,
x4
-
xOrigin
,
y4
-
yOrigin
,
true
);
y4
-
yOrigin
,
x4
-
xOrigin
,
true
));
}
}
}
}
}
}
...
@@ -164,17 +174,14 @@ Imagery::draw2D(double windowWidth, double windowHeight,
...
@@ -164,17 +174,14 @@ Imagery::draw2D(double windowWidth, double windowHeight,
void
void
Imagery
::
prefetch3D
(
double
radius
,
double
tileResolution
,
Imagery
::
prefetch3D
(
double
radius
,
double
tileResolution
,
double
xOrigin
,
double
yOrigin
,
double
xOrigin
,
double
yOrigin
,
double
viewXOffset
,
double
viewYOffset
,
const
QString
&
utmZone
)
const
QString
&
utmZone
,
bool
useHeightModel
)
{
{
int
minTileX
,
minTileY
,
maxTileX
,
maxTileY
;
int
minTileX
,
minTileY
,
maxTileX
,
maxTileY
;
int
zoomLevel
;
int
zoomLevel
;
tileBounds
(
tileResolution
,
tileBounds
(
tileResolution
,
xOrigin
+
viewXOffset
-
radius
,
xOrigin
-
radius
,
yOrigin
-
radius
,
yOrigin
+
viewYOffset
-
radius
,
xOrigin
+
radius
,
yOrigin
+
radius
,
utmZone
,
xOrigin
+
viewXOffset
+
radius
,
yOrigin
+
viewYOffset
+
radius
,
utmZone
,
minTileX
,
minTileY
,
maxTileX
,
maxTileY
,
zoomLevel
);
minTileX
,
minTileY
,
maxTileX
,
maxTileY
,
zoomLevel
);
for
(
int
r
=
minTileY
;
r
<=
maxTileY
;
++
r
)
for
(
int
r
=
minTileY
;
r
<=
maxTileY
;
++
r
)
...
@@ -183,7 +190,7 @@ Imagery::prefetch3D(double radius, double tileResolution,
...
@@ -183,7 +190,7 @@ Imagery::prefetch3D(double radius, double tileResolution,
{
{
QString
url
=
getTileLocation
(
c
,
r
,
zoomLevel
,
tileResolution
);
QString
url
=
getTileLocation
(
c
,
r
,
zoomLevel
,
tileResolution
);
TexturePtr
t
=
textureCache
->
get
(
url
,
useHeightModel
);
TexturePtr
t
=
textureCache
->
get
(
url
);
}
}
}
}
}
}
...
@@ -191,19 +198,21 @@ Imagery::prefetch3D(double radius, double tileResolution,
...
@@ -191,19 +198,21 @@ Imagery::prefetch3D(double radius, double tileResolution,
void
void
Imagery
::
draw3D
(
double
radius
,
double
tileResolution
,
Imagery
::
draw3D
(
double
radius
,
double
tileResolution
,
double
xOrigin
,
double
yOrigin
,
double
xOrigin
,
double
yOrigin
,
double
viewXOffset
,
double
viewYOffset
,
const
QString
&
utmZone
)
const
QString
&
utmZone
,
bool
useHeightModel
)
{
{
int
minTileX
,
minTileY
,
maxTileX
,
maxTileY
;
int
minTileX
,
minTileY
,
maxTileX
,
maxTileY
;
int
zoomLevel
;
int
zoomLevel
;
tileBounds
(
tileResolution
,
tileBounds
(
tileResolution
,
xOrigin
+
viewXOffset
-
radius
,
xOrigin
-
radius
,
yOrigin
-
radius
,
yOrigin
+
viewYOffset
-
radius
,
xOrigin
+
radius
,
yOrigin
+
radius
,
utmZone
,
xOrigin
+
viewXOffset
+
radius
,
yOrigin
+
viewYOffset
+
radius
,
utmZone
,
minTileX
,
minTileY
,
maxTileX
,
maxTileY
,
zoomLevel
);
minTileX
,
minTileY
,
maxTileX
,
maxTileY
,
zoomLevel
);
if
(
getNumDrawables
()
>
0
)
{
removeDrawables
(
0
,
getNumDrawables
());
}
for
(
int
r
=
minTileY
;
r
<=
maxTileY
;
++
r
)
for
(
int
r
=
minTileY
;
r
<=
maxTileY
;
++
r
)
{
{
for
(
int
c
=
minTileX
;
c
<=
maxTileX
;
++
c
)
for
(
int
c
=
minTileX
;
c
<=
maxTileX
;
++
c
)
...
@@ -213,14 +222,15 @@ Imagery::draw3D(double radius, double tileResolution,
...
@@ -213,14 +222,15 @@ Imagery::draw3D(double radius, double tileResolution,
double
x1
,
y1
,
x2
,
y2
,
x3
,
y3
,
x4
,
y4
;
double
x1
,
y1
,
x2
,
y2
,
x3
,
y3
,
x4
,
y4
;
imageBounds
(
c
,
r
,
tileResolution
,
x1
,
y1
,
x2
,
y2
,
x3
,
y3
,
x4
,
y4
);
imageBounds
(
c
,
r
,
tileResolution
,
x1
,
y1
,
x2
,
y2
,
x3
,
y3
,
x4
,
y4
);
TexturePtr
t
=
textureCache
->
get
(
tileURL
,
useHeightModel
);
TexturePtr
t
=
textureCache
->
get
(
tileURL
);
if
(
!
t
.
isNull
())
if
(
!
t
.
isNull
())
{
{
t
->
draw
(
x1
-
xOrigin
,
y1
-
yOrigin
,
addDrawable
(
t
->
draw
(
y1
-
yOrigin
,
x1
-
xOrigin
,
x2
-
xOrigin
,
y2
-
yOrigin
,
y2
-
yOrigin
,
x2
-
xOrigin
,
x3
-
xOrigin
,
y3
-
yOrigin
,
y3
-
yOrigin
,
x3
-
xOrigin
,
x4
-
xOrigin
,
y4
-
yOrigin
,
true
);
y4
-
yOrigin
,
x4
-
xOrigin
,
true
));
}
}
}
}
}
}
...
@@ -257,8 +267,7 @@ Imagery::imageBounds(int tileX, int tileY, double tileResolution,
...
@@ -257,8 +267,7 @@ Imagery::imageBounds(int tileX, int tileY, double tileResolution,
LLtoUTM
(
lat2
,
lon2
,
x3
,
y3
,
utmZone
);
LLtoUTM
(
lat2
,
lon2
,
x3
,
y3
,
utmZone
);
LLtoUTM
(
lat2
,
lon1
,
x4
,
y4
,
utmZone
);
LLtoUTM
(
lat2
,
lon1
,
x4
,
y4
,
utmZone
);
}
}
else
if
(
currentImageryType
==
SWISSTOPO_SATELLITE
||
else
if
(
currentImageryType
==
SWISSTOPO_SATELLITE
)
currentImageryType
==
SWISSTOPO_SATELLITE_3D
)
{
{
double
utmMultiplier
=
tileResolution
*
200.0
;
double
utmMultiplier
=
tileResolution
*
200.0
;
double
minX
=
tileX
*
utmMultiplier
;
double
minX
=
tileX
*
utmMultiplier
;
...
@@ -295,8 +304,7 @@ Imagery::tileBounds(double tileResolution,
...
@@ -295,8 +304,7 @@ Imagery::tileBounds(double tileResolution,
UTMtoTile
(
maxUtmX
,
maxUtmY
,
utmZone
,
tileResolution
,
UTMtoTile
(
maxUtmX
,
maxUtmY
,
utmZone
,
tileResolution
,
maxTileX
,
minTileY
,
zoomLevel
);
maxTileX
,
minTileY
,
zoomLevel
);
}
}
else
if
(
currentImageryType
==
SWISSTOPO_SATELLITE
||
else
if
(
currentImageryType
==
SWISSTOPO_SATELLITE
)
currentImageryType
==
SWISSTOPO_SATELLITE_3D
)
{
{
double
utmMultiplier
=
tileResolution
*
200
;
double
utmMultiplier
=
tileResolution
*
200
;
...
@@ -555,7 +563,7 @@ Imagery::UTMtoLL(double utmNorthing, double utmEasting, const QString& utmZone,
...
@@ -555,7 +563,7 @@ Imagery::UTMtoLL(double utmNorthing, double utmEasting, const QString& utmZone,
*
D
*
D
*
D
*
D
*
D
/
120.0
)
/
cos
(
phi1Rad
);
*
D
*
D
*
D
*
D
*
D
/
120.0
)
/
cos
(
phi1Rad
);
longitude
=
LongOrigin
+
longitude
/
M_PI
*
180.0
;
longitude
=
LongOrigin
+
longitude
/
M_PI
*
180.0
;
}
}
#include <QDebug>
QString
QString
Imagery
::
getTileLocation
(
int
tileX
,
int
tileY
,
int
zoomLevel
,
Imagery
::
getTileLocation
(
int
tileX
,
int
tileY
,
int
zoomLevel
,
double
tileResolution
)
const
double
tileResolution
)
const
...
@@ -572,7 +580,7 @@ Imagery::getTileLocation(int tileX, int tileY, int zoomLevel,
...
@@ -572,7 +580,7 @@ Imagery::getTileLocation(int tileX, int tileY, int zoomLevel,
oss
<<
"http://khm.google.com/vt/lbw/lyrs=y&x="
<<
tileX
oss
<<
"http://khm.google.com/vt/lbw/lyrs=y&x="
<<
tileX
<<
"&y="
<<
tileY
<<
"&z="
<<
zoomLevel
;
<<
"&y="
<<
tileY
<<
"&z="
<<
zoomLevel
;
break
;
break
;
case
SWISSTOPO_SATELLITE
:
case
SWISSTOPO_SATELLITE_3D
:
case
SWISSTOPO_SATELLITE
:
oss
<<
"../map/eth_zurich_swissimage_025/200/color/"
<<
tileY
oss
<<
"../map/eth_zurich_swissimage_025/200/color/"
<<
tileY
<<
"/tile-"
;
<<
"/tile-"
;
if
(
tileResolution
<
1.0
)
if
(
tileResolution
<
1.0
)
...
...
src/ui/map3D/Imagery.h
View file @
64a56635
...
@@ -32,44 +32,42 @@ This file is part of the QGROUNDCONTROL project
...
@@ -32,44 +32,42 @@ This file is part of the QGROUNDCONTROL project
#ifndef IMAGERY_H
#ifndef IMAGERY_H
#define IMAGERY_H
#define IMAGERY_H
#include <osg/Geode>
#include <QScopedPointer>
#include <QScopedPointer>
#include <QString>
#include <QString>
#include "TextureCache.h"
#include "TextureCache.h"
class
Imagery
class
Imagery
:
public
osg
::
Geode
{
{
public:
public:
enum
ImageryType
enum
ImageryType
{
{
GOOGLE
_MAP
=
0
,
BLANK
_MAP
=
0
,
GOOGLE_
SATELLITE
=
1
,
GOOGLE_
MAP
=
1
,
SWISSTOPO
_SATELLITE
=
2
,
GOOGLE
_SATELLITE
=
2
,
SWISSTOPO_SATELLITE
_3D
=
3
SWISSTOPO_SATELLITE
=
3
};
};
Imagery
();
Imagery
();
ImageryType
getImageryType
(
void
)
const
;
void
setImageryType
(
ImageryType
type
);
void
setImageryType
(
ImageryType
type
);
void
setOffset
(
double
xOffset
,
double
yOffset
);
void
setOffset
(
double
xOffset
,
double
yOffset
);
void
prefetch2D
(
double
windowWidth
,
double
windowHeight
,
void
prefetch2D
(
double
windowWidth
,
double
windowHeight
,
double
zoom
,
double
xOrigin
,
double
yOrigin
,
double
zoom
,
double
xOrigin
,
double
yOrigin
,
double
viewXOffset
,
double
viewYOffset
,
const
QString
&
utmZone
);
const
QString
&
utmZone
);
void
draw2D
(
double
windowWidth
,
double
windowHeight
,
void
draw2D
(
double
windowWidth
,
double
windowHeight
,
double
zoom
,
double
xOrigin
,
double
yOrigin
,
double
zoom
,
double
xOrigin
,
double
yOrigin
,
double
viewXOffset
,
double
viewYOffset
,
const
QString
&
utmZone
);
const
QString
&
utmZone
);
void
prefetch3D
(
double
radius
,
double
tileResolution
,
void
prefetch3D
(
double
radius
,
double
tileResolution
,
double
xOrigin
,
double
yOrigin
,
double
xOrigin
,
double
yOrigin
,
double
viewXOffset
,
double
viewYOffset
,
const
QString
&
utmZone
);
const
QString
&
utmZone
,
bool
useHeightModel
);
void
draw3D
(
double
radius
,
double
tileResolution
,
void
draw3D
(
double
radius
,
double
tileResolution
,
double
xOrigin
,
double
yOrigin
,
double
xOrigin
,
double
yOrigin
,
double
viewXOffset
,
double
viewYOffset
,
const
QString
&
utmZone
);
const
QString
&
utmZone
,
bool
useHeightModel
);
bool
update
(
void
);
bool
update
(
void
);
...
...
src/ui/map3D/Pixhawk3DWidget.cc
View file @
64a56635
...
@@ -49,6 +49,7 @@ Pixhawk3DWidget::Pixhawk3DWidget(QWidget* parent)
...
@@ -49,6 +49,7 @@ Pixhawk3DWidget::Pixhawk3DWidget(QWidget* parent)
,
uas
(
NULL
)
,
uas
(
NULL
)
,
displayGrid
(
true
)
,
displayGrid
(
true
)
,
displayTrail
(
false
)
,
displayTrail
(
false
)
,
displayImagery
(
true
)
,
displayTarget
(
false
)
,
displayTarget
(
false
)
,
displayWaypoints
(
true
)
,
displayWaypoints
(
true
)
,
displayRGBD2D
(
false
)
,
displayRGBD2D
(
false
)
...
@@ -74,11 +75,9 @@ Pixhawk3DWidget::Pixhawk3DWidget(QWidget* parent)
...
@@ -74,11 +75,9 @@ Pixhawk3DWidget::Pixhawk3DWidget(QWidget* parent)
trailNode
=
createTrail
();
trailNode
=
createTrail
();
rollingMap
->
addChild
(
trailNode
);
rollingMap
->
addChild
(
trailNode
);
#ifdef QGC_OSGEARTH_ENABLED
// generate map model
// generate map model
mapNode
=
createMap
();
mapNode
=
createMap
();
root
->
addChild
(
mapNode
);
allocentricMap
->
addChild
(
mapNode
);
#endif
// generate target model
// generate target model
allocentricMap
->
addChild
(
createTarget
());
allocentricMap
->
addChild
(
createTarget
());
...
@@ -171,6 +170,12 @@ Pixhawk3DWidget::showWaypoints(int state)
...
@@ -171,6 +170,12 @@ Pixhawk3DWidget::showWaypoints(int state)
}
}
}
}
void
Pixhawk3DWidget
::
selectMapSource
(
int
index
)
{
mapNode
->
setImageryType
(
static_cast
<
Imagery
::
ImageryType
>
(
index
));
}
void
void
Pixhawk3DWidget
::
selectVehicleModel
(
int
index
)
Pixhawk3DWidget
::
selectVehicleModel
(
int
index
)
{
{
...
@@ -205,7 +210,7 @@ Pixhawk3DWidget::toggleFollowCamera(int32_t state)
...
@@ -205,7 +210,7 @@ Pixhawk3DWidget::toggleFollowCamera(int32_t state)
followCamera
=
false
;
followCamera
=
false
;
}
}
}
}
#include <osgDB/WriteFile>
QVector
<
osg
::
ref_ptr
<
osg
::
Node
>
>
QVector
<
osg
::
ref_ptr
<
osg
::
Node
>
>
Pixhawk3DWidget
::
findVehicleModels
(
void
)
Pixhawk3DWidget
::
findVehicleModels
(
void
)
{
{
...
@@ -273,6 +278,12 @@ Pixhawk3DWidget::buildLayout(void)
...
@@ -273,6 +278,12 @@ Pixhawk3DWidget::buildLayout(void)
waypointsCheckBox
->
setText
(
"Waypoints"
);
waypointsCheckBox
->
setText
(
"Waypoints"
);
waypointsCheckBox
->
setChecked
(
displayWaypoints
);
waypointsCheckBox
->
setChecked
(
displayWaypoints
);
QLabel
*
mapLabel
=
new
QLabel
(
"Map"
,
this
);
QComboBox
*
mapComboBox
=
new
QComboBox
(
this
);
mapComboBox
->
addItem
(
"None"
);
mapComboBox
->
addItem
(
"Map (Google)"
);
mapComboBox
->
addItem
(
"Satellite (Google)"
);
QLabel
*
modelLabel
=
new
QLabel
(
"Vehicle Model"
,
this
);
QLabel
*
modelLabel
=
new
QLabel
(
"Vehicle Model"
,
this
);
QComboBox
*
modelComboBox
=
new
QComboBox
(
this
);
QComboBox
*
modelComboBox
=
new
QComboBox
(
this
);
for
(
int
i
=
0
;
i
<
vehicleModels
.
size
();
++
i
)
for
(
int
i
=
0
;
i
<
vehicleModels
.
size
();
++
i
)
...
@@ -299,12 +310,14 @@ Pixhawk3DWidget::buildLayout(void)
...
@@ -299,12 +310,14 @@ Pixhawk3DWidget::buildLayout(void)
layout
->
addWidget
(
trailCheckBox
,
1
,
1
);
layout
->
addWidget
(
trailCheckBox
,
1
,
1
);
layout
->
addWidget
(
waypointsCheckBox
,
1
,
2
);
layout
->
addWidget
(
waypointsCheckBox
,
1
,
2
);
layout
->
addItem
(
new
QSpacerItem
(
10
,
0
,
QSizePolicy
::
Expanding
,
QSizePolicy
::
Expanding
),
1
,
3
);
layout
->
addItem
(
new
QSpacerItem
(
10
,
0
,
QSizePolicy
::
Expanding
,
QSizePolicy
::
Expanding
),
1
,
3
);
layout
->
addWidget
(
modelLabel
,
1
,
4
);
layout
->
addWidget
(
mapLabel
,
1
,
4
);
layout
->
addWidget
(
modelComboBox
,
1
,
5
);
layout
->
addWidget
(
mapComboBox
,
1
,
5
);
layout
->
addWidget
(
targetButton
,
1
,
6
);
layout
->
addWidget
(
modelLabel
,
1
,
6
);
layout
->
addItem
(
new
QSpacerItem
(
10
,
0
,
QSizePolicy
::
Expanding
,
QSizePolicy
::
Expanding
),
1
,
7
);
layout
->
addWidget
(
modelComboBox
,
1
,
7
);
layout
->
addWidget
(
recenterButton
,
1
,
8
);
layout
->
addWidget
(
targetButton
,
1
,
8
);
layout
->
addWidget
(
followCameraCheckBox
,
1
,
9
);
layout
->
addItem
(
new
QSpacerItem
(
10
,
0
,
QSizePolicy
::
Expanding
,
QSizePolicy
::
Expanding
),
1
,
9
);
layout
->
addWidget
(
recenterButton
,
1
,
10
);
layout
->
addWidget
(
followCameraCheckBox
,
1
,
11
);
layout
->
setRowStretch
(
0
,
100
);
layout
->
setRowStretch
(
0
,
100
);
layout
->
setRowStretch
(
1
,
1
);
layout
->
setRowStretch
(
1
,
1
);
setLayout
(
layout
);
setLayout
(
layout
);
...
@@ -315,6 +328,8 @@ Pixhawk3DWidget::buildLayout(void)
...
@@ -315,6 +328,8 @@ Pixhawk3DWidget::buildLayout(void)
this
,
SLOT
(
showTrail
(
int
)));
this
,
SLOT
(
showTrail
(
int
)));
connect
(
waypointsCheckBox
,
SIGNAL
(
stateChanged
(
int
)),
connect
(
waypointsCheckBox
,
SIGNAL
(
stateChanged
(
int
)),
this
,
SLOT
(
showWaypoints
(
int
)));
this
,
SLOT
(
showWaypoints
(
int
)));
connect
(
mapComboBox
,
SIGNAL
(
currentIndexChanged
(
int
)),
this
,
SLOT
(
selectMapSource
(
int
)));
connect
(
modelComboBox
,
SIGNAL
(
currentIndexChanged
(
int
)),
connect
(
modelComboBox
,
SIGNAL
(
currentIndexChanged
(
int
)),
this
,
SLOT
(
selectVehicleModel
(
int
)));
this
,
SLOT
(
selectVehicleModel
(
int
)));
connect
(
recenterButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
recenter
()));
connect
(
recenterButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
recenter
()));
...
@@ -362,20 +377,42 @@ Pixhawk3DWidget::display(void)
...
@@ -362,20 +377,42 @@ Pixhawk3DWidget::display(void)
robotPitch
,
osg
::
Vec3f
(
1.0
f
,
0.0
f
,
0.0
f
),
robotPitch
,
osg
::
Vec3f
(
1.0
f
,
0.0
f
,
0.0
f
),
robotRoll
,
osg
::
Vec3f
(
0.0
f
,
1.0
f
,
0.0
f
)));
robotRoll
,
osg
::
Vec3f
(
0.0
f
,
1.0
f
,
0.0
f
)));
updateTrail
(
robotX
,
robotY
,
robotZ
);
if
(
displayTrail
)
updateTarget
();
{
updateWaypoints
();
updateTrail
(
robotX
,
robotY
,
robotZ
);
}
if
(
displayImagery
)
{
updateImagery
();
}
if
(
displayTarget
)
{
updateTarget
();
}
if
(
displayWaypoints
)
{
updateWaypoints
();
}
#ifdef QGC_LIBFREENECT_ENABLED
#ifdef QGC_LIBFREENECT_ENABLED
updateRGBD
();
if
(
displayRGBD2D
||
displayRGBD3D
)
{
updateRGBD
();
}
#endif
#endif
updateHUD
(
robotX
,
robotY
,
robotZ
,
robotRoll
,
robotPitch
,
robotYaw
);
updateHUD
(
robotX
,
robotY
,
robotZ
,
robotRoll
,
robotPitch
,
robotYaw
);
// set node visibility
// set node visibility
rollingMap
->
setChildValue
(
gridNode
,
displayGrid
);
rollingMap
->
setChildValue
(
gridNode
,
displayGrid
);
rollingMap
->
setChildValue
(
trailNode
,
displayTrail
);
rollingMap
->
setChildValue
(
trailNode
,
displayTrail
);
rollingMap
->
setChildValue
(
targetNode
,
displayTarget
);
rollingMap
->
setChildValue
(
targetNode
,
displayTarget
);
rollingMap
->
setChildValue
(
waypointsNode
,
displayWaypoints
);
rollingMap
->
setChildValue
(
waypointsNode
,
displayWaypoints
);
egocentricMap
->
setChildValue
(
rgbd3DNode
,
displayRGBD3D
);
egocentricMap
->
setChildValue
(
rgbd3DNode
,
displayRGBD3D
);
allocentricMap
->
setChildValue
(
mapNode
,
displayImagery
);
hudGroup
->
setChildValue
(
rgb2DGeode
,
displayRGBD2D
);
hudGroup
->
setChildValue
(
rgb2DGeode
,
displayRGBD2D
);
hudGroup
->
setChildValue
(
depth2DGeode
,
displayRGBD2D
);
hudGroup
->
setChildValue
(
depth2DGeode
,
displayRGBD2D
);
...
@@ -400,6 +437,9 @@ Pixhawk3DWidget::keyPressEvent(QKeyEvent* event)
...
@@ -400,6 +437,9 @@ Pixhawk3DWidget::keyPressEvent(QKeyEvent* event)
case
'c'
:
case
'C'
:
case
'c'
:
case
'C'
:
enableRGBDColor
=
!
enableRGBDColor
;
enableRGBDColor
=
!
enableRGBDColor
;
break
;
break
;
case
'i'
:
case
'I'
:
displayImagery
=
!
displayImagery
;
break
;
}
}
}
}
...
@@ -512,16 +552,11 @@ Pixhawk3DWidget::createTrail(void)
...
@@ -512,16 +552,11 @@ Pixhawk3DWidget::createTrail(void)
return
geode
;
return
geode
;
}
}
#ifdef QGC_OSGEARTH_ENABLED
osg
::
ref_ptr
<
Imagery
>
osg
::
ref_ptr
<
osgEarth
::
MapNode
>
Pixhawk3DWidget
::
createMap
(
void
)
Pixhawk3DWidget
::
createMap
(
void
)
{
{
osg
::
ref_ptr
<
osg
::
Node
>
model
=
osgDB
::
readNodeFile
(
"map.earth"
);
return
osg
::
ref_ptr
<
Imagery
>
(
new
Imagery
());
osg
::
ref_ptr
<
osgEarth
::
MapNode
>
node
=
osgEarth
::
MapNode
::
findMapNode
(
model
);
return
node
;
}
}
#endif
osg
::
ref_ptr
<
osg
::
Node
>
osg
::
ref_ptr
<
osg
::
Node
>
Pixhawk3DWidget
::
createTarget
(
void
)
Pixhawk3DWidget
::
createTarget
(
void
)
...
@@ -730,6 +765,74 @@ Pixhawk3DWidget::updateTrail(float robotX, float robotY, float robotZ)
...
@@ -730,6 +765,74 @@ Pixhawk3DWidget::updateTrail(float robotX, float robotY, float robotZ)
trailGeometry
->
dirtyBound
();
trailGeometry
->
dirtyBound
();
}
}
void
Pixhawk3DWidget
::
updateImagery
(
void
)
{
char
zone
[
5
]
=
"32T"
;
double
viewingRadius
=
cameraManipulator
->
getDistance
()
*
10.0
;
if
(
viewingRadius
<
100.0
)
{
viewingRadius
=
100.0
;
}
double
minResolution
=
0.25
;
double
centerResolution
=
cameraManipulator
->
getDistance
()
/
25.0
;
double
maxResolution
=
1048576.0
;
Imagery
::
ImageryType
imageryType
=
mapNode
->
getImageryType
();
switch
(
imageryType
)
{
case
Imagery
:
:
GOOGLE_MAP
:
minResolution
=
0.25
;
break
;
case
Imagery
:
:
GOOGLE_SATELLITE
:
minResolution
=
0.5
;
break
;
case
Imagery
:
:
SWISSTOPO_SATELLITE
:
minResolution
=
0.25
;