Skip to content

Commit 527042e

Browse files
olivierdalangnyalldawson
authored andcommitted
[convert to curve] style
# Conflicts: # src/app/vertextool/qgsvertextool.cpp
1 parent 8a62db5 commit 527042e

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

python/core/auto_generated/geometry/qgscompoundcurve.sip.in

+11
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,17 @@ Adds a vertex to the end of the geometry.
126126
Condenses the curves in this geometry by combining adjacent linestrings a to a single continuous linestring,
127127
and combining adjacent circularstrings to a single continuous circularstring.
128128

129+
.. versionadded:: 3.20
130+
%End
131+
132+
bool toggleCircularAtVertex( QgsVertexId position );
133+
%Docstring
134+
Converts the vertex at the given position from/to circular
135+
136+
:return: ``False`` if atVertex does not correspond to a valid vertex
137+
on this geometry (including if this geometry is a Point),
138+
or if the specified vertex can't be converted (e.g. start/end points).
139+
129140
.. versionadded:: 3.20
130141
%End
131142

src/core/geometry/qgscompoundcurve.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ QVector< QPair<int, QgsVertexId> > QgsCompoundCurve::curveVertexId( QgsVertexId
915915
return curveIds;
916916
}
917917

918-
bool QgsCompoundCurve::convertVertex( QgsVertexId position )
918+
bool QgsCompoundCurve::toggleCircularAtVertex( QgsVertexId position )
919919
{
920920

921921
// First we find out the sub-curves that are contain that vertex.

src/core/geometry/qgscompoundcurve.h

+10-1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,16 @@ class CORE_EXPORT QgsCompoundCurve: public QgsCurve
116116
*/
117117
void condenseCurves();
118118

119+
/**
120+
* Converts the vertex at the given position from/to circular
121+
* \returns FALSE if atVertex does not correspond to a valid vertex
122+
* on this geometry (including if this geometry is a Point),
123+
* or if the specified vertex can't be converted (e.g. start/end points).
124+
*
125+
* \since QGIS 3.20
126+
*/
127+
bool toggleCircularAtVertex( QgsVertexId position );
128+
119129
void draw( QPainter &p ) const override;
120130
void transform( const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d = QgsCoordinateTransform::ForwardTransform, bool transformZ = false ) override SIP_THROW( QgsCsException );
121131
void transform( const QTransform &t, double zTranslate = 0.0, double zScale = 1.0, double mTranslate = 0.0, double mScale = 1.0 ) override;
@@ -124,7 +134,6 @@ class CORE_EXPORT QgsCompoundCurve: public QgsCurve
124134
bool insertVertex( QgsVertexId position, const QgsPoint &vertex ) override;
125135
bool moveVertex( QgsVertexId position, const QgsPoint &newPos ) override;
126136
bool deleteVertex( QgsVertexId position ) override;
127-
bool convertVertex( QgsVertexId position );
128137
double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt SIP_OUT, QgsVertexId &vertexAfter SIP_OUT, int *leftOf SIP_OUT = nullptr, double epsilon = 4 * std::numeric_limits<double>::epsilon() ) const override;
129138
bool pointAt( int node, QgsPoint &point, QgsVertexId::VertexType &type ) const override;
130139
void sumUpArea( double &sum SIP_OUT ) const override;

src/core/geometry/qgsgeometry.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -578,15 +578,15 @@ bool QgsGeometry::toggleCircularAtVertex( int atVertex )
578578
if ( cpdCurve != nullptr )
579579
{
580580
// If the geom is a already compound curve, we convert inplace, and we're done
581-
success = cpdCurve->convertVertex( id );
581+
success = cpdCurve->toggleCircularAtVertex( id );
582582
}
583583
else
584584
{
585-
// TODO : move this block before the above, so we call convertVertex only in one place
585+
// TODO : move this block before the above, so we call toggleCircularAtVertex only in one place
586586
// If the geom is a linestring or cirularstring, we create a compound curve
587587
std::unique_ptr<QgsCompoundCurve> cpdCurve = std::make_unique<QgsCompoundCurve>();
588588
cpdCurve->addCurve( curve->clone() );
589-
success = cpdCurve->convertVertex( QgsVertexId( -1, -1, id.vertex ) );
589+
success = cpdCurve->toggleCircularAtVertex( QgsVertexId( -1, -1, id.vertex ) );
590590

591591
// In that case, we must also reassign the instances
592592
if ( success )

0 commit comments

Comments
 (0)