Mercurial > hg > octave-lojdl
changeset 7213:4612ef369abb
[project @ 2007-11-29 01:57:10 by jwe]
author | jwe |
---|---|
date | Thu, 29 Nov 2007 01:57:11 +0000 |
parents | 720c2b4271f8 |
children | 86d0b16f2bb2 |
files | scripts/ChangeLog scripts/plot/__go_draw_axes__.m src/graphics.cc src/graphics.h.in |
diffstat | 4 files changed, 96 insertions(+), 104 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2007-11-28 John W. Eaton <jwe@octave.org> + + * plot/__go_draw_axes__.m (get_data_limits): Delete unused arg TX. + 2007-11-28 Michael Goffioul <michael.goffioul@gmail.com> * plot/drawnow.m: Fix typo.
--- a/scripts/plot/__go_draw_axes__.m +++ b/scripts/plot/__go_draw_axes__.m @@ -252,13 +252,13 @@ xmin = ymin = zmin = cmin = Inf; ## This has to be done here as some of the code below depends on the - ## final clim + ## final clim. if (cautoscale) for i = 1:length (kids) obj = get (kids(i)); if (isfield (obj, "cdata")) - [cmin, cmax, cminp] = get_data_limits (cmin, cmax, cminp, - obj.cdata(:)); + cdat = obj.cdata(:); + [cmin, cmax, cminp] = get_data_limits (cmin, cmax, cminp, cdat); endif endfor if (cmin == cmax) @@ -424,15 +424,31 @@ xudat = xudat(:); endif if (yerr) - ylo = ydat-ldat; - yhi = ydat+udat; + if (isempty (ldat)) + ylo = ydat; + else + ylo = ydat-ldat; + endif + if (isempty (udat)) + yhi = ydat; + else + yhi = ydat+udat; + endif if (yautoscale) ty = [ydat; ylo; yhi]; [ymin, ymax, yminp] = get_data_limits (ymin, ymax, yminp, ty); endif if (xerr) - xlo = xdat-xldat; - xhi = xdat+xudat; + if (isempty (xldat)) + xlo = xdat; + else + xlo = xdat-xldat; + endif + if (isempty (xudat)) + xhi = xdat; + else + xhi = xdat+xudat; + endif if (xautoscale) tx = [xdat; xlo; xhi]; [xmin, xmax, xminp] = get_data_limits (xmin, xmax, xminp, tx); @@ -441,25 +457,30 @@ usingclause{data_idx} = "using ($1):($2):($3):($4):($5):($6)"; withclause{data_idx} = "with xyerrorbars"; else - ## Obtain the limits based on the exact x values. if (xautoscale) - [xmin, xmax, xminp] = get_data_limits (xmin, xmax, - xminp, xdat); + [xmin, xmax, xminp] = get_data_limits (xmin, xmax, xminp, xdat); endif data{data_idx} = [xdat, ydat, ylo, yhi]'; usingclause{data_idx} = "using ($1):($2):($3):($4)"; withclause{data_idx} = "with yerrorbars"; endif elseif (xerr) - xlo = xdat-xldat; - xhi = xdat+xudat; + if (isempty (xldat)) + xlo = xdat; + else + xlo = xdat-xldat; + endif + if (isempty (xudat)) + xhi = xdat; + else + xhi = xdat+xudat; + endif if (xautoscale) tx = [xdat; xlo; xhi]; [xmin, xmax, xminp] = get_data_limits (xmin, xmax, xminp, tx); endif if (yautoscale) - [ymin, ymax, yminp] = get_data_limits (ymin, ymax, - yminp, ydat, ty); + [ymin, ymax, yminp] = get_data_limits (ymin, ymax, yminp, ydat); endif data{data_idx} = [xdat, ydat, xlo, xhi]'; usingclause{data_idx} = "using ($1):($2):($3):($4)"; @@ -1255,21 +1276,14 @@ endfunction -function [xmin, xmax, xminp] = get_data_limits (xmin, xmax, xminp, xdat, tx) - if (! (isempty (xdat) || (nargin > 4 && isempty (tx)))) +function [xmin, xmax, xminp] = get_data_limits (xmin, xmax, xminp, xdat) + if (! isempty (xdat)) xdat = xdat(! isinf (xdat)); xmin = min (xmin, min (xdat)); xmax = max (xmax, max (xdat)); - if (nargin == 5) - tx = tx(! isinf (xdat) & tx > 0); - if (! isempty (tx)) - xminp = min (xminp, min (tx)); - endif - else - tmp = min (xdat(xdat > 0)); - if (! isempty (tmp)) - xminp = min (xminp, tmp); - endif + tmp = min (xdat(xdat > 0)); + if (! isempty (tmp)) + xminp = min (xminp, tmp); endif endif endfunction
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -1977,8 +1977,7 @@ m["markerfacecolor"] = "none"; m["markersize"] = 1; m["keylabel"] = ""; - m["interpreter"] = - radio_property (radio_values ("{tex}|none|latex")); + m["interpreter"] = radio_property (radio_values ("{tex}|none|latex")); return m; } @@ -2132,12 +2131,9 @@ m["color"] = Matrix (1, 3, 1.0); m["fontname"] = "Helvetica"; m["fontsize"] = 10; - m["fontangle"] = - radio_property (radio_values ("{normal}|italic|oblique")); - m["fontweight"] = - radio_property (radio_values ("{normal}|bold|demi|light")); - m["interpreter"] = - radio_property (radio_values ("{tex}|none|latex")); + m["fontangle"] = radio_property (radio_values ("{normal}|italic|oblique")); + m["fontweight"] = radio_property (radio_values ("{normal}|bold|demi|light")); + m["interpreter"] = radio_property (radio_values ("{tex}|none|latex")); return m; } @@ -2149,9 +2145,9 @@ image::properties::properties (const graphics_handle& mh, const graphics_handle& p) : base_properties (go_name, mh, p), - cdata (Matrix ()), xdata (Matrix ()), - ydata (Matrix ()) + ydata (Matrix ()), + cdata (Matrix ()) { } void @@ -2171,12 +2167,12 @@ __modified__ = val.bool_value (); modified = false; } - else if (name.compare ("cdata")) - set_cdata (val); else if (name.compare ("xdata")) set_xdata (val); else if (name.compare ("ydata")) set_ydata (val); + else if (name.compare ("cdata")) + set_cdata (val); else { modified = false; @@ -2197,9 +2193,9 @@ m.assign ("parent", parent.as_octave_value ()); m.assign ("children", children); m.assign ("__modified__", __modified__); - m.assign ("cdata", cdata); m.assign ("xdata", xdata); m.assign ("ydata", ydata); + m.assign ("cdata", cdata); return m; } @@ -2219,12 +2215,12 @@ retval = children; else if (name.compare ("__modified__")) retval = __modified__; - else if (name.compare ("cdata")) - retval = cdata; else if (name.compare ("xdata")) retval = xdata; else if (name.compare ("ydata")) retval = ydata; + else if (name.compare ("cdata")) + retval = cdata; else warning ("get: invalid property `%s'", name.c_str ()); @@ -2236,9 +2232,9 @@ { property_list::pval_map_type m; - m["cdata"] = Matrix (); m["xdata"] = Matrix (); m["ydata"] = Matrix (); + m["cdata"] = Matrix (); return m; } @@ -2250,10 +2246,10 @@ patch::properties::properties (const graphics_handle& mh, const graphics_handle& p) : base_properties (go_name, mh, p), - cdata (Matrix ()), xdata (Matrix ()), ydata (Matrix ()), zdata (Matrix ()), + cdata (Matrix ()), faces (Matrix ()), vertices (Matrix ()), facecolor (radio_values ("{flat}|none|interp")), @@ -2286,14 +2282,14 @@ __modified__ = val.bool_value (); modified = false; } - else if (name.compare ("cdata")) - set_cdata (val); else if (name.compare ("xdata")) set_xdata (val); else if (name.compare ("ydata")) set_ydata (val); else if (name.compare ("zdata")) set_zdata (val); + else if (name.compare ("cdata")) + set_cdata (val); else if (name.compare ("faces")) set_faces (val); else if (name.compare ("vertices")) @@ -2340,10 +2336,10 @@ m.assign ("parent", parent.as_octave_value ()); m.assign ("children", children); m.assign ("__modified__", __modified__); - m.assign ("cdata", cdata); m.assign ("xdata", xdata); m.assign ("ydata", ydata); m.assign ("zdata", zdata); + m.assign ("cdata", cdata); m.assign ("faces", faces); m.assign ("vertices", vertices); m.assign ("facecolor", facecolor); @@ -2376,14 +2372,14 @@ retval = children; else if (name.compare ("__modified__")) retval = __modified__; - else if (name.compare ("cdata")) - retval = cdata; else if (name.compare ("xdata")) retval = xdata; else if (name.compare ("ydata")) retval = ydata; else if (name.compare ("zdata")) retval = zdata; + else if (name.compare ("cdata")) + retval = cdata; else if (name.compare ("faces")) retval = faces; else if (name.compare ("vertices")) @@ -2421,10 +2417,10 @@ { property_list::pval_map_type m; - m["cdata"] = Matrix (); m["xdata"] = Matrix (); m["ydata"] = Matrix (); m["zdata"] = Matrix (); + m["cdata"] = Matrix (); m["faces"] = Matrix (); m["vertices"] = Matrix (); m["facecolor"] = color_property (); @@ -2437,8 +2433,7 @@ m["markerfacecolor"] = "none"; m["markersize"] = 1; m["keylabel"] = ""; - m["interpreter"] = - radio_property (radio_values ("{tex}|none|latex")); + m["interpreter"] = radio_property (radio_values ("{tex}|none|latex")); return m; } @@ -2623,8 +2618,7 @@ m["markerfacecolor"] = "none"; m["markersize"] = 1; m["keylabel"] = ""; - m["interpreter"] = - radio_property (radio_values ("{tex}|none|latex")); + m["interpreter"] = radio_property (radio_values ("{tex}|none|latex")); return m; }
--- a/src/graphics.h.in +++ b/src/graphics.h.in @@ -412,14 +412,19 @@ { public: data_property (const Matrix& m = Matrix ()) - : data (m), lo (min_val (m)), hi (max_val (m)) { } + : data (m), min_val (octave_Inf), max_val (-octave_Inf), + min_pos (octave_Inf) + { + get_data_limits (); + } data_property (const octave_value& val) + : data (), min_val (octave_Inf), max_val (-octave_Inf), + min_pos (octave_Inf) { data = val.matrix_value (); - lo = min_val (data); - hi = max_val (data); + get_data_limits (); } data_property& operator = (const data_property& a) @@ -427,72 +432,47 @@ if (&a != this) { data = a.data; - lo = a.lo; - hi = a.hi; + min_val = a.min_val; + max_val = a.max_val; + min_pos = a.min_pos; } return *this; } - data_property& operator = (const octave_value& val) - { - data = val.matrix_value (); - - lo = min_val (data); - hi = max_val (data); - - return *this; - } - operator octave_value (void) const { return data; } private: Matrix data; - double lo; - double hi; - - static double min_val (const Matrix& m) + double min_val; + double max_val; + double min_pos; + + void get_data_limits (void) { - double retval = octave_NaN; - - octave_idx_type nel = m.numel (); + octave_idx_type nel = data.numel (); if (nel > 0) { - retval = octave_Inf; + const double *d = data.data (); for (octave_idx_type i = 0; i < nel; i++) { - double d = m(i); - - if (! isnan (d) && m(i) < retval) - retval = d; + double val = d[i]; + + if (! (xisinf (val) || xisnan (val))) + { + if (val < min_val) + min_val = val; + + if (val > max_val) + max_val = val; + + if (val > 0 && val < min_pos) + min_pos = val; + } } } - - return retval; - } - - static double max_val (const Matrix& m) - { - double retval = octave_NaN; - - octave_idx_type nel = m.numel (); - - if (nel > 0) - { - retval = -octave_Inf; - - for (octave_idx_type i = 0; i < nel; i++) - { - double d = m(i); - - if (! isnan (d) && m(i) > retval) - retval = d; - } - } - - return retval; } };