]> git.donarmstrong.com Git - lilypond.git/blob - molecule.cc
96a21b9025dc590292eee53ef7a85b9f010025e5
[lilypond.git] / molecule.cc
1 #include "glob.hh"
2 #include "string.hh"
3 #include "molecule.hh"
4
5 String
6 Atom::TeXstring() const
7 {
8     // whugh.. Hard coded...
9     String s("\\raise");
10     s+= String(off.y * VERT_TO_PT)+"pt\\hbox to 0pt{\\kern ";
11     s+=String(off.x * HOR_TO_PT) + "pt" + sym->tex + "\\hss}";
12     return s;
13 }
14
15 /****************************************************************/
16
17 String
18 Molecule::TeXstring() const
19 {
20     String s;
21     for(Cursor<Atom> c(ats); c.ok(); c++)
22         s+=(*c).TeXstring();
23     return s;
24 }
25
26 Box
27 Molecule::extent() const
28 {
29     Box b;
30     for(Cursor<Atom> c(ats); c.ok(); c++)
31         b.unite((*c).extent());
32     return b;
33 }
34
35 void
36 Molecule::translate(Offset o)
37 {
38     for(Cursor<Atom> c(ats); c.ok(); c++)
39         (*c).translate(o);
40 }
41
42 void
43 Molecule::add(const Molecule &m)
44 {
45     for (Cursor<Atom> c(m.ats); c.ok(); c++) {
46         Atom a(c);
47         ats.bottom().add(a);    
48     }
49 }
50
51 void
52 Molecule::add_right(const Molecule &m)
53 {
54     Real xof=extent().x.max - m.extent().x.min;
55     Molecule toadd(m);
56     toadd.translate(Offset(xof, 0.0));
57     add(toadd);
58 }
59
60 void
61 Molecule::add_left(const Molecule &m)
62 {
63     Real xof=extent().x.min - m.extent().x.max;
64     Molecule toadd(m);
65     toadd.translate(Offset(xof, 0.0));
66         add(toadd);
67 }
68
69
70 void
71 Molecule::add_top(const Molecule &m)
72 {
73     Real yof=extent().y.max - m.extent().y.min;
74     Molecule toadd(m);
75     toadd.translate(Offset(0,yof));
76         add(toadd);
77 }
78
79 void
80 Molecule::add_bot(const Molecule &m)
81 {
82     Real yof=extent().y.min- m.extent().y.max;
83     Molecule toadd(m);
84     toadd.translate(Offset(0,yof));
85     add(toadd);
86 }
87