QGIS API Documentation 3.41.0-Master (3440c17df1d)
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
52 QgsRenderContext &renderContext() { return mRenderContext; }
53
58 const QgsRenderContext &renderContext() const { return mRenderContext; } SIP_SKIP
59
65 QgsFeedback *feedback() const { return mFeedback; }
66
72 QImage textureImage() const;
73
79 void setTextureImage( const QImage &image );
80
86 void setTextureCoordinates(
87 float textureX1, float textureY1,
88 float textureX2, float textureY2,
89 float textureX3, float textureY3
90 );
91
97 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;
98
99 private:
100#ifdef SIP_RUN
102#endif
103
104 QgsRenderContext &mRenderContext;
105 QgsFeedback *mFeedback = nullptr;
106 QImage mTextureImage;
107 float mTextureCoordinates[6] { 0, 0, 0, 0, 0, 0 };
108
109};
110
119class CORE_EXPORT QgsTiledSceneRenderer
120{
121
122#ifdef SIP_RUN
124
125 const QString type = sipCpp->type();
126 if ( type == QLatin1String( "texture" ) )
127 sipType = sipType_QgsTiledSceneTextureRenderer;
128 else if ( type == QLatin1String( "wireframe" ) )
129 sipType = sipType_QgsTiledSceneWireframeRenderer;
130 else
131 sipType = 0;
132
133 SIP_END
134#endif
135
136 public:
137
139
140 virtual ~QgsTiledSceneRenderer() = default;
141
145 virtual QString type() const = 0;
146
152
155
158
162 virtual Qgis::TiledSceneRendererFlags flags() const;
163
171 static QgsTiledSceneRenderer *load( QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY;
172
177 virtual QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) const = 0;
178
189 double maximumScreenError() const;
190
201 void setMaximumScreenError( double error );
202
209 Qgis::RenderUnit maximumScreenErrorUnit() const;
210
217 void setMaximumScreenErrorUnit( Qgis::RenderUnit unit );
218
224 void setTileBorderRenderingEnabled( bool enabled ) { mTileBorderRendering = enabled; }
225
231 bool isTileBorderRenderingEnabled() const { return mTileBorderRendering; }
232
242 virtual void startRender( QgsTiledSceneRenderContext &context );
243
254 virtual void stopRender( QgsTiledSceneRenderContext &context );
255
259 virtual QList<QgsLayerTreeModelLegendNode *> createLegendNodes( QgsLayerTreeLayer *nodeLayer ) SIP_FACTORY;
260
264 virtual QStringList legendRuleKeys() const;
265
269 virtual void renderTriangle( QgsTiledSceneRenderContext &context, const QPolygonF &triangle ) = 0;
270
274 virtual void renderLine( QgsTiledSceneRenderContext &context, const QPolygonF &line ) = 0;
275
276 protected:
277
281 void copyCommonProperties( QgsTiledSceneRenderer *destination ) const;
282
289 void restoreCommonProperties( const QDomElement &element, const QgsReadWriteContext &context );
290
297 void saveCommonProperties( QDomElement &element, const QgsReadWriteContext &context ) const;
298
299 private:
300#ifdef SIP_RUN
302#endif
303
304#ifdef QGISDEBUG
306 QThread *mThread = nullptr;
307#endif
308
309 double mMaximumScreenError = 3;
310 Qgis::RenderUnit mMaximumScreenErrorUnit = Qgis::RenderUnit::Millimeters;
311 bool mTileBorderRendering = false;
312
313};
314
315#endif // QGSTILEDSCENERENDERER_H
RenderUnit
Rendering size units.
Definition qgis.h:4847
@ Millimeters
Millimeters.
QFlags< TiledSceneRendererFlag > TiledSceneRendererFlags
Flags which control how tiled scene 2D renderers behave.
Definition qgis.h:5311
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
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
QgsTiledSceneRenderContext(const QgsTiledSceneRenderContext &rh)=delete
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
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