QGIS API Documentation 3.99.0-Master (8e76e220402)
Loading...
Searching...
No Matches
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
21#include <QWindow>
22#include <Qt3DRender/QCamera>
23#include <Qt3DRender/QCameraSelector>
24#include <Qt3DRender/QClearBuffers>
25#include <Qt3DRender/QCullFace>
26#include <Qt3DRender/QDebugOverlay>
27#include <Qt3DRender/QDepthTest>
28#include <Qt3DRender/QFrustumCulling>
29#include <Qt3DRender/QLayer>
30#include <Qt3DRender/QLayerFilter>
31#include <Qt3DRender/QParameter>
32#include <Qt3DRender/QPolygonOffset>
33#include <Qt3DRender/QRenderCapture>
34#include <Qt3DRender/QRenderStateSet>
35#include <Qt3DRender/QRenderSurfaceSelector>
36#include <Qt3DRender/QRenderTarget>
37#include <Qt3DRender/QRenderTargetSelector>
38#include <Qt3DRender/QTexture>
39#include <Qt3DRender/QViewport>
40
50class QgsLightSource;
54class QgsRectangle;
57
58#define SIP_NO_FILE
59
70class QgsFrameGraph : public Qt3DCore::QEntity
71{
72 Q_OBJECT
73
74 public:
76 QgsFrameGraph( QSurface *surface, QSize s, Qt3DRender::QCamera *mainCamera, Qt3DCore::QEntity *root );
77
79 Qt3DRender::QFrameGraphNode *frameGraphRoot() { return mRenderSurfaceSelector; }
80
82 Qt3DRender::QCamera *mainCamera() { return mMainCamera; }
83
85 QgsPostprocessingEntity *postprocessingEntity() { return mPostprocessingEntity; }
86
88 Qt3DCore::QEntity *rubberBandsRootEntity() { return mRubberBandsRootEntity; }
89
91 Qt3DRender::QRenderCapture *renderCapture();
92
94 Qt3DRender::QRenderCapture *depthRenderCapture();
95
97 void setFrustumCullingEnabled( bool enabled );
98
100 void setClearColor( const QColor &clearColor );
101
103 void setSize( QSize s );
104
109 void setRenderCaptureEnabled( bool enabled );
110
115 void setDebugOverlayEnabled( bool enabled );
116
118 QString dumpFrameGraph() const;
119
121 QString dumpSceneGraph() const;
122
130 void addClipPlanes( int nrClipPlanes );
131
138 void removeClipPlanes();
139
147 bool registerRenderView( std::unique_ptr<QgsAbstractRenderView> renderView, const QString &name, Qt3DRender::QFrameGraphNode *topNode = nullptr );
148
153 void unregisterRenderView( const QString &name );
154
159 void setRenderViewEnabled( const QString &name, bool enable );
160
165 bool isRenderViewEnabled( const QString &name );
166
171 QgsAbstractRenderView *renderView( const QString &name );
172
178
184
190
196
202
208
213 void updateShadowSettings( const QgsShadowSettings &shadowSettings, const QList<QgsLightSource *> &lightSources );
214
219 void updateDebugShadowMapSettings( const Qgs3DMapSettings &settings );
220
225 void updateDebugDepthMapSettings( const Qgs3DMapSettings &settings );
226
232
237 void updateEyeDomeSettings( const Qgs3DMapSettings &settings );
238
239 static const QString FORWARD_RENDERVIEW;
240 static const QString SHADOW_RENDERVIEW;
241 static const QString AXIS3D_RENDERVIEW;
242 static const QString DEPTH_RENDERVIEW;
243 static const QString OVERLAY_RENDERVIEW;
245 static const QString AMBIENT_OCCLUSION_RENDERVIEW;
246 static const QString HIGHLIGHTS_RENDERVIEW;
247
248 private:
249 Qt3DRender::QRenderSurfaceSelector *mRenderSurfaceSelector = nullptr;
250 Qt3DRender::QViewport *mMainViewPort = nullptr;
251
252 Qt3DRender::QCamera *mMainCamera = nullptr;
253
254 // Post processing pass branch nodes:
255 Qt3DRender::QRenderTargetSelector *mRenderCaptureTargetSelector = nullptr;
256 Qt3DRender::QRenderCapture *mRenderCapture = nullptr;
257 // Post processing pass texture related objects:
258 Qt3DRender::QTexture2D *mRenderCaptureColorTexture = nullptr;
259 Qt3DRender::QTexture2D *mRenderCaptureDepthTexture = nullptr;
260
261 // Rubber bands pass
262 Qt3DRender::QCameraSelector *mRubberBandsCameraSelector = nullptr;
263 Qt3DRender::QLayerFilter *mRubberBandsLayerFilter = nullptr;
264 Qt3DRender::QRenderStateSet *mRubberBandsStateSet = nullptr;
265 Qt3DRender::QRenderTargetSelector *mRubberBandsRenderTargetSelector = nullptr;
266
267 QSize mSize = QSize( 1024, 768 );
268
269 QVector3D mLightDirection = QVector3D( 0.0, -1.0f, 0.0f );
270
271 Qt3DCore::QEntity *mRootEntity = nullptr;
272
273 Qt3DRender::QLayer *mRubberBandsLayer = nullptr;
274
275 QgsPostprocessingEntity *mPostprocessingEntity = nullptr;
276
277 Qt3DCore::QEntity *mRubberBandsRootEntity = nullptr;
278
280 QgsOverlayTextureEntity *mShadowTextureDebugging = nullptr;
282 QgsOverlayTextureEntity *mDepthTextureDebugging = nullptr;
283
284 void constructShadowRenderPass();
285 void constructForwardRenderPass();
286 void constructHighlightsPass();
287 void constructOverlayTexturePass( Qt3DRender::QFrameGraphNode *topNode = nullptr );
288 Qt3DRender::QFrameGraphNode *constructPostprocessingPass();
289 void constructDepthRenderPass();
290 void constructAmbientOcclusionRenderPass();
291 Qt3DRender::QFrameGraphNode *constructRubberBandsPass();
292
293 Qt3DRender::QFrameGraphNode *constructSubPostPassForProcessing();
294 Qt3DRender::QFrameGraphNode *constructSubPostPassForRenderCapture();
295
296 bool mRenderCaptureEnabled = false;
297
298 // holds renderviews according to their name
299 std::map<QString, std::unique_ptr<QgsAbstractRenderView>> mRenderViewMap;
300
301 Q_DISABLE_COPY( QgsFrameGraph )
302};
303
304#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.
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.
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.
static const QString HIGHLIGHTS_RENDERVIEW
QgsHighlightsRenderView & highlightsRenderView()
Returns the highlights renderview, used for rendering highlight overlays of identified features.
static const QString OVERLAY_RENDERVIEW
void updateDebugDepthMapSettings(const Qgs3DMapSettings &settings)
Updates settings for depth debug map.
static const QString AXIS3D_RENDERVIEW
QgsForwardRenderView & forwardRenderView()
Returns forward renderview.
QgsOverlayTextureRenderView & overlayTextureRenderView()
Returns overlay texture renderview.
QString dumpSceneGraph() const
Dumps scene graph as string.
QgsShadowRenderView & shadowRenderView()
Returns shadow 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.
QgsFrameGraph(QSurface *surface, QSize s, Qt3DRender::QCamera *mainCamera, Qt3DCore::QEntity *root)
Constructor.
Qt3DRender::QRenderCapture * renderCapture()
Returns the render capture object used to take an image of the scene.
Container class that holds different objects related to highlighting identified features.
Base class for light sources in 3d scenes.
An entity responsible for rendering an overlay texture in 3D view.
Simple render view to preview overlay textures in 3D view.
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.