#589 zoom by mouse wheel and hotkeys

None
closed-accepted
nobody
None
5
2014-08-05
2012-06-23
Petr Mikulik
No

I have revised zooming by mouse wheel and added corresponding hotkeys.
Now wheel up/down and hotkeys + = - zoom in/out around current mouse cursors.
Shift-Wheel and Control-Wheel as well as Arrow keys are scrolling (arrow keys play different roles in 2d and 3d).
Shift-Control-Wheel zooms in/out in x-axis.

Help 'h' in graph window prints:

...
<WheelUp> zoom in
<WheelDown> zoom out
<Shift-WheelUp> scroll up (in +y direction)
<Shift-WheelDown> scroll down
<Control-WheelUp> scroll right (in +x direction)
<Control-WheelDown> scroll left
<Shift-Control-WheelUp> zoom in only the x-axis
<Shift-Control-WheelDown> zoom out only the x-axis
...
+ `builtin-zoom-in` zoom in
= `builtin-zoom-in` zoom in
- `builtin-zoom-out` zoom out
Right `scroll right in 2d, rotate right in 3d`; <Shift> faster
Up `scroll up in 2d, rotate up in 3d`; <Shift> faster
Left `scroll left in 2d, rotate left in 3d`; <Shift> faster
Down `scroll down in 2d, rotate down in 3d`; <Shift> faster

Discussion

  • Petr Mikulik
    Petr Mikulik
    2012-06-23

    patch for mouse.c

     
    Attachments
  • Ethan Merritt
    Ethan Merritt
    2012-07-05

    After applying your patch, I see no change in the mousing behaviour for the wxt or qt terminals, only for x11. Does each terminal driver have to be modified separately?

     
  • Ethan Merritt
    Ethan Merritt
    2012-07-05

    Aha. The wxt and qt terminal do not load the current mouse coords into the event structure describing a mouse wheel event. When the new zoom code tries to read the mouse coords, it gets only [0,0].

    ...which raises a question. The mouse might not be over the plot at the time you use the wheel. What is supposed to happen in this case?

     
  • Ethan Merritt
    Ethan Merritt
    2012-07-06

    I have modified the qt and wxt terminals to report current mouse position when registering a wheel event. Now the patch works well for these terminals also.

    Could you have a look at cleaning up these compiler warnings before committing the code?

    mouse.c:1697: warning: unused variable ‘y2max’
    mouse.c:1697: warning: unused variable ‘x2max’
    mouse.c:1697: warning: unused variable ‘ymax’
    mouse.c:1697: warning: unused variable ‘xmax’
    mouse.c:1696: warning: unused variable ‘y2min’
    mouse.c:1696: warning: unused variable ‘x2min’
    mouse.c:1696: warning: unused variable ‘ymin’
    mouse.c:1696: warning: unused variable ‘xmin’
    mouse.c:1734: warning: unused variable ‘y2max’
    mouse.c:1734: warning: unused variable ‘x2max’
    mouse.c:1734: warning: unused variable ‘ymax’
    mouse.c:1734: warning: unused variable ‘xmax’
    mouse.c:1733: warning: unused variable ‘y2min’
    mouse.c:1733: warning: unused variable ‘x2min’
    mouse.c:1733: warning: unused variable ‘ymin’
    mouse.c:1733: warning: unused variable ‘xmin’
    mouse.c:1656: warning: control reaches end of non-void function
    mouse.c:1648: warning: control reaches end of non-void function
    mouse.c:1611: warning: ‘builtin_zoom_scroll_left’ defined but not used
    mouse.c:1619: warning: ‘builtin_zoom_scroll_right’ defined but not used
    mouse.c:1627: warning: ‘builtin_zoom_scroll_up’ defined but not used
    mouse.c:1635: warning: ‘builtin_zoom_scroll_down’ defined but not used
    mouse.c:1659: warning: ‘builtin_zoom_in_X’ defined but not used
    mouse.c:1667: warning: ‘builtin_zoom_out_X’ defined but not used

     
  • Petr Mikulik
    Petr Mikulik
    2012-07-10

    patch for mouse.c

     
    Attachments
  • Petr Mikulik
    Petr Mikulik
    2012-07-10

    I have fixed warmings.
    I have added shift factor for scrolling and speed for zooming.

     
  • Ethan Merritt
    Ethan Merritt
    2013-03-17

    Combined this with code/suggestions from Michael Madsen and Mojca Miklavec.
    Applied to CVS 4.7

    • zoom in on mouse position
    • zoom out on mouse position
      <wheel-up> scroll up (in +Y direction).
      <wheel-down> scroll down.
      <shift-wheel-up> scroll left (in -X direction).
      <shift-wheel-down> scroll right.
      <Control-WheelUp> zoom in on mouse position
      <Control-WheelDown> zoom out on mouse position
      <Shift-Control-WheelUp> pinch on x
      <Shift-Control-WheelDown> expand on x

    horizontal stroke/mouse wheel (alt-wheel in Qt)

     
  • Ethan Merritt
    Ethan Merritt
    2013-03-17

    • status: open --> closed-accepted
    • milestone: -->