5 #include "simplestaff.hh"
6 #include "simplewalker.hh"
13 #include "clefitem.hh"
16 #include "localkeyitem.hh"
19 Simple_walker::do_INTERPRET_command(Command*com)
21 if (com->args[0] == "BAR") {
22 local_key_.reset(key_);
23 } else if (com->args[0] == "KEY") {
24 svec<String> s(com->args);
28 oldkey_undo = new svec<int>( key_.oldkey_undo(s));
31 typesetkey = key_.read(s);
32 local_key_.reset(key_);
33 } else if (com->args[0] == "CLEF") {
34 svec<String> s(com->args);
38 WARN << " ignoring INTERPRET command: " << com->args[0];
43 Simple_walker::do_TYPESET_command(Command*com)
45 /* ignore these commands if non-default versions have been
47 if (com->args[0] == "CURRENTKEY")
53 if (com->args[0] == "CURRENTCLEF")
57 com->args[0] = "CLEF";
60 Item* i = staff()->get_TYPESET_item(com);
64 if (com->args[0] == "KEY") {
66 ((Keyitem*) i)->read(*oldkey_undo);
71 ((Keyitem*) i)->read(typesetkey); // ugh
74 if (com->args[0] == "CLEF") {
76 ((Clef_item*)i)->read(clef_);
78 col()->typeset_item_directional(i, 1, break_status);
82 Simple_walker::do_local_key(Note_req*n)
84 if ( local_key_.oct(n->octave).acc(n->name) != n->accidental) {
85 if (!local_key_item_) {
86 local_key_item_ = staff()->get_local_key_item();
89 local_key_item_->add(n->octave, n->name, n->accidental);
90 local_key_.oct(n->octave).set(n->name, n->accidental);
95 Simple_walker::do_note(Rhythmic_req*rq)
97 Simple_column*c = col();
98 Simple_staff *s = staff();
101 Note_req * req = rq->note() ;
102 const Voice *v = req->elt->voice_;
104 Notehead*n = s->get_notehead(req, clef_.c0_pos);
107 int sidx =find_slur(v);
109 pending_slurs[sidx]->add(n);
117 c->typeset_item( s->get_rest(rq->rest()) );
122 Simple_walker::process_requests()
124 Simple_column*c = col();
125 Simple_staff *s = staff();
126 if (c->beam_&& c->beam_->spantype == Span_req::START) {
128 error("Too many beams");
131 for (int i=0; i < c->slurs.sz(); i++) {
132 Slur_req*sl = c->slurs[i];
134 if (sl->spantype == Span_req::START) {
135 if (find_slur(sl->elt->voice_ )>=0)
136 error("Too many slurs in voice");
137 pending_slur_reqs.add(sl);
138 pending_slurs.add(new Slur);
143 stem_ = s->get_stem(c->stem_->stem());
146 for (int i = 0; i < c->notes.sz(); i ++) {
147 do_note(c->notes[i]);
154 c->typeset_item(stem_);
155 /* needed, otherwise placement of
156 local_key fucks up */
157 stem_->set_default_extents();
159 if (c->beam_&& c->beam_->spantype == Span_req::STOP) {
160 pscore_->typeset_spanner(beam_, s->theline);
163 for (int i = 0; i < noteheads.sz(); i++) {
164 c->typeset_item(noteheads[i]);
166 noteheads.set_size(0);
168 if (local_key_item_) {
169 c->typeset_item_directional(local_key_item_, -1);
175 for (int i=0; i < c->slurs.sz(); i++) {
176 Slur_req*sl = c->slurs[i];
178 if (sl->spantype == Span_req::STOP) {
179 int idx = find_slur(sl->elt->voice_);
181 error("can't find slur to end");
183 pscore_->typeset_spanner(pending_slurs[idx],
185 pending_slurs.del(idx);
186 pending_slur_reqs.del(idx);
192 Simple_walker::Simple_walker(Simple_staff*s)
193 : Staff_walker(s, s->theline->pscore_)
199 Local_key_item * i = s->get_local_key_item();
209 Simple_walker::staff()
211 return (Simple_staff*) staff_;
217 return (Simple_column*) *(*this);
221 Simple_walker::reset()
223 processed_clef =false;
224 processed_key = false;
228 Simple_walker::find_slur(const Voice *v)
230 for (int i=0; i < pending_slur_reqs.sz(); i++) {
231 if (pending_slur_reqs[i]->elt->voice_ == v)