2 beam-grav.cc -- implement Beam_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
8 #include "duration-convert.hh"
9 #include "time-description.hh"
10 #include "beam-grav.hh"
13 #include "musical-request.hh"
14 #include "grouping.hh"
17 Beam_engraver::Beam_engraver()
19 span_reqs_drul_
[LEFT
] = span_reqs_drul_
[RIGHT
] =0;
21 current_grouping_p_
=0;
25 Beam_engraver::do_try_request(Request
*r
)
27 Musical_req
* mus_l
= r
->musical();
31 Beam_req
* b
= mus_l
->beam ();
35 if (bool (beam_p_
) == bool (b
->spantype
== Span_req::START
))
38 Direction d
= (!beam_p_
) ? LEFT
: RIGHT
;
39 if (span_reqs_drul_
[d
] && !span_reqs_drul_
[d
]->equal_b (mus_l
))
42 span_reqs_drul_
[d
] = b
;
47 Beam_engraver::do_process_requests()
49 if (beam_p_
|| !span_reqs_drul_
[LEFT
])
52 current_grouping_p_
= new Rhythmic_grouping
;
55 Scalar prop
= get_property ("beamslopedamping");
57 beam_p_
->damping_i_
= prop
;
59 prop
= get_property ("beamquantisation");
61 beam_p_
->quantisation_
= (Beam::Quantisation
)(int)prop
;
63 announce_element (Score_elem_info (beam_p_
, span_reqs_drul_
[LEFT
]));
67 Beam_engraver::do_pre_move_processing()
69 if (!beam_p_
|| !span_reqs_drul_
[RIGHT
])
72 Rhythmic_grouping
const * rg_C
= get_staff_info().rhythmic_C_
;
73 rg_C
->extend (current_grouping_p_
->interval());
74 beam_p_
->set_grouping (*rg_C
, *current_grouping_p_
);
75 typeset_element (beam_p_
);
78 delete current_grouping_p_
;
79 current_grouping_p_
= 0;
81 span_reqs_drul_
[RIGHT
] = span_reqs_drul_
[LEFT
] = 0;
85 Beam_engraver::do_removal_processing()
89 span_reqs_drul_
[LEFT
]->warning (_("unterminated beam"));
90 typeset_element (beam_p_
);
97 Beam_engraver::acknowledge_element (Score_elem_info i
)
99 if (!beam_p_
|| !i
.elem_l_
->is_type_b (Stem::static_name ()))
102 Stem
* s
= (Stem
*)i
.elem_l_
->item();
103 Rhythmic_req
*rhythmic_req
= i
.req_l_
->musical ()->rhythmic ();
104 if (rhythmic_req
->duration_
.durlog_i_
<= 2)
106 rhythmic_req
->warning (_("Stem doesn't fit in Beam"));
111 TODO: do something sensible if it doesn't fit in the beam.
113 Moment start
= get_staff_info().time_C_
->whole_in_measure_
;
115 if (!current_grouping_p_
->child_fit_b (start
))
117 String
s (_("please fix me: Stem at ")
118 + now_moment ().str ()
119 + _(" does not fit in beam"));
121 i
.req_l_
->warning(s
);
127 current_grouping_p_
->add_child (start
, rhythmic_req
->duration ());
128 s
->flag_i_
= rhythmic_req
->duration_
.durlog_i_
;
132 IMPLEMENT_IS_TYPE_B1(Beam_engraver
, Engraver
);
133 ADD_THIS_TRANSLATOR(Beam_engraver
);