Mercurial > hg > octave-lyh
changeset 11635:e08d2fff0d58 release-3-0-x
Implement cdatamapping and respect to to allow correct image/imagesc rendering
author | David Bateman <dbateman@free.fr> |
---|---|
date | Tue, 12 Feb 2008 16:09:13 -0500 |
parents | 83f4996e8d01 |
children | 2be7477f470a |
files | scripts/ChangeLog scripts/image/__img__.m scripts/image/imagesc.m scripts/plot/__go_draw_axes__.m src/ChangeLog src/graphics.cc src/graphics.h.in |
diffstat | 7 files changed, 66 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,10 @@ +2008-02-12 David Bateman <dbateman@free.fr> + + * plot/__go_draw_axes__.m: Use the cdatamapping property to set + the cbrange. + * plot/__img__.m: Set cdatamapping to "direct". + * plot/imagesc.m: Set cdatamapping to "scaled". + 2008-02-08 Julien Pommier <pommier@pianoteq.com> * audio/wavread.m: Limit data read to end of data chunk.
--- a/scripts/image/__img__.m +++ b/scripts/image/__img__.m @@ -54,7 +54,7 @@ ca = gca (); tmp = __go_image__ (ca, "cdata", img, "xdata", xlim, "ydata", ylim, - varargin {:}); + "cdatamapping", "direct", varargin {:}); set (ca, "view", [0, 90]);
--- a/scripts/image/imagesc.m +++ b/scripts/image/imagesc.m @@ -109,6 +109,7 @@ endif ret = image (ax, x, y, A); + set (ret, "cdatamapping", "scaled") ## use given limits or guess them from the matrix if (length (limits) == 2 && limits(2) >= limits(1))
--- a/scripts/plot/__go_draw_axes__.m +++ b/scripts/plot/__go_draw_axes__.m @@ -291,6 +291,7 @@ yautoscale = strcmpi (axis_obj.ylimmode, "auto"); zautoscale = strcmpi (axis_obj.zlimmode, "auto"); cautoscale = strcmpi (axis_obj.climmode, "auto"); + cdatadirect = false; kids = axis_obj.children; @@ -337,6 +338,9 @@ if (use_gnuplot_for_images) + if (strcmp (obj.cdatamapping, "direct")) + cdatadirect = true; + endif fputs (plot_stream, "set border front;\n"); data_idx++; is_image_data(data_idx) = true; @@ -501,6 +505,9 @@ if (! isempty (obj.cdata)) cdat = obj.cdata; + if (strcmp (obj.cdatamapping, "direct")) + cdatadirect = true; + endif else cdat = []; endif @@ -1051,8 +1058,14 @@ fprintf (plot_stream, "set zrange [%.15e:%.15e] %s;\n", zlim, zdir); endif + cmap = parent_figure_obj.colormap; + cmap_sz = rows(cmap); if (! any (isinf (clim))) - fprintf (plot_stream, "set cbrange [%g:%g];\n", clim); + if (cdatadirect) + fprintf (plot_stream, "set cbrange [1:%d];\n", cmap_sz); + else + fprintf (plot_stream, "set cbrange [%g:%g];\n", clim); + endif endif if (strcmpi (axis_obj.box, "on")) @@ -1159,8 +1172,6 @@ endfor endif - cmap = parent_figure_obj.colormap; - cmap_sz = rows(cmap); if (length(cmap) > 0) if (have_newer_gnuplot) fprintf (plot_stream,
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2008-02-12 David Bateman <dbateman@free.fr? + + * graphics.h.in: Implement the cdatamapping property in patch, + surface and image objects. + * graphics.cc: ditto. + 2008-02-12 John W. Eaton <jwe@octave.org> * pt-loop.cc (tree_simple_for_command::eval): Compute range
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -2464,7 +2464,8 @@ : base_properties (go_name, mh, p), xdata (Matrix ()), ydata (Matrix ()), - cdata (Matrix ()) + cdata (Matrix ()), + cdatamapping (radio_values ("{scaled}|direct")) { } void @@ -2490,6 +2491,8 @@ set_ydata (val); else if (name.compare ("cdata")) set_cdata (val); + else if (name.compare ("cdatamapping")) + set_cdatamapping (val); else { modified = false; @@ -2513,6 +2516,7 @@ m.assign ("xdata", xdata); m.assign ("ydata", ydata); m.assign ("cdata", cdata); + m.assign ("cdatamapping", cdatamapping); return m; } @@ -2538,6 +2542,8 @@ retval = ydata; else if (name.compare ("cdata")) retval = cdata; + else if (name.compare ("cdatamapping")) + retval = cdatamapping; else warning ("get: invalid property `%s'", name.c_str ()); @@ -2552,6 +2558,7 @@ m["xdata"] = Matrix (); m["ydata"] = Matrix (); m["cdata"] = Matrix (); + m["cdatamapping"] = radio_property (radio_values ("{scaled}|direct")); return m; } @@ -2567,6 +2574,7 @@ ydata (Matrix ()), zdata (Matrix ()), cdata (Matrix ()), + cdatamapping (radio_values ("{scaled}|direct")), faces (Matrix ()), vertices (Matrix ()), facecolor (radio_values ("{flat}|none|interp")), @@ -2607,6 +2615,8 @@ set_zdata (val); else if (name.compare ("cdata")) set_cdata (val); + else if (name.compare ("cdatamapping")) + set_cdatamapping (val); else if (name.compare ("faces")) set_faces (val); else if (name.compare ("vertices")) @@ -2657,6 +2667,7 @@ m.assign ("ydata", ydata); m.assign ("zdata", zdata); m.assign ("cdata", cdata); + m.assign ("cdatamapping", cdatamapping); m.assign ("faces", faces); m.assign ("vertices", vertices); m.assign ("facecolor", facecolor); @@ -2697,6 +2708,8 @@ retval = zdata; else if (name.compare ("cdata")) retval = cdata; + else if (name.compare ("cdatamapping")) + retval = cdatamapping; else if (name.compare ("faces")) retval = faces; else if (name.compare ("vertices")) @@ -2738,6 +2751,7 @@ m["ydata"] = Matrix (); m["zdata"] = Matrix (); m["cdata"] = Matrix (); + m["cdatamapping"] = radio_property (radio_values ("{scaled}|direct")); m["faces"] = Matrix (); m["vertices"] = Matrix (); m["facecolor"] = color_property (); @@ -2766,6 +2780,7 @@ ydata (Matrix ()), zdata (Matrix ()), cdata (Matrix ()), + cdatamapping (radio_values ("{scaled}|direct")), facecolor (radio_values ("{flat}|none|interp")), facealpha (1.0), edgecolor (color_values (0, 0, 0), radio_values ("flat|none|interp")), @@ -2804,6 +2819,8 @@ set_zdata (val); else if (name.compare ("cdata")) set_cdata (val); + else if (name.compare ("cdatamapping")) + set_cdatamapping (val); else if (name.compare ("facecolor")) set_facecolor (val); else if (name.compare ("facealpha")) @@ -2850,6 +2867,7 @@ m.assign ("ydata", ydata); m.assign ("zdata", zdata); m.assign ("cdata", cdata); + m.assign ("cdatamapping", cdatamapping); m.assign ("facecolor", facecolor); m.assign ("facealpha", facealpha); m.assign ("edgecolor", edgecolor); @@ -2888,6 +2906,8 @@ retval = zdata; else if (name.compare ("cdata")) retval = cdata; + else if (name.compare ("cdatamapping")) + retval = cdatamapping; else if (name.compare ("facecolor")) retval = facecolor; else if (name.compare ("facealpha")) @@ -2925,6 +2945,7 @@ m["ydata"] = Matrix (); m["zdata"] = Matrix (); m["cdata"] = Matrix (); + m["cdatamapping"] = radio_property (radio_values ("{scaled}|direct")); m["facecolor"] = color_property (); m["facealpha"] = 1.0; m["edgecolor"] = color_property ("black");
--- a/src/graphics.h.in +++ b/src/graphics.h.in @@ -738,6 +738,12 @@ return data_property (); } + virtual radio_property get_cdatamapping (void) const + { + error ("get: invalid property \"cdatamapping\""); + return radio_property (); + } + protected: std::string tag; std::string type; @@ -1029,6 +1035,12 @@ return props.get_cdata (); } + radio_property get_cdatamapping (void) const + { + const base_properties& props = get_properties (); + return props.get_cdatamapping (); + } + private: base_graphics_object *rep; }; @@ -1749,6 +1761,7 @@ data_property xdata l data_property ydata l data_property cdata l + radio_property cdatamapping a END_PROPERTIES static std::string go_name; @@ -1844,6 +1857,7 @@ data_property ydata l data_property zdata l data_property cdata l + radio_property cdatamapping a octave_value faces octave_value vertices color_property facecolor a @@ -1952,6 +1966,7 @@ data_property ydata l data_property zdata l data_property cdata l + radio_property cdatamapping a color_property facecolor a octave_value facealpha color_property edgecolor a