Commit d7725641 authored by philipoe's avatar philipoe

PrimaryFlightDisplay: Only show secondary labels if they are valid to avoid cluttering of PFD

parent 38d4066d
......@@ -929,6 +929,7 @@ void PrimaryFlightDisplay::drawAltimeter(
float tickmarkRightMinor = tickmarkLeft+TAPE_GAUGES_TICKWIDTH_MINOR*w;
float numbersLeft = 0.42*w;
float markerTip = (tickmarkLeft*2+tickmarkRightMajor)/3;
float markerOffset = 0.2* markerHalfHeight;
float scaleCenterAltitude = isnan(primaryAltitude) ? 0 : primaryAltitude;
// altitude scale
......@@ -954,13 +955,20 @@ void PrimaryFlightDisplay::drawAltimeter(
}
}
QPainterPath markerPath(QPoint(markerTip, 0));
markerPath.lineTo(markerTip+markerHalfHeight, markerHalfHeight);
markerPath.lineTo(markerTip+markerHalfHeight, 2*markerHalfHeight);
markerPath.lineTo(rightEdge, 2*markerHalfHeight);
markerPath.lineTo(rightEdge, -markerHalfHeight);
markerPath.lineTo(markerTip+markerHalfHeight, -markerHalfHeight);
markerPath.closeSubpath();
QPainterPath primaryMarkerPath(QPoint(markerTip, 0));
primaryMarkerPath.lineTo(markerTip + markerHalfHeight, markerHalfHeight);
primaryMarkerPath.lineTo(rightEdge, markerHalfHeight);
primaryMarkerPath.lineTo(rightEdge, -markerHalfHeight);
primaryMarkerPath.lineTo(markerTip + markerHalfHeight, -markerHalfHeight);
primaryMarkerPath.closeSubpath();
QPainterPath secondaryMarkerPath(QPoint(markerTip + markerHalfHeight, markerHalfHeight + markerOffset));
if (!isnan(climbRate)) {
secondaryMarkerPath.lineTo(markerTip + markerHalfHeight, 2 * markerHalfHeight + markerOffset);
secondaryMarkerPath.lineTo(rightEdge, 2 * markerHalfHeight + markerOffset);
secondaryMarkerPath.lineTo(rightEdge, 1 * markerHalfHeight + markerOffset);
secondaryMarkerPath.closeSubpath();
}
painter.resetTransform();
painter.translate(area.left(), area.center().y());
......@@ -970,7 +978,8 @@ void PrimaryFlightDisplay::drawAltimeter(
painter.setPen(pen);
painter.setBrush(Qt::SolidPattern);
painter.drawPath(markerPath);
painter.drawPath(primaryMarkerPath);
if (!isnan(climbRate)) painter.drawPath(secondaryMarkerPath);
painter.setBrush(Qt::NoBrush);
pen.setColor(Qt::white);
......@@ -986,13 +995,19 @@ void PrimaryFlightDisplay::drawAltimeter(
// draw simple in-tape VVI.
if (!isnan(climbRate)) {
// Draw label
QString s_climb;
s_climb.sprintf("vZ:%2.1f", climbRate);
drawTextRightCenter(painter, s_climb, smallTextSize, rightEdge - 4 * lineWidth, 1.5*mediumTextSize + markerOffset);
// Draw climb rate indicator as an arrow
float vvPixHeight = -climbRate/ALTIMETER_VVI_SPAN * effectiveHalfHeight;
if (abs (vvPixHeight) < markerHalfHeight)
return; // hidden behind marker.
float vvSign = vvPixHeight>0 ? 1 : -1; // reverse y sign
QPointF vvArrowBegin(rightEdge - w*ALTIMETER_VVI_WIDTH / 2, (vvSign ? 2*markerHalfHeight:markerHalfHeight));
QPointF vvArrowBegin(rightEdge - w*ALTIMETER_VVI_WIDTH / 2, (vvSign ? 2*markerHalfHeight+markerOffset : markerHalfHeight));
QPointF vvArrowEnd(rightEdge - w*ALTIMETER_VVI_WIDTH/2, vvPixHeight);
painter.drawLine(vvArrowBegin, vvArrowEnd);
......@@ -1007,10 +1022,6 @@ void PrimaryFlightDisplay::drawAltimeter(
vvArrowHead = QPointF(xcenter-vvArowHeadSize, vvPixHeight - vvSign * vvArowHeadSize);
painter.drawLine(vvArrowHead, vvArrowEnd);
QString s_climb;
s_climb.sprintf("vZ:%2.1f", climbRate);
drawTextRightCenter(painter, s_climb, smallTextSize, rightEdge - 4*lineWidth, +mediumTextSize*1.2);
}
// print secondary altitude
......@@ -1039,12 +1050,13 @@ void PrimaryFlightDisplay::drawVelocityMeter(
float w = area.width();
float effectiveHalfHeight = h*0.45;
float markerHalfHeight = mediumTextSize;
float leftEdge = instrumentEdgePen.widthF()*2;
float tickmarkRight = w-leftEdge;
float tickmarkLeftMajor = tickmarkRight-w*TAPE_GAUGES_TICKWIDTH_MAJOR;
float tickmarkLeftMinor = tickmarkRight-w*TAPE_GAUGES_TICKWIDTH_MINOR;
float leftEdge = instrumentEdgePen.widthF() * 2;
float tickmarkRight = w - leftEdge;
float tickmarkLeftMajor = tickmarkRight - w*TAPE_GAUGES_TICKWIDTH_MAJOR;
float tickmarkLeftMinor = tickmarkRight - w*TAPE_GAUGES_TICKWIDTH_MINOR;
float numbersRight = 0.42*w;
float markerTip = (tickmarkLeftMajor+tickmarkRight*2)/3;
float markerTip = (tickmarkLeftMajor + tickmarkRight * 2) / 3;
float markerOffset = 0.2 * markerHalfHeight;
// Select between air and ground speed:
bool bSpeedIsAirspeed = (isAirplane() && !isnan(airSpeed));
......@@ -1052,16 +1064,16 @@ void PrimaryFlightDisplay::drawVelocityMeter(
float secondarySpeed = !bSpeedIsAirspeed ? airSpeed : groundSpeed;
float centerScaleSpeed = isnan(primarySpeed) ? 0 : primarySpeed;
float start = centerScaleSpeed - AIRSPEED_LINEAR_SPAN/2;
float end = centerScaleSpeed + AIRSPEED_LINEAR_SPAN/2;
float start = centerScaleSpeed - AIRSPEED_LINEAR_SPAN / 2;
float end = centerScaleSpeed + AIRSPEED_LINEAR_SPAN / 2;
int firstTick = ceil(start / AIRSPEED_LINEAR_RESOLUTION) * AIRSPEED_LINEAR_RESOLUTION;
int lastTick = floor(end / AIRSPEED_LINEAR_RESOLUTION) * AIRSPEED_LINEAR_RESOLUTION;
for (int tickSpeed = firstTick; tickSpeed <= lastTick; tickSpeed += AIRSPEED_LINEAR_RESOLUTION) {
pen.setColor(tickSpeed<0 ? redColor : Qt::white);
pen.setColor(tickSpeed < 0 ? redColor : Qt::white);
painter.setPen(pen);
float y = (tickSpeed-centerScaleSpeed)*effectiveHalfHeight/(AIRSPEED_LINEAR_SPAN/2);
float y = (tickSpeed - centerScaleSpeed)*effectiveHalfHeight / (AIRSPEED_LINEAR_SPAN / 2);
bool hasText = tickSpeed % AIRSPEED_LINEAR_MAJOR_RESOLUTION == 0;
painter.resetTransform();
......@@ -1072,18 +1084,27 @@ void PrimaryFlightDisplay::drawVelocityMeter(
QString s_speed;
s_speed.sprintf("%d", abs(tickSpeed));
drawTextRightCenter(painter, s_speed, mediumTextSize, numbersRight, 0);
} else {
}
else {
painter.drawLine(tickmarkLeftMinor, 0, tickmarkRight, 0);
}
}
QPainterPath markerPath(QPoint(markerTip, 0));
markerPath.lineTo(markerTip - markerHalfHeight, markerHalfHeight);
markerPath.lineTo(markerTip - markerHalfHeight, 2*markerHalfHeight);
markerPath.lineTo(leftEdge, 2*markerHalfHeight);
markerPath.lineTo(leftEdge, -markerHalfHeight);
markerPath.lineTo(markerTip - markerHalfHeight, -markerHalfHeight);
markerPath.closeSubpath();
//Paint the label background
QPainterPath primaryMarkerPath(QPoint(markerTip, 0));
primaryMarkerPath.lineTo(markerTip - markerHalfHeight, markerHalfHeight);
primaryMarkerPath.lineTo(leftEdge, markerHalfHeight);
primaryMarkerPath.lineTo(leftEdge, -markerHalfHeight);
primaryMarkerPath.lineTo(markerTip - markerHalfHeight, -markerHalfHeight);
primaryMarkerPath.closeSubpath();
QPainterPath secondaryMarkerPath(QPoint(markerTip - markerHalfHeight, 1 * markerHalfHeight + markerOffset));
if (!isnan(secondarySpeed)) {
secondaryMarkerPath.lineTo(markerTip - markerHalfHeight, 2 * markerHalfHeight + markerOffset);
secondaryMarkerPath.lineTo(leftEdge, 2 * markerHalfHeight + markerOffset);
secondaryMarkerPath.lineTo(leftEdge, 1 * markerHalfHeight + markerOffset);
secondaryMarkerPath.closeSubpath();
}
painter.resetTransform();
painter.translate(area.left(), area.center().y());
......@@ -1093,7 +1114,8 @@ void PrimaryFlightDisplay::drawVelocityMeter(
painter.setPen(pen);
painter.setBrush(Qt::SolidPattern);
painter.drawPath(markerPath);
painter.drawPath(primaryMarkerPath);
if (!isnan(secondarySpeed)) painter.drawPath(secondaryMarkerPath);
painter.setBrush(Qt::NoBrush);
// Draw primary speed
......@@ -1103,17 +1125,16 @@ void PrimaryFlightDisplay::drawVelocityMeter(
if (isnan(primarySpeed))
s_alt.sprintf("---");
else
s_alt.sprintf("%s:%3.1f", (bSpeedIsAirspeed ? "AS":"GS"), primarySpeed);
drawTextLeftCenter(painter, s_alt, mediumTextSize, 4*lineWidth, 0);
s_alt.sprintf("%s:%3.1f", (bSpeedIsAirspeed ? "AS" : "GS"), primarySpeed);
drawTextLeftCenter(painter, s_alt, mediumTextSize, 4 * lineWidth, 0);
// Draw secondary speed
if (!isnan(secondarySpeed)) {
pen.setColor(Qt::white);
painter.setPen(pen);
if (isnan(secondarySpeed))
s_alt.sprintf("---");
else
s_alt.sprintf("%s:%3.1f", (!bSpeedIsAirspeed ? "AS" : "GS"), secondarySpeed);
drawTextLeftCenter(painter, s_alt, smallTextSize, 4*lineWidth, +mediumTextSize*1.2);
drawTextLeftCenter(painter, s_alt, smallTextSize, 4 * lineWidth, 1.5 * markerHalfHeight + markerOffset);
}
}
static const int TOP = (1<<0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment