2 rest-collision-engraver.cc -- implement Rest_collision_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
11 #include "duration.hh"
12 #include "engraver.hh"
13 #include "international.hh"
16 #include "note-column.hh"
17 #include "paper-column.hh"
19 #include "rest-collision.hh"
20 #include "rhythmic-head.hh"
21 #include "stream-event.hh"
24 class Rest_collision_engraver
: public Engraver
27 Grob
*rest_collision_
;
29 void process_acknowledged ();
30 void stop_translation_timestep ();
32 TRANSLATOR_DECLARATIONS (Rest_collision_engraver
);
35 Rest_collision_engraver::Rest_collision_engraver ()
41 Rest_collision_engraver::process_acknowledged ()
45 Moment now
= now_mom ();
47 for (SCM s
= get_property ("busyGrobs"); scm_is_pair (s
); s
= scm_cdr (s
))
49 Grob
*g
= unsmob_grob (scm_cdar (s
));
50 Moment
*m
= unsmob_moment (scm_caar (s
));
54 if (Rhythmic_head::has_interface (g
) && (*m
) > now
)
56 Grob
*column
= g
->get_parent (X_AXIS
);
59 g
->warning (_ ("rhythmic head is not part of a rhythmic column"));
63 // Only include rests that start now. Include notes that started any time.
64 Paper_column
*paper_column
= dynamic_cast<Item
*> (column
)->get_column ();
65 if (!Rest::has_interface (g
) || !paper_column
|| Paper_column::when_mom (paper_column
) == now
)
67 columns
.insert (column
);
68 rest_count
+= Note_column::has_rests (column
);
73 if (!rest_collision_
&& rest_count
&& columns
.size () > 1)
75 rest_collision_
= make_item ("RestCollision", SCM_EOL
);
76 for (set
<Grob
*>::iterator i
= columns
.begin (); i
!= columns
.end (); ++i
)
77 Rest_collision::add_column (rest_collision_
, *i
);
82 Rest_collision_engraver::stop_translation_timestep ()
87 #include "translator.icc"
89 ADD_TRANSLATOR (Rest_collision_engraver
,
91 "Handle collisions of rests.",