29 : mMapSettings( mapRenderer->mapSettings() )
30 , mSnapMode( SnapWithOneResult )
36 : mMapSettings( mapSettings )
44 return snapMapPoint( mapCoordPoint, snappingResult, excludePoints );
49 snappingResult.
clear();
60 for ( snapLayerIt = mSnapLayers.
begin(); snapLayerIt != mSnapLayers.
end(); ++snapLayerIt )
62 if ( !snapLayerIt->mLayer->hasGeometryType() )
65 currentResultList.
clear();
70 if ( snapLayerIt->mLayer->snapWithContext( layerCoordPoint, tolerance,
71 currentResultList, snapLayerIt->mSnapTo ) != 0 )
78 for ( currentResultIt = currentResultList.
begin(); currentResultIt != currentResultList.
end(); ++currentResultIt )
82 newResult = currentResultIt.
value();
91 cleanResultList( snappingResultList, excludePoints );
95 if ( evalIt == snappingResultList.
end() )
103 for ( evalIt = snappingResultList.
begin(); evalIt != snappingResultList.
end(); ++evalIt )
105 if ( evalIt.
value().snappedVertexNr != -1 )
107 returnResult = evalIt.
value();
108 snappingResultList.
erase( evalIt );
114 snappingResult.
push_back( returnResult );
123 double tolerance = 0.000001;
125 for ( evalIt = snappingResultList.
begin(); evalIt != snappingResultList.
end(); ++evalIt )
137 for ( evalIt = snappingResultList.
begin(); evalIt != snappingResultList.
end(); ++evalIt )
148 mSnapLayers = snapLayers;
154 mSnapMode = snapMode;
164 for ( ; result_it != list.
end(); ++result_it )
166 currentSnappingResult = result_it.
value();
170 if ( excludeList.
contains( currentResultPoint ) )
178 for ( ; remove_it != keysToRemove.
constEnd(); ++remove_it )
180 list.
remove( *remove_it );
iterator erase(iterator pos)
void push_back(const T &value)
QgsPoint toMapCoordinates(int x, int y) const
A non GUI class for rendering a map layer set onto a QPainter.
static double toleranceInMapUnits(double tolerance, QgsMapLayer *layer, const QgsMapSettings &mapSettings, UnitType units=LayerUnits)
Static function to translate tolerance value into layer units.
The QgsMapSettings class contains configuration for rendering of the map.
int snapMapPoint(const QgsPoint &mapCoordPoint, QList< QgsSnappingResult > &snappingResult, const QList< QgsPoint > &excludePoints=QList< QgsPoint >())
Does the snapping operation.
Represents the result of a snapping operation.
QMap< Key, T >::iterator insert(const Key &key, const T &value)
Several snapping results which have the same position are returned.
A class to represent a point.
const QgsMapToPixel & mapToPixel() const
QgsPoint beforeVertex
The layer coordinates of the vertex before snappedVertex.
QgsPoint afterVertex
The layer coordinates of the vertex after snappedVertex.
bool contains(const T &value) const
int snappedVertexNr
The vertex index of snappedVertex or -1 if no such vertex number (e.g.
Only one snapping result is returned.
QgsPoint layerToMapCoordinates(QgsMapLayer *theLayer, QgsPoint point) const
transform point coordinates from layer's CRS to output CRS
QgsPoint mapToLayerCoordinates(QgsMapLayer *theLayer, QgsPoint point) const
transform point coordinates from output CRS to layer's CRS
QgsPoint snappedVertex
The coordinates of the snapping result.
Q_DECL_DEPRECATED QgsSnapper(QgsMapRenderer *mapRender)
Q_DECL_DEPRECATED int snapPoint(QPoint startPoint, QList< QgsSnappingResult > &snappingResult, const QList< QgsPoint > &excludePoints=QList< QgsPoint >())
Does the snapping operation.
double sqrDist(double x, double y) const
Returns the squared distance between this point a specified x, y coordinate.
const_iterator constEnd() const
const_iterator constBegin() const
int remove(const Key &key)
void setSnapLayers(const QList< QgsSnapper::SnapLayer > &snapLayers)
void setSnapMode(QgsSnapper::SnappingMode snapMode)