77 Qt3DRender::QCamera *
camera()
const {
return mCamera; }
96 void setCameraMovementSpeed(
double movementSpeed );
111 void frameTriggered(
float dt );
114 void resetView(
float distance );
117 void setViewFromTop(
float worldX,
float worldY,
float distance,
float yaw = 0 );
128 void setLookingAtPoint(
const QgsVector3D &point,
float distance,
float pitch,
float yaw );
140 void setLookingAtMapPoint(
const QgsVector3D &point,
float distance,
float pitch,
float yaw );
146 void setCameraPose(
const QgsCameraPose &camPose,
bool force =
false );
159 float distance()
const {
return mCameraPose.distanceFromCenterPoint(); }
166 float pitch()
const {
return mCameraPose.pitchAngle(); }
173 float yaw()
const {
return mCameraPose.headingAngle(); }
176 QDomElement writeXml( QDomDocument &doc )
const;
178 void readXml(
const QDomElement &elem,
QgsVector3D savedOrigin );
181 void zoom(
float factor );
183 void tiltUpAroundViewCenter(
float deltaPitch );
185 void rotateAroundViewCenter(
float deltaYaw );
187 void setCameraHeadingAngle(
float angle );
189 void moveView(
float tx,
float ty );
195 void walkView(
double tx,
double ty,
double tz );
203 void rotateCamera(
float diffPitch,
float diffYaw );
210 void rotateCameraAroundPivot(
float newPitch,
float newHeading,
const QVector3D &pivotPoint );
219 Q_DECL_DEPRECATED
void zoomCameraAroundPivot(
const QVector3D &oldCameraPosition,
double zoomFactor,
const QVector3D &pivotPoint )
SIP_DEPRECATED;
227 void zoomCameraAroundPivot(
const QVector3D &oldCameraPosition,
double oldDistanceFromCenterPoint,
double zoomFactor,
const QVector3D &pivotPoint );
233 bool keyboardEventFilter( QKeyEvent *event );
261 void globeMoveCenterPoint(
double latDiff,
double lonDiff );
268 void globeZoom(
float factor );
274 void globeUpdatePitchAngle(
float angleDiff );
280 void globeUpdateHeadingAngle(
float angleDiff );
287 void resetGlobe(
float distance,
double lat = 0,
double lon = 0 );
330 void depthBufferCaptured(
const QImage &depthImage );
336 void moveCenterPoint(
const QVector3D &posDiff );
344 void updateCameraFromPose();
346 QWindow *window()
const;
349 enum class MouseOperation
362 const QList<MouseOperation> mTranslateOrRotate = {
363 MouseOperation::Translation,
364 MouseOperation::RotationCamera,
365 MouseOperation::RotationCenter
369 bool isATranslationRotationSequence( MouseOperation newOperation )
const;
371 void setMouseParameters(
const MouseOperation &newOperation,
const QPoint &clickPoint = QPoint() );
378 void rotateToRespectingTerrain(
float pitch,
float yaw );
411 void onPositionChanged( Qt3DInput::QMouseEvent *mouse );
412 void onWheel( Qt3DInput::QWheelEvent *wheel );
413 void onMousePressed( Qt3DInput::QMouseEvent *mouse );
414 void onMouseReleased( Qt3DInput::QMouseEvent *mouse );
415 void applyFlyModeKeyMovements();
419 bool onKeyPressedFlyNavigation( QKeyEvent *event );
420 bool onKeyPressedTerrainNavigation( QKeyEvent *event );
421 bool onKeyPressedGlobeTerrainNavigation( QKeyEvent *event );
422 void onPositionChangedFlyNavigation( Qt3DInput::QMouseEvent *mouse );
423 void onPositionChangedTerrainNavigation( Qt3DInput::QMouseEvent *mouse );
424 void onPositionChangedGlobeTerrainNavigation( Qt3DInput::QMouseEvent *mouse );
426 void handleTerrainNavigationWheelZoom();
434 double sampleDepthBuffer(
int px,
int py );
437 double depthBufferNonVoidAverage();
441 bool screenPointToWorldPos( QPoint position,
double &depth, QVector3D &worldPosition );
451 Qt3DRender::QCamera *mCamera =
nullptr;
463 bool mDepthBufferIsReady =
false;
464 QImage mDepthBufferImage;
467 double mDepthBufferNonVoidAverage = -1;
469 std::unique_ptr<Qt3DRender::QCamera> mDepthBufferCamera;
471 std::unique_ptr<Qt3DRender::QCamera> mCameraBefore;
473 bool mRotationCenterCalculated =
false;
474 QVector3D mRotationCenter;
475 double mRotationDistanceFromCenter = 0;
476 float mRotationPitch = 0;
477 float mRotationYaw = 0;
479 bool mDragPointCalculated =
false;
480 QVector3D mDragPoint;
481 double mDragDepth = 0;
483 bool mZoomPointCalculated =
false;
484 QVector3D mZoomPoint;
490 Qt3DInput::QMouseHandler *mMouseHandler =
nullptr;
491 Qt3DInput::QKeyboardHandler *mKeyboardHandler =
nullptr;
492 bool mInputHandlersEnabled =
true;
495 double mCameraMovementSpeed = 5.0;
497 QSet<int> mDepressedKeys;
498 bool mCaptureFpsMouseMovements =
false;
499 bool mIgnoreNextMouseMove =
false;
500 QTimer *mFpsNavTimer =
nullptr;
502 double mCumulatedWheelY = 0;
504 MouseOperation mCurrentOperation = MouseOperation::None;
510 bool mCameraChanged =
false;