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 );
147 float distance()
const {
return mCameraPose.distanceFromCenterPoint(); }
154 float pitch()
const {
return mCameraPose.pitchAngle(); }
161 float yaw()
const {
return mCameraPose.headingAngle(); }
164 QDomElement writeXml( QDomDocument &doc )
const;
166 void readXml(
const QDomElement &elem );
169 void zoom(
float factor );
171 void tiltUpAroundViewCenter(
float deltaPitch );
173 void rotateAroundViewCenter(
float deltaYaw );
175 void setCameraHeadingAngle(
float angle );
177 void moveView(
float tx,
float ty );
183 void walkView(
double tx,
double ty,
double tz );
191 void rotateCamera(
float diffPitch,
float diffYaw );
198 bool willHandleKeyEvent( QKeyEvent *event );
212 void depthBufferCaptured(
const QImage &depthImage );
220 void updateCameraFromPose();
221 void moveCameraPositionBy(
const QVector3D &posDiff );
223 QWindow *window()
const;
226 enum class MouseOperation
239 const QList<MouseOperation> mTranslateOrRotate =
241 MouseOperation::Translation,
242 MouseOperation::RotationCamera,
243 MouseOperation::RotationCenter
247 bool isATranslationRotationSequence( MouseOperation newOperation )
const;
249 void setMouseParameters(
const MouseOperation &newOperation,
const QPoint &clickPoint = QPoint() );
282 void onPositionChanged( Qt3DInput::QMouseEvent *mouse );
283 void onWheel( Qt3DInput::QWheelEvent *wheel );
284 void onMousePressed( Qt3DInput::QMouseEvent *mouse );
285 void onMouseReleased( Qt3DInput::QMouseEvent *mouse );
286 void onKeyPressed( Qt3DInput::QKeyEvent *event );
287 void onKeyReleased( Qt3DInput::QKeyEvent *event );
288 void applyFlyModeKeyMovements();
291 void onKeyPressedFlyNavigation( Qt3DInput::QKeyEvent *event );
292 void onKeyPressedTerrainNavigation( Qt3DInput::QKeyEvent *event );
293 void onPositionChangedFlyNavigation( Qt3DInput::QMouseEvent *mouse );
294 void onPositionChangedTerrainNavigation( Qt3DInput::QMouseEvent *mouse );
296 void handleTerrainNavigationWheelZoom();
302 double sampleDepthBuffer(
const QImage &buffer,
int px,
int py );
306 bool screenPointToWorldPos( QPoint position, Qt3DRender::QCamera *cameraBefore,
double &depth, QVector3D &worldPosition );
313 Qt3DRender::QCamera *mCamera =
nullptr;
324 bool mDepthBufferIsReady =
false;
325 QImage mDepthBufferImage;
327 std::unique_ptr< Qt3DRender::QCamera > mCameraBefore;
329 bool mRotationCenterCalculated =
false;
330 QVector3D mRotationCenter;
331 double mRotationDistanceFromCenter;
332 double mRotationPitch = 0;
333 double mRotationYaw = 0;
335 bool mDragPointCalculated =
false;
336 QVector3D mDragPoint;
339 bool mZoomPointCalculated =
false;
340 QVector3D mZoomPoint;
342 Qt3DInput::QMouseHandler *mMouseHandler =
nullptr;
343 Qt3DInput::QKeyboardHandler *mKeyboardHandler =
nullptr;
346 double mCameraMovementSpeed = 5.0;
348 QSet< int > mDepressedKeys;
349 bool mCaptureFpsMouseMovements =
false;
350 bool mIgnoreNextMouseMove =
false;
351 QTimer *mFpsNavTimer =
nullptr;
353 double mCumulatedWheelY = 0;
355 MouseOperation mCurrentOperation = MouseOperation::None;
358 friend class TestQgs3DRendering;
359 friend class TestQgs3DCameraController;