d5bf0b8a15aef831772e80c3b6506228966e6e88
[mardrone] / mardrone / ardrone_desktop.qml
1 // uiName:Desktop
2 import Drone 1.0
3 import QtQuick 1.0
4 import QtDesktop 0.1
5 import Gauges 1.0
6 import JoyStick 1.0
7
8 Window {
9     title: "MArdrone"
10     id:mainWindow
11     width: 700
12     height: 800
13     maximumHeight: mainWindow.height
14     minimumHeight: 800
15     maximumWidth: 1280
16     minimumWidth: 700
17     visible: true
18
19
20     MenuBar {
21         Menu {
22             text: "File"
23             MenuItem {
24                 text: "Settings"
25                 shortcut: "Ctrl+O"
26                 onTriggered: configDialog.visible = true
27             }
28             MenuItem {
29                 text: "Close"
30                 shortcut: "Ctrl+Q"
31                 onTriggered: Qt.quit()
32             }
33             MenuItem {
34                 text: "Record"
35                 shortcut: "Ctrl+R"
36                 onTriggered: Qt.quit()
37             }
38         }
39         Menu {
40             text: "Edit"
41             MenuItem {
42                 text: "Copy"
43             }
44             MenuItem {
45                 text: "Paste"
46             }
47         }
48     }
49
50
51   DroneControl {
52         id:drone
53     }
54   JoyStick {
55       id:js
56       onElevatorChanged:{if(drone.confUseJoyStick) drone.pitch=elevator;}
57       onAileronChanged: {if(drone.confUseJoyStick) drone.roll=aileron;}
58       onThrotleChanged: {if(drone.confUseJoyStick) drone.vVelocity=throtle;}
59       onRudderChanged:  {if(drone.confUseJoyStick) drone.yaw=rudder;}
60
61   }
62
63     Column {
64         width:parent.width
65      //   spacing:5
66       Rectangle {
67         id:mainWiew
68         width:parent.width
69         color:"black"
70         height:480
71         //onEntered:(mainWindow.fullscreen=true)
72
73         state:"Landscape"
74         DroneVideo {
75             id:droneVideo
76             y:0
77          //       anchors.horizontalCenter: parent.horizontalCenter
78          //   anchors.horizontalCenter:parent.horizontalCenter
79             width:drone.confFullScreen? parent.width:640 ;height:width<=640 ?480*width/640:480;
80         }
81         Binding {
82           target:drone
83           property:"logSeq"
84           value: droneVideo.frameSeq;
85         }
86         EfisPFD {
87             id:hudPDF
88             y:0
89    //         anchors.horizontalCenter: parent.horizontalCenter
90             visible:drone.confShowHorizon
91             roll:drone.droneRoll
92             pitch:drone.dronePitch
93             ias:drone.droneSpeed
94             alt:drone.droneAltitude/10
95             indicatorColor:"green"
96             skyColor:"#00000000"
97             groundColor:"#00000000"
98             width:640;height:480;
99         }
100         Text {
101             y:100
102             visible:drone.confShowDebug
103             color: "#00FF00"
104             id: droneCtrlValues
105             font.pixelSize:20
106             text: "cmd:pitch=" + drone.pitch.toFixed(2) + " roll= " +  drone.roll.toFixed(2) + " yaw=" + drone.yaw.toFixed(2) + " vv= " + drone.vVelocity.toFixed(2)
107         }
108
109         Text {
110             y:115
111             visible:drone.confShowDebug
112             color: "#00FF00"
113             id: droneNavData
114             font.pixelSize:20
115             text: "pitch=" + Math.round(drone.dronePitch) + " roll= " +  Math.round(drone.droneRoll) + "yaw=" + Math.round(drone.droneYaw) + " alt= " +  Math.round(drone.droneAltitude)
116         }
117
118         Text {
119             y:130
120             visible:drone.confShowDebug
121             color: "#00FF00"
122             id: droneStatus
123             font.pixelSize:20
124             text: drone.decodedStatus
125         }
126    /*     Button {
127             y:150;x:0
128             height: 50
129             width: 50
130             iconSource: "gear32x32.png"
131             onClicked:{   configDialog.visible = true }
132         }
133 */
134         JoyStickIndicator {
135
136             anchors.left:parent.left
137             anchors.bottom:parent.bottom
138             anchors.margins:10
139             visible:drone.confShowJSIndicators&js.haveJoyStick&drone.confUseJoyStick
140             border.width:1
141             color:"transparent"
142             width:100;height:100
143             xvalue:js.axis4
144             yvalue:js.axis3
145             Text {
146                 anchors.bottom: parent.bottom
147                 font.pixelSize: 10
148                 text:"       rudder"
149             }
150             Text {
151                 x:-10;y:50
152                 rotation:90
153                 font.pixelSize: 10
154                 text:"Throtle"
155             }
156         }
157
158
159         JoyStickIndicator {
160
161             anchors.right:parent.right
162             anchors.bottom:parent.bottom
163             anchors.margins:10
164             visible:drone.confShowJSIndicators&js.haveJoyStick&drone.confUseJoyStick
165             border.width:1
166             color:"transparent"
167             width:100;height:100
168             xvalue:js.axis1
169             yvalue:js.axis2
170             Text {
171                 anchors.bottom: parent.bottom
172                 font.pixelSize: 10
173                 text:"      Aileron"
174             }
175             Text {
176                 x:-15;y:50
177                 rotation:90
178                 font.pixelSize: 10
179                 text:"Elevator"
180             }
181         }
182
183             JoyStickTouch {
184                 id:lj
185                 width:280;height:280;
186                 y:200
187                 joyBackground: ""
188                 visible: !drone.confUseAccel & !drone.confUseJoyStick
189                 anchors.left:parent.left
190                 anchors.margins:50
191                 onYvChanged:{drone.pitch=yv/200.0;}
192                 onXvChanged:{drone.roll=xv/200.0;}
193
194
195             }
196
197             JoyStickTouch {
198                  visible: !drone.confUseJoyStick
199                 id:rj
200                 y:200
201                 joyBackground: ""
202                 anchors.right:parent.right
203                 width:280;height:280;
204                 anchors.margins:50
205                 onYvChanged:{drone.vVelocity=-1*yv/200.0;}
206                 onXvChanged:{drone.yaw=xv/200.0;}
207                 onPressedChanged: { drone.ctrlActive=pressed;}
208             }
209       }
210
211       Rectangle {
212           width:parent.width
213      //     width:chlidrenRect.width
214      //     height:childrenRect.height
215           height:320
216           color: "black"
217
218
219
220         Row {
221             id:instrumentPanel
222             spacing:5
223             anchors.fill:parent
224             anchors.margins:5
225
226             EfisPFD {
227                 id:pDF
228                 width:300
229                 height:320
230                 showHSI:true
231                 roll:drone.droneRoll
232                 pitch:drone.dronePitch
233                 ias:drone.droneSpeed
234                 alt:drone.droneAltitude/10
235            //     bezel:"glareshield1.png"
236             }
237         Grid {
238             columns: 3
239
240
241         AltGauge {
242             width:120
243             height:120
244             id:altGauge
245             value:drone.droneAltitude/10
246             bezel:"bezel.png"
247         }
248         AttitudeGauge {
249             width:120
250             height:120
251             id:attGauge
252             roll:drone.droneRoll
253             pitch:drone.dronePitch
254             bezel:"bezel.png"
255         }
256         Item {
257             width:120
258             height:120
259
260
261         GaugeArc {
262             anchors.fill:parent
263             id:speedGauge
264  //           anchors.margins:10
265             displayScale:0.95
266             font.pixelSize:10
267             tickIncrement:20
268             tickSpacing:24
269             tickMinor:5
270             lowPosition:220
271             highPosition:120
272             low:0
273             high:200
274             gaugeStyle:2
275             color:"white"
276             value:drone.droneSpeed
277             lineWidth:2
278             backColor:"black"
279         }
280         Image {
281             anchors.fill:parent
282             source:"bezel.png"
283         }
284         }
285
286         Item {
287             width:120
288             height:120
289
290
291         GaugeArc {
292             anchors.fill:parent
293             id:fuelGauge
294  //           anchors.margins:10
295             displayScale:0.95
296             font.pixelSize:10
297             tickIncrement:10
298             tickSpacing:22
299             tickMinor:5
300             lowPosition:240
301             highPosition:120
302             low:0
303             high:100
304             gaugeStyle:2
305             color:"white"
306             value:drone.droneVBat
307             lineWidth:2
308             backColor:"black"
309         }
310         Image {
311             anchors.fill:parent
312             source:"bezel.png"
313         }
314         }
315         Item {
316             width:120
317             height:120
318
319             HeadingGauge {
320                 width:120
321                 height:120
322                 id:hdgGauge
323                 value:drone.droneYaw
324                 bezel:"bezel.png"
325             }
326         }
327         Item {
328             width:120
329             height:120
330         Rectangle {
331             anchors.fill:parent
332             anchors.margins:5
333             color:"gray"
334             }
335         Row {
336             anchors.centerIn:parent
337             spacing: 5
338             anchors.margins: 30
339             height:90
340         BarGauge {
341            val:drone.pwm_motor1;
342            max: 255
343            height:parent.height
344            width:10
345         }
346         BarGauge {
347             val:drone.pwm_motor2;
348             max: 255
349            height:parent.height
350                      width:10
351         }
352         BarGauge {
353             val:drone.pwm_motor3;
354             max: 255
355             height:parent.height
356             width:10
357         }
358         BarGauge {
359             val:drone.pwm_motor4;
360             max: 255
361             height:parent.height
362              width:10
363         }
364         /*
365         BarGauge {
366             val:drone.droneVBat
367             max: 100
368             height:parent.height
369                       width:10
370         }
371         */
372         }
373         Image {
374             anchors.fill:parent
375             source:"bezel.png"
376         }
377         }
378         Button {
379
380             width:80
381             height:50
382             id:flyButton
383      //       anchors.bottom:parent.bottom
384             anchors.margins:15
385             text:"Fly";
386             checkable:true
387             onClicked:{drone.fly=checked;
388             // mainWindow.fullsecreen=checked;
389             }
390         }
391         Button {
392
393             width:90
394             height:50
395             id:emergencyButton
396          //   anchors.bottom:parent.bottom
397             anchors.margins:15
398             text:"Emrg";
399             checkable:true
400             onClicked:{drone.emergency=checked;}
401         }
402
403         Button {
404
405             width:100
406             height:50
407             id:recordButton
408        //     anchors.bottom:parent.bottom
409             anchors.margins:15
410             text:"Rec";
411             checkable:true
412             onClicked:{droneVideo.recVideo=checked; drone.logFileName=droneVideo.videoFileName; drone.recordLog=checked;}
413         }
414             } // Grid if instruments
415         }
416
417         } // Column ( Main window content )
418        }
419         Dialog {
420             id:configDialog
421             width:800
422             height:600
423             data:ConfigDialogDesktop {}
424         }
425
426   } // Main page
427
428