2 stem-grav.cc -- implement Stem_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "staff-symbol-referencer.hh"
10 #include "stem-engraver.hh"
11 #include "note-head.hh"
13 #include "musical-request.hh"
14 #include "duration-convert.hh"
16 #include "stem-tremolo.hh"
17 #include "staff-info.hh"
18 #include "translator-group.hh"
20 Stem_engraver::Stem_engraver()
25 default_abbrev_i_
= 16;
30 Stem_engraver::do_creation_processing ()
32 SCM prop
= get_property ("abbrev", 0);
33 if (gh_number_p(prop
))
35 default_abbrev_i_
= gh_scm2int (prop
);
40 Stem_engraver::acknowledge_element(Score_element_info i
)
42 if (Rhythmic_head
* h
= dynamic_cast<Rhythmic_head
*> (i
.elem_l_
))
47 Rhythmic_req
* r
= dynamic_cast <Rhythmic_req
*> (i
.req_l_
);
48 int duration_log
= r
->duration_
.durlog_i_
;
52 Staff_symbol_referencer_interface
st(stem_p_
);
55 stem_p_
->set_elt_property ("duration-log", gh_int2scm (duration_log
));
62 hmm, which isn't so bad?
64 int t
= abbrev_req_l_
->type_i_
;
66 t
= default_abbrev_i_
;
68 default_abbrev_i_
= t
;
72 abbrev_p_
= new Stem_tremolo
;
73 announce_element (Score_element_info (abbrev_p_
, abbrev_req_l_
));
74 abbrev_p_
->abbrev_flags_i_
=intlog2 (t
) - (duration_log
>? 2);
78 // must give the request, to preserve the rhythmic info.
79 announce_element (Score_element_info (stem_p_
, r
));
82 if (stem_p_
->flag_i () != duration_log
)
84 r
->warning (_f ("Adding note head to incompatible stem (type = %d)", 1 << stem_p_
->flag_i ()));
87 stem_p_
->add_head (h
);
92 Stem_engraver::do_pre_move_processing()
96 abbrev_p_
->set_stem (stem_p_
);
97 typeset_element (abbrev_p_
);
103 Translator_group
* which
;
104 SCM prop
= get_property ("stemLeftBeamCount", &which
);
105 if (gh_number_p(prop
))
107 stem_p_
->set_beaming (gh_scm2int (prop
),LEFT
);
108 ((Translator_group
*)which
)->set_property ("stemLeftBeamCount", SCM_UNDEFINED
);
110 prop
= get_property ("stemRightBeamCount", &which
);
111 if (gh_number_p(prop
))
113 stem_p_
->set_beaming (gh_scm2int (prop
), RIGHT
);
114 ((Translator_group
*)which
)->set_property ("stemRightBeamCount", SCM_UNDEFINED
);
117 // UGH. Should mark non-forced instead.
118 SCM dir
= stem_p_
->get_elt_property ("direction");
119 if (gh_number_p (dir
) && to_dir(dir
))
121 stem_p_
->set_elt_property ("dir-forced", SCM_BOOL_T
);
125 typeset_element(stem_p_
);
132 Stem_engraver::do_try_music (Music
* r
)
134 if (Tremolo_req
* a
= dynamic_cast <Tremolo_req
*> (r
))
143 ADD_THIS_TRANSLATOR(Stem_engraver
);