Skip to content

Commit

Permalink
adding more movement controls and zoom via keyboard fix #298
Browse files Browse the repository at this point in the history
git-svn-id: file:///home/behr_mi/git/sumo_synched/trunk/sumo@18295 afbd958f-9f77-42d5-a016-97a22340ccf4
  • Loading branch information
namdre committed Apr 24, 2015
1 parent 423bd71 commit 0c0e217
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 7 deletions.
60 changes: 54 additions & 6 deletions src/utils/gui/windows/GUIDanielPerspectiveChanger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ GUIDanielPerspectiveChanger::GUIDanielPerspectiveChanger(
myRotation(0),
myMouseButtonState(MOUSEBTN_NONE),
myMoveOnClick(false),
myDragDelay(0) {}
myDragDelay(0),
myZoomBase(viewPort.getCenter())
{}


GUIDanielPerspectiveChanger::~GUIDanielPerspectiveChanger() {}
Expand Down Expand Up @@ -255,25 +257,71 @@ GUIDanielPerspectiveChanger::changeCanvassLeft(int change) {
long
GUIDanielPerspectiveChanger::onKeyPress(void* data) {
FXEvent* e = (FXEvent*) data;
SUMOReal zoomDiff = 0.1;
SUMOReal moveX = 0;
SUMOReal moveY = 0;
SUMOReal moveFactor = 1;
bool pageVertical = true;
if (e->state & CONTROLMASK) {
zoomDiff /= 2;
moveFactor /= 10;
} else if (e->state & SHIFTMASK) {
pageVertical = false;
zoomDiff *= 2;
}
switch(e->code) {
case FX::KEY_Left:
move( -myViewPort.getWidth()/10, 0);
moveX = -1;
moveFactor /= 10;
break;
case FX::KEY_Right:
move( myViewPort.getWidth()/10, 0);
moveX = 1;
moveFactor /= 10;
break;
case FX::KEY_Up:
move(0, -myViewPort.getHeight()/10);
moveY = -1;
moveFactor /= 10;
break;
case FX::KEY_Down:
move(0, myViewPort.getHeight()/10);
moveY = 1;
moveFactor /= 10;
break;
case FX::KEY_Page_Up:
if (pageVertical) {
moveY = -1;
} else {
moveX = -1;
}
break;
case FX::KEY_Page_Down:
if (pageVertical) {
moveY = 1;
} else {
moveX = 1;
}
break;
case FX::KEY_plus:
case FX::KEY_KP_Add:
myZoomBase = myCallback.getPositionInformation();
zoom(1.0 + zoomDiff);
myCallback.updateToolTip();
return 1;
case FX::KEY_minus:
case FX::KEY_KP_Subtract:
zoomDiff = -zoomDiff;
myZoomBase = myCallback.getPositionInformation();
zoom(1.0 + zoomDiff);
myCallback.updateToolTip();
return 1;
case FX::KEY_c:
myCallback.recenterView();
break;
myCallback.update();
return 1;
default:
return 0;
}
myViewPort.moveby(moveX * moveFactor * myViewPort.getWidth(),
-moveY * moveFactor * myViewPort.getHeight());
myCallback.update();
return 1;
}
Expand Down
5 changes: 4 additions & 1 deletion src/utils/gui/windows/GUISUMOAbstractView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ GUISUMOAbstractView::GUISUMOAbstractView(FXComposite* p,
myUseToolTips(false),
myAmInitialised(false),
myViewportChooser(0),
myVisualizationChanger(0) {
myVisualizationChanger(0),
myWindowCursorPositionX(getWidth()/2),
myWindowCursorPositionY(getHeight()/2)
{
setTarget(this);
enable();
flags |= FLAG_ENABLED;
Expand Down

0 comments on commit 0c0e217

Please sign in to comment.