octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #44670] hgload can't open Matlab figures


From: John Swensen
Subject: [Octave-bug-tracker] [bug #44670] hgload can't open Matlab figures
Date: Tue, 26 Jul 2016 15:58:08 +0000 (UTC)
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.82 Safari/537.36

Follow-up Comment #9, bug #44670 (project octave):

I just wanted to bring my portion of the discussion over from a duplicate bug
I had created. That commentary is available in the linked "duplicate" bug, but
I am reposting here to keep it in the same discussion.

As there have been various discussions on the maintainers mailing list about a
method support a GUI builder, it made me start thinking about how I like the
fact that the Matlab GUIDE only requires a FIG file and an associated M file
as the underlying file format. Some people were in favor of the QTCreator ui
files, which I am fine if that is the decision, but decided to try and get FIG
files generated by Matlab to load in Octave. 

I found a great website called undocumentedmatlab.com that explains that FIG
files are just a MAT file that contains the figure information (see
http://undocumentedmatlab.com/blog/fig-files-format). I think someone within
Octave must have already known this because the hdl2struct and struct2hdl
functions already are almost identical in underlying structure to the
structure contained within a FIG file. 

However, for the life of me I couldn't get struct2hdl to work for me in trying
to load a Matlab-generated FIG file to load. There seemed to be a couple
problems: 
1) too many places where Octave's struct2hdl would fail if the FIG file struct
didn't have properties named exactly the same as Octave was expecting. 

2) struct2hdl wasn't handling the reading of the title, xlabel, ylabel, zlabel
correctly. In the FIG struct, they are listed as children, but in the
resulting axes handle these text handles need to be assigned to the
corresponding property in the axes handle, rather than just added as children.
It seems that Matlab does not add them as children, but does assign the handle
to the appropriate axes property. It seems that Octave both adds them as
children and assigns the handle to the appropriate axes property. The mapping
for these non-regular children is handled with the "special" field of the axes
sub-struct. 

So, I wrote a fairly simple script that seems to be loading simple FIG files
generated from Matlab into Octave. It recursively depth-first traverses the
FIG struct, creates an object based on the handle type (not all are supported
yet), and assigns any properties from the FIG struct that exist in the Octave
handle. In the case where some of the children are irregular, the special
field of the struct is used to determine the mapping from children to
properties. 

Is suspect the the Octave struct2hdl and hdl2struct are self-consistent, it is
just that they don't handle the conversion from Matlab FIG struct to an Octave
handle. I think the right approach is to try to fix up the existing struct2hdl
and hdl2struct to be compatible with the FIG struct from Matlab, but am
wondering if that will break a bunch of other people's code or existing
figures that have been saved as structs in MAT files using the current Octave
hdl2struct.

(file #38031, file #38032)
    _______________________________________________________

Additional Item Attachment:

File name: openfig.m                      Size:2 KB
File name: SineWave.fig                   Size:35 KB


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?44670>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]