/
qgs3dmapcanvas.h
133 lines (103 loc) · 4.53 KB
/
qgs3dmapcanvas.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/***************************************************************************
qgs3dmapcanvas.h
--------------------------------------
Date : July 2017
Copyright : (C) 2017 by Martin Dobias
Email : wonder dot sk at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGS3DMAPCANVAS_H
#define QGS3DMAPCANVAS_H
#include <QWidget>
#include <Qt3DRender/QRenderCapture>
#include "qgsrange.h"
namespace Qt3DExtras
{
class Qt3DWindow;
}
class Qgs3DMapSettings;
class Qgs3DMapScene;
class Qgs3DMapTool;
class QgsWindow3DEngine;
class QgsCameraController;
class QgsPointXY;
class Qgs3DNavigationWidget;
class QgsTemporalController;
class Qgs3DMapCanvas : public QWidget
{
Q_OBJECT
public:
Qgs3DMapCanvas( QWidget *parent = nullptr );
~Qgs3DMapCanvas() override;
//! Configure map scene being displayed. Takes ownership.
void setMap( Qgs3DMapSettings *map );
//! Returns access to the 3D scene configuration
Qgs3DMapSettings *map() { return mMap; }
//! Returns access to the 3D scene (root 3D entity)
Qgs3DMapScene *scene() { return mScene; }
//! Returns access to the view's camera controller. Returns NULLPTR if the scene has not been initialized yet with setMap()
QgsCameraController *cameraController();
//! Resets camera position to the default: looking down at the origin of world coordinates
void resetView( bool resetExtent = false );
//! Sets camera position to look down at the given point (in map coordinates) in given distance from plane with zero elevation
void setViewFromTop( const QgsPointXY ¢er, float distance, float rotation = 0 );
//! Saves the current scene as an image
void saveAsImage( QString fileName, QString fileFormat );
/**
* Sets the active map tool that will receive events from the 3D canvas. Does not transfer ownership.
* If the tool is NULLPTR, events will be used for camera manipulation.
*/
void setMapTool( Qgs3DMapTool *tool );
/**
* Returns the active map tool that will receive events from the 3D canvas.
* If the tool is NULLPTR, events will be used for camera manipulation.
*/
Qgs3DMapTool *mapTool() const { return mMapTool; }
/**
* Sets the visibility of on-screen navigation widget.
*/
void setOnScreenNavigationVisibility( bool visibility );
/**
* Sets the temporal controller
*/
void setTemporalController( QgsTemporalController *temporalController );
//
bool identifyPointCloudOnMouseEvent( QVector<QPair<QgsMapLayer *, QVector<QVariantMap>>> &result, QMouseEvent *event );
signals:
//! Emitted when the 3D map canvas was successfully saved as image
void savedAsImage( QString fileName );
//! Emitted when the the map setting is changed
void mapSettingsChanged();
//! Emitted when the FPS count changes (at most every frame)
void fpsCountChanged( float fpsCount );
//! Emitted when the FPS counter is enabled or disabeld
void fpsCounterEnabledChanged( bool enabled );
public slots:
private slots:
void updateTemporalRange( const QgsDateTimeRange &timeRange );
protected:
void resizeEvent( QResizeEvent *ev ) override;
bool eventFilter( QObject *watched, QEvent *event ) override;
private:
QgsWindow3DEngine *mEngine = nullptr;
QString mCaptureFileName;
QString mCaptureFileFormat;
//! Container QWidget that encapsulates mWindow3D so we can use it embedded in ordinary widgets app
QWidget *mContainer = nullptr;
//! Description of the 3D scene
Qgs3DMapSettings *mMap = nullptr;
//! Root entity of the 3D scene
Qgs3DMapScene *mScene = nullptr;
//! Active map tool that receives events (if NULLPTR then mouse/keyboard events are used for camera manipulation)
Qgs3DMapTool *mMapTool = nullptr;
//! On-Screen Navigation widget.
Qgs3DNavigationWidget *mNavigationWidget = nullptr;
QgsTemporalController *mTemporalController = nullptr;
};
#endif // QGS3DMAPCANVAS_H