]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/atom.cc
release: 1.0.1
[lilypond.git] / lily / atom.cc
index f90625a25f46e610bb53ed5870f301458ca086af..48b5c737202b1b126d42d32321c13942750ebe57 100644 (file)
 
   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 "symbol.hh"
+
+
+#include "atom.hh"
 #include "tex.hh"
 #include "interval.hh"
-#include "dimen.hh"
+#include "dimension.hh"
 #include "string.hh"
-#include "varray.hh"
+#include "array.hh"
 #include "debug.hh"
+#include "main.hh"
 
+inline bool
+Atom::check_infinity_b ()const
+{
+  bool ridiculous = false;
+#ifndef NDEBUG
+  
+  /* infinity checks. */
+  for (int a = X_AXIS; a < NO_AXES; a++)
+    {
+      Axis ax = (Axis)a;
+      if (abs (off_[ax]) >= 100 CM)
+       {
+         warning (_f ("ridiculous dimension: %s, %s", axis_name_str (ax),
+                  print_dimen(off_[ax])));
+         
+         if (experimental_features_global_b)
+           assert (false);
+
+         ((Atom*)this)->off_[ax] = 0.0;
+         ridiculous = true;
+       }
+    }
+#endif
+  return ridiculous;
+}
 
 
 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(Symbol s)
+
+Atom::Atom()
+  : dim_ (Interval (0,0),Interval (0,0))
+{
+  tex_ = "\\unknown";
+}
+
+Atom::Atom (String s, Box b)
+  :  dim_ (b)
 {
-    sym_=s;
+  tex_ = s;
 }
 
 
 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);
+Atom::str() const
+{
+  return String ("Atom (\'") + tex_ + "\', (" + dim_.x().str () + ", "
+    + dim_.y ().str () + "))";
+}
+
+Offset
+Atom::offset () const
+{
+  return off_;
+}
+
+
+
+void
+Atom::translate_axis (Real r, Axis a)
+{
+  off_[a] += r;
+  check_infinity_b ();
+}
+
+void
+Atom::translate (Offset o)
+{
+  off_ += o;
+  check_infinity_b ();
 }