QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
PlanMapItems.qml
Go to the documentation of this file.
1import QtQuick
2import QtLocation
3import QtPositioning
4
5import QGroundControl
6import QGroundControl.Controls
7import QGroundControl.FlightMap
8import QGroundControl.PlanView
9
10// Adds visual items associated with the Flight Plan to the map.
11// Currently only used by Fly View even though it's called PlanMapItems!
12Item {
13 id: _root
14
15 property var map ///< Map control to show items on
16 property bool largeMapView ///< true: map takes up entire view, false: map is in small window
17 property var planMasterController ///< Reference to PlanMasterController for vehicle
18 property var vehicle ///< Vehicle associated with these items
19
20 property var _map: map
21 property var _vehicle: vehicle
22 property var _missionController: planMasterController.missionController
23 property var _geoFenceController: planMasterController.geoFenceController
24 property var _rallyPointController: planMasterController.rallyPointController
25 property var _guidedController: globals.guidedControllerFlyView
26 property var _missionLineViewComponent
27
28 property string fmode: vehicle.flightMode
29
30 MissionItemIndicatorGroup {
31 id: _missionItemIndicatorGroup
32
33 map: _root._map
34 missionItems: _root.largeMapView ? _root._missionController.visualItems : null
35 onItemSelected: (sequenceNumber) => {
36 _root._guidedController.confirmAction(_root._guidedController.actionSetWaypoint, Math.max(sequenceNumber, 1))
37 }
38 }
39
40 // Add the mission item visuals to the map
41 Repeater {
42 model: largeMapView ? _missionController.visualItems : 0
43
44 delegate: MissionItemMapVisual {
45 map: _map
46 vehicle: _vehicle
47 indicatorGroup: _missionItemIndicatorGroup
48 onClicked: _guidedController.confirmAction(_guidedController.actionSetWaypoint, Math.max(object.sequenceNumber, 1))
49 }
50 }
51
52 Component.onCompleted: {
53 _missionLineViewComponent = missionLineViewComponent.createObject(map)
54 if (_missionLineViewComponent.status === Component.Error)
55 console.log(_missionLineViewComponent.errorString())
56 map.addMapItemGroup(_missionLineViewComponent)
57 }
58
59 Component.onDestruction: {
60 if (_missionLineViewComponent) {
61 // Must remove MapItemGroup before destruction, otherwise we crash on quit
62 map.removeMapItemGroup(_missionLineViewComponent)
63 _missionLineViewComponent.destroy()
64 }
65 }
66
67 Component {
68 id: missionLineViewComponent
69
70 MapItemGroup {
71 MissionLineView {
72 model: _missionController.simpleFlightPathSegments
73 }
74
75 MapItemView {
76 model: _missionController.directionArrows
77
78 delegate: MapLineArrow {
79 fromCoord: object ? object.coordinate1 : undefined
80 toCoord: object ? object.coordinate2 : undefined
81 arrowPosition: 3
82 mapControl: _root.map
83 z: QGroundControl.zOrderWaypointLines + 1
84 }
85 }
86 }
87 }
88}