From 20b7fce71db7b4dc9b10d7d6e54a16361ab979a6 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Sat, 23 Jul 2016 21:25:30 -0700 Subject: [PATCH] Support for adjusting existing survey polygon --- src/FlightMap/FlightMap.qml | 136 ++++++++++++++++++++--- src/MissionEditor/SurveyItemEditor.qml | 28 ++++- src/MissionManager/ComplexMissionItem.cc | 8 ++ src/MissionManager/ComplexMissionItem.h | 1 + 4 files changed, 154 insertions(+), 19 deletions(-) diff --git a/src/FlightMap/FlightMap.qml b/src/FlightMap/FlightMap.qml index bcce2ad89..c510232df 100644 --- a/src/FlightMap/FlightMap.qml +++ b/src/FlightMap/FlightMap.qml @@ -137,11 +137,11 @@ Map { // Connections { // target: map.polygonDraw // - // onPolygonStarted: { + // onPolygonCaptureStarted: { // // Polygon creation has started // } // - // onPolygonFinished: { + // onPolygonCaptureFinished: { // // Polygon capture complete, coordinates signal variable contains the polygon points // } // } @@ -161,6 +161,30 @@ Map { horizontalAlignment: Text.AlignHCenter text: qsTr("Click to add point %1").arg(ScreenTools.isMobile || !polygonDrawer.polygonReady ? "" : qsTr("- Right Click to end polygon")) visible: polygonDrawer.drawingPolygon + + Connections { + target: polygonDrawer + + onDrawingPolygonChanged: { + if (polygonDrawer.drawingPolygon) { + polygonHelp.text = qsTr("Click to add point") + } + polygonHelp.visible = polygonDrawer.drawingPolygon + } + + onPolygonReadyChanged: { + if (polygonDrawer.polygonReady && !ScreenTools.isMobile) { + polygonHelp.text = qsTr("Click to add point - Right Click to end polygon") + } + } + + onAdjustingPolygonChanged: { + if (polygonDrawer.adjustingPolygon) { + polygonHelp.text = qsTr("Adjust polygon by dragging corners") + } + polygonHelp.visible = polygonDrawer.adjustingPolygon + } + } } MouseArea { @@ -170,28 +194,40 @@ Map { visible: drawingPolygon z: 1000 // Hack to fix MouseArea layering for now - property alias drawingPolygon: polygonDrawer.hoverEnabled - property bool polygonReady: polygonDrawerPolygon.path.length > 3 ///< true: enough points have been captured to create a closed polygon + property alias drawingPolygon: polygonDrawer.hoverEnabled + property bool adjustingPolygon: false + property bool polygonReady: polygonDrawerPolygon.path.length > 3 ///< true: enough points have been captured to create a closed polygon /// New polygon capture has started - signal polygonStarted + signal polygonCaptureStarted /// Polygon capture is complete /// @param coordinates Map coordinates for the polygon points - signal polygonFinished(var coordinates) + signal polygonCaptureFinished(var coordinates) + + /// Polygon adjustment has begun + signal polygonAdjustStarted + + /// Polygon Vertex coordinate has been adjusted + signal polygonAdjustVertex(int vertexIndex, var vertexCoordinate) + + /// Polygon adjustment finished + signal polygonAdjustFinished + + property var _vertexDragList: [] /// Begin capturing a new polygon - /// polygonStarted will be signalled - function startPolygon() { + /// polygonCaptureStarted will be signalled + function startCapturePolygon() { polygonDrawer.drawingPolygon = true polygonDrawer._clearPolygon() - polygonDrawer.polygonStarted() + polygonDrawer.polygonCaptureStarted() } /// Finish capturing the polygon - /// polygonFinished will be signalled + /// polygonCaptureFinished will be signalled /// @return true: polygon completed, false: not enough points to complete polygon - function finishPolygon() { + function finishCapturePolygon() { if (!polygonDrawer.polygonReady) { return false } @@ -200,10 +236,82 @@ Map { polygonPath.pop() // get rid of drag coordinate polygonDrawer._clearPolygon() polygonDrawer.drawingPolygon = false - polygonDrawer.polygonFinished(polygonPath) + polygonDrawer.polygonCaptureFinished(polygonPath) return true } + function startAdjustPolygon(vertexCoordinates) { + polygonDrawer.adjustingPolygon = true + for (var i=0; i