QGIS API Documentation
2.2.0-Valmiera
|
This class reads the snapping properties from the current project and configures a QgsSnapper to perform the snapping. More...
#include <qgsmapcanvassnapper.h>
Public Member Functions | |
QgsMapCanvasSnapper (QgsMapCanvas *canvas) | |
Constructor. | |
QgsMapCanvasSnapper () | |
~QgsMapCanvasSnapper () | |
int | snapToCurrentLayer (const QPoint &p, QList< QgsSnappingResult > &results, QgsSnapper::SnappingType snap_to, double snappingTol=-1, const QList< QgsPoint > &excludePoints=QList< QgsPoint >()) |
Does a snap to the current layer. | |
int | snapToBackgroundLayers (const QPoint &p, QList< QgsSnappingResult > &results, const QList< QgsPoint > &excludePoints=QList< QgsPoint >()) |
Snaps to the background layers. | |
void | setMapCanvas (QgsMapCanvas *canvas) |
Private Attributes | |
QgsMapCanvas * | mMapCanvas |
Pointer to the map canvas. | |
QgsSnapper * | mSnapper |
The object which does the snapping operations. |
This class reads the snapping properties from the current project and configures a QgsSnapper to perform the snapping.
Snapping can be done to the active layer (useful for selecting a vertex to manipulate) or to background layers
Definition at line 33 of file qgsmapcanvassnapper.h.
QgsMapCanvasSnapper::QgsMapCanvasSnapper | ( | QgsMapCanvas * | canvas | ) |
Constructor.
canvas | the map canvas to snap to |
Definition at line 29 of file qgsmapcanvassnapper.cpp.
References QgsMapCanvas::mapRenderer(), and mSnapper.
QgsMapCanvasSnapper::QgsMapCanvasSnapper | ( | ) |
Definition at line 43 of file qgsmapcanvassnapper.cpp.
QgsMapCanvasSnapper::~QgsMapCanvasSnapper | ( | ) |
Definition at line 47 of file qgsmapcanvassnapper.cpp.
References mSnapper.
void QgsMapCanvasSnapper::setMapCanvas | ( | QgsMapCanvas * | canvas | ) |
Definition at line 52 of file qgsmapcanvassnapper.cpp.
References QgsMapCanvas::mapRenderer(), mMapCanvas, and mSnapper.
int QgsMapCanvasSnapper::snapToBackgroundLayers | ( | const QPoint & | p, |
QList< QgsSnappingResult > & | results, | ||
const QList< QgsPoint > & | excludePoints = QList<QgsPoint>() |
||
) |
Snaps to the background layers.
This method is useful to align the features of the edited layers to those of other layers (as described in the project properties). Uses snap mode QgsSnapper::SnapWithOneResult. Therefore, only the closest result is returned.
p | start point of the snap (in pixel coordinates) |
results | snapped points |
excludePoints | a list with (map coordinate) points that should be excluded in the snapping result. Useful e.g. for vertex moves where a vertex should not be snapped to its original position |
Definition at line 121 of file qgsmapcanvassnapper.cpp.
References QgsGeometry::asPoint(), QgsMapCanvas::currentLayer(), QgsTolerance::defaultTolerance(), QgsGeometry::fromPolyline(), QgsVectorLayer::hasGeometryType(), QgsMapLayerRegistry::instance(), QgsProject::instance(), QgsGeometry::intersection(), QgsMapLayerRegistry::mapLayer(), QgsMapCanvas::mapRenderer(), QgsTolerance::MapUnits, QgsSnapper::SnapLayer::mLayer, mMapCanvas, mSnapper, QgsSnapper::SnapLayer::mSnapTo, QgsSnapper::SnapLayer::mTolerance, QgsSnapper::SnapLayer::mUnitType, QGis::Point, QgsDebugMsg, QgsProject::readListEntry(), QgsProject::readNumEntry(), QgsSnapper::setSnapLayers(), QgsSnapper::setSnapMode(), QgsSnapper::snapPoint(), QgsSnapper::SnapToSegment, QgsSnapper::SnapToVertex, QgsSnapper::SnapToVertexAndSegment, QgsSnapper::SnapWithOneResult, QgsSnapper::SnapWithResultsForSamePosition, QgsSnapper::SnapWithResultsWithinTolerances, and QgsGeometry::type().
int QgsMapCanvasSnapper::snapToCurrentLayer | ( | const QPoint & | p, |
QList< QgsSnappingResult > & | results, | ||
QgsSnapper::SnappingType | snap_to, | ||
double | snappingTol = -1 , |
||
const QList< QgsPoint > & | excludePoints = QList<QgsPoint>() |
||
) |
Does a snap to the current layer.
Uses snap mode QgsSnapper::SnapWithResultsForSamePosition if topological editing is enabled and QgsSnapper::SnapWithOneResult_BY_SEGMENT if not. As this method is usually used to find vertices/segments for editing operations, it uses the search radius for vertex editing from the qgis options.
p | start point of the snap (in pixel coordinates) |
results | list to which the results are appended |
snap_to | snap to vertex or to segment |
snappingTol | snapping tolerance. -1 means that the search radius for vertex edits is taken |
excludePoints | a list with (map coordinate) points that should be excluded in the snapping result. Useful e.g. for vertex moves where a vertex should not be snapped to its original position |
Definition at line 66 of file qgsmapcanvassnapper.cpp.
References QgsMapCanvas::currentLayer(), QgsProject::instance(), QgsMapCanvas::mapRenderer(), QgsTolerance::MapUnits, QgsSnapper::SnapLayer::mLayer, mMapCanvas, mSnapper, QgsSnapper::SnapLayer::mSnapTo, QgsSnapper::SnapLayer::mTolerance, QgsSnapper::SnapLayer::mUnitType, QgsProject::readNumEntry(), QgsSnapper::setSnapLayers(), QgsSnapper::setSnapMode(), QgsSnapper::snapPoint(), QgsSnapper::SnapWithOneResult, QgsSnapper::SnapWithResultsForSamePosition, and QgsTolerance::vertexSearchRadius().
|
private |
Pointer to the map canvas.
Definition at line 69 of file qgsmapcanvassnapper.h.
Referenced by setMapCanvas(), snapToBackgroundLayers(), and snapToCurrentLayer().
|
private |
The object which does the snapping operations.
Definition at line 71 of file qgsmapcanvassnapper.h.
Referenced by QgsMapCanvasSnapper(), setMapCanvas(), snapToBackgroundLayers(), snapToCurrentLayer(), and ~QgsMapCanvasSnapper().