]> git.donarmstrong.com Git - lilypond.git/blob - lily/ps-lookup.cc
patch::: 1.0.14.jcn1: braak
[lilypond.git] / lily / ps-lookup.cc
1 /*
2   ps-lookup.cc -- implement Ps_lookup
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--1998 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #include "ps-lookup.hh"
10 #include "debug.hh"
11 #include "dimensions.hh"
12 #include "symtable.hh"
13 #include "scalar.hh"
14 #include "paper-def.hh"
15 #include "string-convert.hh"
16 #include "main.hh"
17 #include "file-results.hh"
18 #include "header.hh"
19 #include "paper-stream.hh"
20 #include "ps-stream.hh"
21 #include "ps-outputter.hh"
22
23 Ps_lookup::Ps_lookup ()
24   : Lookup ()
25 {
26 }
27
28 Ps_lookup::Ps_lookup (Lookup const& s)
29   : Lookup (s)
30 {
31 }
32
33 Ps_lookup::Ps_lookup (Symtables const& s)
34   : Lookup (s)
35 {
36 }
37
38 Ps_lookup::~Ps_lookup ()
39 {
40 }
41
42 Atom
43 Ps_lookup::afm_find (String s) const
44 {
45   return Lookup::afm_find (s, String ("(\\%03o) show "));
46 }
47
48 Atom*
49 Ps_lookup::atom_p (String s, int n, Box b) const
50 {
51   for (int i = 0; i < n; i++)
52     s.prepend ("% ");
53   return new Atom (s, b);
54 }
55
56 String
57 Ps_lookup::character_str (int i) const
58 {
59   return to_str (i, "(\\%03o)");
60 }
61
62 Atom
63 Ps_lookup::dashed_slur (Array<Offset> controls, Real thick, Real dash) const
64 {
65   assert (controls.size () == 8);
66
67   String ps;
68   
69   Real dx = controls[3].x () - controls[0].x ();
70   Real dy = controls[3].y () - controls[0].y ();
71
72   for (int i = 1; i < 4; i++)
73     ps += String_convert::double_str (controls[i].x ()) + " "
74       + String_convert::double_str (controls[i].y ()) + " ";
75
76   ps += String_convert::double_str (controls[0].x ()) + " "
77     + String_convert::double_str (controls[0].y ()) + " ";
78
79   ps += String_convert::double_str (thick) + " ";
80   Real on = dash > 1? thick * dash - thick : 0;
81   Real off = 2 * thick;
82   ps += "[" + String_convert::double_str (on) + " ";
83   ps += String_convert::double_str (off) + "] ";
84   ps += String_convert::int_str (0) + " ";
85   ps += "draw_dashed_slur ";
86
87   Atom a;
88   a.str_ = ps;
89   
90   a.dim_[X_AXIS] = Interval (0, dx);
91   a.dim_[Y_AXIS] = Interval (0 <? dy,  0 >? dy);
92   a.font_ = font_;
93   return a;
94 }
95
96 Atom
97 Ps_lookup::hairpin (Real width, bool decresc, bool continued) const
98 {
99   Atom a;  
100   Real height = paper_l_->staffheight_f () / 6;
101   String ps;
102   ps += to_str (width) + " " 
103         + to_str (height) + " " 
104     + to_str (continued ? height/2 : 0) + 
105     + " draw_"  + String (decresc ? "de" : "") + "cresc\n";
106   a.str_ = ps;
107
108
109   a.dim_.x () = Interval (0, width);
110   a.dim_.y () = Interval (-2*height, 2*height);
111   a.font_ = font_;
112   return a;
113 }
114
115 Atom
116 Ps_lookup::plet (Real dy , Real dx, Direction dir) const
117 {
118   String ps;
119   
120   ps += String_convert::double_str (dx) + " " 
121     + String_convert::double_str (dy) + " "
122     + String_convert::int_str ( (int)dir) +
123     " draw_plet ";
124
125   Atom s;
126   s.str_ = ps;
127   return s;
128 }
129
130 Atom
131 Ps_lookup::ps_beam (Real slope, Real width, Real thick) const
132 {
133   String ps;
134   ps += to_str (width) + " "+ to_str (slope) + " " + to_str (thick)
135     + " draw_beam ";
136
137   Atom s;
138   s.str_ = ps;
139   return s;
140 }
141
142 Atom
143 Ps_lookup::slur (Array<Offset> controls) const
144 {
145   assert (controls.size () == 8);
146
147   String ps;
148   
149   Real dx = controls[3].x () - controls[0].x ();
150   Real dy = controls[3].y () - controls[0].y ();
151
152   for (int i = 5; i < 8; i++)
153     ps += String_convert::double_str (controls[i].x ()) + " "
154       + String_convert::double_str (controls[i].y ()) + " ";
155
156   ps += String_convert::double_str (controls[4].x ()) + " "
157     + String_convert::double_str (controls[4].y ()) + " ";
158   
159   for (int i = 1; i < 4; i++)
160     ps += String_convert::double_str (controls[i].x ()) + " "
161       + String_convert::double_str (controls[i].y ()) + " ";
162
163   ps += String_convert::double_str (controls[0].x ()) + " "
164     + String_convert::double_str (controls[0].y ()) + " ";
165
166   ps += " draw_slur ";
167
168   Atom s;
169   s.str_ = ps;
170   
171   s.dim_[X_AXIS] = Interval (0, dx);
172   s.dim_[Y_AXIS] = Interval (0 <? dy,  0 >? dy);
173   s.font_ = font_;
174   return s;
175 }
176
177 Atom
178 Ps_lookup::stem (Real y1, Real y2) const
179 {
180   return Lookup::stem (y1, y2, "\n% % % % draw_stem ");
181 }
182
183 Atom
184 Ps_lookup::text (String style, String text) const
185 {
186   return Lookup::text (style, "(" + text + ")");
187 }
188
189 Atom
190 Ps_lookup::vbracket (Real &y) const
191 {
192   Atom psbracket;
193   Real min_y = paper_l_->staffheight_f ();
194   if (y < min_y)
195     {
196       warning (_ ("bracket")
197         + " " + _ ("too small") +  " (" + print_dimen (y) + ")");
198 //      y = min_y;
199     }
200   psbracket.str_ = to_str (y) + " draw_bracket ";
201   psbracket.dim_[Y_AXIS] = Interval (-y/2,y/2);
202   psbracket.dim_[X_AXIS] = Interval (0,4 PT);
203   return psbracket;
204 }
205
206
207