* scm/beam.scm (check-slope-callbacks): check sign of slope.
[lilypond.git] / lily / rhythmic-column-engraver.cc
blob3c63236546d9a36980a3fe308bcf91395c087caa
1 /*
2 rhythmic-column-grav.cc -- implement Rhythmic_column_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
10 #include "slur.hh"
11 #include "engraver.hh"
12 #include "rhythmic-head.hh"
13 #include "stem.hh"
14 #include "note-column.hh"
15 #include "dot-column.hh"
16 #include "event.hh"
17 #include "item.hh"
18 #include "group-interface.hh"
23 this engraver glues together stems, rests and note heads into a NoteColumn
24 grob.
26 It also generates spacing objects. Originally, we have tried to
27 have the spacing functionality at different levels.
29 - by simply using the sequence of Separation-item as
30 spacing-sequences (at staff level). Unfortunately, this fucks up if
31 there are different kinds of tuplets in different voices (8th and
32 8ths triplets combined made the program believe there were 1/12 th
33 notes.).
35 Doing it in a separate engraver using timing info is generally
36 complicated (start/end time management), and fucks up if a voice
37 changes staff.
39 Now we do it from here again. This has the problem that voices can
40 appear and disappear at will, leaving lots of loose ends (the note
41 spacing engraver don't know where to connect the last note of the
42 voice on the right with), but we don't complain about those, and let
43 the default spacing do its work.
48 class Rhythmic_column_engraver :public Engraver
50 Link_array<Grob> rheads_;
51 Grob * stem_;
52 Grob * note_column_;
53 Grob * dotcol_;
55 Grob * last_spacing_;
56 Grob * spacing_;
58 TRANSLATOR_DECLARATIONS (Rhythmic_column_engraver);
59 protected:
61 virtual void acknowledge_grob (Grob_info);
62 virtual void process_acknowledged_grobs ();
63 virtual void stop_translation_timestep ();
68 Rhythmic_column_engraver::Rhythmic_column_engraver ()
70 spacing_ =0 ;
71 last_spacing_ = 0;
73 stem_ =0;
74 note_column_=0;
75 dotcol_ =0;
79 void
80 Rhythmic_column_engraver::process_acknowledged_grobs ()
82 if (rheads_.size ())
84 if (!note_column_)
86 note_column_ = make_item ("NoteColumn",rheads_[0]->self_scm ());
88 spacing_ = make_item ("NoteSpacing", SCM_EOL);
89 spacing_->set_property ("left-items", scm_cons (note_column_->self_scm (), SCM_EOL));
94 if (last_spacing_)
96 Pointer_group_interface::add_grob (last_spacing_,
97 ly_symbol2scm ("right-items" ),
98 note_column_);
103 for (int i=0; i < rheads_.size (); i++)
105 if (!rheads_[i]->get_parent (X_AXIS))
106 Note_column::add_head (note_column_, rheads_[i]);
108 rheads_.set_size (0);
112 if (note_column_)
114 if (dotcol_
115 && !dotcol_->get_parent (X_AXIS))
117 Note_column::set_dotcol (note_column_, dotcol_);
120 if (stem_
121 && !stem_->get_parent (X_AXIS))
123 Note_column::set_stem (note_column_, stem_);
124 stem_ = 0;
130 void
131 Rhythmic_column_engraver::acknowledge_grob (Grob_info i)
133 Item * item = dynamic_cast <Item *> (i.grob_);
134 if (!item || item->get_parent (X_AXIS))
135 return ;
136 if (Stem::has_interface (item))
138 stem_ = item;
140 else if (Rhythmic_head::has_interface (item))
142 rheads_.push (item);
144 else if (Dot_column::has_interface (item))
146 dotcol_ = item;
150 void
151 Rhythmic_column_engraver::stop_translation_timestep ()
153 note_column_ =0;
155 if (spacing_)
157 last_spacing_ = spacing_;
158 spacing_ =0;
161 dotcol_ =0;
162 stem_ =0;
167 ENTER_DESCRIPTION (Rhythmic_column_engraver,
168 /* descr */ "Generates NoteColumn, an objects that groups stems, noteheads and rests.",
169 /* creats*/ "NoteColumn NoteSpacing",
170 /* accepts */ "",
171 /* acks */ "stem-interface rhythmic-head-interface dot-column-interface",
172 /* reads */ "",
173 /* write */ "");