bugGNU Octave - Bugs: bug #50543, Loading of figures (and other...

 
 

bug #50543: Loading of figures (and other objects) from Octave IDE

Submitter:  Georg Wiora <gwiora>
Submitted:  Tue 14 Mar 2017 01:22:59 PM UTC
   
 
Category:  GUI Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Feature Request
Status:  Fixed Assigned to:  None
Originator Name:  gwiora Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 24 May 2018 08:54:51 AM UTC, comment #13: 

Thanks Pantxo, I will open a new bug report about the remaining small issue.

Guillaume <gyom>
Thu 24 May 2018 07:48:49 AM UTC, comment #12: 

I pushed the patch here:

http://hg.savannah.gnu.org/hgweb/octave/rev/ce725103ebf1

Closing report as fixed.

Pantxo Diribarne <pantxo>
Group Member
Wed 23 May 2018 08:44:02 PM UTC, comment #11: 

@gyom: I agree with comment #10.  Please open a new bug report about how open() should respond when there is an error condition.

The error might be because the file doesn't exist, or because there is no known handler.

It would be useful if we knew how Matlab handled errors.  For example


open ('FooBar')         % non-existent file, no output
x = open ('FooBar')     % output requested



Rik <rik5>
Group administrator
Wed 23 May 2018 02:39:46 PM UTC, comment #10: 

@gyom: Yes, that is the way "open.m" currently works. If no suitable application is found, then nothing happens. This should probably be the subject of another bug report.

Pantxo Diribarne <pantxo>
Group Member
Wed 23 May 2018 02:18:56 PM UTC, comment #9: 

@pantxo:

  1. I think what surprised me is that if I double-click on a binary file not recognized by the system (e.g. a binary file for which 'file' says 'data'), then nothing happens. A warning could be displayed in that instance.
  2. Sounds good!
Guillaume <gyom>
Wed 23 May 2018 11:24:08 AM UTC, comment #8: 

@gyom:

1 Yes, in Octave GUI, double click on ".blah" files may only open the file in the text editor if the ".blah" extension is specified in the file browser settings, or by right-click>open in editor. I happen to like this behavior as it is simple to understand: "Unless otherwise specified, double clicking a file will result in the file being handled by the 'open' function".

2 Since we have discussed that "openofig" should be a wrapper around "openfig", we will change this hardcoded path once "openfig.m" is added with your patch from bug # 44670 (and openofig, if you don't mind :-)). Is this OK?

Pantxo Diribarne <pantxo>
Group Member
Wed 23 May 2018 09:04:20 AM UTC, comment #7: 

@pantxo: I applied your patch and it seems to work fine, thanks!
I've got two comments:
1/ When a file extension is not recognized, Matlab defaults to open the file in its text editor while Octave does nothing. If you have a file named file.blah, Matlab opens it in its text editor while Octave will open the default text editor for the system.
2/ If .ofig is hardcoded in open.m, it means there will not be a function openofig.m with the extra optional inputs ("new", "reuse", "visible", "invisible" ) that openfig.m has. What about hardcoding open.m to use openfig.m for .ofig files and have all of the options there (for both .fig and .ofig)?

Guillaume <gyom>
Wed 23 May 2018 07:53:39 AM UTC, comment #6: 

I rebased and finished the patch (see attached) and I'll push it to default unless someone opposes.

(file #44198)

Pantxo Diribarne <pantxo>
Group Member
Thu 16 Mar 2017 08:07:32 AM UTC, comment #5: 

Thank you for your quick implementation pantxo!

To answer your question: Yes, Matlab allows overriding built in open functions.

Georg Wiora <gwiora>
Wed 15 Mar 2017 09:07:20 PM UTC, comment #4: 

I attached a preliminary cset in which I implemented the modification of "open":

  • ".ofig" files are open using hgload
  • first check custom openxxx functions. This allows overiding the default behavior for known extension. Does Matlab allow users to override the default behavior for e.g. .mat files (defining a "openmat" function)?


I also modified the file browser to fallback to make use of "open".

(file #40009)

Pantxo Diribarne <pantxo>
Group Member
Wed 15 Mar 2017 10:37:05 AM UTC, comment #3: 

This solution would be preferable in my opinion. It would allow a free configuration for various file types.
 
Therefore it would be nice if a central "openAny.m" octave function would be called that could be used to handle the file recognition.


function result=openAny(filename)
  FileType = File_Type_Recognition_Function(filename)
  switch(FileType)
  case '.ofig':
    result=openOFIG(filename);
  case '.otherfiletype':
    result=openOTHERFILETYPE(filename);
    .
    .
    .
  otherwise:
    error('Filetype of "%s" can not be loaded!');
  endswitch
endfunction


This kind of interface is limited to load functions returning a single argument. Therefore using varargout as for results may be more suitable.

Georg Wiora <gwiora>
Wed 15 Mar 2017 10:14:45 AM UTC, comment #2: 

What about using the same mechanism than Matlab by using "open" and its extension "openxxx" when double-clicking on a file?

https://www.mathworks.com/help/matlab/ref/open.html#description

Guillaume <gyom>
Tue 14 Mar 2017 06:27:59 PM UTC, comment #1: 

Hi,

>> So .mat files could be restored with "load()" ...

This is already the case: double clicking on a data file will load variables in the base workspace

>> ... and saved figures with hgload()

Since .ofig files are data files, the structure they contain is also loaded as a variable in the base workspace, but it would be easy to implement this. The function to modify is files_dock_widget::display_directory (in files-dock-widget.cc).

Pantxo Diribarne <pantxo>
Group Member
Tue 14 Mar 2017 01:22:59 PM UTC, original submission:  

I whish to open other file types than .m files from octave gui file browser. Especially .mat and .ofig files would be useful.

The current standard behavior for unknown file types is calling the operating systems standard open method.

Preferably calling a configurable octave method could be usefull.

So .mat files could be restored with "load()" and saved figures with hgload().

Georg Wiora <gwiora>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #44198:  open_in_gui.patch added by pantxo (8KiB - text/x-patch)
file #40009:  opencustom.patch added by pantxo (6KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Date Changed by Updated Field Previous Value => Replaced by
    2018-05-24 pantxo StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2018-05-23 pantxo Attached File- Added open_in_gui.patch, #44198
        StatusIn Progress Patch Submitted
    2017-03-15 pantxo Attached File- Added opencustom.patch, #40009
        StatusConfirmed In Progress
    2017-03-14 pantxo StatusNone Confirmed
        Release4.2.1 dev

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code