changeset 19915:f25fe5369022

Don't assume axes parent is a figure (bug #44394) * axis.m: use "ancestor (ca, "figure")" in place of "get (ca, "parent")" * legend.m: use "ancestor (ca, "figure")" in place of "get (ca, "parent")" * colorbar.m: use "ancestor (ca, "figure")" in place of "get (ca, "parent")" * copyobj.m: use "ancestor (ca, "figure")" in place of "get (ca, "parent")" * hold.m: use "ancestor (ca, "figure")" in place of "get (ca, "parent")" * ishold.m: use "ancestor (ca, "figure")" in place of "get (ca, "parent")"
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Sun, 01 Mar 2015 15:10:28 +0100
parents 2350fc8ba960
children 75d1c4096ba7
files scripts/plot/appearance/axis.m scripts/plot/appearance/legend.m scripts/plot/draw/colorbar.m scripts/plot/util/copyobj.m scripts/plot/util/hold.m scripts/plot/util/ishold.m
diffstat 6 files changed, 12 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/appearance/axis.m	Sat Feb 28 19:07:48 2015 -0500
+++ b/scripts/plot/appearance/axis.m	Sun Mar 01 15:10:28 2015 +0100
@@ -193,7 +193,7 @@
       set (ca, "dataaspectratiomode", "auto",
                "plotboxaspectratio", [1, 1, 1]);
     elseif (strcmp (ax, "equal"))
-      if (strcmp (get (get (ca, "parent"), "__graphics_toolkit__"), "gnuplot"))
+      if (strcmp (get (ancestor (ca, "figure"), "__graphics_toolkit__"), "gnuplot"))
         ## FIXME: gnuplot applies the aspect ratio activepostionproperty.
         set (ca, "activepositionproperty", "position");
         ## The following line is a trick used to trigger the recalculation of
--- a/scripts/plot/appearance/legend.m	Sat Feb 28 19:07:48 2015 -0500
+++ b/scripts/plot/appearance/legend.m	Sun Mar 01 15:10:28 2015 +0100
@@ -125,7 +125,7 @@
     if (isempty (ca))
       ca = gca ();
     endif
-    fig = get (ca, "parent");
+    fig = ancestor (ca, "figure");
   else
     fig = get (0, "currentfigure");
     if (isempty (fig))
--- a/scripts/plot/draw/colorbar.m	Sat Feb 28 19:07:48 2015 -0500
+++ b/scripts/plot/draw/colorbar.m	Sun Mar 01 15:10:28 2015 +0100
@@ -149,7 +149,7 @@
       ## if (! isempty (args))
       ##   set (hcb, args{:});
       ## endif
-      ax = get (get (hcb, "parent"), "currrentaxes");
+      ax = get (ancestor (hcb, "figure"), "currrentaxes");
     endif
   endif
 
@@ -163,7 +163,7 @@
   showhiddenhandles = get (0, "showhiddenhandles");
   unwind_protect
     set (0, "showhiddenhandles", "on");
-    cax = findobj (get (ax, "parent"),
+    cax = findobj (ancestor (ax, "figure"),
                    "tag", "colorbar", "type", "axes", "axes", ax);
     if (! isempty (cax))
       delete (cax);
@@ -180,8 +180,8 @@
     obj = get (ax);
     obj.__cbar_hax__ = ax;
     position = obj.position;
-    ## FIXME: Should this be ancestor to accommodate hggroups?
-    hpar = get (ax, "parent");
+    
+    hpar = ancestor (ax, "figure");
     clen = rows (get (hpar, "colormap"));
     cext = get (ax, "clim");
     cdiff = (cext(2) - cext(1)) / clen / 2;
@@ -277,7 +277,7 @@
 function resetaxis (cax, d, ax, orig_props)
   if (isaxes (ax))
     ## FIXME: Probably don't want to delete everyone's listeners on colormap.
-    dellistener (get (ax, "parent"), "colormap");
+    dellistener (ancestor (ax, "figure"), "colormap");
     dellistener (ax, "clim");
     dellistener (ax, "dataaspectratio");
     dellistener (ax, "dataaspectratiomode");
@@ -297,7 +297,7 @@
 function update_colorbar_clim (hax, d, hi, vert)
   if (isaxes (hax)
       && (isempty (gcbf ()) || strcmp (get (gcbf (), "beingdeleted"), "off")))
-    clen = rows (get (get (hax, "parent"), "colormap"));
+    clen = rows (get (ancestor (hax, "figure"), "colormap"));
     cext = get (hax, "clim");
     cdiff = (cext(2) - cext(1)) / clen / 2;
     cmin = cext(1) + cdiff;
--- a/scripts/plot/util/copyobj.m	Sat Feb 28 19:07:48 2015 -0500
+++ b/scripts/plot/util/copyobj.m	Sun Mar 01 15:10:28 2015 +0100
@@ -65,7 +65,7 @@
 
   ## reset current figure (and eventually axes) to original
   set (0, "currentfigure", cf);
-  if (get (hnew, "parent") == cf && ! isempty (ca))
+  if (ancestor (hnew, "figure") == cf && ! isempty (ca))
     set (cf, "currentaxes", ca)
   endif
 
--- a/scripts/plot/util/hold.m	Sat Feb 28 19:07:48 2015 -0500
+++ b/scripts/plot/util/hold.m	Sun Mar 01 15:10:28 2015 +0100
@@ -56,9 +56,8 @@
   if (nargin > 0 && isscalar (varargin{1}) && isaxes (varargin{1}))
     hax = varargin{1};
     varargin(1) = [];
-    nargs = numel (varargin);
-    ## FIXME: Should this be ancestor (hax, "parent")?
-    hfig = get (hax, "parent");
+    nargs = numel (varargin);    
+    hfig = ancestor (hax, "figure");
   elseif (nargin > 0 && numel (varargin{1}) > 1 && ishandle (varargin{1}))
     print_usage ();
   else
--- a/scripts/plot/util/ishold.m	Sat Feb 28 19:07:48 2015 -0500
+++ b/scripts/plot/util/ishold.m	Sun Mar 01 15:10:28 2015 +0100
@@ -44,7 +44,7 @@
         ax = get (fig, "currentaxes");
       elseif (strcmp (get (h, "type"), "axes"))
         ax = h;
-        fig = get (ax, "parent");
+        fig = ancestor (ax, "figure");
       else
         error ("ishold: H must be an axes or figure graphics handle");
       endif