2 collision-engraver.cc -- implement Collision_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2007 Han-Wen Nienhuys <hanwen@xs4all.nl>
10 #include "note-column.hh"
11 #include "note-collision.hh"
12 #include "axis-group-interface.hh"
15 class Collision_engraver : public Engraver
18 vector<Grob*> note_columns_;
21 DECLARE_ACKNOWLEDGER (note_column);
22 void process_acknowledged ();
23 void stop_translation_timestep ();
25 TRANSLATOR_DECLARATIONS (Collision_engraver);
29 Collision_engraver::process_acknowledged ()
31 if (col_ || note_columns_.size () < 2)
34 col_ = make_item ("NoteCollision", SCM_EOL);
36 for (vsize i = 0; i < note_columns_.size (); i++)
37 Note_collision_interface::add_column (col_, note_columns_[i]);
41 Collision_engraver::acknowledge_note_column (Grob_info i)
43 if (Note_column::has_interface (i.grob ()))
45 /*should check Y axis? */
46 if (Note_column::has_rests (i.grob ()) || i.grob ()->get_parent (X_AXIS))
49 if (to_boolean (i.grob ()->get_property ("ignore-collision")))
52 note_columns_.push_back (i.grob ());
57 Collision_engraver::stop_translation_timestep ()
60 note_columns_.clear ();
63 Collision_engraver::Collision_engraver ()
68 #include "translator.icc"
70 ADD_ACKNOWLEDGER (Collision_engraver, note_column);
72 ADD_TRANSLATOR (Collision_engraver,
74 "Collect @code{NoteColumns}, and as soon as there are two or"
75 " more, put them in a @code{NoteCollision} object.",