Skip to content

Commit dab157f

Browse files
committedJun 21, 2016
Minor fixes and doxymentation for QgsSnappingUtils
1 parent 318a835 commit dab157f

File tree

5 files changed

+31
-12
lines changed

5 files changed

+31
-12
lines changed
 

‎python/core/qgspointlocator.sip

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ class QgsPointLocator : QObject
2929

3030
enum Type
3131
{
32-
Invalid,
33-
Vertex,
34-
Edge,
35-
Area,
36-
All
32+
Invalid = 0, //!< Invalid
33+
Vertex = 1, //!< Snapped to a vertex. Can be a vertex of the geometry or an intersection.
34+
Edge = 2, //!< Snapped to an edge
35+
Area = 4, //!< Snapped to an area
36+
All = 7 //!< Combination of vertex, edge and area
Code has comments. Press enter to view.
3737
};
3838

3939
typedef QFlags<QgsPointLocator::Type> Types;

‎python/core/qgssnappingutils.sip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class QgsSnappingUtils : QObject
6969
*/
7070
struct LayerConfig
7171
{
72-
LayerConfig( QgsVectorLayer* l, const QgsPointLocator::Types& t, double tol, QgsTolerance::UnitType u );
72+
LayerConfig( QgsVectorLayer* l, QgsPointLocator::Types t, double tol, QgsTolerance::UnitType u );
7373

7474
bool operator==( const QgsSnappingUtils::LayerConfig& other ) const;
7575
bool operator!=( const QgsSnappingUtils::LayerConfig& other ) const;

‎src/core/qgspointlocator.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ class CORE_EXPORT QgsPointLocator : public QObject
7777
*/
7878
enum Type
7979
{
80-
Invalid = 0, //!< Invalid
81-
Vertex = 1, //!< Snapped to a vertex. Can be a vertex of the geometry or an intersection.
82-
Edge = 2, //!< Snapped to an edge
83-
Area = 4, //!< Snapped to an area
80+
Invalid = 0, //!< Invalid
81+
Vertex = 1, //!< Snapped to a vertex. Can be a vertex of the geometry or an intersection.
82+
Edge = 2, //!< Snapped to an edge
83+
Area = 4, //!< Snapped to an area
8484
All = Vertex | Edge | Area //!< Combination of vertex, edge and area
8585
};
8686

‎src/core/qgsproject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class CORE_EXPORT QgsProject : public QObject
9090

9191
/** Sets the project's title.
9292
* @param title new title
93-
* @note added in 2.4
93+
* @note added in 2.4
9494
* @see title()
9595
*/
9696
void setTitle( const QString& title );

‎src/core/qgssnappingutils.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class CORE_EXPORT QgsSnappingUtils : public QObject
6565

6666
/** Set current layer so that if mode is SnapCurrentLayer we know which layer to use */
6767
void setCurrentLayer( QgsVectorLayer* layer );
68+
/** The current layer used if mode is SnapCurrentLayer */
6869
QgsVectorLayer* currentLayer() const { return mCurrentLayer; }
6970

7071

@@ -105,7 +106,25 @@ class CORE_EXPORT QgsSnappingUtils : public QObject
105106
*/
106107
struct LayerConfig
107108
{
108-
LayerConfig( QgsVectorLayer* l, const QgsPointLocator::Types& t, double tol, QgsTolerance::UnitType u )
109+
/**
110+
* Create a new configuration for a snapping layer.
111+
112+
```py
113+
snapper = QgsMapCanvasSnappingUtils(mapCanvas)
114+
115+
snapping_layer1 = QgsSnappingUtils.LayerConfig(layer1, QgsPointLocator.Vertex, 10, QgsTolerance.Pixels)
116+
snapping_layer2 = QgsSnappingUtils.LayerConfig(layer2, QgsPointLocator.Vertex and QgsPointLocator.Edge, 10, QgsTolerance.Pixels)
117+
118+
snapper.setLayers([snapping_layer1, snapping_layer2])
119+
snapper.setSnapToMapMode(QgsSnappingUtils.SnapAdvanced)
120+
```
121+
122+
* @param l The vector layer for which this configuration is
123+
* @param t Which parts of the geometry should be snappable
124+
* @param tol The tolerance radius in which the snapping will trigger
125+
* @param u The unit in which the tolerance is specified
126+
*/
127+
LayerConfig( QgsVectorLayer* l, QgsPointLocator::Types t, double tol, QgsTolerance::UnitType u )
109128
: layer( l )
110129
, type( t )
111130
, tolerance( tol )

0 commit comments

Comments
 (0)
Please sign in to comment.