QgsMapCanvasSnapper Class Reference
[Gui]

#include <qgsmapcanvassnapper.h>

Collaboration diagram for QgsMapCanvasSnapper:

Collaboration graph
[legend]
List of all members.

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 (usefull for selecting a vertex to manipulate) or to background layers

Definition at line 34 of file 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

QgsMapCanvasmMapCanvas
 Pointer to the map canvas.
QgsSnappermSnapper
 The object which does the snapping operations.


Constructor & Destructor Documentation

QgsMapCanvasSnapper::QgsMapCanvasSnapper ( QgsMapCanvas canvas  ) 

Constructor.

Parameters:
canvas the map canvas to snap to

Definition at line 26 of file qgsmapcanvassnapper.cpp.

References QgsMapCanvas::mapRenderer(), and mSnapper.

QgsMapCanvasSnapper::QgsMapCanvasSnapper (  ) 

Definition at line 38 of file qgsmapcanvassnapper.cpp.

QgsMapCanvasSnapper::~QgsMapCanvasSnapper (  ) 

Definition at line 43 of file qgsmapcanvassnapper.cpp.

References mSnapper.


Member Function Documentation

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.

Parameters:
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 62 of file qgsmapcanvassnapper.cpp.

References QgsMapCanvas::currentLayer(), QgsProject::instance(), QgsSnapper::SnapLayer::mLayer, mMapCanvas, mSnapper, QgsSnapper::SnapLayer::mSnapTo, QgsSnapper::SnapLayer::mTolerance, QgsProject::readNumEntry(), QgsSnapper::setSnapLayers(), QgsSnapper::setSnapMode(), QgsSnapper::snapPoint(), QgsSnapper::SnapWithOneResult, and QgsSnapper::SnapWithResultsForSamePosition.

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

Snaps to the background layers.

This method is usefull 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:
p start point of the snap (in pixel coordinates)
result snapped point
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
Returns:
0 in case of success

Definition at line 125 of file qgsmapcanvassnapper.cpp.

References QgsMapCanvas::currentLayer(), QgsMapLayerRegistry::instance(), QgsProject::instance(), QgsMapLayerRegistry::mapLayer(), QgsSnapper::SnapLayer::mLayer, mMapCanvas, mSnapper, QgsSnapper::SnapLayer::mSnapTo, QgsSnapper::SnapLayer::mTolerance, QgsProject::readListEntry(), QgsProject::readNumEntry(), QgsSnapper::setSnapLayers(), QgsSnapper::setSnapMode(), QgsSnapper::snapPoint(), QgsSnapper::SnapToSegment, QgsSnapper::SnapToVertex, QgsSnapper::SnapToVertexAndSegment, QgsSnapper::SnapWithOneResult, and QgsSnapper::SnapWithResultsForSamePosition.

void QgsMapCanvasSnapper::setMapCanvas ( QgsMapCanvas canvas  ) 

Definition at line 48 of file qgsmapcanvassnapper.cpp.

References QgsMapCanvas::mapRenderer(), mMapCanvas, and mSnapper.


Member Data Documentation

QgsMapCanvas* QgsMapCanvasSnapper::mMapCanvas [private]

Pointer to the map canvas.

Definition at line 70 of file qgsmapcanvassnapper.h.

Referenced by setMapCanvas(), snapToBackgroundLayers(), and snapToCurrentLayer().

QgsSnapper* QgsMapCanvasSnapper::mSnapper [private]

The object which does the snapping operations.

Definition at line 72 of file qgsmapcanvassnapper.h.

Referenced by QgsMapCanvasSnapper(), setMapCanvas(), snapToBackgroundLayers(), snapToCurrentLayer(), and ~QgsMapCanvasSnapper().


The documentation for this class was generated from the following files:
Generated on Tue Jan 6 16:51:21 2009 for Quantum GIS API Documentation by  doxygen 1.5.1