lilypond-0.0.4
[lilypond.git] / calcideal.cc
blobb1410aefc013e9974f28b622c750e2d74c885098
1 #include "tstream.hh"
2 #include "score.hh"
3 #include "pscore.hh"
4 #include "staff.hh"
5 #include "misc.hh"
6 #include "debug.hh"
9 void
10 Score::do_connect(PCol *c1, PCol *c2, Real d)
12 Idealspacing*sp=pscore_->get_spacing(c1,c2);
14 if (!sp->hooke){
15 sp->hooke = 1.0;
16 sp->space =d;
20 void
21 Score::connect_nonmus(PCol* c1, PCol *c2, Real d)
23 if (c2->used && c1->used) {
24 do_connect(c1,c2,d);
26 // alert! this is broken!
27 if (c1->breakable) {
28 do_connect(c1->postbreak, c2,d);
30 if (c2->breakable) {
31 do_connect(c1, c2->prebreak,d);
33 if (c1->breakable &&c2->breakable) {
34 do_connect(c1->postbreak, c2->prebreak,d);
38 /* this needs A LOT of rethinking.
40 generate springs between columns.
42 void
43 Score::calc_idealspacing()
45 PCursor<Score_column*> sc(cols_);
47 for (; sc.ok(); sc++) {
48 if (sc->musical)
49 for (int i=0; i < sc->durations.sz(); i++) {
50 Mtime d = sc->durations[i];
51 Real dist = duration_to_idealspace(d);
52 PCol * c2 = find_col(sc->when + d,true)->pcol;
53 connect_nonmus(sc->pcol, c2, dist);
54 c2 = find_col(sc->when + d,false)->pcol;
55 connect_nonmus(sc->pcol, c2, dist);
57 else if (sc->used()) { // ignore empty columns
58 PCol * c2 = find_col(sc->when,true)->pcol;
59 connect_nonmus(sc->pcol,c2,0.0);