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
25b35d89
Commit
25b35d89
authored
Jan 30, 2012
by
hengli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug in showEvent/hideEvent for Pixhawk3DWidget.
parent
56249630
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
477 additions
and
163 deletions
+477
-163
qgroundcontrol.pro
qgroundcontrol.pro
+4
-2
Pixhawk3DWidget.cc
src/ui/map3D/Pixhawk3DWidget.cc
+86
-150
Pixhawk3DWidget.h
src/ui/map3D/Pixhawk3DWidget.h
+2
-11
gpl.cc
src/ui/map3D/gpl.cc
+333
-0
gpl.h
src/ui/map3D/gpl.h
+52
-0
No files found.
qgroundcontrol.pro
View file @
25b35d89
...
...
@@ -361,7 +361,8 @@ HEADERS += src/MG.h \
src
/
ui
/
mavlink
/
QGCMAVLinkMessageSender
.
h
\
src
/
ui
/
firmwareupdate
/
QGCFirmwareUpdateWidget
.
h
\
src
/
ui
/
QGCPluginHost
.
h
\
src
/
ui
/
firmwareupdate
/
QGCPX4FirmwareUpdate
.
h
src
/
ui
/
firmwareupdate
/
QGCPX4FirmwareUpdate
.
h
\
src
/
ui
/
map3D
/
gpl
.
h
#
Google
Earth
is
only
supported
on
Mac
OS
and
Windows
with
Visual
Studio
Compiler
macx
|
macx
-
g
++
|
macx
-
g
++
42
|
win32
-
msvc2008
|
win32
-
msvc2010
::
HEADERS
+=
src
/
ui
/
map3D
/
QGCGoogleEarthView
.
h
...
...
@@ -494,7 +495,8 @@ SOURCES += src/main.cc \
src
/
ui
/
mavlink
/
QGCMAVLinkMessageSender
.
cc
\
src
/
ui
/
firmwareupdate
/
QGCFirmwareUpdateWidget
.
cc
\
src
/
ui
/
QGCPluginHost
.
cc
\
src
/
ui
/
firmwareupdate
/
QGCPX4FirmwareUpdate
.
cc
src
/
ui
/
firmwareupdate
/
QGCPX4FirmwareUpdate
.
cc
\
src
/
ui
/
map3D
/
gpl
.
cc
#
Enable
Google
Earth
only
on
Mac
OS
and
Windows
with
Visual
Studio
compiler
macx
|
macx
-
g
++
|
macx
-
g
++
42
|
win32
-
msvc2008
|
win32
-
msvc2010
::
SOURCES
+=
src
/
ui
/
map3D
/
QGCGoogleEarthView
.
cc
...
...
src/ui/map3D/Pixhawk3DWidget.cc
View file @
25b35d89
...
...
@@ -43,6 +43,7 @@
#include "UASManager.h"
#include "QGC.h"
#include "gpl.h"
#ifdef QGC_PROTOBUF_ENABLED
#include <tr1/memory>
...
...
@@ -55,7 +56,7 @@ Pixhawk3DWidget::Pixhawk3DWidget(QWidget* parent)
,
mode
(
DEFAULT_MODE
)
,
selectedWpIndex
(
-
1
)
,
displayGrid
(
true
)
,
displayTrail
(
fals
e
)
,
displayTrail
(
tru
e
)
,
displayImagery
(
true
)
,
displayWaypoints
(
true
)
,
displayRGBD2D
(
false
)
...
...
@@ -831,6 +832,20 @@ Pixhawk3DWidget::mousePressEvent(QMouseEvent* event)
Q3DWidget
::
mousePressEvent
(
event
);
}
void
Pixhawk3DWidget
::
showEvent
(
QShowEvent
*
event
)
{
Q3DWidget
::
showEvent
(
event
);
emit
visibilityChanged
(
true
);
}
void
Pixhawk3DWidget
::
hideEvent
(
QHideEvent
*
event
)
{
Q3DWidget
::
hideEvent
(
event
);
emit
visibilityChanged
(
false
);
}
void
Pixhawk3DWidget
::
mouseMoveEvent
(
QMouseEvent
*
event
)
{
...
...
@@ -1242,10 +1257,10 @@ Pixhawk3DWidget::updateTrail(double robotX, double robotY, double robotZ)
}
}
osg
::
Geometry
*
geometry
=
reinterpret_cast
<
osg
::
Geometry
*>
(
trailNode
->
getDrawable
(
0
));
osg
::
Vec3dArray
*
vertices
=
reinterpret_cast
<
osg
::
Vec3dArray
*>
(
geometry
->
getVertexArray
());
osg
::
Geometry
*
geometry
=
trailNode
->
getDrawable
(
0
)
->
asGeometry
();
osg
::
DrawArrays
*
drawArrays
=
reinterpret_cast
<
osg
::
DrawArrays
*>
(
geometry
->
getPrimitiveSet
(
0
));
vertices
->
clear
();
osg
::
ref_ptr
<
osg
::
Vec3Array
>
vertices
(
new
osg
::
Vec3Array
);
for
(
int
i
=
0
;
i
<
trail
.
size
();
++
i
)
{
vertices
->
push_back
(
osg
::
Vec3d
(
trail
[
i
].
y
()
-
robotY
,
...
...
@@ -1253,6 +1268,7 @@ Pixhawk3DWidget::updateTrail(double robotX, double robotY, double robotZ)
-
(
trail
[
i
].
z
()
-
robotZ
)));
}
geometry
->
setVertexArray
(
vertices
);
drawArrays
->
setFirst
(
0
);
drawArrays
->
setCount
(
vertices
->
size
());
geometry
->
dirtyBound
();
...
...
@@ -1359,137 +1375,6 @@ Pixhawk3DWidget::updateTarget(double robotX, double robotY)
sd
->
setColor
(
osg
::
Vec4f
(
1.0
f
,
0.8
f
,
0.0
f
,
1.0
f
));
}
float
colormap_jet
[
128
][
3
]
=
{
{
0.0
f
,
0.0
f
,
0.53125
f
},
{
0.0
f
,
0.0
f
,
0.5625
f
},
{
0.0
f
,
0.0
f
,
0.59375
f
},
{
0.0
f
,
0.0
f
,
0.625
f
},
{
0.0
f
,
0.0
f
,
0.65625
f
},
{
0.0
f
,
0.0
f
,
0.6875
f
},
{
0.0
f
,
0.0
f
,
0.71875
f
},
{
0.0
f
,
0.0
f
,
0.75
f
},
{
0.0
f
,
0.0
f
,
0.78125
f
},
{
0.0
f
,
0.0
f
,
0.8125
f
},
{
0.0
f
,
0.0
f
,
0.84375
f
},
{
0.0
f
,
0.0
f
,
0.875
f
},
{
0.0
f
,
0.0
f
,
0.90625
f
},
{
0.0
f
,
0.0
f
,
0.9375
f
},
{
0.0
f
,
0.0
f
,
0.96875
f
},
{
0.0
f
,
0.0
f
,
1.0
f
},
{
0.0
f
,
0.03125
f
,
1.0
f
},
{
0.0
f
,
0.0625
f
,
1.0
f
},
{
0.0
f
,
0.09375
f
,
1.0
f
},
{
0.0
f
,
0.125
f
,
1.0
f
},
{
0.0
f
,
0.15625
f
,
1.0
f
},
{
0.0
f
,
0.1875
f
,
1.0
f
},
{
0.0
f
,
0.21875
f
,
1.0
f
},
{
0.0
f
,
0.25
f
,
1.0
f
},
{
0.0
f
,
0.28125
f
,
1.0
f
},
{
0.0
f
,
0.3125
f
,
1.0
f
},
{
0.0
f
,
0.34375
f
,
1.0
f
},
{
0.0
f
,
0.375
f
,
1.0
f
},
{
0.0
f
,
0.40625
f
,
1.0
f
},
{
0.0
f
,
0.4375
f
,
1.0
f
},
{
0.0
f
,
0.46875
f
,
1.0
f
},
{
0.0
f
,
0.5
f
,
1.0
f
},
{
0.0
f
,
0.53125
f
,
1.0
f
},
{
0.0
f
,
0.5625
f
,
1.0
f
},
{
0.0
f
,
0.59375
f
,
1.0
f
},
{
0.0
f
,
0.625
f
,
1.0
f
},
{
0.0
f
,
0.65625
f
,
1.0
f
},
{
0.0
f
,
0.6875
f
,
1.0
f
},
{
0.0
f
,
0.71875
f
,
1.0
f
},
{
0.0
f
,
0.75
f
,
1.0
f
},
{
0.0
f
,
0.78125
f
,
1.0
f
},
{
0.0
f
,
0.8125
f
,
1.0
f
},
{
0.0
f
,
0.84375
f
,
1.0
f
},
{
0.0
f
,
0.875
f
,
1.0
f
},
{
0.0
f
,
0.90625
f
,
1.0
f
},
{
0.0
f
,
0.9375
f
,
1.0
f
},
{
0.0
f
,
0.96875
f
,
1.0
f
},
{
0.0
f
,
1.0
f
,
1.0
f
},
{
0.03125
f
,
1.0
f
,
0.96875
f
},
{
0.0625
f
,
1.0
f
,
0.9375
f
},
{
0.09375
f
,
1.0
f
,
0.90625
f
},
{
0.125
f
,
1.0
f
,
0.875
f
},
{
0.15625
f
,
1.0
f
,
0.84375
f
},
{
0.1875
f
,
1.0
f
,
0.8125
f
},
{
0.21875
f
,
1.0
f
,
0.78125
f
},
{
0.25
f
,
1.0
f
,
0.75
f
},
{
0.28125
f
,
1.0
f
,
0.71875
f
},
{
0.3125
f
,
1.0
f
,
0.6875
f
},
{
0.34375
f
,
1.0
f
,
0.65625
f
},
{
0.375
f
,
1.0
f
,
0.625
f
},
{
0.40625
f
,
1.0
f
,
0.59375
f
},
{
0.4375
f
,
1.0
f
,
0.5625
f
},
{
0.46875
f
,
1.0
f
,
0.53125
f
},
{
0.5
f
,
1.0
f
,
0.5
f
},
{
0.53125
f
,
1.0
f
,
0.46875
f
},
{
0.5625
f
,
1.0
f
,
0.4375
f
},
{
0.59375
f
,
1.0
f
,
0.40625
f
},
{
0.625
f
,
1.0
f
,
0.375
f
},
{
0.65625
f
,
1.0
f
,
0.34375
f
},
{
0.6875
f
,
1.0
f
,
0.3125
f
},
{
0.71875
f
,
1.0
f
,
0.28125
f
},
{
0.75
f
,
1.0
f
,
0.25
f
},
{
0.78125
f
,
1.0
f
,
0.21875
f
},
{
0.8125
f
,
1.0
f
,
0.1875
f
},
{
0.84375
f
,
1.0
f
,
0.15625
f
},
{
0.875
f
,
1.0
f
,
0.125
f
},
{
0.90625
f
,
1.0
f
,
0.09375
f
},
{
0.9375
f
,
1.0
f
,
0.0625
f
},
{
0.96875
f
,
1.0
f
,
0.03125
f
},
{
1.0
f
,
1.0
f
,
0.0
f
},
{
1.0
f
,
0.96875
f
,
0.0
f
},
{
1.0
f
,
0.9375
f
,
0.0
f
},
{
1.0
f
,
0.90625
f
,
0.0
f
},
{
1.0
f
,
0.875
f
,
0.0
f
},
{
1.0
f
,
0.84375
f
,
0.0
f
},
{
1.0
f
,
0.8125
f
,
0.0
f
},
{
1.0
f
,
0.78125
f
,
0.0
f
},
{
1.0
f
,
0.75
f
,
0.0
f
},
{
1.0
f
,
0.71875
f
,
0.0
f
},
{
1.0
f
,
0.6875
f
,
0.0
f
},
{
1.0
f
,
0.65625
f
,
0.0
f
},
{
1.0
f
,
0.625
f
,
0.0
f
},
{
1.0
f
,
0.59375
f
,
0.0
f
},
{
1.0
f
,
0.5625
f
,
0.0
f
},
{
1.0
f
,
0.53125
f
,
0.0
f
},
{
1.0
f
,
0.5
f
,
0.0
f
},
{
1.0
f
,
0.46875
f
,
0.0
f
},
{
1.0
f
,
0.4375
f
,
0.0
f
},
{
1.0
f
,
0.40625
f
,
0.0
f
},
{
1.0
f
,
0.375
f
,
0.0
f
},
{
1.0
f
,
0.34375
f
,
0.0
f
},
{
1.0
f
,
0.3125
f
,
0.0
f
},
{
1.0
f
,
0.28125
f
,
0.0
f
},
{
1.0
f
,
0.25
f
,
0.0
f
},
{
1.0
f
,
0.21875
f
,
0.0
f
},
{
1.0
f
,
0.1875
f
,
0.0
f
},
{
1.0
f
,
0.15625
f
,
0.0
f
},
{
1.0
f
,
0.125
f
,
0.0
f
},
{
1.0
f
,
0.09375
f
,
0.0
f
},
{
1.0
f
,
0.0625
f
,
0.0
f
},
{
1.0
f
,
0.03125
f
,
0.0
f
},
{
1.0
f
,
0.0
f
,
0.0
f
},
{
0.96875
f
,
0.0
f
,
0.0
f
},
{
0.9375
f
,
0.0
f
,
0.0
f
},
{
0.90625
f
,
0.0
f
,
0.0
f
},
{
0.875
f
,
0.0
f
,
0.0
f
},
{
0.84375
f
,
0.0
f
,
0.0
f
},
{
0.8125
f
,
0.0
f
,
0.0
f
},
{
0.78125
f
,
0.0
f
,
0.0
f
},
{
0.75
f
,
0.0
f
,
0.0
f
},
{
0.71875
f
,
0.0
f
,
0.0
f
},
{
0.6875
f
,
0.0
f
,
0.0
f
},
{
0.65625
f
,
0.0
f
,
0.0
f
},
{
0.625
f
,
0.0
f
,
0.0
f
},
{
0.59375
f
,
0.0
f
,
0.0
f
},
{
0.5625
f
,
0.0
f
,
0.0
f
},
{
0.53125
f
,
0.0
f
,
0.0
f
},
{
0.5
f
,
0.0
f
,
0.0
f
}
};
#ifdef QGC_PROTOBUF_ENABLED
void
Pixhawk3DWidget
::
updateRGBD
(
double
robotX
,
double
robotY
,
double
robotZ
)
...
...
@@ -1517,9 +1402,11 @@ Pixhawk3DWidget::updateRGBD(double robotX, double robotY, double robotZ)
int
idx
=
fminf
(
depth
[
c
],
7.0
f
)
/
7.0
f
*
127.0
f
;
idx
=
127
-
idx
;
pixel
[
0
]
=
colormap_jet
[
idx
][
2
]
*
255.0
f
;
pixel
[
1
]
=
colormap_jet
[
idx
][
1
]
*
255.0
f
;
pixel
[
2
]
=
colormap_jet
[
idx
][
0
]
*
255.0
f
;
float
r
,
g
,
b
;
qgc
::
colormap
(
"jet"
,
idx
,
r
,
g
,
b
);
pixel
[
0
]
=
r
*
255.0
f
;
pixel
[
1
]
=
g
*
255.0
f
;
pixel
[
2
]
=
b
*
255.0
f
;
}
pixel
+=
3
;
...
...
@@ -1562,10 +1449,11 @@ Pixhawk3DWidget::updateRGBD(double robotX, double robotY, double robotZ)
{
double
dist
=
sqrt
(
x
*
x
+
y
*
y
+
z
*
z
);
int
colorIndex
=
static_cast
<
int
>
(
fmin
(
dist
/
7.0
*
127.0
,
127.0
));
(
*
colors
)[
i
].
set
(
colormap_jet
[
colorIndex
][
0
],
colormap_jet
[
colorIndex
][
1
],
colormap_jet
[
colorIndex
][
2
],
1.0
f
);
float
r
,
g
,
b
;
qgc
::
colormap
(
"jet"
,
colorIndex
,
r
,
g
,
b
);
(
*
colors
)[
i
].
set
(
r
,
g
,
b
,
1.0
f
);
}
}
...
...
@@ -1592,19 +1480,67 @@ Pixhawk3DWidget::updatePath(double robotX, double robotY, double robotZ)
{
px
::
Path
path
=
uas
->
getPath
();
osg
::
Geometry
*
geometry
=
reinterpret_cast
<
osg
::
Geometry
*>
(
pathNode
->
getDrawable
(
0
));
osg
::
Vec3dArray
*
vertices
=
reinterpret_cast
<
osg
::
Vec3dArray
*>
(
geometry
->
getVertexArray
());
osg
::
Geometry
*
geometry
=
pathNode
->
getDrawable
(
0
)
->
asGeometry
();
osg
::
DrawArrays
*
drawArrays
=
reinterpret_cast
<
osg
::
DrawArrays
*>
(
geometry
->
getPrimitiveSet
(
0
));
vertices
->
clear
();
for
(
int
i
=
0
;
i
<
path
.
waypoints_size
();
++
i
)
osg
::
Vec4Array
*
colorArray
=
reinterpret_cast
<
osg
::
Vec4Array
*>
(
geometry
->
getColorArray
());
geometry
->
setColorBinding
(
osg
::
Geometry
::
BIND_PER_VERTEX
);
osg
::
ref_ptr
<
osg
::
LineWidth
>
linewidth
(
new
osg
::
LineWidth
());
linewidth
->
setWidth
(
2.0
f
);
geometry
->
getStateSet
()
->
setAttributeAndModes
(
linewidth
,
osg
::
StateAttribute
::
ON
);
colorArray
->
clear
();
osg
::
ref_ptr
<
osg
::
Vec3Array
>
vertices
(
new
osg
::
Vec3Array
);
// find path length
float
length
=
0.0
f
;
for
(
int
i
=
0
;
i
<
path
.
waypoints_size
()
-
1
;
++
i
)
{
const
px
::
Waypoint
&
wp0
=
path
.
waypoints
(
i
);
const
px
::
Waypoint
&
wp1
=
path
.
waypoints
(
i
+
1
);
length
+=
qgc
::
hypot3f
(
wp0
.
x
()
-
wp1
.
x
(),
wp0
.
y
()
-
wp1
.
y
(),
wp0
.
z
()
-
wp1
.
z
());
}
// build path
if
(
path
.
waypoints_size
()
>
0
)
{
const
px
::
Waypoint
&
wp0
=
path
.
waypoints
(
0
);
vertices
->
push_back
(
osg
::
Vec3d
(
wp0
.
y
()
-
robotY
,
wp0
.
x
()
-
robotX
,
-
(
wp0
.
z
()
-
robotZ
)));
float
r
,
g
,
b
;
qgc
::
colormap
(
"autumn"
,
0
,
r
,
g
,
b
);
colorArray
->
push_back
(
osg
::
Vec4d
(
r
,
g
,
b
,
1.0
f
));
}
float
lengthCurrent
=
0.0
f
;
for
(
int
i
=
0
;
i
<
path
.
waypoints_size
()
-
1
;
++
i
)
{
const
px
::
Waypoint
&
wp
=
path
.
waypoints
(
i
);
const
px
::
Waypoint
&
wp0
=
path
.
waypoints
(
i
);
const
px
::
Waypoint
&
wp1
=
path
.
waypoints
(
i
+
1
);
vertices
->
push_back
(
osg
::
Vec3d
(
wp
.
y
()
-
robotY
,
wp
.
x
()
-
robotX
,
-
(
wp
.
z
()
-
robotZ
)));
lengthCurrent
+=
qgc
::
hypot3f
(
wp0
.
x
()
-
wp1
.
x
(),
wp0
.
y
()
-
wp1
.
y
(),
wp0
.
z
()
-
wp1
.
z
());
vertices
->
push_back
(
osg
::
Vec3d
(
wp1
.
y
()
-
robotY
,
wp1
.
x
()
-
robotX
,
-
(
wp1
.
z
()
-
robotZ
)));
int
colorIdx
=
lengthCurrent
/
length
*
127.0
f
;
float
r
,
g
,
b
;
qgc
::
colormap
(
"autumn"
,
colorIdx
,
r
,
g
,
b
);
colorArray
->
push_back
(
osg
::
Vec4f
(
r
,
g
,
b
,
1.0
f
));
}
geometry
->
setVertexArray
(
vertices
);
drawArrays
->
setFirst
(
0
);
drawArrays
->
setCount
(
vertices
->
size
());
geometry
->
dirtyBound
();
...
...
src/ui/map3D/Pixhawk3DWidget.h
View file @
25b35d89
...
...
@@ -87,17 +87,8 @@ protected:
virtual
void
display
(
void
);
virtual
void
keyPressEvent
(
QKeyEvent
*
event
);
virtual
void
mousePressEvent
(
QMouseEvent
*
event
);
void
showEvent
(
QShowEvent
*
event
)
{
QWidget
::
showEvent
(
event
);
emit
visibilityChanged
(
true
);
}
void
hideEvent
(
QHideEvent
*
event
)
{
QWidget
::
hideEvent
(
event
);
emit
visibilityChanged
(
false
);
}
virtual
void
showEvent
(
QShowEvent
*
event
);
virtual
void
hideEvent
(
QHideEvent
*
event
);
virtual
void
mouseMoveEvent
(
QMouseEvent
*
event
);
UASInterface
*
uas
;
...
...
src/ui/map3D/gpl.cc
0 → 100644
View file @
25b35d89
#include "gpl.h"
namespace
qgc
{
double
hypot3
(
double
x
,
double
y
,
double
z
)
{
return
sqrt
(
square
(
x
)
+
square
(
y
)
+
square
(
z
));
}
float
hypot3f
(
float
x
,
float
y
,
float
z
)
{
return
sqrtf
(
square
(
x
)
+
square
(
y
)
+
square
(
z
));
}
double
d2r
(
double
deg
)
{
return
deg
/
180.0
*
M_PI
;
}
float
d2r
(
float
deg
)
{
return
deg
/
180.0
f
*
M_PI
;
}
double
r2d
(
double
rad
)
{
return
rad
/
M_PI
*
180.0
;
}
float
r2d
(
float
rad
)
{
return
rad
/
M_PI
*
180.0
f
;
}
float
colormapAutumn
[
128
][
3
]
=
{
{
1.0
f
,
0.
f
,
0.
f
},
{
1.0
f
,
0.007874
f
,
0.
f
},
{
1.0
f
,
0.015748
f
,
0.
f
},
{
1.0
f
,
0.023622
f
,
0.
f
},
{
1.0
f
,
0.031496
f
,
0.
f
},
{
1.0
f
,
0.03937
f
,
0.
f
},
{
1.0
f
,
0.047244
f
,
0.
f
},
{
1.0
f
,
0.055118
f
,
0.
f
},
{
1.0
f
,
0.062992
f
,
0.
f
},
{
1.0
f
,
0.070866
f
,
0.
f
},
{
1.0
f
,
0.07874
f
,
0.
f
},
{
1.0
f
,
0.086614
f
,
0.
f
},
{
1.0
f
,
0.094488
f
,
0.
f
},
{
1.0
f
,
0.10236
f
,
0.
f
},
{
1.0
f
,
0.11024
f
,
0.
f
},
{
1.0
f
,
0.11811
f
,
0.
f
},
{
1.0
f
,
0.12598
f
,
0.
f
},
{
1.0
f
,
0.13386
f
,
0.
f
},
{
1.0
f
,
0.14173
f
,
0.
f
},
{
1.0
f
,
0.14961
f
,
0.
f
},
{
1.0
f
,
0.15748
f
,
0.
f
},
{
1.0
f
,
0.16535
f
,
0.
f
},
{
1.0
f
,
0.17323
f
,
0.
f
},
{
1.0
f
,
0.1811
f
,
0.
f
},
{
1.0
f
,
0.18898
f
,
0.
f
},
{
1.0
f
,
0.19685
f
,
0.
f
},
{
1.0
f
,
0.20472
f
,
0.
f
},
{
1.0
f
,
0.2126
f
,
0.
f
},
{
1.0
f
,
0.22047
f
,
0.
f
},
{
1.0
f
,
0.22835
f
,
0.
f
},
{
1.0
f
,
0.23622
f
,
0.
f
},
{
1.0
f
,
0.24409
f
,
0.
f
},
{
1.0
f
,
0.25197
f
,
0.
f
},
{
1.0
f
,
0.25984
f
,
0.
f
},
{
1.0
f
,
0.26772
f
,
0.
f
},
{
1.0
f
,
0.27559
f
,
0.
f
},
{
1.0
f
,
0.28346
f
,
0.
f
},
{
1.0
f
,
0.29134
f
,
0.
f
},
{
1.0
f
,
0.29921
f
,
0.
f
},
{
1.0
f
,
0.30709
f
,
0.
f
},
{
1.0
f
,
0.31496
f
,
0.
f
},
{
1.0
f
,
0.32283
f
,
0.
f
},
{
1.0
f
,
0.33071
f
,
0.
f
},
{
1.0
f
,
0.33858
f
,
0.
f
},
{
1.0
f
,
0.34646
f
,
0.
f
},
{
1.0
f
,
0.35433
f
,
0.
f
},
{
1.0
f
,
0.3622
f
,
0.
f
},
{
1.0
f
,
0.37008
f
,
0.
f
},
{
1.0
f
,
0.37795
f
,
0.
f
},
{
1.0
f
,
0.38583
f
,
0.
f
},
{
1.0
f
,
0.3937
f
,
0.
f
},
{
1.0
f
,
0.40157
f
,
0.
f
},
{
1.0
f
,
0.40945
f
,
0.
f
},
{
1.0
f
,
0.41732
f
,
0.
f
},
{
1.0
f
,
0.4252
f
,
0.
f
},
{
1.0
f
,
0.43307
f
,
0.
f
},
{
1.0
f
,
0.44094
f
,
0.
f
},
{
1.0
f
,
0.44882
f
,
0.
f
},
{
1.0
f
,
0.45669
f
,
0.
f
},
{
1.0
f
,
0.46457
f
,
0.
f
},
{
1.0
f
,
0.47244
f
,
0.
f
},
{
1.0
f
,
0.48031
f
,
0.
f
},
{
1.0
f
,
0.48819
f
,
0.
f
},
{
1.0
f
,
0.49606
f
,
0.
f
},
{
1.0
f
,
0.50394
f
,
0.
f
},
{
1.0
f
,
0.51181
f
,
0.
f
},
{
1.0
f
,
0.51969
f
,
0.
f
},
{
1.0
f
,
0.52756
f
,
0.
f
},
{
1.0
f
,
0.53543
f
,
0.
f
},
{
1.0
f
,
0.54331
f
,
0.
f
},
{
1.0
f
,
0.55118
f
,
0.
f
},
{
1.0
f
,
0.55906
f
,
0.
f
},
{
1.0
f
,
0.56693
f
,
0.
f
},
{
1.0
f
,
0.5748
f
,
0.
f
},
{
1.0
f
,
0.58268
f
,
0.
f
},
{
1.0
f
,
0.59055
f
,
0.
f
},
{
1.0
f
,
0.59843
f
,
0.
f
},
{
1.0
f
,
0.6063
f
,
0.
f
},
{
1.0
f
,
0.61417
f
,
0.
f
},
{
1.0
f
,
0.62205
f
,
0.
f
},
{
1.0
f
,
0.62992
f
,
0.
f
},
{
1.0
f
,
0.6378
f
,
0.
f
},
{
1.0
f
,
0.64567
f
,
0.
f
},
{
1.0
f
,
0.65354
f
,
0.
f
},
{
1.0
f
,
0.66142
f
,
0.
f
},
{
1.0
f
,
0.66929
f
,
0.
f
},
{
1.0
f
,
0.67717
f
,
0.
f
},
{
1.0
f
,
0.68504
f
,
0.
f
},
{
1.0
f
,
0.69291
f
,
0.
f
},
{
1.0
f
,
0.70079
f
,
0.
f
},
{
1.0
f
,
0.70866
f
,
0.
f
},
{
1.0
f
,
0.71654
f
,
0.
f
},
{
1.0
f
,
0.72441
f
,
0.
f
},
{
1.0
f
,
0.73228
f
,
0.
f
},
{
1.0
f
,
0.74016
f
,
0.
f
},
{
1.0
f
,
0.74803
f
,
0.
f
},
{
1.0
f
,
0.75591
f
,
0.
f
},
{
1.0
f
,
0.76378
f
,
0.
f
},
{
1.0
f
,
0.77165
f
,
0.
f
},
{
1.0
f
,
0.77953
f
,
0.
f
},
{
1.0
f
,
0.7874
f
,
0.
f
},
{
1.0
f
,
0.79528
f
,
0.
f
},
{
1.0
f
,
0.80315
f
,
0.
f
},
{
1.0
f
,
0.81102
f
,
0.
f
},
{
1.0
f
,
0.8189
f
,
0.
f
},
{
1.0
f
,
0.82677
f
,
0.
f
},
{
1.0
f
,
0.83465
f
,
0.
f
},
{
1.0
f
,
0.84252
f
,
0.
f
},
{
1.0
f
,
0.85039
f
,
0.
f
},
{
1.0
f
,
0.85827
f
,
0.
f
},
{
1.0
f
,
0.86614
f
,
0.
f
},
{
1.0
f
,
0.87402
f
,
0.
f
},
{
1.0
f
,
0.88189
f
,
0.
f
},
{
1.0
f
,
0.88976
f
,
0.
f
},
{
1.0
f
,
0.89764
f
,
0.
f
},
{
1.0
f
,
0.90551
f
,
0.
f
},
{
1.0
f
,
0.91339
f
,
0.
f
},
{
1.0
f
,
0.92126
f
,
0.
f
},
{
1.0
f
,
0.92913
f
,
0.
f
},
{
1.0
f
,
0.93701
f
,
0.
f
},
{
1.0
f
,
0.94488
f
,
0.
f
},
{
1.0
f
,
0.95276
f
,
0.
f
},
{
1.0
f
,
0.96063
f
,
0.
f
},
{
1.0
f
,
0.9685
f
,
0.
f
},
{
1.0
f
,
0.97638
f
,
0.
f
},
{
1.0
f
,
0.98425
f
,
0.
f
},
{
1.0
f
,
0.99213
f
,
0.
f
},
{
1.0
f
,
1.0
f
,
0.0
f
}
};
float
colormapJet
[
128
][
3
]
=
{
{
0.0
f
,
0.0
f
,
0.53125
f
},
{
0.0
f
,
0.0
f
,
0.5625
f
},
{
0.0
f
,
0.0
f
,
0.59375
f
},
{
0.0
f
,
0.0
f
,
0.625
f
},
{
0.0
f
,
0.0
f
,
0.65625
f
},
{
0.0
f
,
0.0
f
,
0.6875
f
},
{
0.0
f
,
0.0
f
,
0.71875
f
},
{
0.0
f
,
0.0
f
,
0.75
f
},
{
0.0
f
,
0.0
f
,
0.78125
f
},
{
0.0
f
,
0.0
f
,
0.8125
f
},
{
0.0
f
,
0.0
f
,
0.84375
f
},
{
0.0
f
,
0.0
f
,
0.875
f
},
{
0.0
f
,
0.0
f
,
0.90625
f
},
{
0.0
f
,
0.0
f
,
0.9375
f
},
{
0.0
f
,
0.0
f
,
0.96875
f
},
{
0.0
f
,
0.0
f
,
1.0
f
},
{
0.0
f
,
0.03125
f
,
1.0
f
},
{
0.0
f
,
0.0625
f
,
1.0
f
},
{
0.0
f
,
0.09375
f
,
1.0
f
},
{
0.0
f
,
0.125
f
,
1.0
f
},
{
0.0
f
,
0.15625
f
,
1.0
f
},
{
0.0
f
,
0.1875
f
,
1.0
f
},
{
0.0
f
,
0.21875
f
,
1.0
f
},
{
0.0
f
,
0.25
f
,
1.0
f
},
{
0.0
f
,
0.28125
f
,
1.0
f
},
{
0.0
f
,
0.3125
f
,
1.0
f
},
{
0.0
f
,
0.34375
f
,
1.0
f
},
{
0.0
f
,
0.375
f
,
1.0
f
},
{
0.0
f
,
0.40625
f
,
1.0
f
},
{
0.0
f
,
0.4375
f
,
1.0
f
},
{
0.0
f
,
0.46875
f
,
1.0
f
},
{
0.0
f
,
0.5
f
,
1.0
f
},
{
0.0
f
,
0.53125
f
,
1.0
f
},
{
0.0
f
,
0.5625
f
,
1.0
f
},
{
0.0
f
,
0.59375
f
,
1.0
f
},
{
0.0
f
,
0.625
f
,
1.0
f
},
{
0.0
f
,
0.65625
f
,
1.0
f
},
{
0.0
f
,
0.6875
f
,
1.0
f
},
{
0.0
f
,
0.71875
f
,
1.0
f
},
{
0.0
f
,
0.75
f
,
1.0
f
},
{
0.0
f
,
0.78125
f
,
1.0
f
},
{
0.0
f
,
0.8125
f
,
1.0
f
},
{
0.0
f
,
0.84375
f
,
1.0
f
},
{
0.0
f
,
0.875
f
,
1.0
f
},
{
0.0
f
,
0.90625
f
,
1.0
f
},
{
0.0
f
,
0.9375
f
,
1.0
f
},
{
0.0
f
,
0.96875
f
,
1.0
f
},
{
0.0
f
,
1.0
f
,
1.0
f
},
{
0.03125
f
,
1.0
f
,
0.96875
f
},
{
0.0625
f
,
1.0
f
,
0.9375
f
},
{
0.09375
f
,
1.0
f
,
0.90625
f
},
{
0.125
f
,
1.0
f
,
0.875
f
},
{
0.15625
f
,
1.0
f
,
0.84375
f
},
{
0.1875
f
,
1.0
f
,
0.8125
f
},
{
0.21875
f
,
1.0
f
,
0.78125
f
},
{
0.25
f
,
1.0
f
,
0.75
f
},
{
0.28125
f
,
1.0
f
,
0.71875
f
},
{
0.3125
f
,
1.0
f
,
0.6875
f
},
{
0.34375
f
,
1.0
f
,
0.65625
f
},
{
0.375
f
,
1.0
f
,
0.625
f
},
{
0.40625
f
,
1.0
f
,
0.59375
f
},
{
0.4375
f
,
1.0
f
,
0.5625
f
},
{
0.46875
f
,
1.0
f
,
0.53125
f
},
{
0.5
f
,
1.0
f
,
0.5
f
},
{
0.53125
f
,
1.0
f
,
0.46875
f
},
{
0.5625
f
,
1.0
f
,
0.4375
f
},
{
0.59375
f
,
1.0
f
,
0.40625
f
},
{
0.625
f
,
1.0
f
,
0.375
f
},
{
0.65625
f
,
1.0
f
,
0.34375
f
},
{
0.6875
f
,
1.0
f
,
0.3125
f
},
{
0.71875
f
,
1.0
f
,
0.28125
f
},
{
0.75
f
,
1.0
f
,
0.25
f
},
{
0.78125
f
,
1.0
f
,
0.21875
f
},
{
0.8125
f
,
1.0
f
,
0.1875
f
},
{
0.84375
f
,
1.0
f
,
0.15625
f
},
{
0.875
f
,
1.0
f
,
0.125
f
},
{
0.90625
f
,
1.0
f
,
0.09375
f
},
{
0.9375
f
,
1.0
f
,
0.0625
f
},
{
0.96875
f
,
1.0
f
,
0.03125
f
},
{
1.0
f
,
1.0
f
,
0.0
f
},
{
1.0
f
,
0.96875
f
,
0.0
f
},
{
1.0
f
,
0.9375
f
,
0.0
f
},
{
1.0
f
,
0.90625
f
,
0.0
f
},
{
1.0
f
,
0.875
f
,
0.0
f
},
{
1.0
f
,
0.84375
f
,
0.0
f
},
{
1.0
f
,
0.8125
f
,
0.0
f
},
{
1.0
f
,
0.78125
f
,
0.0
f
},
{
1.0
f
,
0.75
f
,
0.0
f
},
{
1.0
f
,
0.71875
f
,
0.0
f
},
{
1.0
f
,
0.6875
f
,
0.0
f
},
{
1.0
f
,
0.65625
f
,
0.0
f
},
{
1.0
f
,
0.625
f
,
0.0
f
},
{
1.0
f
,
0.59375
f
,
0.0
f
},
{
1.0
f
,
0.5625
f
,
0.0
f
},
{
1.0
f
,
0.53125
f
,
0.0
f
},
{
1.0
f
,
0.5
f
,
0.0
f
},
{
1.0
f
,
0.46875
f
,
0.0
f
},
{
1.0
f
,
0.4375
f
,
0.0
f
},
{
1.0
f
,
0.40625
f
,
0.0
f
},
{
1.0
f
,
0.375
f
,
0.0
f
},
{
1.0
f
,
0.34375
f
,
0.0
f
},
{
1.0
f
,
0.3125
f
,
0.0
f
},
{
1.0
f
,
0.28125
f
,
0.0
f
},
{
1.0
f
,
0.25
f
,
0.0
f
},
{
1.0
f
,
0.21875
f
,
0.0
f
},
{
1.0
f
,
0.1875
f
,
0.0
f
},
{
1.0
f
,
0.15625
f
,
0.0
f
},
{
1.0
f
,
0.125
f
,
0.0
f
},
{
1.0
f
,
0.09375
f
,
0.0
f
},
{
1.0
f
,
0.0625
f
,
0.0
f
},
{
1.0
f
,
0.03125
f
,
0.0
f
},
{
1.0
f
,
0.0
f
,
0.0
f
},
{
0.96875
f
,
0.0
f
,
0.0
f
},
{
0.9375
f
,
0.0
f
,
0.0
f
},
{
0.90625
f
,
0.0
f
,
0.0
f
},
{
0.875
f
,
0.0
f
,
0.0
f
},
{
0.84375
f
,
0.0
f
,
0.0
f
},
{
0.8125
f
,
0.0
f
,
0.0
f
},
{
0.78125
f
,
0.0
f
,
0.0
f
},
{
0.75
f
,
0.0
f
,
0.0
f
},
{
0.71875
f
,
0.0
f
,
0.0
f
},
{
0.6875
f
,
0.0
f
,
0.0
f
},
{
0.65625
f
,
0.0
f
,
0.0
f
},
{
0.625
f
,
0.0
f
,
0.0
f
},
{
0.59375
f
,
0.0
f
,
0.0
f
},
{
0.5625
f
,
0.0
f
,
0.0
f
},
{
0.53125
f
,
0.0
f
,
0.0
f
},
{
0.5
f
,
0.0
f
,
0.0
f
}
};
bool
colormap
(
const
QString
&
name
,
unsigned
char
idx
,
float
&
r
,
float
&
g
,
float
&
b
)
{
if
(
idx
>
127
)
{
return
false
;
}
if
(
name
.
compare
(
"jet"
)
==
0
)
{
float
*
color
=
colormapJet
[
idx
];
r
=
color
[
0
];
g
=
color
[
1
];
b
=
color
[
2
];
return
true
;
}
else
if
(
name
.
compare
(
"autumn"
)
==
0
)
{
float
*
color
=
colormapAutumn
[
idx
];
r
=
color
[
0
];
g
=
color
[
1
];
b
=
color
[
2
];
return
true
;
}
return
false
;
}
}
src/ui/map3D/gpl.h
0 → 100644
View file @
25b35d89
#ifndef GPL_H
#define GPL_H
#include <cmath>
#include <QString>
namespace
qgc
{
template
<
class
T
>
const
T
clamp
(
const
T
&
v
,
const
T
&
a
,
const
T
&
b
)
{
return
qMin
(
b
,
qMax
(
a
,
v
));
}
double
hypot3
(
double
x
,
double
y
,
double
z
);
float
hypot3f
(
float
x
,
float
y
,
float
z
);
template
<
class
T
>
const
T
normalizeTheta
(
const
T
&
theta
)
{
T
normTheta
=
theta
;
while
(
normTheta
<
-
M_PI
)
{
normTheta
+=
2
.
0
*
M_PI
;
}
while
(
normTheta
>
M_PI
)
{
normTheta
-=
2
.
0
*
M_PI
;
}
return
normTheta
;
}
double
d2r
(
double
deg
);
float
d2r
(
float
deg
);
double
r2d
(
double
rad
);
float
r2d
(
float
rad
);
template
<
class
T
>
const
T
square
(
const
T
&
x
)
{
return
x
*
x
;
}
bool
colormap
(
const
QString
&
name
,
unsigned
char
idx
,
float
&
r
,
float
&
g
,
float
&
b
);
}
#endif
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