2 molecule.cc -- implement Molecule
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 ugh. Rewrite not finished yet. Still must copy atom lists.
16 #include "dimensions.hh"
17 #include "interval.hh"
19 #include "molecule.hh"
22 #include "killing-cons.tcc"
26 Molecule::extent() const
32 Molecule::extent(Axis a) const
37 Molecule::Molecule (Box b, SCM func)
50 Molecule::translate (Offset o)
56 || isinf (o[a]) || isnan (o[a]))
58 programming_error ("Improbable offset for translation: setting to zero");
64 expr_ = gh_list (ly_symbol2scm ("translate-molecule"),
66 expr_, SCM_UNDEFINED);
73 Molecule::translate_axis (Real x,Axis a)
83 Molecule::add_molecule (Molecule const &m)
85 expr_ = gh_list (ly_symbol2scm ("combine-molecule"),
87 expr_, SCM_UNDEFINED);
92 Molecule::set_empty (bool e)
96 dim_[X_AXIS].set_empty ();
97 dim_[Y_AXIS].set_empty ();
101 dim_[X_AXIS] = Interval(0,0);
102 dim_[Y_AXIS] = Interval (0,0);
107 Molecule::print () const
115 Molecule::align_to (Axis a, Direction d)
117 Interval i (extent (a));
118 Real r = (d == CENTER) ? i.center () : i[d];
119 translate_axis (-r, a);
124 Molecule::add_at_edge (Axis a, Direction d, Molecule const &m, Real padding)
126 Real my_extent= empty_b () ? 0.0 : dim_[a][d];
127 Interval i (m.extent ()[a]);
129 programming_error ("Molecule::add_at_edge: adding empty molecule.");
131 Real his_extent = i[-d];
132 Real offset = my_extent - his_extent;
134 toadd.translate_axis (offset + d * padding, a);
135 add_molecule (toadd);
139 Molecule::empty_b () const
141 return expr_ == SCM_EOL;