Skip to content
Permalink
Browse files

New snapping modes: Centroid and middle of a segment (midpoint) (#33622)

Snap on centroid and midpoint segment [FEATURE][needs-docs]
  • Loading branch information
lbartoletti committed Mar 2, 2020
1 parent d3ce32a commit dfa5cb68aa72e2a0aa43c7afec8f1fddc828e36b
@@ -677,7 +677,9 @@
<file>themes/default/mIconSnappingActiveLayer.svg</file>
<file>themes/default/mIconSnappingAdvanced.svg</file>
<file>themes/default/mIconSnappingAllLayers.svg</file>
<file>themes/default/mIconSnappingVertexAndSegment.svg</file>
<file>themes/default/mIconSnappingArea.svg</file>
<file>themes/default/mIconSnappingCentroid.svg</file>
<file>themes/default/mIconSnappingMiddle.svg</file>
<file>themes/default/mIconSnappingVertex.svg</file>
<file>themes/default/mIconSnappingSegment.svg</file>
<file>themes/default/mIconTopologicalEditing.svg</file>
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="24"
viewBox="0 0 24 24"
width="24"
version="1.1"
id="svg12"
sodipodi:docname="mIconSnappingArea.svg"
inkscape:version="0.92.4 (5da689c313, 2019-01-14)">
<metadata
id="metadata18">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs16" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1018"
id="namedview14"
showgrid="false"
inkscape:zoom="39.333333"
inkscape:cx="7.6525424"
inkscape:cy="9.9661017"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg12" />
<path
inkscape:connector-curvature="0"
id="path14853"
style="fill:#8cbe8c;fill-rule:evenodd;stroke:#555753;stroke-width:0.99999994;stroke-linecap:round;stroke-linejoin:round"
d="M 8.0275898,6.5013888 C 5.2092426,6.5480256 2.7397656,7.7566448 1.743606,10.696115 0.75513812,13.612886 2.9150925,18.878123 7.6761823,16.536618 15.583924,12.647591 15.579986,17.5 17.556921,17.5 c 2.438571,0 4.94037,-1.699566 4.94037,-3.873599 0,-1.944514 0.09638,-3.8063882 -0.992208,-4.8771202 C 19.528148,6.8047667 18.531406,9.7366768 13.216012,7.5651228 11.521995,6.8730481 9.7185988,6.4734058 8.0275898,6.5013888 Z" />
</svg>
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 6.35 6.35"><path d="M2.124 1.985c-.746.012-1.4.332-1.663 1.11-.261.771.31 2.164 1.57 1.545 2.092-1.03 2.091.255 2.614.255.645 0 1.307-.45 1.307-1.025 0-.515.026-1.007-.262-1.29-.523-.515-.787.26-2.193-.314a3.544 3.544 0 0 0-1.373-.281z" fill="#e6e6e6" fill-rule="evenodd" stroke="#585a56" stroke-width=".265" stroke-linecap="round" stroke-linejoin="round" stroke-opacity=".93"/><rect y="2.514" x="2.514" width="1.323" rx=".827" height="1.323" ry=".827" fill="#8cbe8c" stroke="#4b4c4b" stroke-width=".265" stroke-linecap="round"/></svg>
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
height="24"
viewBox="0 0 24 24"
width="24"
version="1.1"
id="svg1536"
sodipodi:docname="mIconSnappingMiddle.svg"
inkscape:version="0.92.4 (5da689c313, 2019-01-14)">
<metadata
id="metadata1542">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs1540" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1018"
id="namedview1538"
showgrid="false"
inkscape:snap-global="true"
inkscape:zoom="20.918576"
inkscape:cx="12"
inkscape:cy="12"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg1536" />
<g
id="g3295"
transform="translate(2.6949154,1.2966099)">
<path
sodipodi:nodetypes="cccc"
style="fill:none;stroke:#8cbe8c;stroke-width:2;stroke-linecap:round;stroke-linejoin:round"
inkscape:connector-curvature="0"
id="path1534-7"
d="m 3.0547087,4.4533901 6.5,12.4999999 m 0,0 6.0000003,-10" />
<circle
transform="rotate(-29.781576)"
r="1.9999999"
cy="11.410214"
cx="0.42228222"
id="path4532-5"
style="fill:#bebebe;fill-opacity:1;stroke:#8c8c8c;stroke-width:0.99999994;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<circle
transform="rotate(30.228466)"
r="1.9999999"
cy="4.2046409"
cx="16.923332"
id="path4532-5-7"
style="fill:#bebebe;fill-opacity:1;stroke:#8c8c8c;stroke-width:0.99999994;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</g>
</svg>
@@ -1,3 +1,5 @@
# The following has been generated automatically from src/core/qgssnappingconfig.h
QgsSnappingConfig.SnappingMode.baseClass = QgsSnappingConfig
QgsSnappingConfig.SnappingType.baseClass = QgsSnappingConfig
QgsSnappingConfig.SnappingTypes.baseClass = QgsSnappingConfig
QgsSnappingConfig.SnappingTypeFlag.baseClass = QgsSnappingConfig
SnappingTypeFlag = QgsSnappingConfig # dirty hack since SIP seems to introduce the flags in module
@@ -11,6 +11,11 @@








class QgsPointLocator : QObject
{
%Docstring
@@ -86,6 +91,8 @@ Configure render context - if not ``None``, it will use to index only visible f
Vertex,
Edge,
Area,
Centroid,
MiddleOfSegment,
All
};

@@ -125,8 +132,25 @@ construct invalid match

bool isValid() const;
bool hasVertex() const;
%Docstring
Returns true if the Match is a vertex
%End
bool hasEdge() const;
%Docstring
Returns true if the Match is an edge
%End
bool hasCentroid() const;
%Docstring
Returns true if the Match is a centroid
%End
bool hasArea() const;
%Docstring
Returns true if the Match is an area
%End
bool hasMiddleSegment() const;
%Docstring
Returns true if the Match is the middle of a segment
%End

double distance() const;
%Docstring
@@ -188,6 +212,24 @@ interpolation of the Z value.
Find nearest vertex to the specified point - up to distance specified by tolerance
Optional filter may discard unwanted matches.
This method is either blocking or non blocking according to ``relaxed`` parameter passed
%End

Match nearestCentroid( const QgsPointXY &point, double tolerance, QgsPointLocator::MatchFilter *filter = 0, bool relaxed = false );
%Docstring
Find nearest centroid to the specified point - up to distance specified by tolerance
Optional filter may discard unwanted matches.
This method is either blocking or non blocking according to ``relaxed`` parameter passed

.. versionadded:: 3.12
%End

Match nearestMiddleOfSegment( const QgsPointXY &point, double tolerance, QgsPointLocator::MatchFilter *filter = 0, bool relaxed = false );
%Docstring
Find nearest middle of segment to the specified point - up to distance specified by tolerance
Optional filter may discard unwanted matches.
This method is either blocking or non blocking according to ``relaxed`` parameter passed

.. versionadded:: 3.12
%End

Match nearestEdge( const QgsPointXY &point, double tolerance, QgsPointLocator::MatchFilter *filter = 0, bool relaxed = false );
@@ -9,7 +9,6 @@




class QgsSnappingConfig
{
%Docstring
@@ -40,6 +39,27 @@ This is a container for configuration of the snapping of the project
Segment,
};

enum SnappingTypes
{
NoSnapFlag,
VertexFlag,
SegmentFlag,
AreaFlag,
CentroidFlag,
MiddleOfSegmentFlag,
};
typedef QFlags<QgsSnappingConfig::SnappingTypes> SnappingTypeFlag;


static const QString snappingTypeFlagToString( SnappingTypeFlag type );
%Docstring
Convenient method to returns the translated name of the enum type
QgsSnappingConfig.SnappingTypeFlag

.. versionadded:: 3.12
%End


class IndividualLayerSettings
{
%Docstring
@@ -53,14 +73,29 @@ This is a container of advanced configuration (per layer) of the snapping of the
%End
public:

IndividualLayerSettings( bool enabled, QgsSnappingConfig::SnappingType type, double tolerance, QgsTolerance::UnitType units );
IndividualLayerSettings( bool enabled, SnappingType type, double tolerance, QgsTolerance::UnitType units ) /Deprecated/;
%Docstring
IndividualLayerSettings

:param enabled:
:param type:
:param tolerance:
:param units:

.. deprecated:: QGIS 3.12
use the method with SnappingTypeFlag instead.
%End

IndividualLayerSettings( bool enabled, SnappingTypeFlag type, double tolerance, QgsTolerance::UnitType units );
%Docstring
IndividualLayerSettings

:param enabled:
:param type:
:param tolerance:
:param units:

.. versionadded:: 3.12
%End

IndividualLayerSettings();
@@ -83,14 +118,34 @@ Returns if snapping is enabled
enables the snapping
%End

QgsSnappingConfig::SnappingType type() const;
QgsSnappingConfig::SnappingTypeFlag typeFlag() const;
%Docstring
Returns the flags type (vertices | segments | area | centroid | middle)

.. versionadded:: 3.12
%End

QgsSnappingConfig::SnappingType type() const /Deprecated/;
%Docstring
Returns the type (vertices and/or segments)
Returns the flags type (vertices | segments | area | centroid | middle)

.. deprecated:: QGIS 3.12
use typeFlag instead.
%End

void setType( QgsSnappingConfig::SnappingType type );
void setType( QgsSnappingConfig::SnappingType type ) /Deprecated/;
%Docstring
define the type of snapping

.. deprecated:: QGIS 3.12
use setTypeFlag instead.
%End

void setTypeFlag( QgsSnappingConfig::SnappingTypeFlag type );
%Docstring
define the type of snapping

.. versionadded:: 3.12
%End

double tolerance() const;
@@ -151,14 +206,34 @@ Returns the mode (all layers, active layer, per layer settings)
define the mode of snapping
%End

SnappingType type() const;
QgsSnappingConfig::SnappingTypeFlag typeFlag() const;
%Docstring
Returns the flags type (vertices | segments | area | centroid | middle)

.. versionadded:: 3.12
%End

QgsSnappingConfig::SnappingType type() const /Deprecated/;
%Docstring
Returns the type (vertices and/or segments)
Returns the flags type (vertices | segments | area | centroid | middle)

.. deprecated:: QGIS 3.12
use typeFlag instead.
%End

void setType( SnappingType type );
void setType( QgsSnappingConfig::SnappingType type );
%Docstring
define the type of snapping

.. deprecated:: QGIS 3.12
use setTypeFlag instead.
%End

void setTypeFlag( QgsSnappingConfig::SnappingTypeFlag type );
%Docstring
define the type of snapping

.. versionadded:: 3.12
%End

double tolerance() const;
@@ -300,6 +375,8 @@ The project from which the snapped layers should be retrieved
%End

};
QFlags<QgsSnappingConfig::SnappingTypes> operator|(QgsSnappingConfig::SnappingTypes f1, QFlags<QgsSnappingConfig::SnappingTypes> f2);


/************************************************************************
* This file has been generated automatically from *
@@ -39,6 +39,8 @@ A class for marking vertices of features using e.g. circles or 'x'.
ICON_BOX,
ICON_CIRCLE,
ICON_DOUBLE_TRIANGLE,
ICON_TRIANGLE,
ICON_RHOMBUS,
};

QgsVertexMarker( QgsMapCanvas *mapCanvas /TransferThis/ );

0 comments on commit dfa5cb6

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