2 collision-reg.cc -- implement Collision_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "note-column.hh"
10 #include "collision.hh"
12 #include "engraver.hh"
13 #include "axis-group-interface.hh"
16 collect Note_column, and as soon as there are 2 or more, put them in
17 a collision object. */
18 class Collision_engraver
: public Engraver
{
20 Link_array
<Grob
> note_column_l_arr_
;
23 virtual void acknowledge_grob (Grob_info
);
24 virtual void create_grobs ();
25 virtual void stop_translation_timestep ();
27 VIRTUAL_COPY_CONS (Translator
);
28 Collision_engraver ();
33 Collision_engraver::create_grobs ()
35 if (col_p_
|| note_column_l_arr_
.size () < 2)
39 col_p_
= new Item (get_property ("NoteCollision"));
40 Axis_group_interface::set_interface (col_p_
);
41 Axis_group_interface::set_axes (col_p_
, X_AXIS
, Y_AXIS
);
43 announce_grob (col_p_
,0);
46 for (int i
=0; i
< note_column_l_arr_
.size (); i
++)
47 Collision::add_column (col_p_
,note_column_l_arr_
[i
]);
51 Collision_engraver::acknowledge_grob (Grob_info i
)
53 if (Note_column::has_interface (i
.elem_l_
))
55 /*should check Y axis? */
56 if (Note_column::rest_b (i
.elem_l_
) || i
.elem_l_
->parent_l (X_AXIS
))
59 note_column_l_arr_
.push (i
.elem_l_
);
64 Collision_engraver::stop_translation_timestep ()
68 typeset_grob (col_p_
);
71 note_column_l_arr_
.clear ();
74 Collision_engraver::Collision_engraver ()
81 ADD_THIS_TRANSLATOR (Collision_engraver
);