]> git.donarmstrong.com Git - lilypond.git/blob - lily/atom.cc
release: 0.1.15
[lilypond.git] / lily / atom.cc
1 /*
2   atom.cc -- implement Atom
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8 #include "atom.hh"
9 #include "tex.hh"
10 #include "interval.hh"
11 #include "dimen.hh"
12 #include "string.hh"
13 #include "varray.hh"
14 #include "debug.hh"
15
16 void
17 Atom::print() const
18 {
19 #ifndef NPRINT
20   DOUT << "texstring: " <<tex_<<"\n";    
21 #endif
22 }
23
24 Box
25 Atom::extent() const
26 {
27   Box b (dim_);
28   b.translate (off_);
29   return b;
30 }
31
32
33 Atom::Atom()
34   : dim_ (Interval (0,0),Interval (0,0))
35 {
36   tex_ = "\\unknown";
37 }
38
39 Atom::Atom (String s, Box b)
40   :  dim_ (b)
41 {
42   tex_ = s;
43 }
44
45
46 String
47 Atom::str() const 
48 {
49   return "Atom (\'"+tex_+"\', (" + dim_.x().str () + ", " 
50     + dim_.y ().str () + "))";
51 }
52
53 String
54 Atom::TeX_string() const
55 {
56   String tex_str = tex_;
57   Offset off = off_;
58
59   /* infinity checks. */
60   for (int a =X_AXIS; a < NO_AXES; a++)
61     {
62       Axis ax = (Axis)a;
63       if (abs (off[ax]) >= 100 CM)
64         {
65           warning ("ridiculous dimension " + axis_name_str (ax)  + ", " 
66                    +print_dimen(off[ax]));
67           off[ax] = 0.0;
68           tex_str += "\errormark"; 
69         }
70     }
71   // whugh.. Hard coded...
72   String s ("\\placebox{");
73   s += print_dimen (off[Y_AXIS])+"}{";
74   s += print_dimen (off[X_AXIS]) + "}{";
75   s += tex_str + "}";
76   return s;
77 }