summaryrefslogtreecommitdiff
path: root/molecule.cc
diff options
context:
space:
mode:
Diffstat (limited to 'molecule.cc')
-rw-r--r--molecule.cc43
1 files changed, 27 insertions, 16 deletions
diff --git a/molecule.cc b/molecule.cc
index e1c4ac5f8d..7b8a752423 100644
--- a/molecule.cc
+++ b/molecule.cc
@@ -1,4 +1,5 @@
#include "glob.hh"
+#include "dimen.hh"
#include "string.hh"
#include "molecule.hh"
#include "symbol.hh"
@@ -6,24 +7,25 @@
Box
Atom::extent() const
{
- Box b( sym->dim);
+ Box b( sym.dim);
b.translate(off);
return b;
}
-Atom::Atom(const Symbol * s)
+Atom::Atom(Symbol s)
{
sym=s;
}
+
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";
- s+= sym->tex + "\\hss}";
+ s+= print_dimen(off.y) +"\\hbox to 0pt{\\kern ";
+ s+= print_dimen(off.x);
+ s+= sym.tex + "\\hss}";
return s;
}
@@ -33,8 +35,8 @@ String
Molecule::TeXstring() const
{
String s;
- for(Cursor<Atom> c(ats); c.ok(); c++)
- s+=(*c).TeXstring();
+ for(PCursor<Atom*> c(ats); c.ok(); c++)
+ s+=c->TeXstring();
return s;
}
@@ -42,24 +44,23 @@ Box
Molecule::extent() const
{
Box b;
- for(Cursor<Atom> c(ats); c.ok(); c++)
- b.unite((*c).extent());
+ for(PCursor<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);
+ for (PCursor<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);
+ for (PCursor<Atom*> c(m.ats); c.ok(); c++) {
+ add(**c);
}
}
@@ -78,7 +79,7 @@ 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);
+ add(toadd);
}
@@ -88,7 +89,7 @@ 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);
+ add(toadd);
}
void
@@ -100,3 +101,13 @@ Molecule::add_bot(const Molecule &m)
add(toadd);
}
+void
+Molecule::operator = (const Molecule&)
+{
+ assert(false);
+}
+
+Molecule::Molecule(const Molecule&s)
+{
+ add(s);
+}