QGIS API Documentation  2.99.0-Master (0a63d1f)
Public Member Functions | List of all members
QgsMapCanvasSnapper Class Reference

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. More...
 
 QgsMapCanvasSnapper ()
 
 QgsMapCanvasSnapper (const QgsMapCanvasSnapper &rh)=delete
 QgsMapCanvasSnapper cannot be copied. More...
 
 ~QgsMapCanvasSnapper ()
 
QgsMapCanvasSnapperoperator= (const QgsMapCanvasSnapper &rh)=delete
 QgsMapCanvasSnapper cannot be copied. More...
 
void setMapCanvas (QgsMapCanvas *canvas)
 
int snapToBackgroundLayers (QPoint p, QList< QgsSnappingResult > &results, const QList< QgsPoint > &excludePoints=QList< QgsPoint >())
 Snaps to the background layers. More...
 
int snapToBackgroundLayers (const QgsPoint &point, QList< QgsSnappingResult > &results, const QList< QgsPoint > &excludePoints=QList< QgsPoint >())
 
int snapToCurrentLayer (QPoint p, QList< QgsSnappingResult > &results, QgsSnapper::SnappingType snap_to, double snappingTol=-1, const QList< QgsPoint > &excludePoints=QList< QgsPoint >(), bool allResutInTolerance=false)
 Does a snap to the current layer. More...
 

Detailed Description

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 34 of file qgsmapcanvassnapper.h.

Constructor & Destructor Documentation

◆ QgsMapCanvasSnapper() [1/3]

QgsMapCanvasSnapper::QgsMapCanvasSnapper ( QgsMapCanvas canvas)

Constructor.

Parameters
canvasthe map canvas to snap to

Definition at line 28 of file qgsmapcanvassnapper.cpp.

◆ QgsMapCanvasSnapper() [2/3]

QgsMapCanvasSnapper::QgsMapCanvasSnapper ( )

Definition at line 38 of file qgsmapcanvassnapper.cpp.

◆ ~QgsMapCanvasSnapper()

QgsMapCanvasSnapper::~QgsMapCanvasSnapper ( )

Definition at line 42 of file qgsmapcanvassnapper.cpp.

◆ QgsMapCanvasSnapper() [3/3]

QgsMapCanvasSnapper::QgsMapCanvasSnapper ( const QgsMapCanvasSnapper rh)
delete

QgsMapCanvasSnapper cannot be copied.

Member Function Documentation

◆ operator=()

QgsMapCanvasSnapper& QgsMapCanvasSnapper::operator= ( const QgsMapCanvasSnapper rh)
delete

QgsMapCanvasSnapper cannot be copied.

◆ setMapCanvas()

void QgsMapCanvasSnapper::setMapCanvas ( QgsMapCanvas canvas)

Definition at line 47 of file qgsmapcanvassnapper.cpp.

◆ snapToBackgroundLayers() [1/2]

int QgsMapCanvasSnapper::snapToBackgroundLayers ( 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.

Parameters
pstart point of the snap (in pixel coordinates)
resultssnapped points
excludePointsa 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
Returns
0 in case of success

Definition at line 122 of file qgsmapcanvassnapper.cpp.

◆ snapToBackgroundLayers() [2/2]

int QgsMapCanvasSnapper::snapToBackgroundLayers ( const QgsPoint point,
QList< QgsSnappingResult > &  results,
const QList< QgsPoint > &  excludePoints = QList<QgsPoint>() 
)

Definition at line 128 of file qgsmapcanvassnapper.cpp.

◆ snapToCurrentLayer()

int QgsMapCanvasSnapper::snapToCurrentLayer ( QPoint  p,
QList< QgsSnappingResult > &  results,
QgsSnapper::SnappingType  snap_to,
double  snappingTol = -1,
const QList< QgsPoint > &  excludePoints = QList<QgsPoint>(),
bool  allResutInTolerance = false 
)

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.

Parameters
pstart point of the snap (in pixel coordinates)
resultslist to which the results are appended
snap_tosnap to vertex or to segment
snappingTolsnapping tolerance. -1 means that the search radius for vertex edits is taken
excludePointsa 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
allResutInTolerancereturn all thew results in the tolerance

Definition at line 61 of file qgsmapcanvassnapper.cpp.


The documentation for this class was generated from the following files: