From 150314ff98235800498b5cd1179e296c536e0488 Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Sun, 16 Sep 2012 10:03:28 +1000 Subject: [PATCH] PFD qml: align elements to pixels grid It improves the rendering quality, sub pixels accuracy gives no benefits in placing PFD elements --- .../openpilotgcs/pfd/default/AltitudeScale.qml | 6 ++---- .../share/openpilotgcs/pfd/default/Compass.qml | 4 ++-- .../openpilotgcs/pfd/default/PfdIndicators.qml | 15 ++++++--------- .../openpilotgcs/pfd/default/PfdWorldView.qml | 9 +++++---- .../share/openpilotgcs/pfd/default/SpeedScale.qml | 6 ++---- .../share/openpilotgcs/pfd/default/VsiScale.qml | 12 ++++-------- 6 files changed, 21 insertions(+), 31 deletions(-) diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml index ff85ffc74..a8f4d66b2 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml @@ -12,10 +12,8 @@ Item { property variant scaledBounds: svgRenderer.scaledElementBounds("pfd.svg", "altitude-bg") - x: scaledBounds.x * sceneItem.width - y: scaledBounds.y * sceneItem.height - width: scaledBounds.width * sceneItem.width - height: scaledBounds.height * sceneItem.height + x: Math.floor(scaledBounds.x * sceneItem.width) + y: Math.floor(scaledBounds.y * sceneItem.height) SvgElementImage { id: altitude_scale diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Compass.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Compass.qml index 650ac639b..3c956d526 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Compass.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Compass.qml @@ -12,8 +12,8 @@ Item { clip: true - x: scaledBounds.x * sceneItem.width - y: scaledBounds.y * sceneItem.height + x: Math.floor(scaledBounds.x * sceneItem.width) + y: Math.floor(scaledBounds.y * sceneItem.height) //anchors.horizontalCenter: parent.horizontalCenter //split compass band to 8 parts to ensure it doesn't exceed the max texture size diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdIndicators.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdIndicators.qml index e71e75dda..8d821e7c3 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdIndicators.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdIndicators.qml @@ -13,10 +13,8 @@ Item { property string statusName : ["Disconnected","HandshakeReq","HandshakeAck","Connected"][GCSTelemetryStats.Status] scaledBounds: svgRenderer.scaledElementBounds("pfd.svg", "gcstelemetry-Disconnected") - x: scaledBounds.x * sceneItem.width - y: scaledBounds.y * sceneItem.height - width: scaledBounds.width * sceneItem.width - height: scaledBounds.height * sceneItem.height + x: Math.floor(scaledBounds.x * sceneItem.width) + y: Math.floor(scaledBounds.y * sceneItem.height) } //telemetry rate text @@ -41,8 +39,8 @@ Item { visible: GPSPosition.Satellites > 0 property variant scaledBounds: svgRenderer.scaledElementBounds("pfd.svg", "gps-txt") - x: scaledBounds.x * sceneItem.width - y: scaledBounds.y * sceneItem.height + x: Math.floor(scaledBounds.x * sceneItem.width) + y: Math.floor(scaledBounds.y * sceneItem.height) } Text { @@ -63,8 +61,7 @@ Item { visible: FlightBatteryState.Voltage > 0 || FlightBatteryState.Current > 0 property variant scaledBounds: svgRenderer.scaledElementBounds("pfd.svg", "battery-txt") - x: scaledBounds.x * sceneItem.width - y: scaledBounds.y * sceneItem.height - + x: Math.floor(scaledBounds.x * sceneItem.width) + y: Math.floor(scaledBounds.y * sceneItem.height) } } diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdWorldView.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdWorldView.qml index 004fc1394..9a461464f 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdWorldView.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdWorldView.qml @@ -8,8 +8,8 @@ Item { smooth: true property variant scaledBounds: svgRenderer.scaledElementBounds("pfd.svg", "world") - width: sceneItem.width*scaledBounds.width - height: sceneItem.height*scaledBounds.height + width: Math.round(sceneItem.width*scaledBounds.width/2)*2 + height: Math.round(sceneItem.height*scaledBounds.height/2)*2 gradient: Gradient { GradientStop { position: 0.3; color: "#6589E2" } @@ -21,8 +21,9 @@ Item { transform: [ Translate { id: pitchTranslate - x: (world.parent.width - world.width)/2 - y: (world.parent.height - world.height)/2 + AttitudeActual.Pitch*world.parent.height/94 + x: Math.round((world.parent.width - world.width)/2) + y: Math.round((world.parent.height - world.height)/2 + + AttitudeActual.Pitch*world.parent.height/94) }, Rotation { angle: -AttitudeActual.Roll diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/SpeedScale.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/SpeedScale.qml index cb3845575..1340b9cdb 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/SpeedScale.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/SpeedScale.qml @@ -12,10 +12,8 @@ Item { sceneSize: sceneItem.sceneSize clip: true - x: scaledBounds.x * sceneItem.width - y: scaledBounds.y * sceneItem.height - width: scaledBounds.width * sceneItem.width - height: scaledBounds.height * sceneItem.height + x: Math.floor(scaledBounds.x * sceneItem.width) + y: Math.floor(scaledBounds.y * sceneItem.height) SvgElementImage { id: speed_scale diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/VsiScale.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/VsiScale.qml index b543809be..171c048e0 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/VsiScale.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/VsiScale.qml @@ -10,10 +10,8 @@ Item { sceneSize: sceneItem.sceneSize clip: true - x: scaledBounds.x * sceneItem.width - y: scaledBounds.y * sceneItem.height - width: scaledBounds.width * sceneItem.width - height: scaledBounds.height * sceneItem.height + x: Math.floor(scaledBounds.x * sceneItem.width) + y: Math.floor(scaledBounds.y * sceneItem.height) SvgElementImage { id: vsi_bar @@ -73,9 +71,7 @@ Item { elementName: "vsi-window" sceneSize: sceneItem.sceneSize - x: scaledBounds.x * sceneItem.width - y: scaledBounds.y * sceneItem.height - width: scaledBounds.width * sceneItem.width - height: scaledBounds.height * sceneItem.height + x: Math.floor(scaledBounds.x * sceneItem.width) + y: Math.floor(scaledBounds.y * sceneItem.height) } }