Skip to content

Commit

Permalink
Implemented movement by arrow keys in 2D mode
Browse files Browse the repository at this point in the history
  • Loading branch information
smistad committed Oct 24, 2022
1 parent 5fe1088 commit 5c72bd8
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions source/FAST/Visualization/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,38 @@ void View::keyPressEvent(QKeyEvent *event) {
case Qt::Key_R:
recalculateCamera();
break;
case Qt::Key_Left:
if(mIsIn2DMode) {
// Move 10% of width
float actualMovementX = width()*0.1 * ((mRight - mLeft) / width());
mCameraPosition[0] += actualMovementX;
m3DViewingTransformation.pretranslate(Vector3f(actualMovementX, 0, 0));
}
break;
case Qt::Key_Right:
if(mIsIn2DMode) {
// Move 10% of width
float actualMovementX = width()*0.1 * ((mRight - mLeft) / width());
mCameraPosition[0] -= actualMovementX;
m3DViewingTransformation.pretranslate(Vector3f(-actualMovementX, 0, 0));
}
break;
case Qt::Key_Down:
if(mIsIn2DMode) {
// Move 10% of height
float actualMovementY = height()*0.1 * ((mRight - mLeft) / height());
mCameraPosition[1] = actualMovementY;
m3DViewingTransformation.pretranslate(Vector3f(0, actualMovementY, 0));
}
break;
case Qt::Key_Up:
if(mIsIn2DMode) {
// Move 10% of height
float actualMovementY = height()*0.1 * ((mRight - mLeft) / height());
mCameraPosition[1] = -actualMovementY;
m3DViewingTransformation.pretranslate(Vector3f(0, -actualMovementY, 0));
}
break;
}
}

Expand Down

0 comments on commit 5c72bd8

Please sign in to comment.