# HG changeset patch # User Rik # Date 1375305480 25200 # Node ID bcada0a4f8a7a6c34fd9a90b2f0e11f7b8030796 # Parent eaab03308c0b5b78997fc4585b0e1489618cefcf isaxes.m: New function to determine if object is axes handle. * scripts/plot/isaxes.m: New function. * scripts/plot/module.mk: Add function to build system. * NEWS: Announce new function. * doc/interpreter/plot.txi: Add function to manual. * libinterp/corefcn/graphics.cc(Fishandle), scripts/plot/isfigure.m: Update seealso links to mention isaxes. diff --git a/NEWS b/NEWS --- a/NEWS +++ b/NEWS @@ -189,22 +189,22 @@ ** Other new functions added in 3.8.0: - atan2d erfcinv jit_startcnt - base64_decode erfi lines - base64_encode expint polyeig - betaincinv findfigs prefdir - built_in_docstrings_file flintmax preferences - cmpermute fminsearch readline_re_read_init_file - cmunique gallery readline_read_init_file - colorcube gco rgbplot - copyobj hdl2struct save_default_options - dawson history_save shrinkfaces - dblist imformats splinefit - debug_jit importdata stemleaf - doc_cache_create iscolormap strjoin - ellipj isequaln struct2hdl - ellipke jit_debug tetramesh - jit_enable waterfall + atan2d erfi jit_startcnt + base64_decode expint lines + base64_encode findfigs polyeig + betaincinv flintmax prefdir + built_in_docstrings_file fminsearch preferences + cmpermute gallery readline_re_read_init_file + cmunique gco readline_read_init_file + colorcube hdl2struct rgbplot + copyobj history_save save_default_options + dawson imformats shrinkfaces + dblist importdata splinefit + debug_jit isaxes stemleaf + doc_cache_create iscolormap strjoin + ellipj isequaln struct2hdl + ellipke jit_debug tetramesh + erfcinv jit_enable waterfall ** Deprecated functions. diff --git a/doc/interpreter/plot.txi b/doc/interpreter/plot.txi --- a/doc/interpreter/plot.txi +++ b/doc/interpreter/plot.txi @@ -1082,13 +1082,16 @@ @subsubsection Handle Functions @cindex handle functions -To determine whether a variable is a graphics object index or a figure -index, use the functions @code{ishandle} and @code{isfigure}. +To determine whether a variable is a graphics object index, or an index +to an axes or figure, use the functions @code{ishandle}, @code{isaxes}, and +@code{isfigure}. @DOCSTRING(ishandle) @DOCSTRING(ishghandle) +@DOCSTRING(isaxes) + @DOCSTRING(isfigure) The function @code{gcf} returns an index to the current figure object, diff --git a/libinterp/corefcn/graphics.cc b/libinterp/corefcn/graphics.cc --- a/libinterp/corefcn/graphics.cc +++ b/libinterp/corefcn/graphics.cc @@ -8287,10 +8287,11 @@ "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} ishandle (@var{h})\n\ Return true if @var{h} is a graphics handle and false otherwise.\n\ +\n\ @var{h} may also be a matrix of handles in which case a logical\n\ array is returned that is true where the elements of @var{h} are\n\ graphics handles and false where they are not.\n\ -@seealso{isfigure}\n\ +@seealso{isaxes, isfigure}\n\ @end deftypefn") { gh_manager::auto_lock guard; diff --git a/scripts/plot/isaxes.m b/scripts/plot/isaxes.m new file mode 100644 --- /dev/null +++ b/scripts/plot/isaxes.m @@ -0,0 +1,56 @@ +## Copyright (C) 2013 Rik Wehbring +## +## This file is part of Octave. +## +## Octave is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or (at +## your option) any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, see +## . + +## -*- texinfo -*- +## @deftypefn {Function File} {} isaxes (@var{h}) +## Return true if @var{h} is an axes graphics handle and false otherwise. +## +## If @var{h} is a matrix then return a logical array which is true where +## the elements of @var{h} are axes graphics handles and false where +## they are not. +## @seealso{isaxes, ishandle} +## @end deftypefn + +## Author: jwe + +function retval = isaxes (h) + + if (nargin != 1) + print_usage (); + endif + + hlist = ishandle (h); + if (any (hlist)) + retval(hlist) = strcmp (get (h(hlist), "type"), "axes"); + else + retval = hlist; + endif + +endfunction + + +%!test +%! hf = figure ("visible", "off"); +%! unwind_protect +%! hax = axes (); +%! assert (isaxes (hax)); +%! assert (! isaxes (-hax)); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect + diff --git a/scripts/plot/isfigure.m b/scripts/plot/isfigure.m --- a/scripts/plot/isfigure.m +++ b/scripts/plot/isfigure.m @@ -23,7 +23,7 @@ ## If @var{h} is a matrix then return a logical array which is true where ## the elements of @var{h} are figure graphics handles and false where ## they are not. -## @seealso{ishandle} +## @seealso{isaxes, ishandle} ## @end deftypefn ## Author: jwe diff --git a/scripts/plot/module.mk b/scripts/plot/module.mk --- a/scripts/plot/module.mk +++ b/scripts/plot/module.mk @@ -118,6 +118,7 @@ plot/hidden.m \ plot/hist.m \ plot/hold.m \ + plot/isaxes.m \ plot/isfigure.m \ plot/ishghandle.m \ plot/ishold.m \