# HG changeset patch # User David Bateman # Date 1202850740 18000 # Node ID 86ba621332ff2a7d0eb76d15ba104264aa730487 # Parent ada435261879e0ce135e2468ade51f3aca8e1270 Implement cdatamapping and respect to to allow correct image/imagesc rendering diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,8 +1,15 @@ +2008-02-12 David Bateman + + * 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 * audio/wavread.m: Limit data read to end of data chunk. -2008-02-08 David Bateman * plot/__contour__.m: Respect the graphic handle options that are passed. diff --git a/scripts/image/__img__.m b/scripts/image/__img__.m --- 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]); diff --git a/scripts/image/imagesc.m b/scripts/image/imagesc.m --- 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)) diff --git a/scripts/plot/__go_draw_axes__.m b/scripts/plot/__go_draw_axes__.m --- 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, diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2008-02-12 David Bateman + + * graphics.h.in: Implement the cdatamapping property in patch and + image objects. + 2008-02-12 John W. Eaton * pt-loop.cc (tree_simple_for_command::eval): Compute range diff --git a/src/graphics.h.in b/src/graphics.h.in --- 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"))