mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-30 15:52:12 +01:00
LP-29 expose PfdContext to Qml as "pfdContext" instead of "qmlWidget"
This commit is contained in:
parent
a1ad54310d
commit
f11e9c6e41
@ -329,5 +329,5 @@ void PfdQmlContext::apply(QQmlContext *context)
|
||||
}
|
||||
|
||||
// to expose settings values
|
||||
context->setContextProperty("qmlWidget", this);
|
||||
context->setContextProperty("pfdContext", this);
|
||||
}
|
||||
|
@ -35,12 +35,12 @@ Item {
|
||||
id: skyNode
|
||||
sceneData: terrainNode
|
||||
dateTime: Utils.getDateTime()
|
||||
minimumAmbientLight: qmlWidget.minimumAmbientLight
|
||||
minimumAmbientLight: pfdContext.minimumAmbientLight
|
||||
}
|
||||
|
||||
OSGFileNode {
|
||||
id: terrainNode
|
||||
source: qmlWidget.terrainFile
|
||||
source: pfdContext.terrainFile
|
||||
async: false
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,6 @@ Item {
|
||||
Loader {
|
||||
anchors.fill: parent
|
||||
focus: true
|
||||
source: qmlWidget.terrainEnabled ? "model/ModelTerrainView.qml" : "model/ModelView.qml"
|
||||
source: pfdContext.terrainEnabled ? "model/ModelTerrainView.qml" : "model/ModelView.qml"
|
||||
}
|
||||
}
|
@ -61,7 +61,7 @@ Rectangle {
|
||||
id: worldLoader
|
||||
anchors.fill: parent
|
||||
focus: true
|
||||
source: qmlWidget.terrainEnabled ? "pfd/PfdTerrainView.qml" : "pfd/PfdWorldView.qml"
|
||||
source: pfdContext.terrainEnabled ? "pfd/PfdTerrainView.qml" : "pfd/PfdWorldView.qml"
|
||||
}
|
||||
|
||||
Pfd.HorizontCenter {
|
||||
@ -103,7 +103,7 @@ Rectangle {
|
||||
Pfd.VsiScale {
|
||||
anchors.fill: parent
|
||||
sceneSize: sceneItem.viewportSize
|
||||
visible: qmlWidget.altitudeUnit != 0
|
||||
visible: pfdContext.altitudeUnit != 0
|
||||
}
|
||||
|
||||
Pfd.Info {
|
||||
|
@ -24,11 +24,11 @@
|
||||
|
||||
// Get date
|
||||
function getDateTime() {
|
||||
switch(qmlWidget.timeMode) {
|
||||
switch(pfdContext.timeMode) {
|
||||
case TimeMode.Local:
|
||||
return new Date();
|
||||
case TimeMode.Predefined:
|
||||
return qmlWidget.dateTime;
|
||||
return pfdContext.dateTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ OSGViewport {
|
||||
id: skyNode
|
||||
sceneData: sceneGroup
|
||||
dateTime: Utils.getDateTime()
|
||||
minimumAmbientLight: qmlWidget.minimumAmbientLight
|
||||
minimumAmbientLight: pfdContext.minimumAmbientLight
|
||||
}
|
||||
|
||||
OSGGroup {
|
||||
@ -45,7 +45,7 @@ OSGViewport {
|
||||
|
||||
OSGFileNode {
|
||||
id: terrainNode
|
||||
source: qmlWidget.terrainFile
|
||||
source: pfdContext.terrainFile
|
||||
async: false
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ OSGViewport {
|
||||
|
||||
OSGFileNode {
|
||||
id: modelFileNode
|
||||
source: qmlWidget.modelFile
|
||||
source: pfdContext.modelFile
|
||||
async: false
|
||||
optimizeMode: OptimizeMode.OptimizeAndCheck
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ Item {
|
||||
|
||||
OSGBackgroundNode {
|
||||
id: backgroundNode
|
||||
imageFile: qmlWidget.backgroundImageFile
|
||||
imageFile: pfdContext.backgroundImageFile
|
||||
}
|
||||
|
||||
OSGTransformNode {
|
||||
@ -52,7 +52,7 @@ Item {
|
||||
|
||||
OSGFileNode {
|
||||
id: fileNode
|
||||
source: qmlWidget.modelFile
|
||||
source: pfdContext.modelFile
|
||||
async: false
|
||||
optimizeMode: OptimizeMode.OptimizeAndCheck
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ Item {
|
||||
id: sceneItem
|
||||
property variant sceneSize
|
||||
|
||||
property real altitude : -qmlWidget.altitudeFactor * UAV.positionStateDown()
|
||||
property real altitude : -pfdContext.altitudeFactor * UAV.positionStateDown()
|
||||
|
||||
SvgElementImage {
|
||||
id: altitude_window
|
||||
@ -34,7 +34,7 @@ Item {
|
||||
sceneSize: sceneItem.sceneSize
|
||||
clip: true
|
||||
|
||||
visible: qmlWidget.altitudeUnit != 0
|
||||
visible: pfdContext.altitudeUnit != 0
|
||||
|
||||
property variant scaledBounds: svgRenderer.scaledElementBounds("pfd/pfd.svg", "altitude-window")
|
||||
|
||||
@ -98,7 +98,7 @@ Item {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
anchors.verticalCenterOffset: -altitude_scale.height / 10 *
|
||||
(UAV.positionStateDown() - UAV.pathDesiredEndDown()) * qmlWidget.altitudeFactor
|
||||
(UAV.positionStateDown() - UAV.pathDesiredEndDown()) * pfdContext.altitudeFactor
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ Item {
|
||||
id: altitude_box
|
||||
clip: true
|
||||
|
||||
visible: qmlWidget.altitudeUnit != 0
|
||||
visible: pfdContext.altitudeUnit != 0
|
||||
|
||||
elementName: "altitude-box"
|
||||
sceneSize: sceneItem.sceneSize
|
||||
@ -136,7 +136,7 @@ Item {
|
||||
elementName: "altitude-unit-box"
|
||||
sceneSize: sceneItem.sceneSize
|
||||
|
||||
visible: qmlWidget.altitudeUnit != 0
|
||||
visible: pfdContext.altitudeUnit != 0
|
||||
|
||||
anchors.top: altitude_window.bottom
|
||||
anchors.right: altitude_window.right
|
||||
@ -145,7 +145,7 @@ Item {
|
||||
|
||||
Text {
|
||||
id: altitude_unit_text
|
||||
text: qmlWidget.altitudeUnit
|
||||
text: pfdContext.altitudeUnit
|
||||
color: "cyan"
|
||||
font {
|
||||
family: pt_bold.name
|
||||
|
@ -62,7 +62,7 @@ Item {
|
||||
sceneSize: info.sceneSize
|
||||
elementName: "info-bg"
|
||||
width: parent.width
|
||||
opacity: qmlWidget.terrainEnabled ? 0.3 : 1
|
||||
opacity: pfdContext.terrainEnabled ? 0.3 : 1
|
||||
}
|
||||
|
||||
//
|
||||
@ -374,7 +374,7 @@ Item {
|
||||
id: reset_consumed_energy_mouseArea;
|
||||
anchors.fill: parent;
|
||||
cursorShape: Qt.PointingHandCursor;
|
||||
onClicked: qmlWidget.resetConsumedEnergy();
|
||||
onClicked: pfdContext.resetConsumedEnergy();
|
||||
}
|
||||
|
||||
// Alarm based on estimatedFlightTime < 120s orange, < 60s red
|
||||
@ -452,7 +452,7 @@ Item {
|
||||
x: Math.floor(scaledBounds.x * sceneItem.width)
|
||||
y: Math.floor(scaledBounds.y * sceneItem.height)
|
||||
|
||||
opacity: qmlWidget.terrainEnabled ? 0.6 : 1
|
||||
opacity: pfdContext.terrainEnabled ? 0.6 : 1
|
||||
|
||||
states: State {
|
||||
name: "fading"
|
||||
|
@ -541,7 +541,7 @@ Item {
|
||||
anchors.fill: parent;
|
||||
cursorShape: Qt.PointingHandCursor;
|
||||
visible: display_bat == true ? 1 : 0
|
||||
onClicked: qmlWidget.resetConsumedEnergy();
|
||||
onClicked: pfdContext.resetConsumedEnergy();
|
||||
}
|
||||
|
||||
// Alarm based on estimatedFlightTime < 120s orange, < 60s red
|
||||
@ -598,7 +598,7 @@ Item {
|
||||
anchors.fill: parent;
|
||||
cursorShape: Qt.PointingHandCursor;
|
||||
visible: display_bat == true ? 1 : 0
|
||||
onClicked: qmlWidget.resetConsumedEnergy();
|
||||
onClicked: pfdContext.resetConsumedEnergy();
|
||||
}
|
||||
|
||||
// Alarm based on estimatedFlightTime < 120s orange, < 60s red
|
||||
|
@ -45,12 +45,12 @@ OSGViewport {
|
||||
id: skyNode
|
||||
sceneData: terrainNode
|
||||
dateTime: Utils.getDateTime()
|
||||
minimumAmbientLight: qmlWidget.minimumAmbientLight
|
||||
minimumAmbientLight: pfdContext.minimumAmbientLight
|
||||
}
|
||||
|
||||
OSGFileNode {
|
||||
id: terrainNode
|
||||
source: qmlWidget.terrainFile
|
||||
source: pfdContext.terrainFile
|
||||
async: false
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ import "../uav.js" as UAV
|
||||
Item {
|
||||
id: sceneItem
|
||||
property variant sceneSize
|
||||
property real groundSpeed : qmlWidget.speedFactor * UAV.currentVelocity()
|
||||
property real groundSpeed : pfdContext.speedFactor * UAV.currentVelocity()
|
||||
|
||||
SvgElementImage {
|
||||
id: speed_window
|
||||
@ -32,7 +32,7 @@ Item {
|
||||
sceneSize: sceneItem.sceneSize
|
||||
clip: true
|
||||
|
||||
visible: qmlWidget.speedUnit != 0
|
||||
visible: pfdContext.speedUnit != 0
|
||||
|
||||
x: Math.floor(scaledBounds.x * sceneItem.width)
|
||||
y: Math.floor(scaledBounds.y * sceneItem.height)
|
||||
@ -88,7 +88,7 @@ Item {
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
anchors.verticalCenterOffset: speed_scale.height / 10 * (sceneItem.groundSpeed - (UAV.pathDesiredEndingVelocity() * qmlWidget.speedFactor))
|
||||
anchors.verticalCenterOffset: speed_scale.height / 10 * (sceneItem.groundSpeed - (UAV.pathDesiredEndingVelocity() * pfdContext.speedFactor))
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ Item {
|
||||
elementName: "speed-box"
|
||||
sceneSize: sceneItem.sceneSize
|
||||
|
||||
visible: qmlWidget.speedUnit != 0
|
||||
visible: pfdContext.speedUnit != 0
|
||||
|
||||
x: scaledBounds.x * sceneItem.width
|
||||
y: scaledBounds.y * sceneItem.height
|
||||
@ -123,7 +123,7 @@ Item {
|
||||
elementName: "speed-unit-box"
|
||||
sceneSize: sceneItem.sceneSize
|
||||
|
||||
visible: qmlWidget.speedUnit != 0
|
||||
visible: pfdContext.speedUnit != 0
|
||||
|
||||
anchors.top: speed_window.bottom
|
||||
anchors.right: speed_window.right
|
||||
@ -132,7 +132,7 @@ Item {
|
||||
|
||||
Text {
|
||||
id: speed_unit_text
|
||||
text: qmlWidget.speedUnit
|
||||
text: pfdContext.speedUnit
|
||||
color: "cyan"
|
||||
font {
|
||||
family: pt_bold.name
|
||||
|
@ -56,7 +56,7 @@ Item {
|
||||
SvgElementImage {
|
||||
id: vsi_scale_meter
|
||||
|
||||
visible: (qmlWidget.altitudeUnit == "m")
|
||||
visible: (pfdContext.altitudeUnit == "m")
|
||||
elementName: "vsi-scale-meter"
|
||||
sceneSize: sceneItem.sceneSize
|
||||
|
||||
@ -68,7 +68,7 @@ Item {
|
||||
SvgElementImage {
|
||||
id: vsi_scale_ft
|
||||
|
||||
visible: (qmlWidget.altitudeUnit == "ft")
|
||||
visible: (pfdContext.altitudeUnit == "ft")
|
||||
elementName: "vsi-scale-ft"
|
||||
sceneSize: sceneItem.sceneSize
|
||||
|
||||
@ -104,7 +104,7 @@ Item {
|
||||
sceneSize: sceneItem.sceneSize
|
||||
|
||||
Text {
|
||||
text: (qmlWidget.altitudeUnit == "m") ? "m/s" : "ft/s"
|
||||
text: (pfdContext.altitudeUnit == "m") ? "m/s" : "ft/s"
|
||||
color: "cyan"
|
||||
font {
|
||||
family: pt_bold.name
|
||||
|
@ -139,7 +139,7 @@ function homePosition() {
|
||||
}
|
||||
|
||||
function defaultPosition() {
|
||||
return Qt.vector3d(qmlWidget.longitude, qmlWidget.latitude, qmlWidget.altitude);
|
||||
return Qt.vector3d(pfdContext.longitude, pfdContext.latitude, pfdContext.altitude);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user