Skip to content
Permalink
Browse files
Remove QgsVectorLayer::snapPoint() and unused code in QgsSelectedFeature
  • Loading branch information
wonder-sk committed Apr 17, 2017
1 parent c749057 commit 7b202edf049bf5d744d6bbd9a50faa681a107e7e
Showing with 1 addition and 109 deletions.
  1. +1 −0 doc/api_break.dox
  2. +0 −10 python/core/qgsvectorlayer.sip
  3. +0 −60 src/app/nodetool/qgsselectedfeature.cpp
  4. +0 −6 src/app/nodetool/qgsselectedfeature.h
  5. +0 −25 src/core/qgsvectorlayer.cpp
  6. +0 −8 src/core/qgsvectorlayer.h
@@ -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}
------------------------
@@ -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/,
@@ -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
@@ -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
@@ -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 )
@@ -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

0 comments on commit 7b202ed

Please sign in to comment.