From 4b6cb418e39341c3b6f15f85238ec52c37cea0c8 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Sun, 1 Sep 2019 13:28:44 -0700 Subject: [PATCH 1/3] Make visibility work --- src/MissionManager/QGCMapPolylineVisuals.qml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/MissionManager/QGCMapPolylineVisuals.qml b/src/MissionManager/QGCMapPolylineVisuals.qml index 20e1fc7..2fa3993 100644 --- a/src/MissionManager/QGCMapPolylineVisuals.qml +++ b/src/MissionManager/QGCMapPolylineVisuals.qml @@ -20,7 +20,7 @@ import QGroundControl.Controls 1.0 import QGroundControl.FlightMap 1.0 import QGroundControl.ShapeFileHelper 1.0 -/// QGCmapPolyline map visuals +/// QGCMapPolyline map visuals Item { id: _root @@ -98,6 +98,8 @@ Item { } } + onVisibleChanged: _polylineComponent.visible = visible + Component.onCompleted: { addVisuals() if (interactive) { From a9448db1cef04f278bdb00f8048bf2e2e69cf0d0 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Sun, 1 Sep 2019 13:29:12 -0700 Subject: [PATCH 2/3] New base class control for Survey/Corridor --- qgroundcontrol.qrc | 1 + src/PlanView/TransectStyleMapVisuals.qml | 157 +++++++++++++++++++++++++ src/QmlControls/QGroundControl/Controls/qmldir | 1 + 3 files changed, 159 insertions(+) create mode 100644 src/PlanView/TransectStyleMapVisuals.qml diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 148e3fa..060ddc4 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -147,6 +147,7 @@ src/PlanView/SurveyMapVisual.qml src/QmlControls/ToolStrip.qml src/PlanView/TransectStyleComplexItemStats.qml + src/PlanView/TransectStyleMapVisuals.qml src/QmlControls/VehicleRotationCal.qml src/QmlControls/VehicleSummaryRow.qml src/ViewWidgets/ViewWidget.qml diff --git a/src/PlanView/TransectStyleMapVisuals.qml b/src/PlanView/TransectStyleMapVisuals.qml new file mode 100644 index 0000000..57212b8 --- /dev/null +++ b/src/PlanView/TransectStyleMapVisuals.qml @@ -0,0 +1,157 @@ +/**************************************************************************** + * + * (c) 2009-2016 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +import QtQuick 2.3 +import QtQuick.Controls 1.2 +import QtLocation 5.3 +import QtPositioning 5.3 + +import QGroundControl 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.Palette 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.FlightMap 1.0 + +/// Base control for both Survey and Corridor Scan map visuals +Item { + id: _root + + property var map ///< Map control to place item in + + property var _missionItem: object + property var _mapPolygon: object.surveyAreaPolygon + property bool _currentItem: object.isCurrentItem + property var _transectPoints: _missionItem.visualTransectPoints + property bool _showPartialEntryExit: !_currentItem && _missionItem.turnAroundDistance.rawValue !== 0 &&_transectPoints.length >= 2 + property var _fullTransectsComponent: null + property var _entryTransectsComponent: null + property var _exitTransectsComponent: null + property var _entryCoordinate + property var _exitCoordinate + + signal clicked(int sequenceNumber) + + function _addVisualElements() { + _fullTransectsComponent = fullTransectsComponent.createObject(map) + _entryTransectsComponent = entryTransectComponent.createObject(map) + _exitTransectsComponent = exitTransectComponent.createObject(map) + _entryCoordinate = entryPointComponent.createObject(map) + _exitCoordinate = exitPointComponent.createObject(map) + + map.addMapItem(_fullTransectsComponent) + map.addMapItem(_entryTransectsComponent) + map.addMapItem(_exitTransectsComponent) + map.addMapItem(_entryCoordinate) + map.addMapItem(_exitCoordinate) + } + + function _destroyVisualElements() { + _fullTransectsComponent.destroy() + _entryTransectsComponent.destroy() + _exitTransectsComponent.destroy() + _entryCoordinate.destroy() + _exitCoordinate.destroy() + } + + Component.onCompleted: { + _addVisualElements() + } + + Component.onDestruction: { + _destroyVisualElements() + } + + // Area polygon + QGCMapPolygonVisuals { + id: mapPolygonVisuals + mapControl: map + mapPolygon: _mapPolygon + interactive: _missionItem.isCurrentItem + borderWidth: 1 + borderColor: "black" + interiorColor: "green" + interiorOpacity: 0.5 + } + + // Full set of transects lines. Shown when item is selected. + Component { + id: fullTransectsComponent + + MapPolyline { + line.color: "white" + line.width: 2 + path: _transectPoints + visible: _currentItem + } + } + + // Entry and exit transect lines only. Used when item is not selected. + Component { + id: entryTransectComponent + + MapPolyline { + line.color: "white" + line.width: 2 + path: _showPartialEntryExit ? [ _transectPoints[0], _transectPoints[1] ] : [] + visible: _showPartialEntryExit + } + } + Component { + id: exitTransectComponent + + MapPolyline { + line.color: "white" + line.width: 2 + path: _showPartialEntryExit ? [ _transectPoints[lastPointIndex - 1], _transectPoints[lastPointIndex] ] : [] + visible: _showPartialEntryExit + + property int lastPointIndex: _transectPoints.length - 1 + } + } + + // Entry point + Component { + id: entryPointComponent + + MapQuickItem { + anchorPoint.x: sourceItem.anchorPointX + anchorPoint.y: sourceItem.anchorPointY + z: QGroundControl.zOrderMapItems + coordinate: _missionItem.coordinate + visible: _missionItem.exitCoordinate.isValid + + sourceItem: MissionItemIndexLabel { + index: _missionItem.sequenceNumber + label: qsTr("Entry") + checked: _missionItem.isCurrentItem + onClicked: _root.clicked(_missionItem.sequenceNumber) + } + } + } + + // Exit point + Component { + id: exitPointComponent + + MapQuickItem { + anchorPoint.x: sourceItem.anchorPointX + anchorPoint.y: sourceItem.anchorPointY + z: QGroundControl.zOrderMapItems + coordinate: _missionItem.exitCoordinate + visible: _missionItem.exitCoordinate.isValid + + sourceItem: MissionItemIndexLabel { + index: _missionItem.lastSequenceNumber + label: qsTr("Exit") + checked: _missionItem.isCurrentItem + onClicked: _root.clicked(_missionItem.sequenceNumber) + } + } + } +} diff --git a/src/QmlControls/QGroundControl/Controls/qmldir b/src/QmlControls/QGroundControl/Controls/qmldir index 2191918..da47b31 100644 --- a/src/QmlControls/QGroundControl/Controls/qmldir +++ b/src/QmlControls/QGroundControl/Controls/qmldir @@ -80,6 +80,7 @@ SliderSwitch 1.0 SliderSwitch.qml SubMenuButton 1.0 SubMenuButton.qml SurveyMapVisuals 1.0 SurveyMapVisuals.qml TransectStyleComplexItemStats 1.0 TransectStyleComplexItemStats.qml +TransectStyleMapVisuals 1.0 TransectStyleMapVisuals.qml ToolStrip 1.0 ToolStrip.qml VehicleRotationCal 1.0 VehicleRotationCal.qml VehicleSummaryRow 1.0 VehicleSummaryRow.qml From 0d6df9f2923b3e3aa673bf5ac8d8a9dc139ba6fc Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Sun, 1 Sep 2019 13:29:28 -0700 Subject: [PATCH 3/3] Use new TransectStyleMapVisuals base control --- src/PlanView/CorridorScanMapVisual.qml | 99 ++---------------------- src/PlanView/SurveyMapVisual.qml | 137 +-------------------------------- 2 files changed, 8 insertions(+), 228 deletions(-) diff --git a/src/PlanView/CorridorScanMapVisual.qml b/src/PlanView/CorridorScanMapVisual.qml index ec9e052..d674a61 100644 --- a/src/PlanView/CorridorScanMapVisual.qml +++ b/src/PlanView/CorridorScanMapVisual.qml @@ -16,107 +16,18 @@ import QGroundControl 1.0 import QGroundControl.Controls 1.0 /// Corridor Scan Complex Mission Item visuals -Item { - id: _root +TransectStyleMapVisuals { + property bool _currentItem: object.isCurrentItem - property var map ///< Map control to place item in - - property var _missionItem: object - property var _entryCoordinate - property var _exitCoordinate - property var _transectLines - - signal clicked(int sequenceNumber) - - function _addVisualElements() { - _entryCoordinate = entryPointComponent.createObject(map) - _exitCoordinate = exitPointComponent.createObject(map) - _transectLines = transectsComponent.createObject(map) - map.addMapItem(_entryCoordinate) - map.addMapItem(_exitCoordinate) - map.addMapItem(_transectLines) - } - - function _destroyVisualElements() { - _entryCoordinate.destroy() - _exitCoordinate.destroy() - _transectLines.destroy() - } - - Component.onCompleted: { - mapPolylineVisuals.addInitialPolyline() - _addVisualElements() - } - - Component.onDestruction: { - _destroyVisualElements() - } - - QGCMapPolygonVisuals { - mapControl: map - mapPolygon: object.surveyAreaPolygon - interactive: false - interiorColor: "green" - interiorOpacity: 0.25 - } + Component.onCompleted: mapPolylineVisuals.addInitialPolyline() QGCMapPolylineVisuals { id: mapPolylineVisuals mapControl: map mapPolyline: object.corridorPolyline - interactive: _missionItem.isCurrentItem + interactive: _currentItem lineWidth: 3 lineColor: "#be781c" - } - - // Entry point - Component { - id: entryPointComponent - - MapQuickItem { - anchorPoint.x: sourceItem.anchorPointX - anchorPoint.y: sourceItem.anchorPointY - z: QGroundControl.zOrderMapItems - coordinate: _missionItem.coordinate - visible: _missionItem.coordinate.isValid - - sourceItem: MissionItemIndexLabel { - index: _missionItem.sequenceNumber - label: "Entry" - checked: _missionItem.isCurrentItem - onClicked: _root.clicked(_missionItem.sequenceNumber) - } - } - } - - // Exit point - Component { - id: exitPointComponent - - MapQuickItem { - anchorPoint.x: sourceItem.anchorPointX - anchorPoint.y: sourceItem.anchorPointY - z: QGroundControl.zOrderMapItems - coordinate: _missionItem.exitCoordinate - visible: _missionItem.exitCoordinate.isValid - - sourceItem: MissionItemIndexLabel { - index: _missionItem.lastSequenceNumber - label: "Exit" - checked: _missionItem.isCurrentItem - onClicked: _root.clicked(_missionItem.sequenceNumber) - } - } - } - - // Transect lines - Component { - id: transectsComponent - - MapPolyline { - line.color: "white" - line.width: 2 - path: _missionItem.visualTransectPoints - } + visible: _currentItem } } diff --git a/src/PlanView/SurveyMapVisual.qml b/src/PlanView/SurveyMapVisual.qml index 237297b..ec4e4cb 100644 --- a/src/PlanView/SurveyMapVisual.qml +++ b/src/PlanView/SurveyMapVisual.qml @@ -19,45 +19,8 @@ import QGroundControl.Controls 1.0 import QGroundControl.FlightMap 1.0 /// Survey Complex Mission Item visuals -Item { - id: _root - - property var map ///< Map control to place item in - - property var _missionItem: object - property var _mapPolygon: object.surveyAreaPolygon - property bool _currentItem: object.isCurrentItem - property var _transectPoints: _missionItem.visualTransectPoints - property bool _showPartialEntryExit: !_currentItem && _missionItem.turnAroundDistance.rawValue != 0 &&_transectPoints.length > 1 - property var _fullTransectsComponent: null - property var _entryTransectsComponent: null - property var _exitTransectsComponent: null - property var _entryCoordinate - property var _exitCoordinate - - signal clicked(int sequenceNumber) - - function _addVisualElements() { - _fullTransectsComponent = fullTransectsComponent.createObject(map) - _entryTransectsComponent = entryTransectComponent.createObject(map) - _exitTransectsComponent = exitTransectComponent.createObject(map) - _entryCoordinate = entryPointComponent.createObject(map) - _exitCoordinate = exitPointComponent.createObject(map) - - map.addMapItem(_fullTransectsComponent) - map.addMapItem(_entryTransectsComponent) - map.addMapItem(_exitTransectsComponent) - map.addMapItem(_entryCoordinate) - map.addMapItem(_exitCoordinate) - } - - function _destroyVisualElements() { - _fullTransectsComponent.destroy() - _entryTransectsComponent.destroy() - _exitTransectsComponent.destroy() - _entryCoordinate.destroy() - _exitCoordinate.destroy() - } +TransectStyleMapVisuals { + property var _mapPolygon: object.surveyAreaPolygon /// Add an initial 4 sided polygon if there is none function _addInitialPolygon() { @@ -90,99 +53,5 @@ Item { } } - Component.onCompleted: { - _addInitialPolygon() - _addVisualElements() - } - - Component.onDestruction: { - _destroyVisualElements() - } - - QGCMapPolygonVisuals { - id: mapPolygonVisuals - mapControl: map - mapPolygon: _mapPolygon - interactive: _missionItem.isCurrentItem - borderWidth: 1 - borderColor: "black" - interiorColor: "green" - interiorOpacity: 0.5 - } - - // Full set of transects lines. Shown when item is selected. - Component { - id: fullTransectsComponent - - MapPolyline { - line.color: "white" - line.width: 2 - path: _transectPoints - visible: _currentItem - } - } - - // Entry and exit transect lines only. Used when item is not selected. - Component { - id: entryTransectComponent - - MapPolyline { - line.color: "white" - line.width: 2 - path: _showPartialEntryExit ? [ _transectPoints[0], _transectPoints[1] ] : [] - visible: _showPartialEntryExit - } - } - Component { - id: exitTransectComponent - - MapPolyline { - line.color: "white" - line.width: 2 - path: _showPartialEntryExit ? [ _transectPoints[lastPointIndex - 1], _transectPoints[lastPointIndex] ] : [] - visible: _showPartialEntryExit - - property int lastPointIndex: _transectPoints.length - 1 - } - } - - // Entry point - Component { - id: entryPointComponent - - MapQuickItem { - anchorPoint.x: sourceItem.anchorPointX - anchorPoint.y: sourceItem.anchorPointY - z: QGroundControl.zOrderMapItems - coordinate: _missionItem.coordinate - visible: _missionItem.exitCoordinate.isValid - - sourceItem: MissionItemIndexLabel { - index: _missionItem.sequenceNumber - label: "Entry" - checked: _missionItem.isCurrentItem - onClicked: _root.clicked(_missionItem.sequenceNumber) - } - } - } - - // Exit point - Component { - id: exitPointComponent - - MapQuickItem { - anchorPoint.x: sourceItem.anchorPointX - anchorPoint.y: sourceItem.anchorPointY - z: QGroundControl.zOrderMapItems - coordinate: _missionItem.exitCoordinate - visible: _missionItem.exitCoordinate.isValid - - sourceItem: MissionItemIndexLabel { - index: _missionItem.lastSequenceNumber - label: "Exit" - checked: _missionItem.isCurrentItem - onClicked: _root.clicked(_missionItem.sequenceNumber) - } - } - } + Component.onCompleted: _addInitialPolygon() }