]> git.donarmstrong.com Git - lilypond.git/blob - src/pcol.cc
release: 0.0.10
[lilypond.git] / src / pcol.cc
1 #include "pcol.hh"
2 #include "pstaff.hh"
3 #include "debug.hh"
4
5 void
6 Idealspacing::print() const
7 {
8 #ifndef NPRINT
9     mtor << "idealspacing {" ;
10     mtor << "distance "<<space<< " strength " << hooke << "}\n";
11 #endif
12 }
13
14 Idealspacing::Idealspacing(const PCol * l,const PCol * r)
15 {
16     space = 0.0;
17     hooke = 0.0;
18     left = l;
19     right = r;
20 }
21
22 void
23 Idealspacing::OK() const
24 {
25 #ifndef NDEBUG
26     assert(hooke >= 0 && left  && right);
27 #endif    
28 }
29
30 /****************************************************************/
31
32 Interval
33 PCol::width() const
34 {
35     Interval w;
36
37     for (PCursor<const Item *> ic(its); ic.ok(); ic++)
38         w.unite(ic->width());
39     if (w.empty())
40         w.unite(Interval(0,0));
41     return w;
42 }
43
44 void
45 PCol::print() const
46 {
47     #ifndef NPRINT
48     mtor << "PCol {";
49     mtor << "# symbols: " << its.size() ;
50     if (breakable()){
51         mtor << "pre,post: ";
52         prebreak->print();
53         postbreak->print();
54     }
55     mtor << "extent: " << width().min << ", " << width().max << "\n";
56     mtor << "}\n";
57     #endif 
58 }
59
60 int
61 PCol::compare(const PCol &, const PCol &)
62 {
63     assert(false);
64     return 0 ;
65 }
66
67 void
68 PCol::OK () const
69 {
70     if (prebreak || postbreak ) {
71         assert(prebreak&&postbreak);
72         assert(prebreak->daddy == this);
73         assert(postbreak->daddy == this);
74     }
75     
76 }
77
78 void
79 PCol::set_breakable()
80 {
81     if (breakable())
82         return;
83
84     prebreak = new PCol(this);
85     postbreak = new PCol(this);
86     used = true;
87 }
88
89 bool
90 PCol::breakable() const
91 {
92     return prebreak||postbreak;
93 }
94
95 PCol::PCol(PCol *parent)
96 {
97     daddy = parent;
98     prebreak=0;
99     postbreak=0;
100     line=0;
101     used  = false;
102 }
103
104 PCol::~PCol()
105 {
106     delete prebreak;
107     delete postbreak;   
108 }
109
110 void
111 PCol::add( Item *i)
112 {
113     its.bottom().add(i);
114     i->pcol_ = this;
115     used = true;
116 }