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"
18 Rest_collision::add_column (Note_column *nc_l)
20 add_dependency (nc_l);
22 rest_l_arr_.push (nc_l);
24 ncol_l_arr_.push (nc_l);
28 Rest_collision::do_post_processing()
32 handle rest under beam (do_post: beams are calculated now)
33 what about combination of collisions and rest under beam
38 Rest_collision::do_pre_processing()
41 handle rest-rest and rest-note collisions
44 decide not to print rest if too crowded?
47 // no rests to collide
48 if (!rest_l_arr_.size())
51 // no partners to collide with
52 if (rest_l_arr_.size() + ncol_l_arr_.size () < 2)
55 // meisjes met meisjes
56 if (!ncol_l_arr_.size())
58 int dy = rest_l_arr_.size() > 2 ? 6 : 4;
60 rest_l_arr_[0]->translate_rests (rest_l_arr_[0]->dir () *dy);
61 // top is last element...
62 rest_l_arr_.top()->translate_rests (rest_l_arr_.top ()->dir ()* dy);
64 // meisjes met jongetjes
67 // int dir_i = - ncol_l_arr_[0]->dir_;
68 Direction dir = rest_l_arr_[0]->dir ();
74 // UGH Should get dims from table!
79 Real internote_f = paper_l ()->get_realvar (interline_scm_sym)/2.0;
80 int sep_i = 3 + size_i / 2;
81 for (int i = 0; i < ncol_l_arr_.size(); i++)
83 // how to know whether to sort?
84 ncol_l_arr_[i]->sort();
85 for (int j = 0; j < ncol_l_arr_[i]->head_l_arr_.size(); j++)
87 int stem = (int)((ncol_l_arr_[i]->stem_l_->extent
88 (Y_AXIS)[dir]) / internote_f);
89 minpos = minpos >? (dir * stem + sep_i);
92 rest_l_arr_[0]->translate_rests (dir * minpos);
97 Rest_collision::do_print() const
100 DOUT << "rests: " << rest_l_arr_.size() << ", ";
101 DOUT << "cols: " << ncol_l_arr_.size();
106 Rest_collision::do_substitute_element_pointer (Score_element*o,Score_element*n)
108 if (Note_column *onl = dynamic_cast<Note_column *> (o))
110 Note_column *n_l = n?dynamic_cast<Note_column *> (n):0;
111 rest_l_arr_.substitute (onl, n_l);
112 ncol_l_arr_.substitute (onl, n_l);
116 Rest_collision::Rest_collision()
118 set_elt_property (transparent_scm_sym, SCM_BOOL_T);