6import QGroundControl.Controls
7import QGroundControl.FlyView
11 visible: proximityValues.telemetryAvailable && coordinate.isValid
13 property var vehicle /// Vehicle object, undefined for ADSB vehicle
15 property double heading: vehicle ? vehicle.heading.value : Number.NaN ///< Vehicle heading, NAN for none
17 anchorPoint.x: vehicleItem.width / 2
18 anchorPoint.y: vehicleItem.height / 2
20 property real _ratio: 1
21 property real _maxDistance: isNaN(proximityValues.maxDistance)
24 var scaleLinePixelLength = 100
25 var leftCoord = map.toCoordinate(Qt.point(0, 0), false /* clipToViewPort */)
26 var rightCoord = map.toCoordinate(Qt.point(scaleLinePixelLength, 0), false /* clipToViewPort */)
27 var scaleLineMeters = Math.round(leftCoord.distanceTo(rightCoord))
28 _ratio = scaleLinePixelLength / scaleLineMeters;
31 ProximityRadarValues {
33 vehicle: _root.vehicle
34 onRotationValueChanged: vehicleSensors.requestPaint()
39 function onWidthChanged() { scaleTimer.restart() }
40 function onHeightChanged() { scaleTimer.restart() }
41 function onZoomLevelChanged() { scaleTimer.restart() }
49 onTriggered: calcSize()
54 width: detectionLimitCircle.width
55 height: detectionLimitCircle.height
58 Component.onCompleted: calcSize()
62 anchors.fill: detectionLimitCircle
65 origin.x: detectionLimitCircle.width / 2
66 origin.y: detectionLimitCircle.height / 2
67 angle: isNaN(heading) ? 0 : heading
70 function deg2rad(degrees) {
72 return degrees * (pi/180);
76 var ctx = getContext("2d");
78 ctx.translate(width/2, height/2)
79 ctx.rotate(-Math.PI/2);
81 ctx.strokeStyle = Qt.rgba(1, 0, 0, 1);
82 for(var i=0; i<proximityValues.rgRotationValues.length; i++){
83 var rotationValue = proximityValues.rgRotationValues[i]
84 if (!isNaN(rotationValue)) {
85 var a=deg2rad(360-22.5)+Math.PI/4*i;
87 ctx.arc(0, 0, rotationValue * _ratio, a, a + Math.PI/4,false);
95 id: detectionLimitCircle
96 width: proximityValues.maxDistance * 2 *_ratio
97 height: proximityValues.maxDistance * 2 *_ratio
98 anchors.fill: detectionLimitCircle
99 color: Qt.rgba(1,1,1,0)
100 border.color: Qt.rgba(1,1,1,1)
104 transform: Rotation {
105 origin.x: detectionLimitCircle.width / 2
106 origin.y: detectionLimitCircle.height / 2
107 angle: isNaN(heading) ? 0 : heading