QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
CameraCalcCamera.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5import QGroundControl
6import QGroundControl.Controls
7import QGroundControl.FactControls
8
9// Camera calculator "Camera" section for mission item editors
10ColumnLayout {
11 spacing: _margin
12
13 property var cameraCalc
14
15 property real _margin: ScreenTools.defaultFontPixelWidth / 2
16 property real _fieldWidth: ScreenTools.defaultFontPixelWidth * 10.5
17 property var _vehicle: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle : QGroundControl.multiVehicleManager.offlineEditingVehicle
18
19 Component.onCompleted: {
20 cameraBrandCombo.selectCurrentBrand()
21 cameraModelCombo.selectCurrentModel()
22 }
23
24 QGCPalette { id: qgcPal; colorGroupEnabled: true }
25
26 ColumnLayout {
27 Layout.fillWidth: true
28 spacing: _margin
29
30 QGCComboBox {
31 id: cameraBrandCombo
32 Layout.fillWidth: true
33 model: cameraCalc.cameraBrandList
34 onModelChanged: selectCurrentBrand()
35 onActivated: (index) => { cameraCalc.cameraBrand = currentText }
36
37 Connections {
38 target: cameraCalc
39 function onCameraBrandChanged() { cameraBrandCombo.selectCurrentBrand() }
40 }
41
42 function selectCurrentBrand() {
43 currentIndex = cameraBrandCombo.find(cameraCalc.cameraBrand)
44 }
45 }
46
47 QGCComboBox {
48 id: cameraModelCombo
49 Layout.fillWidth: true
50 model: cameraCalc.cameraModelList
51 visible: !cameraCalc.isManualCamera && !cameraCalc.isCustomCamera
52 onModelChanged: selectCurrentModel()
53 onActivated: (index) => { cameraCalc.cameraModel = currentText }
54
55 Connections {
56 target: cameraCalc
57 function onCameraModelChanged() { cameraModelCombo.selectCurrentModel() }
58 }
59
60 function selectCurrentModel() {
61 currentIndex = cameraModelCombo.find(cameraCalc.cameraModel)
62 }
63 }
64
65 // Camera based grid ui
66 ColumnLayout {
67 Layout.fillWidth: true
68 spacing: _margin
69 visible: !cameraCalc.isManualCamera
70
71 RowLayout {
72 Layout.alignment: Qt.AlignHCenter
73 spacing: _margin
74 visible: !cameraCalc.fixedOrientation.value
75
76 QGCRadioButton {
77 width: _editFieldWidth
78 text: "Landscape"
79 checked: !!cameraCalc.landscape.value
80 onClicked: cameraCalc.landscape.value = 1
81 }
82
83 QGCRadioButton {
84 id: cameraOrientationPortrait
85 text: "Portrait"
86 checked: !cameraCalc.landscape.value
87 onClicked: cameraCalc.landscape.value = 0
88 }
89 }
90
91 // Custom camera specs
92 ColumnLayout {
93 id: custCameraCol
94 Layout.fillWidth: true
95 spacing: _margin
96 enabled: cameraCalc.isCustomCamera
97
98 RowLayout {
99 Layout.fillWidth: true
100 spacing: _margin
101
102 Item { Layout.fillWidth: true }
103 QGCLabel {
104 Layout.preferredWidth: _root._fieldWidth
105 text: qsTr("Width")
106 }
107 QGCLabel {
108 Layout.preferredWidth: _root._fieldWidth
109 text: qsTr("Height")
110 }
111 }
112
113 RowLayout {
114 Layout.fillWidth: true
115 spacing: _margin
116
117 QGCLabel { text: qsTr("Sensor"); Layout.fillWidth: true }
118 FactTextField {
119 Layout.preferredWidth: _root._fieldWidth
120 fact: cameraCalc.sensorWidth
121 }
122 FactTextField {
123 Layout.preferredWidth: _root._fieldWidth
124 fact: cameraCalc.sensorHeight
125 }
126 }
127
128 RowLayout {
129 Layout.fillWidth: true
130 spacing: _margin
131
132 QGCLabel { text: qsTr("Image"); Layout.fillWidth: true }
133 FactTextField {
134 Layout.preferredWidth: _root._fieldWidth
135 fact: cameraCalc.imageWidth
136 }
137 FactTextField {
138 Layout.preferredWidth: _root._fieldWidth
139 fact: cameraCalc.imageHeight
140 }
141 }
142
143 RowLayout {
144 Layout.fillWidth: true
145 spacing: _margin
146 QGCLabel {
147 text: qsTr("Focal length")
148 Layout.fillWidth: true
149 }
150 FactTextField {
151 Layout.preferredWidth: _root._fieldWidth
152 fact: cameraCalc.focalLength
153 }
154 }
155 }
156 }
157 }
158}