From 12f888dca662b7600c3f2c0a2e3c2bf2f5ce6684 Mon Sep 17 00:00:00 2001 From: Valentin Platzgummer Date: Mon, 1 Apr 2019 13:21:37 +0200 Subject: [PATCH] about to add fact system to wima --- WimaGlobalMeasurementPolygonEditor.qml | 5 ++ qgroundcontrol.pro | 3 + qgroundcontrol.qrc | 3 +- src/MissionManager/WimaController.cc | 8 ++- ...lobalMeasurementPolygon.SettingsGroup.json | 0 .../WimaGlobalMeasurementPolygon.cc | 2 +- .../WimaGlobalMeasurementPolygon.h | 20 +++++- src/MissionManager/WimaPolygon.cc | 7 +- src/MissionManager/WimaPolygon.h | 1 - src/MissionManager/WimaServicePolygon.cc | 2 +- src/MissionManager/WimaVehicleCorridor.cc | 2 +- .../WimaVehicleMeasurementPolygon.cc | 2 +- src/WimaView/WimaItemEditor.qml | 68 +++++++++++++------ src/WimaView/WimaView.qml | 34 ++++------ 14 files changed, 105 insertions(+), 52 deletions(-) create mode 100644 WimaGlobalMeasurementPolygonEditor.qml create mode 100644 src/MissionManager/WimaGlobalMeasurementPolygon.SettingsGroup.json diff --git a/WimaGlobalMeasurementPolygonEditor.qml b/WimaGlobalMeasurementPolygonEditor.qml new file mode 100644 index 000000000..9c36e13c5 --- /dev/null +++ b/WimaGlobalMeasurementPolygonEditor.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + +} diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index af91b5f86..4f471cb5c 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -1307,3 +1307,6 @@ contains (CONFIG, QGC_DISABLE_INSTALLER_SETUP) { } else { include(QGCInstaller.pri) } + +DISTFILES += \ + src/MissionManager/WimaGlobalMeasurementPolygon.SettingsGroup.json diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 8cc6201ca..5c3bc7358 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -213,7 +213,8 @@ src/WimaView/WimaMapVisual.qml src/WimaView/WimaGlobalMeasurementPolygonMapVisual.qml src/WimaView/WimaServicePolygonMapVisual.qml - src/WimaView/WimaItemEditor.qml + src/WimaView/WimaItemEditor.qml + WimaGlobalMeasurementPolygonEditor.qml src/Settings/APMMavlinkStreamRate.SettingsGroup.json diff --git a/src/MissionManager/WimaController.cc b/src/MissionManager/WimaController.cc index bd3435aa7..18ee92dc0 100644 --- a/src/MissionManager/WimaController.cc +++ b/src/MissionManager/WimaController.cc @@ -23,7 +23,7 @@ void WimaController::setMissionController(MissionController *missionC) void WimaController::setCurrentPolygonIndex(int index) { - if(index > 0 && index < _visualItems->count() && index != _currentPolygonIndex){ + if(index >= 0 && index < _visualItems->count() && index != _currentPolygonIndex){ _currentPolygonIndex = index; emit currentPolygonIndexChanged(index); @@ -47,6 +47,12 @@ void WimaController::removeArea(int index) _visualItems->removeAt(index); emit visualItemsChanged(); + + if(_currentPolygonIndex >= _visualItems->count()){ + setCurrentPolygonIndex(_visualItems->count() - 1); + }else{ + recalcPolygonInteractivity(_currentPolygonIndex); + } }else{ qWarning("Index out of bounds!"); } diff --git a/src/MissionManager/WimaGlobalMeasurementPolygon.SettingsGroup.json b/src/MissionManager/WimaGlobalMeasurementPolygon.SettingsGroup.json new file mode 100644 index 000000000..e69de29bb diff --git a/src/MissionManager/WimaGlobalMeasurementPolygon.cc b/src/MissionManager/WimaGlobalMeasurementPolygon.cc index 84f23553a..7f7c41b87 100644 --- a/src/MissionManager/WimaGlobalMeasurementPolygon.cc +++ b/src/MissionManager/WimaGlobalMeasurementPolygon.cc @@ -5,7 +5,7 @@ WimaGlobalMeasurementPolygon::WimaGlobalMeasurementPolygon(QObject *parent): WimaPolygon (parent) { - + this->setObjectName("Operating Area"); } WimaGlobalMeasurementPolygon::WimaGlobalMeasurementPolygon(QGCMapPolygon *other, QObject *parent): diff --git a/src/MissionManager/WimaGlobalMeasurementPolygon.h b/src/MissionManager/WimaGlobalMeasurementPolygon.h index d5578fdf1..9d62c13d0 100644 --- a/src/MissionManager/WimaGlobalMeasurementPolygon.h +++ b/src/MissionManager/WimaGlobalMeasurementPolygon.h @@ -44,6 +44,10 @@ public: void setNumberOfLayers (int numberOfLayers); void setLayerDistance (double distance); + + static const char* settingsGroup; + + signals: void bottomLayerAltitudeChanged (void); void numberOfLayersChanged (void); @@ -54,11 +58,21 @@ signals: private: - double _bottomLayerAltitude; - int _numberOfLayers; - double _layerDistance; + QMap _metaDataMap; + + SettingsFact _bottomLayerAltitude; + SettingsFact _numberOfLayers; + SettingsFact _layerDistance; + + QmlObjectListModel* _vehicleList; QGCMapPolyline* _entryPolyline; + + + + + SettingsFact + }; diff --git a/src/MissionManager/WimaPolygon.cc b/src/MissionManager/WimaPolygon.cc index 412398cf8..927eeb128 100644 --- a/src/MissionManager/WimaPolygon.cc +++ b/src/MissionManager/WimaPolygon.cc @@ -36,8 +36,11 @@ void WimaPolygon::setVehicle(Vehicle *vehicle) void WimaPolygon::setIsCurrentPolygon(bool isCurrentPolygon) { - _isCurrentPolygon = isCurrentPolygon; - emit isCurrentPolygonChanged(); + if(_isCurrentPolygon != isCurrentPolygon){ + _isCurrentPolygon = isCurrentPolygon; + emit isCurrentPolygonChanged(); + } + } QList* WimaPolygon::splitPolygonArea(int numberOfFractions) diff --git a/src/MissionManager/WimaPolygon.h b/src/MissionManager/WimaPolygon.h index 723fc903b..f70f50cc7 100644 --- a/src/MissionManager/WimaPolygon.h +++ b/src/MissionManager/WimaPolygon.h @@ -42,7 +42,6 @@ public: //Property setters void setMaxAltitude (double alt); - void setName (QString name); void setVehicle (Vehicle* vehicle); void setIsCurrentPolygon(bool isCurrentPolygon); diff --git a/src/MissionManager/WimaServicePolygon.cc b/src/MissionManager/WimaServicePolygon.cc index 3be47f627..213a128e9 100644 --- a/src/MissionManager/WimaServicePolygon.cc +++ b/src/MissionManager/WimaServicePolygon.cc @@ -3,7 +3,7 @@ WimaServicePolygon::WimaServicePolygon(QObject *parent): WimaPolygon (parent) { - + this->setObjectName("Service Area"); } WimaServicePolygon::WimaServicePolygon(QGCMapPolygon *other, QObject *parent): diff --git a/src/MissionManager/WimaVehicleCorridor.cc b/src/MissionManager/WimaVehicleCorridor.cc index 74dc43c39..d91cdf307 100644 --- a/src/MissionManager/WimaVehicleCorridor.cc +++ b/src/MissionManager/WimaVehicleCorridor.cc @@ -3,7 +3,7 @@ WimaVehicleCorridor::WimaVehicleCorridor(QObject *parent): WimaPolygon(parent) { - + this->setObjectName("Corridor"); } WimaVehicleCorridor::WimaVehicleCorridor(QGCMapPolygon *other, QObject *parent): diff --git a/src/MissionManager/WimaVehicleMeasurementPolygon.cc b/src/MissionManager/WimaVehicleMeasurementPolygon.cc index b8fd4cf5b..fa6b6ca69 100644 --- a/src/MissionManager/WimaVehicleMeasurementPolygon.cc +++ b/src/MissionManager/WimaVehicleMeasurementPolygon.cc @@ -4,7 +4,7 @@ WimaVehicleMeasurementPolygon::WimaVehicleMeasurementPolygon(QObject *parent): WimaPolygon (parent) { - + this->setObjectName("Vehicle Area"); } WimaVehicleMeasurementPolygon::WimaVehicleMeasurementPolygon(QGCMapPolygon *other, QObject *parent): diff --git a/src/WimaView/WimaItemEditor.qml b/src/WimaView/WimaItemEditor.qml index 796dcf874..9dfdbc04b 100644 --- a/src/WimaView/WimaItemEditor.qml +++ b/src/WimaView/WimaItemEditor.qml @@ -15,14 +15,13 @@ import QGroundControl.Palette 1.0 /// Fly Area Item edit control Rectangle { id: _root - height: editorLoader.visible ? (editorLoader.y + editorLoader.height + (_margin * 2)) : (descriptionLabel.y + descriptionLabel.height + _margin / 2) + height: editorLoader.visible ? (editorLoader.y + editorLoader.height + (_margin * 2)) : (commandPicker.y + commandPicker.height + _margin / 2) color: _currentItem ? qgcPal.missionItemEditor : qgcPal.windowShade radius: _radius property var map ///< Map control - property var flyArea + property var wimaController property var masterController - property var polygon ///< MissionItem associated with this editor property bool readOnly ///< true: read only view, false: full editing view property var rootQgcView property int _index @@ -32,16 +31,15 @@ Rectangle { property var _masterController: masterController property var _missionController: _masterController.missionController - property bool _currentItem: polygon.interactive + property var _polygon: object.polygon + property bool _currentItem: object.isCurrentPolygon property color _outerTextColor: _currentItem ? qgcPal.primaryButtonText : qgcPal.text - property bool _noMissionItemsAdded: ListView.view.model.count === 1 property real _sectionSpacer: ScreenTools.defaultFontPixelWidth / 2 // spacing between section headings readonly property real _editFieldWidth: Math.min(width - _margin * 2, ScreenTools.defaultFontPixelWidth * 12) readonly property real _margin: ScreenTools.defaultFontPixelWidth / 2 readonly property real _radius: ScreenTools.defaultFontPixelWidth / 2 - readonly property real _hamburgerSize: descriptionLabel.height * 0.75 - readonly property bool _waypointsOnlyMode: QGroundControl.corePlugin.options.missionWaypointsOnly + readonly property real _hamburgerSize: commandPicker.height * 0.75 QGCPalette { id: qgcPal @@ -64,10 +62,10 @@ Rectangle { QGCLabel { id: label - anchors.verticalCenter: descriptionLabel.verticalCenter + anchors.verticalCenter: commandPicker.verticalCenter anchors.leftMargin: _margin anchors.left: parent.left - text: index + text: _index+1 color: _outerTextColor } @@ -75,7 +73,7 @@ Rectangle { id: hamburger anchors.rightMargin: ScreenTools.defaultFontPixelWidth anchors.right: parent.right - anchors.verticalCenter: descriptionLabel.verticalCenter + anchors.verticalCenter: commandPicker.verticalCenter width: _hamburgerSize height: _hamburgerSize sourceSize.height: _hamburgerSize @@ -96,43 +94,66 @@ Rectangle { id: hamburgerMenu MenuItem { - text: qsTr("Insert Fly Area") - onTriggered: flyArea.appendFlyAreaPolygon() + text: qsTr("Add Operating Area") + onTriggered: wimaController.addGlobalMeasurementArea() + } + + MenuItem { + text: qsTr("Add Service Area") + onTriggered: wimaController.addServiceArea() } MenuItem { text: qsTr("Delete") onTriggered: remove() } + MenuItem { - text: qsTr("Copy Fly Area") - //onTriggered: //To Do + text: qsTr("Change Area Type ...") + onTriggered: commandPicker.clicked() } } } - QGCLabel { - id: descriptionLabel + QGCButton { + id: commandPicker anchors.topMargin: _margin / 2 anchors.leftMargin: ScreenTools.defaultFontPixelWidth * 2 anchors.rightMargin: ScreenTools.defaultFontPixelWidth anchors.left: label.right anchors.top: parent.top - text: "Fly Area" - verticalAlignment: Text.AlignVCenter - color: _outerTextColor + visible: _currentItem + text: object.objectName; + + Component { + id: commandDialog + + MissionCommandDialog { + missionItem: object + } + } + + onClicked: qgcView.showDialog(commandDialog, qsTr("Select Mission Command"), qgcView.showDialogDefaultWidth, StandardButton.Cancel) } + QGCLabel { + id: commandLabel + anchors.fill: commandPicker + visible: !_currentItem + verticalAlignment: Text.AlignVCenter + text: object.objectName; + color: _outerTextColor + } Loader { id: editorLoader anchors.leftMargin: _margin anchors.topMargin: _margin anchors.left: parent.left - anchors.top: descriptionLabel.bottom - source: "FlyAreaEditor.qml" + anchors.top: commandPicker.bottom + source: object.editorQml visible: _currentItem property var masterController: _masterController @@ -140,3 +161,8 @@ Rectangle { property var editorRoot: _root } } // Rectangle + + + + + diff --git a/src/WimaView/WimaView.qml b/src/WimaView/WimaView.qml index 727916d6c..65d17705a 100644 --- a/src/WimaView/WimaView.qml +++ b/src/WimaView/WimaView.qml @@ -155,7 +155,7 @@ QGCView { } } } - }_layerWimaPlan + } Connections { target: QGroundControl.airspaceManager @@ -257,7 +257,7 @@ QGCView { } Connections { - target: _missionController_layerWimaPlan + target: _missionController onNewItemsFromVehicle: { if (_visualItems && _visualItems.count != 1) { @@ -376,7 +376,7 @@ QGCView { toIndex = 1 } _missionController.moveMissionItem(_moveDialogMissionItemIndex, toIndex) - hideDialog()_layerWimaPlan + hideDialog() } Column { @@ -413,7 +413,7 @@ QGCView { planView: true qgcView: _qgcView - // This is the center rectangle of the map which is not obscured by tools + // This is the center rectangle of the map which is not_layerWimaPlan obscured by tools property rect centerViewport: Qt.rect(_leftToolWidth, _toolbarHeight, editorMap.width - _leftToolWidth - _rightPanelWidth, editorMap.height - _statusHeight - _toolbarHeight) property real _leftToolWidth: toolStrip.x + toolStrip.width @@ -434,7 +434,7 @@ QGCView { QGCMapPalette { id: mapPal; lightColors: editorMap.isSatelliteMap } onZoomLevelChanged: updateAirspace(false) - onCenterChanged: updateAirspace(false)_layerWimaPlan + onCenterChanged: updateAirspace(false) MouseArea { //-- It's a whole lot faster to just fill parent and deal with top offset below @@ -785,7 +785,7 @@ QGCView { //------------------------------------------------------- // Wima Item Editor Item { - id: flyAreaItemEditor + id: wimaItemEditor anchors.left: parent.left anchors.right: parent.right anchors.top: rightControls.bottom @@ -794,7 +794,7 @@ QGCView { anchors.bottomMargin: ScreenTools.defaultFontPixelHeight * 0.25 visible: _editingLayer == _layerWima && !planControlColapsed QGCListView { - id: flyAreaItemEditorListView + id: wimaItemEditorListView anchors.fill: parent spacing: ScreenTools.defaultFontPixelHeight / 4 orientation: ListView.Vertical @@ -808,20 +808,16 @@ QGCView { delegate: WimaItemEditor { map: editorMap masterController: _planMasterController - flyArea: _flyArea + wimaController: _wimaController _index: index - polygon: object width: parent.width readOnly: false rootQgcView: _qgcView - onClicked: _flyArea.selectCurrentPolygon(index) + onClicked: _wimaController.currentPolygonIndex = index onRemove: { var removeIndex = index - _flyArea.removeFlyAreaPolygon(removeIndex) - if (removeIndex >= _flyArea.polygons.count) { - removeIndex-- - } - _flyArea.selectCurrentPolygon(removeIndex) + _wimaController.removeArea(removeIndex) + } } } @@ -970,7 +966,7 @@ QGCView { id: clearVehicleMissionDialog QGCViewMessage { message: qsTr("Are you sure you want to remove all mission items and clear the mission from the vehicle?") - function accept() { + function accept() {_layerWimaPlan masterController.removeAllFromVehicle() hideDialog() } @@ -1065,7 +1061,7 @@ QGCView { } QGCButton { - text: qsTr("Save Mission Waypoints As KML...") + text: qsTr("Save Mission Waypoints As K_layerWimaPlanML...") Layout.columnSpan: 2 enabled: !masterController.syncInProgress && _visualItems.count > 1 onClicked: { @@ -1151,13 +1147,13 @@ QGCView { QGCListView { anchors.fill: parent - model: _flyArea.polygons + model: wimaController.visualItems delegate: Rectangle{ height: 15 color: "lightsteelblue" radius: 1 Text { - text: object.interactive + text: object.isCurrentPolygon } } } -- 2.22.0