Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
97ea3189
Commit
97ea3189
authored
Oct 19, 2010
by
Lionel Heng
Browse files
Fixed all known bugs in 3D imagery.
parent
dd90aa0e
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/ui/map3D/Imagery.cc
View file @
97ea3189
...
...
@@ -6,6 +6,8 @@
const
double
WGS84_A
=
6378137.0
;
const
double
WGS84_ECCSQ
=
0.00669437999013
;
const
int32_t
MAX_ZOOM_LEVEL
=
20
;
Imagery
::
Imagery
()
:
textureCache
(
new
TextureCache
(
1000
))
{
...
...
@@ -261,7 +263,7 @@ Imagery::imageBounds(int32_t x, int32_t y, double imageResolution,
double
&
x1
,
double
&
y1
,
double
&
x2
,
double
&
y2
,
double
&
x3
,
double
&
y3
,
double
&
x4
,
double
&
y4
)
{
int32_t
zoomLevel
=
19
-
static_cast
<
int32_t
>
(
rint
(
log2
(
imageResolution
)));
int32_t
zoomLevel
=
MAX_ZOOM_LEVEL
-
static_cast
<
int32_t
>
(
rint
(
log2
(
imageResolution
)));
int32_t
numTiles
=
static_cast
<
int32_t
>
(
exp2
(
static_cast
<
double
>
(
zoomLevel
)));
double
lon1
=
360.0
*
(
static_cast
<
double
>
(
x
)
...
...
@@ -306,7 +308,7 @@ Imagery::UTMtoTile(double northing, double easting, const QString& utmZone,
UTMtoLL
(
northing
,
easting
,
utmZone
,
latitude
,
longitude
);
zoomLevel
=
19
-
static_cast
<
int32_t
>
(
rint
(
log2
(
imageResolution
)));
zoomLevel
=
MAX_ZOOM_LEVEL
-
static_cast
<
int32_t
>
(
rint
(
log2
(
imageResolution
)));
int32_t
numTiles
=
static_cast
<
int32_t
>
(
exp2
(
static_cast
<
double
>
(
zoomLevel
)));
double
x
=
longitude
/
180.0
;
...
...
src/ui/map3D/Q3DWidget.h
View file @
97ea3189
...
...
@@ -178,7 +178,6 @@ protected:
GLUquadricObj
*
quadObj
;
private:
// QGLWidget events
void
initializeGL
(
void
);
void
paintGL
(
void
);
...
...
src/ui/map3D/QMap3DWidget.cc
View file @
97ea3189
...
...
@@ -56,7 +56,7 @@ QMap3DWidget::QMap3DWidget(QWidget* parent)
setFocusPolicy
(
Qt
::
StrongFocus
);
initialize
(
10
,
10
,
1000
,
900
,
15.0
f
);
setCameraParams
(
0.05
f
,
0.5
f
,
0.01
f
,
0.5
f
,
30.0
f
,
0.01
f
,
4
00.0
f
);
setCameraParams
(
0.05
f
,
0.5
f
,
0.01
f
,
0.5
f
,
30.0
f
,
0.01
f
,
10000
00.0
f
);
setDisplayFunc
(
display
,
this
);
setMouseFunc
(
mouse
,
this
);
...
...
@@ -93,7 +93,7 @@ QMap3DWidget::buildLayout(void)
QLabel
*
imageryLabel
=
new
QLabel
(
this
);
imageryLabel
->
setText
(
"Imagery"
);
QComboBox
*
imageryComboBox
=
new
QComboBox
(
this
);
imageryComboBox
=
new
QComboBox
(
this
);
imageryComboBox
->
addItem
(
"None"
);
imageryComboBox
->
addItem
(
"Map (Google)"
);
imageryComboBox
->
addItem
(
"Satellite (Google)"
);
...
...
@@ -231,6 +231,8 @@ QMap3DWidget::displayHandler(void)
// switch to 2D
setDisplayMode2D
();
drawLegend
();
// display pose information
glColor4f
(
0.0
f
,
0.0
f
,
0.0
f
,
0.5
f
);
glBegin
(
GL_POLYGON
);
...
...
@@ -333,6 +335,55 @@ void QMap3DWidget::drawWaypoints()
}
}
void
QMap3DWidget
::
drawLegend
(
void
)
{
// draw marker outlines
glColor3f
(
1.0
f
,
1.0
f
,
1.0
f
);
glLineWidth
(
3.0
f
);
glBegin
(
GL_LINES
);
glVertex2f
(
20.0
f
,
60.0
f
);
glVertex2f
(
20.0
f
,
80.0
f
);
glVertex2f
(
20.0
f
,
70.0
f
);
glVertex2f
(
100.0
f
,
70.0
f
);
glVertex2f
(
100.0
f
,
60.0
f
);
glVertex2f
(
100.0
f
,
80.0
f
);
glEnd
();
// draw markers
glColor3f
(
0.0
f
,
0.0
f
,
0.0
f
);
glLineWidth
(
1.5
f
);
glBegin
(
GL_LINES
);
glVertex2f
(
20.0
f
,
60.0
f
);
glVertex2f
(
20.0
f
,
80.0
f
);
glVertex2f
(
20.0
f
,
70.0
f
);
glVertex2f
(
100.0
f
,
70.0
f
);
glVertex2f
(
100.0
f
,
60.0
f
);
glVertex2f
(
100.0
f
,
80.0
f
);
glEnd
();
float
f
=
windowHeight
/
2.0
f
/
tanf
(
d2r
(
cameraParams
.
cameraFov
/
2.0
f
));
float
dist
=
cameraPose
.
distance
/
f
*
80.0
f
;
QPainter
painter
;
painter
.
begin
(
this
);
painter
.
setRenderHint
(
QPainter
::
Antialiasing
,
true
);
painter
.
setRenderHint
(
QPainter
::
HighQualityAntialiasing
,
true
);
QColor
rgb
(
255
,
255
,
255
);
if
(
imageryComboBox
->
currentText
().
compare
(
"Map (Google)"
)
==
0
)
{
rgb
.
setRgb
(
0
,
0
,
0
);
}
paintText
(
QString
(
"%1 m"
).
arg
(
dist
,
0
,
'f'
,
2
),
rgb
,
10
,
25
,
getWindowHeight
()
-
65
,
&
painter
);
}
void
QMap3DWidget
::
paintText
(
QString
text
,
QColor
color
,
float
fontSize
,
float
refX
,
float
refY
,
QPainter
*
painter
)
{
QPen
prevPen
=
painter
->
pen
();
...
...
@@ -450,8 +501,11 @@ QMap3DWidget::markTarget(void)
displayTarget
=
true
;
if
(
uas
)
uas
->
setTargetPosition
(
targetPosition
.
x
,
targetPosition
.
y
,
targetPosition
.
z
,
0.0
f
);
if
(
uas
)
{
uas
->
setTargetPosition
(
targetPosition
.
x
,
targetPosition
.
y
,
targetPosition
.
z
,
0.0
f
);
}
}
void
...
...
@@ -533,9 +587,9 @@ QMap3DWidget::drawPlatform(float roll, float pitch, float yaw)
{
glPushMatrix
();
glRotatef
(
(
yaw
*
180.0
f
)
/
M_PI
,
0.0
f
,
0.0
f
,
1.0
f
);
glRotatef
(
(
pitch
*
180.0
f
)
/
M_PI
,
0.0
f
,
1.0
f
,
0.0
f
);
glRotatef
(
(
roll
*
180.0
f
)
/
M_PI
,
1.0
f
,
0.0
f
,
0.0
f
);
glRotatef
(
yaw
*
180.0
f
/
M_PI
,
0.0
f
,
0.0
f
,
1.0
f
);
glRotatef
(
pitch
*
180.0
f
/
M_PI
,
0.0
f
,
1.0
f
,
0.0
f
);
glRotatef
(
roll
*
180.0
f
/
M_PI
,
1.0
f
,
0.0
f
,
0.0
f
);
glLineWidth
(
3.0
f
);
...
...
@@ -606,16 +660,24 @@ QMap3DWidget::drawImagery(double originX, double originY, const QString& zone,
glTranslatef
(
0
,
0
,
0.1
);
CameraPose
camPose
=
getCameraPose
();
double
viewingRadius
=
camPose
.
distance
/
4000.0
*
3000.0
;
double
viewingRadius
=
cameraPose
.
distance
/
4000.0
*
3000.0
;
if
(
viewingRadius
<
100.0
)
{
viewingRadius
=
100.0
;
}
double
minResolution
=
0.125
;
double
centerResolution
=
camPose
.
distance
/
160.0
;
double
maxResolution
=
2.0
;
double
minResolution
=
0.25
;
double
centerResolution
=
cameraPose
.
distance
/
100.0
;
double
maxResolution
=
1048576.0
;
if
(
imageryComboBox
->
currentText
().
compare
(
"Map (Google)"
)
==
0
)
{
minResolution
=
0.25
;
}
else
if
(
imageryComboBox
->
currentText
().
compare
(
"Satellite (Google)"
)
==
0
)
{
minResolution
=
0.5
;
}
double
resolution
=
minResolution
;
while
(
resolution
*
2.0
<
centerResolution
)
...
...
@@ -627,7 +689,8 @@ QMap3DWidget::drawImagery(double originX, double originY, const QString& zone,
resolution
=
maxResolution
;
}
imagery
->
draw3D
(
viewingRadius
,
resolution
,
originX
,
originY
,
camPose
.
xOffset
,
camPose
.
yOffset
,
zone
);
imagery
->
draw3D
(
viewingRadius
,
resolution
,
originX
,
originY
,
cameraPose
.
xOffset
,
cameraPose
.
yOffset
,
zone
);
if
(
prefetch
)
{
...
...
@@ -635,13 +698,13 @@ QMap3DWidget::drawImagery(double originX, double originY, const QString& zone,
{
imagery
->
prefetch3D
(
viewingRadius
/
2.0
,
resolution
/
2.0
,
originX
,
originY
,
camPose
.
xOffset
,
camPose
.
yOffset
,
zone
);
cam
era
Pose
.
xOffset
,
cam
era
Pose
.
yOffset
,
zone
);
}
if
(
resolution
*
2.0
<=
maxResolution
)
{
imagery
->
prefetch3D
(
viewingRadius
*
2.0
,
resolution
*
2.0
,
originX
,
originY
,
camPose
.
xOffset
,
camPose
.
yOffset
,
zone
);
cam
era
Pose
.
xOffset
,
cam
era
Pose
.
yOffset
,
zone
);
}
}
...
...
src/ui/map3D/QMap3DWidget.h
View file @
97ea3189
...
...
@@ -91,6 +91,8 @@ private:
void
drawTrail
(
float
x
,
float
y
,
float
z
);
void
drawTarget
(
float
x
,
float
y
,
float
z
);
void
drawLegend
(
void
);
double
lastRedrawTime
;
bool
displayGrid
;
...
...
@@ -117,6 +119,8 @@ private:
QScopedPointer
<
CheetahModel
>
cheetahModel
;
QScopedPointer
<
Imagery
>
imagery
;
QComboBox
*
imageryComboBox
;
};
#endif // QMAP3DWIDGET_H
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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