1 ## Copyright (C) 2005-2012 John W. Eaton
3 ## This file is part of Octave.
5 ## Octave is free software; you can redistribute it and/or modify it
6 ## under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ## General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
20 ## @deftypefn {Command} {} ishold
21 ## @deftypefnx {Function File} {} ishold (@var{h})
22 ## Return true if the next plot will be added to the current plot, or
23 ## false if the plot device will be cleared before drawing the next plot.
25 ## Optionally, operate on the graphics handle @var{h} rather than the current
30 function retval = ishold (h)
34 ax = get (fig, "currentaxes");
38 ax = get (h, "currentaxes");
40 elseif (strcmpi (get (h, "type"), "axes"))
42 fig = get (h, "parent");
44 error ("ishold: expecting argument to be axes or figure graphics handle");
47 error ("ishold: expecting argument to be axes or figure graphics handle");
53 retval = (strcmpi (get (fig, "nextplot"), "add")
54 && ! isempty (ax) && strcmpi (get (ax, "nextplot"), "add"));
59 %! hf = figure ("visible", "off");
62 %! assert (isempty (get (hf, "currentaxes")));
63 %! assert (get (hf, "NextPlot"), "add");
66 %! assert (!ishold (gca));
67 %! assert (get (gca, "NextPlot"), "replace");
68 %! assert (get (hf, "NextPlot"), "add");
71 %! assert (ishold (gca));
72 %! assert (get (gca, "NextPlot"), "add");
73 %! assert (get (hf, "NextPlot"), "add");
74 %! p = fill ([0 1 1], [0 0 1],"black");
75 %! assert (length (get (hf, "children")), 1);
76 %! assert (length (get (gca, "children")), 2);
77 %! unwind_protect_cleanup