]> git.donarmstrong.com Git - lilypond.git/blob - lily/rod.cc
release: 1.3.30
[lilypond.git] / lily / rod.cc
1 /*   
2   rod.cc --  implement Rod, Column_rod
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 1998--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9 #include "rod.hh"
10 #include "paper-column.hh"
11 #include "debug.hh"
12 #include "dimensions.hh"
13 #include "single-malt-grouping-item.hh"
14
15
16 Rod::Rod ()
17 {
18   distance_f_ = 0.0;
19   item_l_drul_[LEFT] = item_l_drul_[RIGHT] =0;
20 }
21
22 void
23 Column_rod::print () const
24 {
25 #ifndef NDEBUG
26   DEBUG_OUT << "Column_rod { rank = "
27        << other_l_->rank_i () << ", dist = " << distance_f_ << "}\n";   
28 #endif
29 }
30
31 Column_rod::Column_rod ()
32 {
33   distance_f_ = 0;
34   other_l_ = 0;
35 }
36   
37 int
38 Column_rod::compare (const Column_rod &r1, const Column_rod &r2)
39 {
40   return r1.other_l_->rank_i() - r2.other_l_->rank_i();
41 }
42
43 void
44 Rod::add_to_cols ()
45 {
46   Direction d = LEFT;
47   Drul_array<Paper_column*> cols;
48   Real extra_dist = 0.0;
49   do {
50     cols[d] = item_l_drul_[d]->column_l ();
51     extra_dist += item_l_drul_[d]->relative_coordinate (cols[d], X_AXIS);
52   } while ((flip (&d))!=LEFT);
53
54   if (cols[LEFT] != cols[RIGHT])
55     do
56       {
57         cols[-d]->add_rod(cols[d], distance_f_ + extra_dist);
58       }
59     while ((flip (&d))!=LEFT);
60 }
61