2 beam-engraver.cc -- implement Beam_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "beam-engraver.hh"
11 #include "musical-request.hh"
13 #include "grouping.hh"
16 #include "time-description.hh"
18 Beam_engraver::Beam_engraver ()
22 finished_grouping_p_ = 0;
24 reqs_drul_[LEFT] = reqs_drul_[RIGHT] =0;
28 Beam_engraver::do_try_music (Music *m)
30 if (Beam_req * c = dynamic_cast<Beam_req*>(m))
32 reqs_drul_[c->spantype_] = c;
40 Beam_engraver::do_process_requests ()
45 reqs_drul_[STOP]->warning (_("No beam to stop"));
46 finished_beam_p_ = beam_p_;
47 finished_grouping_p_ = grouping_p_;
53 if (reqs_drul_[START])
56 grouping_p_ = new Rhythmic_grouping;
58 Scalar prop = get_property ("beamslopedamping", 0);
60 beam_p_->damping_i_ = prop;
62 prop = get_property ("beamquantisation", 0);
64 beam_p_->quantisation_ = (Beam::Quantisation)(int)prop;
66 // silly try at interstaff beam
67 // must set minVerticalAlign == maxVerticalAlign to get sane results
68 // see input/test/beam-interstaff.ly
69 prop = get_property ("minVerticalAlign", 0);
71 beam_p_->vertical_align_f_ = prop;
73 prop = get_property ("maxVerticalAlign", 0);
76 beam_p_->vertical_align_f_ += (Real)prop;
77 beam_p_->vertical_align_f_ /= (Real)2;
80 announce_element (Score_element_info (beam_p_, reqs_drul_[START]));
85 Beam_engraver::typeset_beam ()
89 Rhythmic_grouping const * rg_C = get_staff_info().rhythmic_C_;
90 rg_C->extend (finished_grouping_p_->interval());
91 finished_beam_p_->set_grouping (*rg_C, *finished_grouping_p_);
92 typeset_element (finished_beam_p_);
95 delete finished_grouping_p_;
96 finished_grouping_p_= 0;
103 Beam_engraver::do_post_move_processing ()
105 reqs_drul_ [START] =0;
109 Beam_engraver::do_pre_move_processing ()
115 Beam_engraver::do_removal_processing ()
118 finished_beam_p_ = beam_p_;
119 finished_grouping_p_ = grouping_p_;
124 Beam_engraver::acknowledge_element (Score_element_info info)
128 Stem* stem_l = dynamic_cast<Stem *> (info.elem_l_);
133 Rhythmic_req *rhythmic_req = dynamic_cast <Rhythmic_req *> (info.req_l_);
136 String s=_("Stem must have Rhythmic structure.");
138 info.req_l_->warning(s);
146 if (rhythmic_req->duration_.durlog_i_<= 2)
148 rhythmic_req->warning (_ ("stem doesn't fit in beam"));
153 TODO: do something sensible if it doesn't fit in the beam.
155 Moment start = get_staff_info().time_C_->whole_in_measure_;
157 if (!grouping_p_->child_fit_b (start))
159 String s (_("please fix me") + ": "
160 + _f ("stem at %s doesn't fit in beam", now_moment ().str ()));
163 info.req_l_->warning(s);
169 grouping_p_->add_child (start, rhythmic_req->duration ());
170 stem_l->flag_i_ = rhythmic_req->duration_.durlog_i_;
171 beam_p_->add_stem (stem_l);
178 ADD_THIS_TRANSLATOR(Beam_engraver);