2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1997--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #include "engraver.hh"
21 #include "note-column.hh"
22 #include "note-collision.hh"
23 #include "axis-group-interface.hh"
26 class Collision_engraver : public Engraver
29 vector<Grob *> note_columns_;
32 DECLARE_ACKNOWLEDGER (note_column);
33 void process_acknowledged ();
34 void stop_translation_timestep ();
36 TRANSLATOR_DECLARATIONS (Collision_engraver);
40 Collision_engraver::process_acknowledged ()
42 if (col_ || note_columns_.size () < 2)
45 col_ = make_item ("NoteCollision", SCM_EOL);
47 for (vsize i = 0; i < note_columns_.size (); i++)
48 Note_collision_interface::add_column (col_, note_columns_[i]);
52 Collision_engraver::acknowledge_note_column (Grob_info i)
54 if (Note_column::has_interface (i.grob ()))
56 /*should check Y axis? */
57 if (Note_column::has_rests (i.grob ()) || i.grob ()->get_parent (X_AXIS))
60 if (to_boolean (i.grob ()->get_property ("ignore-collision")))
63 note_columns_.push_back (i.grob ());
68 Collision_engraver::stop_translation_timestep ()
71 note_columns_.clear ();
74 Collision_engraver::Collision_engraver ()
79 #include "translator.icc"
81 ADD_ACKNOWLEDGER (Collision_engraver, note_column);
83 ADD_TRANSLATOR (Collision_engraver,
85 "Collect @code{NoteColumns}, and as soon as there are two or"
86 " more, put them in a @code{NoteCollision} object.",