76 Qt3DRender::QCamera *
camera()
const {
return mCamera; }
95 void setCameraMovementSpeed(
double movementSpeed );
110 void frameTriggered(
float dt );
113 void resetView(
float distance );
116 void setViewFromTop(
float worldX,
float worldY,
float distance,
float yaw = 0 );
127 void setLookingAtPoint(
const QgsVector3D &point,
float distance,
float pitch,
float yaw );
146 float distance()
const {
return mCameraPose.distanceFromCenterPoint(); }
153 float pitch()
const {
return mCameraPose.pitchAngle(); }
160 float yaw()
const {
return mCameraPose.headingAngle(); }
163 QDomElement writeXml( QDomDocument &doc )
const;
165 void readXml(
const QDomElement &elem );
168 void zoom(
float factor );
170 void tiltUpAroundViewCenter(
float deltaPitch );
172 void rotateAroundViewCenter(
float deltaYaw );
174 void setCameraHeadingAngle(
float angle );
176 void moveView(
float tx,
float ty );
182 void walkView(
double tx,
double ty,
double tz );
190 void rotateCamera(
float diffPitch,
float diffYaw );
197 void rotateCameraAroundPivot(
float newPitch,
float newHeading,
const QVector3D &pivotPoint );
205 void zoomCameraAroundPivot(
const QVector3D &oldCameraPosition,
double zoomFactor,
const QVector3D &pivotPoint );
212 bool willHandleKeyEvent( QKeyEvent *event );
234 void depthBufferCaptured(
const QImage &depthImage );
242 void updateCameraFromPose();
243 void moveCameraPositionBy(
const QVector3D &posDiff );
245 QWindow *window()
const;
248 enum class MouseOperation
261 const QList<MouseOperation> mTranslateOrRotate = {
262 MouseOperation::Translation,
263 MouseOperation::RotationCamera,
264 MouseOperation::RotationCenter
268 bool isATranslationRotationSequence( MouseOperation newOperation )
const;
270 void setMouseParameters(
const MouseOperation &newOperation,
const QPoint &clickPoint = QPoint() );
303 void onPositionChanged( Qt3DInput::QMouseEvent *mouse );
304 void onWheel( Qt3DInput::QWheelEvent *wheel );
305 void onMousePressed( Qt3DInput::QMouseEvent *mouse );
306 void onMouseReleased( Qt3DInput::QMouseEvent *mouse );
307 void onKeyPressed( Qt3DInput::QKeyEvent *event );
308 void onKeyReleased( Qt3DInput::QKeyEvent *event );
309 void applyFlyModeKeyMovements();
312 void onKeyPressedFlyNavigation( Qt3DInput::QKeyEvent *event );
313 void onKeyPressedTerrainNavigation( Qt3DInput::QKeyEvent *event );
314 void onPositionChangedFlyNavigation( Qt3DInput::QMouseEvent *mouse );
315 void onPositionChangedTerrainNavigation( Qt3DInput::QMouseEvent *mouse );
317 void handleTerrainNavigationWheelZoom();
323 double sampleDepthBuffer(
const QImage &buffer,
int px,
int py );
327 bool screenPointToWorldPos( QPoint position, Qt3DRender::QCamera *cameraBefore,
double &depth, QVector3D &worldPosition );
334 Qt3DRender::QCamera *mCamera =
nullptr;
345 bool mDepthBufferIsReady =
false;
346 QImage mDepthBufferImage;
348 std::unique_ptr<Qt3DRender::QCamera> mCameraBefore;
350 bool mRotationCenterCalculated =
false;
351 QVector3D mRotationCenter;
352 double mRotationDistanceFromCenter = 0;
353 double mRotationPitch = 0;
354 double mRotationYaw = 0;
356 bool mDragPointCalculated =
false;
357 QVector3D mDragPoint;
360 bool mZoomPointCalculated =
false;
361 QVector3D mZoomPoint;
363 Qt3DInput::QMouseHandler *mMouseHandler =
nullptr;
364 Qt3DInput::QKeyboardHandler *mKeyboardHandler =
nullptr;
367 double mCameraMovementSpeed = 5.0;
369 QSet<int> mDepressedKeys;
370 bool mCaptureFpsMouseMovements =
false;
371 bool mIgnoreNextMouseMove =
false;
372 QTimer *mFpsNavTimer =
nullptr;
374 double mCumulatedWheelY = 0;
376 MouseOperation mCurrentOperation = MouseOperation::None;
382 friend class TestQgs3DRendering;
383 friend class TestQgs3DCameraController;