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 "input-translator.hh"
18 #include "engraver-group.hh"
19 #include "assoc-iter.hh"
22 Paper_def::set_var(String s, Real r)
24 real_vars_p_->elem(s) = r;
28 Paper_def::get_var(String s)const
30 if(! real_vars_p_->elt_b(s))
31 error ( "unknown paper variable `" + s+"'");
32 return real_vars_p_->elem(s);
36 Paper_def::linewidth_f() const
38 return get_var("linewidth");
42 Paper_def::duration_to_dist(Moment d)
44 Real dur_f = (d) ?pow(get_var("geometric"), log_2(d)) : 0;
45 return get_var("basicspace") + get_var("unitspace") * dur_f;
49 Paper_def::Paper_def()
53 real_vars_p_ = new Assoc<String,Real>;
54 outfile_str_ = "lelie.tex";
57 Paper_def::~Paper_def()
64 Paper_def::Paper_def(Paper_def const&s)
66 itrans_p_ = s.itrans_p_ ? new Input_translator( *s.itrans_p_):0;
67 lookup_p_ = s.lookup_p_? new Lookup(*s.lookup_p_) : 0;
68 lookup_p_->paper_l_ = this;
69 real_vars_p_ = new Assoc<String,Real> (*s.real_vars_p_);
70 outfile_str_ = s.outfile_str_;
74 Paper_def::set(Input_translator * itrans_p)
81 Paper_def::set(Lookup*l)
83 assert(l != lookup_p_);
86 lookup_p_->paper_l_ = this;
90 Paper_def::interline_f() const
92 return get_var("interline");
97 Paper_def::rule_thickness()const
99 return get_var("rule_thickness");
103 Paper_def::interbeam_f() const
105 return get_var("interbeam");
108 Paper_def::internote_f() const
110 return interline_f() / 2;
114 Paper_def::note_width()const
116 return get_var("notewidth");
120 Paper_def::print() const
124 mtor << "out: " <<outfile_str_;
127 for (Assoc_iter<String,Real> i(*real_vars_p_); i.ok(); i++) {
128 mtor << i.key() << "= " << i.val() << "\n";
135 Paper_def::lookup_l()
142 Paper_def::get_global_translator_p() const
144 return itrans_p_->get_group_engraver_p()->global_l();