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 );
292 void depthBufferCaptured(
const QImage &depthImage );
300 void updateCameraFromPose();
301 void moveCameraPositionBy(
const QVector3D &posDiff );
303 QWindow *window()
const;
306 enum class MouseOperation
319 const QList<MouseOperation> mTranslateOrRotate = {
320 MouseOperation::Translation,
321 MouseOperation::RotationCamera,
322 MouseOperation::RotationCenter
326 bool isATranslationRotationSequence( MouseOperation newOperation )
const;
328 void setMouseParameters(
const MouseOperation &newOperation,
const QPoint &clickPoint = QPoint() );
361 void onPositionChanged( Qt3DInput::QMouseEvent *mouse );
362 void onWheel( Qt3DInput::QWheelEvent *wheel );
363 void onMousePressed( Qt3DInput::QMouseEvent *mouse );
364 void onMouseReleased( Qt3DInput::QMouseEvent *mouse );
365 void onKeyPressed( Qt3DInput::QKeyEvent *event );
366 void onKeyReleased( Qt3DInput::QKeyEvent *event );
367 void applyFlyModeKeyMovements();
370 void onKeyPressedFlyNavigation( Qt3DInput::QKeyEvent *event );
371 void onKeyPressedTerrainNavigation( Qt3DInput::QKeyEvent *event );
372 void onKeyPressedGlobeTerrainNavigation( Qt3DInput::QKeyEvent *event );
373 void onPositionChangedFlyNavigation( Qt3DInput::QMouseEvent *mouse );
374 void onPositionChangedTerrainNavigation( Qt3DInput::QMouseEvent *mouse );
375 void onPositionChangedGlobeTerrainNavigation( Qt3DInput::QMouseEvent *mouse );
377 void handleTerrainNavigationWheelZoom();
385 double sampleDepthBuffer(
int px,
int py );
388 double depthBufferNonVoidAverage();
392 bool screenPointToWorldPos( QPoint position, Qt3DRender::QCamera *cameraBefore,
double &depth, QVector3D &worldPosition );
402 Qt3DRender::QCamera *mCamera =
nullptr;
413 bool mDepthBufferIsReady =
false;
414 QImage mDepthBufferImage;
417 double mDepthBufferNonVoidAverage = -1;
419 std::unique_ptr<Qt3DRender::QCamera> mCameraBefore;
421 bool mRotationCenterCalculated =
false;
422 QVector3D mRotationCenter;
423 double mRotationDistanceFromCenter = 0;
424 double mRotationPitch = 0;
425 double mRotationYaw = 0;
427 bool mDragPointCalculated =
false;
428 QVector3D mDragPoint;
431 bool mZoomPointCalculated =
false;
432 QVector3D mZoomPoint;
438 Qt3DInput::QMouseHandler *mMouseHandler =
nullptr;
439 Qt3DInput::QKeyboardHandler *mKeyboardHandler =
nullptr;
440 bool mInputHandlersEnabled =
true;
443 double mCameraMovementSpeed = 5.0;
445 QSet<int> mDepressedKeys;
446 bool mCaptureFpsMouseMovements =
false;
447 bool mIgnoreNextMouseMove =
false;
448 QTimer *mFpsNavTimer =
nullptr;
450 double mCumulatedWheelY = 0;
452 MouseOperation mCurrentOperation = MouseOperation::None;
458 bool mCameraChanged =
false;
461 friend class TestQgs3DRendering;
462 friend class TestQgs3DCameraController;