QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgswindow3dengine.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgswindow3dengine.cpp
3  --------------------------------------
4  Date : July 2018
5  Copyright : (C) 2018 by Martin Dobias
6  Email : wonder dot sk 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 #include "qgswindow3dengine.h"
17 
18 #include <Qt3DRender/QRenderCapture>
19 #include <Qt3DExtras/Qt3DWindow>
20 #include <Qt3DExtras/QForwardRenderer>
21 
22 
24 {
25  mWindow3D = new Qt3DExtras::Qt3DWindow;
26 
27  mCapture = new Qt3DRender::QRenderCapture;
28  mWindow3D->activeFrameGraph()->setParent( mCapture );
29  mWindow3D->setActiveFrameGraph( mCapture );
30 }
31 
33 {
34  return mWindow3D;
35 }
36 
38 {
39  Qt3DRender::QRenderCaptureReply *captureReply;
40  captureReply = mCapture->requestCapture();
41  connect( captureReply, &Qt3DRender::QRenderCaptureReply::completed, this, [ = ]
42  {
43  emit imageCaptured( captureReply->image() );
44  captureReply->deleteLater();
45  } );
46 }
47 
48 void QgsWindow3DEngine::setClearColor( const QColor &color )
49 {
50  mWindow3D->defaultFrameGraph()->setClearColor( color );
51 }
52 
54 {
55  mWindow3D->defaultFrameGraph()->setFrustumCullingEnabled( enabled );
56 }
57 
58 void QgsWindow3DEngine::setRootEntity( Qt3DCore::QEntity *root )
59 {
60  mWindow3D->setRootEntity( root );
61 }
62 
63 Qt3DRender::QRenderSettings *QgsWindow3DEngine::renderSettings()
64 {
65  return mWindow3D->renderSettings();
66 }
67 
68 Qt3DRender::QCamera *QgsWindow3DEngine::camera()
69 {
70  return mWindow3D->camera();
71 }
72 
74 {
75  return mWindow3D->size();
76 }
77 
78 QSurface *QgsWindow3DEngine::surface() const
79 {
80  return mWindow3D;
81 }
QgsWindow3DEngine::setFrustumCullingEnabled
void setFrustumCullingEnabled(bool enabled) override
Sets whether frustum culling is enabled (this should make rendering faster by not rendering entities ...
Definition: qgswindow3dengine.cpp:53
QgsWindow3DEngine::requestCaptureImage
void requestCaptureImage() override
Starts a request for an image rendered by the engine.
Definition: qgswindow3dengine.cpp:37
QgsWindow3DEngine::window
QWindow * window()
Returns the internal 3D window where all the rendered output is displayed.
Definition: qgswindow3dengine.cpp:32
QgsAbstract3DEngine::imageCaptured
void imageCaptured(const QImage &image)
Emitted after a call to requestCaptureImage() to return the captured image.
QgsWindow3DEngine::renderSettings
Qt3DRender::QRenderSettings * renderSettings() override
Returns access to the engine's render settings (the frame graph can be accessed from here)
Definition: qgswindow3dengine.cpp:63
QgsWindow3DEngine::setRootEntity
void setRootEntity(Qt3DCore::QEntity *root) override
Sets root entity of the 3D scene.
Definition: qgswindow3dengine.cpp:58
qgswindow3dengine.h
QgsWindow3DEngine::surface
QSurface * surface() const override
Returns the surface of the engine.
Definition: qgswindow3dengine.cpp:78
QgsWindow3DEngine::QgsWindow3DEngine
QgsWindow3DEngine()
Definition: qgswindow3dengine.cpp:23
QgsWindow3DEngine::size
QSize size() const override
Returns size of the engine's rendering area in pixels.
Definition: qgswindow3dengine.cpp:73
QgsWindow3DEngine::camera
Qt3DRender::QCamera * camera() override
Returns pointer to the engine's camera entity.
Definition: qgswindow3dengine.cpp:68
QgsWindow3DEngine::setClearColor
void setClearColor(const QColor &color) override
Sets background color of the scene.
Definition: qgswindow3dengine.cpp:48