bugGNU Octave - Bugs: bug #62343, 'zoom on' toggles instead of...

 
 

bug #62343: 'zoom on' toggles instead of turning on

Submitted by:  None
Submitted on:  Thu 21 Apr 2022 11:54:39 AM UTC
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Confirmed Assigned to:  None
Originator Name:  Bernhard Schweighofer Originator Email:  -email is unavailable-
Open/Closed:  * Open Release:  * 7.1.0
Operating System:  * GNU/Linux
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       

 

Sat 23 Apr 2022 04:02:54 AM UTC, comment #4: 

The race condition is between the m-file zoom.m and the set___mouse_mode__ special updater in graphics.cc.

The function in graphics.cc is

figure::properties::set___mouse_mode__ (const octave_value& val_arg)

and the actual code is

      if (m___mouse_mode__.set (val, true))
        {
          std::string mode = m___mouse_mode__.current_value ();

          octave_scalar_map pm = get___pan_mode__ ().scalar_map_value ();
          pm.setfield ("Enable", mode == "pan" ? "on" : "off");
          set___pan_mode__ (pm);

          octave_scalar_map rm = get___rotate_mode__ ().scalar_map_value ();
          rm.setfield ("Enable", mode == "rotate" ? "on" : "off");
          set___rotate_mode__ (rm);

          octave_scalar_map zm = get___zoom_mode__ ().scalar_map_value ();
          zm.setfield ("Enable", mode == "zoom" ? "on" : "off");
          zm.setfield ("Direction", direction);
          set___zoom_mode__ (zm);

          mark_modified ();
        }

If you look at the code for zoom.m it first enables the Zoom mode and then calls update_mouse_mode

      switch (option)
        case {"on", "off", "xon", "yon"}
          zm = get (hfig, "__zoom_mode__");
          switch (option)
            case {"on", "off"}
              zm.Enable = option;
              zm.Motion = "both";
            case "xon"
              zm.Enable = "on";
              zm.Motion = "horizontal";
            case "yon"
              zm.Enable = "on";
              zm.Motion = "vertical";
          endswitch
          set (hfig, "__zoom_mode__", zm);
          update_mouse_mode (hfig, option);

Here is the code for update_mouse_mode.

function update_mouse_mode (hfig, arg)

  if (strcmp (arg, "off"))
    set (hfig, "__mouse_mode__", "none");
  else
    ## Bug #62343: Need to directly turn off other graphical modes to
    ##             avoid a race  condition.
#    pan (hfig, "off");
#    rotate3d (hfig, "off");
    set (hfig, "__mouse_mode__", "zoom");
  endif

The original code had a FIXME note

    ## FIXME: Is there a better way other than calling these functions
    ##        to set the other mouse mode Enable fields to "off"?

which suggests someone knew this wasn't the right way to do things.

I don't know why this is so complex and spread across three different m-files, 4 different hidden graphics properties, and one C++ special set_() routine.

My simple fix to comment out the calls to the m-files pan.m and rotate3d.m works, but it is not clear if that is enough.  Calling rotate3d ('off') does more than just flip the "Enable" field of the structure.  It also sets the "Motion" field to "both".

This is weird because this field doesn't exist earlier.  If I call

close all
gcf
get (gcf, '__rotate_mode__')
ans =

  scalar structure containing the fields:

    Enable = off
    RotateStyle = box
    FigureHandle = 1

But, then if I call rotate3d ('off') it gets a new field

rotate3d ('off')
get (gcf, '__rotate_mode__')
ans =

  scalar structure containing the fields:

    Enable = off
    RotateStyle = box
    FigureHandle = 1
    Motion = both

Adding jwe to the CC list since he wrote these originally and may remember why they are this way.

Rik <rik5>
Project Administrator
Thu 21 Apr 2022 07:26:57 PM UTC, comment #3: 

Using sombrero I can duplicate this.  I modified the subfunction update_mouse_mode() in zoom.m to be

    get (hfig, '__zoom_mode__')
    pan (hfig, "off");
    get (hfig, '__zoom_mode__')
    rotate3d (hfig, "off");
    get (hfig, '__zoom_mode__')
    set (hfig, "__mouse_mode__", "zoom");
    get (hfig, '__zoom_mode__')

Running "zoom on" repeatedly shows that the call to pan() and rotate3d() turn zoom off and that it is re-enabled by the call to "__mouse_mode__", "zoom".  I think there is a race condition as Pantxo suggests.

Rik <rik5>
Project Administrator
Thu 21 Apr 2022 03:42:20 PM UTC, comment #2: 

I can reproduce the issue quite reliably with the following scenario. Launch Octave and run "sombrero", click the zoom in button on the newly open figure and then run "zoom on" multiple times. As described by the OP, "zoom on" then toggles the zoom button on and off. This looks like a race condition since, even with the above scenario, sometimes "zoom on" doesn't toggle the button.

Pantxo Diribarne <pantxo>
Project Member
Thu 21 Apr 2022 12:56:12 PM UTC, comment #1: 

Works for me with Octave 7.1.0 on Windows 11.

>> sombrero

>> get (gcf, "__zoom_mode__")

ans =

  scalar structure containing the fields:

    Enable = off
    Motion = both
    Direction = in
    FigureHandle = 1

>> zoom on

>> get (gcf, "__zoom_mode__")
ans =

  scalar structure containing the fields:

    Enable = on
    Motion = both
    Direction = in
    FigureHandle = 1

>> zoom on
>> get (gcf, "__zoom_mode__")
ans =

  scalar structure containing the fields:

    Enable = on
    Motion = both
    Direction = in
    FigureHandle = 1

>>

Also verified by clicking into the plot that the zoom mode actually stays enabled at each step.

Markus M├╝tzel <mmuetzel>
Project Member
Thu 21 Apr 2022 11:54:39 AM UTC, original submission:  

As the title suggests, given a figure/plot and issuing the command 'zoom on' toggles the current zoom instead of turning it on, respectively, letting it stayed turned on.

graphics_toolkit -> qt

BTW. 'zoom off' works as expected: It turns off the zoom, respectively, let it be turned off.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only project members can vote.

     

     

     

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-04-23 rik5 Carbon-Copy- => Added jwe
    2022-04-21 pantxo StatusWorks For Me => Confirmed
    2022-04-21 mmuetzel StatusNone => Works For Me

    Back to the top


    Powered by Savane 3.9