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
31 //anchors.fill: parent
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)
45 manipulator: geoTransformManipulator
51 logarithmicDepthBuffer: true
54 OSGGeoTransformManipulator {
55 id: geoTransformManipulator
57 sceneNode: terrainFileNode
60 attitude: UAV.attitude()
61 position: UAV.position()
66 sceneNode: terrainFileNode
68 dateTime: Utils.getDateTime()
69 minimumAmbientLight: pfdContext.minimumAmbientLight
74 source: pfdContext.terrainFile
79 // using rectangle instead of svg rendered to pixmap
80 // as it's much more memory efficient
85 property variant scaledBounds: svgRenderer.scaledElementBounds("pfd/pfd.svg", "horizon")
86 width: Math.round(sceneItem.width * scaledBounds.width / 2) * 2
87 height: Math.round(sceneItem.height * scaledBounds.height / 2) * 3
89 property double pitch1DegScaledHeight: (svgRenderer.scaledElementBounds("pfd/pfd.svg", "pitch-90").y -
90 svgRenderer.scaledElementBounds("pfd/pfd.svg", "pitch90").y) / 180.0
92 property double pitch1DegHeight: sceneItem.height * pitch1DegScaledHeight
97 x: Math.round((world.parent.width - world.width)/2)
98 // y is centered around world_center element
99 y: Math.round(horizontCenter - world.height / 2 + UAV.attitudePitch() * world.pitch1DegHeight)
102 angle: -UAV.attitudeRoll()
103 origin.x : world.parent.width / 2
104 origin.y : horizontCenter
112 property variant scaledBounds: svgRenderer.scaledElementBounds("pfd/pfd.svg", "pitch-window-terrain")
114 x: Math.floor(scaledBounds.x * sceneItem.width)
115 y: Math.floor(scaledBounds.y * sceneItem.height) - osgViewport.y
116 width: Math.floor(scaledBounds.width * sceneItem.width)
117 height: Math.floor(scaledBounds.height * sceneItem.height)
119 rotation: -UAV.attitudeRoll()
120 transformOrigin: Item.Center
127 elementName: "pitch-scale"
129 //worldView is loaded with Loader, so background element is visible
130 sceneSize: background.sceneSize
131 anchors.centerIn: parent
132 //see comment for world transform
133 anchors.verticalCenterOffset: attitudeState.pitch * world.pitch1DegHeight
134 border: 64 // sometimes numbers are excluded from bounding rect
141 elementName: "center-line"
145 // worldView is loaded with Loader, so background element is visible
146 sceneSize: background.sceneSize
147 anchors.centerIn: parent
149 anchors.verticalCenterOffset: UAV.attitudePitch() * world.pitch1DegHeight
156 elementName: "pitch0"
158 sceneSize: background.sceneSize
159 anchors.centerIn: parent
160 anchors.verticalCenterOffset: UAV.attitudePitch() * world.pitch1DegHeight