16 #ifndef QGSCAMERACONTROLLER_H
17 #define QGSCAMERACONTROLLER_H
23 #include <Qt3DCore/QEntity>
28 class QKeyboardDevice;
29 class QKeyboardHandler;
48 class QgsTerrainEntity;
62 Q_PROPERTY( Qt3DRender::QCamera *camera READ camera WRITE setCamera NOTIFY cameraChanged )
63 Q_PROPERTY( QRect viewport READ viewport WRITE setViewport NOTIFY viewportChanged )
78 void setTerrainEntity( QgsTerrainEntity *te );
81 void setCamera( Qt3DRender::QCamera *camera );
83 void setViewport( QRect viewport );
85 void frameTriggered(
float dt );
88 void resetView(
float distance );
91 void setViewFromTop(
float worldX,
float worldY,
float distance,
float yaw = 0 );
102 void setLookingAtPoint(
const QgsVector3D &point,
float distance,
float pitch,
float yaw );
120 float distance()
const {
return mCameraPose.distanceFromCenterPoint(); }
127 float pitch()
const {
return mCameraPose.pitchAngle(); }
134 float yaw()
const {
return mCameraPose.headingAngle(); }
137 QDomElement writeXml( QDomDocument &doc )
const;
139 void readXml(
const QDomElement &elem );
142 void zoom(
float factor );
144 void tiltUpAroundViewCenter(
float deltaPitch );
146 void rotateAroundViewCenter(
float deltaYaw );
148 void setCameraHeadingAngle(
float angle );
150 void moveView(
float tx,
float ty );
153 void rotateCamera(
float diffPitch,
float diffYaw );
154 void updateCameraFromPose(
bool centerPointChanged =
false );
158 void cameraChanged();
160 void viewportChanged();
163 void onPositionChanged( Qt3DInput::QMouseEvent *mouse );
164 void onWheel( Qt3DInput::QWheelEvent *wheel );
165 void onMousePressed( Qt3DInput::QMouseEvent *mouse );
166 void onMouseReleased( Qt3DInput::QMouseEvent *mouse );
167 void onKeyPressed( Qt3DInput::QKeyEvent *event );
168 void onKeyReleased( Qt3DInput::QKeyEvent *event );
169 void onPickerMousePressed( Qt3DRender::QPickEvent *pick );
173 Qt3DRender::QCamera *mCamera =
nullptr;
177 float mLastPressedHeight = 0;
179 QPointer<QgsTerrainEntity> mTerrainEntity;
188 Qt3DInput::QMouseDevice *mMouseDevice =
nullptr;
189 Qt3DInput::QKeyboardDevice *mKeyboardDevice =
nullptr;
191 Qt3DInput::QMouseHandler *mMouseHandler =
nullptr;
192 Qt3DInput::QKeyboardHandler *mKeyboardHandler =
nullptr;
196 #endif // QGSCAMERACONTROLLER_H