QGIS API Documentation 3.36.0-Maidenhead (09951dc0acf)
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
88
93
95 Qgs3DMapSettings *mapSettings() { return mMapSettings; }
96
98 Qgs3DMapScene *scene() { return mScene; }
99
101 QgsCameraController *cameraController();
102
103#ifndef SIP_RUN
104
108 void setRootEntity( Qt3DCore::QEntity *root );
109
113 void setActiveFrameGraph( Qt3DRender::QFrameGraphNode *activeFrameGraph );
114
118 Qt3DRender::QFrameGraphNode *activeFrameGraph() const;
119
123 Qt3DRender::QCamera *camera() const;
124
128 Qt3DRender::QRenderSettings *renderSettings() const;
129
131 void setMapSettings( Qgs3DMapSettings *mapSettings );
132
134 void resetView();
135
137 void setViewFromTop( const QgsPointXY &center, float distance, float rotation = 0 );
138
140 void saveAsImage( const QString &fileName, const QString &fileFormat );
141
146 void setMapTool( Qgs3DMapTool *tool );
147
152 Qgs3DMapTool *mapTool() const { return mMapTool; }
153
157 QgsWindow3DEngine *engine() const { return mEngine; }
158
162 void setTemporalController( QgsTemporalController *temporalController );
163
167 void setViewFrom2DExtent( const QgsRectangle &extent );
168
172 QVector<QgsPointXY> viewFrustum2DExtent();
173
174 signals:
176 void savedAsImage( const QString &fileName );
177
180
182 void fpsCountChanged( float fpsCount );
183
185 void fpsCounterEnabledChanged( bool enabled );
186
188 void viewed2DExtentFrom3DChanged( QVector<QgsPointXY> extent );
189
191 void cameraNavigationSpeedChanged( double speed );
192
193#endif
194
195 private slots:
196 void captureDepthBuffer();
197 void updateTemporalRange( const QgsDateTimeRange &timeRange );
198 void onNavigationModeChanged( Qgis::NavigationMode mode );
199
200 protected:
201
205 void showEvent( QShowEvent *e ) override;
206
210 void resizeEvent( QResizeEvent * ) override;
211
212 bool eventFilter( QObject *watched, QEvent *event ) override;
213
214 private:
215
216 Qt3DCore::QAspectEngine *m_aspectEngine;
217
218 // Aspects
219 Qt3DRender::QRenderAspect *m_renderAspect;
220 Qt3DInput::QInputAspect *m_inputAspect;
221 Qt3DLogic::QLogicAspect *m_logicAspect;
222
223 // Renderer configuration
224 Qt3DRender::QRenderSettings *m_renderSettings;
225 Qt3DRender::QCamera *m_defaultCamera;
226
227 // Input configuration
228 Qt3DInput::QInputSettings *m_inputSettings;
229
230 // Scene
231 Qt3DCore::QEntity *m_root;
232 Qt3DCore::QEntity *m_userRoot;
233
234 bool m_initialized;
235
236 QgsWindow3DEngine *mEngine = nullptr;
237
239 Qgs3DMapSettings *mMapSettings = nullptr;
241 Qgs3DMapScene *mScene = nullptr;
242
244 Qgs3DMapTool *mMapTool = nullptr;
245
246 QString mCaptureFileName;
247 QString mCaptureFileFormat;
248
249 QgsTemporalController *mTemporalController = nullptr;
250};
251
252#endif //QGS3DMAPCANVAS_H
NavigationMode
The navigation mode used by 3D cameras.
Definition qgis.h:3348
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 ...