]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/molecule.cc
patch::: 1.1.25.jcn1: jcn1
[lilypond.git] / lily / molecule.cc
index f054a280212b2193d93751c0c6abcabe5cc20bf4..4e0bb337667a553918cbc633908ce4a51183e2be 100644 (file)
@@ -3,71 +3,68 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+  (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 #include "interval.hh"
-#include "dimen.hh"
 #include "string.hh"
 #include "molecule.hh"
 #include "atom.hh"
 #include "debug.hh"
-#include "tex.hh"
-
-String
-Molecule::TeX_string() const
-{
-  String s;
-  for (iter_top (ats,c); c.ok(); c++)
-    s+=c->TeX_string();
-  return s;
-}
 
 Box
 Molecule::extent() const
 {
   Box b;
-  for (iter_top (ats,c); c.ok(); c++)
+  for (iter_top (atoms_,c); c.ok(); c++)
     b.unite (c->extent());
   return b;
 }
 
+Interval
+Molecule::extent(Axis a) const
+{
+  Interval i;
+  for (iter_top (atoms_,c); c.ok(); c++)
+    i.unite (c->extent(a));
+  return i;
+}
+
 void
 Molecule::translate (Offset o)
 {
-  for (iter_top (ats,c); c.ok(); c++)
+  for (iter_top (atoms_,c); c.ok(); c++)
     c->translate (o);
 }
 
 void
 Molecule::translate_axis (Real x,Axis a)
 {
-  for (iter_top (ats,c); c.ok(); c++)
+  for (iter_top (atoms_,c); c.ok(); c++)
     c->translate_axis (x,a);
 }
 
 void
-Molecule::add (Molecule const &m)
+Molecule::add_molecule (Molecule const &m)
 {
-  for (iter_top (m.ats,c); c.ok(); c++) 
+  for (iter_top (m.atoms_,c); c.ok(); c++) 
     {
-      add (**c);
+      add_atom (**c);
     }
 }
 
 
 void
-Molecule::add_at_edge (Axis a, Direction d, Molecule const &m)
+Molecule::add_at_edge (Axis a, Direction d, Molecule const &m, Real padding)
 {
-  if (!ats.size()) 
-    {
-      add (m);
-      return;
-    }
-  Real offset = extent ()[a][d] - m.extent ()[a][-d];
+  Real my_extent= atoms_.size()
+    ? extent ()[a][d] 
+    : 0.0;
+  
+  Real offset = my_extent -  m.extent ()[a][-d];
   Molecule toadd (m);
-  toadd.translate_axis (offset, a);
-  add (toadd);
+  toadd.translate_axis (offset + d * padding, a);
+  add_molecule (toadd);
 }
 
   
@@ -80,7 +77,7 @@ Molecule::operator = (Molecule const &)
 
 Molecule::Molecule (Molecule const &s)
 {
-  add (s);
+  add_molecule (s);
 }
 
 void
@@ -89,13 +86,18 @@ Molecule::print() const
 #ifndef NPRINT
   if (! check_debug)
     return;
-  for (iter_top (ats,c); c.ok(); c++)
+  for (iter_top (atoms_,c); c.ok(); c++)
     c->print();
 #endif
 }
 
 void
-Molecule::add (Atom const &a)
+Molecule::add_atom (Atom const &a)
+{
+  atoms_.bottom().add (new Atom (a)); 
+}
+
+Molecule::Molecule (Atom const &a)
 {
-  ats.bottom().add (new Atom (a)); 
+  add_atom (a) ;
 }