changeset 14413:4f160344236a

2011-04-26 Daniel Wagenaar <daw@caltech.edu> * graphics.cc: Modified the text::properties::get_extent method to return correct (x0,y0,w,h). Added FIXME comment to text::properties::get_extent_matrix method, and general comments to text::properties::update_text_extent method.
author Ben Abbott <bpabbott@mac.com>
date Sat, 25 Feb 2012 19:33:28 -0500
parents c4a2eac243b4
children 382b6790eaee
files src/graphics.cc
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/graphics.cc	Sat Feb 25 17:30:44 2012 -0500
+++ b/src/graphics.cc	Sat Feb 25 19:33:28 2012 -0500
@@ -6882,13 +6882,21 @@
 Matrix
 text::properties::get_extent_matrix (void) const
 {
+  // FIXME: Should this function also add the (x,y) base position?
   return extent.get ().matrix_value ();
 }
 
 octave_value
 text::properties::get_extent (void) const
 {
+  // FIXME: This doesn't work right for 3D plots.
+  // (It doesn't in Matlab either, at least not in version 6.5.)
   Matrix m = extent.get ().matrix_value ();
+  Matrix pos = get_position ().matrix_value ();
+  Matrix p = convert_text_position (pos, *this, get_units (), "pixels");
+
+  m(0) += p(0);
+  m(1) += p(1);
 
   return convert_text_position (m, *this, "pixels", get_units ());
 }
@@ -6936,6 +6944,10 @@
 
   renderer.text_to_pixels (sv.join ("\n"), pixels, bbox,
                            halign, valign, get_rotation ());
+  /* The bbox is relative to the text's position.
+     We'll leave it that way, because get_position() does not return
+     valid results when the text is first constructed.
+     Conversion to proper coordinates is performed in get_extent. */
   set_extent (bbox);
 
 #endif