QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
qgs3dmapcanvas.h
Go to the documentation of this file.
1/***************************************************************************
2 qgs3dmapcanvas.h
3 --------------------------------------
4 Date : July 2017
5 Copyright : (C) 2017 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#ifndef QGS3DMAPCANVAS_H
17#define QGS3DMAPCANVAS_H
18
19#include "qgis_3d.h"
20
21#include "qgis.h"
22#include "qgsrange.h"
23
24#include <QtGui/QWindow>
25
26#ifndef SIP_RUN
27namespace Qt3DCore
28{
29 class QAspectEngine;
30 class QAbstractAspect;
31 class QEntity;
32}
33
34namespace Qt3DRender
35{
36 class QCamera;
37 class QFrameGraphNode;
38 class QRenderAspect;
39 class QRenderSettings;
40}
41
42namespace Qt3DExtras
43{
44 class QForwardRenderer;
45}
46
47namespace Qt3DInput
48{
49 class QInputAspect;
50 class QInputSettings;
51}
52
53namespace Qt3DLogic
54{
55 class QLogicAspect;
56}
57#endif
58
59class QgsRectangle;
61class Qgs3DMapTool;
62class QgsPointXY;
65class Qgs3DMapScene;
67
68
79class _3D_EXPORT Qgs3DMapCanvas : public QWindow
80{
81 Q_OBJECT
82 public:
83
86
88 Qgs3DMapSettings *mapSettings() { return mMapSettings; }
89
91 Qgs3DMapScene *scene() { return mScene; }
92
94 QgsCameraController *cameraController();
95
96#ifndef SIP_RUN
97
101 void setRootEntity( Qt3DCore::QEntity *root );
102
106 void setActiveFrameGraph( Qt3DRender::QFrameGraphNode *activeFrameGraph );
107
111 Qt3DRender::QFrameGraphNode *activeFrameGraph() const;
112
116 Qt3DRender::QCamera *camera() const;
117
121 Qt3DRender::QRenderSettings *renderSettings() const;
122
124 void setMapSettings( Qgs3DMapSettings *mapSettings );
125
127 void resetView();
128
130 void setViewFromTop( const QgsPointXY &center, float distance, float rotation = 0 );
131
133 void saveAsImage( const QString &fileName, const QString &fileFormat );
134
139 void setMapTool( Qgs3DMapTool *tool );
140
145 Qgs3DMapTool *mapTool() const { return mMapTool; }
146
150 QgsWindow3DEngine *engine() const { return mEngine; }
151
155 void setTemporalController( QgsTemporalController *temporalController );
156
160 void setViewFrom2DExtent( const QgsRectangle &extent );
161
165 QVector<QgsPointXY> viewFrustum2DExtent();
166
167 signals:
169 void savedAsImage( const QString &fileName );
170
173
175 void fpsCountChanged( float fpsCount );
176
178 void fpsCounterEnabledChanged( bool enabled );
179
181 void viewed2DExtentFrom3DChanged( QVector<QgsPointXY> extent );
182
184 void cameraNavigationSpeedChanged( double speed );
185
186#endif
187
188 private slots:
189 void captureDepthBuffer();
190 void updateTemporalRange( const QgsDateTimeRange &timeRange );
191 void onNavigationModeChanged( Qgis::NavigationMode mode );
192
193 protected:
194
198 void showEvent( QShowEvent *e ) override;
199
203 void resizeEvent( QResizeEvent * ) override;
204
205 bool eventFilter( QObject *watched, QEvent *event ) override;
206
207 private:
208
209 Qt3DCore::QAspectEngine *m_aspectEngine;
210
211 // Aspects
212 Qt3DRender::QRenderAspect *m_renderAspect;
213 Qt3DInput::QInputAspect *m_inputAspect;
214 Qt3DLogic::QLogicAspect *m_logicAspect;
215
216 // Renderer configuration
217 Qt3DRender::QRenderSettings *m_renderSettings;
218 Qt3DRender::QCamera *m_defaultCamera;
219
220 // Input configuration
221 Qt3DInput::QInputSettings *m_inputSettings;
222
223 // Scene
224 Qt3DCore::QEntity *m_root;
225 Qt3DCore::QEntity *m_userRoot;
226
227 bool m_initialized;
228
229 QgsWindow3DEngine *mEngine = nullptr;
230
232 Qgs3DMapSettings *mMapSettings = nullptr;
234 Qgs3DMapScene *mScene = nullptr;
235
237 Qgs3DMapTool *mMapTool = nullptr;
238
239 QString mCaptureFileName;
240 QString mCaptureFileFormat;
241
242 QgsTemporalController *mTemporalController = nullptr;
243};
244
245#endif //QGS3DMAPCANVAS_H
NavigationMode
The navigation mode used by 3D cameras.
Definition qgis.h:3872
QgsWindow3DEngine * engine() const
Returns the 3D engine.
Qgs3DMapSettings * mapSettings()
Returns access to the 3D scene configuration.
void mapSettingsChanged()
Emitted when the the map setting is changed.
void viewed2DExtentFrom3DChanged(QVector< QgsPointXY > extent)
Emitted when the viewed 2D extent seen by the 3D camera has changed.
Qgs3DMapTool * mapTool() const
Returns the active map tool that will receive events from the 3D canvas.
void fpsCountChanged(float fpsCount)
Emitted when the FPS count changes (at most every frame)
void cameraNavigationSpeedChanged(double speed)
Emitted when the camera navigation speed is changed.
Qgs3DMapScene * scene()
Returns access to the 3D scene (root 3D entity)
void savedAsImage(const QString &fileName)
Emitted when the 3D map canvas was successfully saved as image.
void fpsCounterEnabledChanged(bool enabled)
Emitted when the FPS counter is enabled or disabeld.
A class to represent a 2D point.
Definition qgspointxy.h:60
A rectangle specified with double values.
A controller base class for temporal objects, contains a signal for notifying updates of the objects ...