27using namespace Qt::StringLiterals;
34 : mRenderContext( context )
47 mTextureImage = image;
52 mTextureCoordinates[0] = textureX1;
53 mTextureCoordinates[1] = textureY1;
54 mTextureCoordinates[2] = textureX2;
55 mTextureCoordinates[3] = textureY2;
56 mTextureCoordinates[4] = textureX3;
57 mTextureCoordinates[5] = textureY3;
62 textureX1 = mTextureCoordinates[0];
63 textureY1 = mTextureCoordinates[1];
64 textureX2 = mTextureCoordinates[2];
65 textureY2 = mTextureCoordinates[3];
66 textureX3 = mTextureCoordinates[4];
67 textureY3 = mTextureCoordinates[5];
81 if ( element.isNull() )
85 const QString rendererType = element.attribute( u
"type"_s );
91 std::unique_ptr< QgsTiledSceneRenderer > r( m->
createRenderer( element, context ) );
100 mThread = QThread::currentThread();
104 Q_ASSERT_X( mThread == QThread::currentThread(),
"QgsTiledSceneRenderer::startRender",
"startRender called in a different thread - use a cloned renderer instead" );
112 Q_ASSERT_X( mThread == QThread::currentThread(),
"QgsTiledSceneRenderer::stopRender",
"stopRender called in a different thread - use a cloned renderer instead" );
118 return mMaximumScreenError;
123 mMaximumScreenError = error;
128 return mMaximumScreenErrorUnit;
133 mMaximumScreenErrorUnit = unit;
138 return QList<QgsLayerTreeModelLegendNode *>();
143 return QStringList();
155 mMaximumScreenError = element.attribute( u
"maximumScreenError"_s, u
"3"_s ).toDouble();
157 mTileBorderRendering = element.attribute( u
"tileBorderRendering"_s, u
"0"_s ).toInt();
162 element.setAttribute( u
"maximumScreenError"_s,
qgsDoubleToString( mMaximumScreenError ) );
164 element.setAttribute( u
"tileBorderRendering"_s, mTileBorderRendering ? 1 : 0 );
@ RendersLines
Renderer can render line primitives.
@ RendersTriangles
Renderer can render triangle primitives.
RenderUnit
Rendering size units.
QFlags< TiledSceneRendererFlag > TiledSceneRendererFlags
Flags which control how tiled scene 2D renderers behave.
static QgsTiledSceneRendererRegistry * tiledSceneRendererRegistry()
Returns the application's tiled scene renderer registry, used for managing tiled scene layer 2D rende...
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Layer tree node points to a map layer.
A container for the context for various read/write operations on objects.
Contains information about the context of a rendering operation.
Encapsulates the render context for a 2D tiled scene rendering operation.
void textureCoordinates(float &textureX1, float &textureY1, float &textureX2, float &textureY2, float &textureX3, float &textureY3) const
Returns the current texture coordinates.
void setTextureImage(const QImage &image)
Sets the current texture image.
QgsFeedback * feedback() const
Returns the feedback object used to cancel rendering.
void setTextureCoordinates(float textureX1, float textureY1, float textureX2, float textureY2, float textureX3, float textureY3)
Sets the current texture coordinates.
QImage textureImage() const
Returns the current texture image.
QgsTiledSceneRenderContext(QgsRenderContext &context, QgsFeedback *feedback=nullptr)
Constructor for QgsTiledSceneRenderContext.
QgsTiledSceneRendererAbstractMetadata * rendererMetadata(const QString &rendererName)
Returns the metadata for a specified renderer.
void setTileBorderRenderingEnabled(bool enabled)
Sets whether to render the borders of tiles.
virtual QList< QgsLayerTreeModelLegendNode * > createLegendNodes(QgsLayerTreeLayer *nodeLayer)
Creates a set of legend nodes representing the renderer.
void saveCommonProperties(QDomElement &element, const QgsReadWriteContext &context) const
Saves common renderer properties (such as point size and screen error) to the specified DOM element.
virtual void stopRender(QgsTiledSceneRenderContext &context)
Must be called when a render cycle has finished, to allow the renderer to clean up.
void setMaximumScreenErrorUnit(Qgis::RenderUnit unit)
Sets the unit for the maximum screen error allowed when rendering the tiled scene.
Qgis::RenderUnit maximumScreenErrorUnit() const
Returns the unit for the maximum screen error allowed when rendering the tiled scene.
static QgsTiledSceneRenderer * load(QDomElement &element, const QgsReadWriteContext &context)
Creates a renderer from an XML element.
QgsTiledSceneRenderer()=default
double maximumScreenError() const
Returns the maximum screen error allowed when rendering the tiled scene.
void setMaximumScreenError(double error)
Sets the maximum screen error allowed when rendering the tiled scene.
virtual void startRender(QgsTiledSceneRenderContext &context)
Must be called when a new render cycle is started.
void restoreCommonProperties(const QDomElement &element, const QgsReadWriteContext &context)
Restores common renderer properties (such as screen error) from the specified DOM element.
virtual Qgis::TiledSceneRendererFlags flags() const
Returns flags which control how the renderer behaves.
virtual QStringList legendRuleKeys() const
Returns a list of all rule keys for legend nodes created by the renderer.
void copyCommonProperties(QgsTiledSceneRenderer *destination) const
Copies common tiled scene renderer properties (such as screen error) to the destination renderer.
static Q_INVOKABLE Qgis::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
static Q_INVOKABLE QString encodeUnit(Qgis::DistanceUnit unit)
Encodes a distance unit to a string.
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.