Skip to content
Permalink
Browse files

rename navigation modes

  • Loading branch information
NEDJIMAbelgacem authored and nyalldawson committed Jan 13, 2021
1 parent 0318ff7 commit b3d2059bd71c357162801a6728a2390262661273
@@ -103,10 +103,10 @@ void Qgs3DMapSettings::readXml( const QDomElement &elem, const QgsReadWriteConte
mFieldOfView = elemCamera.attribute( QStringLiteral( "field-of-view" ), QStringLiteral( "45" ) ).toFloat();
mProjectionType = static_cast< Qt3DRender::QCameraLens::ProjectionType >( elemCamera.attribute( QStringLiteral( "projection-type" ), QStringLiteral( "1" ) ).toInt() );
QString cameraNavigationMode = elemCamera.attribute( QStringLiteral( "camera-navigation-mode" ), QStringLiteral( "basic-navigation" ) );
if ( cameraNavigationMode == QStringLiteral( "basic-navigation" ) )
mCameraNavigationMode = QgsCameraController::NavigationMode::BasicNavigation;
else if ( cameraNavigationMode == QStringLiteral( "fps-navigation" ) )
mCameraNavigationMode = QgsCameraController::NavigationMode::FPSNavigation;
if ( cameraNavigationMode == QStringLiteral( "terrain-based-navigation" ) )
mCameraNavigationMode = QgsCameraController::NavigationMode::TerrainBasedNavigation;
else if ( cameraNavigationMode == QStringLiteral( "fly-navigation" ) )
mCameraNavigationMode = QgsCameraController::NavigationMode::FlyNavigation;
mCameraMovementSpeed = elemCamera.attribute( QStringLiteral( "camera-movement-speed" ), QStringLiteral( "5.0" ) ).toDouble();
}

@@ -303,11 +303,11 @@ QDomElement Qgs3DMapSettings::writeXml( QDomDocument &doc, const QgsReadWriteCon
elemCamera.setAttribute( QStringLiteral( "projection-type" ), static_cast< int >( mProjectionType ) );
switch ( mCameraNavigationMode )
{
case QgsCameraController::BasicNavigation:
elemCamera.setAttribute( QStringLiteral( "camera-navigation-mode" ), QStringLiteral( "basic-navigation" ) );
case QgsCameraController::TerrainBasedNavigation:
elemCamera.setAttribute( QStringLiteral( "camera-navigation-mode" ), QStringLiteral( "terrain-based-navigation" ) );
break;
case QgsCameraController::FPSNavigation:
elemCamera.setAttribute( QStringLiteral( "camera-navigation-mode" ), QStringLiteral( "fps-navigation" ) );
case QgsCameraController::FlyNavigation:
elemCamera.setAttribute( QStringLiteral( "camera-navigation-mode" ), QStringLiteral( "fly-navigation" ) );
break;
}
elemCamera.setAttribute( QStringLiteral( "camera-movement-speed" ), mCameraMovementSpeed );
@@ -763,7 +763,7 @@ class _3D_EXPORT Qgs3DMapSettings : public QObject, public QgsTemporalRangeObjec
QList<QgsDirectionalLightSettings> mDirectionalLights; //!< List of directional lights defined for the scene
float mFieldOfView = 45.0f; //<! Camera lens field of view value
Qt3DRender::QCameraLens::ProjectionType mProjectionType = Qt3DRender::QCameraLens::PerspectiveProjection; //<! Camera lens projection type
QgsCameraController::NavigationMode mCameraNavigationMode = QgsCameraController::NavigationMode::BasicNavigation;
QgsCameraController::NavigationMode mCameraNavigationMode = QgsCameraController::NavigationMode::TerrainBasedNavigation;
double mCameraMovementSpeed = 5.0;
QList<QgsMapLayerRef> mLayers; //!< Layers to be rendered
QList<QgsMapLayerRef> mTerrainLayers; //!< Terrain layers to be rendered
@@ -319,9 +319,9 @@ void QgsCameraController::moveCameraPositionBy( const QVector3D &posDiff )

void QgsCameraController::onPositionChanged( Qt3DInput::QMouseEvent *mouse )
{
if ( mCameraNavigationMode == FPSNavigation )
if ( mCameraNavigationMode == NavigationMode::FlyNavigation )
{
onPositionChangedFPSNavigation( mouse );
onPositionChangedFlyNavigation( mouse );
return;
}
int dx = mouse->x() - mMousePos.x();
@@ -375,7 +375,7 @@ void QgsCameraController::onPositionChanged( Qt3DInput::QMouseEvent *mouse )
mMousePos = QPoint( mouse->x(), mouse->y() );
}

void QgsCameraController::onPositionChangedFPSNavigation( Qt3DInput::QMouseEvent *mouse )
void QgsCameraController::onPositionChangedFlyNavigation( Qt3DInput::QMouseEvent *mouse )
{
if ( !mMousePressed )
return;
@@ -425,9 +425,9 @@ void QgsCameraController::onMouseReleased( Qt3DInput::QMouseEvent *mouse )

void QgsCameraController::onKeyPressed( Qt3DInput::QKeyEvent *event )
{
if ( mCameraNavigationMode == NavigationMode::FPSNavigation )
if ( mCameraNavigationMode == NavigationMode::FlyNavigation )
{
onKeyPressedFPSNavigation( event );
onKeyPressedFlyNavigation( event );
return;
}

@@ -490,7 +490,7 @@ void QgsCameraController::onKeyPressed( Qt3DInput::QKeyEvent *event )
}
}

void QgsCameraController::onKeyPressedFPSNavigation( Qt3DInput::QKeyEvent *event )
void QgsCameraController::onKeyPressedFlyNavigation( Qt3DInput::QKeyEvent *event )
{
QVector3D cameraUp = mCamera->upVector().normalized();
QVector3D cameraFront = ( QVector3D( mCameraPose.centerPoint().x(), mCameraPose.centerPoint().y(), mCameraPose.centerPoint().z() ) - mCamera->position() ).normalized();
@@ -62,10 +62,11 @@ class _3D_EXPORT QgsCameraController : public Qt3DCore::QEntity
Q_PROPERTY( Qt3DRender::QCamera *camera READ camera WRITE setCamera NOTIFY cameraChanged )
Q_PROPERTY( QRect viewport READ viewport WRITE setViewport NOTIFY viewportChanged )
public:
//! The navigation mode used by the camera
enum NavigationMode
{
BasicNavigation,
FPSNavigation
TerrainBasedNavigation, //! The default navigation based on the terrain
FlyNavigation //! uses WASD keys or arrows to navigate in flying manner
};

public:
@@ -201,8 +202,8 @@ class _3D_EXPORT QgsCameraController : public Qt3DCore::QEntity
void onPickerMousePressed( Qt3DRender::QPickEvent *pick );

private:
void onKeyPressedFPSNavigation( Qt3DInput::QKeyEvent *mouse );
void onPositionChangedFPSNavigation( Qt3DInput::QMouseEvent *mouse );
void onKeyPressedFlyNavigation( Qt3DInput::QKeyEvent *mouse );
void onPositionChangedFlyNavigation( Qt3DInput::QMouseEvent *mouse );

private:
//! Camera that is being controlled
@@ -227,7 +228,7 @@ class _3D_EXPORT QgsCameraController : public Qt3DCore::QEntity

Qt3DInput::QMouseHandler *mMouseHandler = nullptr;
Qt3DInput::QKeyboardHandler *mKeyboardHandler = nullptr;
NavigationMode mCameraNavigationMode = NavigationMode::BasicNavigation;
NavigationMode mCameraNavigationMode = NavigationMode::TerrainBasedNavigation;
double mCameraMovementSpeed = 5.0;
};

@@ -645,12 +645,12 @@
<widget class="QComboBox" name="mCameraNavigationMode">
<item>
<property name="text">
<string>Basic navigation</string>
<string>Terrain Based Navigation</string>
</property>
</item>
<item>
<property name="text">
<string>Fly navigation</string>
<string>Fly Navigation</string>
</property>
</item>
</widget>

0 comments on commit b3d2059

Please sign in to comment.
You can’t perform that action at this time.