lilypond-1.3.65
[lilypond.git] / lily / paper-column.cc
blob5ab553257f9e028413abaab825d2769ec8bfc6b5
1 /*
2 paper-column.cc -- implement Paper_column
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8 #include "moment.hh"
9 #include "paper-column.hh"
10 #include "paper-score.hh"
11 #include "debug.hh"
12 #include "axis-group-interface.hh"
14 void
15 Paper_column::add_rod (Paper_column * p, Real d)
17 Direction dir = Direction (sign (p->rank_i () - rank_i ()));
19 if (dir != RIGHT)
21 programming_error ("Must set minimum distance LTOR.");
22 return;
25 for (int i=0; i < minimal_dists_.size (); i++)
27 Column_rod &rod = minimal_dists_[i];
28 if (rod.other_l_ == p)
30 rod.distance_f_ = rod.distance_f_ >? d;
31 return ;
35 Column_rod cr;
36 cr.distance_f_ = d;
37 cr.other_l_ = p;
39 minimal_dists_.push (cr);
42 void
43 Paper_column::add_spring (Paper_column * p, Real d, Real s)
45 Direction dir = Direction (sign (p->rank_i () - rank_i ()));
47 if (dir != RIGHT)
49 programming_error ("Must set springs LTOR");
50 return;
53 for (int i=0; i < springs_.size (); i++)
55 Column_spring &spring = springs_[i];
56 if (spring.other_l_ == p)
58 spring.distance_f_ = spring.distance_f_ >? d;
59 return ;
63 Column_spring cr;
64 cr.distance_f_ = d;
65 cr.strength_f_ = s;
66 cr.other_l_ = p;
68 springs_.push (cr);
71 int
72 Paper_column::rank_i() const
74 return rank_i_;
77 void
78 Paper_column::set_rank (int i)
80 rank_i_ = i;
85 Line_of_score*
86 Paper_column::line_l() const
88 return line_l_;
91 Paper_column*
92 Paper_column::column_l () const
94 return (Paper_column*)(this);
97 Paper_column::Paper_column (Moment w)
98 : Item (SCM_EOL) // guh.?
100 SCM when = smobify (new Moment (w));
101 set_elt_property ("when", when);
103 Axis_group_interface (this).set_interface ();
104 Axis_group_interface (this).set_axes (X_AXIS, X_AXIS);
105 set_elt_pointer ("bounded-by-me", SCM_EOL);
106 line_l_=0;
107 rank_i_ = -1;
110 Moment
111 Paper_column::when_mom () const
113 SCM m = get_elt_property ("when");
114 Moment s (0);
115 if (SMOB_IS_TYPE_B(Moment, m))
117 s = *SMOB_TO_TYPE (Moment,m);
119 return s;
122 bool
123 Paper_column::musical_b () const
125 SCM m = get_elt_property ("shortest-starter-duration");
126 Moment s (0);
127 if (SMOB_IS_TYPE_B(Moment, m))
129 s = *SMOB_TO_TYPE (Moment,m);
131 return s != Moment(0);
134 bool
135 Paper_column::used_b ()const
137 return gh_pair_p (get_elt_pointer ("elements")) || breakable_b ()
138 || gh_pair_p (get_elt_pointer ("bounded-by-me"))