QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
ADSBVehicleMapItem.qml
Go to the documentation of this file.
1import QtQuick
2import QtLocation
3import QtPositioning
4
5import QGroundControl
6import QGroundControl.Controls
7
8/// Marker for displaying an ADS-B vehicle location on the map
9MapQuickItem {
10 id: _root
11
12 property var map
13 property double altitude: Number.NaN ///< NAN to not show
14 property string callsign: "" ///< Vehicle callsign
15 property double heading: Number.NaN ///< Vehicle heading, NAN for none
16 property real size: ScreenTools.defaultFontPixelHeight * 3
17 property bool alert: false ///< Collision alert
18
19 anchorPoint.x: vehicleItem.width / 2
20 anchorPoint.y: vehicleItem.height / 2
21 visible: coordinate.isValid
22
23 function _labelText() {
24 return isNaN(altitude) ? "" : QGroundControl.unitsConversion.metersToAppSettingsVerticalDistanceUnitsString(altitude, 0) + "\n" + callsign
25 }
26
27 sourceItem: Item {
28 id: vehicleItem
29 width: vehicleIcon.width
30 height: vehicleIcon.height
31
32 Image {
33 id: vehicleIcon
34 source: alert ? "/qmlimages/AlertAircraft.svg" : "/qmlimages/AwarenessAircraft.svg"
35 mipmap: true
36 width: _root.size
37 sourceSize.width: _root.size
38 fillMode: Image.PreserveAspectFit
39 transform: Rotation {
40 origin.x: vehicleIcon.width / 2
41 origin.y: vehicleIcon.height / 2
42 angle: isNaN(heading) ? 0 : heading
43 }
44 }
45
46 QGCMapLabel {
47 id: altitudeLabel
48 objectName: "adsbAltitudeLabel"
49 anchors.top: parent.bottom
50 anchors.horizontalCenter: parent.horizontalCenter
51 map: _root.map
52 font.pointSize: ScreenTools.defaultFontPointSize
53 visible: !isNaN(altitude)
54 text: _labelText()
55 }
56 }
57
58 Connections {
59 target: QGroundControl.unitsConversion
60
61 function onUnitsChanged() {
62 altitudeLabel.text = Qt.binding(_labelText)
63 }
64 }
65}