Mercurial > hg > octave-shane
changeset 7471:86ba621332ff
Implement cdatamapping and respect to to allow correct image/imagesc rendering
author | David Bateman <dbateman@free.fr> |
---|---|
date | Tue, 12 Feb 2008 16:12:20 -0500 |
parents | ada435261879 |
children | 2d8315dcd8d2 |
files | scripts/ChangeLog scripts/image/__img__.m scripts/image/imagesc.m scripts/plot/__go_draw_axes__.m src/ChangeLog src/graphics.h.in |
diffstat | 6 files changed, 31 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,8 +1,15 @@ +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. -2008-02-08 David Bateman <dbateman@free.fr? +2008-02-08 David Bateman <dbateman@free.fr> * plot/__contour__.m: Respect the graphic handle options that are passed.
--- 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 @@ -1062,8 +1069,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")) @@ -1170,8 +1183,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,8 @@ +2008-02-12 David Bateman <dbateman@free.fr> + + * graphics.h.in: Implement the cdatamapping property in patch and + image objects. + 2008-02-12 John W. Eaton <jwe@octave.org> * pt-loop.cc (tree_simple_for_command::eval): Compute range
--- a/src/graphics.h.in +++ b/src/graphics.h.in @@ -2698,6 +2698,7 @@ data_property xdata l , Matrix () data_property ydata l , Matrix () data_property cdata l , Matrix () + radio_property cdatamapping a , "{scaled}|direct" END_PROPERTIES protected: @@ -2814,6 +2815,7 @@ data_property ydata l , Matrix () data_property zdata l , Matrix () data_property cdata l , Matrix () + radio_property cdatamapping a , "{scaled}|direct" color_property facecolor , "{flat}|none|interp" double_property facealpha , 1.0 color_property edgecolor , color_property (color_values (0, 0, 0), radio_values ("flat|none|interp"))