Skip to content

Commit

Permalink
Remove QgsVectorLayer::snapPoint() and unused code in QgsSelectedFeature
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Apr 17, 2017
1 parent c749057 commit 7b202ed
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 109 deletions.
1 change: 1 addition & 0 deletions doc/api_break.dox
Expand Up @@ -2087,6 +2087,7 @@ displayExpression instead. For the map tip use mapTipTemplate() instead.
- checkJoinLayerRemove() has been removed. Joins are removed internally when joined layer is deleted.
- readXml() does not resolve references to joined layers. Call resolveReferences() when joined layers are available.
- snapWithContext(), snapToGeometry() - last argument has changed from QgsSnapper::SnappingType to QgsSnappingResult::SnappingType (no change in functionality).
- snapPoint() has been removed - use QgsPointLocator class instead.

QgsVectorLayerEditBuffer {#qgis_api_break_3_0_QgsVectorLayerEditBuffer}
------------------------
Expand Down
10 changes: 0 additions & 10 deletions python/core/qgsvectorlayer.sip
Expand Up @@ -1073,16 +1073,6 @@ Returns true if the provider has been modified since the last commit
:rtype: bool
%End

bool snapPoint( QgsPoint &point, double tolerance );
%Docstring
Snaps a point to the closest vertex if there is one within the snapping tolerance
\param point The point which is set to the position of a vertex if there is one within the snapping tolerance.
If there is no point within this tolerance, point is left unchanged.
\param tolerance The snapping tolerance
:return: true if the point has been snapped, false if no vertex within search tolerance
:rtype: bool
%End

int snapWithContext( const QgsPoint &startPoint,
double snappingTolerance,
QMultiMap < double, QgsSnappingResult > &snappingResults /Out/,
Expand Down
60 changes: 0 additions & 60 deletions src/app/nodetool/qgsselectedfeature.cpp
Expand Up @@ -308,66 +308,6 @@ void QgsSelectedFeature::deleteSelectedVertexes()
}
}

void QgsSelectedFeature::moveSelectedVertexes( QgsVector v )
{
int nUpdates = 0;
Q_FOREACH ( QgsVertexEntry *entry, mVertexMap )
{
if ( entry->isSelected() )
nUpdates++;
}

if ( nUpdates == 0 )
return;

mVlayer->beginEditCommand( QObject::tr( "Moved vertices" ) );
bool topologicalEditing = QgsProject::instance()->topologicalEditing();

beginGeometryChange();

QMultiMap<double, QgsSnappingResult> currentResultList;
for ( int i = mVertexMap.size() - 1; i > -1 && nUpdates > 0; i-- )
{
QgsVertexEntry *entry = mVertexMap.value( i, nullptr );
if ( !entry || !entry->isSelected() )
continue;

if ( topologicalEditing )
{
// snap from current vertex
currentResultList.clear();
mVlayer->snapWithContext( entry->pointV1(), ZERO_TOLERANCE, currentResultList, QgsSnappingResult::SnapToVertex );
}

// only last update should trigger the geometry update
// as vertex selection gets lost on the update
if ( --nUpdates == 0 )
endGeometryChange();

QgsPointV2 p = entry->point();
p.setX( p.x() + v.x() );
p.setY( p.y() + v.y() );
mVlayer->moveVertex( p, mFeatureId, i );

if ( topologicalEditing )
{
QMultiMap<double, QgsSnappingResult>::iterator resultIt = currentResultList.begin();

for ( ; resultIt != currentResultList.end(); ++resultIt )
{
// move all other
if ( mFeatureId != resultIt.value().snappedAtGeometry )
mVlayer->moveVertex( p, resultIt.value().snappedAtGeometry, resultIt.value().snappedVertexNr );
}
}
}

if ( nUpdates > 0 )
endGeometryChange();

mVlayer->endEditCommand();
}

void QgsSelectedFeature::replaceVertexMap()
{
// delete old map
Expand Down
6 changes: 0 additions & 6 deletions src/app/nodetool/qgsselectedfeature.h
Expand Up @@ -76,12 +76,6 @@ class QgsSelectedFeature: public QObject
*/
void deleteSelectedVertexes();

/**
* Moves selected vertex
* \param v translation vector
*/
void moveSelectedVertexes( QgsVector v );

/**
* Inverts selection of vertex with number
* \param vertexNr number of vertex which is to be inverted
Expand Down
25 changes: 0 additions & 25 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -2582,31 +2582,6 @@ bool QgsVectorLayer::addFeatures( QgsFeatureList features, bool makeSelected )
}


bool QgsVectorLayer::snapPoint( QgsPoint &point, double tolerance )
{
if ( !hasGeometryType() )
return false;

QMultiMap<double, QgsSnappingResult> snapResults;
int result = snapWithContext( point, tolerance, snapResults, QgsSnappingResult::SnapToVertex );

if ( result != 0 )
{
return false;
}

if ( snapResults.size() < 1 )
{
return false;
}

QMultiMap<double, QgsSnappingResult>::const_iterator snap_it = snapResults.constBegin();
point.setX( snap_it.value().snappedVertex.x() );
point.setY( snap_it.value().snappedVertex.y() );
return true;
}


int QgsVectorLayer::snapWithContext( const QgsPoint &startPoint, double snappingTolerance,
QMultiMap<double, QgsSnappingResult> &snappingResults,
QgsSnappingResult::SnappingType snap_to )
Expand Down
8 changes: 0 additions & 8 deletions src/core/qgsvectorlayer.h
Expand Up @@ -1061,14 +1061,6 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
//! Returns true if the provider has been modified since the last commit
virtual bool isModified() const;

/** Snaps a point to the closest vertex if there is one within the snapping tolerance
* \param point The point which is set to the position of a vertex if there is one within the snapping tolerance.
* If there is no point within this tolerance, point is left unchanged.
* \param tolerance The snapping tolerance
* \returns true if the point has been snapped, false if no vertex within search tolerance
*/
bool snapPoint( QgsPoint &point, double tolerance );

/** Snaps to segment or vertex within given tolerance
* \param startPoint point to snap (in layer coordinates)
* \param snappingTolerance distance tolerance for snapping
Expand Down

0 comments on commit 7b202ed

Please sign in to comment.