35 return QStringLiteral(
"linestring" );
40 QPolygonF pts = mCurve->asQPolygonF();
56 pts.erase( std::remove_if( pts.begin(), pts.end(),
57 [](
const QPointF point )
59 return !std::isfinite( point.x() ) || !std::isfinite( point.y() );
62 QPointF *ptr = pts.data();
63 for (
int i = 0; i < pts.size(); ++i, ++ptr )
68 mSymbol->startRender( context );
69 mSymbol->renderPolyline( pts,
nullptr, context );
70 mSymbol->stopRender( context );
75 element.setAttribute( QStringLiteral(
"wkt" ), mCurve->asWkt() );
76 element.setAttribute( QStringLiteral(
"zIndex" ),
zIndex() );
90 const QString wkt = element.attribute( QStringLiteral(
"wkt" ) );
92 if (
const QgsCurve *curve = qgsgeometry_cast< const QgsCurve * >(
geometry.constGet() ) )
93 mCurve.reset( curve->clone() );
95 setZIndex( element.attribute( QStringLiteral(
"zIndex" ) ).toInt() );
97 const QDomElement symbolElem = element.firstChildElement( QStringLiteral(
"symbol" ) );
98 if ( !symbolElem.isNull() )
99 setSymbol( QgsSymbolLayerUtils::loadSymbol< QgsLineSymbol >( symbolElem, context ) );
106 return mCurve->boundingBox();
111 std::unique_ptr< QgsAnnotationLineItem > item = std::make_unique< QgsAnnotationLineItem >( mCurve->clone() );
112 item->setSymbol( mSymbol->clone() );
113 item->setZIndex(
zIndex() );
114 return item.release();
119 return mSymbol.get();
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
void setZIndex(int index)
Sets the item's z index, which controls the order in which annotation items are rendered in the layer...
int zIndex() const
Returns the item's z index, which controls the order in which annotation items are rendered in the la...
An annotation item which renders a line symbol along a line geometry.
QgsRectangle boundingBox() const override
Returns the bounding box of the item's geographic location, in the parent layer's coordinate referenc...
~QgsAnnotationLineItem() override
QgsAnnotationLineItem(QgsCurve *curve)
Constructor for QgsAnnotationLineItem, with the specified linestring.
void setSymbol(QgsLineSymbol *symbol)
Sets the symbol used to render the marker item.
QString type() const override
Returns a unique (untranslated) string identifying the type of item.
bool readXml(const QDomElement &element, const QgsReadWriteContext &context) override
Reads the item's state from the given DOM element.
bool writeXml(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const override
Writes the item's state into an XML element.
const QgsCurve * geometry() const
Returns the geometry of the item.
void render(QgsRenderContext &context, QgsFeedback *feedback) override
Renders the item to the specified render context.
const QgsLineSymbol * symbol() const
Returns the symbol used to render the item.
QgsAnnotationLineItem * clone() override
Returns a clone of the item.
static QgsAnnotationLineItem * create()
Creates a new linestring annotation item.
Custom exception class for Coordinate Reference System related exceptions.
Abstract base class for curved geometry type.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
A geometry is the spatial representation of a feature.
static QgsGeometry fromWkt(const QString &wkt)
Creates a new geometry from a WKT string.
Line string geometry type, with support for z-dimension and m-values.
A line symbol type, for rendering LineString and MultiLineString geometries.
void transformInPlace(double &x, double &y) const
Transforms device coordinates to map coordinates.
The class is used as a container of context for various read/write operations on other 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.