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"
19 The name says it all: make multi measure rests
21 class Multi_measure_rest_engraver
: public Engraver
24 VIRTUAL_COPY_CONS(Translator
);
25 Multi_measure_rest_engraver ();
28 virtual void acknowledge_element (Score_element_info i
);
29 virtual void do_process_music ();
30 virtual bool do_try_music (Music
*);
31 virtual void do_pre_move_processing ();
32 virtual void do_post_move_processing ();
33 virtual void do_removal_processing ();
35 Span_req
* new_req_l_
;
36 Span_req
* busy_span_req_l_
;
37 Span_req
* stop_req_l_
;
41 Multi_measure_rest
*mmrest_p_
;
42 Multi_measure_rest
*lastrest_p_
;
45 ADD_THIS_TRANSLATOR (Multi_measure_rest_engraver
);
47 Multi_measure_rest_engraver::Multi_measure_rest_engraver ()
50 mmrest_p_
= lastrest_p_
=0;
51 new_req_l_
= busy_span_req_l_
= stop_req_l_
=0;
55 Multi_measure_rest_engraver::acknowledge_element (Score_element_info i
)
57 if (Bar
*c
= dynamic_cast<Bar
*> (i
.elem_l_
))
60 mmrest_p_
->add_column (c
);
62 lastrest_p_
->add_column (c
);
67 Multi_measure_rest_engraver::do_try_music (Music
* req_l
)
69 if (Span_req
* sp
= dynamic_cast<Span_req
*> (req_l
))
71 if (sp
->span_type_str_
== "rest")
73 if (sp
->span_dir_
== STOP
)
77 else if (sp
->span_dir_
== START
&& !new_req_l_
)
90 Multi_measure_rest_engraver::do_process_music ()
92 if (new_req_l_
&& stop_req_l_
)
96 start_moment_
= now_mom ();
106 busy_span_req_l_
= new_req_l_
;
110 if (busy_span_req_l_
&& !mmrest_p_
)
112 mmrest_p_
= new Multi_measure_rest (get_property ("basicMultiMeasureRestProperties"));
113 Staff_symbol_referencer_interface
si (mmrest_p_
);
116 announce_element (Score_element_info (mmrest_p_
, busy_span_req_l_
));
118 = gh_scm2int (get_property ("currentBarNumber"));
123 Multi_measure_rest_engraver::do_pre_move_processing ()
125 SCM smp
= get_property ("measurePosition");
126 Moment mp
= (unsmob_moment (smp
)) ? *unsmob_moment (smp
) : Moment (0);
128 if (mmrest_p_
&& (now_mom () >= start_moment_
)
130 && (scm_ilength (mmrest_p_
->get_elt_pointer ("columns")) >= 2))
132 typeset_element (mmrest_p_
);
134 must keep mmrest_p_ around to set measures_i_
139 typeset_element (lastrest_p_
);
145 busy_span_req_l_
= new_req_l_
;
152 Multi_measure_rest_engraver::do_post_move_processing ()
154 Moment
now (now_mom ());
157 SCM smp
= get_property ("measurePosition");
158 Moment mp
= (unsmob_moment (smp
)) ? *unsmob_moment (smp
) : Moment (0);
160 if (mmrest_p_
&& !mp
)
162 lastrest_p_
= mmrest_p_
;
163 int cur
= gh_scm2int (get_property ("currentBarNumber"));
164 lastrest_p_
->set_elt_property ("measure-count",
165 gh_int2scm (cur
- start_measure_i_
));
172 Multi_measure_rest_engraver::do_removal_processing ()
175 typeset_element (mmrest_p_
);
177 typeset_element (lastrest_p_
);