QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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 }
void requestCaptureImage() override
Starts a request for an image rendered by the engine.
void setRootEntity(Qt3DCore::QEntity *root) override
Sets root entity of the 3D scene.
void setClearColor(const QColor &color) override
Sets background color of the scene.
QWindow * window()
Returns the internal 3D window where all the rendered output is displayed.
Qt3DRender::QRenderSettings * renderSettings() override
Returns access to the engine&#39;s render settings (the frame graph can be accessed from here) ...
Qt3DRender::QCamera * camera() override
Returns pointer to the engine&#39;s camera entity.
void imageCaptured(const QImage &image)
Emitted after a call to requestCaptureImage() to return the captured image.
QSize size() const override
Returns size of the engine&#39;s rendering area in pixels.
void setFrustumCullingEnabled(bool enabled) override
Sets whether frustum culling is enabled (this should make rendering faster by not rendering entities ...