QGIS API Documentation 3.43.0-Master (261ee7da134)
qgsframegraph.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsframegraph.h
3 --------------------------------------
4 Date : August 2020
5 Copyright : (C) 2020 by Belgacem Nedjima
6 Email : gb underscore nedjima at esi dot dz
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 QGSFRAMEGRAPH_H
17#define QGSFRAMEGRAPH_H
18
19#include <map>
20#include <QWindow>
21#include <Qt3DRender/QCamera>
22#include <Qt3DRender/QRenderSurfaceSelector>
23#include <Qt3DRender/QViewport>
24#include <Qt3DRender/QCameraSelector>
25#include <Qt3DRender/QLayerFilter>
26#include <Qt3DRender/QLayer>
27#include <Qt3DRender/QRenderTargetSelector>
28#include <Qt3DRender/QRenderTarget>
29#include <Qt3DRender/QTexture>
30#include <Qt3DRender/QClearBuffers>
31#include <Qt3DRender/QParameter>
32#include <Qt3DRender/QFrustumCulling>
33#include <Qt3DRender/QRenderStateSet>
34#include <Qt3DRender/QDepthTest>
35#include <Qt3DRender/QCullFace>
36#include <Qt3DRender/QPolygonOffset>
37#include <Qt3DRender/QRenderCapture>
38#include <Qt3DRender/QDebugOverlay>
39
41
44class QgsRectangle;
54
55#define SIP_NO_FILE
56
67class QgsFrameGraph : public Qt3DCore::QEntity
68{
69 Q_OBJECT
70
71 public:
73 QgsFrameGraph( QSurface *surface, QSize s, Qt3DRender::QCamera *mainCamera, Qt3DCore::QEntity *root );
74
76 Qt3DRender::QFrameGraphNode *frameGraphRoot() { return mRenderSurfaceSelector; }
77
79 Qt3DRender::QCamera *mainCamera() { return mMainCamera; }
80
82 QgsPostprocessingEntity *postprocessingEntity() { return mPostprocessingEntity; }
83
85 Qt3DCore::QEntity *rubberBandsRootEntity() { return mRubberBandsRootEntity; }
86
88 Qt3DRender::QRenderCapture *renderCapture();
89
91 Qt3DRender::QRenderCapture *depthRenderCapture();
92
94 void setFrustumCullingEnabled( bool enabled );
95
97 void setClearColor( const QColor &clearColor );
98
100 void setSize( QSize s );
101
106 void setRenderCaptureEnabled( bool enabled );
107
112 void setDebugOverlayEnabled( bool enabled );
113
115 QString dumpFrameGraph() const;
116
118 QString dumpSceneGraph() const;
119
127 void addClipPlanes( int nrClipPlanes );
128
135 void removeClipPlanes();
136
144 bool registerRenderView( std::unique_ptr<QgsAbstractRenderView> renderView, const QString &name, Qt3DRender::QFrameGraphNode *topNode = nullptr );
145
150 void unregisterRenderView( const QString &name );
151
156 void setRenderViewEnabled( const QString &name, bool enable );
157
162 bool isRenderViewEnabled( const QString &name );
163
168 QgsAbstractRenderView *renderView( const QString &name );
169
175
181
187
193
198 void updateShadowSettings( const QgsShadowSettings &shadowSettings, const QList<QgsLightSource *> &lightSources );
199
204 void updateDebugShadowMapSettings( const Qgs3DMapSettings &settings );
205
210 void updateDebugDepthMapSettings( const Qgs3DMapSettings &settings );
211
217
222 void updateEyeDomeSettings( const Qgs3DMapSettings &settings );
223
224 static const QString FORWARD_RENDERVIEW;
225 static const QString SHADOW_RENDERVIEW;
226 static const QString AXIS3D_RENDERVIEW;
227 static const QString DEPTH_RENDERVIEW;
228 static const QString DEBUG_RENDERVIEW;
230 static const QString AMBIENT_OCCLUSION_RENDERVIEW;
231
232 private:
233 Qt3DRender::QRenderSurfaceSelector *mRenderSurfaceSelector = nullptr;
234 Qt3DRender::QViewport *mMainViewPort = nullptr;
235
236 Qt3DRender::QCamera *mMainCamera = nullptr;
237
238 // Post processing pass branch nodes:
239 Qt3DRender::QRenderTargetSelector *mRenderCaptureTargetSelector = nullptr;
240 Qt3DRender::QRenderCapture *mRenderCapture = nullptr;
241 // Post processing pass texture related objects:
242 Qt3DRender::QTexture2D *mRenderCaptureColorTexture = nullptr;
243 Qt3DRender::QTexture2D *mRenderCaptureDepthTexture = nullptr;
244
245 // Rubber bands pass
246 Qt3DRender::QCameraSelector *mRubberBandsCameraSelector = nullptr;
247 Qt3DRender::QLayerFilter *mRubberBandsLayerFilter = nullptr;
248 Qt3DRender::QRenderStateSet *mRubberBandsStateSet = nullptr;
249 Qt3DRender::QRenderTargetSelector *mRubberBandsRenderTargetSelector = nullptr;
250
251 QSize mSize = QSize( 1024, 768 );
252
253 QVector3D mLightDirection = QVector3D( 0.0, -1.0f, 0.0f );
254
255 Qt3DCore::QEntity *mRootEntity = nullptr;
256
257 Qt3DRender::QLayer *mRubberBandsLayer = nullptr;
258
259 QgsPostprocessingEntity *mPostprocessingEntity = nullptr;
260
261 Qt3DCore::QEntity *mRubberBandsRootEntity = nullptr;
262
264 QgsDebugTextureEntity *mShadowTextureDebugging = nullptr;
266 QgsDebugTextureEntity *mDepthTextureDebugging = nullptr;
267
268 void constructShadowRenderPass();
269 void constructForwardRenderPass();
270 void constructDebugTexturePass( Qt3DRender::QFrameGraphNode *topNode = nullptr );
271 Qt3DRender::QFrameGraphNode *constructPostprocessingPass();
272 void constructDepthRenderPass();
273 void constructAmbientOcclusionRenderPass();
274 Qt3DRender::QFrameGraphNode *constructRubberBandsPass();
275
276 Qt3DRender::QFrameGraphNode *constructSubPostPassForProcessing();
277 Qt3DRender::QFrameGraphNode *constructSubPostPassForRenderCapture();
278
279 bool mRenderCaptureEnabled = false;
280
281 // holds renderviews according to their name
282 std::map<QString, std::unique_ptr<QgsAbstractRenderView>> mRenderViewMap;
283
284 Q_DISABLE_COPY( QgsFrameGraph )
285};
286
287#endif // QGSFRAMEGRAPH_H
Definition of the world.
Base class for 3D render view.
Container class that holds different objects related to ambient occlusion rendering.
Contains the configuration of ambient occlusion rendering.
Object that controls camera movement based on user input.
An entity that is responsible for debugging texture.
Container class that holds different objects related to depth rendering.
Definition of a directional light in a 3D map scene.
Container class that holds different objects related to forward rendering.
Container class that holds different objects related to frame graphs of 3D scenes.
void updateAmbientOcclusionSettings(const QgsAmbientOcclusionSettings &settings)
Updates settings for ambient occlusion.
void updateEyeDomeSettings(const Qgs3DMapSettings &settings)
Updates settings for eye dome lighting.
bool isRenderViewEnabled(const QString &name)
Returns true if the render view named name is found and enabled.
void setRenderViewEnabled(const QString &name, bool enable)
Enables or disables the render view named name according to enable.
void updateShadowSettings(const QgsShadowSettings &shadowSettings, const QList< QgsLightSource * > &lightSources)
Updates shadow bias, light and texture size according to shadowSettings and lightSources.
void addClipPlanes(int nrClipPlanes)
Setups nrClipPlanes clip planes in the forward pass to enable OpenGL clipping.
void unregisterRenderView(const QString &name)
Unregisters the render view named name, if any.
bool registerRenderView(std::unique_ptr< QgsAbstractRenderView > renderView, const QString &name, Qt3DRender::QFrameGraphNode *topNode=nullptr)
Registers a new the render view renderView with name name.
QString dumpFrameGraph() const
Dumps frame graph as string.
void setRenderCaptureEnabled(bool enabled)
Sets whether it will be possible to render to an image.
QgsAmbientOcclusionRenderView & ambientOcclusionRenderView()
Returns ambient occlusion renderview.
Qt3DRender::QRenderCapture * depthRenderCapture()
Returns the render capture object used to take an image of the depth buffer of the scene.
void updateDebugShadowMapSettings(const Qgs3DMapSettings &settings)
Updates settings for shadows debug map.
QgsAbstractRenderView * renderView(const QString &name)
Returns the render view named name, if any.
void removeClipPlanes()
Disables OpenGL clipping.
static const QString AMBIENT_OCCLUSION_RENDERVIEW
Ambient occlusion render view name.
Qt3DRender::QFrameGraphNode * frameGraphRoot()
Returns the root of the frame graph object.
QgsDepthRenderView & depthRenderView()
Returns depth renderview.
void setClearColor(const QColor &clearColor)
Sets the clear color of the scene (background color)
QgsPostprocessingEntity * postprocessingEntity()
Returns the postprocessing entity.
static const QString FORWARD_RENDERVIEW
Qt3DCore::QEntity * rubberBandsRootEntity()
Returns entity for all rubber bands (to show them always on top)
void setFrustumCullingEnabled(bool enabled)
Sets whether frustum culling is enabled.
static const QString SHADOW_RENDERVIEW
void setDebugOverlayEnabled(bool enabled)
Sets whether debug overlay is enabled.
void updateDebugDepthMapSettings(const Qgs3DMapSettings &settings)
Updates settings for depth debug map.
static const QString AXIS3D_RENDERVIEW
QgsForwardRenderView & forwardRenderView()
Returns forward renderview.
QString dumpSceneGraph() const
Dumps scene graph as string.
QgsShadowRenderView & shadowRenderView()
Returns shadow renderview.
static const QString DEBUG_RENDERVIEW
void setSize(QSize s)
Sets the size of the buffers used for rendering.
static const QString DEPTH_RENDERVIEW
Qt3DRender::QCamera * mainCamera()
Returns the main camera.
Qt3DRender::QRenderCapture * renderCapture()
Returns the render capture object used to take an image of the scene.
An entity that is responsible for applying post processing effects.
A rectangle specified with double values.
Container class that holds different objects related to shadow rendering.
Contains configuration for rendering shadows.