changeset 30825:620607ec6608 stable

Fix saving and loading of polar plots (bug #62093) * hdl2struct.m: When converting an axes handle, check whether there is a hidden hggroup wit the "polar_grid" tag. If there is, add it to the list of handles to be converted. * struct2hdl.m (createhg): When creating an hggroup, check if the tag property is "polar_grid" and if so then change "handlevisibility" property to "off".
author Rik <rik@octave.org>
date Sun, 06 Mar 2022 17:51:22 -0800
parents f5587d651bc7
children 7a647311ba8a 0ffe2f9a19f3
files scripts/plot/util/hdl2struct.m scripts/plot/util/struct2hdl.m
diffstat 2 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/util/hdl2struct.m	Sat Mar 05 11:27:03 2022 +0100
+++ b/scripts/plot/util/hdl2struct.m	Sun Mar 06 17:51:22 2022 -0800
@@ -58,13 +58,19 @@
       hnot = findobj (h, "-depth", 1, "tag", "legend", "-or", "tag", "colorbar",
                                       "-or", "type", "uimenu");
       kids = allkids(! ismember (allkids, hnot));
+      if (strcmp (s.type, "axes"))
+        ## Check for polar plots with special "polar_grid" object
+        ## FIXME: A hack to fix bug #62093.
+        kids = [kids; findall(h, "tag", "polar_grid")];
+      endif
+
       nkids = length (kids);
       for i = nkids:-1:1
         s.children(++ii) = hdl2struct (kids(i));
       endfor
     endif
 
-    ## add non "children" children objects (title, xlabel, ...) and
+    ## Add non "children" children objects (title, xlabel, ...) and
     ## hggroup children and tag them in "special"
     if (strcmp (s.type, "hggroup"))
       special = allkids;
--- a/scripts/plot/util/struct2hdl.m	Sat Mar 05 11:27:03 2022 +0100
+++ b/scripts/plot/util/struct2hdl.m	Sun Mar 06 17:51:22 2022 -0800
@@ -441,9 +441,9 @@
 function [h, sout, pout] = createhg (s, p, par, hilev)
 
   ## Here we infer from properties the type of hggroup we should build
-  ## an call corresponding high level functions
+  ## and call the corresponding high level functions.
   ## We manually set "hold on" to avoid next hggroup be deleted
-  ## the proper value of axes "nextplot" will finally be recovered
+  ## the proper value of axes "nextplot" will finally be recovered.
 
   hold on;
   if (hilev)
@@ -475,6 +475,12 @@
     s.special = [];
   endif
 
+  ## Check for polar plots with special "polar_grid" object
+  ## FIXME: A hack to fix bug #62093.
+  if (strcmp (s.properties.tag, "polar_grid"))
+    s.properties.handlevisibility = "off";
+  endif
+
   sout = s;
   pout = p;