changeset 25272:49a8d0a2d7ae

Move exclusion of saved graphics properties from hdl2struct to struct2hdl. Re-architect where read-only or derived properties are excluded. They are now stored in the struct, but discarded when restored to an active handle. * hdl2struct.m: Remove read-only properties associated with a specific handle type from the list of properties to exclude. * struct2hdl.m: Remove read-only properties based on graphics object type.
author Rik <rik@octave.org>
date Tue, 17 Apr 2018 12:05:17 -0700
parents 617fe022e965
children ac6ba9f2fa41
files scripts/plot/util/hdl2struct.m scripts/plot/util/struct2hdl.m
diffstat 2 files changed, 18 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/util/hdl2struct.m	Mon Apr 16 20:43:24 2018 -0700
+++ b/scripts/plot/util/hdl2struct.m	Tue Apr 17 12:05:17 2018 -0700
@@ -135,15 +135,12 @@
   persistent excluded;
 
   if (isempty (excluded))
-    excluded = cell2struct (repmat ({[]}, 1, 21),
+    excluded = cell2struct (repmat ({[]}, 1, 15),
                             {"beingdeleted", "busyaction", "buttondownfcn", ...
                              "children", "clipping", "createfcn", ...
                              "deletefcn", "handlevisibility", "hittest", ...
                              "interruptible", "parent", "selected" , ...
-                             "selectionhighlight", "type", "uicontextmenu", ...
-                             "currentaxes", "currentcharacter", ...
-                             "currentobject", "tightinset", "currentpoint", ...
-                             "extent"}, 2);
+                             "selectionhighlight", "type", "uicontextmenu"}, 2);
   endif
 
   obj = get (h);
--- a/scripts/plot/util/struct2hdl.m	Mon Apr 16 20:43:24 2018 -0700
+++ b/scripts/plot/util/struct2hdl.m	Tue Apr 17 12:05:17 2018 -0700
@@ -123,12 +123,16 @@
     h = 0;
     s.properties = rmfield (s.properties, ...
                               {"callbackobject", "commandwindowsize", ...
+                               "monitorpositions", "pointerwindow", ...
                                "screendepth", "screenpixelsperinch", ...
                                "screensize"});
   elseif (strcmp (s.type, "figure"))
     h = figure ();
+    s.properties = rmfield (s.properties, ...
+                              {"currentaxes", "currentcharacter", ...
+                               "currentobject", "currentpoint"});
   elseif (strcmp (s.type, "axes"))
-    ## legends and colorbars are "transformed" in normal axes
+    ## legends and colorbars are "transformed" in to normal axes
     ## if hilev is not requested
     if (! hilev)
       if (strcmp (s.properties.tag, "legend"))
@@ -141,13 +145,14 @@
         par = gcf;
       endif
     endif
-
+    s.properties = rmfield (s.properties, {"tightinset"});
     [h, s] = createaxes (s, p, par);
   elseif (strcmp (s.type, "line"))
     h = createline (s, par);
   elseif (strcmp (s.type, "patch"))
     [h, s] = createpatch (s, par);
   elseif (strcmp (s.type, "text"))
+    s.properties = rmfield (s.properties, "extent");
     h = createtext (s, par);
   elseif (strcmp (s.type, "image"))
     h = createimage (s, par);
@@ -579,8 +584,8 @@
       set (h, s.properties);
     else
       ## Specials are objects that where automatically constructed with
-      ## current object.  Among them are "x(yz)labels", "title", high
-      ## level hggroup children
+      ## current object.  Among them are "x(yz)labels", "title", and
+      ## high level hggroup children
       fields = fieldnames (s.properties);
       vals = struct2cell (s.properties);
       idx = find (cellfun (@(x) valcomp(x, hdls) , vals));
@@ -597,8 +602,14 @@
         field = fields{nf};
         idx = find (hdls == vals{nf});
         spec = specs(idx);
+        ## FIXME: Wouldn't it be better to call struct2hdl recursively
+        ##        for this handle?  That way the function could determine
+        ##        based on type what special actions to take.
+        try
+          spec.properties = rmfield (spec.properties, "extent");
+        end_try_catch
         if (isprop (h, field))
-          h2 = get (h , field);
+          h2 = get (h, field);
           addmissingprops (h2, spec.properties);
           set (h2, spec.properties);
         endif