2 spaceable-grob.cc -- implement Spaceable_grob
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "spaceable-grob.hh"
15 Spaceable_grob::get_minimum_distances (Grob
*me
)
17 return me
->get_grob_property ("minimum-distances");
20 /*todo: merge code of spring & rod?
23 Spaceable_grob::add_rod (Grob
*me
, Grob
* p
, Real d
)
25 SCM mins
= get_minimum_distances (me
);
26 SCM newdist
= gh_double2scm (d
);
27 for (SCM s
= mins
; gh_pair_p (s
); s
= gh_cdr (s
))
29 SCM dist
= gh_car (s
);
30 if (gh_car (dist
) == p
->self_scm ())
32 gh_set_cdr_x (dist
, scm_max (gh_cdr (dist
),
38 mins
= gh_cons (gh_cons (p
->self_scm (), newdist
), mins
);
39 me
->set_grob_property ("minimum-distances", mins
);
43 Spaceable_grob::add_spring (Grob
*me
, Grob
* p
, Real d
, Real strength
)
45 SCM mins
= me
->get_grob_property ("ideal-distances");
48 SCM newdist
= gh_double2scm (d
);
49 for (SCM s
= mins
; gh_pair_p (s
); s
= gh_cdr (s
))
51 SCM dist
= gh_car (s
);
52 if (gh_car (dist
) == p
->self_scm ())
54 programming_error ("already have that spring");
58 SCM newstrength
= gh_double2scm (strength
);
60 mins
= gh_cons (gh_cons (p
->self_scm (), gh_cons (newdist
, newstrength
)), mins
);
61 me
->set_grob_property ("ideal-distances", mins
);
66 Spaceable_grob::remove_interface (Grob
*me
)
68 me
->remove_grob_property ("minimum-distances");
69 me
->remove_grob_property ("ideal-distances");
70 me
->remove_grob_property ("dir-list");
75 Spaceable_grob::set_interface (Grob
*me
)
77 me
->set_interface (ly_symbol2scm ("spaceable-grob-interface"));