Skip to content
Permalink
Browse files

Minor fixes and doxymentation for QgsSnappingUtils

  • Loading branch information
m-kuhn committed Jun 21, 2016
1 parent 318a835 commit dab157f70fb84b897bbf8758b5f5ba1a6f549110
@@ -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;
@@ -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;
@@ -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
};

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


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

0 comments on commit dab157f

Please sign in to comment.
You can’t perform that action at this time.