Skip to content

Commit 9f3b3e5

Browse files
committedDec 30, 2017
[3d] Allow Shift+up/down/left/right keys to rotate/tilt camera
Just like user can drag map with mouse or move it with up/down/left/right keys, for consistency with Shift+drag we have now also support for arrow keys.
1 parent 63c1925 commit 9f3b3e5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed
 

‎src/3d/qgscameracontroller.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ void QgsCameraController::frameTriggered( float dt )
240240
float tx = mTxAxis->value() * dt * mCameraData.dist * 1.5;
241241
float ty = -mTyAxis->value() * dt * mCameraData.dist * 1.5;
242242

243-
if ( tx || ty )
243+
if ( !mShiftAction->isActive() && ( tx || ty ) )
244244
{
245245
// moving with keyboard - take into account yaw of camera
246246
float t = sqrt( tx * tx + ty * ty );
@@ -253,9 +253,16 @@ void QgsCameraController::frameTriggered( float dt )
253253

254254
if ( ( mLeftMouseButtonAction->isActive() && mShiftAction->isActive() ) || mMiddleMouseButtonAction->isActive() )
255255
{
256+
// rotate/tilt using mouse
256257
mCameraData.pitch += dy;
257258
mCameraData.yaw -= dx / 2;
258259
}
260+
else if ( mShiftAction->isActive() && ( mTxAxis->value() || mTyAxis->value() ) )
261+
{
262+
// rotate/tilt using keyboard
263+
mCameraData.pitch -= mTyAxis->value(); // down key = moving camera toward terrain
264+
mCameraData.yaw -= mTxAxis->value(); // right key = moving camera clockwise
265+
}
259266
else if ( mLeftMouseButtonAction->isActive() && !mShiftAction->isActive() )
260267
{
261268
// translation works as if one grabbed a point on the plane and dragged it

0 commit comments

Comments
 (0)
Please sign in to comment.