2 paper-def.cc -- implement Paper_def
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
13 #include "paper-def.hh"
17 #include "assoc-iter.hh"
18 #include "score-grav.hh"
23 Paper_def::Paper_def()
26 real_vars_p_ = new Dictionary<Real>;
29 Paper_def::~Paper_def()
35 Paper_def::Paper_def (Paper_def const&s)
36 : Music_output_def (s)
38 lookup_p_ = s.lookup_p_? new Lookup (*s.lookup_p_) : 0;
39 lookup_p_->paper_l_ = this;
40 real_vars_p_ = new Dictionary<Real> (*s.real_vars_p_);
44 Paper_def::set_var (String s, Real r)
46 real_vars_p_->elem (s) = r;
50 Paper_def::get_var (String s) const
52 if (! real_vars_p_->elt_b (s))
53 error (_("unknown paper variable `") + s+"'");
54 return real_vars_p_->elem (s);
58 Paper_def::linewidth_f() const
60 return get_var ("linewidth");
64 Paper_def::duration_to_dist (Moment d,Real k) const
66 if (get_var("geometric"))
67 return geometric_spacing(d);
68 return arithmetic_spacing(d,k);
73 Get the measure wide constant for arithmetic.
76 John S. Gourlay. ``Spacing a Line of Music,'' Technical Report
77 OSU-CISRC-10/87-TR35, Department of Computer and Information Science,
78 The Ohio State University, 1987.
82 Paper_def::arithmetic_constant(Moment d) const
84 return get_var("arithmetic_basicspace") - log_2(Moment(1,8) <? d);
88 Paper_def::arithmetic_spacing(Moment d ,Real k) const
90 return (log_2(d) + k)* get_var("arithmetic_multiplier");
94 Paper_def::geometric_spacing(Moment d) const
96 Real dur_f = (d) ?pow (get_var ("geometric"), log_2(d)) : 0;
97 return get_var ("basicspace") + get_var ("unitspace") * dur_f;
101 Paper_def::set (Lookup*l)
103 assert (l != lookup_p_);
106 lookup_p_->paper_l_ = this;
110 Paper_def::interline_f() const
112 return get_var ("interline");
117 Paper_def::rule_thickness() const
119 return get_var ("rule_thickness");
123 Paper_def::interbeam_f() const
125 return get_var ("interbeam");
128 Paper_def::internote_f() const
130 return interline_f() / 2;
134 Paper_def::note_width() const
136 return get_var ("notewidth");
140 Paper_def::print() const
143 Music_output_def::print ();
146 for (Assoc_iter<String,Real> i (*real_vars_p_); i.ok(); i++)
148 DOUT << i.key() << "= " << i.val () << "\n";
155 Paper_def::lookup_l()
161 IMPLEMENT_IS_TYPE_B1(Paper_def, Music_output_def);
164 Paper_def::TeX_output_settings_str () const
167 s += lookup_p_->texsetting + "%(Tex id)\n";
168 for (Assoc_iter<String,Real> i (*real_vars_p_); i.ok(); i++)
169 s += String ("\\def\\mudelapaper") + i.key () + "{" + i.val () + "}\n";
173 int Paper_def::default_count_i_ = 0;
176 Paper_def::get_next_default_count () const
178 return default_count_i_ ++;