bugGNU Octave - Bugs: bug #44672, Differences with figure/uicontrol...

 
 

bug #44672: Differences with figure/uicontrol between Octave and MATLAB

Submitter:  Guillaume <gyom>
Submitted:  Mon 30 Mar 2015 06:27:10 PM UTC
   
 
Category:  Plotting Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Guillaume Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 05 Nov 2018 05:00:45 PM UTC, comment #17: 

I removed the m-file input validation for an even number of PROPERTY/VALUE pairs in figure.m here: https://hg.savannah.gnu.org/hgweb/octave/rev/18449ef91387.

Rik <rik5>
Group administrator
Sat 03 Nov 2018 09:00:07 AM UTC, comment #16: 

Thanks Rik, t makes sense. The same lines should be removed from figure.m for consistency.

Guillaume <gyom>
Fri 02 Nov 2018 11:12:34 PM UTC, comment #15: 

In the end I just removed the check for even numbers of PROPERTY/VALUE pairs in uiobject_split_args.m.  The C++ validation catches anything anyways, and it was becoming too cumbersome to code something in an m-file.  See changeset https://hg.savannah.gnu.org/hgweb/octave/rev/8aaf5f597afc.

Rik <rik5>
Group administrator
Fri 02 Nov 2018 07:10:56 PM UTC, comment #14: 

Sorry for being unclear, I meant a situation like this:


h = figure;
uicontrol (h, "string", "button", struct ("style", "checkbox"), "userdata", struct ("a", 1));


You are right that an invalid syntax will be spotted later on in C++ so we could remove the test entirely.

Guillaume <gyom>
Fri 02 Nov 2018 04:06:03 PM UTC, comment #13: 

Can you post the problem example with 'UserData' so that I have something to check with?

One possibility is just to drop checking for PROP/VALUE pairs and let the error happen in C++ when set() is called incorrectly.

Another possibility is to be very specific and check whether 'UserData' is the property name before the struct.  I'm not a big fan of that though.


Rik <rik5>
Group administrator
Fri 02 Nov 2018 11:46:22 AM UTC, comment #12: 

I cannot think of something else than the following to be used in figure.m and _uiobject_split_args_.m


i = 1;
while (i <= numel (args))
  if (isstruct (args{i}))
    i = i + 1;
  elseif (ischar (args{i}) && i < numel (args))
    i = i + 2;
  else
    error ("%s: PROPERTY/VALUE arguments must occur in pairs", who);
  endif
endwhile


Guillaume <gyom>
Fri 02 Nov 2018 09:37:15 AM UTC, comment #11: 

Thanks Rik. Unfortunately the change relies on the fact that values cannot be structs, which is not true for "UserData" (I cannot find any other property where that would be the case). It means we need a more complicated test; I am not sure this can be written without a loop.

Guillaume <gyom>
Thu 01 Nov 2018 07:00:21 PM UTC, comment #10: 

I added the ability to use a struct with uiXXX objects in this changeset (https://hg.savannah.gnu.org/hgweb/octave/rev/68350e746ff2).  I think that completes this bug report.  Marking as fixed and closing.

Rik <rik5>
Group administrator
Thu 01 Nov 2018 05:34:19 PM UTC, comment #9: 

Yes, I don't see any documentation for it in Matlab but it works and is a rather convenient syntax. Having it available and documented in Octave would be a (low priority) plus.

Guillaume <gyom>
Thu 01 Nov 2018 05:00:40 PM UTC, comment #8: 

@Guillaume: The documentation for uicontrol (http://www.mathworks.com/help/matlab/ref/uicontrol.html) doesn't mention using a struct as input.  But is this a general capability that Matlab has that simply isn't documented?

Does this run under Matlab?


s = struct ('Style','radiobutton','String','Option 1')
h = uicontrol (s)



Rik <rik5>
Group administrator
Thu 01 Nov 2018 04:29:58 PM UTC, comment #7: 

I verified Pantxo's fix for item #2.  Octave is very close now to full compatibility.

Rik <rik5>
Group administrator
Thu 01 Nov 2018 04:07:06 PM UTC, comment #6: 

Thanks Pantxo, I confirm item #2 is now fixed.

My main concern for item #1 was uimenu objects which are now accessible so we can consider it fixed (and open a new bug report if and when uitoolbar objects becomes a concern).

Item #5 was implemented for figure.m by Rik in https://hg.savannah.gnu.org/hgweb/octave/rev/810c7df7e5e7
It is still not implemented for ui*.m (I actually came across it this very morning). Porting the change to _uiobject_split_args_.m would be an option.

Guillaume <gyom>
Thu 01 Nov 2018 01:46:47 PM UTC, comment #5: 

For item #2, I pushed this patch which fixes the issue for me:

http://hg.savannah.gnu.org/hgweb/octave/rev/37743ef71734

As for item #1, the qt default menus are now implemented using uimenu objects but the default toolbar is still not an uitoolbar.

Pantxo Diribarne <pantxo>
Group Member
Tue 14 Aug 2018 11:58:31 PM UTC, comment #4: 

Good news / bad news.  The good news is that I can see why gco is not being updated when a pushbutton is pressed.  The bad news is that I'm not a GUI or Qt expert and I don't know the best way to fix it.

The normal code to handle a MousePressEvent is found in libgui/graphics/Canvas.cc.  See


  Canvas::canvasMousePressEvent (QMouseEvent *event)


However, when a pushbutton is activated the Canvas object apparently never sees the event.  Instead, the code in ButtonControl.cc is executed


  ButtonControl::clicked (void)


That is the root of the problem.  Either the event needs to also be dispatched to Canvas, or ButtonControl needs to borrow code from Canvas.cc to change the CurrentObject property of the figure containing the button.

Rik <rik5>
Group administrator
Tue 14 Aug 2018 09:54:03 PM UTC, comment #3: 

I changed figure.m to accept structures of property/value pairs.  See https://hg.savannah.gnu.org/hgweb/octave/rev/810c7df7e5e7.

This leaves items #1 and #2.

Rik <rik5>
Group administrator
Tue 14 Aug 2018 08:38:15 PM UTC, comment #2: 

Item #4 has been addressed.

Item #3, accepting a number for a string property, I would consider "Won't Fix".  It is easy enough for the programmer themselves to use num2str and that way there was conscious intent by the programmer to have this particular behavior.

Items #1, #2, and #5 are valid.

 


Rik <rik5>
Group administrator
Mon 13 Jun 2016 10:57:24 AM UTC, comment #1: 

Item four ("Interpretation of '&' in the 'String' property of a uicontrol") is discussed independently in bug #48214.

Guillaume <gyom>
Mon 30 Mar 2015 06:27:10 PM UTC, original submission:  

I observed small differences in behaviour or syntax between Octave and MATLAB regarding figure/uicontrol - they sometimes correspond to undocumented features so I understand if they were not implemented in Octave but I thought some of them might still be relevant. Let me know if I should write several bug reports instead or wait for 4.0 release before doing so.

  • Octave does not return all the handles of the default menu from a new figure:



findall(figure)


i.e. Octave returns the handle of the figure only, while MATLAB returns the handles of the figure, menu and toolbar items.

  • Difference between gco and gcbo:



F = figure;
uicontrol(F,'Style','pushbutton','Callback','disp(gco),disp(gcbo)');


at each click on the button, MATLAB displays the handle of the pushbutton for both gco and gcbo while Octave returns [] and the handle of the pushbutton, unless you click in the figure and then gco is the handle of the figure.

  • Numerical content of the 'String' property of a uicontrol:



F = figure;
uicontrol(F,'Style','Edit','String',3);


Octave returns an error as it expects a string while MATLAB will automatically convert to a string (with a call to num2str I presume).

  • Interpretation of '&' in the 'String' property of a uicontrol:



F = figure;
uicontrol(F,'Style','pushbutton','String','A&B');


In Octave, it creates an underlines B (as it would do for a uimenu, and enables Alt-B) while on MATLAB, it displays 'A&B'.

  • Options for figure/uicontrol/... can be provided as property/value pairs and/or a structure:



figure('Color',[0.5 0.5 0.5],'Name','Title','Tag','fig_tag','Pointer','Watch')
figure('Color',[0.5 0.5 0.5],struct('Name','Title','Tag','fig_tag'),'Pointer','Watch')


MATLAB is fine with both syntaxes (I could not find it mentioned in the documentation though) while Octave only acceps the first one.

Guillaume <gyom>

 

(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 pantxo (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by gyom (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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-11-01 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2018-08-14 rik5 StatusNone Confirmed
        SummaryDifference with figure/uicontrol between Octave and MATLAB Differences with figure/uicontrol between Octave and MATLAB

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code