Skip to content
Permalink
Browse files
[convert to curve] style
# Conflicts:
#	src/app/vertextool/qgsvertextool.cpp
  • Loading branch information
olivierdalang authored and nyalldawson committed Jun 18, 2021
1 parent 8a62db5 commit 527042ee1d7bc2889541ae6ced4674ed0171efdf
@@ -126,6 +126,17 @@ Adds a vertex to the end of the geometry.
Condenses the curves in this geometry by combining adjacent linestrings a to a single continuous linestring,
and combining adjacent circularstrings to a single continuous circularstring.

.. versionadded:: 3.20
%End

bool toggleCircularAtVertex( QgsVertexId position );
%Docstring
Converts the vertex at the given position from/to circular

:return: ``False`` if atVertex does not correspond to a valid vertex
on this geometry (including if this geometry is a Point),
or if the specified vertex can't be converted (e.g. start/end points).

.. versionadded:: 3.20
%End

@@ -915,7 +915,7 @@ QVector< QPair<int, QgsVertexId> > QgsCompoundCurve::curveVertexId( QgsVertexId
return curveIds;
}

bool QgsCompoundCurve::convertVertex( QgsVertexId position )
bool QgsCompoundCurve::toggleCircularAtVertex( QgsVertexId position )
{

// First we find out the sub-curves that are contain that vertex.
@@ -116,6 +116,16 @@ class CORE_EXPORT QgsCompoundCurve: public QgsCurve
*/
void condenseCurves();

/**
* Converts the vertex at the given position from/to circular
* \returns FALSE if atVertex does not correspond to a valid vertex
* on this geometry (including if this geometry is a Point),
* or if the specified vertex can't be converted (e.g. start/end points).
*
* \since QGIS 3.20
*/
bool toggleCircularAtVertex( QgsVertexId position );

void draw( QPainter &p ) const override;
void transform( const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d = QgsCoordinateTransform::ForwardTransform, bool transformZ = false ) override SIP_THROW( QgsCsException );
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
bool insertVertex( QgsVertexId position, const QgsPoint &vertex ) override;
bool moveVertex( QgsVertexId position, const QgsPoint &newPos ) override;
bool deleteVertex( QgsVertexId position ) override;
bool convertVertex( QgsVertexId position );
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;
bool pointAt( int node, QgsPoint &point, QgsVertexId::VertexType &type ) const override;
void sumUpArea( double &sum SIP_OUT ) const override;
@@ -578,15 +578,15 @@ bool QgsGeometry::toggleCircularAtVertex( int atVertex )
if ( cpdCurve != nullptr )
{
// If the geom is a already compound curve, we convert inplace, and we're done
success = cpdCurve->convertVertex( id );
success = cpdCurve->toggleCircularAtVertex( id );
}
else
{
// TODO : move this block before the above, so we call convertVertex only in one place
// TODO : move this block before the above, so we call toggleCircularAtVertex only in one place
// If the geom is a linestring or cirularstring, we create a compound curve
std::unique_ptr<QgsCompoundCurve> cpdCurve = std::make_unique<QgsCompoundCurve>();
cpdCurve->addCurve( curve->clone() );
success = cpdCurve->convertVertex( QgsVertexId( -1, -1, id.vertex ) );
success = cpdCurve->toggleCircularAtVertex( QgsVertexId( -1, -1, id.vertex ) );

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

0 comments on commit 527042e

Please sign in to comment.