# HG changeset patch # User Rik # Date 1326950234 28800 # Node ID d580d7179f853dd85bdef11318d855fb29d5f237 # Parent f0d903879eaae180b02db6746dee9ecd84d738a3 Use isfigure() to simplify some plot functions. * figure.m, refresh.m, uiresume.m, uiwait.m: Simplify code by using isfigure(). diff --git a/scripts/plot/figure.m b/scripts/plot/figure.m --- a/scripts/plot/figure.m +++ b/scripts/plot/figure.m @@ -37,7 +37,7 @@ init_new_figure = false; if (mod (nargs, 2) == 1) tmp = varargin{1}; - if (ishandle (tmp) && strcmp (get (tmp, "type"), "figure")) + if (isfigure (tmp)) f = tmp; varargin(1) = []; nargs--; diff --git a/scripts/plot/refresh.m b/scripts/plot/refresh.m --- a/scripts/plot/refresh.m +++ b/scripts/plot/refresh.m @@ -19,24 +19,25 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} refresh () ## @deftypefnx {Function File} {} refresh (@var{h}) -## Refresh a figure, forcing it to be redrawn. Called without an -## argument the current figure is redrawn, otherwise the figure pointed +## Refresh a figure, forcing it to be redrawn. When called without an +## argument the current figure is redrawn. Otherwise, the figure pointed ## to by @var{h} is redrawn. ## @seealso{drawnow} ## @end deftypefn function refresh (h) - if (nargin == 1) - if (!ishandle (h) || !strcmp (get (h, "type"), "figure")) - error ("refresh: expecting argument to be a valid figure handle"); + if (nargin > 1) + print_usage (); + elseif (nargin == 1) + if (! isfigure (h)) + error ("refresh: H must be a valid figure handle"); endif - elseif (nargin > 1) - print_usage (); else h = gcf (); endif - set(h,"__modified__", "on"); + set (h, "__modified__", "on"); drawnow (); + endfunction diff --git a/scripts/plot/uiresume.m b/scripts/plot/uiresume.m --- a/scripts/plot/uiresume.m +++ b/scripts/plot/uiresume.m @@ -29,8 +29,8 @@ function uiresume (h) - if (! ishandle (h) || ! strcmp (get (h, "type"), "figure")) - error ("uiresume: invalid figure handle"); + if (! isfigure (h)) + error ("uiresume: invalid figure handle H"); endif try diff --git a/scripts/plot/uiwait.m b/scripts/plot/uiwait.m --- a/scripts/plot/uiwait.m +++ b/scripts/plot/uiwait.m @@ -47,8 +47,8 @@ h = get (0, "currentfigure"); else h = varargin{1}; - if (! ishandle (h) || ! strcmp (get (h, "type"), "figure")) - error ("uiwait: invalid figure handle"); + if (! isfigure (h)) + error ("uiwait: invalid figure handle H"); endif if (nargin > 1) timeout = varargin{2}; @@ -63,7 +63,7 @@ if (! strcmp (get (h, "__uiwait_state__"), "none")) error ("uiwait: an active uiwait call for this figure already exists"); endif - set (h, "__uiwait_state__", "active"); + set (h, "__uiwait_state__", "active"); end_try_catch waitfor_args = {h, "__uiwait_state__", "triggered"}; if (! isempty (timeout))