QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
TerrainStatus.qml
Go to the documentation of this file.
1import QtQuick
2import QtCharts
3
4import QGroundControl
5import QGroundControl.Controls
6
7Rectangle {
8 id: root
9 radius: ScreenTools.defaultFontPixelWidth * 0.5
10 color: qgcPal.window
11 opacity: 0.80
12 clip: true
13
14 property var missionController
15
16 signal setCurrentSeqNum(int seqNum)
17
18 property real _margins: ScreenTools.defaultFontPixelWidth / 2
19 property var _visualItems: missionController.visualItems
20 property real _altRange: _maxAMSLAltitude - _minAMSLAltitude
21 property real _indicatorSpacing: 5
22 property real _minAMSLAltitude: isNaN(terrainProfile.minAMSLAlt) ? 0 : terrainProfile.minAMSLAlt
23 property real _maxAMSLAltitude: isNaN(terrainProfile.maxAMSLAlt) ? 100 : terrainProfile.maxAMSLAlt
24 property real _missionTotalDistance: isNaN(missionController.missionTotalDistance) ? 100 : missionController.missionTotalDistance
25 property var _unitsConversion: QGroundControl.unitsConversion
26
27 QGCPalette { id: qgcPal }
28
29 QGCLabel {
30 id: titleLabel
31 anchors.top: parent.bottom
32 width: parent.height
33 font.pointSize: ScreenTools.smallFontPointSize
34 text: qsTr("Height AMSL (%1)").arg(_unitsConversion.appSettingsVerticalDistanceUnitsString)
35 horizontalAlignment: Text.AlignHCenter
36 rotation: -90
37 transformOrigin: Item.TopLeft
38 }
39
40 QGCFlickable {
41 id: terrainProfileFlickable
42 anchors.top: parent.top
43 anchors.bottom: parent.bottom
44 anchors.leftMargin: titleLabel.contentHeight
45 anchors.left: parent.left
46 anchors.right: parent.right
47 clip: true
48
49 Item {
50 height: terrainProfileFlickable.height
51 width: terrainProfileFlickable.width
52
53 ChartView {
54 id: chart
55 anchors.fill: parent
56 margins.top: 0
57 margins.right: 0
58 margins.bottom: 0
59 margins.left: 0
60 backgroundColor: "transparent"
61 legend.visible: false
62 antialiasing: true
63
64 ValueAxis {
65 id: axisX
66 min: 0
67 max: _unitsConversion.metersToAppSettingsHorizontalDistanceUnits(missionController.missionTotalDistance)
68 lineVisible: true
69 labelsFont.family: ScreenTools.fixedFontFamily
70 labelsFont.pointSize: ScreenTools.smallFontPointSize
71 labelsColor: qgcPal.text
72 tickCount: 5
73 gridLineColor: applyOpacity(qgcPal.text, 0.25)
74 }
75
76 ValueAxis {
77 id: axisY
78 min: _unitsConversion.metersToAppSettingsVerticalDistanceUnits(_minAMSLAltitude)
79 max: _unitsConversion.metersToAppSettingsVerticalDistanceUnits(_maxAMSLAltitude)
80 lineVisible: true
81 labelsFont.family: ScreenTools.fixedFontFamily
82 labelsFont.pointSize: ScreenTools.smallFontPointSize
83 labelsColor: qgcPal.text
84 tickCount: 4
85 gridLineColor: applyOpacity(qgcPal.text, 0.25)
86 }
87
88 LineSeries {
89 id: lineSeries
90 axisX: axisX
91 axisY: axisY
92 visible: true
93
94 XYPoint { x: 0; y: _unitsConversion.metersToAppSettingsVerticalDistanceUnits(_minAMSLAltitude) }
95 XYPoint { x: _unitsConversion.metersToAppSettingsHorizontalDistanceUnits(_missionTotalDistance); y: _unitsConversion.metersToAppSettingsVerticalDistanceUnits(_maxAMSLAltitude) }
96 }
97 }
98
99 TerrainProfile {
100 id: terrainProfile
101 x: chart.plotArea.x
102 y: chart.plotArea.y
103 height: chart.plotArea.height
104 visibleWidth: chart.plotArea.width
105 missionController: root.missionController
106
107 Repeater {
108 model: missionController.visualItems
109
110 Item {
111 id: topLevelItem
112 anchors.fill: parent
113 visible: object.specifiesCoordinate && !object.standaloneCoordinate
114
115 Rectangle {
116 id: simpleItem
117 height: terrainProfile.height
118 width: 1
119 color: qgcPal.text
120 x: (object.distanceFromStart * terrainProfile.pixelsPerMeter)
121 visible: object.isSimpleItem || object.isSingleItem
122
123 MissionItemIndexLabel {
124 anchors.horizontalCenter: parent.horizontalCenter
125 anchors.bottom: parent.bottom
126 small: true
127 checked: object.isCurrentItem
128 label: object.abbreviation.charAt(0)
129 index: object.abbreviation.charAt(0) > 'A' && object.abbreviation.charAt(0) < 'z' ? -1 : object.sequenceNumber
130 onClicked: root.setCurrentSeqNum(object.sequenceNumber)
131 }
132 }
133
134 Rectangle {
135 id: complexItemEntry
136 height: terrainProfile.height
137 width: 1
138 color: qgcPal.text
139 x: (object.distanceFromStart * terrainProfile.pixelsPerMeter)
140 visible: complexItem.visible
141
142 MissionItemIndexLabel {
143 anchors.horizontalCenter: parent.horizontalCenter
144 anchors.bottom: parent.bottom
145 small: true
146 checked: object.isCurrentItem
147 index: object.sequenceNumber
148 onClicked: root.setCurrentSeqNum(object.sequenceNumber)
149 }
150 }
151
152 Rectangle {
153 id: complexItemExit
154 height: terrainProfile.height
155 width: 1
156 color: qgcPal.text
157 x: ((object.distanceFromStart + object.complexDistance) * terrainProfile.pixelsPerMeter)
158 visible: complexItem.visible
159
160 MissionItemIndexLabel {
161 anchors.horizontalCenter: parent.horizontalCenter
162 anchors.bottom: parent.bottom
163 small: true
164 checked: object.isCurrentItem
165 index: object.lastSequenceNumber
166 onClicked: root.setCurrentSeqNum(object.sequenceNumber)
167 }
168 }
169
170 Rectangle {
171 id: complexItem
172 anchors.bottom: parent.bottom
173 x: (object.distanceFromStart * terrainProfile.pixelsPerMeter)
174 width: complexItem.visible ? object.complexDistance * terrainProfile.pixelsPerMeter : 0
175 height: patternNameLabel.height
176 color: "green"
177 opacity: 0.5
178 visible: !object.isSimpleItem && !object.isSingleItem
179
180 QGCMouseArea {
181 anchors.fill: parent
182 onClicked: root.setCurrentSeqNum(object.sequenceNumber)
183 }
184
185 QGCLabel {
186 id: patternNameLabel
187 anchors.horizontalCenter: parent.horizontalCenter
188 text: complexItem.visible ? object.patternName : ""
189 }
190 }
191 }
192 }
193 }
194 }
195 }
196
197 function applyOpacity(colorIn, opacity){
198 return Qt.rgba(colorIn.r, colorIn.g, colorIn.b, opacity)
199 }
200}