]> git.donarmstrong.com Git - lilypond.git/blob - lily/staff.cc
a533c32f1afc0da0a3f5b7a9155432be7a8dda63
[lilypond.git] / lily / staff.cc
1 /*
2   staff.cc -- implement Staff
3
4   source file of the LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8 #include "input-register.hh"
9 #include "proto.hh"
10 #include "staff.hh"
11 #include "score.hh"
12 #include "voice.hh"
13 #include "staff-column.hh"
14 #include "score-column.hh"
15 #include "voice-element.hh"
16 #include "debug.hh"
17 #include "musical-request.hh"
18 #include "command-request.hh" // todo
19
20
21 void
22 Staff::add(PointerList<Voice*> const &l)
23 {
24     for (iter_top(l,i); i.ok(); i++)
25         voice_list_.bottom().add(i);
26 }
27
28 Paper_def *
29 Staff::paper() const
30 {
31     return score_l_->paper_p_;
32 }
33
34 void
35 Staff::clean_cols()
36 {
37 #if 0 // TODO
38     iter_top(cols_,i);
39     for(; i.ok(); ){
40         if (!i->musical_column_l_->used_b())
41             i->musical_column_l_ = 0;
42         if (!i->command_column_l_->used_b())
43             i->command_column_l_ =0;
44         
45         if (!i->command_column_l_&& !i->musical_column_l_)
46             delete i.remove_p();
47         else
48             i++;
49     }
50 #endif
51 }
52
53
54 void
55 Staff::OK() const
56 {
57 #ifndef NDEBUG
58     cols_.OK();
59     voice_list_.OK();
60     iter_top(cols_, i);
61     iter_top(cols_, j);
62     i++;
63     for (; i.ok(); j++,i++) {
64         assert(j->when () < i->when() );
65     }
66     assert(score_l_);
67 #endif    
68 }
69
70
71 Moment
72 Staff::last() const
73 {
74     Moment l = 0;
75     for (iter_top(voice_list_,i); i.ok(); i++) {
76         l = l >? i->last();
77     }
78     return l;
79 }
80
81 void
82 Staff::print() const
83 {
84 #ifndef NPRINT
85     mtor << "Staff {\n";
86     for (iter_top(voice_list_,i); i.ok(); i++) {
87         i->print();     
88     }
89     ireg_p_->print();
90     mtor <<"}\n";
91 #endif
92 }
93
94 Staff::Staff()
95 {    
96     ireg_p_ =0;
97     score_l_ =0;
98     pscore_l_ =0;
99     pstaff_l_ =0;
100 }
101
102 void
103 Staff::add_col(Staff_column*c_l)
104 {
105     cols_.bottom().add(c_l);
106     c_l->staff_l_ = this;
107 }