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
5795eb6b
Commit
5795eb6b
authored
Jan 19, 2011
by
pixhawk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjusted minor paths and destructors
parent
8e3ebca8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
190 additions
and
162 deletions
+190
-162
HUD.cc
src/ui/HUD.cc
+190
-162
No files found.
src/ui/HUD.cc
View file @
5795eb6b
...
@@ -142,11 +142,11 @@ HUD::HUD(int width, int height, QWidget* parent)
...
@@ -142,11 +142,11 @@ HUD::HUD(int width, int height, QWidget* parent)
fill
.
setColor
(
2
,
qRgb
(
0
,
0
,
0
));
fill
.
setColor
(
2
,
qRgb
(
0
,
0
,
0
));
fill
.
fill
(
0
);
fill
.
fill
(
0
);
QString
imagePath
=
"/Users/user/Desktop/frame0000.png"
;
//
QString imagePath = "/Users/user/Desktop/frame0000.png";
qDebug
()
<<
__FILE__
<<
__LINE__
<<
"template image:"
<<
imagePath
;
//
qDebug() << __FILE__ << __LINE__ << "template image:" << imagePath;
fill
=
QImage
(
imagePath
);
//
fill = QImage(imagePath);
glImage
=
QGLWidget
::
convertToGLFormat
(
fill
);
//
glImage = QGLWidget::convertToGLFormat(fill);
// Refresh timer
// Refresh timer
refreshTimer
->
setInterval
(
updateInterval
);
refreshTimer
->
setInterval
(
updateInterval
);
...
@@ -154,8 +154,7 @@ HUD::HUD(int width, int height, QWidget* parent)
...
@@ -154,8 +154,7 @@ HUD::HUD(int width, int height, QWidget* parent)
connect
(
refreshTimer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
paintHUD
()));
connect
(
refreshTimer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
paintHUD
()));
// Resize to correct size and fill with image
// Resize to correct size and fill with image
resize
(
fill
.
size
());
//glDrawPixels(glImage.width(), glImage.height(), GL_RGBA, GL_UNSIGNED_BYTE, glImage.bits());
glDrawPixels
(
glImage
.
width
(),
glImage
.
height
(),
GL_RGBA
,
GL_UNSIGNED_BYTE
,
glImage
.
bits
());
// Set size once
// Set size once
//setFixedSize(fill.size());
//setFixedSize(fill.size());
...
@@ -189,7 +188,7 @@ HUD::HUD(int width, int height, QWidget* parent)
...
@@ -189,7 +188,7 @@ HUD::HUD(int width, int height, QWidget* parent)
HUD
::~
HUD
()
HUD
::~
HUD
()
{
{
refreshTimer
->
stop
();
}
}
QSize
HUD
::
sizeHint
()
const
QSize
HUD
::
sizeHint
()
const
...
@@ -551,206 +550,235 @@ void HUD::paintEvent(QPaintEvent *event)
...
@@ -551,206 +550,235 @@ void HUD::paintEvent(QPaintEvent *event)
void
HUD
::
paintHUD
()
void
HUD
::
paintHUD
()
{
{
// static quint64 interval = 0;
if
(
isVisible
())
// qDebug() << "INTERVAL:" << MG::TIME::getGroundTimeNow() - interval << __FILE__ << __LINE__;
{
// interval = MG::TIME::getGroundTimeNow();
// static quint64 interval = 0;
// qDebug() << "INTERVAL:" << MG::TIME::getGroundTimeNow() - interval << __FILE__ << __LINE__;
// interval = MG::TIME::getGroundTimeNow();
#if (QGC_EVENTLOOP_DEBUG)
#if (QGC_EVENTLOOP_DEBUG)
qDebug
()
<<
"EVENTLOOP:"
<<
__FILE__
<<
__LINE__
;
qDebug
()
<<
"EVENTLOOP:"
<<
__FILE__
<<
__LINE__
;
#endif
#endif
// Read out most important values to limit hash table lookups
// Read out most important values to limit hash table lookups
// Low-pass roll, pitch and yaw
// Low-pass roll, pitch and yaw
rollLP
=
rollLP
*
0.2
f
+
0.8
f
*
roll
;
rollLP
=
rollLP
*
0.2
f
+
0.8
f
*
roll
;
pitchLP
=
pitchLP
*
0.2
f
+
0.8
f
*
pitch
;
pitchLP
=
pitchLP
*
0.2
f
+
0.8
f
*
pitch
;
yawLP
=
yawLP
*
0.2
f
+
0.8
f
*
yaw
;
yawLP
=
yawLP
*
0.2
f
+
0.8
f
*
yaw
;
// Translate for yaw
const
float
maxYawTrans
=
60.0
f
;
float
newYawDiff
=
yawDiff
;
if
(
isinf
(
newYawDiff
))
newYawDiff
=
yawDiff
;
if
(
newYawDiff
>
M_PI
)
newYawDiff
=
newYawDiff
-
M_PI
;
if
(
newYawDiff
<
-
M_PI
)
newYawDiff
=
newYawDiff
+
M_PI
;
newYawDiff
=
yawDiff
*
0.8
+
newYawDiff
*
0.2
;
yawDiff
=
newYawDiff
;
yawInt
+=
newYawDiff
;
if
(
yawInt
>
M_PI
)
yawInt
=
M_PI
;
if
(
yawInt
<
-
M_PI
)
yawInt
=
-
M_PI
;
float
yawTrans
=
yawInt
*
(
double
)
maxYawTrans
;
yawInt
*=
0.6
f
;
if
((
yawTrans
<
5.0
)
&&
(
yawTrans
>
-
5.0
))
yawTrans
=
0
;
// Translate for yaw
const
float
maxYawTrans
=
60.0
f
;
// Negate to correct direction
float
newYawDiff
=
yawDiff
;
yawTrans
=
-
yawTrans
;
if
(
isinf
(
newYawDiff
))
newYawDiff
=
yawDiff
;
if
(
newYawDiff
>
M_PI
)
newYawDiff
=
newYawDiff
-
M_PI
;
//qDebug() << "yaw translation" << yawTrans << "integral" << yawInt << "difference" << yawDiff << "yaw" << yaw
;
if
(
newYawDiff
<
-
M_PI
)
newYawDiff
=
newYawDiff
+
M_PI
;
// Update scaling factor
newYawDiff
=
yawDiff
*
0.8
+
newYawDiff
*
0.2
;
// adjust scaling to fit both horizontally and vertically
scalingFactor
=
this
->
width
()
/
vwidth
;
double
scalingFactorH
=
this
->
height
()
/
vheight
;
if
(
scalingFactorH
<
scalingFactor
)
scalingFactor
=
scalingFactorH
;
yawDiff
=
newYawDiff
;
yawInt
+=
newYawDiff
;
// OPEN GL PAINTING
if
(
yawInt
>
M_PI
)
yawInt
=
M_PI
;
// Store model view matrix to be able to reset it to the previous state
if
(
yawInt
<
-
M_PI
)
yawInt
=
-
M_PI
;
makeCurrent
();
glMatrixMode
(
GL_MODELVIEW
);
glPushMatrix
();
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
// Blue / Brown background
float
yawTrans
=
yawInt
*
(
double
)
maxYawTrans
;
if
(
noCamera
)
paintCenterBackground
(
roll
,
pitch
,
yawTrans
);
yawInt
*=
0.6
f
;
glMatrixMode
(
GL_MODELVIEW
);
glPopMatrix
();
// END OF OPENGL PAINTING
if
((
yawTrans
<
5.0
)
&&
(
yawTrans
>
-
5.0
))
yawTrans
=
0
;
// Negate to correct direction
yawTrans
=
-
yawTrans
;
//qDebug() << "yaw translation" << yawTrans << "integral" << yawInt << "difference" << yawDiff << "yaw" << yaw;
//glEnable(GL_MULTISAMPLE);
// Update scaling factor
// adjust scaling to fit both horizontally and vertically
scalingFactor
=
this
->
width
()
/
vwidth
;
double
scalingFactorH
=
this
->
height
()
/
vheight
;
if
(
scalingFactorH
<
scalingFactor
)
scalingFactor
=
scalingFactorH
;
// QT PAINTING
//makeCurrent();
QPainter
painter
;
painter
.
begin
(
this
);
painter
.
setRenderHint
(
QPainter
::
Antialiasing
,
true
);
painter
.
setRenderHint
(
QPainter
::
HighQualityAntialiasing
,
true
);
painter
.
translate
((
this
->
vwidth
/
2.0
+
xCenterOffset
)
*
scalingFactor
,
(
this
->
vheight
/
2.0
+
yCenterOffset
)
*
scalingFactor
);
// OPEN GL PAINTING
// Store model view matrix to be able to reset it to the previous state
makeCurrent
();
glMatrixMode
(
GL_MODELVIEW
);
glPushMatrix
();
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
// COORDINATE FRAME IS NOW (0,0) at CENTER OF WIDGET
// Blue / Brown background
if
(
noCamera
)
{
// Draw all fixed indicators
paintCenterBackground
(
roll
,
pitch
,
yawTrans
);
// MODE
}
paintText
(
mode
,
infoColor
,
2.0
f
,
(
-
vwidth
/
2.0
)
+
10
,
-
vheight
/
2.0
+
10
,
&
painter
);
// else {
// STATE
// Fill with black background
paintText
(
state
,
infoColor
,
2.0
f
,
(
-
vwidth
/
2.0
)
+
10
,
-
vheight
/
2.0
+
15
,
&
painter
);
QString
imagePath
=
"/Users/user/Desktop/frame0000.png"
;
// BATTERY
if
(
QFileInfo
(
imagePath
).
exists
())
paintText
(
fuelStatus
,
fuelColor
,
2.0
f
,
(
-
vwidth
/
2.0
)
+
10
,
-
vheight
/
2.0
+
20
,
&
painter
);
{
// Waypoint
//qDebug() << __FILE__ << __LINE__ << "template image:" << imagePath;
paintText
(
waypointName
,
defaultColor
,
2.0
f
,
(
-
vwidth
/
3.0
)
+
10
,
+
vheight
/
3.0
+
15
,
&
painter
);
QImage
fill
=
QImage
(
imagePath
);
// YAW INDICATOR
//
// .
// . .
// .......
//
const
float
yawIndicatorWidth
=
4.0
f
;
const
float
yawIndicatorY
=
vheight
/
2.0
f
-
10.0
f
;
QPolygon
yawIndicator
(
4
);
yawIndicator
.
setPoint
(
0
,
QPoint
(
refToScreenX
(
0.0
f
),
refToScreenY
(
yawIndicatorY
)));
yawIndicator
.
setPoint
(
1
,
QPoint
(
refToScreenX
(
yawIndicatorWidth
/
2.0
f
),
refToScreenY
(
yawIndicatorY
+
yawIndicatorWidth
)));
yawIndicator
.
setPoint
(
2
,
QPoint
(
refToScreenX
(
-
yawIndicatorWidth
/
2.0
f
),
refToScreenY
(
yawIndicatorY
+
yawIndicatorWidth
)));
yawIndicator
.
setPoint
(
3
,
QPoint
(
refToScreenX
(
0.0
f
),
refToScreenY
(
yawIndicatorY
)));
painter
.
setPen
(
defaultColor
);
painter
.
drawPolyline
(
yawIndicator
);
// CENTER
// HEADING INDICATOR
glImage
=
QGLWidget
::
convertToGLFormat
(
fill
);
//
// __ __
// \/\/
//
const
float
hIndicatorWidth
=
7.0
f
;
const
float
hIndicatorY
=
-
25.0
f
;
const
float
hIndicatorYLow
=
hIndicatorY
+
hIndicatorWidth
/
6.0
f
;
const
float
hIndicatorSegmentWidth
=
hIndicatorWidth
/
7.0
f
;
QPolygon
hIndicator
(
7
);
hIndicator
.
setPoint
(
0
,
QPoint
(
refToScreenX
(
0.0
f
-
hIndicatorWidth
/
2.0
f
),
refToScreenY
(
hIndicatorY
)));
hIndicator
.
setPoint
(
1
,
QPoint
(
refToScreenX
(
0.0
f
-
hIndicatorWidth
/
2.0
f
+
hIndicatorSegmentWidth
*
1.75
f
),
refToScreenY
(
hIndicatorY
)));
hIndicator
.
setPoint
(
2
,
QPoint
(
refToScreenX
(
0.0
f
-
hIndicatorSegmentWidth
*
1.0
f
),
refToScreenY
(
hIndicatorYLow
)));
hIndicator
.
setPoint
(
3
,
QPoint
(
refToScreenX
(
0.0
f
),
refToScreenY
(
hIndicatorY
)));
hIndicator
.
setPoint
(
4
,
QPoint
(
refToScreenX
(
0.0
f
+
hIndicatorSegmentWidth
*
1.0
f
),
refToScreenY
(
hIndicatorYLow
)));
hIndicator
.
setPoint
(
5
,
QPoint
(
refToScreenX
(
0.0
f
+
hIndicatorWidth
/
2.0
f
-
hIndicatorSegmentWidth
*
1.75
f
),
refToScreenY
(
hIndicatorY
)));
hIndicator
.
setPoint
(
6
,
QPoint
(
refToScreenX
(
0.0
f
+
hIndicatorWidth
/
2.0
f
),
refToScreenY
(
hIndicatorY
)));
painter
.
setPen
(
defaultColor
);
painter
.
drawPolyline
(
hIndicator
);
float
xFactor
;
float
yFactor
;
// SETPOINT
xFactor
=
width
()
/
(
float
)
fill
.
width
();
const
float
centerWidth
=
4.0
f
;
yFactor
=
height
()
/
(
float
)
fill
.
height
();
painter
.
setPen
(
defaultColor
);
painter
.
setBrush
(
Qt
::
NoBrush
);
// TODO
//painter.drawEllipse(QPointF(refToScreenX(qMin(10.0f, values.value("roll desired", 0.0f) * 10.0f)), refToScreenY(qMin(10.0f, values.value("pitch desired", 0.0f) * 10.0f))), refToScreenX(centerWidth/2.0f), refToScreenX(centerWidth/2.0f));
const
float
centerCrossWidth
=
10.0
f
;
glPixelZoom
(
xFactor
,
yFactor
);
// left
// Resize to correct size and fill with image
painter
.
drawLine
(
QPointF
(
refToScreenX
(
-
centerWidth
/
2.0
f
),
refToScreenY
(
0.0
f
)),
QPointF
(
refToScreenX
(
-
centerCrossWidth
/
2.0
f
),
refToScreenY
(
0.0
f
)));
glDrawPixels
(
glImage
.
width
(),
glImage
.
height
(),
GL_RGBA
,
GL_UNSIGNED_BYTE
,
glImage
.
bits
());
// right
// FIXME Adjust viewport to scale image into view
painter
.
drawLine
(
QPointF
(
refToScreenX
(
centerWidth
/
2.0
f
),
refToScreenY
(
0.0
f
)),
QPointF
(
refToScreenX
(
centerCrossWidth
/
2.0
f
),
refToScreenY
(
0.0
f
)));
}
// top
painter
.
drawLine
(
QPointF
(
refToScreenX
(
0.0
f
),
refToScreenY
(
-
centerWidth
/
2.0
f
)),
QPointF
(
refToScreenX
(
0.0
f
),
refToScreenY
(
-
centerCrossWidth
/
2.0
f
)));
// }
glMatrixMode
(
GL_MODELVIEW
);
glPopMatrix
();
// END OF OPENGL PAINTING
//glEnable(GL_MULTISAMPLE);
// QT PAINTING
//makeCurrent();
QPainter
painter
;
painter
.
begin
(
this
);
painter
.
setRenderHint
(
QPainter
::
Antialiasing
,
true
);
painter
.
setRenderHint
(
QPainter
::
HighQualityAntialiasing
,
true
);
painter
.
translate
((
this
->
vwidth
/
2.0
+
xCenterOffset
)
*
scalingFactor
,
(
this
->
vheight
/
2.0
+
yCenterOffset
)
*
scalingFactor
);
// COORDINATE FRAME IS NOW (0,0) at CENTER OF WIDGET
// Draw all fixed indicators
// MODE
paintText
(
mode
,
infoColor
,
2.0
f
,
(
-
vwidth
/
2.0
)
+
10
,
-
vheight
/
2.0
+
10
,
&
painter
);
// STATE
paintText
(
state
,
infoColor
,
2.0
f
,
(
-
vwidth
/
2.0
)
+
10
,
-
vheight
/
2.0
+
15
,
&
painter
);
// BATTERY
paintText
(
fuelStatus
,
fuelColor
,
2.0
f
,
(
-
vwidth
/
2.0
)
+
10
,
-
vheight
/
2.0
+
20
,
&
painter
);
// Waypoint
paintText
(
waypointName
,
defaultColor
,
2.0
f
,
(
-
vwidth
/
3.0
)
+
10
,
+
vheight
/
3.0
+
15
,
&
painter
);
// YAW INDICATOR
//
// .
// . .
// .......
//
const
float
yawIndicatorWidth
=
4.0
f
;
const
float
yawIndicatorY
=
vheight
/
2.0
f
-
10.0
f
;
QPolygon
yawIndicator
(
4
);
yawIndicator
.
setPoint
(
0
,
QPoint
(
refToScreenX
(
0.0
f
),
refToScreenY
(
yawIndicatorY
)));
yawIndicator
.
setPoint
(
1
,
QPoint
(
refToScreenX
(
yawIndicatorWidth
/
2.0
f
),
refToScreenY
(
yawIndicatorY
+
yawIndicatorWidth
)));
yawIndicator
.
setPoint
(
2
,
QPoint
(
refToScreenX
(
-
yawIndicatorWidth
/
2.0
f
),
refToScreenY
(
yawIndicatorY
+
yawIndicatorWidth
)));
yawIndicator
.
setPoint
(
3
,
QPoint
(
refToScreenX
(
0.0
f
),
refToScreenY
(
yawIndicatorY
)));
painter
.
setPen
(
defaultColor
);
painter
.
drawPolyline
(
yawIndicator
);
// COMPASS
// CENTER
const
float
compassY
=
-
vheight
/
2.0
f
+
10.0
f
;
QRectF
compassRect
(
QPointF
(
refToScreenX
(
-
5.0
f
),
refToScreenY
(
compassY
)),
QSizeF
(
refToScreenX
(
10.0
f
),
refToScreenY
(
5.0
f
)));
painter
.
setBrush
(
Qt
::
NoBrush
);
painter
.
setPen
(
Qt
::
SolidLine
);
painter
.
setPen
(
defaultColor
);
painter
.
drawRoundedRect
(
compassRect
,
2
,
2
);
QString
yawAngle
;
// const float yawDeg = ((values.value("yaw", 0.0f)/M_PI)*180.0f)+180.f;
// HEADING INDICATOR
//
// __ __
// \/\/
//
const
float
hIndicatorWidth
=
7.0
f
;
const
float
hIndicatorY
=
-
25.0
f
;
const
float
hIndicatorYLow
=
hIndicatorY
+
hIndicatorWidth
/
6.0
f
;
const
float
hIndicatorSegmentWidth
=
hIndicatorWidth
/
7.0
f
;
QPolygon
hIndicator
(
7
);
hIndicator
.
setPoint
(
0
,
QPoint
(
refToScreenX
(
0.0
f
-
hIndicatorWidth
/
2.0
f
),
refToScreenY
(
hIndicatorY
)));
hIndicator
.
setPoint
(
1
,
QPoint
(
refToScreenX
(
0.0
f
-
hIndicatorWidth
/
2.0
f
+
hIndicatorSegmentWidth
*
1.75
f
),
refToScreenY
(
hIndicatorY
)));
hIndicator
.
setPoint
(
2
,
QPoint
(
refToScreenX
(
0.0
f
-
hIndicatorSegmentWidth
*
1.0
f
),
refToScreenY
(
hIndicatorYLow
)));
hIndicator
.
setPoint
(
3
,
QPoint
(
refToScreenX
(
0.0
f
),
refToScreenY
(
hIndicatorY
)));
hIndicator
.
setPoint
(
4
,
QPoint
(
refToScreenX
(
0.0
f
+
hIndicatorSegmentWidth
*
1.0
f
),
refToScreenY
(
hIndicatorYLow
)));
hIndicator
.
setPoint
(
5
,
QPoint
(
refToScreenX
(
0.0
f
+
hIndicatorWidth
/
2.0
f
-
hIndicatorSegmentWidth
*
1.75
f
),
refToScreenY
(
hIndicatorY
)));
hIndicator
.
setPoint
(
6
,
QPoint
(
refToScreenX
(
0.0
f
+
hIndicatorWidth
/
2.0
f
),
refToScreenY
(
hIndicatorY
)));
painter
.
setPen
(
defaultColor
);
painter
.
drawPolyline
(
hIndicator
);
// YAW is in compass-human readable format, so 0 - 360deg. This is normal in aviation, not -180 - +180.
const
float
yawDeg
=
((
yawLP
/
M_PI
)
*
180.0
f
)
+
180.0
f
;
yawAngle
.
sprintf
(
"%03d"
,
(
int
)
yawDeg
);
paintText
(
yawAngle
,
defaultColor
,
3.5
f
,
-
3.7
f
,
compassY
+
0.9
f
,
&
painter
);
// CHANGE RATE STRIPS
// SETPOINT
drawChangeRateStrip
(
-
51.0
f
,
-
50.0
f
,
15.0
f
,
-
1.0
f
,
1.0
f
,
-
zSpeed
,
&
painter
);
const
float
centerWidth
=
4.0
f
;
painter
.
setPen
(
defaultColor
);
painter
.
setBrush
(
Qt
::
NoBrush
);
// TODO
//painter.drawEllipse(QPointF(refToScreenX(qMin(10.0f, values.value("roll desired", 0.0f) * 10.0f)), refToScreenY(qMin(10.0f, values.value("pitch desired", 0.0f) * 10.0f))), refToScreenX(centerWidth/2.0f), refToScreenX(centerWidth/2.0f));
// CHANGE RATE STRIPS
const
float
centerCrossWidth
=
10.0
f
;
drawChangeRateStrip
(
49.0
f
,
-
50.0
f
,
15.0
f
,
-
1.0
f
,
1.0
f
,
xSpeed
,
&
painter
);
// left
painter
.
drawLine
(
QPointF
(
refToScreenX
(
-
centerWidth
/
2.0
f
),
refToScreenY
(
0.0
f
)),
QPointF
(
refToScreenX
(
-
centerCrossWidth
/
2.0
f
),
refToScreenY
(
0.0
f
)));
// right
painter
.
drawLine
(
QPointF
(
refToScreenX
(
centerWidth
/
2.0
f
),
refToScreenY
(
0.0
f
)),
QPointF
(
refToScreenX
(
centerCrossWidth
/
2.0
f
),
refToScreenY
(
0.0
f
)));
// top
painter
.
drawLine
(
QPointF
(
refToScreenX
(
0.0
f
),
refToScreenY
(
-
centerWidth
/
2.0
f
)),
QPointF
(
refToScreenX
(
0.0
f
),
refToScreenY
(
-
centerCrossWidth
/
2.0
f
)));
// GAUGES
// Left altitude gauge
drawChangeIndicatorGauge
(
-
vGaugeSpacing
,
-
15.0
f
,
10.0
f
,
2.0
f
,
-
zPos
,
defaultColor
,
&
painter
,
false
);
// Right speed gauge
// COMPASS
drawChangeIndicatorGauge
(
vGaugeSpacing
,
-
15.0
f
,
10.0
f
,
5.0
f
,
xSpeed
,
defaultColor
,
&
painter
,
false
);
const
float
compassY
=
-
vheight
/
2.0
f
+
10.0
f
;
QRectF
compassRect
(
QPointF
(
refToScreenX
(
-
5.0
f
),
refToScreenY
(
compassY
)),
QSizeF
(
refToScreenX
(
10.0
f
),
refToScreenY
(
5.0
f
)));
painter
.
setBrush
(
Qt
::
NoBrush
);
painter
.
setPen
(
Qt
::
SolidLine
);
painter
.
setPen
(
defaultColor
);
painter
.
drawRoundedRect
(
compassRect
,
2
,
2
);
QString
yawAngle
;
// const float yawDeg = ((values.value("yaw", 0.0f)/M_PI)*180.0f)+180.f;
// Waypoint name
// YAW is in compass-human readable format, so 0 - 360deg. This is normal in aviation, not -180 - +180.
if
(
waypointName
!=
""
)
paintText
(
waypointName
,
defaultColor
,
2.0
f
,
(
-
vwidth
/
3.0
)
+
10
,
+
vheight
/
3.0
+
15
,
&
painter
);
const
float
yawDeg
=
((
yawLP
/
M_PI
)
*
180.0
f
)
+
180.0
f
;
yawAngle
.
sprintf
(
"%03d"
,
(
int
)
yawDeg
);
paintText
(
yawAngle
,
defaultColor
,
3.5
f
,
-
3.7
f
,
compassY
+
0.9
f
,
&
painter
);
// MOVING PARTS
// CHANGE RATE STRIPS
drawChangeRateStrip
(
-
51.0
f
,
-
50.0
f
,
15.0
f
,
-
1.0
f
,
1.0
f
,
-
zSpeed
,
&
painter
);
// CHANGE RATE STRIPS
drawChangeRateStrip
(
49.0
f
,
-
50.0
f
,
15.0
f
,
-
1.0
f
,
1.0
f
,
xSpeed
,
&
painter
);
// GAUGES
painter
.
translate
(
refToScreenX
(
yawTrans
),
0
);
// Left altitude gauge
drawChangeIndicatorGauge
(
-
vGaugeSpacing
,
-
15.0
f
,
10.0
f
,
2.0
f
,
-
zPos
,
defaultColor
,
&
painter
,
false
);
// Rotate view and draw all roll-dependent indicators
// Right speed gauge
painter
.
rotate
((
rollLP
/
M_PI
)
*
-
180.0
f
);
drawChangeIndicatorGauge
(
vGaugeSpacing
,
-
15.0
f
,
10.0
f
,
5.0
f
,
xSpeed
,
defaultColor
,
&
painter
,
false
);
painter
.
translate
(
0
,
(
-
pitchLP
/
M_PI
)
*
-
180.0
f
*
refToScreenY
(
1.8
));
//qDebug() << "ROLL" << roll << "PITCH" << pitch << "YAW DIFF" << valuesDot.value("roll", 0.0f);
// Waypoint name
if
(
waypointName
!=
""
)
paintText
(
waypointName
,
defaultColor
,
2.0
f
,
(
-
vwidth
/
3.0
)
+
10
,
+
vheight
/
3.0
+
15
,
&
painter
);
// MOVING PARTS
painter
.
translate
(
refToScreenX
(
yawTrans
),
0
);
// Rotate view and draw all roll-dependent indicators
painter
.
rotate
((
rollLP
/
M_PI
)
*
-
180.0
f
);
painter
.
translate
(
0
,
(
-
pitchLP
/
M_PI
)
*
-
180.0
f
*
refToScreenY
(
1.8
));
// PITCH
//qDebug() << "ROLL" << roll << "PITCH" << pitch << "YAW DIFF" << valuesDot.value("roll", 0.0f);
// PITCH
paintPitchLines
(
pitchLP
,
&
painter
);
paintPitchLines
(
pitchLP
,
&
painter
);
painter
.
end
();
painter
.
end
();
//glDisable(GL_MULTISAMPLE);
//glDisable(GL_MULTISAMPLE);
//glFlush();
//glFlush();
}
}
}
/*
/*
...
...
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