From 460544455d9f449ce80abdab22e0244698444158 Mon Sep 17 00:00:00 2001 From: Ian MacArthur Date: Fri, 6 Jun 2014 21:46:42 +0000 Subject: Another stab at STR #3090. Now, instead of just ignoring the scrollwheel events, I try to make the scene zoom in/out in response to the wheel instead. Seems to be working; not sure I have the zoom sensitivity set to a sensible avlue, though! git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10185 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- test/fracviewer.cxx | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/test/fracviewer.cxx b/test/fracviewer.cxx index e19fd568c..ca1c274ed 100644 --- a/test/fracviewer.cxx +++ b/test/fracviewer.cxx @@ -331,11 +331,37 @@ void agvSwitchMoveMode(int move) void agvHandleButton(int button, int state, int x, int y) { - if (button > GLUT_RIGHT_BUTTON)return; - if (state == GLUT_DOWN && downb == -1) { + // deal with mouse wheel events, that fltk sends as buttons 3 or 4 + //if (button > GLUT_RIGHT_BUTTON)return; + if ((state == GLUT_DOWN) && ((button == 3) || (button == 4))) { + // attempt to process scrollwheel as zoom in/out + float deltay = 0.25; + if (button == 3) { + deltay = (-0.25); + } + downb = -1; + downDist = EyeDist; + downEx = Ex; + downEy = Ey; + downEz = Ez; + downEyeMove = EyeMove; + EyeMove = 0; + + EyeDist = downDist + deltay; + Ex = downEx - E_SENS*deltay*sin(TORAD(EyeAz))*cos(TORAD(EyeEl)); + Ey = downEy - E_SENS*deltay*sin(TORAD(EyeEl)); + Ez = downEz + E_SENS*deltay*cos(TORAD(EyeAz))*cos(TORAD(EyeEl)); + + EyeMove = downEyeMove; + glutPostRedisplay(); + return; + } + else if (button > GLUT_RIGHT_BUTTON)return; // ignore any other button... + + if (state == GLUT_DOWN && downb == -1) { lastx = downx = x; lasty = downy = y; - downb = button; + downb = button; switch (button) { case GLUT_LEFT_BUTTON: -- cgit v1.2.3