From 99b898c5c2aad3acd65f9cc63b7103ffe223b706 Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Sun, 2 Sep 2012 13:33:29 +1000 Subject: [PATCH 01/15] GCS/PFDqml: display the VSI bar updated pfd.svg file with new compass and VSI bar --- .../share/openpilotgcs/pfd/default/Pfd.qml | 19 +- .../openpilotgcs/pfd/default/VsiScale.qml | 85 + .../share/openpilotgcs/pfd/default/pfd.svg | 5470 +++++++++-------- 3 files changed, 3028 insertions(+), 2546 deletions(-) create mode 100644 ground/openpilotgcs/share/openpilotgcs/pfd/default/VsiScale.qml diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml index b25596def..57afeb56a 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml @@ -32,13 +32,13 @@ Rectangle { source: "image://svg/pfd.svg!rollscale" sourceSize: background.sourceSize smooth: true - anchors.centerIn: parent - //rotate it around the center of scene - transform: Rotation { - angle: -AttitudeActual.Roll - origin.x : sceneItem.width/2 - x - origin.y : sceneItem.height/2 - y - } + anchors.centerIn: parent + //rotate it around the center of scene + transform: Rotation { + angle: -AttitudeActual.Roll + origin.x : sceneItem.width/2 - x + origin.y : sceneItem.height/2 - y + } } Image { @@ -78,6 +78,11 @@ Rectangle { sourceSize: background.sourceSize } + VsiScale { + anchors.fill: parent + sourceSize: background.sourceSize + } + PfdIndicators { anchors.fill: parent sourceSize: background.sourceSize diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/VsiScale.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/VsiScale.qml new file mode 100644 index 000000000..455104462 --- /dev/null +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/VsiScale.qml @@ -0,0 +1,85 @@ +import Qt 4.7 + +Item { + id: sceneItem + property variant sourceSize + + Image { + id: vsi_bg + source: "image://svg/pfd.svg!vsi-bg" + sourceSize: sceneItem.sourceSize + clip: true + + property variant scaledBounds: svgRenderer.scaledElementBounds("pfd.svg", "vsi-bg") + + x: scaledBounds.x * sceneItem.width + y: scaledBounds.y * sceneItem.height + width: scaledBounds.width * sceneItem.width + height: scaledBounds.height * sceneItem.height + + Image { + id: vsi_bar + + source: "image://svg/pfd.svg!vsi-bar" + sourceSize: sceneItem.sourceSize + + //the scale in 1000 ft/min with height == 5200 ft/min + height: (-VelocityActual.Down*3.28*60/1000)*(vsi_scale.height/5.2) + + + anchors.bottom: parent.verticalCenter + anchors.left: parent.left + } + + Image { + id: vsi_scale + + source: "image://svg/pfd.svg!vsi-scale" + sourceSize: sceneItem.sourceSize + + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + + //Text labels + Column { + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.right + + Repeater { + model: [2, 1, 0, 1, 2] + Item { + height: vsi_scale.height / 5.2 //the scale height is 5200 + width: vsi_bg.width - vsi_scale.width //fill area right to scale + + Text { + text: modelData + visible: modelData !== 0 //hide "0" label + color: "white" + font.pixelSize: parent.height / 4 + font.family: "Arial" + + anchors.centerIn: parent + } + } + } + } + } + } + + + Image { + id: vsi_window + clip: true + smooth: true + + source: "image://svg/pfd.svg!vsi-window" + sourceSize: sceneItem.sourceSize + + property variant scaledBounds: svgRenderer.scaledElementBounds("pfd.svg", "vsi-window") + + x: scaledBounds.x * sceneItem.width + y: scaledBounds.y * sceneItem.height + width: scaledBounds.width * sceneItem.width + height: scaledBounds.height * sceneItem.height + } +} diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/pfd.svg b/ground/openpilotgcs/share/openpilotgcs/pfd/default/pfd.svg index 95724c8b8..94fa89f92 100755 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/pfd.svg +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/pfd.svg @@ -15,11 +15,11 @@ id="svg2" version="1.1" inkscape:version="0.48.3.1 r9886" - sodipodi:docname="pfd.svg" + sodipodi:docname="pfd-4.svg" style="display:inline" - inkscape:export-filename="H:\Documents\Hobbies\OpenPilot\SVN\artwork\PFD-2.png" - inkscape:export-xdpi="269.53" - inkscape:export-ydpi="269.53"> + inkscape:export-filename="C:\Users\Nuno\Desktop\OpenPilot\PFD\PFD-4.png" + inkscape:export-xdpi="71.993568" + inkscape:export-ydpi="71.993568"> + + + + + + + + @@ -1689,14 +1721,14 @@ image/svg+xml - + + + transform="translate(230.4171,-2.5493479)" + sodipodi:insensitive="true"> @@ -2097,13 +2545,13 @@ id="speed-bg" width="110.05586" height="450" - x="-209.23766" + x="-147.23766" y="131.33096" /> @@ -2280,11 +2728,279 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + 1 + 2 + 1 + + + + + + - From 11025875708410bfa07a018fe2fc0a4b77f959f6 Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Mon, 3 Sep 2012 15:23:51 +1000 Subject: [PATCH 02/15] GCS/PFDqml: fixed compass rendering Converted AttitudeActual.Yaw to -180..180 range, so the whole compass band is always filled --- ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml index 57afeb56a..0827b7d30 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml @@ -63,8 +63,8 @@ Rectangle { sourceSize: background.sourceSize anchors.centerIn: parent - //the band is 540 degrees wide - anchors.horizontalCenterOffset: -1*AttitudeActual.Yaw/540*width + //the band is 540 degrees wide, AttitudeActual.Yaw is converted to -180..180 range + anchors.horizontalCenterOffset: -1*((AttitudeActual.Yaw+180+720) % 360 - 180)/540*width } } From 4cc13c9eea9b4aaa7efb0af8cc9a5d61c53c3b1b Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Sun, 9 Sep 2012 16:58:54 +1000 Subject: [PATCH 03/15] GCS/PFDqml: use the correct sceneSize for svg element images Pass the element source size instead of the scene source size to ensure the element is not downscalled. --- .../pfd/default/AltitudeScale.qml | 20 ++++----- .../share/openpilotgcs/pfd/default/Pfd.qml | 43 ++++++++++--------- .../pfd/default/PfdIndicators.qml | 10 ++--- .../openpilotgcs/pfd/default/PfdWorldView.qml | 10 ++--- .../openpilotgcs/pfd/default/SpeedScale.qml | 24 +++++------ .../pfd/default/SvgElementImage.qml | 14 ++++++ .../openpilotgcs/pfd/default/VsiScale.qml | 30 ++++++------- .../src/libs/utils/svgimageprovider.cpp | 27 +++++++++--- 8 files changed, 100 insertions(+), 78 deletions(-) create mode 100644 ground/openpilotgcs/share/openpilotgcs/pfd/default/SvgElementImage.qml diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml index 6e5b608f7..ff85ffc74 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/AltitudeScale.qml @@ -2,12 +2,12 @@ import Qt 4.7 Item { id: sceneItem - property variant sourceSize + property variant sceneSize - Image { + SvgElementImage { id: altitude_bg - source: "image://svg/pfd.svg!altitude-bg" - sourceSize: sceneItem.sourceSize + elementName: "altitude-bg" + sceneSize: sceneItem.sceneSize clip: true property variant scaledBounds: svgRenderer.scaledElementBounds("pfd.svg", "altitude-bg") @@ -17,11 +17,11 @@ Item { width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height - Image { + SvgElementImage { id: altitude_scale - source: "image://svg/pfd.svg!altitude-scale" - sourceSize: sceneItem.sourceSize + elementName: "altitude-scale" + sceneSize: sceneItem.sceneSize anchors.verticalCenter: parent.verticalCenter // The altitude scale represents 30 meters, @@ -55,12 +55,12 @@ Item { } - Image { + SvgElementImage { id: altitude_window clip: true - source: "image://svg/pfd.svg!altitude-window" - sourceSize: sceneItem.sourceSize + elementName: "altitude-window" + sceneSize: sceneItem.sceneSize property variant scaledBounds: svgRenderer.scaledElementBounds("pfd.svg", "altitude-window") diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml index 0827b7d30..77f4e3f7d 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml @@ -4,15 +4,13 @@ import "." Rectangle { color: "#666666" - Image { + SvgElementImage { id: background - source: "image://svg/pfd.svg!background" - + elementName: "background" fillMode: Image.PreserveAspectFit anchors.fill: parent - sourceSize.width: width - sourceSize.height: height + sceneSize: Qt.size(width, height) Item { id: sceneItem @@ -27,10 +25,11 @@ Rectangle { source: qmlWidget.terrainEnabled ? "PfdTerrainView.qml" : "PfdWorldView.qml" } - Image { + SvgElementImage { id: rollscale - source: "image://svg/pfd.svg!rollscale" - sourceSize: background.sourceSize + elementName: "rollscale" + sceneSize: background.sceneSize + smooth: true anchors.centerIn: parent //rotate it around the center of scene @@ -41,26 +40,28 @@ Rectangle { } } - Image { + SvgElementImage { id: foreground - source: "image://svg/pfd.svg!foreground" - sourceSize: background.sourceSize + elementName: "foreground" + sceneSize: background.sceneSize + anchors.centerIn: parent } - Image { + SvgElementImage { id: compass - source: "image://svg/pfd.svg!compass" - sourceSize: background.sourceSize + elementName: "compass" + sceneSize: background.sceneSize + clip: true y: 12 anchors.horizontalCenter: parent.horizontalCenter - Image { + SvgElementImage { id: compass_band - source: "image://svg/pfd.svg!compass-band" - sourceSize: background.sourceSize + elementName: "compass-band" + sceneSize: background.sceneSize anchors.centerIn: parent //the band is 540 degrees wide, AttitudeActual.Yaw is converted to -180..180 range @@ -70,22 +71,22 @@ Rectangle { SpeedScale { anchors.fill: parent - sourceSize: background.sourceSize + sceneSize: background.sceneSize } AltitudeScale { anchors.fill: parent - sourceSize: background.sourceSize + sceneSize: background.sourceSize } VsiScale { anchors.fill: parent - sourceSize: background.sourceSize + sceneSize: background.sourceSize } PfdIndicators { anchors.fill: parent - sourceSize: background.sourceSize + sceneSize: background.sourceSize } } } diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdIndicators.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdIndicators.qml index d520dcf00..e71e75dda 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdIndicators.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdIndicators.qml @@ -2,17 +2,17 @@ import Qt 4.7 Item { id: sceneItem - property variant sourceSize + property variant sceneSize //telemetry status arrow - Image { + SvgElementImage { id: telemetry_status - source: "image://svg/pfd.svg!gcstelemetry-"+statusName - sourceSize: sceneItem.sourceSize + elementName: "gcstelemetry-"+statusName + sceneSize: sceneItem.sceneSize property string statusName : ["Disconnected","HandshakeReq","HandshakeAck","Connected"][GCSTelemetryStats.Status] - property variant scaledBounds: svgRenderer.scaledElementBounds("pfd.svg", "gcstelemetry-Disconnected") + scaledBounds: svgRenderer.scaledElementBounds("pfd.svg", "gcstelemetry-Disconnected") x: scaledBounds.x * sceneItem.width y: scaledBounds.y * sceneItem.height width: scaledBounds.width * sceneItem.width diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdWorldView.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdWorldView.qml index 9e4a02b3b..9c658afdb 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdWorldView.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdWorldView.qml @@ -1,15 +1,13 @@ import Qt 4.7 Item { - //worldView should fill the source size of svg document id: worldView - Image { + SvgElementImage { id: world - source: "image://svg/pfd.svg!world" - - sourceSize.width: worldView.width - sourceSize.height: worldView.height + elementName: "world" + //worldView is loaded with Loader, so background element is visible + sceneSize: background.sceneSize smooth: true diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/SpeedScale.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/SpeedScale.qml index ddc82b571..cb3845575 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/SpeedScale.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/SpeedScale.qml @@ -2,28 +2,26 @@ import Qt 4.7 Item { id: sceneItem - property variant sourceSize + property variant sceneSize property real groundSpeed : 3.6 * Math.sqrt(Math.pow(VelocityActual.North,2)+ Math.pow(VelocityActual.East,2)) - Image { + SvgElementImage { id: speed_bg - source: "image://svg/pfd.svg!speed-bg" - sourceSize: sceneItem.sourceSize + elementName: "speed-bg" + sceneSize: sceneItem.sceneSize clip: true - property variant scaledBounds: svgRenderer.scaledElementBounds("pfd.svg", "speed-bg") - x: scaledBounds.x * sceneItem.width y: scaledBounds.y * sceneItem.height width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height - Image { + SvgElementImage { id: speed_scale - source: "image://svg/pfd.svg!speed-scale" - sourceSize: sceneItem.sourceSize + elementName: "speed-scale" + sceneSize: sceneItem.sceneSize anchors.verticalCenter: parent.verticalCenter // The speed scale represents 30 meters, @@ -63,14 +61,12 @@ Item { } - Image { + SvgElementImage { id: speed_window clip: true - source: "image://svg/pfd.svg!speed-window" - sourceSize: sceneItem.sourceSize - - property variant scaledBounds: svgRenderer.scaledElementBounds("pfd.svg", "speed-window") + elementName: "speed-window" + sceneSize: sceneItem.sceneSize x: scaledBounds.x * sceneItem.width y: scaledBounds.y * sceneItem.height diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/SvgElementImage.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/SvgElementImage.qml new file mode 100644 index 000000000..f5646b9bd --- /dev/null +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/SvgElementImage.qml @@ -0,0 +1,14 @@ +import Qt 4.7 + +Image { + id: sceneItem + property variant sceneSize + property string elementName + property string svgFileName : "pfd.svg" + property variant scaledBounds: svgRenderer.scaledElementBounds(svgFileName, elementName) + + sourceSize.width: Math.round(sceneSize.width*scaledBounds.width) + sourceSize.height: Math.round(sceneSize.height*scaledBounds.height) + + Component.onCompleted: source = "image://svg/"+svgFileName+"!"+elementName +} diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/VsiScale.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/VsiScale.qml index 455104462..b543809be 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/VsiScale.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/VsiScale.qml @@ -2,26 +2,24 @@ import Qt 4.7 Item { id: sceneItem - property variant sourceSize + property variant sceneSize - Image { + SvgElementImage { id: vsi_bg - source: "image://svg/pfd.svg!vsi-bg" - sourceSize: sceneItem.sourceSize + elementName: "vsi-bg" + sceneSize: sceneItem.sceneSize clip: true - property variant scaledBounds: svgRenderer.scaledElementBounds("pfd.svg", "vsi-bg") - x: scaledBounds.x * sceneItem.width y: scaledBounds.y * sceneItem.height width: scaledBounds.width * sceneItem.width height: scaledBounds.height * sceneItem.height - Image { + SvgElementImage { id: vsi_bar - source: "image://svg/pfd.svg!vsi-bar" - sourceSize: sceneItem.sourceSize + elementName: "vsi-bar" + sceneSize: sceneItem.sceneSize //the scale in 1000 ft/min with height == 5200 ft/min height: (-VelocityActual.Down*3.28*60/1000)*(vsi_scale.height/5.2) @@ -31,11 +29,11 @@ Item { anchors.left: parent.left } - Image { + SvgElementImage { id: vsi_scale - source: "image://svg/pfd.svg!vsi-scale" - sourceSize: sceneItem.sourceSize + elementName: "vsi-scale" + sceneSize: sceneItem.sceneSize anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left @@ -67,15 +65,13 @@ Item { } - Image { + SvgElementImage { id: vsi_window clip: true smooth: true - source: "image://svg/pfd.svg!vsi-window" - sourceSize: sceneItem.sourceSize - - property variant scaledBounds: svgRenderer.scaledElementBounds("pfd.svg", "vsi-window") + elementName: "vsi-window" + sceneSize: sceneItem.sceneSize x: scaledBounds.x * sceneItem.width y: scaledBounds.y * sceneItem.height diff --git a/ground/openpilotgcs/src/libs/utils/svgimageprovider.cpp b/ground/openpilotgcs/src/libs/utils/svgimageprovider.cpp index e0f571369..8d60f2e31 100644 --- a/ground/openpilotgcs/src/libs/utils/svgimageprovider.cpp +++ b/ground/openpilotgcs/src/libs/utils/svgimageprovider.cpp @@ -92,9 +92,15 @@ QImage SvgImageProvider::requestImage(const QString &id, QSize *size, const QSiz QSize docSize = renderer->defaultSize(); - if (!requestedSize.isEmpty() && !docSize.isEmpty()) { - xScale = qreal(requestedSize.width())/docSize.width(); - yScale = qreal(requestedSize.height())/docSize.height(); + if (!requestedSize.isEmpty()) { + if (!element.isEmpty()) { + QRectF elementBounds = renderer->boundsOnElement(element); + xScale = qreal(requestedSize.width())/elementBounds.width(); + yScale = qreal(requestedSize.height())/elementBounds.height(); + } else if (!docSize.isEmpty()) { + xScale = qreal(requestedSize.width())/docSize.width(); + yScale = qreal(requestedSize.height())/docSize.height(); + } } //keep the aspect ratio @@ -114,10 +120,16 @@ QImage SvgImageProvider::requestImage(const QString &id, QSize *size, const QSiz QImage img(w, h, QImage::Format_ARGB32_Premultiplied); img.fill(0); QPainter p(&img); - renderer->render(&p, element); + p.setRenderHints(QPainter::TextAntialiasing | + QPainter::Antialiasing | + QPainter::SmoothPixmapTransform); + + renderer->render(&p, element, QRectF(0, 0, w, h)); if (size) *size = QSize(w, h); + + //img.save(element+".png"); return img; } else { //render the whole svg file @@ -127,7 +139,12 @@ QImage SvgImageProvider::requestImage(const QString &id, QSize *size, const QSiz QImage img(w, h, QImage::Format_ARGB32_Premultiplied); img.fill(0); QPainter p(&img); - renderer->render(&p); + p.setRenderHints(QPainter::TextAntialiasing | + QPainter::Antialiasing | + QPainter::SmoothPixmapTransform); + + p.scale(xScale, yScale); + renderer->render(&p, QRectF(QPointF(), QSizeF(docSize))); if (size) *size = QSize(w, h); From 18a9ad3aa801d64883846f6ac84b973dc2b6cd24 Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Tue, 11 Sep 2012 15:16:58 +1000 Subject: [PATCH 04/15] PFD: split the compass band to parts to fit the texture limit On older graphics cards the texture size limit may be smaller than the compass band width, QML downscales the element to fit the texture. To avoid this, split compass band to tiles. Added parameter like hslice=2:8 to svg image provider and SvgElementImage. --- .../openpilotgcs/pfd/default/Compass.qml | 37 +++++++++++ .../share/openpilotgcs/pfd/default/Pfd.qml | 20 +----- .../pfd/default/SvgElementImage.qml | 19 +++++- .../src/libs/utils/svgimageprovider.cpp | 61 +++++++++++++++++-- 4 files changed, 111 insertions(+), 26 deletions(-) create mode 100644 ground/openpilotgcs/share/openpilotgcs/pfd/default/Compass.qml diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Compass.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Compass.qml new file mode 100644 index 000000000..650ac639b --- /dev/null +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Compass.qml @@ -0,0 +1,37 @@ +import Qt 4.7 +import "." + +Item { + id: sceneItem + property variant sceneSize + + SvgElementImage { + id: compass + elementName: "compass" + sceneSize: sceneItem.sceneSize + + clip: true + + x: scaledBounds.x * sceneItem.width + y: scaledBounds.y * sceneItem.height + //anchors.horizontalCenter: parent.horizontalCenter + + //split compass band to 8 parts to ensure it doesn't exceed the max texture size + Row { + anchors.centerIn: parent + //the band is 540 degrees wide, AttitudeActual.Yaw is converted to -180..180 range + anchors.horizontalCenterOffset: -1*((AttitudeActual.Yaw+180+720) % 360 - 180)/540*width + + Repeater { + model: 5 + SvgElementImage { + id: compass_band + elementName: "compass-band" + sceneSize: background.sceneSize + hSliceCount: 5 + hSlice: index + } + } + } + } +} diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml index 77f4e3f7d..c0456dd76 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml @@ -48,25 +48,9 @@ Rectangle { anchors.centerIn: parent } - SvgElementImage { - id: compass - elementName: "compass" + Compass { + anchors.fill: parent sceneSize: background.sceneSize - - clip: true - - y: 12 - anchors.horizontalCenter: parent.horizontalCenter - - SvgElementImage { - id: compass_band - elementName: "compass-band" - sceneSize: background.sceneSize - - anchors.centerIn: parent - //the band is 540 degrees wide, AttitudeActual.Yaw is converted to -180..180 range - anchors.horizontalCenterOffset: -1*((AttitudeActual.Yaw+180+720) % 360 - 180)/540*width - } } SpeedScale { diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/SvgElementImage.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/SvgElementImage.qml index f5646b9bd..6f84f433d 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/SvgElementImage.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/SvgElementImage.qml @@ -4,11 +4,26 @@ Image { id: sceneItem property variant sceneSize property string elementName - property string svgFileName : "pfd.svg" + property string svgFileName: "pfd.svg" + property int vSlice: 0 + property int vSliceCount: 0 + property int hSlice: 0 + property int hSliceCount: 0 property variant scaledBounds: svgRenderer.scaledElementBounds(svgFileName, elementName) sourceSize.width: Math.round(sceneSize.width*scaledBounds.width) sourceSize.height: Math.round(sceneSize.height*scaledBounds.height) - Component.onCompleted: source = "image://svg/"+svgFileName+"!"+elementName + Component.onCompleted: { + var params = "" + if (hSliceCount > 1) + params += "hslice="+hSlice+":"+hSliceCount + if (vSliceCount > 1) + params += "vslice="+vSlice+":"+vSliceCount + + if (params != "") + params = "?" + params + + source = "image://svg/"+svgFileName+"!"+elementName+params + } } diff --git a/ground/openpilotgcs/src/libs/utils/svgimageprovider.cpp b/ground/openpilotgcs/src/libs/utils/svgimageprovider.cpp index 8d60f2e31..2a032980d 100644 --- a/ground/openpilotgcs/src/libs/utils/svgimageprovider.cpp +++ b/ground/openpilotgcs/src/libs/utils/svgimageprovider.cpp @@ -67,12 +67,23 @@ QSvgRenderer *SvgImageProvider::loadRenderer(const QString &svgFile) } /** - requestedSize is realted to the whole svg file, not to specific element - */ + Supported id format: fileName[!elementName[?parameters]] + where parameters may be: + vslice=1:2;hslice=2:4 - use the 3rd horizontal slice of total 4 slices, slice numbering starts from 0 + + requestedSize is related to the whole element size, even if slice is requested. + + usage: + + Image { + source: "image://svg/pfd.svg!world" + } +*/ QImage SvgImageProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize) { QString svgFile = id; QString element; + QString parameters; int separatorPos = id.indexOf('!'); if (separatorPos != -1) { @@ -80,6 +91,29 @@ QImage SvgImageProvider::requestImage(const QString &id, QSize *size, const QSiz element = id.mid(separatorPos+1); } + int parametersPos = element.indexOf('?'); + if (parametersPos != -1) { + parameters = element.mid(parametersPos+1); + element = element.left(parametersPos); + } + + int hSlicesCount = 0; + int hSlice = 0; + int vSlicesCount = 0; + int vSlice = 0; + if (!parameters.isEmpty()) { + QRegExp hSliceRx("hslice=(\\d+):(\\d+)"); + if (hSliceRx.indexIn(parameters) != -1) { + hSlice = hSliceRx.cap(1).toInt(); + hSlicesCount = hSliceRx.cap(2).toInt(); + } + QRegExp vSliceRx("vslice=(\\d+):(\\d+)"); + if (vSliceRx.indexIn(parameters) != -1) { + vSlice = vSliceRx.cap(1).toInt(); + vSlicesCount = vSliceRx.cap(2).toInt(); + } + } + if (size) *size = QSize(); @@ -114,8 +148,22 @@ QImage SvgImageProvider::requestImage(const QString &id, QSize *size, const QSiz } QRectF elementBounds = renderer->boundsOnElement(element); - int w = qRound(elementBounds.width() * xScale); - int h = qRound(elementBounds.height() * yScale); + int elementWidth = qRound(elementBounds.width() * xScale); + int elementHeigh = qRound(elementBounds.height() * yScale); + int w = elementWidth; + int h = elementHeigh; + int x = 0; + int y = 0; + + if (hSlicesCount > 1) { + x = (w*hSlice)/hSlicesCount; + w = (w*(hSlice+1))/hSlicesCount - x; + } + + if (vSlicesCount > 1) { + y = (h*(vSlice))/vSlicesCount; + h = (h*(vSlice+1))/vSlicesCount - y; + } QImage img(w, h, QImage::Format_ARGB32_Premultiplied); img.fill(0); @@ -124,12 +172,13 @@ QImage SvgImageProvider::requestImage(const QString &id, QSize *size, const QSiz QPainter::Antialiasing | QPainter::SmoothPixmapTransform); - renderer->render(&p, element, QRectF(0, 0, w, h)); + p.translate(-x,-y); + renderer->render(&p, element, QRectF(0, 0, elementWidth, elementHeigh)); if (size) *size = QSize(w, h); - //img.save(element+".png"); + //img.save(element+parameters+".png"); return img; } else { //render the whole svg file From 53d8fa46666dacc67ede022e50715c1616e4237b Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Tue, 11 Sep 2012 15:19:19 +1000 Subject: [PATCH 05/15] Added the border parameter to the svg image provider it's useful to extent the image by 1 pixel sometimes, so the AA area is not clipped. --- .../openpilotgcs/src/libs/utils/svgimageprovider.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ground/openpilotgcs/src/libs/utils/svgimageprovider.cpp b/ground/openpilotgcs/src/libs/utils/svgimageprovider.cpp index 2a032980d..102a24b26 100644 --- a/ground/openpilotgcs/src/libs/utils/svgimageprovider.cpp +++ b/ground/openpilotgcs/src/libs/utils/svgimageprovider.cpp @@ -70,6 +70,7 @@ QSvgRenderer *SvgImageProvider::loadRenderer(const QString &svgFile) Supported id format: fileName[!elementName[?parameters]] where parameters may be: vslice=1:2;hslice=2:4 - use the 3rd horizontal slice of total 4 slices, slice numbering starts from 0 + borders=1 - 1 pixel wide transparent border requestedSize is related to the whole element size, even if slice is requested. @@ -101,6 +102,7 @@ QImage SvgImageProvider::requestImage(const QString &id, QSize *size, const QSiz int hSlice = 0; int vSlicesCount = 0; int vSlice = 0; + int border = 0; if (!parameters.isEmpty()) { QRegExp hSliceRx("hslice=(\\d+):(\\d+)"); if (hSliceRx.indexIn(parameters) != -1) { @@ -112,6 +114,10 @@ QImage SvgImageProvider::requestImage(const QString &id, QSize *size, const QSiz vSlice = vSliceRx.cap(1).toInt(); vSlicesCount = vSliceRx.cap(2).toInt(); } + QRegExp borderRx("border=(\\d+)"); + if (borderRx.indexIn(parameters) != -1) { + border = borderRx.cap(1).toInt(); + } } if (size) @@ -165,14 +171,14 @@ QImage SvgImageProvider::requestImage(const QString &id, QSize *size, const QSiz h = (h*(vSlice+1))/vSlicesCount - y; } - QImage img(w, h, QImage::Format_ARGB32_Premultiplied); + QImage img(w+border*2, h+border*2, QImage::Format_ARGB32_Premultiplied); img.fill(0); QPainter p(&img); p.setRenderHints(QPainter::TextAntialiasing | QPainter::Antialiasing | QPainter::SmoothPixmapTransform); - p.translate(-x,-y); + p.translate(-x+border,-y+border); renderer->render(&p, element, QRectF(0, 0, elementWidth, elementHeigh)); if (size) From 288cb40c92c39a1ae605d8576f3b8b4379b0f7e5 Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Tue, 11 Sep 2012 15:22:04 +1000 Subject: [PATCH 06/15] Updated the pfd.svg file compass-band has a hidden vertical square to make the vertical limit. New IDs: world-bg (group of sky and ground) sky (blue part of the world) ground (orange part of the world) pitch_scale (the center scale) world-centerline (the centerline in the center of the world and in the middle of the sky and ground) By muralha --- .../share/openpilotgcs/pfd/default/pfd.svg | 899 ++++-------------- 1 file changed, 203 insertions(+), 696 deletions(-) diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/pfd.svg b/ground/openpilotgcs/share/openpilotgcs/pfd/default/pfd.svg index 94fa89f92..2fb70210c 100755 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/pfd.svg +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/pfd.svg @@ -15,7 +15,7 @@ id="svg2" version="1.1" inkscape:version="0.48.3.1 r9886" - sodipodi:docname="pfd-4.svg" + sodipodi:docname="pfd-6.svg" style="display:inline" inkscape:export-filename="C:\Users\Nuno\Desktop\OpenPilot\PFD\PFD-4.png" inkscape:export-xdpi="71.993568" @@ -1615,11 +1615,11 @@ borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" - inkscape:zoom="1.1193346" - inkscape:cx="509.61927" - inkscape:cy="365.39566" + inkscape:zoom="1" + inkscape:cx="568.94653" + inkscape:cy="247.78161" inkscape:document-units="px" - inkscape:current-layer="dots1-3" + inkscape:current-layer="layer41" showgrid="false" inkscape:window-width="1680" inkscape:window-height="987" @@ -1753,699 +1753,200 @@ id="world" inkscape:label="#g3042"> + transform="matrix(4.6362185,0,0,1.9084264,-1475.4746,-363.49767)" + id="world-bg" + inkscape:label="#g4280"> + id="ground" + style="fill:url(#linearGradient5597);fill-opacity:1;stroke:none" + inkscape:label="#rect3724" /> + rx="2.7755576e-017" + inkscape:label="#rect2942" /> - - 10 - - - 10 - - - 20 - - - 20 - - - -10 - - - -10 - - - -20 - - - -20 - - - - - - - - - - - - - - - - + inkscape:label="vsi-bg" + sodipodi:insensitive="true"> - + style="display:inline" + sodipodi:insensitive="true"> - + inkscape:connector-curvature="0" /> 255 + @@ -4379,8 +3875,7 @@ inkscape:groupmode="layer" id="layer35" inkscape:label="desired_layers" - style="display:none" - sodipodi:insensitive="true"> + style="display:none"> + + + Date: Tue, 11 Sep 2012 15:25:13 +1000 Subject: [PATCH 07/15] GCS/PFDqml: split the world view to smaller parts Ground and sky is rendered as QML Rectangle with gradients; Pitch scale and center line are rendered separately from the world element, so they always fit the maximum texture size. --- .../openpilotgcs/pfd/default/PfdWorldView.qml | 38 ++++++++++++++++--- .../pfd/default/SvgElementImage.qml | 9 ++++- 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdWorldView.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdWorldView.qml index 9c658afdb..004fc1394 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdWorldView.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/PfdWorldView.qml @@ -3,14 +3,21 @@ import Qt 4.7 Item { id: worldView - SvgElementImage { + Rectangle { id: world - elementName: "world" - //worldView is loaded with Loader, so background element is visible - sceneSize: background.sceneSize - smooth: true + property variant scaledBounds: svgRenderer.scaledElementBounds("pfd.svg", "world") + width: sceneItem.width*scaledBounds.width + height: sceneItem.height*scaledBounds.height + + gradient: Gradient { + GradientStop { position: 0.3; color: "#6589E2" } + GradientStop { position: 0.4999; color: "#AFC2F0" } + GradientStop { position: 0.5; color: "#A46933" } + GradientStop { position: 0.8; color: "black" } + } + transform: [ Translate { id: pitchTranslate @@ -23,5 +30,26 @@ Item { origin.y : world.parent.height/2 } ] + + SvgElementImage { + id: pitch_scale + elementName: "pitch_scale" + //worldView is loaded with Loader, so background element is visible + sceneSize: background.sceneSize + anchors.centerIn: parent + border: 64 //sometimes numbers are excluded from bounding rect + + smooth: true + } + + SvgElementImage { + id: horizont_line + elementName: "world-centerline" + //worldView is loaded with Loader, so background element is visible + sceneSize: background.sceneSize + anchors.centerIn: parent + border: 1 + smooth: true + } } } diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/SvgElementImage.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/SvgElementImage.qml index 6f84f433d..ea9d54626 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/SvgElementImage.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/SvgElementImage.qml @@ -9,6 +9,9 @@ Image { property int vSliceCount: 0 property int hSlice: 0 property int hSliceCount: 0 + //border property is useful to extent the area of image e bit, + //so it looks well antialiased when rotated + property int border: 0 property variant scaledBounds: svgRenderer.scaledElementBounds(svgFileName, elementName) sourceSize.width: Math.round(sceneSize.width*scaledBounds.width) @@ -17,9 +20,11 @@ Image { Component.onCompleted: { var params = "" if (hSliceCount > 1) - params += "hslice="+hSlice+":"+hSliceCount + params += "hslice="+hSlice+":"+hSliceCount+";" if (vSliceCount > 1) - params += "vslice="+vSlice+":"+vSliceCount + params += "vslice="+vSlice+":"+vSliceCount+";" + if (border > 0) + params += "border="+border+";" if (params != "") params = "?" + params From a8e6f4991b54089c0fa56d93ff2f1aa0a8862bf8 Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Fri, 14 Sep 2012 08:50:02 +1000 Subject: [PATCH 08/15] Added "use OpenGL" option to qml based PFD --- .../src/plugins/pfdqml/pfdqmlgadget.cpp | 1 + .../pfdqml/pfdqmlgadgetconfiguration.cpp | 6 +- .../pfdqml/pfdqmlgadgetconfiguration.h | 3 + .../pfdqml/pfdqmlgadgetoptionspage.cpp | 7 +++ .../plugins/pfdqml/pfdqmlgadgetoptionspage.ui | 62 ++++++++++++------- .../src/plugins/pfdqml/pfdqmlgadgetwidget.cpp | 29 +++++++-- .../src/plugins/pfdqml/pfdqmlgadgetwidget.h | 4 +- 7 files changed, 85 insertions(+), 27 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.cpp b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.cpp index 89d0b852d..7fa9be6a5 100644 --- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.cpp +++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.cpp @@ -38,6 +38,7 @@ PfdQmlGadget::~PfdQmlGadget() void PfdQmlGadget::loadConfiguration(IUAVGadgetConfiguration* config) { PfdQmlGadgetConfiguration *m = qobject_cast(config); + m_widget->setOpenGLEnabled(m->openGLEnabled()); m_widget->setQmlFile(m->qmlFile()); m_widget->setEarthFile(m->earthFile()); m_widget->setTerrainEnabled(m->terrainEnabled()); diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetconfiguration.cpp b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetconfiguration.cpp index 8a21da857..8991107fd 100644 --- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetconfiguration.cpp +++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetconfiguration.cpp @@ -25,7 +25,8 @@ PfdQmlGadgetConfiguration::PfdQmlGadgetConfiguration(QString classId, QSettings IUAVGadgetConfiguration(classId, parent), m_qmlFile("Unknown"), m_earthFile("Unknown"), - m_terrainEnabled(true), + m_openGLEnabled(true), + m_terrainEnabled(false), m_actualPositionUsed(false), m_latitude(0), m_longitude(0), @@ -40,6 +41,7 @@ PfdQmlGadgetConfiguration::PfdQmlGadgetConfiguration(QString classId, QSettings m_earthFile = qSettings->value("earthFile").toString(); m_earthFile=Utils::PathUtils().InsertDataPath(m_earthFile); + m_openGLEnabled = qSettings->value("openGLEnabled", true).toBool(); m_terrainEnabled = qSettings->value("terrainEnabled").toBool(); m_actualPositionUsed = qSettings->value("actualPositionUsed").toBool(); m_latitude = qSettings->value("latitude").toDouble(); @@ -57,6 +59,7 @@ IUAVGadgetConfiguration *PfdQmlGadgetConfiguration::clone() { PfdQmlGadgetConfiguration *m = new PfdQmlGadgetConfiguration(this->classId()); m->m_qmlFile = m_qmlFile; + m->m_openGLEnabled = m_openGLEnabled; m->m_earthFile = m_earthFile; m->m_terrainEnabled = m_terrainEnabled; m->m_actualPositionUsed = m_actualPositionUsed; @@ -78,6 +81,7 @@ void PfdQmlGadgetConfiguration::saveConfig(QSettings* qSettings) const { QString earthFile = Utils::PathUtils().RemoveDataPath(m_earthFile); qSettings->setValue("earthFile", earthFile); + qSettings->setValue("openGLEnabled", m_openGLEnabled); qSettings->setValue("terrainEnabled", m_terrainEnabled); qSettings->setValue("actualPositionUsed", m_actualPositionUsed); qSettings->setValue("latitude", m_latitude); diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetconfiguration.h b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetconfiguration.h index 69205375c..b13f6ea0a 100644 --- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetconfiguration.h +++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetconfiguration.h @@ -29,6 +29,7 @@ public: void setQmlFile(const QString &fileName) { m_qmlFile=fileName; } void setEarthFile(const QString &fileName) { m_earthFile=fileName; } + void setOpenGLEnabled(bool flag) { m_openGLEnabled = flag; } void setTerrainEnabled(bool flag) { m_terrainEnabled = flag; } void setActualPositionUsed(bool flag) { m_actualPositionUsed = flag; } void setLatitude(double value) { m_latitude = value; } @@ -38,6 +39,7 @@ public: QString qmlFile() const { return m_qmlFile; } QString earthFile() const { return m_earthFile; } + bool openGLEnabled() const { return m_openGLEnabled; } bool terrainEnabled() const { return m_terrainEnabled; } bool actualPositionUsed() const { return m_actualPositionUsed; } double latitude() const { return m_latitude; } @@ -51,6 +53,7 @@ public: private: QString m_qmlFile; // The name of the dial's SVG source file QString m_earthFile; // The name of osgearth terrain file + bool m_openGLEnabled; bool m_terrainEnabled; bool m_actualPositionUsed; double m_latitude; diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetoptionspage.cpp b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetoptionspage.cpp index 929dce289..bd4d21649 100644 --- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetoptionspage.cpp +++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetoptionspage.cpp @@ -53,6 +53,7 @@ QWidget *PfdQmlGadgetOptionsPage::createPage(QWidget *parent) options_page->earthFile->setPromptDialogTitle(tr("Choose OsgEarth terrain file")); options_page->earthFile->setPath(m_config->earthFile()); + options_page->useOpenGL->setChecked(m_config->openGLEnabled()); options_page->showTerrain->setChecked(m_config->terrainEnabled()); options_page->useActualLocation->setChecked(m_config->actualPositionUsed()); @@ -80,7 +81,13 @@ void PfdQmlGadgetOptionsPage::apply() { m_config->setQmlFile(options_page->qmlSourceFile->path()); m_config->setEarthFile(options_page->earthFile->path()); + m_config->setOpenGLEnabled(options_page->useOpenGL->isChecked()); + +#ifdef USE_OSG m_config->setTerrainEnabled(options_page->showTerrain->isChecked()); +#else + m_config->setTerrainEnabled(false); +#endif m_config->setActualPositionUsed(options_page->useActualLocation->isChecked()); m_config->setLatitude(options_page->latitude->text().toDouble()); diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetoptionspage.ui b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetoptionspage.ui index 3f244043b..92e87fbb3 100644 --- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetoptionspage.ui +++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetoptionspage.ui @@ -20,12 +20,6 @@ Form - - 0 - - - 0 - @@ -42,8 +36,8 @@ 0 0 - 457 - 436 + 439 + 418 @@ -78,6 +72,16 @@ + + + Use OpenGL + + + true + + + + Show Terrain: @@ -213,7 +217,7 @@ - + Qt::Vertical @@ -249,12 +253,12 @@ setEnabled(bool) - 150 - 138 + 167 + 188 - 142 - 172 + 260 + 222 @@ -265,12 +269,12 @@ setEnabled(bool) - 164 - 141 + 181 + 188 - 164 - 202 + 282 + 255 @@ -281,12 +285,28 @@ setEnabled(bool) - 190 - 141 + 207 + 188 - 190 - 237 + 308 + 288 + + + + + useOpenGL + toggled(bool) + showTerrain + setEnabled(bool) + + + 99 + 57 + + + 99 + 89 diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp index d6e43e70e..0c0ff6e36 100644 --- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp @@ -34,6 +34,7 @@ PfdQmlGadgetWidget::PfdQmlGadgetWidget(QWidget *parent) : QDeclarativeView(parent), + m_openGLEnabled(false), m_terrainEnabled(false), m_actualPositionUsed(false), m_latitude(46.671478), @@ -44,12 +45,15 @@ PfdQmlGadgetWidget::PfdQmlGadgetWidget(QWidget *parent) : setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); setResizeMode(SizeRootObjectToView); - setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); + //setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); QStringList objectsToExport; objectsToExport << "VelocityActual" << "PositionActual" << "AttitudeActual" << + "VelocityDesired" << + "PositionDesired" << + "AttitudeHoldDesired" << "GPSPosition" << "GCSTelemetryStats" << "FlightBatteryState"; @@ -106,9 +110,26 @@ void PfdQmlGadgetWidget::setEarthFile(QString arg) void PfdQmlGadgetWidget::setTerrainEnabled(bool arg) { - if (m_terrainEnabled != arg) { - m_terrainEnabled = arg; - emit terrainEnabledChanged(arg); + bool wasEnabled = terrainEnabled(); + m_terrainEnabled = arg; + + if (wasEnabled != terrainEnabled()) + emit terrainEnabledChanged(terrainEnabled()); +} + +void PfdQmlGadgetWidget::setOpenGLEnabled(bool arg) +{ + if (m_openGLEnabled != arg) { + m_openGLEnabled = arg; + + qDebug() << Q_FUNC_INFO << "Set OPENGL" << m_openGLEnabled; + if (m_openGLEnabled) + setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers))); + else + setViewport(new QWidget); + + //update terrainEnabled status with opengl status chaged + setTerrainEnabled(m_terrainEnabled); } } diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.h b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.h index ba89f282c..2e8bb3f8e 100644 --- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.h +++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.h @@ -39,7 +39,7 @@ public: void setQmlFile(QString fn); QString earthFile() const { return m_earthFile; } - bool terrainEnabled() const { return m_terrainEnabled; } + bool terrainEnabled() const { return m_terrainEnabled && m_openGLEnabled; } bool actualPositionUsed() const { return m_actualPositionUsed; } double latitude() const { return m_latitude; } @@ -49,6 +49,7 @@ public: public slots: void setEarthFile(QString arg); void setTerrainEnabled(bool arg); + void setOpenGLEnabled(bool arg); void setLatitude(double arg); void setLongitude(double arg); @@ -68,6 +69,7 @@ signals: private: QString m_qmlFileName; QString m_earthFile; + bool m_openGLEnabled; bool m_terrainEnabled; bool m_actualPositionUsed; From 150314ff98235800498b5cd1179e296c536e0488 Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Sun, 16 Sep 2012 10:03:28 +1000 Subject: [PATCH 09/15] 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) } } From 608297fbd3421a495b076f19da4172437b3c93c9 Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Thu, 20 Sep 2012 09:14:49 +1000 Subject: [PATCH 10/15] Changed the default PFD widget to qml based one --- .../openpilotgcs/default_configurations/OpenPilotGCS.xml | 4 ++-- .../openpilotgcs/default_configurations/OpenPilotGCS_wide.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml b/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml index 3445e0b17..443d47edd 100644 --- a/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml +++ b/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS.xml @@ -2467,9 +2467,9 @@ splitter - PFDGadget + PfdQmlGadget - raw + NoTerrain uavGadget diff --git a/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS_wide.xml b/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS_wide.xml index 3b3ceddd5..960c10355 100644 --- a/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS_wide.xml +++ b/ground/openpilotgcs/share/openpilotgcs/default_configurations/OpenPilotGCS_wide.xml @@ -2494,9 +2494,9 @@ splitter - PFDGadget + PfdQmlGadget - raw + NoTerrain uavGadget From 6174fa2d7f250e6aca5a3fc8ad262364d04a3c7c Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Thu, 20 Sep 2012 09:17:10 +1000 Subject: [PATCH 11/15] PFD: display the side-slip indicator --- .../share/openpilotgcs/pfd/default/Pfd.qml | 22 +++++++++++++++++++ .../src/plugins/pfdqml/pfdqmlgadgetwidget.cpp | 1 + 2 files changed, 23 insertions(+) diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml index c0456dd76..e393b185e 100644 --- a/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/Pfd.qml @@ -48,6 +48,28 @@ Rectangle { anchors.centerIn: parent } + SvgElementImage { + id: side_slip + elementName: "sideslip" + sceneSize: background.sceneSize + smooth: true + + property real sideSlip: Accels.y + //smooth side slip changes, a low pass filter replacement + //accels are updated once per second + Behavior on sideSlip { + SmoothedAnimation { + duration: 1000 + velocity: -1 + } + } + + anchors.horizontalCenter: foreground.horizontalCenter + //0.5 coefficient is empirical to limit indicator movement + anchors.horizontalCenterOffset: -sideSlip*width*0.5 + y: scaledBounds.y * sceneItem.height + } + Compass { anchors.fill: parent sceneSize: background.sceneSize diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp index 0c0ff6e36..7ef3612aa 100644 --- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadgetwidget.cpp @@ -51,6 +51,7 @@ PfdQmlGadgetWidget::PfdQmlGadgetWidget(QWidget *parent) : objectsToExport << "VelocityActual" << "PositionActual" << "AttitudeActual" << + "Accels" << "VelocityDesired" << "PositionDesired" << "AttitudeHoldDesired" << From 28f028064a22d6bf87d2f75ed5be2c3eaafbaddd Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Sun, 23 Sep 2012 19:13:05 +1000 Subject: [PATCH 12/15] Fixed the osgearth cache only configuration osgEarth enables it even if OSGEARTH_CACHE_ONLY is set to false it's necessary to unset it instead --- ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.cpp b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.cpp index 7fa9be6a5..770cc9744 100644 --- a/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.cpp +++ b/ground/openpilotgcs/src/plugins/pfdqml/pfdqmlgadget.cpp @@ -52,8 +52,10 @@ void PfdQmlGadget::loadConfiguration(IUAVGadgetConfiguration* config) if (m->cacheOnly()) { qputenv("OSGEARTH_CACHE_ONLY", "true"); } else { - //how portable it is? - //unsetenv("OSGEARTH_CACHE_ONLY"); - qputenv("OSGEARTH_CACHE_ONLY", "false"); +#ifdef Q_OS_WIN32 + qputenv("OSGEARTH_CACHE_ONLY", ""); +#else + unsetenv("OSGEARTH_CACHE_ONLY"); +#endif } } From dbbdb62173298e132888ed3cce4b122f063977d8 Mon Sep 17 00:00:00 2001 From: Dmytro Poplavskiy Date: Sun, 23 Sep 2012 19:30:10 +1000 Subject: [PATCH 13/15] Added the readymap based earth files --- .../openpilotgcs/pfd/default/readymap.earth | 35 +++++++++++++++++++ .../pfd/default/yahoo_readymap.earth | 25 +++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 ground/openpilotgcs/share/openpilotgcs/pfd/default/readymap.earth create mode 100644 ground/openpilotgcs/share/openpilotgcs/pfd/default/yahoo_readymap.earth diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/readymap.earth b/ground/openpilotgcs/share/openpilotgcs/pfd/default/readymap.earth new file mode 100644 index 000000000..55adca838 --- /dev/null +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/readymap.earth @@ -0,0 +1,35 @@ + + + + + http://readymap.org/readymap/tiles/1.0.0/7/ + + + + http://readymap.org/readymap/tiles/1.0.0/35/ + + + + http://readymap.org/readymap/tiles/1.0.0/9/ + + + + + false + 6.0 + + + + diff --git a/ground/openpilotgcs/share/openpilotgcs/pfd/default/yahoo_readymap.earth b/ground/openpilotgcs/share/openpilotgcs/pfd/default/yahoo_readymap.earth new file mode 100644 index 000000000..6846feb27 --- /dev/null +++ b/ground/openpilotgcs/share/openpilotgcs/pfd/default/yahoo_readymap.earth @@ -0,0 +1,25 @@ + + + + + + satellite + + + + + http://readymap.org/readymap/tiles/1.0.0/9/ + + + + + false + 6.0 + + + From 8b91e19733193881176683f751aa49b3264e7ee0 Mon Sep 17 00:00:00 2001 From: PT_Dreamer Date: Mon, 24 Sep 2012 12:32:46 +0100 Subject: [PATCH 14/15] GCS/Telemetry Fixes reconnection loop This fixes a situation where the telemetry would keep looping from the connected to the reconnecting state. One of the situations this was happening was going from "halt" to "boot" --- ground/openpilotgcs/src/plugins/uavtalk/telemetrymonitor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/plugins/uavtalk/telemetrymonitor.h b/ground/openpilotgcs/src/plugins/uavtalk/telemetrymonitor.h index 5d480a86e..2cd31c474 100644 --- a/ground/openpilotgcs/src/plugins/uavtalk/telemetrymonitor.h +++ b/ground/openpilotgcs/src/plugins/uavtalk/telemetrymonitor.h @@ -60,7 +60,7 @@ public slots: private: static const int STATS_UPDATE_PERIOD_MS = 4000; - static const int STATS_CONNECT_PERIOD_MS = 1000; + static const int STATS_CONNECT_PERIOD_MS = 2000; static const int CONNECTION_TIMEOUT_MS = 8000; UAVObjectManager* objMngr; From 3d5381893b26d1481922c6763a9548422e9834a7 Mon Sep 17 00:00:00 2001 From: PT_Dreamer Date: Mon, 24 Sep 2012 22:47:18 +0100 Subject: [PATCH 15/15] GCS-Changed relaytuning uavo to gcs readOnly --- shared/uavobjectdefinition/relaytuning.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/uavobjectdefinition/relaytuning.xml b/shared/uavobjectdefinition/relaytuning.xml index d781e45ca..e7b7419ee 100644 --- a/shared/uavobjectdefinition/relaytuning.xml +++ b/shared/uavobjectdefinition/relaytuning.xml @@ -3,7 +3,7 @@ The input to the relay tuning. - +