75 Qt3DRender::QCamera *
camera()
const {
return mCamera; }
94 void setCameraMovementSpeed(
double movementSpeed );
109 void frameTriggered(
float dt );
112 void resetView(
float distance );
115 void setViewFromTop(
float worldX,
float worldY,
float distance,
float yaw = 0 );
126 void setLookingAtPoint(
const QgsVector3D &point,
float distance,
float pitch,
float yaw );
138 void setLookingAtMapPoint(
const QgsVector3D &point,
float distance,
float pitch,
float yaw );
144 void setCameraPose(
const QgsCameraPose &camPose,
bool force =
false );
157 float distance()
const {
return mCameraPose.distanceFromCenterPoint(); }
164 float pitch()
const {
return mCameraPose.pitchAngle(); }
171 float yaw()
const {
return mCameraPose.headingAngle(); }
174 QDomElement writeXml( QDomDocument &doc )
const;
176 void readXml(
const QDomElement &elem );
179 void zoom(
float factor );
181 void tiltUpAroundViewCenter(
float deltaPitch );
183 void rotateAroundViewCenter(
float deltaYaw );
185 void setCameraHeadingAngle(
float angle );
187 void moveView(
float tx,
float ty );
193 void walkView(
double tx,
double ty,
double tz );
201 void rotateCamera(
float diffPitch,
float diffYaw );
208 void rotateCameraAroundPivot(
float newPitch,
float newHeading,
const QVector3D &pivotPoint );
216 void zoomCameraAroundPivot(
const QVector3D &oldCameraPosition,
double zoomFactor,
const QVector3D &pivotPoint );
223 bool willHandleKeyEvent( QKeyEvent *event );
257 void depthBufferCaptured(
const QImage &depthImage );
265 void updateCameraFromPose();
266 void moveCameraPositionBy(
const QVector3D &posDiff );
268 QWindow *window()
const;
271 enum class MouseOperation
284 const QList<MouseOperation> mTranslateOrRotate = {
285 MouseOperation::Translation,
286 MouseOperation::RotationCamera,
287 MouseOperation::RotationCenter
291 bool isATranslationRotationSequence( MouseOperation newOperation )
const;
293 void setMouseParameters(
const MouseOperation &newOperation,
const QPoint &clickPoint = QPoint() );
326 void onPositionChanged( Qt3DInput::QMouseEvent *mouse );
327 void onWheel( Qt3DInput::QWheelEvent *wheel );
328 void onMousePressed( Qt3DInput::QMouseEvent *mouse );
329 void onMouseReleased( Qt3DInput::QMouseEvent *mouse );
330 void onKeyPressed( Qt3DInput::QKeyEvent *event );
331 void onKeyReleased( Qt3DInput::QKeyEvent *event );
332 void applyFlyModeKeyMovements();
335 void onKeyPressedFlyNavigation( Qt3DInput::QKeyEvent *event );
336 void onKeyPressedTerrainNavigation( Qt3DInput::QKeyEvent *event );
337 void onPositionChangedFlyNavigation( Qt3DInput::QMouseEvent *mouse );
338 void onPositionChangedTerrainNavigation( Qt3DInput::QMouseEvent *mouse );
340 void handleTerrainNavigationWheelZoom();
346 double sampleDepthBuffer(
int px,
int py );
350 bool screenPointToWorldPos( QPoint position, Qt3DRender::QCamera *cameraBefore,
double &depth, QVector3D &worldPosition );
357 Qt3DRender::QCamera *mCamera =
nullptr;
368 bool mDepthBufferIsReady =
false;
369 QImage mDepthBufferImage;
372 double mDepthBufferNonVoidAverage = -1;
374 std::unique_ptr<Qt3DRender::QCamera> mCameraBefore;
376 bool mRotationCenterCalculated =
false;
377 QVector3D mRotationCenter;
378 double mRotationDistanceFromCenter = 0;
379 double mRotationPitch = 0;
380 double mRotationYaw = 0;
382 bool mDragPointCalculated =
false;
383 QVector3D mDragPoint;
386 bool mZoomPointCalculated =
false;
387 QVector3D mZoomPoint;
389 Qt3DInput::QMouseHandler *mMouseHandler =
nullptr;
390 Qt3DInput::QKeyboardHandler *mKeyboardHandler =
nullptr;
391 bool mInputHandlersEnabled =
true;
394 double mCameraMovementSpeed = 5.0;
396 QSet<int> mDepressedKeys;
397 bool mCaptureFpsMouseMovements =
false;
398 bool mIgnoreNextMouseMove =
false;
399 QTimer *mFpsNavTimer =
nullptr;
401 double mCumulatedWheelY = 0;
403 MouseOperation mCurrentOperation = MouseOperation::None;
409 bool mCameraChanged =
false;
412 friend class TestQgs3DRendering;
413 friend class TestQgs3DCameraController;