QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
FenceInspector.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Layouts
3import QtPositioning
4
5import QGroundControl
6import QGroundControl.Controls
7import QGroundControl.FactControls
8
9/// Inspector of the selected fence or the breach return point
10Item {
11 id: root
12
13 required property var page
14 property bool drillIn: false
15
16 signal backRequested
17
18 readonly property string _kind: page.selectedKind
19 readonly property var _fence: page.selectedObject
20 readonly property var _controller: page.controller
21
22 QGCPalette { id: qgcPal }
23
24 Fact { id: emptyFact }
25
26 ColumnLayout {
27 anchors.fill: parent
28 anchors.margins: ScreenTools.defaultFontPixelWidth / 2
29 spacing: ScreenTools.defaultFontPixelHeight * 0.5
30
31 PlanInspectorHeader {
32 Layout.fillWidth: true
33 namePrefix: "planPanel_fenceInspector"
34 drillIn: root.drillIn
35 deletable: root._kind !== "breach"
36 canStepPrevious: root.page.selectedEntryIndex > 0
37 canStepNext: root.page.selectedEntryIndex >= 0 && root.page.selectedEntryIndex < root.page.entries.length - 1
38 title: {
39 switch (root._kind) {
40 case "polygon":
41 return qsTr("Polygon %1").arg(root.page.selectedIndex + 1)
42 case "circle":
43 return qsTr("Circle %1").arg(root.page.selectedIndex + 1)
44 case "breach":
45 return qsTr("Breach return point")
46 }
47 return ""
48 }
49
50 onBackRequested: root.backRequested()
51 onPreviousRequested: root.page.step(-1)
52 onNextRequested: root.page.step(1)
53 onDeleteRequested: {
54 if (mainWindow.allowViewSwitch()) {
55 root.page.deleteSelected()
56 }
57 }
58 }
59
60 QGCFlickable {
61 id: flickable
62
63 Layout.fillWidth: true
64 Layout.fillHeight: true
65 contentHeight: bodyColumn.height
66 clip: true
67
68 ColumnLayout {
69 id: bodyColumn
70
71 width: flickable.width
72 spacing: ScreenTools.defaultFontPixelHeight * 0.5
73
74 QGCRadioButtonBar {
75 objectName: "planPanel_fenceInclusion"
76 model: [ qsTr("Include"), qsTr("Exclude") ]
77 currentIndex: root._fence && root._fence.inclusion ? 0 : 1
78 visible: root._kind === "polygon" || root._kind === "circle"
79
80 onActivated: (index) => {
81 if (root._fence) {
82 root._fence.inclusion = index === 0
83 }
84 }
85 }
86
87 QGCLabel {
88 objectName: "planPanel_fenceHint"
89 Layout.fillWidth: true
90 visible: root._kind === "polygon" || root._kind === "circle"
91 wrapMode: Text.WordWrap
92 color: qgcPal.textSecondary
93 font.pointSize: ScreenTools.smallFontPointSize
94 text: root._kind === "polygon" ?
95 qsTr("Drag the vertices on the map to reshape the fence.") :
96 qsTr("Drag the center on the map to move the fence.")
97 }
98
99 Loader {
100 Layout.fillWidth: true
101 active: root._kind === "circle" && root._fence !== null
102
103 sourceComponent: LabelledFactTextField {
104 objectName: "planPanel_fenceRadius"
105 label: qsTr("Radius")
106 // The selection can change to a fence without a radius before this field is torn down
107 fact: root._fence && root._fence.radius ? root._fence.radius : emptyFact
108 }
109 }
110
111 QGCLabel {
112 Layout.fillWidth: true
113 visible: root._kind === "breach"
114 wrapMode: Text.WordWrap
115 color: qgcPal.textSecondary
116 font.pointSize: ScreenTools.smallFontPointSize
117 text: qsTr("Optional point the vehicle flies to after a fence breach.")
118 }
119
120 LabelledFactTextField {
121 objectName: "planPanel_fenceBreachAltitude"
122 Layout.fillWidth: true
123 label: qsTr("Altitude")
124 fact: root._controller.breachReturnAltitude
125 visible: root._kind === "breach" && root._controller.breachReturnPoint.isValid
126 }
127
128 QGCButton {
129 objectName: "planPanel_fenceBreachToggle"
130 Layout.fillWidth: true
131 visible: root._kind === "breach"
132 text: root._controller.breachReturnPoint.isValid ? qsTr("Remove breach return point") : qsTr("Set at map center")
133
134 onClicked: {
135 if (!mainWindow.allowViewSwitch()) {
136 return
137 }
138 if (root._controller.breachReturnPoint.isValid) {
139 root._controller.breachReturnPoint = QtPositioning.coordinate()
140 } else {
141 root._controller.breachReturnPoint = root.page.editorMap.center
142 }
143 }
144 }
145 }
146 }
147 }
148}