# HG changeset patch # User Michael Goffioul # Date 1245016194 -3600 # Node ID 3da821b161e93df42b356585b1d23ea05111db38 # Parent d50c3d8efe7114b1199f3b60304e249d3e4892ae imported patch ticklabel diff -r d50c3d8efe71 -r 3da821b161e9 src/ChangeLog --- a/src/ChangeLog Sun Jun 14 16:10:12 2009 -0400 +++ b/src/ChangeLog Sun Jun 14 22:49:54 2009 +0100 @@ -191,6 +191,25 @@ * variables.cc (do_who): Only output symbols with a defined value. +2009-06-14 Michael Goffioul + + * graphics.h.in (axes::properties::xtick, axes::properties::ytick, + axes::properties::ztick, axes::properties::xticklabelmode, + axes::properties::yticklabelmode, axes::properties::zticklabelmode): + Add 'u' modifier to enable updaters. + (axes::properties::calc_ticklabels): New function to update tick + labels. + (axes::properties::update_xtick, axes::properties::update_ytick, + axes::properties::update_ztick, + axes::properties::update_xticklabelmode, + axes::properties::update_yticklabelmode, + axes::properties::update_zticklabelmode): Add updaters to update tick + labels correctly. + (axes::properties::update_xlim, axes::properties::update_ylim, + axes::properties::update_zlim): Update tick labels. + * graphics.cc (axes::properties::calc_ticklabels): New function to + update tick labels. + 2009-05-22 Michael Goffioul * toplev.h (main_loop): Tag with OCTINTERP_API. diff -r d50c3d8efe71 -r 3da821b161e9 src/graphics.cc --- a/src/graphics.cc Sun Jun 14 16:10:12 2009 -0400 +++ b/src/graphics.cc Sun Jun 14 22:49:54 2009 +0100 @@ -3424,6 +3424,24 @@ ticks = tmp_ticks; } +void +axes::properties::calc_ticklabels (const array_property& ticks, + any_property& labels, bool logscale) +{ + Matrix values = ticks.get ().matrix_value (); + Cell c (values.dims ()); + std::ostringstream os; + + for (int i = 0; i < values.numel (); i++) + { + os.str (std::string ()); + os << values(i); + c(i) = os.str (); + } + + labels = c; +} + static void get_children_limits (double& min_val, double& max_val, double& min_pos, const Matrix& kids, char limit_type) diff -r d50c3d8efe71 -r 3da821b161e9 src/graphics.h.in --- a/src/graphics.h.in Sun Jun 14 16:10:12 2009 -0400 +++ b/src/graphics.h.in Sun Jun 14 22:49:54 2009 +0100 @@ -2662,9 +2662,9 @@ bool_property xminorgrid , "off" bool_property yminorgrid , "off" bool_property zminorgrid , "off" - row_vector_property xtick m , default_axes_tick () - row_vector_property ytick m , default_axes_tick () - row_vector_property ztick m , default_axes_tick () + row_vector_property xtick mu , default_axes_tick () + row_vector_property ytick mu , default_axes_tick () + row_vector_property ztick mu , default_axes_tick () radio_property xtickmode , "{auto}|manual" radio_property ytickmode , "{auto}|manual" radio_property ztickmode , "{auto}|manual" @@ -2675,9 +2675,9 @@ any_property xticklabel m , "" any_property yticklabel m , "" any_property zticklabel m , "" - radio_property xticklabelmode , "{auto}|manual" - radio_property yticklabelmode , "{auto}|manual" - radio_property zticklabelmode , "{auto}|manual" + radio_property xticklabelmode u , "{auto}|manual" + radio_property yticklabelmode u , "{auto}|manual" + radio_property zticklabelmode u , "{auto}|manual" radio_property interpreter , "tex|{none}|latex" color_property color , color_property (color_values (1, 1, 1), radio_values ("none")) color_property xcolor , color_values (0, 0, 0) @@ -2747,12 +2747,45 @@ void update_ydir (void) { update_camera (); } void update_zdir (void) { update_camera (); } + void update_xtick (void) + { + if (xticklabelmode.is ("auto")) + calc_ticklabels (xtick, xticklabel, xscale.is ("log")); + } + void update_ytick (void) + { + if (yticklabelmode.is ("auto")) + calc_ticklabels (ytick, yticklabel, yscale.is ("log")); + } + void update_ztick (void) + { + if (zticklabelmode.is ("auto")) + calc_ticklabels (ztick, zticklabel, zscale.is ("log")); + } + + void update_xticklabelmode (void) + { + if (xticklabelmode.is ("auto")) + calc_ticklabels (xtick, xticklabel, xscale.is ("log")); + } + void update_yticklabelmode (void) + { + if (yticklabelmode.is ("auto")) + calc_ticklabels (ytick, yticklabel, yscale.is ("log")); + } + void update_zticklabelmode (void) + { + if (zticklabelmode.is ("auto")) + calc_ticklabels (ztick, zticklabel, zscale.is ("log")); + } + void sync_positions (void); void update_outerposition (void) { sync_positions ();} void update_position (void) { sync_positions (); } double calc_tick_sep (double minval, double maxval); void calc_ticks_and_lims (array_property& lims, array_property& ticks, bool limmode_is_auto, bool is_logscale); + void calc_ticklabels (const array_property& ticks, any_property& labels, bool is_logscale); void fix_limits (array_property& lims) { if (lims.get ().is_empty ()) @@ -2780,6 +2813,8 @@ { if (xtickmode.is ("auto")) calc_ticks_and_lims (xlim, xtick, xlimmode.is ("auto"), xscale.is ("log")); + if (xticklabelmode.is ("auto")) + calc_ticklabels (xtick, xticklabel, xscale.is ("log")); fix_limits (xlim); @@ -2791,6 +2826,8 @@ { if (ytickmode.is ("auto")) calc_ticks_and_lims (ylim, ytick, ylimmode.is ("auto"), yscale.is ("log")); + if (yticklabelmode.is ("auto")) + calc_ticklabels (ytick, yticklabel, yscale.is ("log")); fix_limits (ylim); @@ -2802,6 +2839,8 @@ { if (ztickmode.is ("auto")) calc_ticks_and_lims (zlim, ztick, zlimmode.is ("auto"), zscale.is ("log")); + if (zticklabelmode.is ("auto")) + calc_ticklabels (ztick, zticklabel, zscale.is ("log")); fix_limits (zlim);