Minor fixes and doxymentation for QgsSnappingUtils

This commit is contained in:
Matthias Kuhn 2016-06-21 10:59:04 +02:00
parent 318a835039
commit dab157f70f
5 changed files with 31 additions and 12 deletions

View File

@ -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
};
typedef QFlags<QgsPointLocator::Type> Types;

View File

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

View File

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

View File

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

View File

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