}
void
-Lookup::print()const
+Lookup::print() const
{
- #ifndef NPRINT
+#ifndef NPRINT
DOUT << "Lookup: " << texsetting << " {\n";
symtables_->print();
DOUT << "}\n";
- #endif
+#endif
}
Symbol
Lookup::ball (int j) const
{
if (j > 2)
- j = 2;
+ j = 2;
Symtable * st = (*symtables_)("balls");
return st->lookup (String (j));
{
if (j>3)
{
- j = 3;
- warning ("max 3 dots"); // todo
+ j = 3;
+ warning ("max 3 dots"); // todo
}
return (*symtables_)("dots")->lookup (j);
}
if (i < 0)
{
- idx = "botlines";
- arg = -i;
+ idx = "botlines";
+ arg = -i;
}
else
{
- arg = i;
- idx = "toplines";
+ arg = i;
+ idx = "toplines";
}
Symbol ret = (*symtables_)("streepjes")->lookup (idx);
{
if (y1 > y2)
{
- Real t = y1;
- y1 = y2;
- y2 = t;
+ Real t = y1;
+ y1 = y2;
+ y2 = t;
}
Symbol s;
{
if (y < 2* 20 PT)
{
- warning ( "piano brace too small (" + print_dimen (y)+ ")");
- y = 2*20 PT;
+ warning ("piano brace too small (" + print_dimen (y)+ ")");
+ y = 2*20 PT;
}
if (y > 67 * 2 PT)
{
- warning ( "piano brace too big (" + print_dimen (y)+ ")");
- y = 67 *2 PT;
+ warning ("piano brace too big (" + print_dimen (y)+ ")");
+ y = 67 *2 PT;
}
int idx = int (rint ((y/2.0 - 20) + 148));
Symbol s = (*symtables_)("param")->lookup ("brace");
{
- Array<String> a;
- a.push (idx);
- s.tex = substitute_args (s.tex,a);
- s.dim.y() = Interval (0,y);
- }
+ Array<String> a;
+ a.push (idx);
+ s.tex = substitute_args (s.tex,a);
+ s.dim.y() = Interval (0,y);
+ }
{
- Array<String> a;
- a.push (print_dimen (y/2));
- a.push (print_dimen (0));
- a.push (s.tex);
- s.tex = substitute_args ("\\placebox{%}{%}{%}", a);
- }
+ Array<String> a;
+ a.push (print_dimen (y/2));
+ a.push (print_dimen (0));
+ a.push (s.tex);
+ s.tex = substitute_args ("\\placebox{%}{%}{%}", a);
+ }
return s;
{
for (Assoc_iter<String, Symtable*> i (s); i.ok(); i++)
{
- add (i.key(), new Symtable (*i.val ()));
+ add (i.key(), new Symtable (*i.val ()));
}
}
{
for (Assoc_iter<String, Symtable*> i (*this); i.ok(); i++)
{
- delete i.val();
+ delete i.val();
}
}
Symtable::lookup (String s) const
{
if (elt_b (s))
- return (*this)[s];
+ return (*this)[s];
else
{
- warning ("Symtable `" + id_str+ "\': unknown symbol `" +s+"'\n");
- Symbol sy;
- return sy;
+ warning ("Symtable `" + id_str+ "\': unknown symbol `" +s+"'\n");
+ Symbol sy;
+ return sy;
}
}
{
for (Assoc_iter<String, Symtable*> i (*this); i.ok(); i++)
{
- DOUT << "table \'" << i.key() << "\' {\n";
- i.val()->print ();
- DOUT << "}\n";
+ DOUT << "table \'" << i.key() << "\' {\n";
+ i.val()->print ();
+ DOUT << "}\n";
}
}
void
{
for (Assoc_iter<String, Symbol> i (*this); i.ok(); i++)
{
- DOUT << "\'" << i.key() << "\'->" << i.val ().str () << "\n";
+ DOUT << "\'" << i.key() << "\'->" << i.val ().str () << "\n";
}
}
/*
+ tex-beam.cc -- implement Lookup::{beam_element, beam, rule_symbol}
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1996,1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+/*
Code to generate beams for TeX
-
*/
#include <math.h>
{
if (abs (s) > 0.5)
{
- WARN << "beam steeper than 0.5 (" << s << ")\n";
- s = sign (s) * 0.5;
+ WARN << "beam steeper than 0.5 (" << s << ")\n";
+ s = sign (s) * 0.5;
}
int i = int (rint (s * 20.0));
s = i/20.0;
if (s>0)
- return 6*i +122;
+ return 6*i +122;
else
- return -6 * i+ 186;
+ return -6 * i+ 186;
}
Symbol
{
int sidx = slope_index (slope);
if (!slope)
- return rule_symbol (2 PT, width);
+ return rule_symbol (2 PT, width);
if (width < 2 PT)
{
- WARN<<"Beam too narrow. (" << print_dimen (width) <<")\n";
- width = 2 PT;
+ WARN<<"Beam too narrow. (" << print_dimen (width) <<")\n";
+ width = 2 PT;
}
Real elemwidth = 64 PT;
int widx = 5;
while (elemwidth > width)
{
- widx --;
- elemwidth /= 2.0;
+ widx --;
+ elemwidth /= 2.0;
}
Real overlap = elemwidth/4;
Real last_x = width - elemwidth;
m.add (a);
while (x < last_x)
{
- a=elem;
- a.translate (Offset (x-overlap, (x-overlap)*slope));
- m.add (a);
- x += elemwidth - overlap;
+ a=elem;
+ a.translate (Offset (x-overlap, (x-overlap)*slope));
+ m.add (a);
+ x += elemwidth - overlap;
}
a=elem;
a.translate (Offset (last_x, (last_x) * slope));
char c='#';
switch (y_sign)
{
- case -1:
- c = 'd';
- break;
- case 0:
- c = 'h';
- break;
- case 1:
- c = 'u';
- break;
- default:
- assert (false);
+ case -1:
+ c = 'd';
+ break;
+ case 0:
+ c = 'h';
+ break;
+ case 1:
+ c = 'u';
+ break;
+ default:
+ assert (false);
}
return c;
}
Lookup::half_slur_middlepart (Real &dx, int dir) const
{
if (dx >= 400 PT) {// todo
- WARN<<"halfslur too large" <<print_dimen (dx)<< "shrinking (ugh)\n";
- dx = 400 PT;
- }
+ WARN<<"halfslur too large" <<print_dimen (dx)<< "shrinking (ugh)\n";
+ dx = 400 PT;
+ }
int widx = int (floor (dx / 4.0));
dx = widx * 4.0;
if (widx) widx --;
else
{
- WARN << "slur too narrow\n";
+ WARN << "slur too narrow\n";
}
Symbol s;
int idx = widx;
if (dir < 0)
- idx += 128;
+ idx += 128;
assert (idx < 256);
- f+=String ("{") + String (idx ) + "}";
+ f+=String ("{") + String (idx) + "}";
s.tex = f;
Atom a (s);
a.translate (dx/2, X_AXIS);
{
Real orig_dx = dx;
if (!xpart)
- return half_slur_middlepart (dx, dir);
+ return half_slur_middlepart (dx, dir);
int widx;
if (dx >= 96 PT)
{
- WARN << "Slur half too wide." << print_dimen (orig_dx) << " shrinking (ugh)\n";
- dx = 96 PT;
+ WARN << "Slur half too wide." << print_dimen (orig_dx) << " shrinking (ugh)\n";
+ dx = 96 PT;
}
widx = int (rint (dx/12.0));
dx = widx*12.0;
if (widx)
- widx --;
+ widx --;
else
{
- WARN << "slur too narrow " << print_dimen (orig_dx)<<"\n";
+ WARN << "slur too narrow " << print_dimen (orig_dx)<<"\n";
}
Symbol s;
int hidx = dy;
if (hidx <0)
- hidx = -hidx;
+ hidx = -hidx;
hidx --;
int idx =-1;
idx = widx * 16 + hidx;
if (xpart < 0)
- idx += 128;
+ idx += 128;
assert (idx < 256);
- f+=String ("{") + String (idx ) + "}";
+ f+=String ("{") + String (idx) + "}";
s.tex = f;
if (y_sign)
{
- large |= dx>= 4*16 PT;
+ large |= dx>= 4*16 PT;
}
else
- large |= dx>= 4*54 PT;
+ large |= dx>= 4*54 PT;
if (large)
{
- return big_slur (dy, dx, dir);
+ return big_slur (dy, dx, dir);
}
Real orig_dx = dx;
int widx = int (floor (dx/4.0)); // slurs better too small..
dx = 4.0 * widx;
if (widx)
- widx --;
+ widx --;
else
{
- WARN << "slur too narrow: " << print_dimen (orig_dx) << "\n";
+ WARN << "slur too narrow: " << print_dimen (orig_dx) << "\n";
}
int hidx = dy;
if (hidx <0)
- hidx = -hidx;
+ hidx = -hidx;
hidx --;
if (hidx > 8)
{
- WARN<<"slur to steep: " << dy << " shrinking (ugh)\n";
+ WARN<<"slur to steep: " << dy << " shrinking (ugh)\n";
}
Symbol s;
int idx=-1;
if (y_sign) {
- idx = hidx * 16 + widx;
- if (dir < 0)
- idx += 128;
- }
+ idx = hidx * 16 + widx;
+ if (dir < 0)
+ idx += 128;
+ }
else
{
- if (dx >= 4*54 PT)
- {
- WARN << "slur too wide: " << print_dimen (dx) <<
- " shrinking (ugh)\n";
- dx = 4*54 PT;
- }
- idx = widx;
- if (dir < 0)
- idx += 54;
+ if (dx >= 4*54 PT)
+ {
+ WARN << "slur too wide: " << print_dimen (dx) <<
+ " shrinking (ugh)\n";
+ dx = 4*54 PT;
+ }
+ idx = widx;
+ if (dir < 0)
+ idx += 54;
}
assert (idx < 256);
- f+=String ("{") + String (idx ) + "}";
+ f+=String ("{") + String (idx) + "}";
s.tex = f;
Atom a (s);