1
/***************************************************************************
2
qgsmaptooledit.h - base class for editing map tools
5
copyright : (C) 2007 by Marco Hugentobler
6
email : marco dot hugentobler at karto dot baug dot ethz dot ch
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 QGSMAPTOOLEDIT_H
18
#define QGSMAPTOOLEDIT_H
20
#include "qgsmaptool.h"
21
#include "qgsmapcanvassnapper.h"
26
/**Base class for map tools that edit vector geometry*/
27
class QgsMapToolEdit: public QgsMapTool
30
QgsMapToolEdit( QgsMapCanvas* canvas );
31
virtual ~QgsMapToolEdit();
33
virtual bool isEditTool() { return true; }
36
/**Snapper object that reads the settings from project and option
37
and applies it to the map canvas*/
38
QgsMapCanvasSnapper mSnapper;
40
/**Inserts vertices to the snapped segments of the editing layer.
41
This is useful for topological editing if snap to segment is enabled.
42
@param snapResults results collected from the snapping operation
43
@param editedLayer pointer to the editing layer
44
@return 0 in case of success*/
45
int insertSegmentVerticesForSnap( const QList<QgsSnappingResult>& snapResults, QgsVectorLayer* editedLayer );
47
/**Extracts a single snapping point from a set of snapping results.
48
This is useful for snapping operations that just require a position to snap to and not all the
49
snapping results. If the list is empty, the screen coordinates are transformed into map coordinates and returned
50
@param snapResults results collected from the snapping operation.
51
@return the snapped point in map coordinates*/
52
QgsPoint snapPointFromResults( const QList<QgsSnappingResult>& snapResults, const QPoint& screenCoords );
54
/**Creates a rubber band with the color/line width from
55
the QGIS settings. The caller takes ownership of the
57
QgsRubberBand* createRubberBand( bool isPolygon = false );
59
/**Returns the current vector layer of the map canvas or 0*/
60
QgsVectorLayer* currentVectorLayer();
62
/**Adds vertices to other features to keep topology up to date, e.g. to neighbouring polygons.
63
@param geom list of points (in layer coordinate system)
64
@return 0 in case of success*/
65
int addTopologicalPoints( const QList<QgsPoint>& geom );