QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
34 return QStringLiteral(
"linestring" );
39 QPolygonF pts = mCurve->asQPolygonF();
55 pts.erase( std::remove_if( pts.begin(), pts.end(),
56 [](
const QPointF point )
58 return !std::isfinite( point.x() ) || !std::isfinite( point.y() );
61 QPointF *ptr = pts.data();
62 for (
int i = 0; i < pts.size(); ++i, ++ptr )
67 mSymbol->startRender( context );
68 mSymbol->renderPolyline( pts,
nullptr, context );
69 mSymbol->stopRender( context );
74 element.setAttribute( QStringLiteral(
"wkt" ), mCurve->asWkt() );
75 element.setAttribute( QStringLiteral(
"zIndex" ),
zIndex() );
89 const QString wkt = element.attribute( QStringLiteral(
"wkt" ) );
91 if (
const QgsCurve *curve = qgsgeometry_cast< const QgsCurve * >(
geometry.constGet() ) )
92 mCurve.reset( curve->clone() );
94 setZIndex( element.attribute( QStringLiteral(
"zIndex" ) ).toInt() );
96 const QDomElement symbolElem = element.firstChildElement( QStringLiteral(
"symbol" ) );
97 if ( !symbolElem.isNull() )
98 setSymbol( QgsSymbolLayerUtils::loadSymbol< QgsLineSymbol >( symbolElem, context ) );
105 return mCurve->boundingBox();
110 std::unique_ptr< QgsAnnotationLineItem > item = qgis::make_unique< QgsAnnotationLineItem >( mCurve->clone() );
111 item->setSymbol( mSymbol->clone() );
112 item->setZIndex(
zIndex() );
113 return item.release();
118 return mSymbol.get();
Abstract base class for curved geometry type.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
The class is used as a container of context for various read/write operations on other objects.
void render(QgsRenderContext &context, QgsFeedback *feedback) override
Renders the item to the specified render context.
QgsRectangle boundingBox() const override
Returns the bounding box of the item's geographic location, in the parent layer's coordinate referenc...
Contains information about the context of a rendering operation.
Line string geometry type, with support for z-dimension and m-values.
A rectangle specified with double values.
QgsAnnotationLineItem * clone() override
Returns a clone of the item.
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
Custom exception class for Coordinate Reference System related exceptions.
bool readXml(const QDomElement &element, const QgsReadWriteContext &context) override
Reads the item's state from the given DOM element.
QString type() const override
Returns a unique (untranslated) string identifying the type of item.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
const QgsLineSymbol * symbol() const
Returns the symbol used to render the item.
A line symbol type, for rendering LineString and MultiLineString geometries.
static QgsGeometry fromWkt(const QString &wkt)
Creates a new geometry from a WKT string.
const QgsCurve * geometry() const
Returns the geometry of the item.
int zIndex() const
Returns the item's z index, which controls the order in which annotation items are rendered in the la...
void transformInPlace(double &x, double &y) const
Transform device coordinates to map coordinates.
A geometry is the spatial representation of a feature.
void setSymbol(QgsLineSymbol *symbol)
Sets the symbol used to render the marker item.
~QgsAnnotationLineItem() override
An annotation item which renders a line symbol along a line geometry.
bool writeXml(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const override
Writes the item's state into an XML element.
QgsAnnotationLineItem(QgsCurve *curve)
Constructor for QgsAnnotationLineItem, with the specified linestring.
static QgsAnnotationLineItem * create()
Creates a new linestring annotation item.
static QDomElement saveSymbol(const QString &symbolName, const QgsSymbol *symbol, QDomDocument &doc, const QgsReadWriteContext &context)
Writes a symbol definition to XML.
void setZIndex(int index)
Sets the item's z index, which controls the order in which annotation items are rendered in the layer...
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.