QGIS API Documentation 4.1.0-Master (9af12b5a203)
Loading...
Searching...
No Matches
qgscategorized3drenderer.h
Go to the documentation of this file.
1/***************************************************************************
2 qgscategorized3drenderer.h
3 --------------------------------------
4 Date : November 2025
5 Copyright : (C) 2025 by Jean Felder
6 Email : jean dot felder at oslandia dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSCATEGORIZED3DRENDERER_H
17#define QGSCATEGORIZED3DRENDERER_H
18
19#include <memory>
20
21#include "qgis_3d.h"
22#include "qgis_sip.h"
24#include "qgsabstract3dsymbol.h"
26#include "qgscolorramp.h"
27
29class QgsFeature3DHandler;
30class QgsExpression;
31
32
43{
44 public:
46
48 QgsAbstract3DRenderer *createRenderer( QDomElement &elem, const QgsReadWriteContext &context ) override SIP_FACTORY;
49};
50
51
61class _3D_EXPORT Qgs3DRendererCategory
62{
63 public:
65
75 Qgs3DRendererCategory( const QVariant &value, QgsAbstract3DSymbol *symbol SIP_TRANSFER, bool render = true );
76
79
87 const QVariant value() const { return mValue; }
88
93 QgsAbstract3DSymbol *symbol() const { return mSymbol.get(); }
94
99 bool renderState() const { return mRender; }
100
108 void setValue( const QVariant &value );
109
117 void setSymbol( QgsAbstract3DSymbol *symbol SIP_TRANSFER );
118
123 void setRenderState( bool render );
124
125 private:
126 QVariant mValue;
127 std::unique_ptr<QgsAbstract3DSymbol> mSymbol;
128 bool mRender = true;
129};
130
131using Qgs3DCategoryList = QList<Qgs3DRendererCategory>;
132
133
146{
147 public:
150
152 QgsCategorized3DRenderer( const QString &attributeName = QString(), const Qgs3DCategoryList &categories = Qgs3DCategoryList() );
153
154 QString type() const override { return "categorized"; }
155 QgsCategorized3DRenderer *clone() const override SIP_FACTORY;
156 Qt3DCore::QEntity *createEntity( Qgs3DMapSettings *mapSettings ) const override SIP_SKIP;
157
164 void updateSymbols( QgsAbstract3DSymbol *symbol );
165
169 const Qgs3DCategoryList &categories() const { return mCategories; }
170
178 QString classAttribute() const { return mAttributeName; }
179
187 void setClassAttribute( QString attributeName );
188
195 QgsAbstract3DSymbol *sourceSymbol();
196
204 const QgsAbstract3DSymbol *sourceSymbol() const SIP_SKIP;
205
213 void setSourceSymbol( QgsAbstract3DSymbol *symbol SIP_TRANSFER );
214
220 QgsColorRamp *sourceColorRamp();
221
228 const QgsColorRamp *sourceColorRamp() const SIP_SKIP;
229
236 void setSourceColorRamp( QgsColorRamp *ramp SIP_TRANSFER );
237
242 void updateColorRamp( QgsColorRamp *ramp SIP_TRANSFER );
243
252 bool updateCategoryValue( int catIndex, const QVariant &value );
253
262 bool updateCategorySymbol( int catIndex, QgsAbstract3DSymbol *symbol SIP_TRANSFER );
263
274 bool updateCategoryRenderState( int catIndex, bool render );
275
281 void addCategory( const Qgs3DRendererCategory &category );
282
288 bool deleteCategory( int catIndex );
289
295 void deleteAllCategories();
296
300 bool moveCategory( int from, int to );
301
310 static Qgs3DCategoryList createCategories( const QVariantList &values, const QgsAbstract3DSymbol *symbol, QgsVectorLayer *layer = nullptr, const QString &attributeName = QString() );
311
316 void sortByValue( Qt::SortOrder order = Qt::AscendingOrder );
317
318 void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
319 void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
320
321 private:
322 QString mAttributeName;
323 Qgs3DCategoryList mCategories;
324 std::unique_ptr<QgsColorRamp> mSourceColorRamp;
325 std::unique_ptr<QgsAbstract3DSymbol> mSourceSymbol;
326};
327
328#endif // QGSCATEGORIZED3DRENDERER_H
Definition of the world.
Rendering context for preparation of 3D entities.
virtual QgsAbstract3DRenderer * createRenderer(QDomElement &elem, const QgsReadWriteContext &context)=0
Returns new instance of the renderer given the DOM element.
Qgs3DRendererAbstractMetadata(const QString &type)
Constructor of the base class.
Represents an individual category (class) from a QgsCategorized3DRenderer.
Qgs3DRendererCategory()=default
const QVariant value() const
Returns the value corresponding to this category.
bool renderState() const
Returns true if the category is currently enabled and should be rendered.
Qgs3DRendererCategory & operator=(const Qgs3DRendererCategory &other)
QgsAbstract3DSymbol * symbol() const
Returns the symbol which will be used to render this category.
Base class for all renderers that participate in 3D views.
Abstract base class for 3D symbols that are used by VectorLayer3DRenderer objects.
QString classAttribute() const
Returns the class attribute for the renderer, which is the field name or expression string from the l...
QgsCategorized3DRenderer(const QString &attributeName=QString(), const Qgs3DCategoryList &categories=Qgs3DCategoryList())
Construct renderer with the given categories.
const Qgs3DCategoryList & categories() const
Returns a list of all categories recognized by the renderer.
QString type() const override
Returns unique identifier of the renderer class (used to identify subclass).
Abstract base class for color ramps.
Handles parsing and evaluation of expressions (formerly called "search strings").
A container for the context for various read/write operations on objects.
Represents a vector layer which manages a vector based dataset.
#define SIP_SKIP
Definition qgis_sip.h:133
#define SIP_TRANSFER
Definition qgis_sip.h:35
#define SIP_FACTORY
Definition qgis_sip.h:83
QList< Qgs3DRendererCategory > Qgs3DCategoryList