# HG changeset patch # User Michael Goffioul # Date 1204641278 -3600 # Node ID f317f14516cbedbe26d85bd9cfe1ed0b7285edaa # Parent 228858e69bd1f17b336765b2d776688390e62de1 Add zoom stack facility in axes object. diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -31,6 +31,18 @@ 2008-06-04 Michael Goffioul + * graphics.h.in (axes::properties::pixel2coord): Center Z coordinate + on x_zlim instead of 0. + (axes::properties::zoom, axes::properties::unzoom, + axes::properties::clear_zoom_stack): New methods to handle zoom stack. + (axes::properties::zoom_stack): New field to hold zoom stack. + (axes::properties::update_xlim, axes::properites::update_ylim): + Additional do_clr_zoom argument to control whether the zoom stack will + be cleared. + (axes::properties::update_zlim): Clear zoom stack. + * graphics.cc (axes::properties::zoom, axes::properties::unzoom, + axes::properties::clear_zoom_stack): New methods to handle zoom stack. + * genprops.awk (emit_source): Use all properties in factory defaults. * graphics.h.in (base_property::base_property): Set internal counter diff --git a/src/graphics.cc b/src/graphics.cc --- a/src/graphics.cc +++ b/src/graphics.cc @@ -2893,6 +2893,53 @@ unwind_protect::run (); } +void +axes::properties::zoom (const Matrix& xl, const Matrix& yl) +{ + zoom_stack.push_front (xlimmode.get ()); + zoom_stack.push_front (xlim.get ()); + zoom_stack.push_front (ylimmode.get ()); + zoom_stack.push_front (ylim.get ()); + + xlim = xl; + xlimmode = "manual"; + ylim = yl; + ylimmode = "manual"; + + update_transform (); + update_xlim (false); + update_ylim (false); +} + +void +axes::properties::unzoom (void) +{ + if (zoom_stack.size () >= 4) + { + ylim = zoom_stack.front (); + zoom_stack.pop_front (); + ylimmode = zoom_stack.front (); + zoom_stack.pop_front (); + xlim = zoom_stack.front (); + zoom_stack.pop_front (); + xlimmode = zoom_stack.front (); + zoom_stack.pop_front (); + + update_transform (); + update_xlim (false); + update_ylim (false); + } +} + +void +axes::properties::clear_zoom_stack (void) +{ + while (zoom_stack.size () > 4) + zoom_stack.pop_front (); + + unzoom (); +} + // --------------------------------------------------------------------- // Note: "line" code is entirely auto-generated diff --git a/src/graphics.h.in b/src/graphics.h.in --- a/src/graphics.h.in +++ b/src/graphics.h.in @@ -2546,17 +2546,21 @@ Matrix get_transform_zlim (void) const { return x_zlim; } ColumnVector pixel2coord (double px, double py) const - { return get_transform ().untransform (px, py, 0); } + { return get_transform ().untransform (px, py, (x_zlim(0)+x_zlim(1))/2); } ColumnVector coord2pixel (double x, double y, double z) const { return get_transform ().transform (x, y, z); } + void zoom (const Matrix& xl, const Matrix& yl); + void unzoom (void); + void clear_zoom_stack (void); private: scaler sx, sy, sz; Matrix x_render, x_render_inv; Matrix x_gl_mat1, x_gl_mat2; Matrix x_zlim; + std::list zoom_stack; // See the genprops.awk script for an explanation of the // properties declarations. @@ -2733,19 +2737,27 @@ public: Matrix get_axis_limits (double xmin, double xmax, double min_pos, bool logscale); - void update_xlim (void) + + void update_xlim (bool do_clr_zoom = true) { if (xtickmode.is ("auto")) calc_ticks_and_lims (xlim, xtick, xlimmode.is ("auto")); + fix_limits (xlim); + + if (do_clr_zoom) + zoom_stack.clear (); } - void update_ylim (void) + void update_ylim (bool do_clr_zoom = true) { if (ytickmode.is ("auto")) calc_ticks_and_lims (ylim, ytick, ylimmode.is ("auto")); fix_limits (ylim); + + if (do_clr_zoom) + zoom_stack.clear (); } void update_zlim (void) @@ -2754,6 +2766,8 @@ calc_ticks_and_lims (zlim, ztick, zlimmode.is ("auto")); fix_limits (zlim); + + zoom_stack.clear (); } };