changeset 7286:c0c6aa5afff4

[project @ 2007-12-11 16:52:56 by jwe]
author jwe
date Tue, 11 Dec 2007 16:57:39 +0000
parents c8d362c69013
children 3f29467c1667
files scripts/ChangeLog scripts/plot/__plt_get_axis_arg__.m src/ChangeLog src/graphics.cc src/graphics.h.in
diffstat 5 files changed, 39 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Tue Dec 11 01:54:19 2007 +0000
+++ b/scripts/ChangeLog	Tue Dec 11 16:57:39 2007 +0000
@@ -1,3 +1,8 @@
+2007-12-11  David Bateman  <dbateman@free.fr>
+
+	* plot/__plt_get_axis_arg__.m: Ignore integer valued handles as
+	object handles are all now non integer.
+
 2007-12-10  John W. Eaton  <jwe@octave.org>
 
 	* plot/sombrero.m, plot/peaks.m: Use surf instead of mesh.
--- a/scripts/plot/__plt_get_axis_arg__.m	Tue Dec 11 01:54:19 2007 +0000
+++ b/scripts/plot/__plt_get_axis_arg__.m	Tue Dec 11 16:57:39 2007 +0000
@@ -30,7 +30,10 @@
     nogca = false;
   endif
 
-  if (nargin > 1 && length (varargin) > 0 && ishandle (varargin{1}))
+  ## Figure handles are integers, but object handles are non integer,
+  ## therefore ignore integer scalars.
+  if (nargin > 1 && length (varargin) > 0 && ishandle (varargin{1})
+      && floor(varargin{1}) != varargin{1})
     tmp = varargin{1};
     obj = get (tmp);
     if (strcmp (obj.type, "axes") || strcmp (obj.type, "hggroup"))
@@ -47,7 +50,7 @@
     if (isempty (f))
       h = [];
     else
-      h = get (f, 'currentaxes');
+      h = get (f, "currentaxes");
     endif
     if (isempty (h))
       if (nogca)
--- a/src/ChangeLog	Tue Dec 11 01:54:19 2007 +0000
+++ b/src/ChangeLog	Tue Dec 11 16:57:39 2007 +0000
@@ -1,3 +1,12 @@
+2007-12-11  David Bateman  <dbateman@free.fr>
+
+	* graphics.cc (axes::properties::properties):
+	Initialize xcolor, ycolor, and zcolor to (0, 0, 0).
+
+	* graphics.h.in (gh_manager::next_handle): Now double.
+	* graphics.cc (gh_manager::get_handle, gh_manager::gh_manager):
+	Set fractional part of next_handle to a random value.
+
 2007-12-10  John W. Eaton  <jwe@octave.org>
 
 	* ov-cell.cc (octave_cell::all_strings): Handle empty elements.
--- a/src/graphics.cc	Tue Dec 11 01:54:19 2007 +0000
+++ b/src/graphics.cc	Tue Dec 11 16:57:39 2007 +0000
@@ -26,6 +26,7 @@
 
 #include <cctype>
 #include <cfloat>
+#include <cstdlib>
 
 #include <algorithm>
 #include <list>
@@ -454,7 +455,13 @@
 	  handle_free_list.erase (p);
 	}
       else
-	retval = next_handle--;
+	{
+	  static double maxrand = RAND_MAX + 2.0;
+
+	  retval = graphics_handle (next_handle);
+
+	  next_handle = trunc (next_handle) - 1.0 - (rand () + 1.0) / maxrand;
+	}
     }
 
   return retval;
@@ -1080,7 +1087,7 @@
 }
 
 axes::properties::properties (const graphics_handle& mh,
-					const graphics_handle& p)
+			      const graphics_handle& p)
   : base_properties (go_name, mh, p),
     position (Matrix ()),
     title (octave_NaN),
@@ -1120,10 +1127,10 @@
     xticklabelmode ("auto"),
     yticklabelmode ("auto"),
     zticklabelmode ("auto"),
-    color (color_values(0, 0, 0), radio_values ("flat|none|interp")),
-    xcolor (),
-    ycolor (),
-    zcolor (),
+    color (color_values (0, 0, 0), radio_values ("flat|none|interp")),
+    xcolor (color_values (0, 0, 0)),
+    ycolor (color_values (0, 0, 0)),
+    zcolor (color_values (0, 0, 0)),
     xscale (radio_values ("{linear}|log")),
     yscale (radio_values ("{linear}|log")),
     zscale (radio_values ("{linear}|log")),
@@ -2556,7 +2563,7 @@
     vertices (Matrix ()),
     facecolor (radio_values ("{flat}|none|interp")),
     facealpha (1.0),
-    edgecolor (color_values(0, 0, 0), radio_values ("flat|none|interp")),
+    edgecolor (color_values (0, 0, 0), radio_values ("flat|none|interp")),
     linestyle ("-"),
     linewidth (0.5),
     marker ("none"),
@@ -2753,7 +2760,7 @@
     cdata (Matrix ()),
     facecolor (radio_values ("{flat}|none|interp")),
     facealpha (1.0),
-    edgecolor (color_values(0, 0, 0), radio_values ("flat|none|interp")),
+    edgecolor (color_values (0, 0, 0), radio_values ("flat|none|interp")),
     linestyle ("-"),
     linewidth (0.5),
     marker ("none"),
@@ -2946,8 +2953,11 @@
   return parent_obj.get_factory_default (type () + name);
 }
 
+// We use a random value for the handle to avoid issues with plots and
+// scalar values for the first argument.
 gh_manager::gh_manager (void)
-  : handle_map (), handle_free_list (), next_handle (-1)
+  : handle_map (), handle_free_list (),
+    next_handle (-1.0 - (rand () + 1.0) / (RAND_MAX + 2.0))
 {
   handle_map[0] = graphics_object (new root_figure ());
 }
--- a/src/graphics.h.in	Tue Dec 11 01:54:19 2007 +0000
+++ b/src/graphics.h.in	Tue Dec 11 16:57:39 2007 +0000
@@ -2140,7 +2140,7 @@
   std::set<graphics_handle> handle_free_list;
 
   // The next handle available if handle_free_list is empty.
-  graphics_handle next_handle;
+  double next_handle;
 
   // The allocated figure handles.  Top of the stack is most recently
   // created.