QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
ProximityRadarVideoView.qml
Go to the documentation of this file.
1import QtQuick
2import QtLocation
3import QtPositioning
4
5import QGroundControl
6import QGroundControl.Controls
7import QGroundControl.FlyView
8
9Item {
10 id: _root
11 anchors.fill: parent
12 visible: proximityValues.telemetryAvailable
13
14 property var vehicle ///< Vehicle object, undefined for ADSB vehicle
15 property real range: 6 ///< Default 6m view
16
17 property var _minlength: Math.min(_root.width,_root.height)
18 property var _ratio: (_minlength / 2) / _root.range
19
20 ProximityRadarValues {
21 id: proximityValues
22 vehicle: _root.vehicle
23 onRotationValueChanged: _sectorViewEllipsoid.requestPaint()
24 }
25
26 Canvas{
27 id: _sectorViewEllipsoid
28 anchors.fill: _root
29 opacity: 0.5
30
31 onPaint: {
32 var ctx = getContext("2d");
33 ctx.reset();
34 ctx.translate(width/2, height/2)
35 ctx.strokeStyle = Qt.rgba(1, 0, 0, 1);
36 ctx.lineWidth = width/100;
37 ctx.scale(_root.width / _minlength, _root.height / _minlength);
38 ctx.rotate(-Math.PI/2 - Math.PI/8);
39 for (var i=0; i<proximityValues.rgRotationValues.length; i++) {
40 var rotationValue = proximityValues.rgRotationValues[i]
41 if (!isNaN(rotationValue)) {
42 var a=Math.PI/4 * i;
43 ctx.beginPath();
44 ctx.arc(0, 0, rotationValue * _ratio, 0 + a + Math.PI/50, Math.PI/4 + a - Math.PI/50, false);
45 ctx.stroke();
46 }
47 }
48 }
49 }
50
51 Item {
52 anchors.fill: parent
53
54 Repeater{
55 model: proximityValues.rgRotationValues.length
56
57 QGCLabel{
58 x: (_sectorViewEllipsoid.width / 2) - (width / 2)
59 y: (_sectorViewEllipsoid.height / 2) - (height / 2)
60 text: proximityValues.rgRotationValueStrings[index]
61 font.bold: true
62 visible: !isNaN(proximityValues.rgRotationValues[index])
63
64 transform: Translate {
65 x: Math.cos(-Math.PI/2 + Math.PI/4 * index) * (proximityValues.rgRotationValues[index] * _ratio)
66 y: Math.sin(-Math.PI/2 + Math.PI/4 * index) * (proximityValues.rgRotationValues[index] * _ratio)
67 }
68 }
69 }
70 transform: Scale {
71 origin.x: _sectorViewEllipsoid.width / 2
72 origin.y: _sectorViewEllipsoid.height / 2
73 xScale: _root.width / _minlength
74 yScale: _root.height / _minlength
75 }
76 }
77
78}