lilypond-0.0.5
[lilypond.git] / calcideal.cc
blob1dc0e1d3859e79f73d02e35bf6b8aad1e2f37465
1 #include "tstream.hh"
2 #include "score.hh"
3 #include "pscore.hh"
4 #include "staff.hh"
5 #include "paper.hh"
6 #include "misc.hh"
7 #include "sccol.hh"
8 #include "debug.hh"
11 void
12 Score::do_connect(PCol *c1, PCol *c2, Real d)
14 Idealspacing*sp=pscore_->get_spacing(c1,c2);
16 if (!sp->hooke){
17 sp->hooke = 1.0;
18 sp->space =d;
22 void
23 Score::connect_nonmus(PCol* c1, PCol *c2, Real d)
25 if (c2->used && c1->used) {
26 do_connect(c1,c2,d);
28 // alert! this is broken!
29 if (c1->breakable()) {
30 do_connect(c1->postbreak, c2,d);
32 if (c2->breakable()) {
33 do_connect(c1, c2->prebreak,d);
35 if (c1->breakable() &&c2->breakable()) {
36 do_connect(c1->postbreak, c2->prebreak,d);
40 /* this needs A LOT of rethinking.
42 generate springs between columns.
44 void
45 Score::calc_idealspacing()
47 PCursor<Score_column*> sc(cols_);
49 for (; sc.ok(); sc++) {
50 if (sc->musical)
51 for (int i=0; i < sc->durations.sz(); i++) {
52 Real d = sc->durations[i];
53 Real dist = duration_to_idealspace(d, paper_->whole_width);
54 PCol * c2 = find_col(sc->when + d,true)->pcol;
55 connect_nonmus(sc->pcol, c2, dist);
56 c2 = find_col(sc->when + d,false)->pcol;
57 connect_nonmus(sc->pcol, c2, dist);
59 else if (sc->used()) { // ignore empty columns
60 PCol * c2 = find_col(sc->when,true)->pcol;
61 connect_nonmus(sc->pcol,c2,0.0);