2 graphical-element.cc -- implement Graphical_element
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "graphical-element.hh"
10 #include "graphical-axis-group.hh"
13 Graphical_element::Graphical_element ()
19 Graphical_element::Graphical_element (Graphical_element const &s)
20 : dim_cache_ (s.dim_cache_)
27 Graphical_element::init ()
29 dim_cache_[X_AXIS].elt_l_ = dim_cache_[Y_AXIS].elt_l_ = this;
33 Graphical_element::absolute_coordinate (Axis a) const
35 return dim_cache_[a].absolute_coordinate ();
40 Graphical_element::absolute_offset() const
42 return Offset (absolute_coordinate (X_AXIS), absolute_coordinate (Y_AXIS));
48 Graphical_element::translate_axis (Real y, Axis a)
50 dim_cache_[a].translate (y);
54 Graphical_element::relative_coordinate (Dimension_cache*e, Axis a) const
56 return dim_cache_[a].relative_coordinate (e);
60 Graphical_element::common_group (Graphical_element const* s, Axis a) const
62 return dim_cache_[a].common_group (&s->dim_cache_[a]);
66 Graphical_element::translate (Offset offset)
68 translate_axis (offset[Y_AXIS], Y_AXIS);
69 translate_axis (offset[X_AXIS], X_AXIS);
74 Graphical_element::set_empty (bool b)
76 dim_cache_[X_AXIS].set_empty (b);
77 dim_cache_[Y_AXIS].set_empty (b);
81 Graphical_element::extent (Axis a) const
83 Dimension_cache const * d = &dim_cache_[a];
93 Graphical_element::do_print () const
103 Graphical_element::invalidate_cache (Axis a)
105 dim_cache_[a].invalidate ();
109 Graphical_element::parent_l (Axis a) const
111 Dimension_cache*d= dim_cache_[a].parent_l_;
112 return d ? d->elt_l_ : 0;
115 Graphical_element::~Graphical_element ()
120 Graphical_element::common_group (Link_array<Graphical_element> gs, Axis a) const
122 Dimension_cache * common = &dim_cache_[a];
123 for (int i=0; i < gs.size (); i++)
125 common = common->common_group (&gs[i]->dim_cache_[a]);
132 Graphical_element::name () const
134 return classname (this);