flower-1.0.3
[lilypond.git] / pcol.cc
blob1ae06519ac55c90f4ae61c2904788e130651699a
1 #include "pcol.hh"
2 #include "pstaff.hh"
3 #include "debug.hh"
5 void
6 Idealspacing::print() const
8 #ifndef NPRINT
9 mtor << "idealspacing {" ;
10 mtor << "distance "<<space<< " strength " << hooke << "}\n";
11 #endif
14 Idealspacing::Idealspacing(const PCol * l,const PCol * r)
16 space = 0.0;
17 hooke = 0.0;
18 left = l;
19 right = r;
22 void
23 Idealspacing::OK() const
25 #ifndef NDEBUG
26 assert(hooke >= 0 && left && right);
27 #endif
30 /****************************************************************/
32 Interval
33 PCol::width() const
35 Interval w;
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;
44 void
45 PCol::print() const
47 #ifndef NPRINT
48 mtor << "PCol {";
49 mtor << "# symbols: " << its.size() ;
50 if (breakable()){
51 mtor << "pre,post: ";
52 prebreak->print();
53 postbreak->print();
55 mtor << "extent: " << width().min << ", " << width().max << "\n";
56 mtor << "}\n";
57 #endif
60 int
61 PCol::compare(const PCol &, const PCol &)
63 assert(false);
64 return 0 ;
67 void
68 PCol::OK () const
70 if (prebreak || postbreak ) {
71 assert(prebreak&&postbreak);
72 assert(prebreak->daddy == this);
73 assert(postbreak->daddy == this);
78 void
79 PCol::set_breakable()
81 if (breakable())
82 return;
84 prebreak = new PCol(this);
85 postbreak = new PCol(this);
86 used = true;
89 bool
90 PCol::breakable() const
92 return prebreak||postbreak;
95 PCol::PCol(PCol *parent) {
96 daddy = parent;
97 prebreak=0;
98 postbreak=0;
99 line=0;
100 used = false;
103 PCol::~PCol()
106 delete prebreak;
108 delete postbreak;
111 void
112 PCol::add(const Item *i)
114 its.bottom().add(i);
115 used = true;