2 paper-def.cc -- implement Paper_def
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
13 #include "paper-def.hh"
17 #include "assoc-iter.hh"
18 #include "score-grav.hh"
20 #include "identifier.hh"
25 Paper_def::Paper_def ()
31 Paper_def::~Paper_def ()
37 Paper_def::Paper_def (Paper_def const&s)
38 : Music_output_def (s)
40 lookup_p_ = s.lookup_p_? new Lookup (*s.lookup_p_) : 0;
43 lookup_p_->paper_l_ = this;
45 scope_p_ = new Scope (*s.scope_p_);
49 Paper_def::get_var (String s) const
51 if (!scope_p_->elt_b (s))
52 error (_ ("unknown paper variable `") + s+"'");
53 Real * p = scope_p_->elem (s)->real ();
60 Paper_def::line_dimensions_int (int n) const
62 if (!shape_int_a_.size ())
64 return Interval (0, linewidth_f ());
66 return Interval (get_var ("indent"), linewidth_f ());
68 if (n >= shape_int_a_.size ())
69 n = shape_int_a_.size () -1;
71 return shape_int_a_[n];
75 Paper_def::beam_thickness_f () const
77 return get_var ("beam_thickness");
81 Paper_def::linewidth_f () const
83 return get_var ("linewidth");
87 Paper_def::duration_to_dist (Moment d,Real k) const
89 if (get_var ("geometric"))
90 return geometric_spacing (d);
91 return arithmetic_spacing (d,k);
96 Get the measure wide constant for arithmetic.
99 John S. Gourlay. ``Spacing a Line of Music,'' Technical Report
100 OSU-CISRC-10/87-TR35, Department of Computer and Information Science,
101 The Ohio State University, 1987.
105 Paper_def::arithmetic_constant (Moment d) const
107 return get_var ("arithmetic_basicspace") - log_2 (Moment (1,8) <? d);
111 Paper_def::arithmetic_spacing (Moment d ,Real k) const
113 return (log_2 (d) + k)* get_var ("arithmetic_multiplier");
117 Paper_def::geometric_spacing (Moment d) const
119 Real dur_f = (d) ?pow (get_var ("geometric"), log_2 (d)) : 0;
120 return get_var ("basicspace") + get_var ("unitspace") * dur_f;
124 Paper_def::set (Lookup*l)
126 assert (l != lookup_p_);
129 lookup_p_->paper_l_ = this;
133 Paper_def::interline_f () const
135 return get_var ("interline");
139 Paper_def::rule_thickness () const
141 return get_var ("rulethickness");
145 Paper_def::staffline_f () const
147 return get_var ("rulethickness");
151 Paper_def::staffheight_f () const
153 return get_var ("staffheight");
157 Paper_def::interbeam_f (int multiplicity_i) const
159 if (multiplicity_i <= 3)
160 return get_var ("interbeam");
162 return get_var ("interbeam4");
166 Paper_def::internote_f () const
168 return get_var ("internote");
172 Paper_def::note_width () const
174 return get_var ("notewidth");
178 Paper_def::print () const
181 Music_output_def::print ();
185 for (Assoc_iter<String,Identifier*> i (*scope_p_); i.ok (); i++)
187 DOUT << i.key () << "= ";
188 // i.val ()->print ();
190 DOUT << i.val ()->str () << "\n";
197 Paper_def::lookup_l ()
203 IMPLEMENT_IS_TYPE_B1 (Paper_def, Music_output_def);
206 Paper_def::TeX_output_settings_str () const
209 for (Assoc_iter<String,Identifier*> i (*scope_p_); i.ok (); i++)
210 s += String ("\\def\\mudelapaper") + i.key ()
211 + "{" + i.val ()->str () + "}\n";
212 s += lookup_p_->texsetting + "% (Tex id)\n";
216 int Paper_def::default_count_i_ = 0;
219 Paper_def::get_next_default_count () const
221 return default_count_i_ ++;