]> git.donarmstrong.com Git - lilypond.git/blob - pcol.cc
44c82a938ddf67ff316bbb82c0663638c2a4c32c
[lilypond.git] / 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 void
22 Idealspacing::OK() const
23 {
24 #ifndef NDEBUG
25     assert(hooke >= 0 && left  && right);
26 #endif    
27 }
28
29 /****************************************************************/
30
31 Interval
32 PCol::width() const
33 {
34     Interval w;
35
36     for (PCursor<const Item *> ic(its); ic.ok(); ic++)
37         w.unite(ic->width());
38     if (w.empty())
39         w.unite(Interval(0,0));
40     return w;
41 }
42
43 void
44 PCol::print() const
45 {
46     #ifndef NPRINT
47     mtor << "PCol {";
48     mtor << "# symbols: " << its.size() ;
49     mtor << "breakable: " << breakable<<"\n";
50     mtor << "extent: " << width().min << ", " << width().max << "\n";
51     mtor << "}\n";
52     #endif 
53 }
54
55 int
56 PCol::compare(const PCol &, const PCol &)
57 {
58     assert(false);
59     return 0 ;
60 }
61
62 void
63 PCol::OK () const
64 {
65     if (prebreak || postbreak ) {
66         assert(breakable);
67     }
68     
69 }
70
71 void
72 PCol::set_breakable()
73 {
74     if (breakable)
75         return;
76
77     prebreak = new PCol(this);
78     postbreak = new PCol(this);
79     breakable = true;
80     used = true;
81 }
82
83 PCol::PCol(PCol *parent) {
84     daddy = parent;
85     prebreak=0;
86     postbreak=0;
87     breakable=false;
88     line=0;
89     used  = false;
90 }
91
92 PCol::~PCol()
93 {
94     if (prebreak)
95         delete prebreak;        // no recursion!
96     if (postbreak)
97         delete postbreak;       
98 }
99
100 void
101 PCol::add(const Item *i)
102 {
103     its.bottom().add(i);
104     used = true;
105 }
106