1 /*************************************************************************** 2 qgsmaptoolreverseline.h - reverse a line geometry 3 --------------------- 4 begin : April 2018 5 copyright : (C) 2018 by Loïc Bartoletti 6 email : loic dot bartoletti at oslandia dot com 7 *************************************************************************** 8 * * 9 * This program is free software; you can redistribute it and/or modify * 10 * it under the terms of the GNU General Public License as published by * 11 * the Free Software Foundation; either version 2 of the License, or * 12 * (at your option) any later version. * 13 * * 14 ***************************************************************************/ 15 16 #ifndef QGSMAPTOOLREVERSELINE_H 17 #define QGSMAPTOOLREVERSELINE_H 18 19 #include "qgsmaptooledit.h" 20 #include "qgis_app.h" 21 #include "qgsgeometry.h" 22 #include "qgsfeatureid.h" 23 24 25 class QgsVertexMarker; 26 27 //! Map tool to delete vertices from line/polygon features 28 class APP_EXPORT QgsMapToolReverseLine: public QgsMapToolEdit 29 { 30 Q_OBJECT 31 32 public: 33 QgsMapToolReverseLine( QgsMapCanvas *canvas ); 34 ~QgsMapToolReverseLine() override; 35 36 void canvasMoveEvent( QgsMapMouseEvent *e ) override; 37 38 void canvasPressEvent( QgsMapMouseEvent *e ) override; 39 40 void canvasReleaseEvent( QgsMapMouseEvent *e ) override; 41 42 //! called when map tool is being deactivated 43 void deactivate() override; 44 45 private: 46 QgsVectorLayer *vlayer = nullptr; 47 48 QgsGeometry partUnderPoint( QPoint p, QgsFeatureId &fid, int &partNum ); 49 50 /* Rubberband that shows the part being reversed*/ 51 std::unique_ptr<QgsRubberBand>mRubberBand; 52 53 //The feature and part where the mouse cursor was pressed 54 //This is used to check whether we are still in the same part at cursor release 55 QgsFeatureId mPressedFid = 0; 56 int mPressedPartNum = 0; 57 }; 58 59 #endif // QGSMAPTOOLREVERSELINE_H 60