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 Direction dir = rest_l_arr_[0]->dir_;
77 // UGH Should get dims from table!
82 Real internote_f = paper_l ()->get_realvar (interline_scm_sym)/2.0;
83 int sep_i = 3 + size_i / 2;
84 for (int i = 0; i < ncol_l_arr_.size(); i++)
86 // how to know whether to sort?
87 ncol_l_arr_[i]->sort();
88 for (int j = 0; j < ncol_l_arr_[i]->head_l_arr_.size(); j++)
90 int stem = (int)((ncol_l_arr_[i]->stem_l_->extent
91 (Y_AXIS)[dir]) / internote_f);
92 minpos = minpos >? (dir * stem + sep_i);
95 rest_l_arr_[0]->translate_rests (dir * minpos);
100 Rest_collision::do_print() const
103 DOUT << "rests: " << rest_l_arr_.size() << ", ";
104 DOUT << "cols: " << ncol_l_arr_.size();
109 Rest_collision::do_substitute_element_pointer (Score_element*o,Score_element*n)
111 if (Note_column *onl = dynamic_cast<Note_column *> (o))
113 Note_column *n_l = n?dynamic_cast<Note_column *> (n):0;
114 rest_l_arr_.substitute (onl, n_l);
115 ncol_l_arr_.substitute (onl, n_l);
119 Rest_collision::Rest_collision()
121 set_elt_property (transparent_scm_sym, SCM_BOOL_T);