QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
QgsSnapper Class Reference

A class that allows advanced snapping operations on a set of vector layers. More...

#include <qgssnapper.h>

Collaboration diagram for QgsSnapper:
Collaboration graph
[legend]

Classes

struct  SnapLayer

Public Types

enum  SnappingType { SnapToVertex, SnapToSegment, SnapToVertexAndSegment }
 Snap to vertex, to segment or both. More...
enum  SnappingMode { SnapWithOneResult, SnapWithResultsForSamePosition, SnapWithResultsWithinTolerances }

Public Member Functions

 QgsSnapper (QgsMapRenderer *mapRender)
 ~QgsSnapper ()
int snapPoint (const QPoint &startPoint, QList< QgsSnappingResult > &snappingResult, const QList< QgsPoint > &excludePoints=QList< QgsPoint >())
 Does the snapping operation.
void setSnapLayers (const QList< QgsSnapper::SnapLayer > &snapLayers)
void setSnapMode (QgsSnapper::SnappingMode snapMode)

Private Member Functions

 QgsSnapper ()
 Don't use the default constructor.
void cleanResultList (QMultiMap< double, QgsSnappingResult > &list, const QList< QgsPoint > &excludeList) const
 Removes the snapping results that contains points in exclude list.

Private Attributes

QgsMapRenderermMapRenderer
 The maprender object contains information about the output coordinate system of the map and about the relationship between pixel space and map space.
QgsSnapper::SnappingMode mSnapMode
 Snap mode to apply.
QList< QgsSnapper::SnapLayermSnapLayers
 List of layers to which snapping is applied.

Detailed Description

A class that allows advanced snapping operations on a set of vector layers.

Definition at line 61 of file qgssnapper.h.

Member Enumeration Documentation

Enumerator:
SnapWithOneResult 

Only one snapping result is returned.

SnapWithResultsForSamePosition 

Several snapping results which have the same position are returned.

This is useful for topological editing

SnapWithResultsWithinTolerances 

All results within the given layer tolerances are returned.

Definition at line 73 of file qgssnapper.h.

Snap to vertex, to segment or both.

Enumerator:
SnapToVertex 
SnapToSegment 
SnapToVertexAndSegment 

Definition at line 65 of file qgssnapper.h.

Constructor & Destructor Documentation

QgsSnapper::QgsSnapper ( QgsMapRenderer mapRender)

Definition at line 27 of file qgssnapper.cpp.

QgsSnapper::~QgsSnapper ( )

Definition at line 37 of file qgssnapper.cpp.

QgsSnapper::QgsSnapper ( )
private

Don't use the default constructor.

Definition at line 32 of file qgssnapper.cpp.

Member Function Documentation

void QgsSnapper::cleanResultList ( QMultiMap< double, QgsSnappingResult > &  list,
const QList< QgsPoint > &  excludeList 
) const
private

Removes the snapping results that contains points in exclude list.

Definition at line 135 of file qgssnapper.cpp.

References QgsSnappingResult::snappedVertex, and QgsSnappingResult::snappedVertexNr.

Referenced by snapPoint().

void QgsSnapper::setSnapLayers ( const QList< QgsSnapper::SnapLayer > &  snapLayers)
void QgsSnapper::setSnapMode ( QgsSnapper::SnappingMode  snapMode)
int QgsSnapper::snapPoint ( const QPoint &  startPoint,
QList< QgsSnappingResult > &  snappingResult,
const QList< QgsPoint > &  excludePoints = QList<QgsPoint>() 
)

Does the snapping operation.

Parameters
startPointthe start point for snapping (in pixel coordinates)
snappingResultthe list where the results are inserted (everything in map coordinate system)
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 42 of file qgssnapper.cpp.

References QgsSnappingResult::afterVertex, QgsSnappingResult::beforeVertex, cleanResultList(), QgsMapRenderer::coordinateTransform(), QgsMapRenderer::layerToMapCoordinates(), QgsMapRenderer::mapToLayerCoordinates(), mMapRenderer, mSnapLayers, mSnapMode, QgsSnappingResult::snappedVertex, SnapWithOneResult, SnapWithResultsForSamePosition, QgsPoint::sqrDist(), QgsTolerance::toleranceInMapUnits(), and QgsMapToPixel::toMapCoordinates().

Referenced by QgsMapCanvasSnapper::snapToBackgroundLayers(), and QgsMapCanvasSnapper::snapToCurrentLayer().

Member Data Documentation

QgsMapRenderer* QgsSnapper::mMapRenderer
private

The maprender object contains information about the output coordinate system of the map and about the relationship between pixel space and map space.

Definition at line 118 of file qgssnapper.h.

Referenced by snapPoint().

QList<QgsSnapper::SnapLayer> QgsSnapper::mSnapLayers
private

List of layers to which snapping is applied.

Definition at line 122 of file qgssnapper.h.

Referenced by setSnapLayers(), and snapPoint().

QgsSnapper::SnappingMode QgsSnapper::mSnapMode
private

Snap mode to apply.

Definition at line 120 of file qgssnapper.h.

Referenced by setSnapMode(), and snapPoint().


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