]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.3.70
authorfred <fred>
Tue, 26 Mar 2002 23:24:27 +0000 (23:24 +0000)
committerfred <fred>
Tue, 26 Mar 2002 23:24:27 +0000 (23:24 +0000)
22 files changed:
lily/beam.cc
lily/break-algorithm.cc
lily/gourlay-breaking.cc
lily/grace-align-item.cc
lily/include/break-algorithm.hh
lily/include/column-x-positions.hh
lily/include/item.hh
lily/include/line-of-score.hh
lily/include/paper-column.hh
lily/include/simple-spacer.hh
lily/include/spaceable-element.hh [new file with mode: 0644]
lily/include/spacing-spanner.hh
lily/include/spanner.hh
lily/item.cc
lily/line-of-score.cc
lily/paper-column.cc
lily/paper-score.cc
lily/rod.cc
lily/score-engraver.cc
lily/script-column-engraver.cc
lily/separating-line-group-engraver.cc
lily/spring.cc

index 604c4d356bdb3a542718fe9e3b9ec52921183d16..9e59ec64851ef735e95d7ba00e2b0ae7ad2eab20 100644 (file)
 
 
 #include <math.h> // tanh.
+
+
 #include "directional-element-interface.hh"
 #include "beaming.hh"
-#include "dimensions.hh"
 #include "beam.hh"
 #include "misc.hh"
-#include "debug.hh"
 #include "least-squares.hh"
 #include "stem.hh"
 #include "paper-def.hh"
 #include "group-interface.hh"
 #include "staff-symbol-referencer.hh"
 #include "cross-staff.hh"
-
-Beam::Beam (SCM s)
-  : Spanner (s)
-{
-  Score_element*me =this;
-  
-  Pointer_group_interface g (me, "stems");
-  g.set_interface ();
-
-  set_elt_property ("height", gh_int2scm (0)); // ugh.
-  set_elt_property ("y-position" ,gh_int2scm (0));
-}
+#include "item.hh"
+#include "spanner.hh"
+#include "warn.hh"
 
 void
-Beam::add_stem (Score_element*s)
+Beam::add_stem (Score_element*me, Score_element*s)
 {
-    Score_element*me =this;
   Pointer_group_interface gi (me, "stems");
   gi.add_element (s);
   
   s->add_dependency (me);
 
   assert (!Stem::beam_l (s));
-  s->set_elt_property ("beam", self_scm_);
+  s->set_elt_property ("beam", me->self_scm_);
 
   add_bound_item (dynamic_cast<Spanner*> (me), dynamic_cast<Item*> (s));
 }
 
 int
-Beam::get_multiplicity () const
+Beam::get_multiplicity (Score_element*me) 
 {
-  Score_element*me =(Score_element*)this;
   int m = 0;
   for (SCM s = me->get_elt_property ("stems"); gh_pair_p (s); s = gh_cdr (s))
     {
@@ -86,23 +75,20 @@ MAKE_SCHEME_CALLBACK(Beam,before_line_breaking);
 SCM
 Beam::before_line_breaking (SCM smob)
 {
-  
-  Score_element * beam =  unsmob_element (smob);
-  Beam * me =dynamic_cast<Beam*> (beam);
+  Score_element * me =  unsmob_element (smob);
 
   // Why?
-  if (me->visible_stem_count () < 2)
+  if (visible_stem_count (me) < 2)
     {
       warning (_ ("beam has less than two stems"));
-
     }
 
   if (!Directional_element_interface (me).get ())
-    Directional_element_interface (me).set (me->get_default_dir ());
+    Directional_element_interface (me).set (get_default_dir (me));
 
-  me->auto_knees ();
-  me->set_stem_directions ();
-  me->set_stem_shorten ();
+  auto_knees (me);
+  set_stem_directions (me);
+  set_stem_shorten (me);
 
   return SCM_EOL;
 }
@@ -111,14 +97,14 @@ Beam::before_line_breaking (SCM smob)
  FIXME
  */
 Direction
-Beam::get_default_dir () const
+Beam::get_default_dir (Score_element*me) 
 {
   Drul_array<int> total;
   total[UP]  = total[DOWN] = 0;
   Drul_array<int> count; 
   count[UP]  = count[DOWN] = 0;
   Direction d = DOWN;
-  Spanner*me = (Spanner*)this;
+
   Link_array<Item> stems=
        Pointer_group_interface__extract_elements (me, (Item*)0, "stems");
 
@@ -150,7 +136,7 @@ Beam::get_default_dir () const
   /*
     If dir is not determined: get default
   */
-  return to_dir (get_elt_property ("default-neutral-direction"));
+  return to_dir (me->get_elt_property ("default-neutral-direction"));
 }
 
 
@@ -160,11 +146,11 @@ Beam::get_default_dir () const
        once stem gets cleaned-up.
  */
 void
-Beam::set_stem_directions ()
+Beam::set_stem_directions (Score_element*me)
 {
   Link_array<Item> stems
-    =Pointer_group_interface__extract_elements (this,  (Item*) 0, "stems");
-  Direction d = Directional_element_interface (this).get ();
+    =Pointer_group_interface__extract_elements (me,  (Item*) 0, "stems");
+  Direction d = Directional_element_interface (me).get ();
   
   for (int i=0; i <stems.size (); i++)
     {
@@ -176,10 +162,10 @@ Beam::set_stem_directions ()
 } 
 
 void
-Beam::auto_knees ()
+Beam::auto_knees (Score_element*me)
 {
-  if (!auto_knee ("auto-interstaff-knee-gap", true))
-    auto_knee ("auto-knee-gap", false);
+  if (!auto_knee (me,"auto-interstaff-knee-gap", true))
+    auto_knee (me, "auto-knee-gap", false);
 }
 
 /*
@@ -190,12 +176,11 @@ Beam::auto_knees ()
   don't set, or unset autoKneeGap/autoInterstaffKneeGap.
  */
 bool
-Beam::auto_knee (String gap_str, bool interstaff_b)
+Beam::auto_knee (Score_element*me, String gap_str, bool interstaff_b)
 {
   bool knee_b = false;
   int knee_y = 0;
-  SCM gap = get_elt_property (gap_str.ch_C());
-  Spanner* me =  this;
+  SCM gap = me->get_elt_property (gap_str.ch_C());
   
   Direction d = Directional_element_interface (me).get ();
       Link_array<Item> stems=
@@ -203,15 +188,16 @@ Beam::auto_knee (String gap_str, bool interstaff_b)
   
   if (gh_number_p (gap))
     {
+      Spanner*sp = dynamic_cast<Spanner*> (me);
       int auto_gap_i = gh_scm2int (gap);
       for (int i=1; i < stems.size (); i++)
         {
-         bool is_b = (bool)(calc_interstaff_dist (stems[i], me
-           - calc_interstaff_dist (stems[i-1], me));
+         bool is_b = (bool)(calc_interstaff_dist (stems[i], sp
+           - calc_interstaff_dist (stems[i-1], sp));
          int l_y = (int)(Stem::head_positions(stems[i-1])[d])
-           + (int)calc_interstaff_dist (stems[i-1], me);
+           + (int)calc_interstaff_dist (stems[i-1], sp);
          int r_y = (int)(Stem::head_positions(stems[i])[d])
-           + (int)calc_interstaff_dist (stems[i], me);
+           + (int)calc_interstaff_dist (stems[i], sp);
          int gap_i = r_y - l_y;
 
          if ((abs (gap_i) >= auto_gap_i) && (!interstaff_b || is_b))
@@ -228,7 +214,7 @@ Beam::auto_knee (String gap_str, bool interstaff_b)
         {
          Item *s = stems[i];     
          int y = (int)(Stem::head_positions(s)[d])
-           + (int)calc_interstaff_dist (s, me);
+           + (int)calc_interstaff_dist (s, dynamic_cast<Spanner*> (me));
 
          Directional_element_interface (s).set (y < knee_y ? UP : DOWN);
          s->set_elt_property ("dir-forced", SCM_BOOL_T);
@@ -244,17 +230,17 @@ Beam::auto_knee (String gap_str, bool interstaff_b)
     scmify forced-fraction
  */
 void
-Beam::set_stem_shorten ()
+Beam::set_stem_shorten (Score_element*m)
 {
-  Spanner*me = this;
-  if (!visible_stem_count ())
+  Spanner*me = dynamic_cast<Spanner*> (m);
+  if (!visible_stem_count (me))
     return;
 
-  Real forced_fraction = forced_stem_count () / visible_stem_count ();
+  Real forced_fraction = forced_stem_count (me) / visible_stem_count (me);
   if (forced_fraction < 0.5)
     return;
 
-  int multiplicity = get_multiplicity ();
+  int multiplicity = get_multiplicity (me);
 
   // grace stems?
   SCM shorten = scm_eval (ly_symbol2scm ("beamed-stem-shorten"));
@@ -268,7 +254,7 @@ Beam::set_stem_shorten ()
   SCM shorten_elt = scm_list_ref (shorten, gh_int2scm (multiplicity <? (sz - 1)));
   Real shorten_f = gh_scm2double (shorten_elt) * staff_space;
 
-  /* cute, but who invented this -- how to customise ? */
+  /* cute, but who invented me -- how to customise ? */
   if (forced_fraction < 1)
     shorten_f /= 2;
 
@@ -293,19 +279,18 @@ MAKE_SCHEME_CALLBACK(Beam,after_line_breaking);
 SCM
 Beam::after_line_breaking (SCM smob)
 {
-  Score_element * beam =  unsmob_element (smob);
-  Beam * me =dynamic_cast<Beam*> (beam);
+  Score_element * me =  unsmob_element (smob);
 
   /* first, calculate y, dy */
   Real y, dy;
-  me->calc_default_position_and_height (&y, &dy);
-  if (me->visible_stem_count ())
+calc_default_position_and_height (me, &y, &dy);
+  if (visible_stem_count (me))
     {
-      if (me->suspect_slope_b (y, dy))
+      if (suspect_slope_b (me, y, dy))
        dy = 0;
 
-      Real damped_dy = me->calc_slope_damping_f (dy);
-      Real quantised_dy = me->quantise_dy_f (damped_dy);
+      Real damped_dy = calc_slope_damping_f (me, dy);
+      Real quantised_dy = quantise_dy_f (me, damped_dy);
 
       y += (dy - quantised_dy) / 2;
       dy = quantised_dy;
@@ -336,11 +321,11 @@ Beam::after_line_breaking (SCM smob)
   else
     { 
       /* we can modify y, so we should quantise y */
-      Real y_shift = me->check_stem_length_f (y, dy);
+      Real y_shift = check_stem_length_f (me, y, dy);
       y += y_shift;
-      y = me->quantise_y_f (y, dy, 0);
-      me->set_stem_length (y, dy);
-      y_shift = me->check_stem_length_f (y, dy);
+      y = quantise_y_f (me,y, dy, 0);
+      set_stem_length (me, y, dy);
+      y_shift = check_stem_length_f (me, y, dy);
 
       if (y_shift > half_space / 4)
        {
@@ -353,12 +338,12 @@ Beam::after_line_breaking (SCM smob)
          int quant_dir = 0;
          if (abs (y_shift) > half_space / 2)
            quant_dir = sign (y_shift) * Directional_element_interface (me).get ();
-         y = me->quantise_y_f (y, dy, quant_dir);
+         y = quantise_y_f (me, y, dy, quant_dir);
        }
     }
   // UGH. Y is not in staff position unit?
   // Ik dacht datwe daar juist van weg wilden?
-  me->set_stem_length (y, dy);
+  set_stem_length (me, y, dy);
   me->set_elt_property ("y-position", gh_double2scm (y));
 
   return SCM_UNDEFINED;
@@ -368,16 +353,15 @@ Beam::after_line_breaking (SCM smob)
   See Documentation/tex/fonts.doc
  */
 void
-Beam::calc_default_position_and_height (Real* y, Real* dy) const
+Beam::calc_default_position_and_height (Score_element*me,Real* y, Real* dy) 
 {
-  Spanner*me = (Spanner*)this;
   *y = 0;
   *dy = 0;  
-  if (visible_stem_count () <= 1)
+  if (visible_stem_count (me) <= 1)
     return;
 
-  Real first_ideal = Stem::calc_stem_info (first_visible_stem ()).idealy_f_;
-  if (first_ideal == Stem::calc_stem_info (last_visible_stem ()).idealy_f_)
+  Real first_ideal = Stem::calc_stem_info (first_visible_stem (me)).idealy_f_;
+  if (first_ideal == Stem::calc_stem_info (last_visible_stem (me)).idealy_f_)
     {
       *dy = 0;
       *y = first_ideal;
@@ -385,7 +369,7 @@ Beam::calc_default_position_and_height (Real* y, Real* dy) const
     }
 
   Array<Offset> ideals;
-  Real x0 = first_visible_stem ()->relative_coordinate (0, X_AXIS);
+  Real x0 = first_visible_stem (me)->relative_coordinate (0, X_AXIS);
   Link_array<Item> stems=
     Pointer_group_interface__extract_elements (me, (Item*)0, "stems");
 
@@ -400,23 +384,23 @@ Beam::calc_default_position_and_height (Real* y, Real* dy) const
   Real dydx;
   minimise_least_squares (&dydx, y, ideals); // duh, takes references
 
-  Real dx = last_visible_stem ()->relative_coordinate (0, X_AXIS) - x0;
+  Real dx = last_visible_stem (me)->relative_coordinate (0, X_AXIS) - x0;
   *dy = dydx * dx;
 }
 
 bool
-Beam::suspect_slope_b (Real y, Real dy) const
+Beam::suspect_slope_b (Score_element*me, Real y, Real dy) 
 {
   /* first, calculate y, dy */
   /*
     steep slope running against lengthened stem is suspect
   */
-  Real first_ideal = Stem::calc_stem_info (first_visible_stem ()).idealy_f_;
-  Real last_ideal = Stem::calc_stem_info (last_visible_stem ()).idealy_f_;
-  Real lengthened = paper_l ()->get_var ("beam_lengthened");
-  Real steep = paper_l ()->get_var ("beam_steep_slope");
+  Real first_ideal = Stem::calc_stem_info (first_visible_stem (me)).idealy_f_;
+  Real last_ideal = Stem::calc_stem_info (last_visible_stem (me)).idealy_f_;
+  Real lengthened = me->paper_l ()->get_var ("beam_lengthened");
+  Real steep = me->paper_l ()->get_var ("beam_steep_slope");
 
-  Real dx = last_visible_stem ()->relative_coordinate (0, X_AXIS) - first_visible_stem ()->relative_coordinate (0, X_AXIS);
+  Real dx = last_visible_stem (me)->relative_coordinate (0, X_AXIS) - first_visible_stem (me)->relative_coordinate (0, X_AXIS);
   Real dydx = dy && dx ? dy/dx : 0;
 
   if (((y - first_ideal > lengthened) && (dydx > steep))
@@ -433,15 +417,15 @@ Beam::suspect_slope_b (Real y, Real dy) const
   corresponds with some tables in [Wanske]
 */
 Real
-Beam::calc_slope_damping_f (Real dy) const
+Beam::calc_slope_damping_f (Score_element*me,Real dy) 
 {
-  SCM damp = get_elt_property ("damping"); 
+  SCM damp = me->get_elt_property ("damping"); 
   int damping = gh_scm2int (damp);
 
   if (damping)
     {
-      Real dx = last_visible_stem ()->relative_coordinate (0, X_AXIS)
-       - first_visible_stem ()->relative_coordinate (0, X_AXIS);
+      Real dx = last_visible_stem (me)->relative_coordinate (0, X_AXIS)
+       - first_visible_stem (me)->relative_coordinate (0, X_AXIS);
       Real dydx = dy && dx ? dy/dx : 0;
       dydx = 0.6 * tanh (dydx) / damping;
       return dydx * dx;
@@ -450,18 +434,17 @@ Beam::calc_slope_damping_f (Real dy) const
 }
 
 Real
-Beam::calc_stem_y_f (Item* s, Real y, Real dy) const
+Beam::calc_stem_y_f (Score_element*me,Item* s, Real y, Real dy) 
 {
-  Score_element*me = (Score_element*)this;
-  Real thick = gh_scm2double (get_elt_property ("beam-thickness"));
-  thick *= paper_l ()->get_var ("staffspace");
+  Real thick = gh_scm2double (me->get_elt_property ("beam-thickness"));
+  thick *= me->paper_l ()->get_var ("staffspace");
   
-  int beam_multiplicity = get_multiplicity ();
+  int beam_multiplicity = get_multiplicity (me);
   int stem_multiplicity = (Stem::flag_i (s) - 2) >? 0;
 
-  Real interbeam_f = paper_l ()->interbeam_f (beam_multiplicity);
-  Real x0 = first_visible_stem ()->relative_coordinate (0, X_AXIS);
-  Real dx = last_visible_stem ()->relative_coordinate (0, X_AXIS) - x0;
+  Real interbeam_f = me->paper_l ()->interbeam_f (beam_multiplicity);
+  Real x0 = first_visible_stem (me)->relative_coordinate (0, X_AXIS);
+  Real dx = last_visible_stem (me)->relative_coordinate (0, X_AXIS) - x0;
   Real stem_y = (dy && dx ? (s->relative_coordinate (0, X_AXIS) - x0) / dx * dy : 0) + y;
 
   /* knee */
@@ -478,7 +461,7 @@ Beam::calc_stem_y_f (Item* s, Real y, Real dy) const
       
       // huh, why not for first visible?
        if (Staff_symbol_referencer::staff_symbol_l (s)
-          != Staff_symbol_referencer::staff_symbol_l (last_visible_stem ()))
+          != Staff_symbol_referencer::staff_symbol_l (last_visible_stem (me)))
         stem_y += Directional_element_interface (me).get ()
           * (beam_multiplicity - stem_multiplicity) * interbeam_f;
       }
@@ -487,9 +470,8 @@ Beam::calc_stem_y_f (Item* s, Real y, Real dy) const
 }
 
 Real
-Beam::check_stem_length_f (Real y, Real dy) const
+Beam::check_stem_length_f (Score_element*me,Real y, Real dy) 
 {
-  Score_element * me = (Score_element*)this;
   Real shorten = 0;
   Real lengthen = 0;
   Direction dir = Directional_element_interface (me).get ();
@@ -503,7 +485,7 @@ Beam::check_stem_length_f (Real y, Real dy) const
       if (Stem::invisible_b (s))
        continue;
 
-      Real stem_y = calc_stem_y_f (s, y, dy);
+      Real stem_y = calc_stem_y_f (me, s, y, dy);
        
       stem_y *= dir;
       Stem_info info = Stem::calc_stem_info (s);
@@ -526,10 +508,8 @@ Beam::check_stem_length_f (Real y, Real dy) const
   stem directions and length should set to relative to the chord's
   position of the beam.  */
 void
-Beam::set_stem_length (Real y, Real dy)
+Beam::set_stem_length (Score_element*me,Real y, Real dy)
 {
-  Beam*me = this;
-
   Real half_space = Staff_symbol_referencer::staff_space (me)/2;
   Link_array<Item> stems=
     Pointer_group_interface__extract_elements (me, (Item*)0, "stems");
@@ -541,10 +521,10 @@ Beam::set_stem_length (Real y, Real dy)
       if (Stem::invisible_b (s))
        continue;
 
-      Real stem_y = calc_stem_y_f (s, y, dy);
+      Real stem_y = calc_stem_y_f (me, s, y, dy);
 
       /* caution: stem measures in staff-positions */
-      Stem::set_stemend (s,(stem_y + calc_interstaff_dist (s, me)) / half_space);
+      Stem::set_stemend (s,(stem_y + calc_interstaff_dist (s, dynamic_cast<Spanner*> (me))) / half_space);
     }
 }
 
@@ -557,9 +537,8 @@ Beam::set_stem_length (Real y, Real dy)
   + n * staff_space
 */
 Real
-Beam::quantise_dy_f (Real dy) const
+Beam::quantise_dy_f (Score_element*me,Real dy) 
 {
-  Score_element*me = (Score_element*)this;
   Array<Real> a;
   for (SCM s = scm_eval (ly_symbol2scm ("beam-height-quants")); s !=SCM_EOL; s = gh_cdr (s))
     a.push (gh_scm2double (gh_car (s)));
@@ -586,10 +565,9 @@ Beam::quantise_dy_f (Real dy) const
   if extend_b then stems must *not* get shorter
  */
 Real
-Beam::quantise_y_f (Real y, Real dy, int quant_dir)
+Beam::quantise_y_f (Score_element*me,Real y, Real dy, int quant_dir)
 {
-  int multiplicity = get_multiplicity ();
-  Score_element*me = (Score_element*)this;
+  int multiplicity = get_multiplicity (me);
 
   Real staff_space = Staff_symbol_referencer::staff_space (me);
   SCM quants = scm_eval (gh_list (ly_symbol2scm ("beam-vertical-position-quants"),
@@ -617,9 +595,8 @@ Beam::quantise_y_f (Real y, Real dy, int quant_dir)
 }
 
 void
-Beam::set_beaming (Beaming_info_list *beaming)
+Beam::set_beaming (Score_element*me,Beaming_info_list *beaming)
 {
-  Score_element*me = this;
   Link_array<Score_element> stems=
     Pointer_group_interface__extract_elements (me, (Score_element*)0, "stems");
   
@@ -644,28 +621,27 @@ Beam::set_beaming (Beaming_info_list *beaming)
   clean  me up.
   */
 Molecule
-Beam::stem_beams (Item *here, Item *next, Item *prev) const
+Beam::stem_beams (Score_element*me,Item *here, Item *next, Item *prev) 
 {
-  Score_element*me = (Score_element*)this;
   if ((next && !(next->relative_coordinate (0, X_AXIS) > here->relative_coordinate (0, X_AXIS))) ||
       (prev && !(prev->relative_coordinate (0, X_AXIS) < here->relative_coordinate (0, X_AXIS))))
       programming_error ("Beams are not left-to-right");
 
-  Real staffline_f = paper_l ()->get_var ("stafflinethickness");
-  int multiplicity = get_multiplicity ();
+  Real staffline_f = me->paper_l ()->get_var ("stafflinethickness");
+  int multiplicity = get_multiplicity (me);
 
 
-  Real interbeam_f = paper_l ()->interbeam_f (multiplicity);
-  Real thick = gh_scm2double (get_elt_property ("beam-thickness"));
-  thick *= paper_l ()->get_var ("staffspace");
+  Real interbeam_f = me->paper_l ()->interbeam_f (multiplicity);
+  Real thick = gh_scm2double (me->get_elt_property ("beam-thickness"));
+  thick *= me->paper_l ()->get_var ("staffspace");
     
   Real bdy = interbeam_f;
   Real stemdx = staffline_f;
 
-  Real dx = visible_stem_count () ?
-    last_visible_stem ()->relative_coordinate (0, X_AXIS) - first_visible_stem ()->relative_coordinate (0, X_AXIS)
+  Real dx = visible_stem_count (me) ?
+    last_visible_stem (me)->relative_coordinate (0, X_AXIS) - first_visible_stem (me)->relative_coordinate (0, X_AXIS)
     : 0.0;
-  Real dy = gh_scm2double (get_elt_property ("height"));
+  Real dy = gh_scm2double (me->get_elt_property ("height"));
   Real dydx = dy && dx ? dy/dx : 0;
 
   Molecule leftbeams;
@@ -676,11 +652,11 @@ Beam::stem_beams (Item *here, Item *next, Item *prev) const
   if (!Stem::first_head (here))
     nw_f = 0;
   else if (Stem::type_i (here)== 1)
-    nw_f = paper_l ()->get_var ("wholewidth");
+    nw_f = me->paper_l ()->get_var ("wholewidth");
   else if (Stem::type_i (here) == 2)
-    nw_f = paper_l ()->get_var ("notewidth") * 0.8;
+    nw_f = me->paper_l ()->get_var ("notewidth") * 0.8;
   else
-    nw_f = paper_l ()->get_var ("quartwidth");
+    nw_f = me->paper_l ()->get_var ("quartwidth");
 
 
   Direction dir = Directional_element_interface (me).get ();
@@ -698,7 +674,7 @@ Beam::stem_beams (Item *here, Item *next, Item *prev) const
       w = w/2 <? nw_f;
       Molecule a;
       if (lhalfs)              // generates warnings if not
-       a =  lookup_l ()->beam (dydx, w, thick);
+       a =  me->lookup_l ()->beam (dydx, w, thick);
       a.translate (Offset (-w, -w * dydx));
       for (int j = 0; j  < lhalfs; j++)
        {
@@ -714,12 +690,12 @@ Beam::stem_beams (Item *here, Item *next, Item *prev) const
       int rwholebeams= Stem::beam_count (here,RIGHT) <? Stem::beam_count (next,LEFT) ;
 
       Real w = next->relative_coordinate (0, X_AXIS) - here->relative_coordinate (0, X_AXIS);
-      Molecule a = lookup_l ()->beam (dydx, w + stemdx, thick);
+      Molecule a = me->lookup_l ()->beam (dydx, w + stemdx, thick);
       a.translate_axis( - stemdx/2, X_AXIS);
       int j = 0;
       Real gap_f = 0;
 
-      SCM gap = get_elt_property ("beam-gap");
+      SCM gap = me->get_elt_property ("beam-gap");
       if (gh_number_p (gap))
        {
          int gap_i = gh_scm2int ( (gap));
@@ -734,7 +710,7 @@ Beam::stem_beams (Item *here, Item *next, Item *prev) const
          // TODO: notehead widths differ for different types
          gap_f = nw_f / 2;
          w -= 2 * gap_f;
-         a = lookup_l ()->beam (dydx, w + stemdx, thick);
+         a = me->lookup_l ()->beam (dydx, w + stemdx, thick);
        }
 
       for (; j  < rwholebeams; j++)
@@ -746,7 +722,7 @@ Beam::stem_beams (Item *here, Item *next, Item *prev) const
 
       w = w/2 <? nw_f;
       if (rhalfs)
-       a = lookup_l ()->beam (dydx, w, thick);
+       a = me->lookup_l ()->beam (dydx, w, thick);
 
       for (; j  < rwholebeams + rhalfs; j++)
        {
@@ -769,19 +745,18 @@ MAKE_SCHEME_CALLBACK(Beam,brew_molecule);
 SCM
 Beam::brew_molecule (SCM smob)
 {
-  Score_element * beam =  unsmob_element (smob);
-  Beam * me =dynamic_cast<Beam*> (beam);
+  Score_element * me =unsmob_element (smob);
 
   Molecule mol;
   if (!gh_pair_p (me->get_elt_property ("stems")))
     return SCM_EOL;
   Real x0,dx;
   Link_array<Item>stems = 
-    Pointer_group_interface__extract_elements ((Beam*) me, (Item*) 0, "stems");  
-  if (me->visible_stem_count ())
+    Pointer_group_interface__extract_elements (me, (Item*) 0, "stems");  
+  if (visible_stem_count (me))
     {
-      x0 = me->first_visible_stem ()->relative_coordinate (0, X_AXIS);
-      dx = me->last_visible_stem ()->relative_coordinate (0, X_AXIS) - x0;
+      x0 = first_visible_stem (me)->relative_coordinate (0, X_AXIS);
+      dx = last_visible_stem (me)->relative_coordinate (0, X_AXIS) - x0;
     }
   else
     {
@@ -801,23 +776,22 @@ Beam::brew_molecule (SCM smob)
       Item * prev = (j > 0)? stems[j-1] : 0;
       Item * next = (j < stems.size()-1) ? stems[j+1] :0;
 
-      Molecule sb = me->stem_beams (i, next, prev);
+      Molecule sb = stem_beams (me, i, next, prev);
       Real x = i->relative_coordinate (0, X_AXIS)-x0;
       sb.translate (Offset (x, x * dydx + y));
       mol.add_molecule (sb);
     }
   mol.translate_axis (x0 
-    - me->get_bound (LEFT)->relative_coordinate (0, X_AXIS), X_AXIS);
+    - dynamic_cast<Spanner*> (me)->get_bound (LEFT)->relative_coordinate (0, X_AXIS), X_AXIS);
 
   return mol.create_scheme ();
 }
 
 int
-Beam::forced_stem_count () const
+Beam::forced_stem_count (Score_element*me) 
 {
-  Score_element* me = (Score_element*)this;
   Link_array<Item>stems = 
-    Pointer_group_interface__extract_elements ((Beam*) me, (Item*) 0, "stems");
+    Pointer_group_interface__extract_elements ( me, (Item*) 0, "stems");
   int f = 0;
   for (int i=0; i < stems.size (); i++)
     {
@@ -840,9 +814,8 @@ Beam::forced_stem_count () const
    use filter and standard list functions.
  */
 int
-Beam::visible_stem_count () const
+Beam::visible_stem_count (Score_element*me) 
 {
-  Score_element * me = (Score_element*)this;
   Link_array<Item>stems = 
     Pointer_group_interface__extract_elements (me, (Item*) 0, "stems");
   int c = 0;
@@ -855,11 +828,10 @@ Beam::visible_stem_count () const
 }
 
 Item*
-Beam::first_visible_stem() const
+Beam::first_visible_stem(Score_element*me) 
 {
-  Score_element * me = (Score_element*)this;
   Link_array<Item>stems = 
-    Pointer_group_interface__extract_elements ((Beam*) me, (Item*) 0, "stems");
+    Pointer_group_interface__extract_elements ( me, (Item*) 0, "stems");
   
   for (int i = 0; i < stems.size (); i++)
     {
@@ -870,11 +842,10 @@ Beam::first_visible_stem() const
 }
 
 Item*
-Beam::last_visible_stem() const
+Beam::last_visible_stem(Score_element*me) 
 {
-  Score_element * me = (Score_element*)this;
   Link_array<Item>stems = 
-    Pointer_group_interface__extract_elements ((Beam*) me, (Item*) 0, "stems");
+    Pointer_group_interface__extract_elements ( me, (Item*) 0, "stems");
   for (int i = stems.size (); i--;)
     {
       if (!Stem::invisible_b (stems[i]))
@@ -902,8 +873,8 @@ Beam::rest_collision_callback (Score_element *rest, Axis a )
   Score_element * stem = st;
   if (!stem)
     return 0.0;
-  Beam * beam = dynamic_cast<Beam*> (unsmob_element (stem->get_elt_property ("beam"))); 
-  if (!beam || !beam->visible_stem_count ())
+  Score_element * beam = unsmob_element (stem->get_elt_property ("beam"));
+  if (!beam || !Beam::has_interface (beam) || !Beam::visible_stem_count (beam))
     return 0.0;
 
   // make callback for rest from this.
@@ -920,8 +891,8 @@ Beam::rest_collision_callback (Score_element *rest, Axis a )
   if (gh_number_p (s))
     beam_y = gh_scm2double (s);
   
-  Real x0 = beam->first_visible_stem()->relative_coordinate (0, X_AXIS);
-  Real dx = beam->last_visible_stem()->relative_coordinate (0, X_AXIS) - x0;
+  Real x0 = first_visible_stem(beam)->relative_coordinate (0, X_AXIS);
+  Real dx = last_visible_stem(beam)->relative_coordinate (0, X_AXIS) - x0;
   Real dydx = beam_dy && dx ? beam_dy/dx : 0;
 
   Direction d = Stem::get_direction (stem);
@@ -946,3 +917,21 @@ Beam::rest_collision_callback (Score_element *rest, Axis a )
 
   return  (-d *  discrete_dist);
 }
+
+
+bool
+Beam::has_interface (Score_element*me)
+{
+  return me->has_interface (ly_symbol2scm ("beam-interface"));
+}
+
+void
+Beam::set_interface (Score_element*me)
+{
+  Pointer_group_interface g (me, "stems");
+  g.set_interface ();
+
+  me->set_elt_property ("height", gh_int2scm (0)); // ugh.
+  me->set_elt_property ("y-position" ,gh_int2scm (0));
+  me->set_interface (ly_symbol2scm("beam-interface"));
+}
index 7c679d76fb42b0e22589e291d5494fbd55c41896..4802e0507c9ed2420495d5a0221605388158fa93 100644 (file)
 Array<int>
 Break_algorithm::find_break_indices () const
 {
-  Link_array<Paper_column> all = pscore_l_->line_l_->column_l_arr ();
-  
-                                        
+  Link_array<Score_element> all = pscore_l_->line_l_->column_l_arr ();
   Array<int> retval;
 
   for (int i=0; i < all.size (); i++)
-    if (all[i]->breakable_b ())
+    if (Item::breakable_b (all[i]))
       retval.push (i);
 
   if (linewidth_f_ <=0)
@@ -39,15 +37,14 @@ Break_algorithm::find_break_indices () const
 }
 
 
-Link_array<Paper_column>
+Link_array<Score_element>
 Break_algorithm::find_breaks () const
 {
-  Link_array<Paper_column> all = pscore_l_->line_l_->column_l_arr ();
-    
-  Link_array<Paper_column> retval;
+  Link_array<Score_element> all = pscore_l_->line_l_->column_l_arr ();
+  Link_array<Score_element> retval;
 
   for (int i=0; i < all.size (); i++)
-    if (all[i]->breakable_b ())
+    if (Item::breakable_b (all[i]))
       retval.push (all[i]);
 
   if (linewidth_f_ <=0)
@@ -59,7 +56,7 @@ Break_algorithm::find_breaks () const
 
 
 Simple_spacer*
-Break_algorithm::generate_spacing_problem (Link_array<Paper_column> curline, Interval line) const
+Break_algorithm::generate_spacing_problem (Link_array<Score_element> curline, Interval line) const
 {
   Simple_spacer * sp =  new Simple_spacer;
   Paper_def * d = pscore_l_->paper_l_;
index 3f9662a99a95b07f3600de8c3ca6b327ed74839c..192ece0a69c9642c51a56b04fed0b3ad03894f42 100644 (file)
@@ -54,7 +54,7 @@ Array<Column_x_positions>
 Gourlay_breaking::do_solve () const
 {
   Array<Break_node> optimal_paths;
-  Link_array<Paper_column> all =
+  Link_array<Score_element> all =
     pscore_l_->line_l_->column_l_arr ();
   
   Array<int> breaks = find_break_indices ();
@@ -80,10 +80,10 @@ Gourlay_breaking::do_solve () const
 
       for (int start_idx = break_idx; start_idx--;)
        {
-         Link_array<Paper_column> line = all.slice (breaks[start_idx], breaks[break_idx]+1);
+         Link_array<Score_element> line = all.slice (breaks[start_idx], breaks[break_idx]+1);
   
-         line[0]     = dynamic_cast<Paper_column*> (line[0]    ->find_prebroken_piece (RIGHT));
-         line.top () = dynamic_cast<Paper_column*> (line.top ()->find_prebroken_piece (LEFT));
+         line[0]     = dynamic_cast<Item*> (line[0])    ->find_prebroken_piece (RIGHT);
+         line.top () = dynamic_cast<Item*> (line.top ())->find_prebroken_piece (LEFT);
            
          Column_x_positions cp;
          cp.cols_ = line;
@@ -177,7 +177,7 @@ Gourlay_breaking::combine_demerits (Column_x_positions const &prev,
                                    Column_x_positions const &this_one) const
 {
   Real break_penalties = 0.0;
-  Paper_column * pc = this_one.cols_.top ();
+  Score_element * pc = this_one.cols_.top ();
   if (pc->original_l_)
     {
       SCM pen = pc->get_elt_property ("penalty");
index 2b7aec2beb2aa11c2a801e3cb6e6374d08644f33..a8150dac67b2d14580051b4d54660a74166ffe79 100644 (file)
 #include "paper-column.hh"
 #include "paper-def.hh"
 
-void
-Grace_align_item::set_interface (Score_element*me)
-{
-  me->set_interface (ly_symbol2scm ("grace-align-interface"));
-  me->set_elt_property ("stacking-dir", gh_int2scm (RIGHT));
-  Align_interface::set_interface(me);
-  Align_interface::set_axis (me,X_AXIS);
-}
-
 /*
   TODO: cfg-able
  */
@@ -41,6 +32,17 @@ Grace_align_item::before_line_breaking (SCM smob)
   return SCM_UNDEFINED;
 }
 
+void
+Grace_align_item::set_interface (Score_element*me)
+{
+  me->set_interface (ly_symbol2scm ("grace-align-interface"));
+  me->set_elt_property ("stacking-dir", gh_int2scm (RIGHT));
+  Align_interface::set_interface(me);
+  Align_interface::set_axis (me,X_AXIS);
+}
+
+
+
 bool
 Grace_align_item::has_interface (Score_element*m)
 {
index 7e0c3415444b82dd88000c1b59573954859fdb53..fa0b0d77709c51fde1c56a94fc989d439f07412e 100644 (file)
@@ -28,7 +28,7 @@ protected:
   Real linewidth_f_;
 
   /// search all pcols which are breakable.
-  Link_array<Paper_column> find_breaks() const;
+  Link_array<Score_element> find_breaks() const;
 
   Array<int> find_break_indices() const;
     
@@ -37,10 +37,10 @@ protected:
   void solve_line (Column_x_positions*) const;
 
   /// does curline fit on the paper?    
-  bool feasible (Link_array<Paper_column>) const;
+  bool feasible (Link_array<Score_element>) const;
     
 
-  Simple_spacer* generate_spacing_problem (Link_array<Paper_column>, Interval) const;
+  Simple_spacer* generate_spacing_problem (Link_array<Score_element>, Interval) const;
 
   virtual Array<Column_x_positions> do_solve() const=0;
 
index 23bea78d2ed195f37faeba5ef99c228df454e9ff..aec96022230b59c66d58338def47a914bf8e59b2 100644 (file)
@@ -13,7 +13,7 @@
 
 struct Column_x_positions
 {
-  Link_array<Paper_column> cols_;
+  Link_array<Score_element> cols_;
   Array<Real> config_;
   Real force_f_;
   bool satisfies_constraints_b_;
index c036dd2e524cd19bb8eacd4c472bb961f6c419a7..16f298f7f2361983d612975fcd699d3e6dfff2d2 100644 (file)
@@ -43,7 +43,7 @@ public:
   Item (SCM);
   Item (Item const &);
 
-  bool breakable_b () const;
+  static bool breakable_b (Score_element*me);
   bool broken_b () const;
   
   Direction break_status_dir () const;
index 9d510c692cfb172584e9f8dc26f6315b8c891c9b..96b3d6b265a8524b69478c46585afc70a1416201 100644 (file)
@@ -44,7 +44,7 @@ public:
   void output_lines ();
 
   Link_array<Item> broken_col_range (Item const*, Item const*) const;
-  Link_array<Paper_column> column_l_arr () const;
+  Link_array<Score_element> column_l_arr () const;
   
   void add_column (Paper_column*);
   void typeset_element (Score_element*);
index 3b1756e8f1cb77ce9548e48152734f2e9ffdd36d..5633cb0fb236e48d8845d0fc2d9b30045479b5ce 100644 (file)
 #include "spring.hh"
 
 /**
-   stuff grouped vertically.
-    This is a class to address items vertically. It contains the data for:
-    \begin{itemize}
-    \item
-    unbroken score
-    \item
-    broken score
-    \item
-    the linespacing problem
-    \end{itemize}
+   bounded-by-me -- list of elts.
+
+   shortest-starter-duration -- rational signifying shortest moment that starts here
+
+
+   Interfaces:
+
+   axis-group, spaceable-element.
   */
 
 class Paper_column : public Item
@@ -32,29 +30,11 @@ class Paper_column : public Item
 public:
   VIRTUAL_COPY_CONS(Score_element);
 
-  /*
-    ugh.
-
-    TODO:
-    
-    * junk these after spacing is done.
-
-    * Put these in Scheme.
-   */
-
-
-  Array<Column_rod>  minimal_dists_;
-  Array<Column_spring > springs_;
-
-
   /*
     Not (yet) in scm, because of messy effects when a column commits suicide.
    */
   int  rank_i_;
-  /// set a minimum distance
-  void add_rod (Paper_column * to, Real distance);
-  void add_spring (Paper_column * to, Real dist, Real strength);
-
+  virtual void do_break_processing ();
   virtual Paper_column *column_l () const;
   virtual Line_of_score *line_l () const;
 
@@ -65,10 +45,10 @@ public:
   static int rank_i(Score_element*);
 
   Paper_column (SCM);
-  Moment when_mom ()const;
-
   bool musical_b () const;
-  bool used_b () const;
+  static Moment when_mom (Score_element*);
+
+  static bool used_b (Score_element*) ;
   void set_rank (int);
 };
      
index 0cc519fdbb3120a7426c165445c5028bb098b128..4f317b148abd251d8868ce49d240910aa96e7a10 100644 (file)
@@ -73,7 +73,7 @@ struct Simple_spacer
   Simple_spacer ();
   
   void solve (Column_x_positions *) const;
-  void add_columns (Link_array<Paper_column>);
+  void add_columns (Link_array<Score_element>);
   void my_solve_linelen ();
   void my_solve_natural_len ();
   Real active_springs_stiffness () const;
diff --git a/lily/include/spaceable-element.hh b/lily/include/spaceable-element.hh
new file mode 100644 (file)
index 0000000..72a713e
--- /dev/null
@@ -0,0 +1,29 @@
+/*   
+  spaceable-element.hh -- declare Spaceable_element
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  
+ */
+
+#ifndef SPACEABLE_ELEMENT_HH
+#define SPACEABLE_ELEMENT_HH
+
+#include "lily-guile.hh"
+#include "lily-proto.hh"
+
+
+struct Spaceable_element
+{
+  /// set a minimum distance
+  static void add_rod (Score_element*me, Score_element * to, Real distance);
+  static void add_spring (Score_element*me,Score_element * to, Real dist, Real strength);
+  static void set_interface (Score_element*);
+  static void remove_interface (Score_element*);
+  static SCM get_minimum_distances (Score_element*);
+  static SCM get_ideal_distances (Score_element*);
+};
+
+#endif /* SPACEABLE_ELEMENT_HH */
+
index c6e4bdd7cdf628e757c06b62c6885558e33a4cf1..917b5fdc89df4fd1a1910ca6c741a6ba4b5c1448 100644 (file)
 
 #include "spanner.hh"
 
-class Spacing_spanner : public Spanner
+class Spacing_spanner
 {
 public:
-  Spacing_spanner (SCM);
-
-  VIRTUAL_COPY_CONS(Score_element);
-  Array<Spring> do_measure (Link_array<Paper_column>) const;
-
-protected:
-  virtual  Array<Spring> get_springs () const;
-
-  Real stem_dir_correction (Paper_column*,Paper_column*)  const;
-  Real default_bar_spacing (Paper_column*,Paper_column*,Moment)  const;
-  Real note_spacing (Paper_column*,Paper_column*,Moment)  const;
-  Real get_duration_space (Moment dur, Moment shortest) const;
+  static void set_interface (Score_element*);
+  static void do_measure (Score_element*,Link_array<Score_element>) ;
+
+  static SCM set_springs (SCM);
+  static Real stem_dir_correction (Score_element*,Score_element*,Score_element*)  ;
+  static Real default_bar_spacing (Score_element*,Score_element*,Score_element*,Moment)  ;
+  static Real note_spacing (Score_element*,Score_element*,Score_element*,Moment)  ;
+  static Real get_duration_space (Score_element*,Moment dur, Moment shortest) ;
 };
 
 #endif /* SPACING_SPANNER_HH */
index 4ce355dd4c26add27d83492a1bd06d88c5fafad5..dd5a61b21b06e6336a8575d856e0efb866658d40 100644 (file)
@@ -47,16 +47,11 @@ public:
   Real spanner_length () const;
 
   static int compare (Spanner * const &,Spanner * const &);
-  virtual Array<Rod> get_rods () const;
-  virtual Array<Spring> get_springs () const;  
   virtual Score_element* find_broken_piece (Line_of_score*) const;
   virtual void do_derived_mark ();
 protected:
   void set_my_columns ();
   VIRTUAL_COPY_CONS(Score_element);
-
-
-  virtual void do_space_processing ();
   virtual void do_break_processing ();
   virtual Line_of_score*line_l () const;
 };
index 319c4028427cfa493f7e90123c3132d6a9bd96ca..4e995bfd775c9c5fd03bd8cab90d40cba06020f7 100644 (file)
@@ -31,15 +31,23 @@ Item::Item (Item const &s)
 }
 
 
-
 bool
-Item::breakable_b () const
+Item::breakable_b (Score_element*me) 
 {
-  if (original_l_ )
+  if (me->original_l_)
     return false;
+
+  if (!dynamic_cast<Item*>(me))
+    programming_error ("only items can be breakable.");
   
-  Item * i  =dynamic_cast<Item*> (parent_l (X_AXIS));
-  return (i) ?  i->breakable_b () : to_boolean (get_elt_property ("breakable"));
+  Item * i  =dynamic_cast<Item*> (me->parent_l (X_AXIS));
+  return (i) ?  Item::breakable_b (i) : to_boolean (me->get_elt_property ("breakable"));
+}
+
+Paper_column *
+Item::column_l () const
+{
+  return dynamic_cast<Item*> (parent_l (X_AXIS))->column_l ();
 }
 
 Line_of_score *
@@ -83,7 +91,7 @@ Item::discretionary_processing()
   if (broken_b ())
     return;
 
-  if (breakable_b ())
+  if (Item::breakable_b (this))
     copy_breakable_items();
 }
 
@@ -114,11 +122,6 @@ Item::find_prebroken_piece (Direction d) const
   return dynamic_cast<Item*> (broken_to_drul_[d]);
 }
 
-Paper_column *
-Item::column_l () const
-{
-  return dynamic_cast<Item*> (parent_l (X_AXIS))->column_l ();
-}
 
 Direction
 Item::break_status_dir () const
index 464212d3cbf4cc2f2a7a5947045d2f7034dfdb7c..ff641c0c240f18e274437c627e1f0551bf16f191 100644 (file)
@@ -133,7 +133,7 @@ Line_of_score::break_into_pieces (Array<Column_x_positions> const &breaking)
       Line_of_score *line_l = dynamic_cast <Line_of_score*> (clone());
       line_l->rank_i_ = i;
       //      line_l->set_immutable_elt_property ("rank", gh_int2scm( i));
-      Link_array<Paper_column> c (breaking[i].cols_);
+      Link_array<Score_element> c (breaking[i].cols_);
       pscore_l_->typeset_line (line_l);
       
       line_l->set_bound(LEFT,c[0]);
@@ -141,7 +141,7 @@ Line_of_score::break_into_pieces (Array<Column_x_positions> const &breaking)
       for (int j=0; j < c.size(); j++)
        {
          c[j]->translate_axis (breaking[i].config_[j],X_AXIS);
-         c[j]->line_l_ = line_l;
+         dynamic_cast<Paper_column*> (c[j])->line_l_ = line_l;
        }
       
       broken_into_l_arr_.push (line_l);
@@ -233,7 +233,12 @@ Line_of_score::pre_processing ()
   
   progress_indication ("\n" + _ ("Calculating column positions...") + " " );
   for (SCM s = get_elt_property ("all-elements"); gh_pair_p (s); s = gh_cdr (s))
-    unsmob_element (gh_car (s))->do_space_processing ();
+    {
+      Score_element * e = unsmob_element (gh_car (s));
+      SCM proc = e->get_elt_property ("spacing-procedure");
+      if (gh_procedure_p (proc))
+       gh_call1 (proc, e->self_scm_);
+    }
 }
 
 void
@@ -325,9 +330,8 @@ Line_of_score::broken_col_range (Item const*l, Item const*r) const
   
   while (gh_pair_p (s) && gh_car (s) != l->self_scm_)
     {
-      Paper_column *c
-       = dynamic_cast<Paper_column*> (unsmob_element (gh_car (s)));
-      if (c->breakable_b () && !c->line_l_)
+      Paper_column*c = dynamic_cast<Paper_column*> ( unsmob_element (gh_car (s)));
+      if (Item::breakable_b (c) && !c->line_l_)
        ret.push (c);
 
       s = gh_cdr  (s);
@@ -341,15 +345,15 @@ Line_of_score::broken_col_range (Item const*l, Item const*r) const
    Return all columns, but filter out any unused columns , since they might
    disrupt the spacing problem.
  */
-Link_array<Paper_column>
+Link_array<Score_element>
 Line_of_score::column_l_arr ()const
 {
-  Link_array<Paper_column> acs
-    = Pointer_group_interface__extract_elements (this, (Paper_column*) 0, "columns");
+  Link_array<Score_element> acs
+    = Pointer_group_interface__extract_elements (this, (Score_element*) 0, "columns");
   bool bfound = false;
   for (int i= acs.size (); i -- ; )
     {
-      bool brb = acs[i]->breakable_b();
+      bool brb = Item::breakable_b (acs[i]);
       bfound = bfound || brb;
 
       /*
@@ -357,7 +361,7 @@ Line_of_score::column_l_arr ()const
        seem empty. We need to retain breakable columns, in case
        someone forced a breakpoint.
       */
-      if (!bfound || !acs[i]->used_b ())
+      if (!bfound || !Paper_column::used_b (acs[i]))
        acs.del (i);
     }
   return acs;
index 579d028256cd97edede31f93edd79a1d2699252d..fcdc933f9aa39c0eb43d1a8d245719c0cf207a4e 100644 (file)
 #include "paper-score.hh"
 #include "debug.hh"
 #include "axis-group-interface.hh"
+#include "spaceable-element.hh"
 
 void
-Paper_column::add_rod (Paper_column * p, Real d)
+Paper_column::do_break_processing ()
 {
-  Direction dir =  Direction (sign (rank_i(p)  -rank_i (this)));
-  
-  if (dir != RIGHT)
-    {
-      programming_error ("Must set minimum distance LTOR.");
-      return;
-    }
-  
-  for (int i=0; i < minimal_dists_.size (); i++)
-    {
-      Column_rod &rod = minimal_dists_[i];
-      if (rod.other_l_ == p)
-       {
-         rod.distance_f_ = rod.distance_f_ >? d;
-         return ;
-       }
-    }
-
-  Column_rod cr;
-  cr.distance_f_ = d;
-  cr.other_l_ = p;
-
-  minimal_dists_.push (cr);
-}
-
-void
-Paper_column::add_spring (Paper_column * p, Real d, Real s)
-{
-  Direction dir =  Direction (sign (rank_i(p)  -rank_i (this)));
-  
-  if (dir != RIGHT)
-    {
-      programming_error ("Must set springs LTOR");
-      return;
-    }
-  
-  for (int i=0; i < springs_.size (); i++)
-    {
-      Column_spring &spring = springs_[i];
-      if (spring.other_l_ == p)
-       {
-         spring.distance_f_ = spring.distance_f_ >? d;
-         return ;
-       }
-    }
-
-  Column_spring cr;
-  cr.distance_f_ = d;
-  cr.strength_f_ = s;  
-  cr.other_l_ = p;
-
-  springs_.push (cr);
+  Spaceable_element::remove_interface(this);
+  Item::do_break_processing ();
 }
 
 int
@@ -91,19 +42,20 @@ Paper_column::Paper_column (SCM l)
 {
   Axis_group_interface::set_interface (this);
   Axis_group_interface::set_axes (this, X_AXIS, X_AXIS);
+  Spaceable_element::set_interface (this);
   set_elt_property ("bounded-by-me", SCM_EOL);
   line_l_=0;
   rank_i_ = -1;
 }
 
 Moment
-Paper_column::when_mom () const
+Paper_column::when_mom (Score_element*me)
 {
-  SCM m = get_elt_property ("when");
+  SCM m = me->get_elt_property ("when");
   Moment s (0);
-  if (SMOB_IS_TYPE_B(Moment, m))
+  if (unsmob_moment (m))
     {
-      s = *SMOB_TO_TYPE (Moment,m);
+      return *unsmob_moment (m);
     }
   return s;
 }
@@ -113,17 +65,17 @@ Paper_column::musical_b () const
 {
   SCM m = get_elt_property ("shortest-starter-duration");
   Moment s (0);
-  if (SMOB_IS_TYPE_B(Moment, m))
+  if (unsmob_moment (m))
     {
-      s = *SMOB_TO_TYPE (Moment,m);
+      s = *unsmob_moment (m);
     }
   return s != Moment(0);
 }
 
 bool
-Paper_column::used_b ()const
+Paper_column::used_b (Score_element*me )
 {
-  return gh_pair_p (get_elt_property ("elements")) ||  breakable_b ()
-    || gh_pair_p (get_elt_property ("bounded-by-me"))
+  return gh_pair_p (me->get_elt_property ("elements")) ||  Item::breakable_b (me)
+    || gh_pair_p (me->get_elt_property ("bounded-by-me"))
     ;
 }
index 601ce748cb8b96da88836fc724e833ff49bfb8b4..86797de758a08224a8267f47cc5d7dba0959b66e 100644 (file)
@@ -79,7 +79,7 @@ Paper_score::process ()
   /*
     Be sure to set breakability on first & last column.
    */
-  Link_array<Paper_column> pc (line_l_->column_l_arr ());
+  Link_array<Score_element> pc (line_l_->column_l_arr ());
   
   pc[0]->set_elt_property ("breakable", SCM_BOOL_T);
   pc.top ()->set_elt_property ("breakable", SCM_BOOL_T);
index 15b4c7a8085bb13eb097178375d042e2aff5d622..621fd15de231fb93078ed9981d30809c74a67eae 100644 (file)
@@ -10,8 +10,7 @@
 #include "paper-column.hh"
 #include "debug.hh"
 #include "dimensions.hh"
-#include "separation-item.hh"
-
+#include "spaceable-element.hh"
 
 Rod::Rod ()
 {
@@ -20,11 +19,6 @@ Rod::Rod ()
 }
 
 
-Column_rod::Column_rod ()
-{
-  distance_f_ = 0;
-  other_l_ = 0;
-}
 
 void
 Rod::columnize ()
@@ -43,7 +37,8 @@ Rod::add_to_cols ()
 {
   columnize();
   if (item_l_drul_[LEFT] != item_l_drul_[RIGHT])
-    dynamic_cast<Paper_column*> (item_l_drul_[LEFT])->
-      add_rod(dynamic_cast<Paper_column*>(item_l_drul_[RIGHT]), distance_f_ );
+    Spaceable_element::add_rod (item_l_drul_[LEFT],
+                               item_l_drul_[RIGHT],
+                               distance_f_ );
 }
 
index 842a896fb7faacd69d3c68e45fa4557d1c5aeea2..1e35503f42e88de3404ffff1f5101753e9186a3c 100644 (file)
@@ -195,7 +195,7 @@ Score_engraver::set_columns (Paper_column *new_command_l,
       if (*current[i])
        {
          scoreline_l_->add_column ((*current[i]));
-         if (!(*current[i])->used_b())
+         if (!Paper_column::used_b (*current[i]))
            {
              (*current[i])->suicide ();
              *current[i]  =0;
index 47c37cfcaae516660fc7bd62825c401bde7af358..02676f0145213d268214556ca4a6689aa0b75090 100644 (file)
@@ -60,7 +60,7 @@ Script_column_engraver::acknowledge_element( Score_element_info inf)
     {
       Item *thing = dynamic_cast<Item*> (inf.elem_l_);
       if (thing
-         && !thing->breakable_b ()
+         && !Item::breakable_b (thing)
          && Side_position::get_axis (inf.elem_l_) == Y_AXIS)
        {
          script_l_arr_.push (thing);
index 96749f04102a1c2a41668a500de9196c3da9dca2..7cc7ad681a3f0438045b1f932a8e5998a1a6ec4b 100644 (file)
@@ -18,7 +18,7 @@ class Separating_line_group_engraver : public Engraver
 protected:
   Item * break_malt_p_;
   Item * nobreak_malt_p_;
-  Separating_group_spanner * sep_span_p_;
+  Spanner * sep_span_p_;
   
   virtual void acknowledge_element (Score_element_info);
   virtual void do_creation_processing ();
@@ -39,7 +39,8 @@ Separating_line_group_engraver::Separating_line_group_engraver ()
 void
 Separating_line_group_engraver::do_creation_processing ()
 {
-  sep_span_p_ = new Separating_group_spanner (get_property ("basicSeparatingGroupSpannerProperties"));
+  sep_span_p_ = new Spanner (get_property ("basicSeparatingGroupSpannerProperties"));
+  Separating_group_spanner::set_interface (sep_span_p_);
   announce_element (Score_element_info (sep_span_p_, 0));
   sep_span_p_->set_bound (LEFT, unsmob_element (get_property ("currentCommandColumn")));
 }
@@ -58,7 +59,7 @@ Separating_line_group_engraver::acknowledge_element (Score_element_info i)
   Item * it = dynamic_cast <Item *> (i.elem_l_);
   if (it && !it->parent_l (X_AXIS))
     {
-      bool ib =it->breakable_b ();
+      bool ib =Item::breakable_b (it);
       Item *&p_ref_ (ib ? break_malt_p_
                              : nobreak_malt_p_);
 
index 41a7e1772ddce17c1612325a003ab6cd5ec42624..e5136a82ffb3e9ad4e47f468a160699648b87774 100644 (file)
@@ -10,6 +10,7 @@
 #include "spring.hh"
 #include "debug.hh"
 #include "item.hh"
+#include "spaceable-element.hh"
 #include "paper-column.hh"
 
 Spring::Spring ()
@@ -22,7 +23,9 @@ Spring::Spring ()
 void
 Spring::add_to_cols ()
 {
-  item_l_drul_[LEFT]->column_l ()->add_spring (item_l_drul_[RIGHT]->column_l (), distance_f_, strength_f_);
+  Spaceable_element::add_spring (item_l_drul_[LEFT]->column_l (),
+                                item_l_drul_[RIGHT]->column_l (),
+                                distance_f_, strength_f_);
 }