QGIS API Documentation 4.1.0-Master (01362494303)
Loading...
Searching...
No Matches
qgs3d.h
Go to the documentation of this file.
1/***************************************************************************
2 qgs3d.h
3 --------
4 begin : July 2020
5 copyright : (C) 2020 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 QGS3D_H
19#define QGS3D_H
20
21#include <memory>
22
23#include "qgis.h"
24#include "qgis_3d.h"
25#include "qgis_sip.h"
26
31class QgsMaterial;
34#ifndef SIP_RUN
35namespace Qt3DCore
36{
37 class QGeometry;
38}
39
40namespace Qt3DRender
41{
42 class QEffect;
43}
44#endif
45
52class _3D_EXPORT Qgs3D
53{
54 public:
55 Qgs3D( const Qgs3D &other ) = delete;
56 Qgs3D &operator=( const Qgs3D &other ) = delete;
57
61 static Qgs3D *instance();
62
63 ~Qgs3D();
64
68 static void initialize();
69
74
79
80#ifndef SIP_RUN
89
94 static QMap<QString, QString> toMaterialExportParameters( const QgsAbstractMaterialSettings *settings );
95
100 static void addMaterialParametersToEffect( Qt3DRender::QEffect *effect, const QgsAbstractMaterialSettings *settings, const QgsMaterialContext &materialContext );
101
106 static void applyMaterialDataDefinedToGeometry( const QgsAbstractMaterialSettings *settings, Qt3DCore::QGeometry *geometry, int vertexCount, const QByteArray &dataDefinedBytes );
107
113 static QByteArray materialDataDefinedVertexColorsAsByte( const QgsAbstractMaterialSettings *settings, const QgsExpressionContext &expressionContext );
114
120
125
126#endif
127
128 private:
129 Qgs3D();
130
131#ifdef SIP_RUN
132 Qgs3D( const Qgs3D &other );
133#endif
134
135 bool mInitialized = false;
136
137 Qgs3DTerrainRegistry *mTerrainRegistry = nullptr;
138 std::unique_ptr< QgsAbstractMaterial3DHandler > mNullMaterialHandler;
139 std::unique_ptr< QgsAbstractMaterial3DHandler > mPhongMaterialHandler;
140 std::unique_ptr< QgsAbstractMaterial3DHandler > mPhongTexturedMaterialHandler;
141 std::unique_ptr< QgsAbstractMaterial3DHandler > mSimpleLineMaterialHandler;
142 std::unique_ptr< QgsAbstractMaterial3DHandler > mGoochMaterialHandler;
143 std::unique_ptr< QgsAbstractMaterial3DHandler > mMetalRoughMaterialHandler;
144 std::unique_ptr< QgsAbstractMaterial3DHandler > mMetalRoughTexturedMaterialHandler;
145};
146
147#endif // QGS3D_H
MaterialRenderingTechnique
Material rendering techniques.
Definition qgis.h:4342
Registry of available 3d terrain classes.
static void initialize()
Initializes the 3D framework.
Definition qgs3d.cpp:67
static QMap< QString, QString > toMaterialExportParameters(const QgsAbstractMaterialSettings *settings)
Returns the parameters to be exported to .mtl file.
Definition qgs3d.cpp:150
static Qgs3DTerrainRegistry * terrainRegistry()
Returns the terrain registry, used for managing 3D terrains.
Definition qgs3d.cpp:119
static QgsMaterial * toMaterial(const QgsAbstractMaterialSettings *settings, Qgis::MaterialRenderingTechnique technique, const QgsMaterialContext &context)
Creates a new QgsMaterial object representing the material settings.
Definition qgs3d.cpp:141
static void addMaterialParametersToEffect(Qt3DRender::QEffect *effect, const QgsAbstractMaterialSettings *settings, const QgsMaterialContext &materialContext)
Adds parameters from the material settings to a destination effect.
Definition qgs3d.cpp:159
static QgsMaterialRegistry * materialRegistry()
Returns the material registry, used for managing 3D materials.
Definition qgs3d.cpp:114
static Qgs3D * instance()
Returns a pointer to the singleton instance.
Definition qgs3d.cpp:50
static const QgsAbstractMaterial3DHandler * handlerForMaterialSettings(const QgsAbstractMaterialSettings *settings)
Returns the handler to use for a material settings.
Definition qgs3d.cpp:124
Qgs3D & operator=(const Qgs3D &other)=delete
Qgs3D(const Qgs3D &other)=delete
static QByteArray materialDataDefinedVertexColorsAsByte(const QgsAbstractMaterialSettings *settings, const QgsExpressionContext &expressionContext)
Returns byte array corresponding to the data defined colors depending of the expressionContext,...
Definition qgs3d.cpp:175
static int materialDataDefinedByteStride(const QgsAbstractMaterialSettings *settings)
Returns byte stride of the data defined colors,used to fill the vertex colors data defined buffer for...
Definition qgs3d.cpp:184
static void applyMaterialDataDefinedToGeometry(const QgsAbstractMaterialSettings *settings, Qt3DCore::QGeometry *geometry, int vertexCount, const QByteArray &dataDefinedBytes)
Applies the data defined bytes, dataDefinedBytes, on the geometry by filling a specific vertex buffer...
Definition qgs3d.cpp:167
Abstract base class for material 3D handlers.
Abstract base class for material settings.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Context settings for a material.
Registry of available 3d material settings classes.
Base class for all materials used within QGIS 3D views.
Definition qgsmaterial.h:40