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 );
223 bool keyboardEventFilter( QKeyEvent *event );
251 void globeMoveCenterPoint(
double latDiff,
double lonDiff );
258 void globeZoom(
float factor );
264 void globeUpdatePitchAngle(
float angleDiff );
270 void globeUpdateHeadingAngle(
float angleDiff );
277 void resetGlobe(
float distance,
double lat = 0,
double lon = 0 );
313 void depthBufferCaptured(
const QImage &depthImage );
321 void updateCameraFromPose();
322 void moveCameraPositionBy(
const QVector3D &posDiff );
324 QWindow *window()
const;
327 enum class MouseOperation
340 const QList<MouseOperation> mTranslateOrRotate = {
341 MouseOperation::Translation,
342 MouseOperation::RotationCamera,
343 MouseOperation::RotationCenter
347 bool isATranslationRotationSequence( MouseOperation newOperation )
const;
349 void setMouseParameters(
const MouseOperation &newOperation,
const QPoint &clickPoint = QPoint() );
356 void rotateToRespectingTerrain(
float pitch,
float yaw );
389 void onPositionChanged( Qt3DInput::QMouseEvent *mouse );
390 void onWheel( Qt3DInput::QWheelEvent *wheel );
391 void onMousePressed( Qt3DInput::QMouseEvent *mouse );
392 void onMouseReleased( Qt3DInput::QMouseEvent *mouse );
393 void applyFlyModeKeyMovements();
397 bool onKeyPressedFlyNavigation( QKeyEvent *event );
398 bool onKeyPressedTerrainNavigation( QKeyEvent *event );
399 bool onKeyPressedGlobeTerrainNavigation( QKeyEvent *event );
400 void onPositionChangedFlyNavigation( Qt3DInput::QMouseEvent *mouse );
401 void onPositionChangedTerrainNavigation( Qt3DInput::QMouseEvent *mouse );
402 void onPositionChangedGlobeTerrainNavigation( Qt3DInput::QMouseEvent *mouse );
404 void handleTerrainNavigationWheelZoom();
412 double sampleDepthBuffer(
int px,
int py );
415 double depthBufferNonVoidAverage();
419 bool screenPointToWorldPos( QPoint position,
double &depth, QVector3D &worldPosition );
429 Qt3DRender::QCamera *mCamera =
nullptr;
441 bool mDepthBufferIsReady =
false;
442 QImage mDepthBufferImage;
445 double mDepthBufferNonVoidAverage = -1;
447 std::unique_ptr<Qt3DRender::QCamera> mDepthBufferCamera;
449 std::unique_ptr<Qt3DRender::QCamera> mCameraBefore;
451 bool mRotationCenterCalculated =
false;
452 QVector3D mRotationCenter;
453 double mRotationDistanceFromCenter = 0;
454 float mRotationPitch = 0;
455 float mRotationYaw = 0;
457 bool mDragPointCalculated =
false;
458 QVector3D mDragPoint;
461 bool mZoomPointCalculated =
false;
462 QVector3D mZoomPoint;
468 Qt3DInput::QMouseHandler *mMouseHandler =
nullptr;
469 Qt3DInput::QKeyboardHandler *mKeyboardHandler =
nullptr;
470 bool mInputHandlersEnabled =
true;
473 double mCameraMovementSpeed = 5.0;
475 QSet<int> mDepressedKeys;
476 bool mCaptureFpsMouseMovements =
false;
477 bool mIgnoreNextMouseMove =
false;
478 QTimer *mFpsNavTimer =
nullptr;
480 double mCumulatedWheelY = 0;
482 MouseOperation mCurrentOperation = MouseOperation::None;
488 bool mCameraChanged =
false;
491 friend class TestQgs3DRendering;
492 friend class TestQgs3DCameraController;