comparison src/graphics.cc @ 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 7a5aacf65f81
children 13640f7f40bb
comparison
equal deleted inserted replaced
12495:4675ce154a55 12496:245b5efb07c2
3239 axes::properties::calc_tightbox (const Matrix& init_pos) 3239 axes::properties::calc_tightbox (const Matrix& init_pos)
3240 { 3240 {
3241 Matrix pos = init_pos; 3241 Matrix pos = init_pos;
3242 graphics_object obj = gh_manager::get_object (get_parent ()); 3242 graphics_object obj = gh_manager::get_object (get_parent ());
3243 Matrix parent_bb = obj.get_properties ().get_boundingbox (true); 3243 Matrix parent_bb = obj.get_properties ().get_boundingbox (true);
3244 Matrix ext = get_extent (true); 3244 Matrix ext = get_extent (true, true);
3245 ext(1) = parent_bb(3) - ext(1) - ext(3); 3245 ext(1) = parent_bb(3) - ext(1) - ext(3);
3246 ext(0)++; 3246 ext(0)++;
3247 ext(1)++; 3247 ext(1)++;
3248 ext = convert_position (ext, "pixels", get_units (), 3248 ext = convert_position (ext, "pixels", get_units (),
3249 parent_bb.extract_n (0, 2, 1, 2)); 3249 parent_bb.extract_n (0, 2, 1, 2));
4716 4716
4717 return pos; 4717 return pos;
4718 } 4718 }
4719 4719
4720 Matrix 4720 Matrix
4721 axes::properties::get_extent (bool with_text) const 4721 axes::properties::get_extent (bool with_text, bool only_text_height) const
4722 { 4722 {
4723 graphics_xform xform = get_transform (); 4723 graphics_xform xform = get_transform ();
4724 4724
4725 Matrix ext (1, 4, 0.0); 4725 Matrix ext (1, 4, 0.0);
4726 ext(0) = octave_Inf; 4726 ext(0) = octave_Inf;
4761 { 4761 {
4762 Matrix text_ext = text_props.get_extent_matrix (); 4762 Matrix text_ext = text_props.get_extent_matrix ();
4763 Matrix text_pos = text_props.get_position ().matrix_value (); 4763 Matrix text_pos = text_props.get_position ().matrix_value ();
4764 text_pos = xform.transform (text_pos(0), text_pos(1), text_pos(2)); 4764 text_pos = xform.transform (text_pos(0), text_pos(1), text_pos(2));
4765 4765
4766 ext(0) = std::min (ext(0), text_pos(0)+text_ext(0)); 4766 bool ignore_horizontal = false;
4767 ext(1) = std::min (ext(1), text_pos(1)-text_ext(1)-text_ext(3)); 4767 bool ignore_vertical = false;
4768 ext(2) = std::max (ext(2), text_pos(0)+text_ext(0)+text_ext(2)); 4768 if (only_text_height)
4769 ext(3) = std::max (ext(3), text_pos(1)-text_ext(1)); 4769 {
4770 double text_rotation = text_props.get_rotation();
4771 if (text_rotation == 0. || text_rotation == 180.)
4772 ignore_horizontal = true;
4773 else if (text_rotation == 90. || text_rotation == 270.)
4774 ignore_vertical = true;
4775 }
4776
4777 if (! ignore_horizontal)
4778 {
4779 ext(0) = std::min (ext(0), text_pos(0)+text_ext(0));
4780 ext(2) = std::max (ext(2), text_pos(0)+text_ext(0)+text_ext(2));
4781 }
4782
4783 if (! ignore_vertical)
4784 {
4785 ext(1) = std::min (ext(1), text_pos(1)-text_ext(1)-text_ext(3));
4786 ext(3) = std::max (ext(3), text_pos(1)-text_ext(1));
4787 }
4770 } 4788 }
4771 } 4789 }
4772 } 4790 }
4773 4791
4774 ext(2) = ext(2)-ext(0); 4792 ext(2) = ext(2)-ext(0);