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 );
240 void depthBufferCaptured(
const QImage &depthImage );
248 void updateCameraFromPose();
249 void moveCameraPositionBy(
const QVector3D &posDiff );
251 QWindow *window()
const;
254 enum class MouseOperation
267 const QList<MouseOperation> mTranslateOrRotate = {
268 MouseOperation::Translation,
269 MouseOperation::RotationCamera,
270 MouseOperation::RotationCenter
274 bool isATranslationRotationSequence( MouseOperation newOperation )
const;
276 void setMouseParameters(
const MouseOperation &newOperation,
const QPoint &clickPoint = QPoint() );
309 void onPositionChanged( Qt3DInput::QMouseEvent *mouse );
310 void onWheel( Qt3DInput::QWheelEvent *wheel );
311 void onMousePressed( Qt3DInput::QMouseEvent *mouse );
312 void onMouseReleased( Qt3DInput::QMouseEvent *mouse );
313 void onKeyPressed( Qt3DInput::QKeyEvent *event );
314 void onKeyReleased( Qt3DInput::QKeyEvent *event );
315 void applyFlyModeKeyMovements();
318 void onKeyPressedFlyNavigation( Qt3DInput::QKeyEvent *event );
319 void onKeyPressedTerrainNavigation( Qt3DInput::QKeyEvent *event );
320 void onPositionChangedFlyNavigation( Qt3DInput::QMouseEvent *mouse );
321 void onPositionChangedTerrainNavigation( Qt3DInput::QMouseEvent *mouse );
323 void handleTerrainNavigationWheelZoom();
329 double sampleDepthBuffer(
int px,
int py );
333 bool screenPointToWorldPos( QPoint position, Qt3DRender::QCamera *cameraBefore,
double &depth, QVector3D &worldPosition );
340 Qt3DRender::QCamera *mCamera =
nullptr;
351 bool mDepthBufferIsReady =
false;
352 QImage mDepthBufferImage;
355 double mDepthBufferNonVoidAverage = -1;
357 std::unique_ptr<Qt3DRender::QCamera> mCameraBefore;
359 bool mRotationCenterCalculated =
false;
360 QVector3D mRotationCenter;
361 double mRotationDistanceFromCenter = 0;
362 double mRotationPitch = 0;
363 double mRotationYaw = 0;
365 bool mDragPointCalculated =
false;
366 QVector3D mDragPoint;
369 bool mZoomPointCalculated =
false;
370 QVector3D mZoomPoint;
372 Qt3DInput::QMouseHandler *mMouseHandler =
nullptr;
373 Qt3DInput::QKeyboardHandler *mKeyboardHandler =
nullptr;
374 bool mInputHandlersEnabled =
true;
377 double mCameraMovementSpeed = 5.0;
379 QSet<int> mDepressedKeys;
380 bool mCaptureFpsMouseMovements =
false;
381 bool mIgnoreNextMouseMove =
false;
382 QTimer *mFpsNavTimer =
nullptr;
384 double mCumulatedWheelY = 0;
386 MouseOperation mCurrentOperation = MouseOperation::None;
392 bool mCameraChanged =
false;
395 friend class TestQgs3DRendering;
396 friend class TestQgs3DCameraController;