40  return QStringLiteral( 
"polygon" );
 
 
   46  auto transformRing = [&context]( QPolygonF & pts )
 
   62    pts.erase( std::remove_if( pts.begin(), pts.end(),
 
   63                               []( 
const QPointF point )
 
   65      return !std::isfinite( point.x() ) || !std::isfinite( point.y() );
 
   68    QPointF *ptr = pts.data();
 
   69    for ( 
int i = 0; i < pts.size(); ++i, ++ptr )
 
   75  QPolygonF exterior = mPolygon->exteriorRing()->asQPolygonF();
 
   76  transformRing( exterior );
 
   77  QVector<QPolygonF> rings;
 
   78  rings.reserve( mPolygon->numInteriorRings() );
 
   79  for ( 
int i = 0; i < mPolygon->numInteriorRings(); ++i )
 
   81    QPolygonF ring = mPolygon->interiorRing( i )->asQPolygonF();
 
   82    transformRing( ring );
 
   86  mSymbol->startRender( context );
 
   87  mSymbol->renderPolygon( exterior, rings.empty() ? 
nullptr : &rings, 
nullptr, context );
 
   88  mSymbol->stopRender( context );
 
 
   93  element.setAttribute( QStringLiteral( 
"wkt" ), mPolygon->asWkt() );
 
 
  102  QList< QgsAnnotationItemNode > res;
 
  104  auto processRing  = [&res]( 
const QgsCurve * ring, 
int ringId )
 
  108    res.reserve( res.size() + count );
 
  109    for ( 
int i = 0; i < count; ++i )
 
  115  if ( 
const QgsCurve *ring = mPolygon->exteriorRing() )
 
  117    processRing( ring, 0 );
 
  119  for ( 
int i = 0; i < mPolygon->numInteriorRings(); ++i )
 
  121    processRing( mPolygon->interiorRing( i ), i + 1 );
 
 
  129  switch ( operation->
type() )
 
  142      if ( mPolygon->deleteVertex( deleteOperation->
nodeId() ) )
 
  153      mPolygon->closestSegment( addOperation->
point(), segmentPoint, endOfSegmentVertex );
 
  154      if ( mPolygon->insertVertex( endOfSegmentVertex, segmentPoint ) )
 
  162      const QTransform transform = QTransform::fromTranslate( moveOperation->
translationX(), moveOperation->
translationY() );
 
  163      mPolygon->transform( transform );
 
 
  173  switch ( operation->
type() )
 
  178      std::unique_ptr< QgsCurvePolygon > modifiedPolygon( mPolygon->clone() );
 
  179      if ( modifiedPolygon->moveVertex( moveOperation->
nodeId(), 
QgsPoint( moveOperation->
after() ) ) )
 
  189      const QTransform transform = QTransform::fromTranslate( moveOperation->
translationX(), moveOperation->
translationY() );
 
  190      std::unique_ptr< QgsCurvePolygon > modifiedPolygon( mPolygon->clone() );
 
  191      modifiedPolygon->transform( transform );
 
 
  214  const QString wkt = element.attribute( QStringLiteral( 
"wkt" ) );
 
  217    mPolygon.reset( polygon->clone() );
 
  219  const QDomElement symbolElem = element.firstChildElement( QStringLiteral( 
"symbol" ) );
 
  220  if ( !symbolElem.isNull() )
 
  221    setSymbol( QgsSymbolLayerUtils::loadSymbol< QgsFillSymbol >( symbolElem, context ).release() );
 
 
  229  auto item = std::make_unique< QgsAnnotationPolygonItem >( mPolygon->clone() );
 
  230  item->setSymbol( mSymbol->clone() );
 
  231  item->copyCommonProperties( 
this );;
 
  232  return item.release();
 
 
  237  return mPolygon->boundingBox();
 
 
  247  return mSymbol.get();
 
 
@ VertexHandle
Node is a handle for manipulating vertices.
 
@ SupportsReferenceScale
Item supports reference scale based rendering.
 
AnnotationItemEditOperationResult
Results from an edit operation on an annotation item.
 
@ Invalid
Operation has invalid parameters for the item, no change occurred.
 
@ Success
Item was modified successfully.
 
@ ItemCleared
The operation results in the item being cleared, and the item should be removed from the layer as a r...
 
QFlags< AnnotationItemFlag > AnnotationItemFlags
Annotation item flags.
 
Abstract base class for annotation item edit operations.
 
@ DeleteNode
Delete a node.
 
@ TranslateItem
Translate (move) an item.
 
virtual Type type() const =0
Returns the operation type.
 
Encapsulates the context for an annotation item edit operation.
 
Annotation item edit operation consisting of adding a node.
 
QgsPoint point() const
Returns the node position (in layer coordinates).
 
Annotation item edit operation consisting of deleting a node.
 
QgsVertexId nodeId() const
Returns the deleted node ID.
 
Annotation item edit operation consisting of moving a node.
 
QgsPoint after() const
Returns the node position after the move occurred (in layer coordinates).
 
QgsVertexId nodeId() const
Returns the associated node ID.
 
Encapsulates the transient results of an in-progress annotation edit operation.
 
Annotation item edit operation consisting of translating (moving) an item.
 
double translationY() const
Returns the y-axis translation, in layer units.
 
double translationX() const
Returns the x-axis translation, in layer units.
 
Contains information about a node used for editing an annotation item.
 
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
 
virtual bool writeCommonProperties(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Writes common properties from the base class into an XML element.
 
virtual bool readCommonProperties(const QDomElement &element, const QgsReadWriteContext &context)
Reads common properties from the base class from the given DOM element.
 
An annotation item which renders a fill symbol for a polygon geometry.
 
Qgis::AnnotationItemEditOperationResult applyEditV2(QgsAbstractAnnotationItemEditOperation *operation, const QgsAnnotationItemEditContext &context) override
Applies an edit operation to the item.
 
bool readXml(const QDomElement &element, const QgsReadWriteContext &context) override
Reads the item's state from the given DOM element.
 
void render(QgsRenderContext &context, QgsFeedback *feedback) override
Renders the item to the specified render context.
 
const QgsCurvePolygon * geometry() const
Returns the geometry of the item.
 
void setSymbol(QgsFillSymbol *symbol)
Sets the symbol used to render the polygon item.
 
const QgsFillSymbol * symbol() const
Returns the symbol used to render the item.
 
QgsRectangle boundingBox() const override
Returns the bounding box of the item's geographic location, in the parent layer's coordinate referenc...
 
QString type() const override
Returns a unique (untranslated) string identifying the type of item.
 
bool writeXml(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const override
Writes the item's state into an XML element.
 
void setGeometry(QgsCurvePolygon *geometry)
Sets the geometry of the item.
 
Qgis::AnnotationItemFlags flags() const override
Returns item flags.
 
QgsAnnotationPolygonItem * clone() const override
Returns a clone of the item.
 
QList< QgsAnnotationItemNode > nodesV2(const QgsAnnotationItemEditContext &context) const override
Returns the nodes for the item, used for editing the item.
 
~QgsAnnotationPolygonItem() override
 
static QgsAnnotationPolygonItem * create()
Creates a new polygon annotation item.
 
QgsAnnotationPolygonItem(QgsCurvePolygon *polygon)
Constructor for QgsAnnotationPolygonItem, with the specified polygon geometry.
 
QgsAnnotationItemEditOperationTransientResults * transientEditResultsV2(QgsAbstractAnnotationItemEditOperation *operation, const QgsAnnotationItemEditContext &context) override
Retrieves the results of a transient (in progress) edit operation on the item.
 
Custom exception class for Coordinate Reference System related exceptions.
 
Curve polygon geometry type.
 
Abstract base class for curved geometry type.
 
virtual int numPoints() const =0
Returns the number of points in the curve.
 
virtual bool isClosed() const
Returns true if the curve is closed.
 
virtual double xAt(int index) const =0
Returns the x-coordinate of the specified node in the line string.
 
virtual double yAt(int index) const =0
Returns the y-coordinate of the specified node in the line string.
 
Base class for feedback objects to be used for cancellation of something running in a worker thread.
 
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
 
A geometry is the spatial representation of a feature.
 
static Q_INVOKABLE QgsGeometry fromWkt(const QString &wkt)
Creates a new geometry from a WKT string.
 
void transformInPlace(double &x, double &y) const
Transforms map coordinates to device coordinates.
 
Point geometry type, with support for z-dimension and m-values.
 
A container for the context for various read/write operations on objects.
 
A rectangle specified with double values.
 
Contains information about the context of a rendering operation.
 
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
 
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
 
static QDomElement saveSymbol(const QString &symbolName, const QgsSymbol *symbol, QDomDocument &doc, const QgsReadWriteContext &context)
Writes a symbol definition to XML.
 
Utility class for identifying a unique vertex within a geometry.