bugGNU Octave - Bugs: bug #49446, Graphics objects (esp. legends)...

 
 

bug #49446: Graphics objects (esp. legends) should be manipulated/dragged with the mouse

Submitter:  Philip Nienhuis <philipnienhuis>
Submitted:  Wed 26 Oct 2016 09:36:54 AM UTC
   
 
Category:  Plotting Severity:  1 - Wish
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Patch Submitted Assigned to:  None
Originator Name:  Philip Nienhuis Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 20 Feb 2023 04:02:33 PM UTC, comment #10: 

Patch updated for octave-9.0.0 (hg id e27744dfb13a)

(note: hg id in patch is different as I'm on a local branch, but the cset is independent of that)

(file #54385)

Philip Nienhuis <philipnienhuis>
Group Member
Sat 06 Aug 2022 10:25:48 AM UTC, comment #9: 

Although maybe not Matlab-compatible (in Matlab interaction with plots is quite different than Octave these days), I've tried Remi's patch for a while and it works perfectly - for me.

The patch still applies cleanly as well.
I'd suggest that for the time being, this patch can be committed until we have a better solution for dragging the legend (and other plot objects) around.

Philip Nienhuis <philipnienhuis>
Group Member
Mon 26 Oct 2020 11:20:14 PM UTC, comment #8: 

As discussed in patch #9986, I've attached moving_legend.patch that allows user to interact with the mouse to move the legend around.

Note that the new behavior is restricted to legend. It will not work for titles for example.

This is currently enabled only when pan mode is active. It can be changed if you think of better ergonomics.
I was thinking that it would be annoying to move it by accident.

Other ergonomics would be to activate pan mode (including for axes) with CTRL key down. This feels very natural to me.

Remi Thebault <rtbo>
Fri 22 Dec 2017 06:15:15 PM UTC, comment #7: 

At least for FLTK, it is possible to click on a legend object and move it around.  This is very useful for getting the best position.  The code for this is in _init_fltk_.cc.  Maybe something like it can be borrowed and put in the Qt mouse button 1 handling routine.

Rik <rik5>
Group administrator
Mon 05 Dec 2016 12:38:35 PM UTC, comment #6: 

figure ()
%% ST inactive:
plot (1:10)
get (gcf, 'currentobject')
%% Left Click on the axes: what happens?

Warning: MATLAB has disabled some advanced graphics rendering features by switching to
software OpenGL. For more information, click here.
ans =
  0×0 empty GraphicsPlaceholder array.


get (gcf, 'currentobject') == gca

>> get (gcf, 'currentobject') == gca
ans =
  logical
   1


%% Righ Click on the axes: what happens?

...nothing...

get (gcf, 'currentobject') == gca

>> get (gcf, 'currentobject') == gca
ans =
  logical
   1


%% Check the SL and left click on the axes: what happens? Do handles appear around the axes ...?

(I suppose SelectionTool = button "Edit plot" = the white arrow button)
Clicking that shows a handle grid around the entire plot (editplot-1.png).
Clicking the axes then moves those handles to the plot lines (editplot-2.png)


>> get (gcf, 'currentobject') == gca
ans =
  logical
   1


%% Uncheck the ST: what happens?

The handle grid disappears.



Philip Nienhuis <philipnienhuis>
Group Member
Mon 28 Nov 2016 09:46:23 PM UTC, comment #5: 

Pantxo,

Hopefully Thursday I'll have time to check with Matlab.

Selection works easy in Matlab (at least for legends):
simply left-click on the legend and drag it around with LMB pressed.

Philip Nienhuis <philipnienhuis>
Group Member
Wed 23 Nov 2016 02:52:18 PM UTC, comment #4: 

@Philip: could you describe how the selection tool works in ML. I know the question is vague but having a few info would help implementing this tool in Octave.

For example does the Selection Tool (ST) have to be toggled to be able to change the current object of a figure? Test

figure ()
%% ST inactive:
plot (1:10)
get (gcf, 'currentobject')
%% Left Click on the axes: what happens?
get (gcf, 'currentobject') == gca
%% Righ Click on the axes: what happens?
get (gcf, 'currentobject') == gca
%% Check the SL and left click on the axes: what happens? Do handles appear around the axes ...?
get (gcf, 'currentobject') == gca
%% Uncheck the ST: what happens?


Pantxo Diribarne <pantxo>
Group Member
Wed 26 Oct 2016 03:46:00 PM UTC, comment #3: 

Here is an ugly workaround for moving legends with mouse:


function downfcn (h)
  pos = get (h, "position");
  fpt = get (gcbf, "currentpoint");
  setappdata (gcbf, "legenddragged", {h, pos(1:2)./fpt});
endfunction

function movefcn (h)
  data = getappdata (h, "legenddragged");
  if (isempty (data))
    return
  endif
  pos = get (data{1}, "position");
  pos(1:2) = get (gcbf, "currentpoint").*data{2};
  set (data{1}, "position",  pos)
endfunction

function upfcn (h);
  setappdata (h, "legenddragged", []);
endfunction

plot (1:10)
hl = legend ("toto");
set (hl, "buttondownfcn", @downfcn)
set (gcf, "windowbuttonmotionfcn", @movefcn)
set (gcf, "windowbuttonupfcn", @upfcn)


Pantxo Diribarne <pantxo>
Group Member
Wed 26 Oct 2016 02:40:05 PM UTC, comment #2: 

(I did search for similar reports but it didn't occur to me that "legend changes position" would be duplicates as well.)

You suggestion to change title is a good one. I'll change the status to "none' then, OK?

Philip Nienhuis <philipnienhuis>
Group Member
Wed 26 Oct 2016 10:37:37 AM UTC, comment #1: 

Hi Philip,

The legend has "normalized" units and no listener on the figure/axes position, hence the magnification you observe when increasing the figure size. This is a known bug: see bug #39697 and bug #40333.
Now about moving the legend I think it is possible:


plot (1:10);
hl = legend ("toto")
pos = get (hl, "position");
set (hl, "position", [.3 .5 pos(3:4)])


Can I close this report as a duplicate of cited reports, or would you prefer to keep this report and make the main issue be "graphics objects can be manipulated/dragged with the moue"?

Pantxo Diribarne <pantxo>
Group Member
Wed 26 Oct 2016 09:36:54 AM UTC, original submission:  

(See attached pic for a comparison between Matlab (2014a) and Octave, both in one picture)

In Matlab, when a plot windows with a legend is resized / stretched using the mouse, the legends move with the plot area proper but aren't stretched with/like the plot area itself.
In Octave, the legend box is stretched as well, in proportion to the plot window (while the contents seem to remain untouched as regards size).
This applies to both horizontal and vertical resizing of plot windows.

In addition, in Matlab one can freely drag the legend box around in the plot window as a separate entity. In Octave the legend is fixed to its position.
In the attached pic I've dragged the legend in the Matlab subpicture from left to the right and a little below, just to show what I mean.

I suppose one of the reasons that legends in Matlab aren't stretched/resized together with plot windows is just because they seem to be independent entities.

Philip Nienhuis <philipnienhuis>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #54385:  bug_49446_moving_legend_v2.cset added by philipnienhuis (5KiB - application/octet-stream)
file #50121:  moving_legend.patch added by rtbo (5KiB - text/x-patch)
file #39147:  editplot-1.png added by philipnienhuis (16KiB - image/png)
file #39148:  editplot-2.png added by philipnienhuis (18KiB - image/png)
file #38815:  MLvsOct_plot.png added by philipnienhuis (148KiB - image/png)

 

Digest:
   patch dependencies.

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rtbo (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by philipnienhuis (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 group members can vote.

     

    Follow 12 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-02-20 philipnienhuis Attached File- Added bug_49446_moving_legend_v2.cset, #54385
    2022-08-06 philipnienhuis StatusNone Patch Submitted
    2020-10-27 siko1056 Dependencies- Depends on patch #9986
    2020-10-26 rtbo Attached File- Added moving_legend.patch, #50121
    2016-12-05 rik5 Carbon-CopyRemoved 72865 -
    2016-12-05 philipnienhuis Attached File- Added editplot-1.png, #39147
        Attached File- Added editplot-2.png, #39148
    2016-11-16 rik5 Severity3 - Normal 1 - Wish
    2016-10-26 philipnienhuis StatusDuplicate None
        SummaryLegends shoudn't be resized together with plot window, and be movable independently Graphics objects (esp. legends) should be manipulated/dragged with the mouse
    2016-10-26 pantxo StatusNone Duplicate
    2016-10-26 philipnienhuis Attached File- Added MLvsOct_plot.png, #38815

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code