From fa6684ff86d3ac06e1087a0f1f42124c27850f27 Mon Sep 17 00:00:00 2001 From: Gus Grubba Date: Tue, 30 Jan 2018 12:58:56 -0500 Subject: [PATCH] Make "required" rules to be selected by default and you cannot change it. Fix sorting issues with QmlObjectListModel Show airspaces in Plan View as well --- src/Airmap/AirMapAdvisoryManager.cc | 2 ++ src/Airmap/AirMapRulesetsManager.cc | 1 + src/Airmap/AirspaceControl.qml | 1 + src/Airmap/README.md | 21 +++++++++++++++------ src/Airmap/RuleSelector.qml | 4 +++- src/PlanView/PlanView.qml | 27 +++++++++++++++++++++++++++ src/QmlControls/QmlObjectListModel.cc | 2 ++ src/QmlControls/QmlObjectListModel.h | 7 +++++-- 8 files changed, 56 insertions(+), 9 deletions(-) diff --git a/src/Airmap/AirMapAdvisoryManager.cc b/src/Airmap/AirMapAdvisoryManager.cc index 2d232ffcb..eef4f9bb9 100644 --- a/src/Airmap/AirMapAdvisoryManager.cc +++ b/src/Airmap/AirMapAdvisoryManager.cc @@ -93,7 +93,9 @@ AirMapAdvisoryManager::_requestAdvisories() qCDebug(AirMapManagerLog) << "Adding advisory" << pAdvisory->name(); } //-- Sort in order of color (priority) + _airspaces.beginReset(); std::sort(_airspaces.objectList()->begin(), _airspaces.objectList()->end(), adv_sort); + _airspaces.endReset(); _valid = true; } else { qCDebug(AirMapManagerLog) << "Advisories Request Failed"; diff --git a/src/Airmap/AirMapRulesetsManager.cc b/src/Airmap/AirMapRulesetsManager.cc index 2906a84f2..a3f6b54b4 100644 --- a/src/Airmap/AirMapRulesetsManager.cc +++ b/src/Airmap/AirMapRulesetsManager.cc @@ -71,6 +71,7 @@ void AirMapRulesetsManager::setROI(const QGeoCoordinate& center) break; case RuleSet::SelectionType::required: pRule->_selectionType = AirspaceRule::Required; + pRule->_selected = true; break; default: case RuleSet::SelectionType::optional: diff --git a/src/Airmap/AirspaceControl.qml b/src/Airmap/AirspaceControl.qml index 71d5af96f..56e8e2e31 100644 --- a/src/Airmap/AirspaceControl.qml +++ b/src/Airmap/AirspaceControl.qml @@ -470,6 +470,7 @@ Item { delegate: RuleSelector { visible: object.selectionType === AirspaceRule.Required rule: object + required: true anchors.right: parent.right anchors.rightMargin: ScreenTools.defaultFontPixelWidth anchors.left: parent.left diff --git a/src/Airmap/README.md b/src/Airmap/README.md index c3977d352..c57893947 100644 --- a/src/Airmap/README.md +++ b/src/Airmap/README.md @@ -1,14 +1,23 @@ ## To be deleted when development is complete -* "Required" rules must be pre-selectd and cannot be unselected by the user +* Traffic monitor timeout is now set to 2 minutes following instructions from Thomas Voß. -* AirMapRestrictionManager seems to be incomplete (if not redundant). Shouldn't we use the array of AirSpace items returned by AirMapAdvisoryManager instead? In addition to the AirSpace object, it gives you a color to use in order of importance. +* Group rules jurisdictions -* Traffic monitor timeout is now set to 2 minutes following instructions from Thomas Voß. +* Check rules sorting order. Repopulating QmlObjectListModel causes the repeater to show the contents in random order. -* Check rules sorting order +* ~AirMapRestrictionManager seems to be incomplete (if not redundant). Shouldn't we use the array of AirSpace items returned by AirMapAdvisoryManager instead? In addition to the AirSpace object, it gives you a color to use in order of importance.~ See question below. -* Group rules jurisdictions +* ~"Required" rules must be pre-selectd and cannot be unselected by the user~ -* ~Add a "Wrong Way" icon to the airspace widget when not connected~ +* ~Add a "Wrong Way" icon to the airspace widget when not connected~ + + +Questions: + +Given a same set of coordinates, what is the relationship between the `Airspace` elements returned by `Airspaces::Search` and those returned by `Status::GetStatus` (Advisories)? The former don’t have a “color”. The latter do but those don’t have any geometry. In addition, given two identical set of arguments (coordinates), the resulting sets are not the same. A given airspace may also be repeated several times with different “levels”, such as an airport having several “green” and several “yellow” advisories (but no red or orange). How do you filter what to show on the screen? + +Also, the main glaring airspace nearby, KRDU has one entry in Airspaces whose ID is not in the array returned by the advisories (and therefore no color to assign to it). In fact, KRDU shows up 20 times in Advisories and 11 times in Airspaces. + +In summary, why do I have to make two requests to get two arrays of Airspaces, which should be mostly the same? \ No newline at end of file diff --git a/src/Airmap/RuleSelector.qml b/src/Airmap/RuleSelector.qml index 8d1c276d5..951ba2036 100644 --- a/src/Airmap/RuleSelector.qml +++ b/src/Airmap/RuleSelector.qml @@ -17,6 +17,7 @@ Rectangle { color: _selected ? qgcPal.windowShade : qgcPal.window property var rule: null property bool checked: false + property bool required: false property bool _selected: { if (exclusiveGroup) { return checked @@ -57,7 +58,8 @@ Rectangle { } } MouseArea { - anchors.fill: parent + anchors.fill: parent + enabled: !required onClicked: { if (exclusiveGroup) { checked = true diff --git a/src/PlanView/PlanView.qml b/src/PlanView/PlanView.qml index 163c2884f..329949110 100644 --- a/src/PlanView/PlanView.qml +++ b/src/PlanView/PlanView.qml @@ -59,6 +59,7 @@ QGCView { property real _toolbarHeight: _qgcView.height - ScreenTools.availableHeight property int _editingLayer: _layerMission property int _toolStripBottom: toolStrip.height + toolStrip.y + property bool _airspaceManagement: QGroundControl.airmapSupported && _activeVehicle readonly property int _layerMission: 1 readonly property int _layerGeoFence: 2 @@ -348,6 +349,12 @@ QGCView { QGCMapPalette { id: mapPal; lightColors: editorMap.isSatelliteMap } + onCenterChanged: { + if(_activeVehicle && QGroundControl.airmapSupported) { + _activeVehicle.airspaceController.setROI(center, 5000) + } + } + MouseArea { //-- It's a whole lot faster to just fill parent and deal with top offset below // than computing the coordinate offset. @@ -427,6 +434,26 @@ QGCView { planView: true } + // Airspace overlap support + MapItemView { + model: _airspaceManagement && _activeVehicle.airspaceController.airspaceVisible ? _activeVehicle.airspaceController.airspaces.circles : [] + delegate: MapCircle { + center: object.center + radius: object.radius + color: Qt.rgba(0.94, 0.87, 0, 0.1) + border.color: Qt.rgba(1,1,1,0.65) + } + } + + MapItemView { + model: _airspaceManagement && _activeVehicle.airspaceController.airspaceVisible ? _activeVehicle.airspaceController.airspaces.polygons : [] + delegate: MapPolygon { + path: object.polygon + color: Qt.rgba(0.94, 0.87, 0, 0.1) + border.color: Qt.rgba(1,1,1,0.65) + } + } + ToolStrip { id: toolStrip anchors.leftMargin: ScreenTools.defaultFontPixelWidth diff --git a/src/QmlControls/QmlObjectListModel.cc b/src/QmlControls/QmlObjectListModel.cc index 1db22e6e8..2371eac4a 100644 --- a/src/QmlControls/QmlObjectListModel.cc +++ b/src/QmlControls/QmlObjectListModel.cc @@ -226,8 +226,10 @@ void QmlObjectListModel::deleteListAndContents(void) void QmlObjectListModel::clearAndDeleteContents(void) { + beginResetModel(); for (int i=0; i<_objectList.count(); i++) { _objectList[i]->deleteLater(); } clear(); + endResetModel(); } diff --git a/src/QmlControls/QmlObjectListModel.h b/src/QmlControls/QmlObjectListModel.h index cc817ab0d..79f140a93 100644 --- a/src/QmlControls/QmlObjectListModel.h +++ b/src/QmlControls/QmlObjectListModel.h @@ -50,10 +50,13 @@ public: template T value(int index) { return qobject_cast(_objectList[index]); } /// Calls deleteLater on all items and this itself. - void deleteListAndContents(void); + void deleteListAndContents (void); /// Clears the list and calls deleteLater on each entry - void clearAndDeleteContents(void); + void clearAndDeleteContents (void); + + void beginReset () { beginResetModel(); } + void endReset () { endResetModel(); } signals: void countChanged (int count); -- 2.22.0