QGIS API Documentation 3.41.0-Master (cea29feecf2)
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} // namespace Qt3DCore
33
34namespace Qt3DRender
35{
36 class QCamera;
37 class QFrameGraphNode;
38 class QRenderAspect;
39 class QRenderSettings;
40} // namespace Qt3DRender
41
42namespace Qt3DExtras
43{
44 class QForwardRenderer;
45}
46
47namespace Qt3DInput
48{
49 class QInputAspect;
50 class QInputSettings;
51} // namespace Qt3DInput
52
53namespace Qt3DLogic
54{
55 class QLogicAspect;
56}
57#endif
58
59class QgsRectangle;
61class Qgs3DMapTool;
62class QgsPointXY;
65class Qgs3DMapScene;
67class QgsFeature;
68class QgsMapLayer;
69class QgsRubberBand3D;
70
71
82class _3D_EXPORT Qgs3DMapCanvas : public QWindow
83{
84 Q_OBJECT
85 public:
88
90 Qgs3DMapSettings *mapSettings() { return mMapSettings; }
91
93 Qgs3DMapScene *scene() { return mScene; }
94
96 QgsCameraController *cameraController();
97
98#ifndef SIP_RUN
99
103 void setRootEntity( Qt3DCore::QEntity *root );
104
108 void setActiveFrameGraph( Qt3DRender::QFrameGraphNode *activeFrameGraph );
109
113 Qt3DRender::QFrameGraphNode *activeFrameGraph() const;
114
118 Qt3DRender::QCamera *camera() const;
119
123 Qt3DRender::QRenderSettings *renderSettings() const;
124
126 void setMapSettings( Qgs3DMapSettings *mapSettings );
127
129 void resetView();
130
132 void setViewFromTop( const QgsPointXY &center, float distance, float rotation = 0 );
133
135 void saveAsImage( const QString &fileName, const QString &fileFormat );
136
141 void setMapTool( Qgs3DMapTool *tool );
142
147 Qgs3DMapTool *mapTool() const { return mMapTool; }
148
152 QgsWindow3DEngine *engine() const { return mEngine; }
153
157 void setTemporalController( QgsTemporalController *temporalController );
158
162 void setViewFrom2DExtent( const QgsRectangle &extent );
163
167 QVector<QgsPointXY> viewFrustum2DExtent();
168
173 void highlightFeature( const QgsFeature &feature, QgsMapLayer *layer );
174
178 void clearHighlights();
179
180 signals:
182 void savedAsImage( const QString &fileName );
183
186
188 void fpsCountChanged( float fpsCount );
189
191 void fpsCounterEnabledChanged( bool enabled );
192
194 void viewed2DExtentFrom3DChanged( QVector<QgsPointXY> extent );
195
197 void cameraNavigationSpeedChanged( double speed );
198
199#endif
200
201 private slots:
202 void captureDepthBuffer();
203 void updateTemporalRange( const QgsDateTimeRange &timeRange );
204 void onNavigationModeChanged( Qgis::NavigationMode mode );
205 void updateHighlightSizes();
206
207 protected:
211 void showEvent( QShowEvent *e ) override;
212
216 void resizeEvent( QResizeEvent * ) override;
217
218 bool eventFilter( QObject *watched, QEvent *event ) override;
219
220 private:
221 Qt3DCore::QAspectEngine *m_aspectEngine;
222
223 // Aspects
224 Qt3DRender::QRenderAspect *m_renderAspect;
225 Qt3DInput::QInputAspect *m_inputAspect;
226 Qt3DLogic::QLogicAspect *m_logicAspect;
227
228 // Renderer configuration
229 Qt3DRender::QRenderSettings *m_renderSettings;
230 Qt3DRender::QCamera *m_defaultCamera;
231
232 // Input configuration
233 Qt3DInput::QInputSettings *m_inputSettings;
234
235 // Scene
236 Qt3DCore::QEntity *m_root;
237 Qt3DCore::QEntity *m_userRoot;
238
239 bool m_initialized;
240
241 QgsWindow3DEngine *mEngine = nullptr;
242
244 Qgs3DMapSettings *mMapSettings = nullptr;
246 Qgs3DMapScene *mScene = nullptr;
247
249 Qgs3DMapTool *mMapTool = nullptr;
250
251 QString mCaptureFileName;
252 QString mCaptureFileFormat;
253
254 QgsTemporalController *mTemporalController = nullptr;
255
257 QMap<QgsMapLayer *, QgsRubberBand3D *> mHighlights;
258};
259
260#endif //QGS3DMAPCANVAS_H
NavigationMode
The navigation mode used by 3D cameras.
Definition qgis.h:3917
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.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:58
Base class for all map layer types.
Definition qgsmaplayer.h:76
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 ...