16 #ifndef QGSCAMERACONTROLLER_H 17 #define QGSCAMERACONTROLLER_H 23 #include <Qt3DCore/QEntity> 28 class QKeyboardDevice;
29 class QKeyboardHandler;
48 class QgsTerrainEntity;
59 Q_PROPERTY( Qt3DRender::QCamera *camera READ camera WRITE setCamera NOTIFY cameraChanged )
60 Q_PROPERTY( QRect viewport READ viewport WRITE setViewport NOTIFY viewportChanged )
75 void setTerrainEntity( QgsTerrainEntity *te );
78 void setCamera( Qt3DRender::QCamera *camera );
80 void setViewport( QRect viewport );
82 void frameTriggered(
float dt );
85 void resetView(
float distance );
88 void setViewFromTop(
float worldX,
float worldY,
float distance,
float yaw = 0 );
99 void setLookingAtPoint(
const QgsVector3D &point,
float distance,
float pitch,
float yaw );
117 float distance()
const {
return mCameraPose.distanceFromCenterPoint(); }
124 float pitch()
const {
return mCameraPose.pitchAngle(); }
131 float yaw()
const {
return mCameraPose.headingAngle(); }
134 QDomElement writeXml( QDomDocument &doc )
const;
136 void readXml(
const QDomElement &elem );
139 void zoom(
float factor );
141 void tiltUpAroundViewCenter(
float deltaPitch );
143 void rotateAroundViewCenter(
float deltaYaw );
145 void setCameraHeadingAngle(
float angle );
147 void moveView(
float tx,
float ty );
150 void rotateCamera(
float diffPitch,
float diffYaw );
151 void updateCameraFromPose(
bool centerPointChanged =
false );
155 void cameraChanged();
157 void viewportChanged();
160 void onPositionChanged( Qt3DInput::QMouseEvent *mouse );
161 void onWheel( Qt3DInput::QWheelEvent *wheel );
162 void onMousePressed( Qt3DInput::QMouseEvent *mouse );
163 void onMouseReleased( Qt3DInput::QMouseEvent *mouse );
164 void onKeyPressed( Qt3DInput::QKeyEvent *event );
165 void onKeyReleased( Qt3DInput::QKeyEvent *event );
166 void onPickerMousePressed( Qt3DRender::QPickEvent *pick );
170 Qt3DRender::QCamera *mCamera =
nullptr;
174 float mLastPressedHeight = 0;
176 QPointer<QgsTerrainEntity> mTerrainEntity;
185 Qt3DInput::QMouseDevice *mMouseDevice =
nullptr;
186 Qt3DInput::QKeyboardDevice *mKeyboardDevice =
nullptr;
188 Qt3DInput::QMouseHandler *mMouseHandler =
nullptr;
189 Qt3DInput::QKeyboardHandler *mKeyboardHandler =
nullptr;
193 #endif // QGSCAMERACONTROLLER_H 3 Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double preci...
QgsCameraPose cameraPose() const
Returns camera pose.
float pitch() const
Returns pitch angle in degrees (0 = looking from the top, 90 = looking from the side).
QRect viewport() const
Returns viewport rectangle.
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
3 Class that encapsulates camera pose in a 3D scene.
float yaw() const
Returns yaw angle in degrees.
3 Object that controls camera movement based on user input
float distance() const
Returns distance of the camera from the point it is looking at.