QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
3d
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 "
qgs3dmapcanvas.h
"
19
#include "
qgsframegraph.h
"
20
#include "
qgsshadowrenderview.h
"
21
22
#include <Qt3DRender/QRenderSettings>
23
24
#include "moc_qgswindow3dengine.cpp"
25
26
QgsWindow3DEngine::QgsWindow3DEngine
(
Qgs3DMapCanvas
*parent )
27
:
QgsAbstract3DEngine
( parent )
28
{
29
mMapCanvas3D = parent;
30
31
mRoot =
new
Qt3DCore::QEntity;
32
mMapCanvas3D->
setRootEntity
( mRoot );
33
34
mFrameGraph
=
new
QgsFrameGraph
( mMapCanvas3D, QSize( 1024, 768 ), mMapCanvas3D->camera(), mRoot );
35
mMapCanvas3D->setActiveFrameGraph(
mFrameGraph
->frameGraphRoot() );
36
37
// force switching to no shadow rendering
38
mFrameGraph
->shadowRenderView().setEnabled(
false
);
39
}
40
41
QWindow *
QgsWindow3DEngine::window
()
42
{
43
return
mMapCanvas3D;
44
}
45
46
Qt3DCore::QEntity *
QgsWindow3DEngine::root
()
const
47
{
48
return
mRoot;
49
}
50
51
void
QgsWindow3DEngine::setClearColor
(
const
QColor &color )
52
{
53
mFrameGraph
->setClearColor( color );
54
}
55
56
void
QgsWindow3DEngine::setFrustumCullingEnabled
(
bool
enabled )
57
{
58
// Not sure if this works properly
59
mFrameGraph
->setFrustumCullingEnabled( enabled );
60
}
61
62
void
QgsWindow3DEngine::setRootEntity
( Qt3DCore::QEntity *
root
)
63
{
64
mSceneRoot =
root
;
65
mSceneRoot->setParent( mRoot );
66
}
67
68
Qt3DRender::QRenderSettings *
QgsWindow3DEngine::renderSettings
()
69
{
70
return
mMapCanvas3D->renderSettings();
71
}
72
73
Qt3DRender::QCamera *
QgsWindow3DEngine::camera
()
74
{
75
return
mMapCanvas3D->camera();
76
}
77
78
QSize
QgsWindow3DEngine::size
()
const
79
{
80
return
mMapCanvas3D->size();
81
}
82
83
QSurface *
QgsWindow3DEngine::surface
()
const
84
{
85
return
mMapCanvas3D;
86
}
87
88
void
QgsWindow3DEngine::setSize
( QSize s )
89
{
90
mSize = s;
91
92
mMapCanvas3D->setWidth( mSize.width() );
93
mMapCanvas3D->setHeight( mSize.height() );
94
mFrameGraph
->setSize( mSize * mMapCanvas3D->devicePixelRatio() );
95
camera
()->setAspectRatio(
float
( mSize.width() ) /
float
( mSize.height() ) );
96
emit
sizeChanged
();
97
}
Qgs3DMapCanvas
Convenience wrapper to simplify the creation of a 3D window ready to be used with QGIS.
Definition
qgs3dmapcanvas.h:89
Qgs3DMapCanvas::setRootEntity
void setRootEntity(Qt3DCore::QEntity *root)
Sets the specified root entity of the scene.
Definition
qgs3dmapcanvas.cpp:90
QgsAbstract3DEngine::sizeChanged
void sizeChanged()
Emitted after a call to setSize().
QgsAbstract3DEngine::QgsAbstract3DEngine
QgsAbstract3DEngine(QObject *parent=nullptr)
Constructor for QgsAbstract3DEngine with the specified parent object.
Definition
qgsabstract3dengine.cpp:26
QgsAbstract3DEngine::mFrameGraph
QgsFrameGraph * mFrameGraph
Definition
qgsabstract3dengine.h:142
QgsFrameGraph
Container class that holds different objects related to frame graphs of 3D scenes.
Definition
qgsframegraph.h:86
QgsWindow3DEngine::setRootEntity
void setRootEntity(Qt3DCore::QEntity *root) override
Sets root entity of the 3D scene.
Definition
qgswindow3dengine.cpp:62
QgsWindow3DEngine::QgsWindow3DEngine
QgsWindow3DEngine(Qgs3DMapCanvas *parent)
Constructor for QgsWindow3DEngine with the specified parent Qgs3DMapCanvas.
Definition
qgswindow3dengine.cpp:26
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:68
QgsWindow3DEngine::setSize
void setSize(QSize s) override
Sets the size of the rendering area (in pixels).
Definition
qgswindow3dengine.cpp:88
QgsWindow3DEngine::size
QSize size() const override
Returns size of the engine's rendering area in pixels.
Definition
qgswindow3dengine.cpp:78
QgsWindow3DEngine::root
Qt3DCore::QEntity * root() const
Returns the root entity.
Definition
qgswindow3dengine.cpp:46
QgsWindow3DEngine::camera
Qt3DRender::QCamera * camera() override
Returns pointer to the engine's camera entity.
Definition
qgswindow3dengine.cpp:73
QgsWindow3DEngine::surface
QSurface * surface() const override
Returns the surface of the engine.
Definition
qgswindow3dengine.cpp:83
QgsWindow3DEngine::setClearColor
void setClearColor(const QColor &color) override
Sets background color of the scene.
Definition
qgswindow3dengine.cpp:51
QgsWindow3DEngine::window
QWindow * window()
Returns the internal 3D window where all the rendered output is displayed.
Definition
qgswindow3dengine.cpp:41
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:56
qgs3dmapcanvas.h
qgsframegraph.h
qgsshadowrenderview.h
qgswindow3dengine.h
Generated on
for QGIS API Documentation by
1.17.0