From d969b400cbfa104cf59475cf8ac82a689b75da13 Mon Sep 17 00:00:00 2001 From: fred Date: Sun, 24 Mar 2002 19:55:50 +0000 Subject: [PATCH] lilypond-0.1.11 --- lily/beam-grav.cc | 130 +++++++++++++++++++++++++++++++++++++++++++ lily/clef-item.cc | 16 +++--- lily/include/bar.hh | 16 +++--- lily/include/beam.hh | 44 +++++++-------- 4 files changed, 168 insertions(+), 38 deletions(-) create mode 100644 lily/beam-grav.cc diff --git a/lily/beam-grav.cc b/lily/beam-grav.cc new file mode 100644 index 0000000000..dcdce82975 --- /dev/null +++ b/lily/beam-grav.cc @@ -0,0 +1,130 @@ +/* + beam-grav.cc -- implement Beam_engraver + + source file of the GNU LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys +*/ +#include "duration-convert.hh" +#include "time-description.hh" +#include "beam-grav.hh" +#include "stem.hh" +#include "beam.hh" +#include "musical-request.hh" +#include "grouping.hh" +#include "text-spanner.hh" +#include "text-def.hh" + +Beam_engraver::Beam_engraver() +{ + span_reqs_drul_[LEFT] = span_reqs_drul_[RIGHT] =0; + beam_p_ =0; + current_grouping_p_ =0; +} + +bool +Beam_engraver::do_try_request(Request*r) +{ + Musical_req* mus_l = r->musical(); + if (!mus_l) + return false; + + Beam_req * b = mus_l->beam(); + + if (!b) + return false; + + if (bool (beam_p_) == bool (b->spantype == Span_req::START)) + return false; + + Direction d = (!beam_p_) ? LEFT : RIGHT; + if (span_reqs_drul_[d] && !span_reqs_drul_[d]->equal_b (mus_l)) + return false; + + span_reqs_drul_[d] = b; + return true; +} + +void +Beam_engraver::do_process_requests() +{ + if ( !beam_p_ && span_reqs_drul_[LEFT]) { + current_grouping_p_ = new Rhythmic_grouping; + beam_p_ = new Beam; + if (span_reqs_drul_[LEFT]->nplet) + { + Text_spanner* t = new Text_spanner(); + Text_def *defp = new Text_def; + t->set_support (beam_p_); + defp->align_i_ = 0; + defp->text_str_ = span_reqs_drul_[LEFT]->nplet; + defp->style_str_="italic"; + t->spec_p_ = defp; + announce_element (Score_elem_info (t,0)); + typeset_element (t); + } + announce_element (Score_elem_info (beam_p_, span_reqs_drul_[LEFT])); + } +} + +void +Beam_engraver::do_pre_move_processing() +{ + if (beam_p_ && span_reqs_drul_[RIGHT]) { + Rhythmic_grouping const * rg_C = get_staff_info().rhythmic_C_; + rg_C->extend (current_grouping_p_->interval()); + beam_p_->set_grouping (*rg_C, *current_grouping_p_); + typeset_element (beam_p_); + beam_p_ = 0; + + delete current_grouping_p_; + current_grouping_p_ = 0; + + span_reqs_drul_[RIGHT] = + span_reqs_drul_[LEFT] = 0; + } +} + +void +Beam_engraver::do_removal_processing() +{ + if (beam_p_) + { + span_reqs_drul_[LEFT]->warning ("unterminated beam"); + typeset_element (beam_p_); + beam_p_ =0; + } +} + + +void +Beam_engraver::acknowledge_element (Score_elem_info i) +{ + if (beam_p_ && i.elem_l_->is_type_b (Stem::static_name())) + { + Stem * s = (Stem*)i.elem_l_->item(); + Rhythmic_req *rhythmic_req = i.req_l_->musical ()->rhythmic (); + if (rhythmic_req->duration_.durlog_i_<= 2) + { + rhythmic_req->warning ("Stem doesn't fit in Beam"); + return ; + } + + /* + TODO: do something sensible if it doesn't fit in the beam. + */ + current_grouping_p_->add_child (get_staff_info().time_C_->whole_in_measure_, + rhythmic_req->duration()); + /* + TODO + should change rep. of flags too.k + */ + s->flag_i_ = Duration_convert::type2_i + (rhythmic_req->duration_.durlog_i_); + s->print_flag_b_ = false; + beam_p_->add (s); + } +} + +IMPLEMENT_IS_TYPE_B1(Beam_engraver, Engraver); +ADD_THIS_ENGRAVER(Beam_engraver); diff --git a/lily/clef-item.cc b/lily/clef-item.cc index 8a2534b111..fc579ec347 100644 --- a/lily/clef-item.cc +++ b/lily/clef-item.cc @@ -21,8 +21,8 @@ Clef_item::do_pre_processing() if (default_b_) { - empty_b_ = (break_status_i() != 1); - transparent_b_ = (break_status_i() != 1); + empty_b_ = (break_status_i() != 1); + transparent_b_ = (break_status_i() != 1); } } @@ -39,13 +39,13 @@ Clef_item::read (String t) { type_= t; if (type_ == "violin") - y_off = 2; + y_off = 2; if (type_ == "alto") - y_off = 4; + y_off = 4; if (type_ == "tenor") - y_off = 6; + y_off = 6; if (type_ == "bass") - y_off = 6; + y_off = 6; } void Clef_item::read (Clef_engraver const &k) @@ -54,11 +54,11 @@ Clef_item::read (Clef_engraver const &k) } Molecule* -Clef_item::brew_molecule_p()const +Clef_item::brew_molecule_p() const { String t = type_; if (change_b_) - t += "_change"; + t += "_change"; Symbol s = paper()->lookup_l ()->clef (t); Molecule*output = new Molecule (Atom (s)); output->translate (paper()->internote_f () * y_off, Y_AXIS); diff --git a/lily/include/bar.hh b/lily/include/bar.hh index c03527e6cc..ce886830b0 100644 --- a/lily/include/bar.hh +++ b/lily/include/bar.hh @@ -14,17 +14,17 @@ */ class Bar:public Item { public: - String type_str_; - int spanned_i_; + String type_str_; + int spanned_i_; - DECLARE_MY_RUNTIME_TYPEINFO; - SCORE_ELEM_CLONE(Bar); - Bar(); + DECLARE_MY_RUNTIME_TYPEINFO; + SCORE_ELEM_CLONE(Bar); + Bar(); private: - void do_print() const; + void do_print() const; protected: - virtual void do_pre_processing(); - Molecule*brew_molecule_p()const; + virtual void do_pre_processing(); + Molecule*brew_molecule_p() const; }; #endif // BAR_HH diff --git a/lily/include/beam.hh b/lily/include/beam.hh index 48b4f9bb4c..ad775b7a3c 100644 --- a/lily/include/beam.hh +++ b/lily/include/beam.hh @@ -15,36 +15,36 @@ direction */ class Beam: public Directional_spanner { public: - Link_array stems; - /// the slope of the beam in posns / point (dimension) - Real slope; + Link_array stems; + /// the slope of the beam in posns / point (dimension) + Real slope; - /// position of leftmost end of beam - Real left_pos; + /// position of leftmost end of beam + Real left_pos; - /* *************** */ - DECLARE_MY_RUNTIME_TYPEINFO; - Beam(); - void add (Stem*); + /* *************** */ + DECLARE_MY_RUNTIME_TYPEINFO; + Beam(); + void add (Stem*); - void set_grouping (Rhythmic_grouping def, Rhythmic_grouping current); - void set_stemlens(); - SCORE_ELEM_CLONE(Beam); + void set_grouping (Rhythmic_grouping def, Rhythmic_grouping current); + void set_stemlens(); + SCORE_ELEM_CLONE(Beam); protected: - virtual Interval do_width()const; - virtual Offset center() const; - virtual void set_default_dir(); - virtual void do_pre_processing(); - virtual void do_post_processing(); - virtual void do_substitute_dependent (Score_elem*, Score_elem*); + virtual Interval do_width() const; + virtual Offset center() const; + virtual void set_default_dir(); + virtual void do_pre_processing(); + virtual void do_post_processing(); + virtual void do_substitute_dependent (Score_elem*, Score_elem*); - virtual void do_print() const; + virtual void do_print() const; private: - Molecule stem_beams (Stem *here, Stem *next, Stem *prev)const; - void solve_slope(); - Molecule*brew_molecule_p()const; + Molecule stem_beams (Stem *here, Stem *next, Stem *prev) const; + void solve_slope(); + Molecule*brew_molecule_p() const; }; #endif // BEAM_HH -- 2.39.5