QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
30 : mFillSymbol( symbol ? symbol : defaultFillSymbol() )
39 return QStringLiteral(
"extent" );
44 std::unique_ptr< QgsPointCloudExtentRenderer > res = std::make_unique< QgsPointCloudExtentRenderer >( mFillSymbol ? mFillSymbol->clone() :
nullptr );
56 std::unique_ptr< QgsPointCloudExtentRenderer > r = std::make_unique< QgsPointCloudExtentRenderer >();
58 const QDomElement symbolElem = element.firstChildElement( QStringLiteral(
"symbol" ) );
59 if ( !symbolElem.isNull() )
61 r->mFillSymbol.reset( QgsSymbolLayerUtils::loadSymbol<QgsFillSymbol>( symbolElem, context ) );
64 r->restoreCommonProperties( element, context );
70 auto transformRing = [&context]( QPolygonF & pts )
86 pts.erase( std::remove_if( pts.begin(), pts.end(),
87 [](
const QPointF point )
89 return !std::isfinite( point.x() ) || !std::isfinite( point.y() );
92 QPointF *ptr = pts.data();
93 for (
int i = 0; i < pts.size(); ++i, ++ptr )
101 if (
const QgsPolygon *polygon = qgsgeometry_cast< const QgsPolygon * >( *it ) )
103 QPolygonF exterior = polygon->exteriorRing()->asQPolygonF();
104 transformRing( exterior );
105 QVector<QPolygonF> rings;
106 rings.reserve( polygon->numInteriorRings() );
107 for (
int i = 0; i < polygon->numInteriorRings(); ++i )
109 QPolygonF ring = polygon->interiorRing( i )->asQPolygonF();
110 transformRing( ring );
111 rings.append( ring );
114 mFillSymbol->renderPolygon( exterior, rings.empty() ?
nullptr : &rings,
nullptr, context.
renderContext() );
121 std::unique_ptr< QgsSimpleLineSymbolLayer > layer = std::make_unique< QgsSimpleLineSymbolLayer >();
122 layer->setColor( QColor( 228, 26, 28 ) );
123 layer->setWidth( 0.960000 );
124 layer->setPenStyle( Qt::DotLine );
131 return mFillSymbol.get();
136 mFillSymbol.reset( symbol );
141 QDomElement rendererElem = doc.createElement( QStringLiteral(
"renderer" ) );
143 rendererElem.setAttribute( QStringLiteral(
"type" ),
type() );
146 rendererElem.appendChild( symbolElem );
166 QList<QgsLayerTreeModelLegendNode *> nodes;
168 const QgsLegendSymbolItem extentItem( mFillSymbol.get(), QStringLiteral(
"extent" ), QStringLiteral(
"extent" ) );
QgsPointCloudRenderer * clone() const override
Create a deep copy of this renderer.
~QgsPointCloudExtentRenderer() override
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
QgsPointCloudExtentRenderer(QgsFillSymbol *symbol=nullptr)
Constructor for QgsPointCloudExtentRenderer.
QString type() const override
Returns the identifier of the renderer type.
The class is used as a container of context for various read/write operations on other objects.
QgsAbstractGeometry::const_part_iterator const_parts_end() const
Returns STL-style iterator pointing to the imaginary part after the last part of the geometry.
QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) const override
Saves the renderer configuration to an XML element.
void renderExtent(const QgsGeometry &extent, QgsPointCloudRenderContext &context)
Renders a polygon extent geometry to the specified render context.
@ RenderMillimeters
Millimeters.
QgsAbstractGeometry::const_part_iterator const_parts_begin() const
Returns STL-style const iterator pointing to the first part of the geometry.
void copyCommonProperties(QgsPointCloudRenderer *destination) const
Copies common point cloud properties (such as point size and screen error) to the destination rendere...
Base class for storing raw data from point cloud nodes.
void stopRender(QgsPointCloudRenderContext &context) override
Must be called when a render cycle has finished, to allow the renderer to clean up.
virtual void startRender(QgsPointCloudRenderContext &context)
Must be called when a new render cycle is started.
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
The class stores information about one class/rule of a vector layer renderer in a unified way that ca...
Custom exception class for Coordinate Reference System related exceptions.
QList< QgsLayerTreeModelLegendNode * > createLegendNodes(QgsLayerTreeLayer *nodeLayer) override
Creates a set of legend nodes representing the renderer.
Encapsulates the render context for a 2D point cloud rendering operation.
Layer tree node points to a map layer.
void startRender(QgsPointCloudRenderContext &context) override
Must be called when a new render cycle is started.
virtual void stopRender(QgsPointCloudRenderContext &context)
Must be called when a render cycle has finished, to allow the renderer to clean up.
void setFillSymbol(QgsFillSymbol *symbol)
Sets the symbol used to render the cloud's extent.
void renderBlock(const QgsPointCloudBlock *block, QgsPointCloudRenderContext &context) override
Renders a block of point cloud data using the specified render context.
static QgsPointCloudRenderer * create(QDomElement &element, const QgsReadWriteContext &context)
Creates an extent renderer from an XML element.
static QgsFillSymbol * defaultFillSymbol()
Returns a new instance of the default fill symbol to use for showing point cloud extents.
void transformInPlace(double &x, double &y) const
Transforms device coordinates to map coordinates.
QgsFillSymbol * fillSymbol() const
Returns the symbol used to render the cloud's extent.
A geometry is the spatial representation of a feature.
QList< QgsSymbolLayer * > QgsSymbolLayerList
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
void setEmbeddedInParent(bool embedded) override
Abstract base class for 2d point cloud renderers.
void saveCommonProperties(QDomElement &element, const QgsReadWriteContext &context) const
Saves common renderer properties (such as point size and screen error) to the specified DOM element.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
Implementation of legend node interface for displaying preview of vector symbols and their labels and...
static QDomElement saveSymbol(const QString &symbolName, const QgsSymbol *symbol, QDomDocument &doc, const QgsReadWriteContext &context)
Writes a symbol definition to XML.