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
46 //incrementalCompile: true
52 logarithmicDepthBuffer: true
55 OSGGeoTransformManipulator {
56 id: geoTransformManipulator
58 sceneNode: terrainFileNode
61 attitude: UAV.attitude()
62 position: UAV.position()
67 sceneNode: terrainFileNode
69 dateTime: Utils.getDateTime()
70 minimumAmbientLight: pfdContext.minimumAmbientLight
75 source: pfdContext.terrainFile
80 // using rectangle instead of svg rendered to pixmap
81 // as it's much more memory efficient
86 property variant scaledBounds: svgRenderer.scaledElementBounds("pfd/pfd.svg", "horizon")
87 width: Math.round(sceneItem.width * scaledBounds.width / 2) * 2
88 height: Math.round(sceneItem.height * scaledBounds.height / 2) * 3
90 property double pitch1DegScaledHeight: (svgRenderer.scaledElementBounds("pfd/pfd.svg", "pitch-90").y -
91 svgRenderer.scaledElementBounds("pfd/pfd.svg", "pitch90").y) / 180.0
93 property double pitch1DegHeight: sceneItem.height * pitch1DegScaledHeight
98 x: Math.round((world.parent.width - world.width)/2)
99 // y is centered around world_center element
100 y: Math.round(horizontCenter - world.height / 2 + UAV.attitudePitch() * world.pitch1DegHeight)
103 angle: -UAV.attitudeRoll()
104 origin.x : world.parent.width / 2
105 origin.y : horizontCenter
113 property variant scaledBounds: svgRenderer.scaledElementBounds("pfd/pfd.svg", "pitch-window-terrain")
115 x: Math.floor(scaledBounds.x * sceneItem.width)
116 y: Math.floor(scaledBounds.y * sceneItem.height) - osgViewport.y
117 width: Math.floor(scaledBounds.width * sceneItem.width)
118 height: Math.floor(scaledBounds.height * sceneItem.height)
120 rotation: -UAV.attitudeRoll()
121 transformOrigin: Item.Center
128 elementName: "pitch-scale"
130 //worldView is loaded with Loader, so background element is visible
131 sceneSize: background.sceneSize
132 anchors.centerIn: parent
133 //see comment for world transform
134 anchors.verticalCenterOffset: attitudeState.pitch * world.pitch1DegHeight
135 border: 64 // sometimes numbers are excluded from bounding rect
142 elementName: "center-line"
146 // worldView is loaded with Loader, so background element is visible
147 sceneSize: background.sceneSize
148 anchors.centerIn: parent
150 anchors.verticalCenterOffset: UAV.attitudePitch() * world.pitch1DegHeight
157 elementName: "pitch0"
159 sceneSize: background.sceneSize
160 anchors.centerIn: parent
161 anchors.verticalCenterOffset: UAV.attitudePitch() * world.pitch1DegHeight