Mercurial > hg > octave-shane
changeset 7276:1e8e64d71e34
[project @ 2007-12-10 20:09:59 by jwe]
author | jwe |
---|---|
date | Mon, 10 Dec 2007 20:09:59 +0000 |
parents | c099705f1aa7 |
children | 0c733917b6c8 |
files | scripts/ChangeLog scripts/image/__img__.m scripts/image/image.m scripts/plot/__patch__.m src/ChangeLog src/graphics.h.in |
diffstat | 6 files changed, 56 insertions(+), 70 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,10 @@ +2007-12-10 David Bateman <dbateman@free.fr> + + * image/image.m: Rewritten to allow trailing properties to be + passed to underlying image object. + * image/__img__.m: Pass additional arguments to __go_image__. + * plot/__patch__.m: Don't set clim, rely on autoscaling. + 2007-12-10 John W. Eaton <jwe@octave.org> * plot/__go_draw_axes__.m: If we have a grid, send "set grid
--- a/scripts/image/__img__.m +++ b/scripts/image/__img__.m @@ -32,7 +32,7 @@ ## Created: July 1994 ## Adapted-By: jwe -function h = __img__ (x, y, img) +function h = __img__ (x, y, img, varargin) newplot (); @@ -53,7 +53,8 @@ ca = gca (); - tmp = __go_image__ (ca, "cdata", img, "xdata", xlim, "ydata", ylim); + tmp = __go_image__ (ca, "cdata", img, "xdata", xlim, "ydata", ylim, + varargin {:}); set (ca, "view", [0, 90]);
--- a/scripts/image/image.m +++ b/scripts/image/image.m @@ -41,57 +41,41 @@ function retval = image (varargin) - if (nargin == 0) - __image__ (gca ()); - elseif (nargin == 1) - print_usage (); - elseif (isscalar (varargin{1}) && ishandle (varargin{1})) - h = varargin{1}; - if (! strcmp (get (h, "type"), "axes")) - error ("image: expecting first argument to be an axes object"); + [ax, varargin, nargin] = __plt_get_axis_arg__ ("image", varargin{:}); + + firstnonnumeric = Inf; + for i = 1 : nargin + if (! isnumeric (varargin{i})) + firstnonnumeric = i; + break; endif - oldh = gca (); - unwind_protect - axes (h); - tmp = __image__ (h, varargin{2:end}); - unwind_protect_cleanup - axes (oldh); - end_unwind_protect + endfor + + if (nargin == 0 || firstnonnumeric == 1) + img = loadimage ("default.img"); + x = y = []; + elseif (nargin == 1 || firstnonnumeric == 2) + img = varargin{1}; + x = y = []; + elseif (nargin == 2 || firstnonnumeric == 3) + print_usage (); else - tmp = __image__ (gca (), varargin{:}); + x = varargin{1}; + y = varargin{2}; + img = varargin{3}; + firstnonnumeric = 4; endif + oldax = gca (); + unwind_protect + axes (ax); + h = __img__ (x, y, img, varargin {firstnonnumeric:end}); + unwind_protect_cleanup + axes (oldax); + end_unwind_protect + if (nargout > 0) - retval = tmp; + retval = h; endif endfunction - -function h = __image__ (ax, x, y, img) - - ## Deprecated zoom. Remove this hunk of code if old zoom argument - ## is outmoded. - if ((nargin == 3 && isscalar (y)) || nargin == 5) - warning ("image: zoom argument ignored -- use GUI features"); - endif - if (nargin == 5) - nargin = 4; - endif - if (nargin == 3 && isscalar (y)) - nargin = 2; - endif - - if (nargin == 1) - ## Load Bobbie Jo Richardson (Born 3/16/94) - img = loadimage ("default.img"); - x = y = []; - elseif (nargin == 2) - img = x; - x = y = []; - elseif (nargin == 3 || nargin > 4) - print_usage (); - endif - - h = __img__ (x, y, img); - -endfunction
--- a/scripts/plot/__patch__.m +++ b/scripts/plot/__patch__.m @@ -141,9 +141,6 @@ error ("patch: not supported"); endif - h = __go_patch__ (p); - ax = get (h, "parent"); - cargs = {}; if (have_c) if (ischar (c)) @@ -160,14 +157,6 @@ cargs{2} = "flat"; cargs{3} = "cdata"; cargs{4} = c; - clim = get (ax, "clim"); - if (c(1) < clim(1)) - set (ax, "clim", [c(1), clim(2)]) - clim(1) = c(1); - endif - if (c(1) > clim(2)) - set (ax, "clim", [clim(1), c(1)]) - endif else error ("patch: color value not valid"); endif @@ -178,17 +167,11 @@ cargs{4} = c; else ## Color Vectors - if (rows (c2) != rows (x) || rows (c2) != length (y)) error ("patch: size of x, y, and c must be equal") else cargs{1} = "facecolor"; cargs{2} = "interp"; - if (abs(max(c2(:)) - min(c2(:))) < eps) - set (ax, "clim", [c2(1)-1, c2(1)+1]) - else - set (ax, "clim", [min(c2(:)), max(c2(:))]); - endif endif endif else @@ -196,8 +179,8 @@ cargs{2} = [0, 1, 0]; endif - set (h, "xdata", x, "ydata", y, "faces", faces, "vertices", vert, - cargs{:}, varargin{iarg:end}); + h = __go_patch__ (p, "xdata", x, "ydata", y, "faces", faces, + "vertices", vert, cargs{:}, varargin{iarg:end}); if (have_z) set (h, "zdata", z); endif
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2007-12-10 David Bateman <dbateman@free.fr> + + * graphics.h.in (data_property::data): Declare as NDArray instead + of Matrix. Change all uses. + 2007-12-10 John W. Eaton <jwe@octave.org> * OPERATORS/op-cm-s.cc: Define function for el_mul with
--- a/src/graphics.h.in +++ b/src/graphics.h.in @@ -408,7 +408,13 @@ class data_property { public: - data_property (const Matrix& m = Matrix ()) + data_property (const NDArray& m = NDArray ()) + : data (m), xmin (octave_Inf), xmax (-octave_Inf), xminp (octave_Inf) + { + get_data_limits (); + } + + data_property (const Matrix& m) : data (m), xmin (octave_Inf), xmax (-octave_Inf), xminp (octave_Inf) { get_data_limits (); @@ -417,7 +423,7 @@ data_property (const octave_value& val) : data (), xmin (octave_Inf), xmax (-octave_Inf), xminp (octave_Inf) { - data = val.matrix_value (); + data = val.array_value (); get_data_limits (); } @@ -442,7 +448,7 @@ double min_pos (void) const { return xminp; } private: - Matrix data; + NDArray data; double xmin; double xmax; double xminp;