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"
15 #include "stem-tremolo.hh"
16 #include "staff-info.hh"
17 #include "translator-group.hh"
19 Stem_engraver::Stem_engraver()
24 default_abbrev_i_ = 16;
29 Stem_engraver::do_creation_processing ()
31 Scalar prop = get_property ("abbrev", 0);
34 default_abbrev_i_ = prop;
39 Stem_engraver::acknowledge_element(Score_element_info i)
41 if (Rhythmic_head * h = dynamic_cast<Rhythmic_head *> (i.elem_l_))
46 Rhythmic_req * r = dynamic_cast <Rhythmic_req *> (i.req_l_);
47 int duration_log = r->duration_.durlog_i_;
51 stem_p_->flag_i_ = duration_log;
58 hmm, which isn't so bad?
60 int t = abbrev_req_l_->type_i_;
62 t = default_abbrev_i_;
64 default_abbrev_i_ = t;
68 abbrev_p_ = new Stem_tremolo;
69 announce_element (Score_element_info (abbrev_p_, abbrev_req_l_));
70 abbrev_p_->abbrev_flags_i_ =intlog2 (t) - (duration_log>? 2);
74 // must give the request, to preserve the rhythmic info.
75 announce_element (Score_element_info (stem_p_, r));
78 if (stem_p_->flag_i_ != duration_log)
80 r->warning (_f("Adding note head to incompatible stem (type = %d)", 1 << stem_p_->flag_i_));
83 stem_p_->add_head (h);
88 Stem_engraver::do_pre_move_processing()
92 abbrev_p_->set_stem (stem_p_);
93 typeset_element (abbrev_p_);
99 Scalar prop = get_property ("verticalDirection", 0);
100 Direction dir = prop.isnum_b () ? (Direction)int(prop) : CENTER;
104 stem_p_->set_elt_property (dir_forced_scm_sym, SCM_BOOL_T);
107 Translator_group const *which;
108 prop = get_property ("stemLeftBeamCount", &which);
111 stem_p_->beams_i_drul_[LEFT] = prop;
112 ((Translator_group*)which)->set_property ("stemLeftBeamCount", "");
114 prop = get_property ("stemRightBeamCount", &which);
117 stem_p_->beams_i_drul_[RIGHT] = prop;
118 ((Translator_group*)which)->set_property ("stemRightBeamCount", "");
121 prop = get_property ("stemLength", 0);
124 stem_p_->set_elt_property (length_scm_sym, gh_double2scm (prop.to_f ()));
127 prop = get_property ("stemStyle", 0);
130 stem_p_->set_elt_property (style_scm_sym, gh_str02scm (prop.ch_C()));
133 typeset_element(stem_p_);
140 Stem_engraver::do_try_music (Music* r)
142 if (Tremolo_req* a = dynamic_cast <Tremolo_req *> (r))
151 ADD_THIS_TRANSLATOR(Stem_engraver);