Skip to content

Commit

Permalink
Commited patch from Stefanie for QgsVectorLayer::snapToGeometry
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8150 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Feb 13, 2008
1 parent 40f8ba5 commit a60ebc7
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions src/core/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2850,6 +2850,8 @@ void QgsVectorLayer::snapToGeometry(const QgsPoint& startPoint, int featureId, Q
}
snappingResultVertex.snappedAtGeometry = featureId;
snappingResultVertex.layer = this;
snappingResults.insert(sqrt(sqrDistVertexSnap), snappingResultVertex);
return;
}
}
if(snap_to == QgsSnapper::SNAP_TO_SEGMENT || snap_to == QgsSnapper::SNAP_TO_VERTEX_AND_SEGMENT) //snap to segment
Expand All @@ -2868,29 +2870,11 @@ void QgsVectorLayer::snapToGeometry(const QgsPoint& startPoint, int featureId, Q
snappingResultSegment.beforeVertex = geom->vertexAt(afterVertex - 1);
snappingResultSegment.afterVertex = geom->vertexAt(afterVertex);
snappingResultSegment.layer = this;
snappingResults.insert(sqrt(sqrDistSegmentSnap), snappingResultSegment);
}
}
}

if(snap_to == QgsSnapper::SNAP_TO_VERTEX && sqrDistVertexSnap < sqrSnappingTolerance)
{
snappingResults.insert(sqrt(sqrDistVertexSnap), snappingResultVertex);
}
else if(snap_to == QgsSnapper::SNAP_TO_SEGMENT && sqrDistSegmentSnap < sqrSnappingTolerance && vectorType() != QGis::Point)
{
snappingResults.insert(sqrt(sqrDistSegmentSnap), snappingResultSegment);
}
else if(snap_to == QgsSnapper::SNAP_TO_VERTEX_AND_SEGMENT) //to vertex and segment
{
if(sqrDistVertexSnap < sqrSnappingTolerance)
{
snappingResults.insert(sqrt(sqrDistVertexSnap), snappingResultVertex);
}
else if(sqrDistSegmentSnap < sqrSnappingTolerance && vectorType() != QGis::Point)
{
snappingResults.insert(sqrt(sqrDistSegmentSnap), snappingResultSegment);
}
}
}

int QgsVectorLayer::insertSegmentVerticesForSnap(const QList<QgsSnappingResult>& snapResults)
Expand Down

0 comments on commit a60ebc7

Please sign in to comment.