2 ps-lookup.cc -- implement Ps_lookup
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "ps-lookup.hh"
11 #include "symtable.hh"
12 #include "dimension.hh"
15 #include "paper-def.hh"
16 #include "string-convert.hh"
19 Ps_lookup::Ps_lookup ()
24 Ps_lookup::Ps_lookup (Lookup const& s)
29 Ps_lookup::Ps_lookup (Symtables const& s)
34 Ps_lookup::~Ps_lookup ()
39 Ps_lookup::afm_find (String s) const
41 return Lookup::afm_find (s, String ("(%d)"));
45 Ps_lookup::dashed_slur (Array<Offset> controls, Real thick, Real dash) const
47 assert (controls.size () == 8);
51 Real dx = controls[3].x () - controls[0].x ();
52 Real dy = controls[3].y () - controls[0].y ();
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 ()) + " ";
58 ps += String_convert::double_str (controls[0].x ()) + " "
59 + String_convert::double_str (controls[0].y ()) + " ";
61 ps += String_convert::double_str (thick) + " ";
62 Real on = dash > 1? thick * dash - thick : 0;
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";
72 a.dim_[X_AXIS] = Interval (0, dx);
73 a.dim_[Y_AXIS] = Interval (0 <? dy, 0 >? dy);
79 Ps_lookup::hairpin (Real width, bool decresc, bool continued) const
82 Real height = paper_l_->staffheight_f () / 6;
84 ps += to_str (width) + " "
85 + to_str (height) + " "
86 + to_str (continued ? height/2 : 0) +
87 + " draw_" + String (decresc ? "de" : "") + "cresc\n";
91 a.dim_.x () = Interval (0, width);
92 a.dim_.y () = Interval (-2*height, 2*height);
98 Ps_lookup::plet (Real dy , Real dx, Direction dir) const
102 ps += String_convert::double_str (dx) + " "
103 + String_convert::double_str (dy) + " "
104 + String_convert::int_str ( (int)dir) +
113 Ps_lookup::ps_beam (Real slope, Real width, Real thick) const
116 ps += to_str (width) + " "+ to_str (slope) + " " + to_str (thick)
125 Ps_lookup::slur (Array<Offset> controls) const
127 assert (controls.size () == 8);
131 Real dx = controls[3].x () - controls[0].x ();
132 Real dy = controls[3].y () - controls[0].y ();
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 ()) + " ";
138 ps += String_convert::double_str (controls[4].x ()) + " "
139 + String_convert::double_str (controls[4].y ()) + " ";
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 ()) + " ";
145 ps += String_convert::double_str (controls[0].x ()) + " "
146 + String_convert::double_str (controls[0].y ()) + " ";
153 s.dim_[X_AXIS] = Interval (0, dx);
154 s.dim_[Y_AXIS] = Interval (0 <? dy, 0 >? dy);
160 Ps_lookup::stem (Real y1, Real y2) const
162 // return Lookup::stem (y1, y2, "\\kern %\\vrule width % height % depth %");
163 return Lookup::stem (y1, y2, "% % moveto % % lineto");
167 Ps_lookup::vbracket (Real &y) const
170 Real min_y = paper_l_->staffheight_f ();
173 warning (_ ("bracket")
174 + " " + _ ("too small") + " (" + print_dimen (y) + ")");
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);