Skip to content
Permalink
Browse files

Merge pull request #5715 from nyalldawson/3d_ctrl

[3d] Holding ctrl results in finer view adjustments
  • Loading branch information
nyalldawson committed Dec 14, 2017
2 parents 457abe7 + cf25b3e commit 5bac8a6e0d33ab4c2a9e80d63580a355cda6cd15
Showing with 13 additions and 1 deletion.
  1. +10 −1 src/3d/qgscameracontroller.cpp
  2. +3 −0 src/3d/qgscameracontroller.h
@@ -37,6 +37,8 @@ QgsCameraController::QgsCameraController( Qt3DCore::QNode *parent )
, mRightMouseButtonInput( new Qt3DInput::QActionInput() )
, mShiftAction( new Qt3DInput::QAction() )
, mShiftInput( new Qt3DInput::QActionInput() )
, mCtrlAction( new Qt3DInput::QAction() )
, mCtrlInput( new Qt3DInput::QActionInput() )
, mWheelAxis( new Qt3DInput::QAxis() )
, mMouseWheelInput( new Qt3DInput::QAnalogAxisInput() )
, mTxAxis( new Qt3DInput::QAxis() )
@@ -82,6 +84,11 @@ QgsCameraController::QgsCameraController( Qt3DCore::QNode *parent )
mShiftInput->setSourceDevice( mKeyboardDevice );
mShiftAction->addInput( mShiftInput );

// Keyboard ctrl
mCtrlInput->setButtons( QVector<int>() << Qt::Key_Control );
mCtrlInput->setSourceDevice( mKeyboardDevice );
mCtrlAction->addInput( mCtrlInput );

// Keyboard Pos Tx
mKeyboardTxPosInput->setButtons( QVector<int>() << Qt::Key_Right );
mKeyboardTxPosInput->setScale( 1.0f );
@@ -110,6 +117,7 @@ QgsCameraController::QgsCameraController( Qt3DCore::QNode *parent )
mLogicalDevice->addAction( mMiddleMouseButtonAction );
mLogicalDevice->addAction( mRightMouseButtonAction );
mLogicalDevice->addAction( mShiftAction );
mLogicalDevice->addAction( mCtrlAction );
mLogicalDevice->addAxis( mWheelAxis );
mLogicalDevice->addAxis( mTxAxis );
mLogicalDevice->addAxis( mTyAxis );
@@ -221,7 +229,8 @@ void QgsCameraController::frameTriggered( float dt )
int dy = mMousePos.y() - mLastMousePos.y();
mLastMousePos = mMousePos;

mCameraData.dist -= mCameraData.dist * mWheelAxis->value() * 10 * dt;
double scaling = ( mCtrlAction->isActive() ? 0.1 : 1.0 );
mCameraData.dist -= scaling * mCameraData.dist * mWheelAxis->value() * 10 * dt;

if ( mRightMouseButtonAction->isActive() )
{
@@ -158,6 +158,9 @@ class _3D_EXPORT QgsCameraController : public Qt3DCore::QEntity
Qt3DInput::QAction *mShiftAction = nullptr;
Qt3DInput::QActionInput *mShiftInput = nullptr;

Qt3DInput::QAction *mCtrlAction = nullptr;
Qt3DInput::QActionInput *mCtrlInput = nullptr;

Qt3DInput::QAxis *mWheelAxis = nullptr;
Qt3DInput::QAnalogAxisInput *mMouseWheelInput = nullptr;

0 comments on commit 5bac8a6

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