2 rest-collision.cc -- implement Rest_collision
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "rest-collision.hh"
11 #include "note-column.hh"
13 #include "note-head.hh"
14 #include "collision.hh"
15 #include "paper-def.hh"
21 Rest_collision::add_column (Note_column *nc_l)
23 add_dependency (nc_l);
25 rest_l_arr_.push (nc_l);
27 ncol_l_arr_.push (nc_l);
31 Rest_collision::do_post_processing()
35 handle rest under beam (do_post: beams are calculated now)
36 what about combination of collisions and rest under beam
41 Rest_collision::do_pre_processing()
44 handle rest-rest and rest-note collisions
47 decide not to print rest if too crowded?
50 // no rests to collide
51 if (!rest_l_arr_.size())
54 // no partners to collide with
55 if (rest_l_arr_.size() + ncol_l_arr_.size () < 2)
58 // meisjes met meisjes
59 if (!ncol_l_arr_.size())
61 int dy = rest_l_arr_.size() > 2 ? 6 : 4;
63 rest_l_arr_[0]->translate_rests (rest_l_arr_[0]->dir_ *dy);
64 // top is last element...
65 rest_l_arr_.top()->translate_rests (rest_l_arr_.top ()->dir_* dy);
67 // meisjes met jongetjes
70 // int dir_i = - ncol_l_arr_[0]->dir_;
71 int dir_i = rest_l_arr_[0]->dir_;
77 // UGH Should get dims from table!
80 Real internote_f = paper ()->internote_f ();
81 int sep_i = 3 + size_i / 2;
82 for (int i = 0; i < ncol_l_arr_.size(); i++)
84 // how to know whether to sort?
85 ncol_l_arr_[i]->sort();
86 for (int j = 0; j < ncol_l_arr_[i]->head_l_arr_.size(); j++)
88 int stem = (int)((ncol_l_arr_[i]->stem_l_->extent
89 (Y_AXIS)[dir_i]) / internote_f);
90 minpos = minpos >? (dir_i * stem + sep_i);
93 rest_l_arr_[0]->translate_rests (dir_i * minpos);
98 Rest_collision::do_print() const
101 DOUT << "rests: " << rest_l_arr_.size() << ", ";
102 DOUT << "cols: " << ncol_l_arr_.size();
107 Rest_collision::do_substitute_dependency (Score_element*o,Score_element*n)
109 if (Note_column *onl = dynamic_cast<Note_column *> (o))
111 Note_column *n_l = n?dynamic_cast<Note_column *> (n):0;
112 rest_l_arr_.substitute (onl, n_l);
113 ncol_l_arr_.substitute (onl, n_l);
117 Rest_collision::Rest_collision()
119 transparent_b_ = true;