lilypond-0.1.14
[lilypond.git] / src / staffwalker.cc
blobc3900d35f21673e831c457643433d34840ac4e36
1 /*
2 staffwalker.cc -- implement Staff_walker
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
9 #include "grouping.hh"
10 #include "staff.hh"
11 #include "musicalrequest.hh"
12 #include "staffwalker.hh"
13 #include "staffcolumn.hh"
14 #include "scorecolumn.hh"
15 #include "debug.hh"
16 #include "timedescription.hh"
17 #include "commandrequest.hh"
18 #include "grouping.hh"
19 #include "scorewalker.hh"
21 Staff_walker::~Staff_walker()
23 do_pre_move();
26 Staff_walker::Staff_walker(Staff_walker const &s)
27 :PCursor<Staff_column*> (s)
29 assert(false);
32 Staff_walker::Staff_walker(Staff * s, PScore*ps )
33 : PCursor<Staff_column*> (s->cols_)
35 staff_l_ = s;
36 pscore_l_ = ps;
38 // should be in tdes. TODO
39 default_grouping = new Rhythmic_grouping(MInterval(0, 1), 4);
40 score_walk_l_ = 0;
43 Moment
44 Staff_walker::when() const
46 return ptr()->when();
50 void
51 Staff_walker::process_timing_reqs()
53 for (int i=0; i < ptr()->timing_req_l_arr_.size(); i++) {
54 Timing_req * tr_l = ptr()->timing_req_l_arr_[i];
55 if (tr_l->meterchange()) {
56 int b_i=tr_l->meterchange()->beats_i_;
57 int o_i = tr_l->meterchange()->one_beat_i_;
58 time_.set_meter(b_i, o_i);
60 *default_grouping = Rhythmic_grouping(
61 MInterval(0,Moment(b_i, o_i)), b_i);
65 for (int i=0; i < ptr()->timing_req_l_arr_.size(); i++) {
66 Timing_req * tr_l = ptr()->timing_req_l_arr_[i];
67 if (tr_l->partial()) {
68 time_.setpartial(tr_l->partial()->duration_);
69 } else if (tr_l->barcheck() && time_.whole_in_measure_) {
70 warning( "Barcheck failed", tr_l->defined_ch_c_l_ );
71 } else if (tr_l->cadenza()) {
72 time_.set_cadenza(tr_l->cadenza()->on_b_);
73 } else if (tr_l->measuregrouping()) {
74 *default_grouping = parse_grouping(
75 tr_l->measuregrouping()->beat_i_arr_,
76 tr_l->measuregrouping()->elt_length_arr_);
79 time_.OK();
82 void
83 Staff_walker::operator++(int i)
85 Moment last = when();
87 do_pre_move();
88 PCursor<Staff_column*>::operator++(i);
89 if (ok() ) {
90 Moment delta_t = when() - last;
91 assert(delta_t >0);
92 time_.add( delta_t );
94 do_post_move();
97 void
98 Staff_walker::process()
100 process_timing_reqs();
101 process_requests();
104 void
105 Staff_walker::allow_break()
107 score_walk_l_->allow_break(this);