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"
28 class Collision_engraver : public Engraver
31 vector<Grob *> note_columns_;
34 void acknowledge_note_column (Grob_info);
35 void process_acknowledged ();
36 void stop_translation_timestep ();
38 TRANSLATOR_DECLARATIONS (Collision_engraver);
42 Collision_engraver::process_acknowledged ()
44 if (col_ || note_columns_.size () < 2)
47 col_ = make_item ("NoteCollision", SCM_EOL);
49 for (vsize i = 0; i < note_columns_.size (); i++)
50 Note_collision_interface::add_column (col_, note_columns_[i]);
54 Collision_engraver::acknowledge_note_column (Grob_info i)
56 if (has_interface<Note_column> (i.grob ()))
58 /*should check Y axis? */
59 if (Note_column::has_rests (i.grob ()) || i.grob ()->get_parent (X_AXIS))
62 if (to_boolean (i.grob ()->get_property ("ignore-collision")))
65 note_columns_.push_back (i.grob ());
70 Collision_engraver::stop_translation_timestep ()
73 note_columns_.clear ();
76 Collision_engraver::Collision_engraver (Context *c)
84 Collision_engraver::boot ()
86 ADD_ACKNOWLEDGER (Collision_engraver, note_column);
89 ADD_TRANSLATOR (Collision_engraver,
91 "Collect @code{NoteColumns}, and as soon as there are two or"
92 " more, put them in a @code{NoteCollision} object.",