QGIS API Documentation 3.38.0-Grenoble (exported)
Loading...
Searching...
No Matches
qgstiledscenerenderer.h
Go to the documentation of this file.
1/***************************************************************************
2 qgstiledscenerenderer.h
3 --------------------
4 begin : August 2023
5 copyright : (C) 2023 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSTILEDSCENERENDERER_H
19#define QGSTILEDSCENERENDERER_H
20
21#include "qgsrendercontext.h"
22
23#include "qgis_core.h"
24#include "qgis_sip.h"
25
28
38{
39 public:
40
44 QgsTiledSceneRenderContext( QgsRenderContext &context, QgsFeedback *feedback = nullptr );
45
48
51
55 QgsRenderContext &renderContext() { return mRenderContext; }
56
61 const QgsRenderContext &renderContext() const { return mRenderContext; } SIP_SKIP
62
68 QgsFeedback *feedback() const { return mFeedback; }
69
75 QImage textureImage() const;
76
82 void setTextureImage( const QImage &image );
83
89 void setTextureCoordinates(
90 float textureX1, float textureY1,
91 float textureX2, float textureY2,
92 float textureX3, float textureY3
93 );
94
100 void textureCoordinates( float &textureX1 SIP_OUT, float &textureY1 SIP_OUT, float &textureX2 SIP_OUT, float &textureY2 SIP_OUT, float &textureX3 SIP_OUT, float &textureY3 SIP_OUT ) const;
101
102 private:
103#ifdef SIP_RUN
105#endif
106
107 QgsRenderContext &mRenderContext;
108 QgsFeedback *mFeedback = nullptr;
109 QImage mTextureImage;
110 float mTextureCoordinates[6] { 0, 0, 0, 0, 0, 0 };
111
112};
113
122class CORE_EXPORT QgsTiledSceneRenderer
123{
124
125#ifdef SIP_RUN
127
128 const QString type = sipCpp->type();
129 if ( type == QLatin1String( "texture" ) )
130 sipType = sipType_QgsTiledSceneTextureRenderer;
131 else if ( type == QLatin1String( "wireframe" ) )
132 sipType = sipType_QgsTiledSceneWireframeRenderer;
133 else
134 sipType = 0;
135
136 SIP_END
137#endif
138
139 public:
140
145
146 virtual ~QgsTiledSceneRenderer() = default;
147
151 virtual QString type() const = 0;
152
158
161
164
168 virtual Qgis::TiledSceneRendererFlags flags() const;
169
177 static QgsTiledSceneRenderer *load( QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY;
178
183 virtual QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) const = 0;
184
195 double maximumScreenError() const;
196
207 void setMaximumScreenError( double error );
208
215 Qgis::RenderUnit maximumScreenErrorUnit() const;
216
223 void setMaximumScreenErrorUnit( Qgis::RenderUnit unit );
224
230 void setTileBorderRenderingEnabled( bool enabled ) { mTileBorderRendering = enabled; }
231
237 bool isTileBorderRenderingEnabled() const { return mTileBorderRendering; }
238
248 virtual void startRender( QgsTiledSceneRenderContext &context );
249
260 virtual void stopRender( QgsTiledSceneRenderContext &context );
261
265 virtual QList<QgsLayerTreeModelLegendNode *> createLegendNodes( QgsLayerTreeLayer *nodeLayer ) SIP_FACTORY;
266
270 virtual QStringList legendRuleKeys() const;
271
275 virtual void renderTriangle( QgsTiledSceneRenderContext &context, const QPolygonF &triangle ) = 0;
276
280 virtual void renderLine( QgsTiledSceneRenderContext &context, const QPolygonF &line ) = 0;
281
282 protected:
283
287 void copyCommonProperties( QgsTiledSceneRenderer *destination ) const;
288
295 void restoreCommonProperties( const QDomElement &element, const QgsReadWriteContext &context );
296
303 void saveCommonProperties( QDomElement &element, const QgsReadWriteContext &context ) const;
304
305 private:
306#ifdef SIP_RUN
308#endif
309
310#ifdef QGISDEBUG
312 QThread *mThread = nullptr;
313#endif
314
315 double mMaximumScreenError = 3;
316 Qgis::RenderUnit mMaximumScreenErrorUnit = Qgis::RenderUnit::Millimeters;
317 bool mTileBorderRendering = false;
318
319};
320
321#endif // QGSTILEDSCENERENDERER_H
RenderUnit
Rendering size units.
Definition qgis.h:4489
@ Millimeters
Millimeters.
QFlags< TiledSceneRendererFlag > TiledSceneRendererFlags
Flags which control how tiled scene 2D renderers behave.
Definition qgis.h:4867
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
Layer tree node points to a map layer.
The QgsLegendRendererItem class is abstract interface for legend items returned from QgsMapLayerLegen...
The class is used as a container of context for various read/write operations on other objects.
Contains information about the context of a rendering operation.
Encapsulates the render context for a 2D tiled scene rendering operation.
QgsFeedback * feedback() const
Returns the feedback object used to cancel rendering.
QgsTiledSceneRenderContext & operator=(const QgsTiledSceneRenderContext &)=delete
QgsTiledSceneRenderContext cannot be copied.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
QgsTiledSceneRenderContext(const QgsTiledSceneRenderContext &rh)=delete
QgsTiledSceneRenderContext cannot be copied.
const QgsRenderContext & renderContext() const
Returns a reference to the context's render context.
Abstract base class for 2d tiled scene renderers.
void setTileBorderRenderingEnabled(bool enabled)
Sets whether to render the borders of tiles.
virtual QString type() const =0
Returns the identifier of the renderer type.
QgsTiledSceneRenderer(const QgsTiledSceneRenderer &other)=delete
QgsTiledSceneRenderer cannot be copied – use clone() instead.
virtual QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) const =0
Saves the renderer configuration to an XML element.
virtual ~QgsTiledSceneRenderer()=default
virtual QgsTiledSceneRenderer * clone() const =0
Create a deep copy of this renderer.
QgsTiledSceneRenderer()=default
Constructor for QgsTiledSceneRenderer.
QgsTiledSceneRenderer & operator=(const QgsTiledSceneRenderer &other)=delete
QgsTiledSceneRenderer cannot be copied – use clone() instead.
virtual void renderTriangle(QgsTiledSceneRenderContext &context, const QPolygonF &triangle)=0
Renders a triangle.
virtual void renderLine(QgsTiledSceneRenderContext &context, const QPolygonF &line)=0
Renders a line.
bool isTileBorderRenderingEnabled() const
Returns whether to render also borders of tiles.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:191
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_OUT
Definition qgis_sip.h:58
#define SIP_FACTORY
Definition qgis_sip.h:76
#define SIP_END
Definition qgis_sip.h:208