From 3c1a92d25f287fd93c5c6dc059557ae32a7f9229 Mon Sep 17 00:00:00 2001 From: fred Date: Sun, 10 Nov 1996 23:15:33 +0000 Subject: [PATCH] lilypond-0.0.9 --- src/molecule.cc | 144 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 src/molecule.cc diff --git a/src/molecule.cc b/src/molecule.cc new file mode 100644 index 0000000000..e8c4d2adec --- /dev/null +++ b/src/molecule.cc @@ -0,0 +1,144 @@ +#include "glob.hh" +#include "dimen.hh" +#include "string.hh" +#include "molecule.hh" +#include "symbol.hh" +#include "debug.hh" +#include "tex.hh" + +void +Atom::print() const +{ + mtor << "texstring: " < a; + a.add(print_dimen(off.y)); + a.add(print_dimen(off.x)); + a.add(sym.tex); + return substitute_args(s, a); +} + + +String +Molecule::TeXstring() const +{ + String s; + for(PCursor c(ats); c.ok(); c++) + s+=c->TeXstring(); + return s; +} + +Box +Molecule::extent() const +{ + Box b; + for(PCursor c(ats); c.ok(); c++) + b.unite(c->extent()); + return b; +} + +void +Molecule::translate(Offset o) +{ + for (PCursor c(ats); c.ok(); c++) + c->translate(o); +} + +void +Molecule::add(const Molecule &m) +{ + for (PCursor c(m.ats); c.ok(); c++) { + add(**c); + } +} + +void +Molecule::add_right(const Molecule &m) +{ + if (!ats.size()) { + add(m); + return; + } + 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) +{ + if (!ats.size()) { + add(m); + return; + } + 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) +{ + if (!ats.size()) { + add(m); + return; + } + 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) +{ + if (!ats.size()) { + add(m); + return; + } + Real yof=extent().y.min- m.extent().y.max; + Molecule toadd(m); + toadd.translate(Offset(0,yof)); + add(toadd); +} + +void +Molecule::operator = (const Molecule&) +{ + assert(false); +} + +Molecule::Molecule(const Molecule&s) +{ + add(s); +} + +void +Molecule::print() const +{ + for (PCursor c(ats); c.ok(); c++) + c->print(); +} -- 2.39.5