QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
qgs3dterrainregistry.h
Go to the documentation of this file.
1/***************************************************************************
2 qgs3dterrainregistry.h
3 --------------------------------------
4 Date : November 2024
5 Copyright : (C) 2024 by Nyall Dawson
6 Email : nyall dot dawson at gmail 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 QGS3DTERRAINREGISTRY_H
17#define QGS3DTERRAINREGISTRY_H
18
19#include "qgis_3d.h"
20#include "qgis_sip.h"
21#include <QString>
22
23#include <QDomElement>
24#include <QMap>
25#include <QIcon>
26
31class QgsRectangle;
32
43{
44 public:
50 Qgs3DTerrainAbstractMetadata( const QString &type, const QString &visibleName, const QIcon &icon = QIcon() )
51 : mType( type )
52 , mVisibleName( visibleName )
53 , mIcon( icon )
54 {}
55
56 virtual ~Qgs3DTerrainAbstractMetadata() = default;
57
61 QString type() const { return mType; }
62
66 QString visibleName() const { return mVisibleName; }
67
71 QIcon icon() const { return mIcon; }
72
79
88
89 private:
90 QString mType;
91 QString mVisibleName;
92 QIcon mIcon;
93};
94
96SIP_SKIP typedef QgsAbstractTerrainSettings *( *QgsTerrainSettingsCreateFunc )();
98SIP_SKIP typedef QgsTerrainGenerator *( *QgsTerrainGeneratorCreateFunc )();
99
100#ifndef SIP_RUN
101
111{
112 public:
121 Qgs3DTerrainMetadata( const QString &type, const QString &visibleName, QgsTerrainSettingsCreateFunc pfSettingsCreate, QgsTerrainGeneratorCreateFunc pfGeneratorCreate, const QIcon &icon = QIcon() )
122 : Qgs3DTerrainAbstractMetadata( type, visibleName, icon )
123 , mCreateFunc( pfSettingsCreate )
124 , mGeneratorCreateFunc( pfGeneratorCreate )
125 {}
126
131
135 QgsTerrainGeneratorCreateFunc createGeneratorFunction() const { return mGeneratorCreateFunc; }
136
137 QgsAbstractTerrainSettings *createTerrainSettings() override SIP_FACTORY { return mCreateFunc ? mCreateFunc() : nullptr; }
138 QgsTerrainGenerator *createTerrainGenerator() override { return mGeneratorCreateFunc ? mGeneratorCreateFunc() : nullptr; }
139
140 private:
142 QgsTerrainGeneratorCreateFunc mGeneratorCreateFunc;
143};
144#endif
145
146
156class _3D_EXPORT Qgs3DTerrainRegistry
157{
158 public:
161
164
166 Qgs3DTerrainAbstractMetadata *terrainMetadata( const QString &type ) const;
167
171 QStringList types() const;
172
174 bool addType( Qgs3DTerrainAbstractMetadata *metadata SIP_TRANSFER );
175
183 QgsAbstractTerrainSettings *createTerrainSettings( const QString &type ) const SIP_FACTORY;
184
194 SIP_SKIP QgsTerrainGenerator *createTerrainGenerator( const QString &type ) const;
195
199 QgsAbstractTerrainSettings *configureTerrainFromProject( QgsProjectElevationProperties *properties ) SIP_FACTORY;
200
201 private:
202#ifdef SIP_RUN
204#endif
205
206 QMap<QString, Qgs3DTerrainAbstractMetadata *> mMetadata;
208 QStringList mTerrainOrder;
209};
210
211
212#endif // QGS3DTERRAINREGISTRY_H
Stores metadata about one 3D terrain class.
Qgs3DTerrainAbstractMetadata(const QString &type, const QString &visibleName, const QIcon &icon=QIcon())
Constructor for Qgs3DTerrainAbstractMetadata, with the specified type and visibleName.
QString type() const
Returns the unique terrain type string.
virtual ~Qgs3DTerrainAbstractMetadata()=default
QString visibleName() const
Returns the terrain's visible (translated) name.
virtual QgsTerrainGenerator * createTerrainGenerator()
Creates a new instance of this terrain generator type.
QIcon icon() const
Returns an icon representing the terrain type, if available.
virtual QgsAbstractTerrainSettings * createTerrainSettings()=0
Creates a new instance of this terrain settings type.
Convenience metadata class that uses static functions to create 3D terrain objects.
QgsTerrainGeneratorCreateFunc createGeneratorFunction() const
Returns the terrain generator creation function.
QgsTerrainSettingsCreateFunc createSettingsFunction() const
Returns the terrain setting's creation function.
Qgs3DTerrainMetadata(const QString &type, const QString &visibleName, QgsTerrainSettingsCreateFunc pfSettingsCreate, QgsTerrainGeneratorCreateFunc pfGeneratorCreate, const QIcon &icon=QIcon())
Constructor for Qgs3DTerrainMetadata, with the specified type and visibleName.
QgsTerrainGenerator * createTerrainGenerator() override
Creates a new instance of this terrain generator type.
QgsAbstractTerrainSettings * createTerrainSettings() override
Creates a new instance of this terrain settings type.
Registry of available 3d terrain classes.
Qgs3DTerrainRegistry & operator=(const Qgs3DTerrainRegistry &rh)=delete
Qgs3DTerrainRegistry(const Qgs3DTerrainRegistry &rh)=delete
Contains elevation properties for a QgsProject.
The class is used as a container of context for various read/write operations on other objects.
A rectangle specified with double values.
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:76
QgsAbstractTerrainSettings *(* QgsTerrainSettingsCreateFunc)()
Terrain settings creation function.
QgsTerrainGenerator *(* QgsTerrainGeneratorCreateFunc)()
Terrain generator creation function.