2 collision-engraver.cc -- implement Collision_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
10 #include "note-column.hh"
11 #include "note-collision.hh"
12 #include "axis-group-interface.hh"
14 class Collision_engraver : public Engraver
17 vector<Grob*> note_columns_;
20 DECLARE_ACKNOWLEDGER (note_column);
21 void process_acknowledged ();
22 void stop_translation_timestep ();
24 TRANSLATOR_DECLARATIONS (Collision_engraver);
28 Collision_engraver::process_acknowledged ()
30 if (col_ || note_columns_.size () < 2)
33 col_ = make_item ("NoteCollision", SCM_EOL);
35 for (vsize i = 0; i < note_columns_.size (); i++)
36 Note_collision_interface::add_column (col_, note_columns_[i]);
40 Collision_engraver::acknowledge_note_column (Grob_info i)
42 if (Note_column::has_interface (i.grob ()))
44 /*should check Y axis? */
45 if (Note_column::has_rests (i.grob ()) || i.grob ()->get_parent (X_AXIS))
48 note_columns_.push_back (i.grob ());
53 Collision_engraver::stop_translation_timestep ()
56 note_columns_.clear ();
59 Collision_engraver::Collision_engraver ()
64 #include "translator.icc"
66 ADD_ACKNOWLEDGER (Collision_engraver, note_column);
68 ADD_TRANSLATOR (Collision_engraver,
69 /* doc */ "Collect NoteColumns, and as soon as there are two or more, put them in a NoteCollision object.",
70 /* create */ "NoteCollision",