#include "tex.hh"
#include "scalar.hh"
#include "paper-def.hh"
+#include "main.hh"
Lookup::Lookup()
{
paper_l_ = 0;
texsetting = "\\unknowntexsetting";
- symtables_ = new Symtables;
+ symtables_p_ = new Symtables;
}
Lookup::Lookup (Lookup const &s)
{
paper_l_ = s.paper_l_;
texsetting = s.texsetting;
- symtables_ = new Symtables (*s.symtables_);
+ symtables_p_ = new Symtables (*s.symtables_p_);
}
Lookup::~Lookup()
{
- delete symtables_;
+ delete symtables_p_;
}
void
Lookup::add (String s, Symtable*p)
{
- symtables_->add (s, p);
+ symtables_p_->add (s, p);
}
void
{
#ifndef NPRINT
DOUT << "Lookup: " << texsetting << " {\n";
- symtables_->print();
+ symtables_p_->print();
DOUT << "}\n";
#endif
}
Array<String> a;
a.push (text);
- Atom tsym = (*symtables_)("style")->lookup (style);
+ Atom tsym = (*symtables_p_)("style")->lookup (style);
a[0] = substitute_args (tsym.tex_,a);
- Atom s = (*symtables_)("align")->lookup (dir);
+ Atom s = (*symtables_p_)("align")->lookup (dir);
s.tex_ = substitute_args (s.tex_,a);
s.dim_ = tsym.dim_;
return s;
if (j > 2)
j = 2;
- Symtable * st = (*symtables_)("balls");
+ Symtable * st = (*symtables_p_)("balls");
return st->lookup (String (j));
}
Atom
Lookup::rest (int j, bool o) const
{
- return (*symtables_)("rests")->lookup (String (j) + (o ? "o" : ""));
+ return (*symtables_p_)("rests")->lookup (String (j) + (o ? "o" : ""));
}
Atom
Lookup::fill (Box b) const
{
- Atom s ((*symtables_)("param")->lookup ("fill"));
+ Atom s ((*symtables_p_)("param")->lookup ("fill"));
s.dim_ = b;
return s;
}
Atom
Lookup::accidental (int j) const
{
- return (*symtables_)("accidentals")->lookup (String (j));
+ return (*symtables_p_)("accidentals")->lookup (String (j));
}
{
Array<String> a;
a.push (print_dimen (h));
- Atom ret=(*symtables_)("bars")->lookup (s);;
+ Atom ret=(*symtables_p_)("bars")->lookup (s);
ret.tex_ = substitute_args (ret.tex_, a);
- ret.dim_.y() = Interval (0, h);
+ ret.dim_.y() = Interval (-h/2, h/2);
return ret;
}
Atom
Lookup::script (String s) const
{
- return (*symtables_)("scripts")->lookup (s);
+ return (*symtables_p_)("scripts")->lookup (s);
}
Atom
Lookup::dynamic (String s) const
{
- return (*symtables_)("dynamics")->lookup (s);
+ return (*symtables_p_)("dynamics")->lookup (s);
}
Atom
Lookup::clef (String s) const
{
- return (*symtables_)("clefs")->lookup (s);
+ return (*symtables_p_)("clefs")->lookup (s);
}
Atom
Lookup::dots () const
{
- return (*symtables_)("dots")->lookup ("dot");
+ return (*symtables_p_)("dots")->lookup ("dot");
}
Atom
Lookup::flag (int j, Direction d) const
{
char c = (d == UP) ? 'u' : 'd';
- return (*symtables_)("flags")->lookup (c + String (j));
+ return (*symtables_p_)("flags")->lookup (c + String (j));
}
Atom
if (type > 2)
type = 2;
- Symtable * st = (*symtables_)("balls");
+ Symtable * st = (*symtables_p_)("balls");
return st->lookup (String (type) + 'l');
}
Atom
Lookup::hairpin (Real &wid, bool decresc) const
{
- int idx = int (rint (wid / 6 PT));
- if (!idx) idx ++;
- wid = idx*6 PT;
- String idxstr = (decresc)? "decrescendosym" : "crescendosym";
- Atom ret=(*symtables_)("param")->lookup (idxstr);
-
- Array<String> a;
- a.push (idx);
- ret.tex_ = substitute_args (ret.tex_, a);
+ bool embedded_b = postscript_global_b;
+ String embed;
+ Atom ret;
+ if (embedded_b)
+ {
+ Real height = 2 PT;
+ embed = "\\embeddedps{\n" ;
+ embed += String (wid) + " "
+ + String (height)
+ + " draw_" + String(decresc ? "de" : "") + "cresc}\n";
+ ret.tex_ = embed;
+ }
+ else
+ {
+ if (wid > 32 * 6 PT)
+ {
+ warning (_("Crescendo too long (") + print_dimen (wid)
+ +_( ") shrinking (ugh)"));
+ wid = 32*6 PT;
+ }
+ int idx = int (rint (wid / 6 PT));
+ if (!idx) idx ++;
+ wid = idx*6 PT;
+ String idxstr = (decresc)? "decrescendosym" : "crescendosym";
+ ret=(*symtables_p_)("param")->lookup (idxstr);
+
+ Array<String> a;
+ a.push (idx);
+ ret.tex_ = substitute_args (ret.tex_, a);
+ }
+
ret.dim_.x() = Interval (0,wid);
return ret;
}
-Atom
-Lookup::linestaff (int lines, Real interline_f, Real wid) const
-{
- Atom s;
- Real dy = (lines >0) ? (lines-1)*interline_f : 0;
- s.dim_ = Box (Interval (0,wid), Interval (0,dy));
-
- Array<String> a;
- a.push (lines);
- a.push (print_dimen (wid));
-
- s.tex_ = (*symtables_)("param")->lookup ("linestaf").tex_;
- s.tex_ = substitute_args (s.tex_, a);
-
-
- s.translate_axis (-s.extent ()[Y_AXIS].center (), Y_AXIS);
-
- return s;
-}
-
-
Atom
Lookup::meter (Array<Scalar> a) const
{
- Atom s((*symtables_)("param")->lookup ("meter"));
+ Atom s((*symtables_p_)("param")->lookup ("meter"));
s.tex_ = substitute_args (s.tex_,a);
return s;
}
a.push (print_dimen (y1));
a.push (print_dimen (y2));
- String src = (*symtables_)("param")->lookup ("stem").tex_;
+ String src = (*symtables_p_)("param")->lookup ("stem").tex_;
s.tex_ = substitute_args (src,a);
return s;
}
Atom
Lookup::vbrace (Real &y) const
{
- if (y < 2* 20 PT)
+ Atom brace = (*symtables_p_)("param")->lookup ("brace");
+ Interval ydims = brace.dim_[Y_AXIS];
+ Real min_y = ydims[LEFT];
+ Real max_y = ydims[RIGHT];
+ Real step = 2.0 PT;
+
+ if (y < min_y)
{
warning (_("piano brace too small (") + print_dimen (y)+ ")");
- y = 2*20 PT;
+ y = min_y;
}
- if (y > 67 * 2 PT)
+ if (y > max_y)
{
warning (_("piano brace too big (") + print_dimen (y)+ ")");
- y = 67 *2 PT;
+ y = max_y;
}
- int idx = int (rint ((y/2.0 - 20) + 148));
-
- Atom s = (*symtables_)("param")->lookup ("brace");
+
+ int idx = int (rint ((y- min_y)/step)) + 1;
+
{
Array<String> a;
a.push (idx);
- s.tex_ = substitute_args (s.tex_,a);
- s.dim_.y() = Interval (0,y);
+ brace.tex_ = substitute_args (brace.tex_,a);
+ brace.dim_[Y_AXIS] = Interval (-y/2,y/2);
}
- {
- 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;
+ return brace;
}