]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/atom.cc
release: 0.1.22
[lilypond.git] / lily / atom.cc
index 0ca9649b35c04fde9981f4328feb0760b182955e..870c6bece91c6b8fdc9da8884c84366b7dc40083 100644 (file)
@@ -5,7 +5,7 @@
 
   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
 */
-#include "symbol.hh"
+#include "atom.hh"
 #include "tex.hh"
 #include "interval.hh"
 #include "dimen.hh"
 #include "varray.hh"
 #include "debug.hh"
 
-
-
 void
 Atom::print() const
 {
-    mtor << "texstring: " <<sym.tex<<"\n";    
+#ifndef NPRINT
+  DOUT << "texstring: " <<tex_<<"\n";    
+  
+  DOUT << "dim:";
+    for (Axis i=X_AXIS; i < NO_AXES; incr(i))
+      DOUT << axis_name_str(i) << " = " << dim_[i].str();
+
+  DOUT << "\noffset: " << off_.str ();
+#endif
 }
 
 Box
 Atom::extent() const
 {
-    Box b( sym.dim);
-    b.translate(off);
-    return b;
+  Box b (dim_);
+  b.translate (off_);
+  return b;
+}
+
+
+Atom::Atom()
+  : dim_ (Interval (0,0),Interval (0,0))
+{
+  tex_ = "\\unknown";
 }
 
-Atom::Atom(Symbol s)
+Atom::Atom (String s, Box b)
+  :  dim_ (b)
 {
-    sym=s;
+  tex_ = s;
 }
 
 
+String
+Atom::str() const 
+{
+  return "Atom (\'"+tex_+"\', (" + dim_.x().str () + ", " 
+    + dim_.y ().str () + "))";
+}
+
 String
 Atom::TeX_string() const
 {
-    /* infinity checks. */
-    assert( abs(off.x) < 100 CM);
-    assert( abs(off.y) < 100 CM);
-    
-    // whugh.. Hard coded...
-    String s("\\placebox{%}{%}{%}");
-    Array<String> a;
-    a.push(print_dimen(off.y));
-    a.push(print_dimen(off.x));
-    a.push(sym.tex);
-    return substitute_args(s, a);
+  String tex_str = tex_;
+  Offset off = off_;
+
+  /* infinity checks. */
+  for (int a = X_AXIS; a < NO_AXES; a++)
+    {
+      Axis ax = (Axis)a;
+      if (abs (off[ax]) >= 100 CM)
+       {
+         warning ("ridiculous dimension " + axis_name_str (ax)  + ", " 
+                  +print_dimen(off[ax]));
+         off[ax] = 0.0;
+         tex_str += "\errormark"; 
+       }
+    }
+  // whugh.. Hard coded...
+  String s ("\\placebox{");
+  s += print_dimen (off[Y_AXIS])+"}{";
+  s += print_dimen (off[X_AXIS]) + "}{";
+  s += tex_str + "}";
+  return s;
+}
+
+void
+Atom::translate_axis (Real r, Axis a)
+{
+  off_[a] += r; 
+}
+
+void
+Atom::translate (Offset o)
+{
+  off_ += o;
 }