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, Qt3DRender::QCamera *cameraBefore,
double &depth, QVector3D &worldPosition );
408 Qt3DRender::QCamera *mCamera =
nullptr;
419 bool mDepthBufferIsReady =
false;
420 QImage mDepthBufferImage;
423 double mDepthBufferNonVoidAverage = -1;
425 std::unique_ptr<Qt3DRender::QCamera> mCameraBefore;
427 bool mRotationCenterCalculated =
false;
428 QVector3D mRotationCenter;
429 double mRotationDistanceFromCenter = 0;
430 float mRotationPitch = 0;
431 float mRotationYaw = 0;
433 bool mDragPointCalculated =
false;
434 QVector3D mDragPoint;
437 bool mZoomPointCalculated =
false;
438 QVector3D mZoomPoint;
444 Qt3DInput::QMouseHandler *mMouseHandler =
nullptr;
445 Qt3DInput::QKeyboardHandler *mKeyboardHandler =
nullptr;
446 bool mInputHandlersEnabled =
true;
449 double mCameraMovementSpeed = 5.0;
451 QSet<int> mDepressedKeys;
452 bool mCaptureFpsMouseMovements =
false;
453 bool mIgnoreNextMouseMove =
false;
454 QTimer *mFpsNavTimer =
nullptr;
456 double mCumulatedWheelY = 0;
458 MouseOperation mCurrentOperation = MouseOperation::None;
464 bool mCameraChanged =
false;
467 friend class TestQgs3DRendering;
468 friend class TestQgs3DCameraController;