Mercurial > hg > octave-lojdl
changeset 12496:245b5efb07c2
fix axes position synchronization for long text objects
author | Konstantinos Poulios <logari81@gmail.com> |
---|---|
date | Thu, 03 Mar 2011 14:04:19 +0100 |
parents | 4675ce154a55 |
children | 1536ed546219 |
files | src/ChangeLog src/graphics.cc src/graphics.h.in |
diffstat | 3 files changed, 34 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2011-03-03 Konstantinos Poulios <logari81@googlemail.com> + + * graphics.h.in (axes::properties::get_extent): Add new optional + argument for ignoring the length of text objects. + * graphics.cc (axes::properties::get_extent): Add the possibility + of ignoring the length of text objects. + (axes::properties::calc_tightbox): Take only text height into + account for the calculation of the tight box. + 2011-02-26 Konstantinos Poulios <logari81@googlemail.com> * DLD-FUNCTIONS/__init_fltk__.cc (plot_window::plot_window):
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -3241,7 +3241,7 @@ Matrix pos = init_pos; graphics_object obj = gh_manager::get_object (get_parent ()); Matrix parent_bb = obj.get_properties ().get_boundingbox (true); - Matrix ext = get_extent (true); + Matrix ext = get_extent (true, true); ext(1) = parent_bb(3) - ext(1) - ext(3); ext(0)++; ext(1)++; @@ -4718,7 +4718,7 @@ } Matrix -axes::properties::get_extent (bool with_text) const +axes::properties::get_extent (bool with_text, bool only_text_height) const { graphics_xform xform = get_transform (); @@ -4763,10 +4763,28 @@ Matrix text_pos = text_props.get_position ().matrix_value (); text_pos = xform.transform (text_pos(0), text_pos(1), text_pos(2)); - ext(0) = std::min (ext(0), text_pos(0)+text_ext(0)); - ext(1) = std::min (ext(1), text_pos(1)-text_ext(1)-text_ext(3)); - ext(2) = std::max (ext(2), text_pos(0)+text_ext(0)+text_ext(2)); - ext(3) = std::max (ext(3), text_pos(1)-text_ext(1)); + bool ignore_horizontal = false; + bool ignore_vertical = false; + if (only_text_height) + { + double text_rotation = text_props.get_rotation(); + if (text_rotation == 0. || text_rotation == 180.) + ignore_horizontal = true; + else if (text_rotation == 90. || text_rotation == 270.) + ignore_vertical = true; + } + + if (! ignore_horizontal) + { + ext(0) = std::min (ext(0), text_pos(0)+text_ext(0)); + ext(2) = std::max (ext(2), text_pos(0)+text_ext(0)+text_ext(2)); + } + + if (! ignore_vertical) + { + ext(1) = std::min (ext(1), text_pos(1)-text_ext(1)-text_ext(3)); + ext(3) = std::max (ext(3), text_pos(1)-text_ext(1)); + } } } }
--- a/src/graphics.h.in +++ b/src/graphics.h.in @@ -3077,7 +3077,7 @@ const scaler& get_z_scaler (void) const { return sz; } Matrix get_boundingbox (bool internal = false) const; - Matrix get_extent (bool with_text = false) const; + Matrix get_extent (bool with_text = false, bool only_text_height=false) const; void update_boundingbox (void) {