7import QGroundControl.Controls
9/// Marker for displaying a vehicle location on the map
13 property var vehicle /// Vehicle object, undefined for ADSB vehicle
15 property double altitude: Number.NaN ///< NAN to not show
16 property string callsign: "" ///< Vehicle callsign
17 property double heading: vehicle ? vehicle.heading.value : Number.NaN ///< Vehicle heading, NAN for none
18 property real size: ScreenTools.defaultFontPixelHeight * 3 /// Default size for icon, most usage overrides this
19 property bool alert: false /// Collision alert
21 anchorPoint.x: vehicleItem.width / 2
22 anchorPoint.y: vehicleItem.height / 2
23 visible: coordinate.isValid
25 property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
26 property bool _adsbVehicle: vehicle ? false : true
27 property var _map: map
28 property bool _multiVehicle: QGroundControl.multiVehicleManager.vehicles.count > 1
32 width: vehicleIcon.width
33 height: vehicleIcon.height
34 opacity: _adsbVehicle || vehicle === _activeVehicle ? 1.0 : 0.5
38 shadowEnabled: vehicleIcon.visible && _adsbVehicle
39 shadowColor: Qt.rgba(0.94,0.91,0,1.0)
40 shadowVerticalOffset: 4
41 shadowHorizontalOffset: 4
50 model: vehicle ? vehicle.gimbalController.gimbals : []
54 anchors.centerIn: vehicleItem
55 width: vehicleItem.width * 2
56 height: vehicleItem.height * 2
57 property var gimbalYaw: object.absoluteYaw.rawValue
58 rotation: gimbalYaw + 180
59 onGimbalYawChanged: canvas.requestPaint()
60 visible: vehicle && !isNaN(gimbalYaw) && QGroundControl.settingsManager.gimbalControllerSettings.showAzimuthIndicatorOnMap.rawValue
61 opacity: object === vehicle.gimbalController.activeGimbal ? 1.0 : 0.4
65 anchors.centerIn: canvasItem
66 anchors.verticalCenterOffset: vehicleItem.width
67 width: vehicleItem.width
68 height: vehicleItem.height
70 onPaint: paintHeading()
72 function paintHeading() {
73 var context = getContext("2d")
74 // console.log("painting heading " + object.param1Raw + " " + opacity + " " + visible + " " + _index)
75 context.clearRect(0, 0, vehicleIcon.width, vehicleIcon.height);
77 var centerX = canvas.width / 2;
78 var centerY = canvas.height / 2;
79 var length = canvas.height * 1.3
80 var width = canvas.width * 0.6
82 var point1 = [centerX - width , centerY + canvas.height * 0.6]
83 var point2 = [centerX, centerY - canvas.height * 0.5]
84 var point3 = [centerX + width , centerY + canvas.height * 0.6]
85 var point4 = [centerX, centerY + canvas.height * 0.2]
89 context.globalAlpha = 0.9;
91 context.moveTo(centerX, centerY + canvas.height * 0.2);
92 context.lineTo(point1[0], point1[1]);
93 context.lineTo(point2[0], point2[1]);
94 context.lineTo(point3[0], point3[1]);
95 context.lineTo(point4[0], point4[1]);
98 const gradient = context.createLinearGradient(canvas.width / 2, canvas.height , canvas.width / 2, 0);
99 gradient.addColorStop(0.3, Qt.rgba(255,255,255,0));
100 gradient.addColorStop(0.5, Qt.rgba(255,255,255,0.5));
101 gradient.addColorStop(1, qgcPal.mapIndicator);
103 context.fillStyle = gradient;
113 source: _adsbVehicle ? (alert ? "/qmlimages/AlertAircraft.svg" : "/qmlimages/AwarenessAircraft.svg") : vehicle.vehicleImageOpaque
116 sourceSize.width: _root.size
117 fillMode: Image.PreserveAspectFit
118 transform: Rotation {
119 origin.x: vehicleIcon.width / 2
120 origin.y: vehicleIcon.height / 2
121 angle: isNaN(heading) ? 0 : heading
127 anchors.top: parent.bottom
128 anchors.horizontalCenter: parent.horizontalCenter
130 text: vehicleLabelText
131 font.pointSize: _adsbVehicle ? ScreenTools.defaultFontPointSize : ScreenTools.smallFontPointSize
132 visible: _adsbVehicle ? !isNaN(altitude) : _multiVehicle
133 property string vehicleLabelText: visible ?
135 QGroundControl.unitsConversion.metersToAppSettingsVerticalDistanceUnits(altitude).toFixed(0) + " " + QGroundControl.unitsConversion.appSettingsHorizontalDistanceUnitsString + "\n" + callsign :
136 (_multiVehicle ? qsTr("Vehicle %1").arg(vehicle.id) : "")) :