1
/***************************************************************************
2
qgsmaptoolvertexedit.h - tool for adding, moving, deleting vertices
5
copyright : (C) 2006 by Martin Dobias
6
email : wonder.sk at gmail dot com
7
***************************************************************************
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. *
14
***************************************************************************/
17
#ifndef QGSMAPTOOLVERTEXEDIT_H
18
#define QGSMAPTOOLVERTEXEDIT_H
20
#include "qgsmaptool.h"
21
#include "qgsgeometry.h"
24
class QgsVertexMarker;
26
class QgsMapToolVertexEdit : public QgsMapTool
38
QgsMapToolVertexEdit(QgsMapCanvas* canvas, enum Tool tool);
40
virtual ~QgsMapToolVertexEdit();
42
//! Overridden mouse move event
43
virtual void canvasMoveEvent(QMouseEvent * e);
45
//! Overridden mouse press event
46
virtual void canvasPressEvent(QMouseEvent * e);
48
//! Overridden mouse release event
49
virtual void canvasReleaseEvent(QMouseEvent * e);
51
//! called when map tool is being deactivated
52
virtual void deactivate();
56
//! create instance of rubber band - done when the mouse is pressed down
57
void createRubberBand();
59
//! delete instance of rubber band - done when the mouse is released
60
void deleteRubberBand();
62
//! returns tolerance in map coordinates
65
/** Helper function to inverse project a point if projections
66
are enabled. Failsafe, returns the sent point if anything fails.
67
@whenmsg is a part fo the error message. */
68
QgsPoint maybeInversePoint(QgsPoint point, const char whenmsg[]);
70
//! current vertex edit tool
73
/**Searches the closest point within the project tolerance and setx mSnappedAtFeatureId and mSnappedAtVertex*/
74
bool snapVertexWithContext(QgsPoint& point);
76
/** Searches the closest vertex of "geometry" to the given "point"
78
This is useful when selecting a vertex to move, as the selection process is a two step process:
80
1. Select the closest line segment to the mouse pointer
81
(snapSegmentWithContext()).
82
2. Select the closest vertex on (1)
83
(snpVertexOfSnappedSegment()).
85
Step 1 is needed to disambiguate between two geometries sharing the same vertex.
87
bool snapVertexOfSnappedSegment(QgsPoint& point);
89
/**Snaps a point (without setting mSnappedAtFeatureId and mSnappedAtVertex). Does not snap to the specified vertex,
90
because during dragging, a vertex should not be snapped to itself*/
91
bool snapVertex(QgsPoint& point, int exclFeatureId, int exclVertexNr);
94
bool snapSegmentWithContext(QgsPoint& point);
97
//! The snapped-to segment before this vertex number (identifying the vertex that is being moved)
98
QgsGeometryVertexIndex mSnappedAtVertex;
100
/**The index of the first rubber band point (to connect to mSnappedatVertex). -1 if no such point exists*/
101
int mRubberBandIndex1;
103
/**The index of the second rubber band point (to connect to mSnappedatVertex). -1 if no such point exists*/
104
int mRubberBandIndex2;
106
//! The snapped-to segment before this vertex number (identifying the segment that a new vertex is being added to)
107
QgsGeometryVertexIndex mSnappedBeforeVertex;
109
//! The snapped-to feature ID
110
int mSnappedAtFeatureId;
112
//! The snapped-to geometry
113
QgsGeometry mSnappedAtGeometry;
115
QgsRubberBand* mRubberBand;
117
bool mStartPointValid;
118
bool mStopPointValid;
120
QgsVertexMarker* mCross;