author | Francesco Abbate <francesco.bbt@gmail.com> | 2012年08月07日 17:19:04 +0200 |
---|---|---|
committer | Francesco Abbate <francesco.bbt@gmail.com> | 2012年08月07日 17:19:04 +0200 |
commit | 5d5237a6688d733c645a1df04471545036f94c7a (patch) | |
tree | 1f2621c970ec63ef14d0d845c609d75f4d2818a4 /agg-plot/text-shape.h | |
parent | 78086498f6df8d08b540608dbf91337611864dc9 (diff) | |
download | gsl-shell-5d5237a6688d733c645a1df04471545036f94c7a.tar.gz |
-rw-r--r-- | agg-plot/text-shape.h | 18 |
diff --git a/agg-plot/text-shape.h b/agg-plot/text-shape.h index 38abf892..aadbe147 100644 --- a/agg-plot/text-shape.h +++ b/agg-plot/text-shape.h @@ -15,6 +15,7 @@ namespace draw { m_matrix.tx = x; m_matrix.ty = y; m_text_label.model_mtx(m_matrix); + compute_bounding_box(); } virtual void rewind(unsigned path_id) @@ -32,12 +33,20 @@ namespace draw { virtual void bounding_box(double *x1, double *y1, double *x2, double *y2) { + *x1 = m_bbox.x1; + *y1 = m_bbox.y1; + *x2 = m_bbox.x2; + *y2 = m_bbox.y2; + } + + void compute_bounding_box() + { const double pad = 1.0; const double tx = m_matrix.tx, ty = m_matrix.ty; - *x1 = tx - pad; - *y1 = ty - pad; - *x2 = tx + m_text_label.get_text_width() + pad; - *y2 = ty + m_text_label.get_text_height() + pad; + m_bbox.x1 = tx - pad; + m_bbox.y1 = ty - pad; + m_bbox.x2 = tx + m_text_label.get_text_width() + pad; + m_bbox.y2 = ty + m_text_label.get_text_height() + pad; } virtual str write_svg(int id, agg::rgba8 c, double h) @@ -74,6 +83,7 @@ namespace draw { agg::trans_affine m_matrix; const agg::trans_affine* m_scaling; double m_size; + agg::rect_base<double> m_bbox; }; } |