2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1997--2015 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 #include "translator.icc"
30 class Collision_engraver : public Engraver
33 vector<Grob *> note_columns_;
36 DECLARE_ACKNOWLEDGER (note_column);
37 void process_acknowledged ();
38 void stop_translation_timestep ();
40 TRANSLATOR_DECLARATIONS (Collision_engraver);
44 Collision_engraver::process_acknowledged ()
46 if (col_ || note_columns_.size () < 2)
49 col_ = make_item ("NoteCollision", SCM_EOL);
51 for (vsize i = 0; i < note_columns_.size (); i++)
52 Note_collision_interface::add_column (col_, note_columns_[i]);
56 Collision_engraver::acknowledge_note_column (Grob_info i)
58 if (has_interface<Note_column> (i.grob ()))
60 /*should check Y axis? */
61 if (Note_column::has_rests (i.grob ()) || i.grob ()->get_parent (X_AXIS))
64 if (to_boolean (i.grob ()->get_property ("ignore-collision")))
67 note_columns_.push_back (i.grob ());
72 Collision_engraver::stop_translation_timestep ()
75 note_columns_.clear ();
78 Collision_engraver::Collision_engraver ()
83 ADD_ACKNOWLEDGER (Collision_engraver, note_column);
85 ADD_TRANSLATOR (Collision_engraver,
87 "Collect @code{NoteColumns}, and as soon as there are two or"
88 " more, put them in a @code{NoteCollision} object.",