2 tie-reg.cc -- implement Ties_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "ties-engraver.hh"
11 #include "note-head.hh"
12 #include "musical-request.hh"
13 #include "music-list.hh"
15 Ties_engraver::Ties_engraver()
17 req_l_
= end_req_l_
=0;
18 processed_ack_pass_i_
= 0;
23 Ties_engraver::do_post_move_processing()
25 processed_ack_pass_i_
=0;
29 Ties_engraver::do_try_music (Music
*req
)
31 if (Tie_req
* r
= dynamic_cast <Tie_req
*> (req
))
41 Ties_engraver::acknowledge_element (Score_element_info i
)
43 if (!req_l_
&& ! end_req_l_
)
45 if (Note_head
* h
= dynamic_cast <Note_head
*> (i
.elem_l_
))
47 Melodic_req
*m
= dynamic_cast <Melodic_req
*> (i
.req_l_
);
49 head_mel_tuple_arr_
.push (Head_melodic_tuple (h
, m
));
54 Ties_engraver::process_acknowledged ()
56 if (!head_mel_tuple_arr_
.size () || processed_ack_pass_i_
++)
59 head_mel_tuple_arr_
.sort (Head_melodic_tuple::compare
);
60 if (req_l_
&& !tie_p_arr_
.size ())
62 for (int i
=0; i
< head_mel_tuple_arr_
.size (); i
++)
65 p
->set_head (LEFT
,head_mel_tuple_arr_
[i
].head_l_
);
66 // announce_element (Score_element_info (p, req_l_));
73 for (int i
=0; i
< end_tie_p_arr_
.size (); i
++)
76 if (j
>= head_mel_tuple_arr_
.size ())
78 left_head_mel_tuple_arr_
[i
].mel_l_
->warning (_( "Can't find a note head at the right to attach Tie"));
79 j
= head_mel_tuple_arr_
.size () -1;
82 Tie
*p
=end_tie_p_arr_
[i
];
83 p
->set_head (RIGHT
, head_mel_tuple_arr_
[j
].head_l_
);
84 if (!Melodic_req::compare (*head_mel_tuple_arr_
[j
].mel_l_
,
85 *left_head_mel_tuple_arr_
[j
].mel_l_
))
86 p
->same_pitch_b_
= true;
87 announce_element ( Score_element_info (p
, end_req_l_
));
94 Ties_engraver::do_pre_move_processing()
96 if (!head_mel_tuple_arr_
.size ())
100 for (int i
=0; i
< end_tie_p_arr_
.size (); i
++)
102 Scalar
tie_dir (get_property ("tieYDirection"));
103 Scalar
y_dir (get_property ("ydirection"));
104 Direction dir
= CENTER
;
105 if (tie_dir
.length_i () && tie_dir
.isnum_b ())
106 dir
= (Direction
) sign (int (tie_dir
));
107 else if (y_dir
.length_i () && y_dir
.isnum_b ())
108 dir
= (Direction
) sign (int (y_dir
));
110 end_tie_p_arr_
[i
]->dir_
= dir
;
111 typeset_element (end_tie_p_arr_
[i
]);
114 end_tie_p_arr_
= tie_p_arr_
;
115 left_head_mel_tuple_arr_
= head_mel_tuple_arr_
;
119 head_mel_tuple_arr_
.clear ();
124 Ties_engraver::do_removal_processing ()
129 Ties_engraver::do_process_requests ()
134 ADD_THIS_TRANSLATOR(Ties_engraver
);
137 Head_melodic_tuple::Head_melodic_tuple ()
143 Head_melodic_tuple::Head_melodic_tuple (Note_head
*h
, Melodic_req
*m
)
150 Head_melodic_tuple::compare (Head_melodic_tuple
const&h1
,
151 Head_melodic_tuple
const &h2
)
153 return Melodic_req::compare (*h1
.mel_l_
, *h2
.mel_l_
);