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 );
139 void setLookingAtMapPoint(
const QgsVector3D &point,
float distance,
float pitch,
float yaw );
145 void setCameraPose(
const QgsCameraPose &camPose,
bool force =
false );
158 float distance()
const {
return mCameraPose.distanceFromCenterPoint(); }
165 float pitch()
const {
return mCameraPose.pitchAngle(); }
172 float yaw()
const {
return mCameraPose.headingAngle(); }
175 QDomElement writeXml( QDomDocument &doc )
const;
177 void readXml(
const QDomElement &elem );
180 void zoom(
float factor );
182 void tiltUpAroundViewCenter(
float deltaPitch );
184 void rotateAroundViewCenter(
float deltaYaw );
186 void setCameraHeadingAngle(
float angle );
188 void moveView(
float tx,
float ty );
194 void walkView(
double tx,
double ty,
double tz );
202 void rotateCamera(
float diffPitch,
float diffYaw );
209 void rotateCameraAroundPivot(
float newPitch,
float newHeading,
const QVector3D &pivotPoint );
217 void zoomCameraAroundPivot(
const QVector3D &oldCameraPosition,
double zoomFactor,
const QVector3D &pivotPoint );
224 bool willHandleKeyEvent( QKeyEvent *event );
252 void globeMoveCenterPoint(
double latDiff,
double lonDiff );
259 void globeZoom(
float factor );
265 void globeUpdatePitchAngle(
float angleDiff );
271 void globeUpdateHeadingAngle(
float angleDiff );
278 void resetGlobe(
float distance,
double lat = 0,
double lon = 0 );
298 void depthBufferCaptured(
const QImage &depthImage );
306 void updateCameraFromPose();
307 void moveCameraPositionBy(
const QVector3D &posDiff );
309 QWindow *window()
const;
312 enum class MouseOperation
325 const QList<MouseOperation> mTranslateOrRotate = {
326 MouseOperation::Translation,
327 MouseOperation::RotationCamera,
328 MouseOperation::RotationCenter
332 bool isATranslationRotationSequence( MouseOperation newOperation )
const;
334 void setMouseParameters(
const MouseOperation &newOperation,
const QPoint &clickPoint = QPoint() );
367 void onPositionChanged( Qt3DInput::QMouseEvent *mouse );
368 void onWheel( Qt3DInput::QWheelEvent *wheel );
369 void onMousePressed( Qt3DInput::QMouseEvent *mouse );
370 void onMouseReleased( Qt3DInput::QMouseEvent *mouse );
371 void onKeyPressed( Qt3DInput::QKeyEvent *event );
372 void onKeyReleased( Qt3DInput::QKeyEvent *event );
373 void applyFlyModeKeyMovements();
376 void onKeyPressedFlyNavigation( Qt3DInput::QKeyEvent *event );
377 void onKeyPressedTerrainNavigation( Qt3DInput::QKeyEvent *event );
378 void onKeyPressedGlobeTerrainNavigation( Qt3DInput::QKeyEvent *event );
379 void onPositionChangedFlyNavigation( Qt3DInput::QMouseEvent *mouse );
380 void onPositionChangedTerrainNavigation( Qt3DInput::QMouseEvent *mouse );
381 void onPositionChangedGlobeTerrainNavigation( Qt3DInput::QMouseEvent *mouse );
383 void handleTerrainNavigationWheelZoom();
391 double sampleDepthBuffer(
int px,
int py );
394 double depthBufferNonVoidAverage();
398 bool screenPointToWorldPos( QPoint position,
double &depth, QVector3D &worldPosition );
408 Qt3DRender::QCamera *mCamera =
nullptr;
420 bool mDepthBufferIsReady =
false;
421 QImage mDepthBufferImage;
424 double mDepthBufferNonVoidAverage = -1;
426 std::unique_ptr<Qt3DRender::QCamera> mDepthBufferCamera;
428 std::unique_ptr<Qt3DRender::QCamera> mCameraBefore;
430 bool mRotationCenterCalculated =
false;
431 QVector3D mRotationCenter;
432 double mRotationDistanceFromCenter = 0;
433 float mRotationPitch = 0;
434 float mRotationYaw = 0;
436 bool mDragPointCalculated =
false;
437 QVector3D mDragPoint;
440 bool mZoomPointCalculated =
false;
441 QVector3D mZoomPoint;
447 Qt3DInput::QMouseHandler *mMouseHandler =
nullptr;
448 Qt3DInput::QKeyboardHandler *mKeyboardHandler =
nullptr;
449 bool mInputHandlersEnabled =
true;
452 double mCameraMovementSpeed = 5.0;
454 QSet<int> mDepressedKeys;
455 bool mCaptureFpsMouseMovements =
false;
456 bool mIgnoreNextMouseMove =
false;
457 QTimer *mFpsNavTimer =
nullptr;
459 double mCumulatedWheelY = 0;
461 MouseOperation mCurrentOperation = MouseOperation::None;
467 bool mCameraChanged =
false;
470 friend class TestQgs3DRendering;
471 friend class TestQgs3DCameraController;