2 multi_measure_rest-engraver.cc -- implement Multi_measure_rest_engraver
4 (c) 1998--2000 Jan Nieuwenhuizen <janneke@gnu.org>
5 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "musical-request.hh"
10 #include "multi-measure-rest.hh"
11 #include "paper-column.hh"
12 #include "engraver-group-engraver.hh"
14 #include "staff-symbol-referencer.hh"
15 #include "engraver.hh"
20 The name says it all: make multi measure rests
22 class Multi_measure_rest_engraver
: public Engraver
25 VIRTUAL_COPY_CONS(Translator
);
26 Multi_measure_rest_engraver ();
29 virtual void acknowledge_element (Score_element_info i
);
30 virtual void do_process_music ();
31 virtual bool do_try_music (Music
*);
32 virtual void do_pre_move_processing ();
33 virtual void do_post_move_processing ();
34 virtual void do_removal_processing ();
36 Span_req
* new_req_l_
;
37 Span_req
* busy_span_req_l_
;
38 Span_req
* stop_req_l_
;
46 ADD_THIS_TRANSLATOR (Multi_measure_rest_engraver
);
48 Multi_measure_rest_engraver::Multi_measure_rest_engraver ()
51 mmrest_p_
= lastrest_p_
=0;
52 new_req_l_
= busy_span_req_l_
= stop_req_l_
=0;
56 Multi_measure_rest_engraver::acknowledge_element (Score_element_info i
)
58 Item
* item
= dynamic_cast<Item
*> (i
.elem_l_
);
59 if (item
&& Bar::has_interface (item
))
62 Multi_measure_rest::add_column (mmrest_p_
,item
);
64 Multi_measure_rest::add_column (lastrest_p_
,item
);
69 Multi_measure_rest_engraver::do_try_music (Music
* req_l
)
71 if (Span_req
* sp
= dynamic_cast<Span_req
*> (req_l
))
73 if (sp
->span_type_str_
== "rest")
75 if (sp
->span_dir_
== STOP
)
79 else if (sp
->span_dir_
== START
&& !new_req_l_
)
92 Multi_measure_rest_engraver::do_process_music ()
94 if (new_req_l_
&& stop_req_l_
)
98 start_moment_
= now_mom ();
108 busy_span_req_l_
= new_req_l_
;
112 if (busy_span_req_l_
&& !mmrest_p_
)
114 mmrest_p_
= new Multi_measure_rest (get_property ("basicMultiMeasureRestProperties"));
115 Multi_measure_rest::set_interface (mmrest_p_
);
116 Staff_symbol_referencer::set_interface (mmrest_p_
);
118 announce_element (Score_element_info (mmrest_p_
, busy_span_req_l_
));
120 = gh_scm2int (get_property ("currentBarNumber"));
125 Multi_measure_rest_engraver::do_pre_move_processing ()
127 SCM smp
= get_property ("measurePosition");
128 Moment mp
= (unsmob_moment (smp
)) ? *unsmob_moment (smp
) : Moment (0);
130 if (mmrest_p_
&& (now_mom () >= start_moment_
)
132 && (scm_ilength (mmrest_p_
->get_elt_property ("columns")) >= 2))
134 typeset_element (mmrest_p_
);
136 must keep mmrest_p_ around to set measures_i_
141 typeset_element (lastrest_p_
);
147 busy_span_req_l_
= new_req_l_
;
154 Multi_measure_rest_engraver::do_post_move_processing ()
156 Moment
now (now_mom ());
159 SCM smp
= get_property ("measurePosition");
160 Moment mp
= (unsmob_moment (smp
)) ? *unsmob_moment (smp
) : Moment (0);
162 if (mmrest_p_
&& !mp
)
164 lastrest_p_
= mmrest_p_
;
165 int cur
= gh_scm2int (get_property ("currentBarNumber"));
166 lastrest_p_
->set_elt_property ("measure-count",
167 gh_int2scm (cur
- start_measure_i_
));
174 Multi_measure_rest_engraver::do_removal_processing ()
177 typeset_element (mmrest_p_
);
179 typeset_element (lastrest_p_
);