Skip to content
Permalink
Browse files
R.I.P. QgsSnapper and QgsMapCanvasSnapper
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 316d9c3359aa0e6c94145382d6665a53866f8a4b
@@ -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}
@@ -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}
------------------------
@@ -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
@@ -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
@@ -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 );

};
@@ -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)
@@ -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

This file was deleted.

@@ -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
@@ -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
@@ -220,7 +220,6 @@ SET(QGIS_CORE_SRCS
qgsscaleutils.cpp
qgssimplifymethod.cpp
qgsslconnect.cpp
qgssnapper.cpp
qgssnappingutils.cpp
qgsspatialindex.cpp
qgssqlexpressioncompiler.cpp
@@ -30,8 +30,6 @@
#include <QFileInfo>
#include <QStringList>

//#include <QDomDocument>qgp
#include "qgssnapper.h"
#include "qgsunittypes.h"
#include "qgssnappingconfig.h"
#include "qgsprojectversion.h"

This file was deleted.

Loading

0 comments on commit 316d9c3

Please sign in to comment.