2 slur-reg.cc -- implement Slur_register
4 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
9 #include "musicalrequest.hh"
10 #include "complex-walker.hh"
11 #include "slur-reg.hh"
14 #include "notehead.hh"
17 Slur_register::set_feature(Features i
)
19 dir_i_
= i
.direction_i_
;
22 Slur_register::Slur_register()
24 set_feature(Features::dir(0));
28 Slur_register::try_request(Request
*req_l
)
33 new_slur_req_l_arr_
.push(req_l
->slur());
38 Slur_register::acknowledge_element(Staff_elem_info info
)
40 if (info
.elem_p_
->name() == Notehead::static_name()) {
41 Notehead
*head_p
=(Notehead
*) info
.elem_p_
;// ugh
42 for (int i
= 0; i
< slur_l_stack_
.size(); i
++)
43 slur_l_stack_
[i
]->add(head_p
);
44 for (int i
= 0; i
< end_slur_l_arr_
.size(); i
++)
45 end_slur_l_arr_
[i
]->add(head_p
);
52 Slur_register::process_requests()
54 Array
<Slur
*> start_slur_l_arr_
;
55 for (int i
=0; i
< new_slur_req_l_arr_
.size(); i
++) {
56 Slur_req
* slur_req_l
= new_slur_req_l_arr_
[i
];
57 // end slur: move the slur to other array
58 if (slur_req_l
->spantype
== Span_req::STOP
) {
59 if (slur_l_stack_
.empty())
60 warning("can't find slur to end",
61 slur_req_l
->defined_ch_c_l_
);
63 end_slur_l_arr_
.push(slur_l_stack_
.pop());
66 } else if (slur_req_l
->spantype
== Span_req::START
) {
67 // push a new slur onto stack.
68 //(use temp. array to wait for all slur STOPs)
70 requests_arr_
.push(slur_req_l
);
71 start_slur_l_arr_
.push(s_p
);
72 announce_element(Staff_elem_info(s_p
, slur_req_l
));
75 for (int i
=0; i
< start_slur_l_arr_
.size(); i
++)
76 slur_l_stack_
.push(start_slur_l_arr_
[i
]);
80 Slur_register::pre_move_processing()
82 for (int i
= 0; i
< end_slur_l_arr_
.size(); i
++) {
84 end_slur_l_arr_
[i
]->dir_i_
= dir_i_
;
85 typeset_element(end_slur_l_arr_
[i
]);
87 end_slur_l_arr_
.set_size(0);
91 Slur_register::post_move_processing()
93 new_slur_req_l_arr_
.set_size(0);
95 Slur_register::~Slur_register()
97 for (int i
=0; i
< requests_arr_
.size(); i
++) {
98 warning("unterminated slur", requests_arr_
[i
]->defined_ch_c_l_
);