78 Qt3DRender::QCamera *
camera()
const {
return mCamera; }
97 void setCameraMovementSpeed(
double movementSpeed );
112 void frameTriggered(
float dt );
115 void resetView(
float distance );
118 void setViewFromTop(
float worldX,
float worldY,
float distance,
float yaw = 0 );
129 void setLookingAtPoint(
const QgsVector3D &point,
float distance,
float pitch,
float yaw );
148 float distance()
const {
return mCameraPose.distanceFromCenterPoint(); }
155 float pitch()
const {
return mCameraPose.pitchAngle(); }
162 float yaw()
const {
return mCameraPose.headingAngle(); }
165 QDomElement writeXml( QDomDocument &doc )
const;
167 void readXml(
const QDomElement &elem );
170 void zoom(
float factor );
172 void tiltUpAroundViewCenter(
float deltaPitch );
174 void rotateAroundViewCenter(
float deltaYaw );
176 void setCameraHeadingAngle(
float angle );
178 void moveView(
float tx,
float ty );
184 void walkView(
double tx,
double ty,
double tz );
192 void rotateCamera(
float diffPitch,
float diffYaw );
199 bool willHandleKeyEvent( QKeyEvent *event );
213 void depthBufferCaptured(
const QImage &depthImage );
221 void updateCameraFromPose();
222 void moveCameraPositionBy(
const QVector3D &posDiff );
224 QWindow *window()
const;
227 enum class MouseOperation
240 const QList<MouseOperation> mTranslateOrRotate =
242 MouseOperation::Translation,
243 MouseOperation::RotationCamera,
244 MouseOperation::RotationCenter
248 bool isATranslationRotationSequence( MouseOperation newOperation )
const;
250 void setMouseParameters(
const MouseOperation &newOperation,
const QPoint &clickPoint = QPoint() );
283 void onPositionChanged( Qt3DInput::QMouseEvent *mouse );
284 void onWheel( Qt3DInput::QWheelEvent *wheel );
285 void onMousePressed( Qt3DInput::QMouseEvent *mouse );
286 void onMouseReleased( Qt3DInput::QMouseEvent *mouse );
287 void onKeyPressed( Qt3DInput::QKeyEvent *event );
288 void onKeyReleased( Qt3DInput::QKeyEvent *event );
289 void applyFlyModeKeyMovements();
292 void onKeyPressedFlyNavigation( Qt3DInput::QKeyEvent *event );
293 void onKeyPressedTerrainNavigation( Qt3DInput::QKeyEvent *event );
294 void onPositionChangedFlyNavigation( Qt3DInput::QMouseEvent *mouse );
295 void onPositionChangedTerrainNavigation( Qt3DInput::QMouseEvent *mouse );
297 void handleTerrainNavigationWheelZoom();
303 double sampleDepthBuffer(
const QImage &buffer,
int px,
int py );
307 bool screenPointToWorldPos( QPoint position, Qt3DRender::QCamera *cameraBefore,
double &depth, QVector3D &worldPosition );
314 Qt3DRender::QCamera *mCamera =
nullptr;
325 bool mDepthBufferIsReady =
false;
326 QImage mDepthBufferImage;
328 std::unique_ptr< Qt3DRender::QCamera > mCameraBefore;
330 bool mRotationCenterCalculated =
false;
331 QVector3D mRotationCenter;
332 double mRotationDistanceFromCenter;
333 double mRotationPitch = 0;
334 double mRotationYaw = 0;
336 bool mDragPointCalculated =
false;
337 QVector3D mDragPoint;
340 bool mZoomPointCalculated =
false;
341 QVector3D mZoomPoint;
343 Qt3DInput::QMouseHandler *mMouseHandler =
nullptr;
344 Qt3DInput::QKeyboardHandler *mKeyboardHandler =
nullptr;
347 double mCameraMovementSpeed = 5.0;
349 QSet< int > mDepressedKeys;
350 bool mCaptureFpsMouseMovements =
false;
351 bool mIgnoreNextMouseMove =
false;
352 QTimer *mFpsNavTimer =
nullptr;
354 double mCumulatedWheelY = 0;
356 MouseOperation mCurrentOperation = MouseOperation::None;
359 friend class TestQgs3DRendering;
360 friend class TestQgs3DCameraController;