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
4dd1e6b0
Commit
4dd1e6b0
authored
Feb 12, 2013
by
Bryant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The HSIDisplay widget now displays all types of waypoints, not just those of type LOCAL_NED.
parent
cf176d0c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
30 deletions
+43
-30
HSIDisplay.cc
src/ui/HSIDisplay.cc
+42
-29
HSIDisplay.h
src/ui/HSIDisplay.h
+1
-1
No files found.
src/ui/HSIDisplay.cc
View file @
4dd1e6b0
...
...
@@ -1186,7 +1186,7 @@ void HSIDisplay::drawSetpointXYZYaw(float x, float y, float z, float yaw, const
}
}
void
HSIDisplay
::
drawWaypoint
(
QPainter
&
painter
,
const
QColor
&
color
,
float
width
,
const
QVector
<
Waypoint
*>&
list
,
int
i
,
const
QPointF
&
p
)
void
HSIDisplay
::
drawWaypoint
(
QPainter
&
painter
,
const
QColor
&
color
,
float
width
,
const
Waypoint
*
w
,
const
QPointF
&
p
)
{
painter
.
setBrush
(
Qt
::
NoBrush
);
...
...
@@ -1206,19 +1206,20 @@ void HSIDisplay::drawWaypoint(QPainter& painter, const QColor& color, float widt
poly
.
replace
(
3
,
QPointF
(
p
.
x
()
-
waypointSize
/
2.0
f
,
p
.
y
()));
float
radius
=
(
waypointSize
/
2.0
f
)
*
0.8
*
(
1
/
sqrt
(
2.0
f
));
float
acceptRadius
=
list
.
at
(
i
)
->
getAcceptanceRadius
();
float
acceptRadius
=
w
->
getAcceptanceRadius
();
double
yawDiff
=
w
->
getYaw
()
/
180.0
*
M_PI
-
yaw
;
// Draw background
pen
.
setColor
(
Qt
::
black
);
painter
.
setPen
(
pen
);
drawLine
(
p
.
x
(),
p
.
y
(),
p
.
x
()
+
sin
(
list
.
at
(
i
)
->
getYaw
()
/
180.0
*
M_PI
-
yaw
)
*
radius
,
p
.
y
()
-
cos
(
list
.
at
(
i
)
->
getYaw
()
/
180.0
*
M_PI
-
yaw
)
*
radius
,
refLineWidthToPen
(
0.4
f
*
3.0
f
),
Qt
::
black
,
&
painter
);
drawLine
(
p
.
x
(),
p
.
y
(),
p
.
x
()
+
sin
(
yawDiff
)
*
radius
,
p
.
y
()
-
cos
(
yawDiff
)
*
radius
,
refLineWidthToPen
(
0.4
f
*
3.0
f
),
Qt
::
black
,
&
painter
);
drawPolygon
(
poly
,
&
painter
);
drawCircle
(
p
.
x
(),
p
.
y
(),
metricToRef
(
acceptRadius
),
3.0
,
Qt
::
black
,
&
painter
);
// Draw foreground
pen
.
setColor
(
color
);
painter
.
setPen
(
pen
);
drawLine
(
p
.
x
(),
p
.
y
(),
p
.
x
()
+
sin
(
list
.
at
(
i
)
->
getYaw
()
/
180.0
*
M_PI
-
yaw
)
*
radius
,
p
.
y
()
-
cos
(
list
.
at
(
i
)
->
getYaw
()
/
180.0
*
M_PI
-
yaw
)
*
radius
,
refLineWidthToPen
(
0.4
f
),
color
,
&
painter
);
drawLine
(
p
.
x
(),
p
.
y
(),
p
.
x
()
+
sin
(
yawDiff
)
*
radius
,
p
.
y
()
-
cos
(
yawDiff
)
*
radius
,
refLineWidthToPen
(
0.4
f
),
color
,
&
painter
);
drawPolygon
(
poly
,
&
painter
);
drawCircle
(
p
.
x
(),
p
.
y
(),
metricToRef
(
acceptRadius
),
1.0
,
Qt
::
green
,
&
painter
);
}
...
...
@@ -1227,51 +1228,65 @@ void HSIDisplay::drawWaypoints(QPainter& painter)
{
if
(
uas
)
{
// Grab all waypoints.
const
QVector
<
Waypoint
*>&
list
=
uas
->
getWaypointManager
()
->
getWaypointEditableList
();
const
int
numWaypoints
=
list
.
size
();
// Do not work on empty lists
if
(
list
.
size
()
==
0
)
return
;
if
(
list
.
size
()
==
0
)
{
return
;
}
QColor
color
;
// Make sure any drawn shapes are not filled-in.
painter
.
setBrush
(
Qt
::
NoBrush
);
// XXX Ugly hacks, needs rewrite
QPointF
lastWaypoint
;
QPointF
currentWaypoint
;
int
currentIndex
=
0
;
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
numWaypoints
;
i
++
)
{
const
Waypoint
*
w
=
list
.
at
(
i
);
QPointF
in
;
if
(
list
.
at
(
i
)
->
getFrame
()
==
MAV_FRAME_LOCAL_NED
)
// Use local coordinates as-is.
int
frameRef
=
w
->
getFrame
();
if
(
frameRef
==
MAV_FRAME_LOCAL_NED
)
{
// Do not transform
in
=
QPointF
(
list
.
at
(
i
)
->
getX
(),
list
.
at
(
i
)
->
getY
());
}
else
{
// Transform to local coordinates first
double
x
=
list
.
at
(
i
)
->
getX
();
double
y
=
list
.
at
(
i
)
->
getY
();
in
=
QPointF
(
x
,
y
);
in
=
QPointF
(
w
->
getX
(),
w
->
getY
());
}
else
if
(
frameRef
==
MAV_FRAME_LOCAL_ENU
)
{
in
=
QPointF
(
w
->
getY
(),
w
->
getX
());
}
// Convert global coordinates into the local ENU frame, then display them.
else
if
(
frameRef
==
MAV_FRAME_GLOBAL
||
frameRef
==
MAV_FRAME_GLOBAL_RELATIVE_ALT
)
{
// Get the position of the GPS origin for the MAV.
// Transform the lat/lon for this waypoint into the local frame
double
e
,
n
,
u
;
UASManager
::
instance
()
->
wgs84ToEnu
(
w
->
getX
(),
w
->
getY
(),
w
->
getZ
(),
&
e
,
&
n
,
&
u
);
in
=
QPointF
(
n
,
e
);
}
// Otherwise we don't process this waypoint.
// FIXME: This code will probably fail if the last waypoint found is not a valid one.
else
{
continue
;
}
// Transform from world to body coordinates
in
=
metricWorldToBody
(
in
);
// Scale from metric to screen reference coordinates
QPointF
p
=
metricBodyToRef
(
in
);
// Select color based on if this is the current waypoint
if
(
list
.
at
(
i
)
->
getCurrent
())
// Select color based on if this is the current waypoint
.
if
(
w
->
getCurrent
())
{
currentIndex
=
i
;
currentWaypoint
=
p
;
drawWaypoint
(
painter
,
QGC
::
colorYellow
,
refLineWidthToPen
(
0.8
f
),
w
,
p
);
}
else
{
drawWaypoint
(
painter
,
QGC
::
colorCyan
,
refLineWidthToPen
(
0.4
f
),
list
,
i
,
p
);
drawWaypoint
(
painter
,
QGC
::
colorCyan
,
refLineWidthToPen
(
0.4
f
),
w
,
p
);
}
// DRAW CONNECTING LINE
// Draw line from last waypoint to this one
// Draw connecting line from last waypoint to this one.
if
(
!
lastWaypoint
.
isNull
())
{
drawLine
(
lastWaypoint
.
x
(),
lastWaypoint
.
y
(),
p
.
x
(),
p
.
y
(),
refLineWidthToPen
(
0.4
f
*
2.0
f
),
Qt
::
black
,
&
painter
);
...
...
@@ -1279,8 +1294,6 @@ void HSIDisplay::drawWaypoints(QPainter& painter)
}
lastWaypoint
=
p
;
}
drawWaypoint
(
painter
,
QGC
::
colorYellow
,
refLineWidthToPen
(
0.8
f
),
list
,
currentIndex
,
currentWaypoint
);
}
}
...
...
src/ui/HSIDisplay.h
View file @
4dd1e6b0
...
...
@@ -199,7 +199,7 @@ protected slots:
/** @brief Draw waypoints of this system */
void
drawWaypoints
(
QPainter
&
painter
);
/** @brief Draw one waypoint */
void
drawWaypoint
(
QPainter
&
painter
,
const
QColor
&
color
,
float
width
,
const
QVector
<
Waypoint
*>&
list
,
int
i
,
const
QPointF
&
p
);
void
drawWaypoint
(
QPainter
&
painter
,
const
QColor
&
color
,
float
width
,
const
Waypoint
*
w
,
const
QPointF
&
p
);
/** @brief Draw the limiting safety area */
void
drawSafetyArea
(
const
QPointF
&
topLeft
,
const
QPointF
&
bottomRight
,
const
QColor
&
color
,
QPainter
&
painter
);
/** @brief Receive mouse clicks */
...
...
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