]> git.donarmstrong.com Git - lilypond.git/blob - lily/paper-def.cc
release: 0.0.60
[lilypond.git] / lily / paper-def.cc
1 /*
2   paper-def.cc -- implement Paper_def
3
4   source file of the LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9 #include <math.h>
10 #include "misc.hh"
11 #include "paper-def.hh"
12 #include "debug.hh"
13 #include "lookup.hh"
14 #include "dimen.hh"
15
16
17
18 // golden ratio
19 const Real PHI = (1+sqrt(5))/2;
20
21 // see  Roelofs, p. 57
22 Real
23 Paper_def::duration_to_dist(Moment d)
24 {
25     if (!d)
26         return 0;
27     
28     return whole_width * pow(geometric_, log_2(d));
29 }
30
31 Real
32 Paper_def::rule_thickness()const
33 {
34     return 0.4 PT;
35 }
36
37 Paper_def::Paper_def(Lookup *l)
38 {
39     lookup_p_ = l;
40     linewidth = 15 *CM_TO_PT;           // in cm for now
41     whole_width = 8 * note_width();
42     geometric_ = sqrt(2);
43     outfile = "lelie.tex";
44 }
45
46 Paper_def::~Paper_def()
47 {
48     delete lookup_p_;
49 }
50 Paper_def::Paper_def(Paper_def const&s)
51 {
52     lookup_p_ = new Lookup(*s.lookup_p_);
53     geometric_ = s.geometric_;
54     whole_width = s.whole_width;
55     outfile = s.outfile;
56     linewidth = s.linewidth;
57 }
58
59 void
60 Paper_def::set(Lookup*l)
61 {
62     assert(l != lookup_p_);
63     delete lookup_p_;
64     lookup_p_ = l;
65 }
66
67 Real
68 Paper_def::interline() const
69 {
70     return lookup_p_->ball(4).dim.y.length();
71 }
72
73 Real
74 Paper_def::internote() const
75 {
76     return lookup_p_->internote();
77 }
78 Real
79 Paper_def::note_width()const
80 {
81     return lookup_p_->ball(4).dim.x.length( );
82 }
83 Real
84 Paper_def::standard_height() const
85 {
86     return 20 PT;
87 }
88
89 void
90 Paper_def::print() const
91 {
92 #ifndef NPRINT
93     mtor << "Paper {width: " << print_dimen(linewidth);
94     mtor << "whole: " << print_dimen(whole_width);
95     mtor << "out: " <<outfile;
96     lookup_p_->print();
97     mtor << "}\n";
98 #endif
99 }
100 Lookup const *
101 Paper_def::lookup_l()
102 {
103     return lookup_p_;
104 }