QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
SensorsCalibrationStage.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5import QGroundControl
6import QGroundControl.Controls
7
8import "PX4SensorsOrientation.js" as Orientation
9
10/// The large picture of the vehicle on the side to calibrate next, or on the side it is on now.
11Rectangle {
12 id: control
13
14 property string side: "level"
15 /// The vehicle is being turned on this side, so the picture shows the turn
16 property bool rotating: false
17 /// What to do with the vehicle now, shown with a busy indicator. Empty when there is nothing to do.
18 property string instruction: ""
19 property bool active: false
20 property string tag: ""
21 property string caption: ""
22 /// "ok" or "error" draws that mark over the picture
23 property string mark: ""
24 /// "multiRotor", "fixedWing", "vtol", "rover" or anything else for a flat board
25 property string vehicleKind: ""
26
27 objectName: "sensorsCal_stage"
28 implicitWidth: ScreenTools.defaultFontPixelWidth * 50
29 implicitHeight: ScreenTools.defaultFontPixelHeight * 19
30 radius: ScreenTools.defaultBorderRadius * 2
31 color: active ? qgcPal.accentSubtle : qgcPal.windowCard
32 border.color: mark === "ok" ? qgcPal.colorGreen : mark === "error" ? qgcPal.colorRed : active ? qgcPal.accent : qgcPal.borderSubtle
33
34 QGCPalette { id: qgcPal }
35
36 QGCChip {
37 anchors.left: parent.left
38 anchors.top: parent.top
39 anchors.margins: ScreenTools.defaultFontPixelWidth
40 text: control.tag
41 textColor: qgcPal.accent
42 visible: control.tag !== ""
43 }
44
45 BusyIndicator {
46 anchors.right: parent.right
47 anchors.top: parent.top
48 anchors.margins: ScreenTools.defaultFontPixelWidth
49 running: visible
50 visible: control.instruction !== ""
51 implicitWidth: ScreenTools.defaultFontPixelHeight * 1.5
52 implicitHeight: implicitWidth
53 }
54
55 ColumnLayout {
56 anchors.fill: parent
57 anchors.margins: ScreenTools.defaultFontPixelWidth
58 spacing: ScreenTools.defaultFontPixelHeight * 0.25
59
60 // Qt Quick 3D needs a GPU renderer. Without one the still pictures are shown instead.
61 Loader {
62 id: picture
63 Layout.fillWidth: true
64 Layout.fillHeight: true
65 opacity: control.mark === "" ? 1 : 0.3
66 sourceComponent: {
67 switch (GraphicsInfo.api) {
68 case GraphicsInfo.Unknown:
69 return null
70 case GraphicsInfo.Software:
71 return stillPicture
72 }
73 return vehicleView
74 }
75 }
76
77 Component {
78 id: vehicleView
79
80 SensorsVehicleView {
81 side: control.side
82 rotating: control.rotating
83 vehicleKind: control.vehicleKind
84 }
85 }
86
87 Component {
88 id: stillPicture
89
90 Image {
91 source: Orientation.imageSource(control.side, control.rotating)
92 fillMode: Image.PreserveAspectFit
93 }
94 }
95
96 QGCLabel {
97 Layout.alignment: Qt.AlignHCenter
98 text: control.instruction !== "" ? qsTr("%1 - %2").arg(control.caption).arg(control.instruction) : control.caption
99 font.pointSize: ScreenTools.mediumFontPointSize
100 font.bold: true
101 }
102 }
103
104 Rectangle {
105 anchors.centerIn: parent
106 implicitWidth: ScreenTools.defaultFontPixelHeight * 5
107 implicitHeight: implicitWidth
108 radius: implicitWidth / 2
109 color: control.mark === "ok" ? qgcPal.colorGreen : qgcPal.colorRed
110 visible: control.mark !== ""
111
112 QGCLabel {
113 anchors.centerIn: parent
114 text: control.mark === "ok" ? "✓" : "!"
115 font.pointSize: ScreenTools.largeFontPointSize
116 font.bold: true
117 color: qgcPal.window
118 }
119 }
120}