diff src/graphics.cc @ 8183:277218396978

Handle arrays of handles in the Fishandle function
author David Bateman <dbateman@free.fr>
date Mon, 06 Oct 2008 13:31:56 -0400
parents c066714ee5d5
children 32e9e8103390
line wrap: on
line diff
--- a/src/graphics.cc	Mon Oct 06 13:03:04 2008 -0400
+++ b/src/graphics.cc	Mon Oct 06 13:31:56 2008 -0400
@@ -1424,10 +1424,34 @@
   return h.ok ();
 }
 
-static bool
+static octave_value
 is_handle (const octave_value& val)
 {
-  return val.is_real_scalar () && is_handle (val.double_value ());
+  octave_value retval = false;
+
+  if (val.is_real_scalar () && is_handle (val.double_value ()))
+    retval = true;
+  else if (val.is_real_matrix ())
+    {
+      if (val.is_string ())
+	retval = boolNDArray (val.dims (), false);
+      else
+	{
+	  const NDArray handles = val.array_value ();
+
+	  if (! error_state)
+	    {
+	      boolNDArray result (handles.dims ());
+
+	      for (octave_idx_type i = 0; i < handles.numel (); i++)
+		result.xelem (i) = is_handle (handles (i));
+
+	      retval = result;
+	    }
+	}
+    }
+
+  return retval;
 }
 
 static bool