]> git.donarmstrong.com Git - lilypond.git/blob - lily/ps-lookup.cc
patch::: 1.0.12.jcn2: opniewvisite
[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 "symtable.hh"
12 #include "dimension.hh"
13 #include "tex.hh"
14 #include "scalar.hh"
15 #include "paper-def.hh"
16 #include "string-convert.hh"
17 #include "main.hh"
18
19 Ps_lookup::Ps_lookup ()
20   : Lookup ()
21 {
22 }
23
24 Ps_lookup::Ps_lookup (Lookup const& s)
25   : Lookup (s)
26 {
27 }
28
29 Ps_lookup::Ps_lookup (Symtables const& s)
30   : Lookup (s)
31 {
32 }
33
34 Ps_lookup::~Ps_lookup ()
35 {
36 }
37
38 Atom
39 Ps_lookup::afm_find (String s) const
40 {
41   return Lookup::afm_find (s, String ("(%d)"));
42 }
43
44 Atom
45 Ps_lookup::dashed_slur (Array<Offset> controls, Real thick, Real dash) const
46 {
47   assert (controls.size () == 8);
48
49   String ps;
50   
51   Real dx = controls[3].x () - controls[0].x ();
52   Real dy = controls[3].y () - controls[0].y ();
53
54   for (int i = 1; i < 4; i++)
55     ps += String_convert::double_str (controls[i].x ()) + " "
56       + String_convert::double_str (controls[i].y ()) + " ";
57
58   ps += String_convert::double_str (controls[0].x ()) + " "
59     + String_convert::double_str (controls[0].y ()) + " ";
60
61   ps += String_convert::double_str (thick) + " ";
62   Real on = dash > 1? thick * dash - thick : 0;
63   Real off = 2 * thick;
64   ps += "[" + String_convert::double_str (on) + " ";
65   ps += String_convert::double_str (off) + "] ";
66   ps += String_convert::int_str (0) + " ";
67   ps += " draw_dashed_slur";
68
69   Atom a;
70   a.str_ = ps;
71   
72   a.dim_[X_AXIS] = Interval (0, dx);
73   a.dim_[Y_AXIS] = Interval (0 <? dy,  0 >? dy);
74   a.font_ = font_;
75   return a;
76 }
77
78 Atom
79 Ps_lookup::hairpin (Real width, bool decresc, bool continued) const
80 {
81   Atom a;  
82   Real height = paper_l_->staffheight_f () / 6;
83   String ps;
84   ps += to_str (width) + " " 
85         + to_str (height) + " " 
86     + to_str (continued ? height/2 : 0) + 
87     + " draw_"  + String (decresc ? "de" : "") + "cresc\n";
88   a.str_ = ps;
89
90
91   a.dim_.x () = Interval (0, width);
92   a.dim_.y () = Interval (-2*height, 2*height);
93   a.font_ = font_;
94   return a;
95 }
96
97 Atom
98 Ps_lookup::plet (Real dy , Real dx, Direction dir) const
99 {
100   String ps;
101   
102   ps += String_convert::double_str (dx) + " " 
103     + String_convert::double_str (dy) + " "
104     + String_convert::int_str ( (int)dir) +
105     " draw_plet";
106
107   Atom s;
108   s.str_ = ps;
109   return s;
110 }
111
112 Atom
113 Ps_lookup::ps_beam (Real slope, Real width, Real thick) const
114 {
115   String ps;
116   ps += to_str (width) + " "+ to_str (slope) + " " + to_str (thick)
117     + " draw_beam";
118
119   Atom s;
120   s.str_ = ps;
121   return s;
122 }
123
124 Atom
125 Ps_lookup::slur (Array<Offset> controls) const
126 {
127   assert (controls.size () == 8);
128
129   String ps;
130   
131   Real dx = controls[3].x () - controls[0].x ();
132   Real dy = controls[3].y () - controls[0].y ();
133
134   for (int i = 5; i < 8; i++)
135     ps += String_convert::double_str (controls[i].x ()) + " "
136       + String_convert::double_str (controls[i].y ()) + " ";
137
138   ps += String_convert::double_str (controls[4].x ()) + " "
139     + String_convert::double_str (controls[4].y ()) + " ";
140   
141   for (int i = 1; i < 4; i++)
142     ps += String_convert::double_str (controls[i].x ()) + " "
143       + String_convert::double_str (controls[i].y ()) + " ";
144
145   ps += String_convert::double_str (controls[0].x ()) + " "
146     + String_convert::double_str (controls[0].y ()) + " ";
147
148   ps += " draw_slur";
149
150   Atom s;
151   s.str_ = ps;
152   
153   s.dim_[X_AXIS] = Interval (0, dx);
154   s.dim_[Y_AXIS] = Interval (0 <? dy,  0 >? dy);
155   s.font_ = font_;
156   return s;
157 }
158
159 Atom
160 Ps_lookup::stem (Real y1, Real y2) const
161 {
162   //  return Lookup::stem (y1, y2, "\\kern %\\vrule width % height % depth %");
163   return Lookup::stem (y1, y2, "% % moveto % % lineto");
164 }
165
166 Atom
167 Ps_lookup::vbracket (Real &y) const
168 {
169   Atom psbracket;
170   Real min_y = paper_l_->staffheight_f ();
171   if (y < min_y)
172     {
173       warning (_ ("bracket")
174         + " " + _ ("too small") +  " (" + print_dimen (y) + ")");
175 //      y = min_y;
176     }
177   psbracket.str_ = to_str (y) + " draw_bracket";
178   psbracket.dim_[Y_AXIS] = Interval (-y/2,y/2);
179   psbracket.dim_[X_AXIS] = Interval (0,4 PT);
180   return psbracket;
181 }
182
183
184