2 graphical-element.cc -- implement Graphical_element
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "graphical-element.hh"
10 #include "graphical-axis-group.hh"
14 Graphical_element::empty_b () const
16 return dim_cache_[X_AXIS].empty_b () && dim_cache_[Y_AXIS].empty_b ();
19 Graphical_element::Graphical_element ()
24 Graphical_element::Graphical_element (Graphical_element const &s)
25 : dim_cache_ (s.dim_cache_)
31 Graphical_element::init ()
33 dim_cache_[X_AXIS].elt_l_ = dim_cache_[Y_AXIS].elt_l_ = this;
37 Graphical_element::absolute_coordinate (Axis a) const
39 return dim_cache_[a].absolute_coordinate ();
44 Graphical_element::absolute_offset() const
46 return Offset (absolute_coordinate (X_AXIS), absolute_coordinate (Y_AXIS));
52 Graphical_element::translate_axis (Real y, Axis a)
54 dim_cache_[a].translate (y);
58 Graphical_element::relative_coordinate (Dimension_cache*e, Axis a) const
60 return dim_cache_[a].relative_coordinate (e);
64 Graphical_element::common_group (Graphical_element const* s, Axis a) const
66 return dim_cache_[a].common_group (&s->dim_cache_[a]);
70 Graphical_element::translate (Offset offset)
72 translate_axis (offset[Y_AXIS], Y_AXIS);
73 translate_axis (offset[X_AXIS], X_AXIS);
78 Graphical_element::set_empty (bool b)
80 dim_cache_[X_AXIS].set_empty (b);
81 dim_cache_[Y_AXIS].set_empty (b);
85 Graphical_element::extent (Axis a) const
87 Dimension_cache const * d = &dim_cache_[a];
93 ((Dimension_cache*)d)->set_dim ((a == X_AXIS)? do_width(): do_height ());
100 Graphical_element::unlink ()
102 for (int a=X_AXIS; a < NO_AXES; a++)
103 if (Dimension_cache * d = dim_cache_[a].parent_l_)
105 if (Graphical_axis_group * eg
106 = dynamic_cast<Graphical_axis_group*> (d->elt_l_))
107 eg->remove_element (this);
112 Graphical_element::junk_links ()
117 Graphical_element::do_print () const
127 Graphical_element::invalidate_cache (Axis a)
129 dim_cache_[a].invalidate ();
133 Graphical_element::parent_l (Axis a) const
135 Dimension_cache*d= dim_cache_[a].parent_l_;
136 return d ? d->elt_l_ : 0;
139 Graphical_element::~Graphical_element ()
144 Graphical_element::common_group (Link_array<Graphical_element> gs, Axis a) const
146 Dimension_cache * common = &dim_cache_[a];
147 for (int i=0; i < gs.size (); i++)
149 common = common->common_group (&gs[i]->dim_cache_[a]);
156 Graphical_element::name () const
158 return classname (this);