2 * Copyright (C) 2016 The LibrePilot Project
3 * Contact: http://www.librepilot.org
5 * This file is part of LibrePilot GCS.
7 * LibrePilot GCS is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * LibrePilot GCS is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with LibrePilot GCS. If not, see <http://www.gnu.org/licenses/>.
22 import "../js/common.js" as Utils
23 import "../js/uav.js" as UAV
27 property variant sceneSize
29 property real altitude : -pfdContext.altitudeFactor * UAV.positionStateDown()
33 elementName: "altitude-window"
34 sceneSize: sceneItem.sceneSize
37 visible: pfdContext.altitudeUnit != 0
39 property variant scaledBounds: svgRenderer.scaledElementBounds("pfd/pfd.svg", "altitude-window")
41 x: Math.floor(scaledBounds.x * sceneItem.width)
42 y: Math.floor(scaledBounds.y * sceneItem.height)
47 elementName: "altitude-scale"
48 sceneSize: sceneItem.sceneSize
50 anchors.verticalCenter: parent.verticalCenter
51 // The altitude scale represents 10 units (ft or meters),
52 // move using decimal term from value to display
53 anchors.verticalCenterOffset: height/10 * (altitude - Math.floor(altitude))
54 anchors.left: parent.left
56 property int topNumber: Math.floor(altitude)+5
63 height: altitude_scale.height / 10
64 width: altitude_window.width
67 text: altitude_scale.topNumber - index
69 font.pixelSize: parent.height / 3
70 font.family: pt_bold.name
72 anchors.horizontalCenter: parent.horizontalCenter
73 anchors.verticalCenter: parent.top
82 elementName: "altitude-vector"
83 sceneSize: sceneItem.sceneSize
85 height: -UAV.nedAccelDown() * altitude_scale.height / 10
87 anchors.left: parent.left
88 anchors.bottom: parent.verticalCenter
93 elementName: "altitude-waypoint"
94 sceneSize: sceneItem.sceneSize
95 visible: (UAV.isFlightModeAssisted() && (UAV.pathDesiredEndDown() != 0.0))
97 anchors.left: parent.left
98 anchors.verticalCenter: parent.verticalCenter
100 anchors.verticalCenterOffset: -altitude_scale.height / 10 *
101 (UAV.positionStateDown() - UAV.pathDesiredEndDown()) * pfdContext.altitudeFactor
109 visible: pfdContext.altitudeUnit != 0
111 elementName: "altitude-box"
112 sceneSize: sceneItem.sceneSize
114 property variant scaledBounds: svgRenderer.scaledElementBounds("pfd/pfd.svg", "altitude-box")
116 x: scaledBounds.x * sceneItem.width
117 y: scaledBounds.y * sceneItem.height
118 width: scaledBounds.width * sceneItem.width
119 height: scaledBounds.height * sceneItem.height
123 text: " " + altitude.toFixed(1)
127 pixelSize: parent.height * 0.35
128 weight: Font.DemiBold
130 anchors.centerIn: parent
135 id: altitude_unit_box
136 elementName: "altitude-unit-box"
137 sceneSize: sceneItem.sceneSize
139 visible: pfdContext.altitudeUnit != 0
141 anchors.top: altitude_window.bottom
142 anchors.right: altitude_window.right
143 width: scaledBounds.width * sceneItem.width
144 height: scaledBounds.height * sceneItem.height
147 id: altitude_unit_text
148 text: pfdContext.altitudeUnit
152 pixelSize: parent.height * 0.6
153 weight: Font.DemiBold
155 anchors.centerIn: parent