Skip to content

Commit

Permalink
R.I.P. QgsSnapper and QgsMapCanvasSnapper
Browse files Browse the repository at this point in the history
These classes have been replaced by more efficient and flexible classes
(see QgsPointLocator, QgsSnappingUtils, QgsMapCanvasSnappingUtils)
  • Loading branch information
wonder-sk committed Apr 17, 2017
1 parent 8b08285 commit 316d9c3
Show file tree
Hide file tree
Showing 20 changed files with 35 additions and 856 deletions.
3 changes: 3 additions & 0 deletions doc/api_break.dox
Expand Up @@ -285,6 +285,8 @@ should now call QgsCoordinateReferenceSystem::invalidateCache() and QgsCoordinat
- QgsSvgAnnotationItem. Use QgsSvgAnnotation instead.
- QgsSymbologyV2Conversion was removed. Reading of renderers from pre-1.0 versions is not supported anymore.
- QgsTextAnnotationItem. Use QgsTextAnnotation instead.
- QgsSnapper. Use QgsSnappingUtils instead.
- QgsMapCanvasSnapper. Use QgsMapCanvas::snappingUtils() instead.


General changes {#qgis_api_break_3_0_global}
Expand Down Expand Up @@ -2084,6 +2086,7 @@ displayExpression instead. For the map tip use mapTipTemplate() instead.
- createJoinCaches() has been removed. Caches are created/updated when needed internally.
- 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).

QgsVectorLayerEditBuffer {#qgis_api_break_3_0_QgsVectorLayerEditBuffer}
------------------------
Expand Down
1 change: 0 additions & 1 deletion python/auto_sip.blacklist
Expand Up @@ -399,7 +399,6 @@ gui/qgsmanageconnectionsdialog.sip
gui/qgsmapcanvas.sip
gui/qgsmapcanvasannotationitem.sip
gui/qgsmapcanvasitem.sip
gui/qgsmapcanvassnapper.sip
gui/qgsmapcanvassnappingutils.sip
gui/qgsmapcanvastracer.sip
gui/qgsmaplayeractionregistry.sip
Expand Down
67 changes: 9 additions & 58 deletions python/core/qgssnapper.sip
Expand Up @@ -7,6 +7,15 @@ struct QgsSnappingResult
#include <qgssnapper.h>
%End

/** Snap to vertex, to segment or both*/
enum SnappingType
{
SnapToVertex,
SnapToSegment,
//snap to vertex and also to segment if no vertex is within the search tolerance
SnapToVertexAndSegment
};

/** The coordinates of the snapping result*/
QgsPoint snappedVertex;
/** The vertex index of snappedVertex
Expand All @@ -27,61 +36,3 @@ struct QgsSnappingResult
/** Layer where the snap occurred*/
const QgsVectorLayer* layer;
};



/** A class that allows advanced snapping operations on a set of vector layers*/
class QgsSnapper
{
%TypeHeaderCode
#include <qgssnapper.h>
%End

public:
/** Snap to vertex, to segment or both*/
enum SnappingType
{
SnapToVertex,
SnapToSegment,
//snap to vertex and also to segment if no vertex is within the search tolerance
SnapToVertexAndSegment
};

enum SnappingMode
{
/** Only one snapping result is returned*/
SnapWithOneResult,
/** Several snapping results which have the same position are returned.
This is useful for topological editing*/
SnapWithResultsForSamePosition,
/** All results within the given layer tolerances are returned*/
SnapWithResultsWithinTolerances
};

struct SnapLayer
{
/** The layer to which snapping is applied*/
QgsVectorLayer* mLayer;
/** The snapping tolerances for the layers, always in source coordinate systems of the layer*/
double mTolerance;
/** What snapping type to use (snap to segment or to vertex)*/
QgsSnapper::SnappingType mSnapTo;
/** What unit is used for tolerance*/
QgsTolerance::UnitType mUnitType;
};

explicit QgsSnapper( const QgsMapSettings& mapSettings );

/** Does the snapping operation
* @param mapCoordPoint the start point for snapping (in map coordinates)
* @param snappingResult the list where the results are inserted (everything in map coordinate system)
* @param excludePoints a list with (map coordinate) points that should be excluded in the snapping result. Useful e.g. for vertex moves where a vertex should not be snapped to its original position
* @return 0 in case of success
*/
int snapMapPoint( const QgsPoint &mapCoordPoint, QList<QgsSnappingResult> &snappingResult /Out/, const QList<QgsPoint> &excludePoints = QList<QgsPoint>() );

//setters
void setSnapLayers( const QList<QgsSnapper::SnapLayer>& snapLayers );
void setSnapMode( QgsSnapper::SnappingMode snapMode );

};
2 changes: 1 addition & 1 deletion python/core/qgsvectorlayer.sip
Expand Up @@ -1086,7 +1086,7 @@ Returns true if the provider has been modified since the last commit
int snapWithContext( const QgsPoint &startPoint,
double snappingTolerance,
QMultiMap < double, QgsSnappingResult > &snappingResults /Out/,
QgsSnapper::SnappingType snap_to );
QgsSnappingResult::SnappingType snap_to );
%Docstring
Snaps to segment or vertex within given tolerance
\param startPoint point to snap (in layer coordinates)
Expand Down
1 change: 0 additions & 1 deletion python/gui/gui.sip
Expand Up @@ -101,7 +101,6 @@
%Include qgsmapcanvas.sip
%Include qgsmapcanvasannotationitem.sip
%Include qgsmapcanvasitem.sip
%Include qgsmapcanvassnapper.sip
%Include qgsmapcanvassnappingutils.sip
%Include qgsmapcanvastracer.sip
%Include qgsmaplayeractionregistry.sip
Expand Down
54 changes: 0 additions & 54 deletions python/gui/qgsmapcanvassnapper.sip

This file was deleted.

4 changes: 2 additions & 2 deletions src/app/nodetool/qgsselectedfeature.cpp
Expand Up @@ -252,7 +252,7 @@ void QgsSelectedFeature::deleteSelectedVertexes()
{
// snap from current vertex
currentResultList.clear();
mVlayer->snapWithContext( mVertexMap.at( i )->pointV1(), ZERO_TOLERANCE, currentResultList, QgsSnapper::SnapToVertex );
mVlayer->snapWithContext( mVertexMap.at( i )->pointV1(), ZERO_TOLERANCE, currentResultList, QgsSnappingResult::SnapToVertex );
}

// only last update should trigger the geometry update
Expand Down Expand Up @@ -336,7 +336,7 @@ void QgsSelectedFeature::moveSelectedVertexes( QgsVector v )
{
// snap from current vertex
currentResultList.clear();
mVlayer->snapWithContext( entry->pointV1(), ZERO_TOLERANCE, currentResultList, QgsSnapper::SnapToVertex );
mVlayer->snapWithContext( entry->pointV1(), ZERO_TOLERANCE, currentResultList, QgsSnappingResult::SnapToVertex );
}

// only last update should trigger the geometry update
Expand Down
1 change: 0 additions & 1 deletion src/core/CMakeLists.txt
Expand Up @@ -220,7 +220,6 @@ SET(QGIS_CORE_SRCS
qgsscaleutils.cpp
qgssimplifymethod.cpp
qgsslconnect.cpp
qgssnapper.cpp
qgssnappingutils.cpp
qgsspatialindex.cpp
qgssqlexpressioncompiler.cpp
Expand Down
2 changes: 0 additions & 2 deletions src/core/qgsproject.h
Expand Up @@ -30,8 +30,6 @@
#include <QFileInfo>
#include <QStringList>

//#include <QDomDocument>qgp
#include "qgssnapper.h"
#include "qgsunittypes.h"
#include "qgssnappingconfig.h"
#include "qgsprojectversion.h"
Expand Down
168 changes: 0 additions & 168 deletions src/core/qgssnapper.cpp

This file was deleted.

0 comments on commit 316d9c3

Please sign in to comment.