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