changeset 14226:d580d7179f85

Use isfigure() to simplify some plot functions. * figure.m, refresh.m, uiresume.m, uiwait.m: Simplify code by using isfigure().
author Rik <octave@nomad.inbox5.com>
date Wed, 18 Jan 2012 21:17:14 -0800
parents f0d903879eaa
children c24833c6ebc2
files scripts/plot/figure.m scripts/plot/refresh.m scripts/plot/uiresume.m scripts/plot/uiwait.m
diffstat 4 files changed, 15 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- 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--;
--- 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
--- 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
--- 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))