diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 2711db9d7fd3d069c753d16d56cae9ab12acf982..82b70a88178ee45b1f121acf5b9bf7aa1c81a27c 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -237,6 +237,7 @@ src/WimaView/WimaJoinedAreaDataVisual.qml src/Wima/Snake/WimaAreaNoVisual.qml src/WimaView/WimaMeasurementAreaDataVisual.qml + src/QmlControls/QGCButtonColumn.qml src/Settings/APMMavlinkStreamRate.SettingsGroup.json diff --git a/src/MissionManager/MissionController.cc b/src/MissionManager/MissionController.cc index 1907b83cab884e55c4e43492007ef5e7c1d61d6a..863d8953c44556fce8388c991474fdd4fa62fe88 100644 --- a/src/MissionManager/MissionController.cc +++ b/src/MissionManager/MissionController.cc @@ -2440,6 +2440,8 @@ QStringList MissionController::complexMissionItemNames(void) const { complexItems.append(_surveyMissionItemName); complexItems.append(patternCorridorScanName); + // Circular Survey not added here, as it can only be used together with + // WimaView. if (_controllerVehicle->fixedWing()) { complexItems.append(patternFWLandingName); } diff --git a/src/QmlControls/QGCButtonColumn.qml b/src/QmlControls/QGCButtonColumn.qml new file mode 100644 index 0000000000000000000000000000000000000000..1599dc8cb0fa93414a63b0c3d6e6386a981355f8 --- /dev/null +++ b/src/QmlControls/QGCButtonColumn.qml @@ -0,0 +1,45 @@ +import QtQuick 2.3 +import QtQuick.Controls 1.2 +import QtQuick.Layouts 1.2 +import QtPositioning 5.3 + +import QGroundControl 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.Palette 1.0 + +ColumnLayout { + id: root + spacing: ScreenTools.defaultFontPixelWidth * 0.5 + + property var model // list of lists (nested list contains all entries of ENTRY_NAME) + property string headLine + property bool hideOnClicked: true + + enum EntryName { + Text = 0, + Visible = 1, + Enabled = 2, + OnClicked = 3 + } + + QGCLabel { text: headLine } + + Repeater{ + model: root.model + QGCButton { + text: modelData[QGCButtonColumn.EntryName.Text] + visible: modelData[QGCButtonColumn.EntryName.Visible] + enabled: modelData[QGCButtonColumn.EntryName.Enabled] + Layout.fillWidth: true + + onClicked: { + if (hideOnClicked){ + dropPanel.hide() + } + root.model[index][QGCButtonColumn.EntryName.OnClicked]() + } + } + } + +} // ColumnLayout diff --git a/src/QmlControls/QGroundControl.Controls.qmldir b/src/QmlControls/QGroundControl.Controls.qmldir index 0ea43058f06df7e456c88d7ca2e16c991951540b..83953b980534590a92c5a85957d9716638473ac3 100644 --- a/src/QmlControls/QGroundControl.Controls.qmldir +++ b/src/QmlControls/QGroundControl.Controls.qmldir @@ -101,5 +101,6 @@ DragCoordinate 1.0 DragCoordinate.qml CoordinateIndicator 1.0 CoordinateIndicator.qml CoordinateIndicatorDrag 1.0 CoordinateIndicatorDrag.qml ProgressIndicator 1.0 ProgressIndicator.qml +QGCButtonColumn 1.0 QGCButtonColumn.qml diff --git a/src/QmlControls/QmlObjectListModel.h b/src/QmlControls/QmlObjectListModel.h index 8f45fa09efaf8c39a3a5564270cafcc976c3c5ac..2eca445bb2f3b8843f323cb2be83b310f6eedb44 100644 --- a/src/QmlControls/QmlObjectListModel.h +++ b/src/QmlControls/QmlObjectListModel.h @@ -26,7 +26,8 @@ public: Q_PROPERTY(bool dirty READ dirty WRITE setDirty NOTIFY dirtyChanged) Q_INVOKABLE QObject *get(int index) { return _objectList[index]; } - Q_INVOKABLE const QObject *get(int index) const { return _objectList[index]; } + // No Q_INVOKABLE here, as QML seems to have a problem with const QObject*. + const QObject *get(int index) const { return _objectList[index]; } // Property accessors diff --git a/src/WimaView/WimaView.qml b/src/WimaView/WimaView.qml index a9bb554c72f0e67d6a66ae43c1866ff936b01bd0..6928bf5d0355d5814442f36e973e6798a57f8325 100644 --- a/src/WimaView/WimaView.qml +++ b/src/WimaView/WimaView.qml @@ -117,6 +117,24 @@ QGCView { map: editorMap usePlannedHomePosition: masterController planMasterController: _planMasterController + + function fitMapViewportToAreas() { + if (!_wimaPlaner.visualItems) { + // Being called prior to controller.start + return + } + + var coordList = [ ] + for (var i = 0; i < _wimaPlaner.visualItems.count; i++){ + var area = _wimaPlaner.visualItems.get(i) + for (var j = 0; j < area.path.length; ++j){ + var vertex = area.path[j] + coordList.push(vertex) + } + } + console.log(coordList) + fitMapViewportToAllCoordinates(coordList) + } } on_AirspaceEnabledChanged: { @@ -1158,9 +1176,52 @@ QGCView { Component { id: centerMapDropPanel - CenterMapDropPanel { - map: editorMap - fitFunctions: mapFitFunctions + QGCButtonColumn { + headLine: qsTr("Center map on:") + model:[ + [ + qsTr("Mission"), /*button text*/ + true, /*visible*/ + true, /*enabled*/ + function(){mapFitFunctions.fitMapViewportToMissionItems()} /*onClicked*/ + ], + [ + qsTr("All Items"), /*button text*/ + true, /*visible*/ + true, /*enabled*/ + function(){mapFitFunctions.fitMapViewportToAllItems()} /*onClicked*/ + ], + [ + qsTr("Areas"), /*button text*/ + true, /*visible*/ + true, /*enabled*/ + function(){mapFitFunctions.fitMapViewportToAreas()} /*onClicked*/ + ], + [ + qsTr("Home"), /*button text*/ + true, /*visible*/ + true, /*enabled*/ + function(){editorMap.center = mapFitFunctions.fitHomePosition()} /*onClicked*/ + ], + [ + qsTr("Vehicle"), /*button text*/ + true, /*visible*/ + _activeVehicle && _activeVehicle.coordinate.isValid, /*enabled*/ + function(){editorMap.center = _activeVehicle.coordinate} /*onClicked*/ + ], + [ + qsTr("Current Location"), /*button text*/ + true, /*visible*/ + editorMap.gcsPosition.isValid, /*enabled*/ + function(){editorMap.center = editorMap.gcsPosition} /*onClicked*/ + ], + [ + qsTr("Specified Location"), /*button text*/ + true, /*visible*/ + true, /*enabled*/ + function(){editorMap.centerToSpecifiedLocation()} /*onClicked*/ + ] + ] } }