2 spaceable-element.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-element.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 = get_ideal_distances (me);
46 SCM newdist= gh_double2scm (d);
47 for (SCM s = mins; gh_pair_p (s); s = gh_cdr (s))
49 SCM dist = gh_car (s);
50 if (gh_car (dist) == p->self_scm ())
52 programming_error("already have that spring");
56 SCM newstrength= gh_double2scm (strength);
58 mins = gh_cons (gh_cons (p->self_scm (), gh_cons (newdist, newstrength)), mins);
59 me->set_grob_property ("ideal-distances", mins);
63 Spaceable_grob::get_ideal_distances (Grob*me)
65 return me->get_grob_property ("ideal-distances");
70 Spaceable_grob::remove_interface (Grob*me)
72 me->remove_grob_property ("minimum-distances");
73 me->remove_grob_property ("ideal-distances");
74 me->remove_grob_property ("dir-list");
79 Spaceable_grob::set_interface (Grob*me)
81 me->set_interface (ly_symbol2scm ("spaceable-element-interface"));