Skip to content

Commit

Permalink
Simpler code, use direct connection to camera signal
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 16, 2021
1 parent 20aea8b commit e2c98e1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/3d/qgs3dmapscene.cpp
Expand Up @@ -196,7 +196,6 @@ Qgs3DMapScene::Qgs3DMapScene( const Qgs3DMapSettings &map, QgsAbstract3DEngine *

connect( mCameraController, &QgsCameraController::cameraChanged, this, &Qgs3DMapScene::onCameraChanged );
connect( mCameraController, &QgsCameraController::viewportChanged, this, &Qgs3DMapScene::onCameraChanged );
connect( mCameraController, &QgsCameraController::navigationModeHotKeyPressed, this, &Qgs3DMapScene::navigationModeHotKeyPressed );

#if 0
// experiments with loading of existing 3D models.
Expand Down
2 changes: 0 additions & 2 deletions src/3d/qgs3dmapscene.h
Expand Up @@ -139,8 +139,6 @@ class _3D_EXPORT Qgs3DMapScene : public Qt3DCore::QEntity
void fpsCountChanged( float fpsCount );
//! Emitted when the FPS counter is activated or deactivated
void fpsCounterEnabledChanged( bool fpsCounterEnabled );
//! Emitted when the navigation mode is changed using the hotkey ctrl + ~
void navigationModeHotKeyPressed( QgsCameraController::NavigationMode mode );

public slots:
//! Updates the temporale entities
Expand Down
14 changes: 8 additions & 6 deletions src/3d/qgscameracontroller.h
Expand Up @@ -96,12 +96,6 @@ class _3D_EXPORT QgsCameraController : public Qt3DCore::QEntity
*/
QgsCameraController::NavigationMode cameraNavigationMode() const { return mCameraNavigationMode; }

/**
* Sets the navigation mode used by the camera controller.
* \since QGIS 3.18
*/
void setCameraNavigationMode( QgsCameraController::NavigationMode navigationMode );

/**
* Returns the camera movement speed
* \since QGIS 3.18
Expand Down Expand Up @@ -205,6 +199,14 @@ class _3D_EXPORT QgsCameraController : public Qt3DCore::QEntity
//! Move the map by \a tx and \a ty
void moveView( float tx, float ty );

public slots:

/**
* Sets the navigation mode used by the camera controller.
* \since QGIS 3.18
*/
void setCameraNavigationMode( QgsCameraController::NavigationMode navigationMode );

private:
void rotateCamera( float diffPitch, float diffYaw );
void updateCameraFromPose( bool centerPointChanged = false );
Expand Down
2 changes: 1 addition & 1 deletion src/app/3d/qgs3dmapcanvas.cpp
Expand Up @@ -102,7 +102,6 @@ void Qgs3DMapCanvas::setMap( Qgs3DMapSettings *map )
mScene = newScene;
connect( mScene, &Qgs3DMapScene::fpsCountChanged, this, &Qgs3DMapCanvas::fpsCountChanged );
connect( mScene, &Qgs3DMapScene::fpsCounterEnabledChanged, this, &Qgs3DMapCanvas::fpsCounterEnabledChanged );
connect( mScene, &Qgs3DMapScene::navigationModeHotKeyPressed, this, &Qgs3DMapCanvas::onNavigationModeHotKeyPressed );

delete mMap;
mMap = map;
Expand All @@ -116,6 +115,7 @@ void Qgs3DMapCanvas::setMap( Qgs3DMapSettings *map )
QCursor::setPos( mapToGlobal( point ) );
} );
connect( cameraController(), &QgsCameraController::cameraMovementSpeedChanged, mMap, &Qgs3DMapSettings::setCameraMovementSpeed );
connect( cameraController(), &QgsCameraController::navigationModeHotKeyPressed, this, &Qgs3DMapCanvas::onNavigationModeHotKeyPressed );

emit mapSettingsChanged();
}
Expand Down

0 comments on commit e2c98e1

Please sign in to comment.