QGIS API Documentation  2.5.0-Master
 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

Q_DECL_DEPRECATED QgsSnapper (QgsMapRenderer *mapRender)
 @ deprecated since 2.4 - use constructor with QgsMapSettings More...
 
 QgsSnapper (const QgsMapSettings &mapSettings)
 
 ~QgsSnapper ()
 
int snapPoint (const QPoint &startPoint, QList< QgsSnappingResult > &snappingResult, const QList< QgsPoint > &excludePoints=QList< QgsPoint >())
 Does the snapping operation. More...
 
void setSnapLayers (const QList< QgsSnapper::SnapLayer > &snapLayers)
 
void setSnapMode (QgsSnapper::SnappingMode snapMode)
 

Private Member Functions

void cleanResultList (QMultiMap< double, QgsSnappingResult > &list, const QList< QgsPoint > &excludeList) const
 Removes the snapping results that contains points in exclude list. More...
 

Private Attributes

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

Detailed Description

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

Definition at line 62 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 74 of file qgssnapper.h.

Snap to vertex, to segment or both.

Enumerator
SnapToVertex 
SnapToSegment 
SnapToVertexAndSegment 

Definition at line 66 of file qgssnapper.h.

Constructor & Destructor Documentation

QgsSnapper::QgsSnapper ( QgsMapRenderer mapRender)

@ deprecated since 2.4 - use constructor with QgsMapSettings

Definition at line 28 of file qgssnapper.cpp.

QgsSnapper::QgsSnapper ( const QgsMapSettings mapSettings)
explicit

Definition at line 34 of file qgssnapper.cpp.

QgsSnapper::~QgsSnapper ( )

Definition at line 39 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 154 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 44 of file qgssnapper.cpp.

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

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

Member Data Documentation

const QgsMapSettings& QgsSnapper::mMapSettings
private

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

Definition at line 122 of file qgssnapper.h.

Referenced by snapPoint().

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

List of layers to which snapping is applied.

Definition at line 126 of file qgssnapper.h.

Referenced by setSnapLayers(), and snapPoint().

QgsSnapper::SnappingMode QgsSnapper::mSnapMode
private

Snap mode to apply.

Definition at line 124 of file qgssnapper.h.

Referenced by setSnapMode(), and snapPoint().


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