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
84badf33
Commit
84badf33
authored
Jun 19, 2013
by
dongfang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PFD crash on start bugfix and rename to .cc
parent
e0d9b8fb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
182 additions
and
272 deletions
+182
-272
qgroundcontrol.pro
qgroundcontrol.pro
+1
-1
PrimaryFlightDisplay.cc
src/ui/PrimaryFlightDisplay.cc
+173
-261
PrimaryFlightDisplay.h
src/ui/PrimaryFlightDisplay.h
+8
-10
No files found.
qgroundcontrol.pro
View file @
84badf33
...
@@ -568,7 +568,7 @@ SOURCES += src/main.cc \
...
@@ -568,7 +568,7 @@ SOURCES += src/main.cc \
src
/
ui
/
designer
/
QGCRadioChannelDisplay
.
cpp
\
src
/
ui
/
designer
/
QGCRadioChannelDisplay
.
cpp
\
src
/
ui
/
QGCTabbedInfoView
.
cpp
\
src
/
ui
/
QGCTabbedInfoView
.
cpp
\
src
/
ui
/
UASRawStatusView
.
cpp
\
src
/
ui
/
UASRawStatusView
.
cpp
\
src
/
ui
/
PrimaryFlightDisplay
.
c
pp
\
src
/
ui
/
PrimaryFlightDisplay
.
c
c
\
src
/
ui
/
uas
/
QGCMessageView
.
cc
src
/
ui
/
uas
/
QGCMessageView
.
cc
#
Enable
Google
Earth
only
on
Mac
OS
and
Windows
with
Visual
Studio
compiler
#
Enable
Google
Earth
only
on
Mac
OS
and
Windows
with
Visual
Studio
compiler
...
...
src/ui/PrimaryFlightDisplay.c
pp
→
src/ui/PrimaryFlightDisplay.c
c
View file @
84badf33
...
@@ -12,97 +12,84 @@
...
@@ -12,97 +12,84 @@
#include <QtCore/qmath.h>
#include <QtCore/qmath.h>
//#include <cmath>
//#include <cmath>
#define SEPARATE_COMPASS_ASPECTRATIO (3.0f/4.0f)
static
const
float
SEPARATE_COMPASS_ASPECTRATIO
=
3.0
f
/
4.0
f
;
static
const
float
LINEWIDTH
=
0.0036
f
;
static
const
float
SMALL_TEXT_SIZE
=
0.028
f
;
static
const
float
MEDIUM_TEXT_SIZE
=
SMALL_TEXT_SIZE
*
1.2
f
;
static
const
float
LARGE_TEXT_SIZE
=
MEDIUM_TEXT_SIZE
*
1.2
f
;
#define LINEWIDTH 0.0036f
static
const
bool
SHOW_ZERO_ON_SCALES
=
true
;
//#define TAPES_TEXT_SIZE 0.028
//#define AI_TEXT_SIZE 0.040
//#define AI_TEXT_MIN_PIXELS 12
//#define AI_TEXT_MAX_PIXELS 36
//#define PANELS_TEXT_SIZE 0.030
//#define COMPASS_SCALE_TEXT_SIZE 0.16
#define SMALL_TEXT_SIZE 0.03f
#define MEDIUM_TEXT_SIZE (SMALL_TEXT_SIZE*1.2f)
#define LARGE_TEXT_SIZE (MEDIUM_TEXT_SIZE*1.2f)
#define SHOW_ZERO_ON_SCALES true
// all in units of display height
// all in units of display height
#define ROLL_SCALE_RADIUS 0.42f
static
const
float
ROLL_SCALE_RADIUS
=
0.42
f
;
#define ROLL_SCALE_TICKMARKLENGTH 0.04f
static
const
float
ROLL_SCALE_TICKMARKLENGTH
=
0.04
f
;
#define ROLL_SCALE_MARKERWIDTH 0.06f
static
const
float
ROLL_SCALE_MARKERWIDTH
=
0.06
f
;
#define ROLL_SCALE_MARKERHEIGHT 0.04f
static
const
float
ROLL_SCALE_MARKERHEIGHT
=
0.04
f
;
// scale max. degrees
// scale max. degrees
#define ROLL_SCALE_RANGE 60
static
const
int
ROLL_SCALE_RANGE
=
60
;
// fraction of height to translate for each degree of pitch.
// fraction of height to translate for each degree of pitch.
#define PITCHTRANSLATION 65.0
static
const
float
PITCHTRANSLATION
=
65
;
//
10
degrees for each line
//
5
degrees for each line
#define PITCH_SCALE_RESOLUTION 5
static
const
int
PITCH_SCALE_RESOLUTION
=
5
;
#define PITCH_SCALE_MAJORWIDTH 0.1
static
const
float
PITCH_SCALE_MAJORWIDTH
=
0.1
f
;
#define PITCH_SCALE_MINORWIDTH 0.066
static
const
float
PITCH_SCALE_MINORWIDTH
=
0.066
;
// Beginning from PITCH_SCALE_WIDTHREDUCTION_FROM degrees of +/- pitch, the
// Beginning from PITCH_SCALE_WIDTHREDUCTION_FROM degrees of +/- pitch, the
// width of the lines is reduced, down to PITCH_SCALE_WIDTHREDUCTION times
// width of the lines is reduced, down to PITCH_SCALE_WIDTHREDUCTION times
// the normal width. This helps keep orientation in extreme attitudes.
// the normal width. This helps keep orientation in extreme attitudes.
#define PITCH_SCALE_WIDTHREDUCTION_FROM 30
static
const
int
PITCH_SCALE_WIDTHREDUCTION_FROM
=
30
;
#define PITCH_SCALE_WIDTHREDUCTION 0.3
static
const
float
PITCH_SCALE_WIDTHREDUCTION
=
0.3
f
;
#define PITCH_SCALE_HALFRANGE 15
static
const
int
PITCH_SCALE_HALFRANGE
=
15
;
// The number of degrees to either side of the heading to draw the compass disk.
// The number of degrees to either side of the heading to draw the compass disk.
// 180 is valid, this will draw a complete disk. If the disk is partly clipped
// 180 is valid, this will draw a complete disk. If the disk is partly clipped
// away, less will do.
// away, less will do.
#define COMPASS_DISK_MAJORTICK 10
static
const
int
COMPASS_DISK_MAJORTICK
=
10
;
#define COMPASS_DISK_ARROWTICK 45
static
const
int
COMPASS_DISK_ARROWTICK
=
45
;
#define COMPASS_DISK_MAJORLINEWIDTH 0.006
static
const
float
COMPASS_DISK_MAJORLINEWIDTH
=
0.006
;
#define COMPASS_DISK_MINORLINEWIDTH 0.004
static
const
float
COMPASS_DISK_MINORLINEWIDTH
=
0.004
;
#define COMPASS_DISK_RESOLUTION 10
static
const
int
COMPASS_DISK_RESOLUTION
=
10
;
#define COMPASS_SEPARATE_DISK_RESOLUTION 5
static
const
float
COMPASS_SEPARATE_DISK_RESOLUTION
=
5
;
#define COMPASS_DISK_MARKERWIDTH 0.2
static
const
float
COMPASS_DISK_MARKERWIDTH
=
0.2
;
#define COMPASS_DISK_MARKERHEIGHT 0.133
static
const
float
COMPASS_DISK_MARKERHEIGHT
=
0.133
;
#define CROSSTRACK_MAX 1000
static
const
int
CROSSTRACK_MAX
=
1000
;
#define CROSSTRACK_RADIUS 0.6
static
const
float
CROSSTRACK_RADIUS
=
0.6
;
#define TAPE_GAUGES_TICKWIDTH_MAJOR 0.25
static
const
float
TAPE_GAUGES_TICKWIDTH_MAJOR
=
0.25
;
#define TAPE_GAUGES_TICKWIDTH_MINOR 0.15
static
const
float
TAPE_GAUGES_TICKWIDTH_MINOR
=
0.15
;
// The altitude difference between top and bottom of scale
// The altitude difference between top and bottom of scale
#define ALTIMETER_LINEAR_SPAN 50
static
const
int
ALTIMETER_LINEAR_SPAN
=
50
;
// every 5 meters there is a tick mark
// every 5 meters there is a tick mark
#define ALTIMETER_LINEAR_RESOLUTION 5
static
const
int
ALTIMETER_LINEAR_RESOLUTION
=
5
;
// every 10 meters there is a number
// every 10 meters there is a number
#define ALTIMETER_LINEAR_MAJOR_RESOLUTION 10
static
const
int
ALTIMETER_LINEAR_MAJOR_RESOLUTION
=
10
;
// Projected: An experiment. Make tape appear projected from a cylinder, like a French "drum" style gauge.
// Projected: An experiment. Make tape appear projected from a cylinder, like a French "drum" style gauge.
// The altitude difference between top and bottom of scale
// The altitude difference between top and bottom of scale
#define ALTIMETER_PROJECTED_SPAN 50
static
const
int
ALTIMETER_PROJECTED_SPAN
=
50
;
// every 5 meters there is a tick mark
// every 5 meters there is a tick mark
#define ALTIMETER_PROJECTED_RESOLUTION 5
static
const
int
ALTIMETER_PROJECTED_RESOLUTION
=
5
;
// every 10 meters there is a number
// every 10 meters there is a number
#define ALTIMETER_PROJECTED_MAJOR_RESOLUTION 10
static
const
int
ALTIMETER_PROJECTED_MAJOR_RESOLUTION
=
10
;
// min. and max. vertical velocity
// min. and max. vertical velocity
//#define ALTIMETER_PROJECTED
// min. and max. vertical velocity
// min. and max. vertical velocity
#define ALTIMETER_VVI_SPAN 5
static
const
int
ALTIMETER_VVI_SPAN
=
5
;
#define ALTIMETER_VVI_WIDTH 0.2
static
const
float
ALTIMETER_VVI_WIDTH
=
0.2
f
;
// Now the same thing for airspeed!
// Now the same thing for airspeed!
#define AIRSPEED_LINEAR_SPAN 15
static
const
int
AIRSPEED_LINEAR_SPAN
=
15
;
#define AIRSPEED_LINEAR_RESOLUTION 1
static
const
int
AIRSPEED_LINEAR_RESOLUTION
=
1
;
#define AIRSPEED_LINEAR_MAJOR_RESOLUTION 5
static
const
int
AIRSPEED_LINEAR_MAJOR_RESOLUTION
=
5
;
#define UNKNOWN_BATTERY -1
static
const
int
UNKNOWN_ATTITUDE
=
-
1000
;
#define UNKNOWN_ATTITUDE 0
static
const
int
UNKNOWN_ALTITUDE
=
-
1000
;
#define UNKNOWN_ALTITUDE -1000
static
const
int
UNKNOWN_SPEED
=
-
1
;
#define UNKNOWN_SPEED -1
#define UNKNOWN_COUNT -1
#define UNKNOWN_GPSFIXTYPE -1
/*
/*
*@TODO:
*@TODO:
...
@@ -115,6 +102,12 @@ double PrimaryFlightDisplay_round(double value, int digits=0)
...
@@ -115,6 +102,12 @@ double PrimaryFlightDisplay_round(double value, int digits=0)
return
floor
(
value
*
pow
(
10
,
digits
)
+
0.5
)
/
pow
(
10
,
digits
);
return
floor
(
value
*
pow
(
10
,
digits
)
+
0.5
)
/
pow
(
10
,
digits
);
}
}
qreal
PrimaryFlightDisplay_constrain
(
qreal
value
,
qreal
min
,
qreal
max
)
{
if
(
value
<
min
)
value
=
min
;
else
if
(
value
>
max
)
value
=
max
;
return
value
;
}
const
int
PrimaryFlightDisplay
::
tickValues
[]
=
{
10
,
20
,
30
,
45
,
60
};
const
int
PrimaryFlightDisplay
::
tickValues
[]
=
{
10
,
20
,
30
,
45
,
60
};
const
QString
PrimaryFlightDisplay
::
compassWindNames
[]
=
{
const
QString
PrimaryFlightDisplay
::
compassWindNames
[]
=
{
QString
(
"N"
),
QString
(
"N"
),
...
@@ -132,24 +125,24 @@ PrimaryFlightDisplay::PrimaryFlightDisplay(int width, int height, QWidget *paren
...
@@ -132,24 +125,24 @@ PrimaryFlightDisplay::PrimaryFlightDisplay(int width, int height, QWidget *paren
uas
(
NULL
),
uas
(
NULL
),
/*
altimeterMode(GPS_MAIN),
altimeterMode(GPS_MAIN),
altimeterFrame(ASL),
altimeterFrame(ASL),
speedMode(GROUND_MAIN),
speedMode(GROUND_MAIN),
*/
roll
(
UNKNOWN_ATTITUDE
),
roll
(
UNKNOWN_ATTITUDE
),
pitch
(
UNKNOWN_ATTITUDE
),
pitch
(
UNKNOWN_ATTITUDE
),
// heading(NAN),
heading
(
UNKNOWN_ATTITUDE
),
heading
(
UNKNOWN_ATTITUDE
),
primaryAltitude
(
UNKNOWN_ALTITUDE
),
primaryAltitude
(
UNKNOWN_ALTITUDE
),
GPSAltitude
(
UNKNOWN_ALTITUDE
),
GPSAltitude
(
UNKNOWN_ALTITUDE
),
aboveHomeAltitude
(
UNKNOWN_ALTITUDE
),
aboveHomeAltitude
(
UNKNOWN_ALTITUDE
),
primarySpeed
(
UNKNOWN_SPEED
),
primarySpeed
(
UNKNOWN_SPEED
),
groundspeed
(
UNKNOWN_SPEED
),
groundspeed
(
UNKNOWN_SPEED
),
verticalVelocity
(
UNKNOWN_ALTITUDE
),
verticalVelocity
(
UNKNOWN_ALTITUDE
),
font
(
"Bitstream Vera Sans"
),
refreshTimer
(
new
QTimer
(
this
)),
navigationCrosstrackError
(
0
),
navigationCrosstrackError
(
0
),
navigationTargetBearing
(
UNKNOWN_ATTITUDE
),
navigationTargetBearing
(
UNKNOWN_ATTITUDE
),
...
@@ -164,11 +157,15 @@ PrimaryFlightDisplay::PrimaryFlightDisplay(int width, int height, QWidget *paren
...
@@ -164,11 +157,15 @@ PrimaryFlightDisplay::PrimaryFlightDisplay(int width, int height, QWidget *paren
fineLineWidth
(
1
),
fineLineWidth
(
1
),
instrumentEdgePen
(
QColor
::
fromHsvF
(
0
,
0
,
0.65
,
0.5
)),
instrumentEdgePen
(
QColor
::
fromHsvF
(
0
,
0
,
0.65
,
0.5
)),
// AIEdgePen(QColor::fromHsvF(0, 0, 0.65, 0.5)),
instrumentBackground
(
QColor
::
fromHsvF
(
0
,
0
,
0.3
,
0.3
)),
instrumentBackground
(
QColor
::
fromHsvF
(
0
,
0
,
0.3
,
0.3
)),
instrumentOpagueBackground
(
QColor
::
fromHsvF
(
0
,
0
,
0.3
,
1.0
))
instrumentOpagueBackground
(
QColor
::
fromHsvF
(
0
,
0
,
0.3
,
1.0
)),
font
(
"Bitstream Vera Sans"
),
refreshTimer
(
new
QTimer
(
this
))
{
{
Q_UNUSED
(
width
)
Q_UNUSED
(
height
)
setMinimumSize
(
120
,
80
);
setMinimumSize
(
120
,
80
);
setSizePolicy
(
QSizePolicy
::
Expanding
,
QSizePolicy
::
Expanding
);
setSizePolicy
(
QSizePolicy
::
Expanding
,
QSizePolicy
::
Expanding
);
...
@@ -211,25 +208,19 @@ void PrimaryFlightDisplay::hideEvent(QHideEvent* event)
...
@@ -211,25 +208,19 @@ void PrimaryFlightDisplay::hideEvent(QHideEvent* event)
emit
visibilityChanged
(
false
);
emit
visibilityChanged
(
false
);
}
}
qreal
constrain
(
qreal
value
,
qreal
min
,
qreal
max
)
{
if
(
value
<
min
)
value
=
min
;
else
if
(
value
>
max
)
value
=
max
;
return
value
;
}
void
PrimaryFlightDisplay
::
resizeEvent
(
QResizeEvent
*
e
)
{
void
PrimaryFlightDisplay
::
resizeEvent
(
QResizeEvent
*
e
)
{
QWidget
::
resizeEvent
(
e
);
QWidget
::
resizeEvent
(
e
);
qreal
size
=
e
->
size
().
width
();
qreal
size
=
e
->
size
().
width
();
//if(e->size().height()<size) size = e->size().height();
//if(e->size().height()<size) size = e->size().height();
lineWidth
=
constrain
(
size
*
LINEWIDTH
,
1
,
6
);
lineWidth
=
PrimaryFlightDisplay_
constrain
(
size
*
LINEWIDTH
,
1
,
6
);
fineLineWidth
=
constrain
(
size
*
LINEWIDTH
*
2
/
3
,
1
,
2
);
fineLineWidth
=
PrimaryFlightDisplay_
constrain
(
size
*
LINEWIDTH
*
2
/
3
,
1
,
2
);
instrumentEdgePen
.
setWidthF
(
fineLineWidth
);
instrumentEdgePen
.
setWidthF
(
fineLineWidth
);
//AIEdgePen.setWidthF(fineLineWidth);
//AIEdgePen.setWidthF(fineLineWidth);
smallTe
s
tSize
=
size
*
SMALL_TEXT_SIZE
;
smallTe
x
tSize
=
size
*
SMALL_TEXT_SIZE
;
mediumTextSize
=
size
*
MEDIUM_TEXT_SIZE
;
mediumTextSize
=
size
*
MEDIUM_TEXT_SIZE
;
largeTextSize
=
size
*
LARGE_TEXT_SIZE
;
largeTextSize
=
size
*
LARGE_TEXT_SIZE
;
...
@@ -246,11 +237,7 @@ void PrimaryFlightDisplay::resizeEvent(QResizeEvent *e) {
...
@@ -246,11 +237,7 @@ void PrimaryFlightDisplay::resizeEvent(QResizeEvent *e) {
void
PrimaryFlightDisplay
::
paintEvent
(
QPaintEvent
*
event
)
void
PrimaryFlightDisplay
::
paintEvent
(
QPaintEvent
*
event
)
{
{
// Event is not needed
// the event is ignored as this widget
// is refreshed automatically
Q_UNUSED
(
event
);
Q_UNUSED
(
event
);
//makeDummyData();
doPaint
();
doPaint
();
}
}
...
@@ -316,45 +303,34 @@ void PrimaryFlightDisplay::updateAttitude(UASInterface* uas, double roll, double
...
@@ -316,45 +303,34 @@ void PrimaryFlightDisplay::updateAttitude(UASInterface* uas, double roll, double
{
{
Q_UNUSED
(
uas
);
Q_UNUSED
(
uas
);
Q_UNUSED
(
timestamp
);
Q_UNUSED
(
timestamp
);
if
(
!
isnan
(
roll
)
&&
!
isinf
(
roll
)
&&
!
isnan
(
pitch
)
&&
!
isinf
(
pitch
)
&&
!
isnan
(
yaw
)
&&
!
isinf
(
yaw
))
// Called from UAS.cc l. 616
{
if
(
isnan
(
roll
)
||
isinf
(
roll
))
{
// TODO: Units conversion? // Called from UAS.cc l. 646
this
->
roll
=
UNKNOWN_ATTITUDE
;
this
->
roll
=
roll
*
(
180.0
/
M_PI
);
}
else
{
this
->
pitch
=
pitch
*
(
180.0
/
M_PI
);
this
->
roll
=
roll
*
(
180.0
/
M_PI
);
yaw
=
yaw
*
(
180.0
/
M_PI
);
}
if
(
yaw
<
0
)
yaw
+=
360
;
this
->
heading
=
yaw
;
}
// TODO: Else-part. We really should have an "attitude bad or unknown" indication instead of just freezing.
//qDebug("r,p,y: %f,%f,%f", roll, pitch, yaw);
if
(
isnan
(
pitch
)
||
isinf
(
pitch
))
{
this
->
pitch
=
UNKNOWN_ATTITUDE
;
}
else
{
this
->
pitch
=
pitch
*
(
180.0
/
M_PI
);
}
if
(
isnan
(
yaw
)
||
isinf
(
yaw
))
{
this
->
heading
=
UNKNOWN_ATTITUDE
;
}
else
{
yaw
=
yaw
*
(
180.0
/
M_PI
);
if
(
yaw
<
0
)
yaw
+=
360
;
this
->
heading
=
yaw
;
}
}
}
/*
* TODO! Implementation or removal of this.
* Currently a dummy.
*/
void
PrimaryFlightDisplay
::
updateAttitude
(
UASInterface
*
uas
,
int
component
,
double
roll
,
double
pitch
,
double
yaw
,
quint64
timestamp
)
void
PrimaryFlightDisplay
::
updateAttitude
(
UASInterface
*
uas
,
int
component
,
double
roll
,
double
pitch
,
double
yaw
,
quint64
timestamp
)
{
{
Q_UNUSED
(
uas
);
Q_UNUSED
(
component
);
Q_UNUSED
(
component
);
Q_UNUSED
(
timestamp
);
this
->
updateAttitude
(
uas
,
roll
,
pitch
,
yaw
,
timestamp
);
// Called from UAS.cc l. 616
if
(
!
isnan
(
roll
)
&&
!
isinf
(
roll
)
&&
!
isnan
(
pitch
)
&&
!
isinf
(
pitch
)
&&
!
isnan
(
yaw
)
&&
!
isinf
(
yaw
))
{
this
->
roll
=
roll
*
(
180.0
/
M_PI
);
this
->
pitch
=
pitch
*
(
180.0
/
M_PI
);
yaw
=
yaw
*
(
180.0
/
M_PI
);
if
(
yaw
<
0
)
yaw
+=
360
;
this
->
heading
=
yaw
;
}
// qDebug("(2) r,p,y: %f,%f,%f", roll, pitch, yaw);
}
}
/*
* TODO! Examine what data comes with this call, should we consider it airspeed, ground speed or
* should we not consider it at all?
*/
void
PrimaryFlightDisplay
::
updatePrimarySpeed
(
UASInterface
*
uas
,
double
speed
,
quint64
timestamp
)
void
PrimaryFlightDisplay
::
updatePrimarySpeed
(
UASInterface
*
uas
,
double
speed
,
quint64
timestamp
)
{
{
Q_UNUSED
(
uas
);
Q_UNUSED
(
uas
);
...
@@ -529,6 +505,8 @@ void PrimaryFlightDisplay::fillInstrumentOpagueBackground(QPainter& painter, QRe
...
@@ -529,6 +505,8 @@ void PrimaryFlightDisplay::fillInstrumentOpagueBackground(QPainter& painter, QRe
}
}
qreal
pitchAngleToTranslation
(
qreal
viewHeight
,
float
pitch
)
{
qreal
pitchAngleToTranslation
(
qreal
viewHeight
,
float
pitch
)
{
if
(
pitch
==
UNKNOWN_ATTITUDE
)
return
0
;
return
pitch
*
viewHeight
/
PITCHTRANSLATION
;
return
pitch
*
viewHeight
/
PITCHTRANSLATION
;
}
}
...
@@ -588,6 +566,10 @@ void PrimaryFlightDisplay::drawAIGlobalFeatures(
...
@@ -588,6 +566,10 @@ void PrimaryFlightDisplay::drawAIGlobalFeatures(
QRectF
mainArea
,
QRectF
mainArea
,
QRectF
paintArea
)
{
QRectF
paintArea
)
{
float
displayRoll
=
this
->
roll
;
if
(
displayRoll
==
UNKNOWN_ATTITUDE
)
displayRoll
=
0
;
painter
.
resetTransform
();
painter
.
resetTransform
();
painter
.
translate
(
mainArea
.
center
());
painter
.
translate
(
mainArea
.
center
());
...
@@ -599,7 +581,7 @@ void PrimaryFlightDisplay::drawAIGlobalFeatures(
...
@@ -599,7 +581,7 @@ void PrimaryFlightDisplay::drawAIGlobalFeatures(
// QTransform forwardTransform;
// QTransform forwardTransform;
//forwardTransform.translate(mainArea.center().x(), mainArea.center().y());
//forwardTransform.translate(mainArea.center().x(), mainArea.center().y());
painter
.
rotate
(
-
r
oll
);
painter
.
rotate
(
-
displayR
oll
);
painter
.
translate
(
0
,
pitchPixels
);
painter
.
translate
(
0
,
pitchPixels
);
// Calculate the radius of area we need to paint to cover all.
// Calculate the radius of area we need to paint to cover all.
...
@@ -624,7 +606,6 @@ void PrimaryFlightDisplay::drawAIGlobalFeatures(
...
@@ -624,7 +606,6 @@ void PrimaryFlightDisplay::drawAIGlobalFeatures(
skyPath
.
lineTo
(
hzonRight
);
skyPath
.
lineTo
(
hzonRight
);
skyPath
.
closeSubpath
();
skyPath
.
closeSubpath
();
// TODO: The gradient is wrong now.
QLinearGradient
skyGradient
(
0
,
-
gradientEnd
,
0
,
0
);
QLinearGradient
skyGradient
(
0
,
-
gradientEnd
,
0
,
0
);
skyGradient
.
setColorAt
(
0
,
QColor
::
fromHsvF
(
0.6
,
1.0
,
0.7
));
skyGradient
.
setColorAt
(
0
,
QColor
::
fromHsvF
(
0.6
,
1.0
,
0.7
));
skyGradient
.
setColorAt
(
1
,
QColor
::
fromHsvF
(
0.6
,
0.25
,
0.9
));
skyGradient
.
setColorAt
(
1
,
QColor
::
fromHsvF
(
0.6
,
0.25
,
0.9
));
...
@@ -661,6 +642,10 @@ void PrimaryFlightDisplay::drawPitchScale(
...
@@ -661,6 +642,10 @@ void PrimaryFlightDisplay::drawPitchScale(
bool
drawNumbersRight
bool
drawNumbersRight
)
{
)
{
float
displayPitch
=
this
->
pitch
;
if
(
displayPitch
==
UNKNOWN_ATTITUDE
)
displayPitch
=
0
;
// The area should be quadratic but if not width is the major size.
// The area should be quadratic but if not width is the major size.
qreal
w
=
area
.
width
();
qreal
w
=
area
.
width
();
if
(
w
<
area
.
height
())
w
=
area
.
height
();
if
(
w
<
area
.
height
())
w
=
area
.
height
();
...
@@ -673,7 +658,7 @@ void PrimaryFlightDisplay::drawPitchScale(
...
@@ -673,7 +658,7 @@ void PrimaryFlightDisplay::drawPitchScale(
QTransform
savedTransform
=
painter
.
transform
();
QTransform
savedTransform
=
painter
.
transform
();
// find the mark nearest center
// find the mark nearest center
int
snap
=
qRound
((
double
)(
p
itch
/
PITCH_SCALE_RESOLUTION
))
*
PITCH_SCALE_RESOLUTION
;
int
snap
=
qRound
((
double
)(
displayP
itch
/
PITCH_SCALE_RESOLUTION
))
*
PITCH_SCALE_RESOLUTION
;
int
_min
=
snap
-
PITCH_SCALE_HALFRANGE
;
int
_min
=
snap
-
PITCH_SCALE_HALFRANGE
;
int
_max
=
snap
+
PITCH_SCALE_HALFRANGE
;
int
_max
=
snap
+
PITCH_SCALE_HALFRANGE
;
for
(
int
degrees
=
_min
;
degrees
<=
_max
;
degrees
+=
PITCH_SCALE_RESOLUTION
)
{
for
(
int
degrees
=
_min
;
degrees
<=
_max
;
degrees
+=
PITCH_SCALE_RESOLUTION
)
{
...
@@ -691,7 +676,7 @@ void PrimaryFlightDisplay::drawPitchScale(
...
@@ -691,7 +676,7 @@ void PrimaryFlightDisplay::drawPitchScale(
linewidth
*=
(
PITCH_SCALE_WIDTHREDUCTION
*
(
1
-
temp
)
+
temp
);
linewidth
*=
(
PITCH_SCALE_WIDTHREDUCTION
*
(
1
-
temp
)
+
temp
);
}
}
float
shift
=
pitchAngleToTranslation
(
w
,
p
itch
-
degrees
);
float
shift
=
pitchAngleToTranslation
(
w
,
displayP
itch
-
degrees
);
// TODO: Intrusion detection and evasion. That is, don't draw
// TODO: Intrusion detection and evasion. That is, don't draw
// where the compass has intruded.
// where the compass has intruded.
...
@@ -706,8 +691,11 @@ void PrimaryFlightDisplay::drawPitchScale(
...
@@ -706,8 +691,11 @@ void PrimaryFlightDisplay::drawPitchScale(
if
(
displayDegrees
>
90
)
displayDegrees
=
180
-
displayDegrees
;
if
(
displayDegrees
>
90
)
displayDegrees
=
180
-
displayDegrees
;
else
if
(
displayDegrees
<-
90
)
displayDegrees
=
-
180
-
displayDegrees
;
else
if
(
displayDegrees
<-
90
)
displayDegrees
=
-
180
-
displayDegrees
;
if
(
SHOW_ZERO_ON_SCALES
||
degrees
)
{
if
(
SHOW_ZERO_ON_SCALES
||
degrees
)
{
QString
s_number
;
//= QString("%d").arg(degrees);
QString
s_number
;
s_number
.
sprintf
(
"%d"
,
displayDegrees
);
if
(
this
->
pitch
==
UNKNOWN_ATTITUDE
)
s_number
.
sprintf
(
"-"
);
else
s_number
.
sprintf
(
"%d"
,
displayDegrees
);
if
(
drawNumbersLeft
)
drawTextRightCenter
(
painter
,
s_number
,
mediumTextSize
,
-
PITCH_SCALE_MAJORWIDTH
*
w
-
10
,
0
);
if
(
drawNumbersLeft
)
drawTextRightCenter
(
painter
,
s_number
,
mediumTextSize
,
-
PITCH_SCALE_MAJORWIDTH
*
w
-
10
,
0
);
if
(
drawNumbersRight
)
drawTextLeftCenter
(
painter
,
s_number
,
mediumTextSize
,
PITCH_SCALE_MAJORWIDTH
*
w
+
10
,
0
);
if
(
drawNumbersRight
)
drawTextLeftCenter
(
painter
,
s_number
,
mediumTextSize
,
PITCH_SCALE_MAJORWIDTH
*
w
+
10
,
0
);
}
}
...
@@ -770,10 +758,13 @@ void PrimaryFlightDisplay::drawAIAttitudeScales(
...
@@ -770,10 +758,13 @@ void PrimaryFlightDisplay::drawAIAttitudeScales(
QRectF
area
,
QRectF
area
,
float
intrusion
float
intrusion
)
{
)
{
float
displayRoll
=
this
->
roll
;
if
(
displayRoll
==
UNKNOWN_ATTITUDE
)
displayRoll
=
0
;
// To save computations, we do these transformations once for both scales:
// To save computations, we do these transformations once for both scales:
painter
.
resetTransform
();
painter
.
resetTransform
();
painter
.
translate
(
area
.
center
());
painter
.
translate
(
area
.
center
());
painter
.
rotate
(
-
r
oll
);
painter
.
rotate
(
-
displayR
oll
);
QTransform
saved
=
painter
.
transform
();
QTransform
saved
=
painter
.
transform
();
drawRollScale
(
painter
,
area
,
true
,
true
);
drawRollScale
(
painter
,
area
,
true
,
true
);
...
@@ -782,8 +773,12 @@ void PrimaryFlightDisplay::drawAIAttitudeScales(
...
@@ -782,8 +773,12 @@ void PrimaryFlightDisplay::drawAIAttitudeScales(
}
}
void
PrimaryFlightDisplay
::
drawAICompassDisk
(
QPainter
&
painter
,
QRectF
area
,
float
halfspan
)
{
void
PrimaryFlightDisplay
::
drawAICompassDisk
(
QPainter
&
painter
,
QRectF
area
,
float
halfspan
)
{
float
start
=
heading
-
halfspan
;
float
displayHeading
=
this
->
heading
;
float
end
=
heading
+
halfspan
;
if
(
displayHeading
==
UNKNOWN_ATTITUDE
)
displayHeading
=
0
;
float
start
=
displayHeading
-
halfspan
;
float
end
=
displayHeading
+
halfspan
;
int
firstTick
=
ceil
(
start
/
COMPASS_DISK_RESOLUTION
)
*
COMPASS_DISK_RESOLUTION
;
int
firstTick
=
ceil
(
start
/
COMPASS_DISK_RESOLUTION
)
*
COMPASS_DISK_RESOLUTION
;
int
lastTick
=
floor
(
end
/
COMPASS_DISK_RESOLUTION
)
*
COMPASS_DISK_RESOLUTION
;
int
lastTick
=
floor
(
end
/
COMPASS_DISK_RESOLUTION
)
*
COMPASS_DISK_RESOLUTION
;
...
@@ -805,7 +800,7 @@ void PrimaryFlightDisplay::drawAICompassDisk(QPainter& painter, QRectF area, flo
...
@@ -805,7 +800,7 @@ void PrimaryFlightDisplay::drawAICompassDisk(QPainter& painter, QRectF area, flo
else
if
(
displayTick
>=
360
)
displayTick
-=
360
;
else
if
(
displayTick
>=
360
)
displayTick
-=
360
;
// yaw is in center.
// yaw is in center.
float
off
=
tickYaw
-
h
eading
;
float
off
=
tickYaw
-
displayH
eading
;
// wrap that to ]-180..180]
// wrap that to ]-180..180]
if
(
off
<=-
180
)
off
+=
360
;
else
if
(
off
>
180
)
off
-=
360
;
if
(
off
<=-
180
)
off
+=
360
;
else
if
(
off
>
180
)
off
-=
360
;
...
@@ -814,15 +809,18 @@ void PrimaryFlightDisplay::drawAICompassDisk(QPainter& painter, QRectF area, flo
...
@@ -814,15 +809,18 @@ void PrimaryFlightDisplay::drawAICompassDisk(QPainter& painter, QRectF area, flo
bool
drewArrow
=
false
;
bool
drewArrow
=
false
;
bool
isMajor
=
displayTick
%
COMPASS_DISK_MAJORTICK
==
0
;
bool
isMajor
=
displayTick
%
COMPASS_DISK_MAJORTICK
==
0
;
if
(
displayTick
==
30
||
displayTick
==
60
||
// If heading unknown, still draw marks but no numbers.
if
(
this
->
heading
!=
UNKNOWN_ATTITUDE
&&
(
displayTick
==
30
||
displayTick
==
60
||
displayTick
==
120
||
displayTick
==
150
||
displayTick
==
120
||
displayTick
==
150
||
displayTick
==
210
||
displayTick
==
240
||
displayTick
==
210
||
displayTick
==
240
||
displayTick
==
300
||
displayTick
==
330
)
{
displayTick
==
300
||
displayTick
==
330
)
)
{
// draw a number
// draw a number
QString
s_number
;
QString
s_number
;
s_number
.
sprintf
(
"%d"
,
displayTick
/
10
);
s_number
.
sprintf
(
"%d"
,
displayTick
/
10
);
painter
.
setPen
(
scalePen
);
painter
.
setPen
(
scalePen
);
drawTextCenter
(
painter
,
s_number
,
/*COMPASS_SCALE_TEXT_SIZE*radius*/
smallTes
tSize
,
0
,
-
innerRadius
*
0.75
);
drawTextCenter
(
painter
,
s_number
,
smallTex
tSize
,
0
,
-
innerRadius
*
0.75
);
}
else
{
}
else
{
if
(
displayTick
%
COMPASS_DISK_ARROWTICK
==
0
)
{
if
(
displayTick
%
COMPASS_DISK_ARROWTICK
==
0
)
{
if
(
displayTick
!=
0
)
{
if
(
displayTick
!=
0
)
{
...
@@ -836,7 +834,8 @@ void PrimaryFlightDisplay::drawAICompassDisk(QPainter& painter, QRectF area, flo
...
@@ -836,7 +834,8 @@ void PrimaryFlightDisplay::drawAICompassDisk(QPainter& painter, QRectF area, flo
painter
.
setBrush
(
Qt
::
NoBrush
);
painter
.
setBrush
(
Qt
::
NoBrush
);
drewArrow
=
true
;
drewArrow
=
true
;
}
}
if
(
displayTick
%
90
==
0
)
{
// If heading unknown, still draw marks but no N S E W.
if
(
this
->
heading
!=
UNKNOWN_ATTITUDE
&&
displayTick
%
90
==
0
)
{
// Also draw a label
// Also draw a label
QString
name
=
compassWindNames
[
displayTick
/
45
];
QString
name
=
compassWindNames
[
displayTick
/
45
];
painter
.
setPen
(
scalePen
);
painter
.
setPen
(
scalePen
);
...
@@ -875,11 +874,15 @@ void PrimaryFlightDisplay::drawAICompassDisk(QPainter& painter, QRectF area, flo
...
@@ -875,11 +874,15 @@ void PrimaryFlightDisplay::drawAICompassDisk(QPainter& painter, QRectF area, flo
painter
.
setPen
(
instrumentEdgePen
);
painter
.
setPen
(
instrumentEdgePen
);
painter
.
drawRoundedRect
(
digitalCompassRect
,
instrumentEdgePen
.
widthF
()
*
2
/
3
,
instrumentEdgePen
.
widthF
()
*
2
/
3
);
painter
.
drawRoundedRect
(
digitalCompassRect
,
instrumentEdgePen
.
widthF
()
*
2
/
3
,
instrumentEdgePen
.
widthF
()
*
2
/
3
);
/* final safeguard for really stupid systems */
int
digitalCompassValue
=
static_cast
<
int
>
(
qRound
((
double
)
heading
))
%
360
;
QString
s_digitalCompass
;
QString
s_digitalCompass
;
s_digitalCompass
.
sprintf
(
"%03d"
,
digitalCompassValue
);
if
(
this
->
heading
==
UNKNOWN_ATTITUDE
)
s_digitalCompass
.
sprintf
(
"---"
);
else
{
/* final safeguard for really stupid systems */
int
digitalCompassValue
=
static_cast
<
int
>
(
qRound
((
double
)
heading
))
%
360
;
s_digitalCompass
.
sprintf
(
"%03d"
,
digitalCompassValue
);
}
QPen
pen
;
QPen
pen
;
pen
.
setWidthF
(
lineWidth
);
pen
.
setWidthF
(
lineWidth
);
...
@@ -915,106 +918,15 @@ void PrimaryFlightDisplay::drawAICompassDisk(QPainter& painter, QRectF area, flo
...
@@ -915,106 +918,15 @@ void PrimaryFlightDisplay::drawAICompassDisk(QPainter& painter, QRectF area, flo
QPen
pen
;
QPen
pen
;
pen
.
setWidthF
(
lineWidth
);
pen
.
setWidthF
(
lineWidth
);
pen
.
setColor
(
Qt
::
black
);
pen
.
setColor
(
Qt
::
black
);
if
(
errorBeyondRadius
)
{
pen
.
setStyle
(
Qt
::
DotLine
);
}
painter
.
setPen
(
pen
);
painter
.
setPen
(
pen
);
painter
.
drawLine
(
QPointF
(
x
,
y
),
QPointF
(
x
,
-
y
));
painter
.
drawLine
(
QPointF
(
x
,
y
),
QPointF
(
x
,
-
y
));
}
}
}
}
/*
void PrimaryFlightDisplay::drawSeparateCompassDisk(QPainter& painter, QRectF area) {
float radius = area.width()/2;
float innerRadius = radius * 0.96;
painter.resetTransform();
painter.setBrush(instrumentOpagueBackground);
painter.setPen(instrumentEdgePen);
painter.drawEllipse(area);
painter.setBrush(Qt::NoBrush);
QPen scalePen(Qt::white);
scalePen.setWidthF(fineLineWidth);
for (int displayTick=0; displayTick<360; displayTick+=COMPASS_SEPARATE_DISK_RESOLUTION) {
// yaw is in center.
float off = displayTick - heading;
// wrap that to ]-180..180]
if (off<=-180) off+= 360; else if (off>180) off -= 360;
painter.translate(area.center());
painter.rotate(off);
bool drewArrow = false;
bool isMajor = displayTick % COMPASS_DISK_MAJORTICK == 0;
if (displayTick==30 || displayTick==60 ||
displayTick==120 || displayTick==150 ||
displayTick==210 || displayTick==240 ||
displayTick==300 || displayTick==330) {
// draw a number
QString s_number;
s_number.sprintf("%d", displayTick/10);
painter.setPen(scalePen);
drawTextCenter(painter, s_number, mediumTextSize, 0, -innerRadius*0.75);
} else {
if (displayTick % COMPASS_DISK_ARROWTICK == 0) {
if (displayTick!=0) {
QPainterPath markerPath(QPointF(0, -innerRadius*(1-COMPASS_DISK_MARKERHEIGHT/2)));
markerPath.lineTo(innerRadius*COMPASS_DISK_MARKERWIDTH/4, -innerRadius);
markerPath.lineTo(-innerRadius*COMPASS_DISK_MARKERWIDTH/4, -innerRadius);
markerPath.closeSubpath();
painter.setPen(scalePen);
painter.setBrush(Qt::SolidPattern);
painter.drawPath(markerPath);
painter.setBrush(Qt::NoBrush);
drewArrow = true;
}
if (displayTick%90 == 0) {
// Also draw a label
QString name = compassWindNames[displayTick / 45];
painter.setPen(scalePen);
drawTextCenter(painter, name, mediumTextSize, 0, -innerRadius*0.75);
}
}
}
// draw the scale lines. If an arrow was drawn, stay off from it.
QPointF p_start = drewArrow ? QPoint(0, -innerRadius*0.94) : QPoint(0, -innerRadius);
QPoint p_end = isMajor ? QPoint(0, -innerRadius*0.86) : QPoint(0, -innerRadius*0.90);
painter.setPen(scalePen);
painter.drawLine(p_start, p_end);
painter.resetTransform();
}
painter.setPen(scalePen);
//painter.setBrush(Qt::SolidPattern);
painter.translate(area.center());
QPainterPath markerPath(QPointF(0, -radius-2));
markerPath.lineTo(radius*COMPASS_DISK_MARKERWIDTH/2, -radius-radius*COMPASS_DISK_MARKERHEIGHT-2);
markerPath.lineTo(-radius*COMPASS_DISK_MARKERWIDTH/2, -radius-radius*COMPASS_DISK_MARKERHEIGHT-2);
markerPath.closeSubpath();
painter.drawPath(markerPath);
QRectF headingNumberRect(-radius/3, radius*0.12, radius*2/3, radius*0.28);
painter.setPen(instrumentEdgePen);
painter.drawRoundedRect(headingNumberRect, instrumentEdgePen.widthF()*2/3, instrumentEdgePen.widthF()*2/3);
// if (heading < 0) heading += 360;
// else if (heading >= 360) heading -= 360;
int yawCompass = static_cast<int>(heading) % 360;
QString yawAngle;
yawAngle.sprintf("%03d", yawCompass);
QPen pen;
pen.setWidthF(lineWidth);
pen.setColor(Qt::white);
painter.setPen(pen);
drawTextCenter(painter, yawAngle, largeTextSize, 0, radius/4);
}
*/
void
PrimaryFlightDisplay
::
drawAltimeter
(
void
PrimaryFlightDisplay
::
drawAltimeter
(
QPainter
&
painter
,
QPainter
&
painter
,
QRectF
area
,
// the area where to draw the tape.
QRectF
area
,
// the area where to draw the tape.
...
@@ -1039,8 +951,9 @@ void PrimaryFlightDisplay::drawAltimeter(
...
@@ -1039,8 +951,9 @@ void PrimaryFlightDisplay::drawAltimeter(
float
effectiveHalfHeight
=
h
*
0.45
;
float
effectiveHalfHeight
=
h
*
0.45
;
// not yet implemented: Display of secondary altitude.
// not yet implemented: Display of secondary altitude.
// if (isAirplane())
if
(
secondaryAltitude
!=
UNKNOWN_ALTITUDE
)
{
// effectiveHalfHeight-= secondaryAltitudeBoxHeight;
effectiveHalfHeight
-=
secondaryAltitudeBoxHeight
;
}
float
markerHalfHeight
=
mediumTextSize
*
0.8
;
float
markerHalfHeight
=
mediumTextSize
*
0.8
;
float
leftEdge
=
instrumentEdgePen
.
widthF
()
*
2
;
float
leftEdge
=
instrumentEdgePen
.
widthF
()
*
2
;
...
@@ -1053,20 +966,6 @@ void PrimaryFlightDisplay::drawAltimeter(
...
@@ -1053,20 +966,6 @@ void PrimaryFlightDisplay::drawAltimeter(
float
scaleCenterAltitude
=
primaryAltitude
==
UNKNOWN_ALTITUDE
?
0
:
primaryAltitude
;
float
scaleCenterAltitude
=
primaryAltitude
==
UNKNOWN_ALTITUDE
?
0
:
primaryAltitude
;
// altitude scale
// altitude scale
#ifdef ALTIMETER_PROJECTED
float
range
=
1.2
;
float
start
=
scaleCenterAltitude
-
ALTIMETER_PROJECTED_SPAN
/
2
;
float
end
=
scaleCenterAltitude
+
ALTIMETER_PROJECTED_SPAN
/
2
;
int
firstTick
=
ceil
(
start
/
ALTIMETER_PROJECTED_RESOLUTION
)
*
ALTIMETER_PROJECTED_RESOLUTION
;
int
lastTick
=
floor
(
end
/
ALTIMETER_PROJECTED_RESOLUTION
)
*
ALTIMETER_PROJECTED_RESOLUTION
;
for
(
int
tickAlt
=
firstTick
;
tickAlt
<=
lastTick
;
tickAlt
+=
ALTIMETER_PROJECTED_RESOLUTION
)
{
// a number between 0 and 1. Use as radians directly.
float
r
=
range
*
(
tickAlt
-
altitude
)
/
(
ALTIMETER_PROJECTED_SPAN
/
2
);
float
y
=
effectiveHalfHeight
*
sin
(
r
);
scale
=
cos
(
r
);
if
(
scale
<
0
)
scale
=
-
scale
;
bool
hasText
=
tickAlt
%
ALTIMETER_PROJECTED_MAJOR_RESOLUTION
==
0
;
#else
float
start
=
scaleCenterAltitude
-
ALTIMETER_LINEAR_SPAN
/
2
;
float
start
=
scaleCenterAltitude
-
ALTIMETER_LINEAR_SPAN
/
2
;
float
end
=
scaleCenterAltitude
+
ALTIMETER_LINEAR_SPAN
/
2
;
float
end
=
scaleCenterAltitude
+
ALTIMETER_LINEAR_SPAN
/
2
;
int
firstTick
=
ceil
(
start
/
ALTIMETER_LINEAR_RESOLUTION
)
*
ALTIMETER_LINEAR_RESOLUTION
;
int
firstTick
=
ceil
(
start
/
ALTIMETER_LINEAR_RESOLUTION
)
*
ALTIMETER_LINEAR_RESOLUTION
;
...
@@ -1074,7 +973,7 @@ void PrimaryFlightDisplay::drawAltimeter(
...
@@ -1074,7 +973,7 @@ void PrimaryFlightDisplay::drawAltimeter(
for
(
int
tickAlt
=
firstTick
;
tickAlt
<=
lastTick
;
tickAlt
+=
ALTIMETER_LINEAR_RESOLUTION
)
{
for
(
int
tickAlt
=
firstTick
;
tickAlt
<=
lastTick
;
tickAlt
+=
ALTIMETER_LINEAR_RESOLUTION
)
{
float
y
=
(
tickAlt
-
scaleCenterAltitude
)
*
effectiveHalfHeight
/
(
ALTIMETER_LINEAR_SPAN
/
2
);
float
y
=
(
tickAlt
-
scaleCenterAltitude
)
*
effectiveHalfHeight
/
(
ALTIMETER_LINEAR_SPAN
/
2
);
bool
isMajor
=
tickAlt
%
ALTIMETER_LINEAR_MAJOR_RESOLUTION
==
0
;
bool
isMajor
=
tickAlt
%
ALTIMETER_LINEAR_MAJOR_RESOLUTION
==
0
;
#endif
painter
.
resetTransform
();
painter
.
resetTransform
();
painter
.
translate
(
area
.
left
(),
area
.
center
().
y
()
-
y
);
painter
.
translate
(
area
.
left
(),
area
.
center
().
y
()
-
y
);
pen
.
setColor
(
tickAlt
<
0
?
redColor
:
Qt
::
white
);
pen
.
setColor
(
tickAlt
<
0
?
redColor
:
Qt
::
white
);
...
@@ -1117,9 +1016,10 @@ void PrimaryFlightDisplay::drawAltimeter(
...
@@ -1117,9 +1016,10 @@ void PrimaryFlightDisplay::drawAltimeter(
s_alt
.
sprintf
(
"%3.0f"
,
primaryAltitude
);
s_alt
.
sprintf
(
"%3.0f"
,
primaryAltitude
);
float
xCenter
=
(
markerTip
+
rightEdge
)
/
2
;
float
xCenter
=
(
markerTip
+
rightEdge
)
/
2
;
drawTextCenter
(
painter
,
s_alt
,
/* TAPES_TEXT_SIZE*width()*/
mediumTextSize
,
xCenter
,
0
);
drawTextCenter
(
painter
,
s_alt
,
mediumTextSize
,
xCenter
,
0
);
if
(
vv
==
UNKNOWN_ALTITUDE
)
return
;
// draw simple in-tape VVI.
if
(
vv
!=
UNKNOWN_ALTITUDE
)
{
float
vvPixHeight
=
-
vv
/
ALTIMETER_VVI_SPAN
*
effectiveHalfHeight
;
float
vvPixHeight
=
-
vv
/
ALTIMETER_VVI_SPAN
*
effectiveHalfHeight
;
if
(
abs
(
vvPixHeight
)
<
markerHalfHeight
)
return
;
// hidden behind marker.
if
(
abs
(
vvPixHeight
)
<
markerHalfHeight
)
return
;
// hidden behind marker.
...
@@ -1141,6 +1041,19 @@ void PrimaryFlightDisplay::drawAltimeter(
...
@@ -1141,6 +1041,19 @@ void PrimaryFlightDisplay::drawAltimeter(
vvArrowHead
=
QPointF
(
xcenter
-
vvArowHeadSize
,
vvPixHeight
-
vvSign
*
vvArowHeadSize
);
vvArrowHead
=
QPointF
(
xcenter
-
vvArowHeadSize
,
vvPixHeight
-
vvSign
*
vvArowHeadSize
);
painter
.
drawLine
(
vvArrowHead
,
vvArrowEnd
);
painter
.
drawLine
(
vvArrowHead
,
vvArrowEnd
);
}
// print secondary altitude
if
(
secondaryAltitude
!=
UNKNOWN_ALTITUDE
)
{
QRectF
saBox
(
area
.
x
(),
area
.
y
()
-
secondaryAltitudeBoxHeight
,
w
,
secondaryAltitudeBoxHeight
);
painter
.
resetTransform
();
painter
.
translate
(
saBox
.
center
());
QString
s_salt
;
s_salt
.
sprintf
(
"%3.0f"
,
secondaryAltitude
);
drawTextCenter
(
painter
,
s_salt
,
mediumTextSize
,
0
,
0
);
}
// print target altitude (if applicable)
}
}
void
PrimaryFlightDisplay
::
drawVelocityMeter
(
void
PrimaryFlightDisplay
::
drawVelocityMeter
(
...
@@ -1226,16 +1139,15 @@ void PrimaryFlightDisplay::drawVelocityMeter(
...
@@ -1226,16 +1139,15 @@ void PrimaryFlightDisplay::drawVelocityMeter(
drawTextCenter
(
painter
,
s_alt
,
/* TAPES_TEXT_SIZE*width()*/
mediumTextSize
,
xCenter
,
0
);
drawTextCenter
(
painter
,
s_alt
,
/* TAPES_TEXT_SIZE*width()*/
mediumTextSize
,
xCenter
,
0
);
}
}
static
const
int
TOP
=
(
1
<<
0
);
static
const
int
BOTTOM
=
(
1
<<
1
);
static
const
int
LEFT
=
(
1
<<
2
);
static
const
int
RIGHT
=
(
1
<<
3
);
#define TOP (1<<0)
static
const
int
TOP_HALF
=
(
1
<<
4
);
#define BOTTOM (1<<1)
static
const
int
BOTTOM_HALF
=
(
1
<<
5
);
#define LEFT (1<<2)
static
const
int
LEFT_HALF
=
(
1
<<
6
);
#define RIGHT (1<<3)
static
const
int
RIGHT_HALF
=
(
1
<<
7
);
#define TOP_2 (1<<4)
#define BOTTOM_2 (1<<5)
#define LEFT_2 (1<<6)
#define RIGHT_2 (1<<7)
void
applyMargin
(
QRectF
&
area
,
float
margin
,
int
where
)
{
void
applyMargin
(
QRectF
&
area
,
float
margin
,
int
where
)
{
if
(
margin
<
0.01
)
return
;
if
(
margin
<
0.01
)
return
;
...
@@ -1245,7 +1157,7 @@ void applyMargin(QRectF& area, float margin, int where) {
...
@@ -1245,7 +1157,7 @@ void applyMargin(QRectF& area, float margin, int where) {
if
(
where
&
LEFT
)
{
if
(
where
&
LEFT
)
{
area
.
setX
(
save
.
x
()
+
(
consumed
=
margin
));
area
.
setX
(
save
.
x
()
+
(
consumed
=
margin
));
}
else
if
(
where
&
LEFT_
2
)
{
}
else
if
(
where
&
LEFT_
HALF
)
{
area
.
setX
(
save
.
x
()
+
(
consumed
=
margin
/
2
));
area
.
setX
(
save
.
x
()
+
(
consumed
=
margin
/
2
));
}
else
{
}
else
{
consumed
=
0
;
consumed
=
0
;
...
@@ -1253,7 +1165,7 @@ void applyMargin(QRectF& area, float margin, int where) {
...
@@ -1253,7 +1165,7 @@ void applyMargin(QRectF& area, float margin, int where) {
if
(
where
&
RIGHT
)
{
if
(
where
&
RIGHT
)
{
area
.
setWidth
(
save
.
width
()
-
consumed
-
margin
);
area
.
setWidth
(
save
.
width
()
-
consumed
-
margin
);
}
else
if
(
where
&
RIGHT_
2
)
{
}
else
if
(
where
&
RIGHT_
HALF
)
{
area
.
setWidth
(
save
.
width
()
-
consumed
-
margin
/
2
);
area
.
setWidth
(
save
.
width
()
-
consumed
-
margin
/
2
);
}
else
{
}
else
{
area
.
setWidth
(
save
.
width
()
-
consumed
);
area
.
setWidth
(
save
.
width
()
-
consumed
);
...
@@ -1261,7 +1173,7 @@ void applyMargin(QRectF& area, float margin, int where) {
...
@@ -1261,7 +1173,7 @@ void applyMargin(QRectF& area, float margin, int where) {
if
(
where
&
TOP
)
{
if
(
where
&
TOP
)
{
area
.
setY
(
save
.
y
()
+
(
consumed
=
margin
));
area
.
setY
(
save
.
y
()
+
(
consumed
=
margin
));
}
else
if
(
where
&
TOP_
2
)
{
}
else
if
(
where
&
TOP_
HALF
)
{
area
.
setY
(
save
.
y
()
+
(
consumed
=
margin
/
2
));
area
.
setY
(
save
.
y
()
+
(
consumed
=
margin
/
2
));
}
else
{
}
else
{
consumed
=
0
;
consumed
=
0
;
...
@@ -1269,7 +1181,7 @@ void applyMargin(QRectF& area, float margin, int where) {
...
@@ -1269,7 +1181,7 @@ void applyMargin(QRectF& area, float margin, int where) {
if
(
where
&
BOTTOM
)
{
if
(
where
&
BOTTOM
)
{
area
.
setHeight
(
save
.
height
()
-
consumed
-
margin
);
area
.
setHeight
(
save
.
height
()
-
consumed
-
margin
);
}
else
if
(
where
&
BOTTOM_
2
)
{
}
else
if
(
where
&
BOTTOM_
HALF
)
{
area
.
setHeight
(
save
.
height
()
-
consumed
-
margin
/
2
);
area
.
setHeight
(
save
.
height
()
-
consumed
-
margin
/
2
);
}
else
{
}
else
{
area
.
setHeight
(
save
.
height
()
-
consumed
);
area
.
setHeight
(
save
.
height
()
-
consumed
);
...
@@ -1277,17 +1189,17 @@ void applyMargin(QRectF& area, float margin, int where) {
...
@@ -1277,17 +1189,17 @@ void applyMargin(QRectF& area, float margin, int where) {
}
}
void
setMarginsForInlineLayout
(
qreal
margin
,
QRectF
&
panel1
,
QRectF
&
panel2
,
QRectF
&
panel3
,
QRectF
&
panel4
)
{
void
setMarginsForInlineLayout
(
qreal
margin
,
QRectF
&
panel1
,
QRectF
&
panel2
,
QRectF
&
panel3
,
QRectF
&
panel4
)
{
applyMargin
(
panel1
,
margin
,
BOTTOM
|
LEFT
|
RIGHT_
2
);
applyMargin
(
panel1
,
margin
,
BOTTOM
|
LEFT
|
RIGHT_
HALF
);
applyMargin
(
panel2
,
margin
,
BOTTOM
|
LEFT_
2
|
RIGHT_2
);
applyMargin
(
panel2
,
margin
,
BOTTOM
|
LEFT_
HALF
|
RIGHT_HALF
);
applyMargin
(
panel3
,
margin
,
BOTTOM
|
LEFT_
2
|
RIGHT_2
);
applyMargin
(
panel3
,
margin
,
BOTTOM
|
LEFT_
HALF
|
RIGHT_HALF
);
applyMargin
(
panel4
,
margin
,
BOTTOM
|
LEFT_
2
|
RIGHT
);
applyMargin
(
panel4
,
margin
,
BOTTOM
|
LEFT_
HALF
|
RIGHT
);
}
}
void
setMarginsForCornerLayout
(
qreal
margin
,
QRectF
&
panel1
,
QRectF
&
panel2
,
QRectF
&
panel3
,
QRectF
&
panel4
)
{
void
setMarginsForCornerLayout
(
qreal
margin
,
QRectF
&
panel1
,
QRectF
&
panel2
,
QRectF
&
panel3
,
QRectF
&
panel4
)
{
applyMargin
(
panel1
,
margin
,
BOTTOM
|
LEFT
|
RIGHT_
2
);
applyMargin
(
panel1
,
margin
,
BOTTOM
|
LEFT
|
RIGHT_
HALF
);
applyMargin
(
panel2
,
margin
,
BOTTOM
|
LEFT_
2
|
RIGHT_2
);
applyMargin
(
panel2
,
margin
,
BOTTOM
|
LEFT_
HALF
|
RIGHT_HALF
);
applyMargin
(
panel3
,
margin
,
BOTTOM
|
LEFT_
2
|
RIGHT_2
);
applyMargin
(
panel3
,
margin
,
BOTTOM
|
LEFT_
HALF
|
RIGHT_HALF
);
applyMargin
(
panel4
,
margin
,
BOTTOM
|
LEFT_
2
|
RIGHT
);
applyMargin
(
panel4
,
margin
,
BOTTOM
|
LEFT_
HALF
|
RIGHT
);
}
}
inline
qreal
tapesGaugeWidthFor
(
qreal
containerWidth
,
qreal
preferredAIWidth
)
{
inline
qreal
tapesGaugeWidthFor
(
qreal
containerWidth
,
qreal
preferredAIWidth
)
{
...
...
src/ui/PrimaryFlightDisplay.h
View file @
84badf33
...
@@ -63,6 +63,7 @@ signals:
...
@@ -63,6 +63,7 @@ signals:
void
visibilityChanged
(
bool
visible
);
void
visibilityChanged
(
bool
visible
);
private:
private:
/*
enum AltimeterMode {
enum AltimeterMode {
PRIMARY_MAIN_GPS_SUB, // Show the primary alt. on tape and GPS as extra info
PRIMARY_MAIN_GPS_SUB, // Show the primary alt. on tape and GPS as extra info
GPS_MAIN // Show GPS on tape and no extra info
GPS_MAIN // Show GPS on tape and no extra info
...
@@ -77,6 +78,7 @@ private:
...
@@ -77,6 +78,7 @@ private:
PRIMARY_MAIN_GROUND_SUB,// Show primary speed (often airspeed) on tape and groundspeed as extra
PRIMARY_MAIN_GROUND_SUB,// Show primary speed (often airspeed) on tape and groundspeed as extra
GROUND_MAIN // Show groundspeed on tape and no extra info
GROUND_MAIN // Show groundspeed on tape and no extra info
};
};
*/
/*
/*
* There are at least these differences between airplane and copter PDF view:
* There are at least these differences between airplane and copter PDF view:
...
@@ -115,9 +117,11 @@ private:
...
@@ -115,9 +117,11 @@ private:
UASInterface
*
uas
;
///< The uas currently monitored
UASInterface
*
uas
;
///< The uas currently monitored
/*
AltimeterMode altimeterMode;
AltimeterMode altimeterMode;
AltimeterFrame altimeterFrame;
AltimeterFrame altimeterFrame;
SpeedMode speedMode;
SpeedMode speedMode;
*/
bool
didReceivePrimaryAltitude
;
bool
didReceivePrimaryAltitude
;
bool
didReceivePrimarySpeed
;
bool
didReceivePrimarySpeed
;
...
@@ -144,9 +148,9 @@ private:
...
@@ -144,9 +148,9 @@ private:
float
navigationTargetBearing
;
float
navigationTargetBearing
;
Layout
layout
;
// The display layout.
Layout
layout
;
// The display layout.
Style
style
;
// The AI style (tapes translusent or opague)
Style
style
;
// The AI style (tapes translucent or opague)
// TODO: Use stylesheet colors?
QColor
redColor
;
QColor
redColor
;
QColor
amberColor
;
QColor
amberColor
;
QColor
greenColor
;
QColor
greenColor
;
...
@@ -154,7 +158,7 @@ private:
...
@@ -154,7 +158,7 @@ private:
qreal
lineWidth
;
qreal
lineWidth
;
qreal
fineLineWidth
;
qreal
fineLineWidth
;
qreal
smallTe
s
tSize
;
qreal
smallTe
x
tSize
;
qreal
mediumTextSize
;
qreal
mediumTextSize
;
qreal
largeTextSize
;
qreal
largeTextSize
;
...
@@ -170,13 +174,7 @@ private:
...
@@ -170,13 +174,7 @@ private:
static
const
int
tickValues
[];
static
const
int
tickValues
[];
static
const
QString
compassWindNames
[];
static
const
QString
compassWindNames
[];
static
const
int
updateInterval
=
40
;
static
const
int
updateInterval
=
40
;
signals:
public
slots
:
};
};
#endif // PRIMARYFLIGHTDISPLAY_H
#endif // PRIMARYFLIGHTDISPLAY_H
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