From 27f0e0678039789332aa38da03928bb24eb0b66c Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Wed, 24 Sep 2014 17:49:22 +0200 Subject: [PATCH] OP-1506 Wrong_display_alt_speed : Fix wrong scale display for speed and altitude. Hide scales (because do nothing) if no units defined in options km/h, m/s, knots, miles/h (speed) or meter / ft (altitude) --- .../pfd/default/AltitudeScale.qml | 61 ++++++--- .../share/openpilotgcs/pfd/default/Info.qml | 11 ++ .../share/openpilotgcs/pfd/default/Pfd.qml | 1 + .../openpilotgcs/pfd/default/SpeedScale.qml | 60 +++++--- .../openpilotgcs/pfd/default/VsiScale.qml | 9 -- .../share/openpilotgcs/pfd/default/pfd.svg | 129 ++++++++++-------- 6 files changed, 163 insertions(+), 108 deletions(-) diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml index 18df7808e..9aaa82030 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml @@ -4,12 +4,16 @@ Item { id: sceneItem property variant sceneSize + property real altitude : -qmlWidget.altitudeFactor * PositionState.Down + SvgElementImage { id: altitude_window elementName: "altitude-window" sceneSize: sceneItem.sceneSize clip: true + visible: qmlWidget.altitudeUnit != 0 + property variant scaledBounds: svgRenderer.scaledElementBounds("pfd.svg", "altitude-window") x: Math.floor(scaledBounds.x * sceneItem.width) @@ -22,25 +26,25 @@ Item { sceneSize: sceneItem.sceneSize anchors.verticalCenter: parent.verticalCenter - // The altitude scale represents 30 meters, - // move it in 0..5m range - anchors.verticalCenterOffset: -height/30 * (PositionState.Down-Math.floor(PositionState.Down/5*qmlWidget.altitudeFactor)*5) + // The altitude scale represents 10 units (ft or meters), + // move using decimal term from value to display + anchors.verticalCenterOffset: height/10 * (altitude - Math.floor(altitude)) anchors.left: parent.left - property int topNumber: 15-Math.floor(PositionState.Down/5*qmlWidget.altitudeFactor)*5 + property int topNumber: Math.floor(altitude)+5 // Altitude numbers Column { Repeater { - model: 7 + model: 10 Item { - height: altitude_scale.height / 6 + height: altitude_scale.height / 10 width: altitude_window.width Text { - text: altitude_scale.topNumber - index*5 + text: altitude_scale.topNumber - index color: "white" - font.pixelSize: parent.height / 4 + font.pixelSize: parent.height / 3 font.family: "Arial" anchors.horizontalCenter: parent.horizontalCenter @@ -56,7 +60,7 @@ Item { elementName: "altitude-vector" sceneSize: sceneItem.sceneSize - height: -NedAccel.Down * altitude_scale.height/30 + height: -NedAccel.Down * altitude_scale.height/10 anchors.left: parent.left anchors.bottom: parent.verticalCenter @@ -71,7 +75,7 @@ Item { anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter - anchors.verticalCenterOffset: -altitude_scale.height/30 * (PositionState.Down - PathDesired.End_Down) + anchors.verticalCenterOffset: -altitude_scale.height/10 * (PositionState.Down - PathDesired.End_Down) * qmlWidget.altitudeFactor } } @@ -79,6 +83,8 @@ Item { id: altitude_box clip: true + visible: qmlWidget.altitudeUnit != 0 + elementName: "altitude-box" sceneSize: sceneItem.sceneSize @@ -91,26 +97,39 @@ Item { Text { id: altitude_text - text: Math.floor(-PositionState.Down * qmlWidget.altitudeFactor).toFixed() + text: " " +altitude.toFixed(1) color: "white" font { family: "Arial" - pixelSize: parent.height * 0.4 + pixelSize: parent.height * 0.35 + weight: Font.DemiBold } anchors.centerIn: parent } } - Text { - id: altitude_unit_text - text: qmlWidget.altitudeUnit - color: "white" - font { - family: "Arial" - pixelSize: sceneSize.height * 0.025 - } + SvgElementImage { + id: altitude_unit_box + elementName: "altitude-unit-box" + sceneSize: sceneItem.sceneSize + + visible: qmlWidget.altitudeUnit != 0 + anchors.top: altitude_window.bottom anchors.right: altitude_window.right - anchors.margins: font.pixelSize * 0.3 + width: scaledBounds.width * sceneItem.width + height: scaledBounds.height * sceneItem.height + + Text { + id: altitude_unit_text + text: qmlWidget.altitudeUnit + color: "white" + font { + family: "Arial" + pixelSize: parent.height * 0.6 + weight: Font.DemiBold + } + anchors.centerIn: parent + } } } diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Info.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Info.qml index 96897fc38..c22f60c60 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Info.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Info.qml @@ -70,6 +70,17 @@ Item { // End Functions // // Start Drawing + // Foreground (gradient) + + SvgElementImage { + id: foreground + elementName: "foreground" + sceneSize: info.sceneSize + + x: Math.floor(scaledBounds.x * info.width) + y: Math.floor(scaledBounds.y * info.height) + + } SvgElementImage { id: info_bg diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml index 41a19ae69..e14e4a96b 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml @@ -76,6 +76,7 @@ Rectangle { VsiScale { anchors.fill: parent sceneSize: sceneItem.viewportSize + visible: qmlWidget.altitudeUnit != 0 } Info { diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/SpeedScale.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/SpeedScale.qml index e0b971afa..cf51768e9 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/SpeedScale.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/SpeedScale.qml @@ -12,6 +12,8 @@ Item { sceneSize: sceneItem.sceneSize clip: true + visible: qmlWidget.speedUnit != 0 + x: Math.floor(scaledBounds.x * sceneItem.width) y: Math.floor(scaledBounds.y * sceneItem.height) @@ -22,12 +24,12 @@ Item { sceneSize: sceneItem.sceneSize anchors.verticalCenter: parent.verticalCenter - // The speed scale represents 30 meters, - // move it in 0..5m range - anchors.verticalCenterOffset: height/30 * (sceneItem.groundSpeed-Math.floor(sceneItem.groundSpeed/5)*5) + // The speed scale represents 10 units, + // move using decimal term from value to display + anchors.verticalCenterOffset: height/10 * (sceneItem.groundSpeed-Math.floor(sceneItem.groundSpeed)) anchors.right: parent.right - property int topNumber: Math.floor(sceneItem.groundSpeed/5)*5+15 + property int topNumber: Math.floor(sceneItem.groundSpeed)+5 // speed numbers Column { @@ -35,18 +37,18 @@ Item { anchors.right: speed_scale.right Repeater { - model: 7 + model: 10 Item { - height: speed_scale.height / 6 + height: speed_scale.height / 10 width: speed_window.width Text { //don't show negative numbers - text: speed_scale.topNumber - index*5 + text: speed_scale.topNumber - index color: "white" - visible: speed_scale.topNumber - index*5 >= 0 + visible: speed_scale.topNumber - index >= 0 - font.pixelSize: parent.height / 4 + font.pixelSize: parent.height / 3 font.family: "Arial" anchors.horizontalCenter: parent.horizontalCenter @@ -66,17 +68,18 @@ Item { anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter - anchors.verticalCenterOffset: speed_scale.height/30 * (sceneItem.groundSpeed - PathDesired.EndingVelocity) + anchors.verticalCenterOffset: speed_scale.height/10 * (sceneItem.groundSpeed - (PathDesired.EndingVelocity * qmlWidget.speedFactor)) } } SvgElementImage { id: speed_box clip: true - elementName: "speed-box" sceneSize: sceneItem.sceneSize + visible: qmlWidget.speedUnit != 0 + x: scaledBounds.x * sceneItem.width y: scaledBounds.y * sceneItem.height width: scaledBounds.width * sceneItem.width @@ -84,26 +87,39 @@ Item { Text { id: speed_text - text: Math.round(sceneItem.groundSpeed).toFixed() + text: sceneItem.groundSpeed.toFixed(1)+" " color: "white" font { family: "Arial" - pixelSize: parent.height * 0.4 + pixelSize: parent.height * 0.35 + weight: Font.DemiBold } anchors.centerIn: parent } } - Text { - id: speed_unit_text - text: qmlWidget.speedUnit - color: "white" - font { - family: "Arial" - pixelSize: sceneSize.height * 0.025 - } + SvgElementImage { + id: speed_unit_box + elementName: "speed-unit-box" + sceneSize: sceneItem.sceneSize + + visible: qmlWidget.speedUnit != 0 + anchors.top: speed_window.bottom anchors.right: speed_window.right - anchors.margins: font.pixelSize * 0.3 + width: scaledBounds.width * sceneItem.width + height: scaledBounds.height * sceneItem.height + + Text { + id: speed_unit_text + text: qmlWidget.speedUnit + color: "white" + font { + family: "Arial" + pixelSize: parent.height * 0.6 + weight: Font.DemiBold + } + anchors.centerIn: parent + } } } diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/VsiScale.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/VsiScale.qml index 033c8cb40..fe4fe6179 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/VsiScale.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/VsiScale.qml @@ -77,13 +77,4 @@ Item { } } - SvgElementImage { - id: foreground - elementName: "foreground" - sceneSize: sceneItem.sceneSize - - x: Math.floor(scaledBounds.x * sceneItem.width) - y: Math.floor(scaledBounds.y * sceneItem.height) - - } } diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/pfd.svg b/ground/openpilotgcs/share/openpilotgcs/pfd/default/pfd.svg index bde6f6681..665d48e11 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/pfd.svg +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/pfd.svg @@ -328,11 +328,11 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="2.1478368" - inkscape:cx="247.68069" - inkscape:cy="165.05075" + inkscape:zoom="1.0739184" + inkscape:cx="534.18699" + inkscape:cy="142.57283" inkscape:document-units="px" - inkscape:current-layer="layer77" + inkscape:current-layer="svg2" showgrid="false" fit-margin-top="0" fit-margin-left="0" @@ -352,7 +352,7 @@ inkscape:snap-bbox-midpoints="true" inkscape:snap-grids="false" inkscape:snap-to-guides="false" - inkscape:snap-nodes="false" + inkscape:snap-nodes="true" inkscape:bbox-paths="true" inkscape:snap-global="true" inkscape:snap-intersection-paths="true" @@ -377,7 +377,7 @@ id="guide8297" /> image/svg+xml - + @@ -442,7 +442,8 @@ inkscape:groupmode="layer" id="layer69" inkscape:label="foreground_layer" - style="display:inline"> + style="display:inline" + sodipodi:insensitive="true"> + style="display:none" + sodipodi:insensitive="true"> + style="display:inline" + sodipodi:insensitive="true"> + style="display:inline" + sodipodi:insensitive="true"> @@ -2622,7 +2626,8 @@ + inkscape:label="system-panel-mousearea" + sodipodi:insensitive="true"> + + + + + transform="translate(-20.837274,47.18067)"> - - - - - - - - + style="display:inline" + sodipodi:insensitive="true"> + + + + + +