From 7cbbf378b86e58eaf076d223da231f97cf207cfb Mon Sep 17 00:00:00 2001 From: Aleksey Kontsevich Date: Mon, 8 Jun 2020 14:37:34 +0300 Subject: [PATCH] QGCMapPolygon select vertexes functionality --- src/MissionManager/QGCMapPolygon.cc | 12 ++++++++++++ src/MissionManager/QGCMapPolygon.h | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/src/MissionManager/QGCMapPolygon.cc b/src/MissionManager/QGCMapPolygon.cc index 8f088917f..26e7cca71 100644 --- a/src/MissionManager/QGCMapPolygon.cc +++ b/src/MissionManager/QGCMapPolygon.cc @@ -311,6 +311,7 @@ void QGCMapPolygon::removeVertex(int vertexIndex) QObject* coordObj = _polygonModel.removeAt(vertexIndex); coordObj->deleteLater(); + selectVertex(-1); _polygonPath.removeAt(vertexIndex); emit pathChanged(); @@ -622,3 +623,14 @@ void QGCMapPolygon::setShowAltColor(bool showAltColor){ emit showAltColorChanged(showAltColor); } } + +void QGCMapPolygon::selectVertex(int index) +{ + if(0 <= index && index < count() && index != _selectedVertexIndex) { + _selectedVertexIndex = index; + } else { + _selectedVertexIndex = -1; // deselect vertex + } + + emit selectedVertexChanged(_selectedVertexIndex); +} diff --git a/src/MissionManager/QGCMapPolygon.h b/src/MissionManager/QGCMapPolygon.h index 08612b5ae..8ac0df731 100644 --- a/src/MissionManager/QGCMapPolygon.h +++ b/src/MissionManager/QGCMapPolygon.h @@ -42,6 +42,7 @@ public: Q_PROPERTY(bool empty READ empty NOTIFY isEmptyChanged) Q_PROPERTY(bool traceMode READ traceMode WRITE setTraceMode NOTIFY traceModeChanged) Q_PROPERTY(bool showAltColor READ showAltColor WRITE setShowAltColor NOTIFY showAltColorChanged) + Q_PROPERTY(int selectedVertex READ selectedVertex WRITE selectVertex NOTIFY selectedVertexChanged) Q_INVOKABLE void clear(void); Q_INVOKABLE void appendVertex(const QGeoCoordinate& coordinate); @@ -111,6 +112,7 @@ public: bool empty (void) const { return _polygonModel.count() == 0; } bool traceMode (void) const { return _traceMode; } bool showAltColor(void) const { return _showAltColor; } + int selectedVertex() const { return _selectedVertexIndex; } QVariantList path (void) const { return _polygonPath; } QmlObjectListModel* qmlPathModel(void) { return &_polygonModel; } @@ -123,6 +125,7 @@ public: void setInteractive (bool interactive); void setTraceMode (bool traceMode); void setShowAltColor(bool showAltColor); + void selectVertex (int index); static const char* jsonPolygonKey; @@ -138,6 +141,7 @@ signals: bool isEmptyChanged (void); void traceModeChanged (bool traceMode); void showAltColorChanged(bool showAltColor); + void selectedVertexChanged(int index); private slots: void _polygonModelCountChanged(int count); @@ -162,6 +166,7 @@ private: bool _resetActive = false; bool _traceMode = false; bool _showAltColor = false; + int _selectedVertexIndex = -1; }; #endif -- 2.22.0