]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.1
authorfred <fred>
Fri, 2 Aug 1996 18:37:24 +0000 (18:37 +0000)
committerfred <fred>
Fri, 2 Aug 1996 18:37:24 +0000 (18:37 +0000)
molecule.cc [new file with mode: 0644]

diff --git a/molecule.cc b/molecule.cc
new file mode 100644 (file)
index 0000000..96a21b9
--- /dev/null
@@ -0,0 +1,87 @@
+#include "glob.hh"
+#include "string.hh"
+#include "molecule.hh"
+
+String
+Atom::TeXstring() const
+{
+    // whugh.. Hard coded...
+    String s("\\raise");
+    s+= String(off.y * VERT_TO_PT)+"pt\\hbox to 0pt{\\kern ";
+    s+=String(off.x * HOR_TO_PT) + "pt" + sym->tex + "\\hss}";
+    return s;
+}
+
+/****************************************************************/
+
+String
+Molecule::TeXstring() const
+{
+    String s;
+    for(Cursor<Atom> c(ats); c.ok(); c++)
+       s+=(*c).TeXstring();
+    return s;
+}
+
+Box
+Molecule::extent() const
+{
+    Box b;
+    for(Cursor<Atom> c(ats); c.ok(); c++)
+       b.unite((*c).extent());
+    return b;
+}
+
+void
+Molecule::translate(Offset o)
+{
+    for(Cursor<Atom> c(ats); c.ok(); c++)
+       (*c).translate(o);
+}
+
+void
+Molecule::add(const Molecule &m)
+{
+    for (Cursor<Atom> c(m.ats); c.ok(); c++) {
+       Atom a(c);
+       ats.bottom().add(a);    
+    }
+}
+
+void
+Molecule::add_right(const Molecule &m)
+{
+    Real xof=extent().x.max - m.extent().x.min;
+    Molecule toadd(m);
+    toadd.translate(Offset(xof, 0.0));
+    add(toadd);
+}
+
+void
+Molecule::add_left(const Molecule &m)
+{
+    Real xof=extent().x.min - m.extent().x.max;
+    Molecule toadd(m);
+    toadd.translate(Offset(xof, 0.0));
+        add(toadd);
+}
+
+
+void
+Molecule::add_top(const Molecule &m)
+{
+    Real yof=extent().y.max - m.extent().y.min;
+    Molecule toadd(m);
+    toadd.translate(Offset(0,yof));
+        add(toadd);
+}
+
+void
+Molecule::add_bot(const Molecule &m)
+{
+    Real yof=extent().y.min- m.extent().y.max;
+    Molecule toadd(m);
+    toadd.translate(Offset(0,yof));
+    add(toadd);
+}
+