Skip to content

Commit

Permalink
Minor fixes and doxymentation for QgsSnappingUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Jun 21, 2016
1 parent 318a835 commit dab157f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
10 changes: 5 additions & 5 deletions python/core/qgspointlocator.sip
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ class QgsPointLocator : QObject

enum Type
{
Invalid,
Vertex,
Edge,
Area,
All
Invalid = 0, //!< Invalid
Vertex = 1, //!< Snapped to a vertex. Can be a vertex of the geometry or an intersection.
Edge = 2, //!< Snapped to an edge
Area = 4, //!< Snapped to an area
All = 7 //!< Combination of vertex, edge and area

This comment has been minimized.

Copy link
@3nids

3nids Jun 21, 2016

Member

I thought SIP files should not contain the enum values, am I wrong?

This comment has been minimized.

Copy link
@m-kuhn

m-kuhn Jun 21, 2016

Author Member

No, you are right

};

typedef QFlags<QgsPointLocator::Type> Types;
Expand Down
2 changes: 1 addition & 1 deletion python/core/qgssnappingutils.sip
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class QgsSnappingUtils : QObject
*/
struct LayerConfig
{
LayerConfig( QgsVectorLayer* l, const QgsPointLocator::Types& t, double tol, QgsTolerance::UnitType u );
LayerConfig( QgsVectorLayer* l, QgsPointLocator::Types t, double tol, QgsTolerance::UnitType u );

bool operator==( const QgsSnappingUtils::LayerConfig& other ) const;
bool operator!=( const QgsSnappingUtils::LayerConfig& other ) const;
Expand Down
8 changes: 4 additions & 4 deletions src/core/qgspointlocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ class CORE_EXPORT QgsPointLocator : public QObject
*/
enum Type
{
Invalid = 0, //!< Invalid
Vertex = 1, //!< Snapped to a vertex. Can be a vertex of the geometry or an intersection.
Edge = 2, //!< Snapped to an edge
Area = 4, //!< Snapped to an area
Invalid = 0, //!< Invalid
Vertex = 1, //!< Snapped to a vertex. Can be a vertex of the geometry or an intersection.
Edge = 2, //!< Snapped to an edge
Area = 4, //!< Snapped to an area
All = Vertex | Edge | Area //!< Combination of vertex, edge and area
};

Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsproject.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class CORE_EXPORT QgsProject : public QObject

/** Sets the project's title.
* @param title new title
* @note added in 2.4
* @note added in 2.4
* @see title()
*/
void setTitle( const QString& title );
Expand Down
21 changes: 20 additions & 1 deletion src/core/qgssnappingutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class CORE_EXPORT QgsSnappingUtils : public QObject

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


Expand Down Expand Up @@ -105,7 +106,25 @@ class CORE_EXPORT QgsSnappingUtils : public QObject
*/
struct LayerConfig
{
LayerConfig( QgsVectorLayer* l, const QgsPointLocator::Types& t, double tol, QgsTolerance::UnitType u )
/**
* Create a new configuration for a snapping layer.
```py
snapper = QgsMapCanvasSnappingUtils(mapCanvas)
snapping_layer1 = QgsSnappingUtils.LayerConfig(layer1, QgsPointLocator.Vertex, 10, QgsTolerance.Pixels)
snapping_layer2 = QgsSnappingUtils.LayerConfig(layer2, QgsPointLocator.Vertex and QgsPointLocator.Edge, 10, QgsTolerance.Pixels)
snapper.setLayers([snapping_layer1, snapping_layer2])
snapper.setSnapToMapMode(QgsSnappingUtils.SnapAdvanced)
```
* @param l The vector layer for which this configuration is
* @param t Which parts of the geometry should be snappable
* @param tol The tolerance radius in which the snapping will trigger
* @param u The unit in which the tolerance is specified
*/
LayerConfig( QgsVectorLayer* l, QgsPointLocator::Types t, double tol, QgsTolerance::UnitType u )
: layer( l )
, type( t )
, tolerance( tol )
Expand Down

0 comments on commit dab157f

Please sign in to comment.