lilypond-0.1.47
[lilypond.git] / lily / molecule.cc
blobf054a280212b2193d93751c0c6abcabe5cc20bf4
1 /*
2 molecule.cc -- implement Molecule
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
9 #include "interval.hh"
10 #include "dimen.hh"
11 #include "string.hh"
12 #include "molecule.hh"
13 #include "atom.hh"
14 #include "debug.hh"
15 #include "tex.hh"
17 String
18 Molecule::TeX_string() const
20 String s;
21 for (iter_top (ats,c); c.ok(); c++)
22 s+=c->TeX_string();
23 return s;
26 Box
27 Molecule::extent() const
29 Box b;
30 for (iter_top (ats,c); c.ok(); c++)
31 b.unite (c->extent());
32 return b;
35 void
36 Molecule::translate (Offset o)
38 for (iter_top (ats,c); c.ok(); c++)
39 c->translate (o);
42 void
43 Molecule::translate_axis (Real x,Axis a)
45 for (iter_top (ats,c); c.ok(); c++)
46 c->translate_axis (x,a);
49 void
50 Molecule::add (Molecule const &m)
52 for (iter_top (m.ats,c); c.ok(); c++)
54 add (**c);
59 void
60 Molecule::add_at_edge (Axis a, Direction d, Molecule const &m)
62 if (!ats.size())
64 add (m);
65 return;
67 Real offset = extent ()[a][d] - m.extent ()[a][-d];
68 Molecule toadd (m);
69 toadd.translate_axis (offset, a);
70 add (toadd);
75 void
76 Molecule::operator = (Molecule const &)
78 assert (false);
81 Molecule::Molecule (Molecule const &s)
83 add (s);
86 void
87 Molecule::print() const
89 #ifndef NPRINT
90 if (! check_debug)
91 return;
92 for (iter_top (ats,c); c.ok(); c++)
93 c->print();
94 #endif
97 void
98 Molecule::add (Atom const &a)
100 ats.bottom().add (new Atom (a));