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 "stem-engraver.hh"
10 #include "note-head.hh"
12 #include "musical-request.hh"
13 #include "duration-convert.hh"
16 #include "staff-info.hh"
17 #include "translator-group.hh"
19 Stem_engraver::Stem_engraver()
24 default_abbrev_i_ = 16;
28 Stem_engraver::do_creation_processing ()
30 Scalar prop = get_property ("abbrev", 0);
33 default_abbrev_i_ = prop;
38 Stem_engraver::acknowledge_element(Score_element_info i)
40 if (Rhythmic_head * h = dynamic_cast<Rhythmic_head *> (i.elem_l_))
42 Rhythmic_req * r = dynamic_cast <Rhythmic_req *> (i.req_l_);
43 int duration_log = r->duration_.durlog_i_;
47 stem_p_->flag_i_ = duration_log;
54 hmm, which isn't so bad?
56 int t = abbrev_req_l_->type_i_;
58 t = default_abbrev_i_;
60 default_abbrev_i_ = t;
64 abbrev_p_ = new Abbreviation;
65 announce_element (Score_element_info (abbrev_p_, abbrev_req_l_));
66 abbrev_p_->abbrev_flags_i_ =intlog2 (t) - (duration_log>? 2);
70 // must give the request, to preserve the rhythmic info.
71 announce_element (Score_element_info (stem_p_, r));
74 if (stem_p_->flag_i_ != duration_log)
76 r->warning (_f("Adding note head to incompatible stem (type = %d)", 1 << stem_p_->flag_i_));
79 stem_p_->add_head (h);
84 Stem_engraver::do_pre_move_processing()
88 abbrev_p_->set_stem (stem_p_);
89 typeset_element (abbrev_p_);
95 Scalar prop = get_property ("verticalDirection", 0);
96 Direction dir = prop.isnum_b () ? (Direction)int(prop) : CENTER;
100 stem_p_->set_elt_property (dir_forced_scm_sym, SCM_BOOL_T);
103 Translator_group const *which;
104 prop = get_property ("stemLeftBeamCount", &which);
107 stem_p_->beams_i_drul_[LEFT] = prop;
108 ((Translator_group*)which)->set_property ("stemLeftBeamCount", "");
110 prop = get_property ("stemRightBeamCount", &which);
113 stem_p_->beams_i_drul_[RIGHT] = prop;
114 ((Translator_group*)which)->set_property ("stemRightBeamCount", "");
117 typeset_element(stem_p_);
124 Stem_engraver::do_try_music (Music* r)
126 if (Abbreviation_req* a = dynamic_cast <Abbreviation_req *> (r))
135 ADD_THIS_TRANSLATOR(Stem_engraver);