30 : mMapCanvas( canvas )
65 const QList<QgsPoint>& excludePoints )
69 if ( !mSnapper || !mMapCanvas )
74 if ( topologicalEditing == 0 )
97 if ( snappingTol < 0 )
107 QList<QgsSnapper::SnapLayer> snapLayers;
108 snapLayers.append( snapLayer );
111 if ( mSnapper->
snapMapPoint( p, results, excludePoints ) != 0 )
136 if ( topologicalEditing == 0 )
138 if ( intersectionSnapping == 0 )
143 else if ( intersectionSnapping == 0 )
153 bool snappingDefinedInProject, ok;
160 if ( !( layerIdList.size() == enabledList.size() &&
161 layerIdList.size() == toleranceList.size() &&
162 layerIdList.size() == toleranceUnitList.size() &&
163 layerIdList.size() == snapToList.size() ) )
169 QList<QgsSnapper::SnapLayer> snapLayers;
173 if ( snappingDefinedInProject )
176 QStringList::const_iterator layerIt( layerIdList.constBegin() );
177 QStringList::const_iterator tolIt( toleranceList.constBegin() );
178 QStringList::const_iterator tolUnitIt( toleranceUnitList.constBegin() );
179 QStringList::const_iterator snapIt( snapToList.constBegin() );
180 QStringList::const_iterator enabledIt( enabledList.constBegin() );
181 for ( ; layerIt != layerIdList.constEnd(); ++layerIt, ++tolIt, ++tolUnitIt, ++snapIt, ++enabledIt )
183 if ( *enabledIt !=
"enabled" )
194 snapLayer.
mLayer = vlayer;
201 if ( *snapIt ==
"to_vertex" )
205 else if ( *snapIt ==
"to_segment" )
215 snapLayers.append( snapLayer );
226 if ( !currentVectorLayer )
229 snapLayer.
mLayer = currentVectorLayer;
233 QString defaultSnapString = settings.value(
"/qgis/digitizing/default_snap_mode",
"off" ).toString();
234 if ( defaultSnapString ==
"to segment" )
238 else if ( defaultSnapString ==
"to vertex and segment" )
242 else if ( defaultSnapString ==
"to vertex" )
255 snapLayers.append( snapLayer );
260 if ( mSnapper->
snapMapPoint( point, results, excludePoints ) != 0 )
263 if ( intersectionSnapping != 1 )
266 QList<QgsSnappingResult> segments;
267 QList<QgsSnappingResult> points;
268 for ( QList<QgsSnappingResult>::const_iterator it = results.constBegin();
269 it != results.constEnd();
272 if ( it->snappedVertexNr == -1 )
275 segments.push_back( *it );
280 points.push_back( *it );
284 if ( segments.length() < 2 )
287 QList<QgsSnappingResult> myResults;
289 for ( QList<QgsSnappingResult>::const_iterator oSegIt = segments.constBegin();
290 oSegIt != segments.constEnd();
293 QgsDebugMsg( QString::number( oSegIt->beforeVertexNr ) );
295 QVector<QgsPoint> vertexPoints;
296 vertexPoints.append( oSegIt->beforeVertex );
297 vertexPoints.append( oSegIt->afterVertex );
301 for ( QList<QgsSnappingResult>::iterator iSegIt = segments.begin();
302 iSegIt != segments.end();
305 QVector<QgsPoint> vertexPoints;
306 vertexPoints.append( iSegIt->beforeVertex );
307 vertexPoints.append( iSegIt->afterVertex );
314 double toleranceA = 0;
315 double toleranceB = 0;
316 for (
int i = 0 ;i < snapLayers.size();++i )
318 if ( snapLayers[i].mLayer == oSegIt->layer )
322 if ( snapLayers[i].mLayer == iSegIt->layer )
328 double distance = intersectionPoint->
distance( *cursorPoint );
329 if ( distance < toleranceA && distance < toleranceB )
331 iSegIt->snappedVertex = intersectionPoint->
asPoint();
332 myResults.append( *iSegIt );
338 if ( myResults.length() > 0 )