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/>.
25 import "../js/common.js" as Utils
26 import "../js/uav.js" as UAV
34 readonly property real horizontCenter : horizontCenterItem.horizontCenter
36 // Factor for OSGViewer vertical offset
37 readonly property double factor: 0.04
39 // Stretch height and apply offset
40 //height: height * (1 + factor)
43 sceneNode: billboardNode
45 updateMode: UpdateMode.Discrete
54 children: [ videoNode ]
59 imageUrl: "gst://localhost/play?" + encodeURIComponent(pfdContext.gstPipeline)
63 // using rectangle instead of svg rendered to pixmap
64 // as it's much more memory efficient
69 property variant scaledBounds: svgRenderer.scaledElementBounds("pfd/pfd.svg", "horizon")
70 width: Math.round(sceneItem.width * scaledBounds.width / 2) * 2
71 height: Math.round(sceneItem.height * scaledBounds.height / 2) * 3
73 property double pitch1DegScaledHeight: (svgRenderer.scaledElementBounds("pfd/pfd.svg", "pitch-90").y -
74 svgRenderer.scaledElementBounds("pfd/pfd.svg", "pitch90").y) / 180.0
76 property double pitch1DegHeight: sceneItem.height * pitch1DegScaledHeight
81 x: Math.round((world.parent.width - world.width)/2)
82 // y is centered around world_center element
83 y: Math.round(horizontCenter - world.height / 2 + UAV.attitudePitch() * world.pitch1DegHeight)
86 angle: -UAV.attitudeRoll()
87 origin.x : world.parent.width / 2
88 origin.y : horizontCenter
96 property variant scaledBounds: svgRenderer.scaledElementBounds("pfd/pfd.svg", "pitch-window-terrain")
98 x: Math.floor(scaledBounds.x * sceneItem.width)
99 y: Math.floor(scaledBounds.y * sceneItem.height) - osgViewport.y
100 width: Math.floor(scaledBounds.width * sceneItem.width)
101 height: Math.floor(scaledBounds.height * sceneItem.height)
103 rotation: -UAV.attitudeRoll()
104 transformOrigin: Item.Center
111 elementName: "pitch-scale"
113 //worldView is loaded with Loader, so background element is visible
114 sceneSize: background.sceneSize
115 anchors.centerIn: parent
116 //see comment for world transform
117 anchors.verticalCenterOffset: attitudeState.pitch * world.pitch1DegHeight
118 border: 64 // sometimes numbers are excluded from bounding rect
125 elementName: "center-line"
129 // worldView is loaded with Loader, so background element is visible
130 sceneSize: background.sceneSize
131 anchors.centerIn: parent
133 anchors.verticalCenterOffset: UAV.attitudePitch() * world.pitch1DegHeight
140 elementName: "pitch0"
142 sceneSize: background.sceneSize
143 anchors.centerIn: parent
144 anchors.verticalCenterOffset: UAV.attitudePitch() * world.pitch1DegHeight