]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/collision.cc
release: 1.3.73
[lilypond.git] / lily / collision.cc
index 9cedc344799fd404ccfa8c23f0ec0c5ecb910677..8d1f6d1232ca0fa1d63cce82821b665af6be83db 100644 (file)
 #include "item.hh"
 
 void
-Collision::add_column (Note_column* ncol_l)
+Collision::add_column (Score_element*me,Score_element* ncol_l)
 {
   ncol_l->add_offset_callback (force_shift_callback, X_AXIS);
-  Axis_group_interface (elt_l_).add_element (ncol_l);
-  elt_l_->add_dependency (ncol_l);
+  Axis_group_interface::add_element (me, ncol_l);
+  me->add_dependency (ncol_l);
 }
 
 Real
-Collision::force_shift_callback (Score_element const * c, Axis a)
+Collision::force_shift_callback (Score_element * c, Axis a)
 {
   assert (a == X_AXIS);
   
@@ -30,9 +30,9 @@ Collision::force_shift_callback (Score_element const * c, Axis a)
   /*
     ugh. the way DONE is done is not clean
    */
-  if (!unsmob_element (me->get_elt_pointer ("done")))
+  if (!unsmob_element (me->get_elt_property ("done")))
     {
-      me->set_elt_pointer ("done", me->self_scm_);
+      me->set_elt_property ("done", me->self_scm_);
       do_shifts (me);
     }
   
@@ -77,18 +77,18 @@ Collision::do_shifts(Score_element* me)
 SCM
 Collision::automatic_shift (Score_element *me)
 {
-  Drul_array<Link_array<Note_column> > clash_groups;
+  Drul_array<Link_array<Score_element> > clash_groups;
   Drul_array<Array<int> > shifts;
   SCM  tups = SCM_EOL;
 
-  SCM s = me->get_elt_pointer ("elements");
+  SCM s = me->get_elt_property ("elements");
   for (; gh_pair_p (s); s = gh_cdr (s))
     {
       SCM car = gh_car (s);
 
       Score_element * se = unsmob_element (car);
-      if (Note_column * col = dynamic_cast<Note_column*> (se))
-       clash_groups[col->dir ()].push (col);
+      if (Note_column::has_interface (se))
+       clash_groups[Note_column::dir (se)].push (se);
     }
 
   
@@ -96,7 +96,7 @@ Collision::automatic_shift (Score_element *me)
   do
     {
       Array<int> & shift (shifts[d]);
-      Link_array<Note_column> & clashes (clash_groups[d]);
+      Link_array<Score_element> & clashes (clash_groups[d]);
 
       clashes.sort (Note_column::shift_compare);
 
@@ -157,26 +157,26 @@ Collision::automatic_shift (Score_element *me)
     all of them again. */
   if (extents[UP].size () && extents[DOWN].size ())
     {
-      Note_column *cu_l =clash_groups[UP][0];
-      Note_column *cd_l =clash_groups[DOWN][0];
+      Score_element *cu_l =clash_groups[UP][0];
+      Score_element *cd_l =clash_groups[DOWN][0];
 
 
       /*
        TODO.
        */
-      Rhythmic_head * nu_l= cu_l->first_head();
-      Rhythmic_head * nd_l = cd_l->first_head();
+      Score_element * nu_l= Note_column::first_head(cu_l);
+      Score_element * nd_l = Note_column::first_head(cd_l);
       
       int downpos = Note_column::head_positions_interval (cd_l)[BIGGER];
       int uppos = Note_column::head_positions_interval (cu_l)[SMALLER];      
       
       bool merge  =
        downpos == uppos
-       && nu_l->balltype_i () == nd_l->balltype_i ();
+       && Rhythmic_head::balltype_i (nu_l) == Rhythmic_head::balltype_i (nd_l);
 
 
       if (!to_boolean (me->get_elt_property ("merge-differently-dotted")))
-       merge = merge && nu_l->dot_count () == nd_l->dot_count ();
+       merge = merge && Rhythmic_head::dot_count (nu_l) == Rhythmic_head::dot_count (nd_l);
 
       /*
        notes are close, but can not be merged.  Shift
@@ -208,7 +208,7 @@ Collision::forced_shift (Score_element *me)
 {
   SCM tups = SCM_EOL;
   
-  SCM s = me->get_elt_pointer ("elements");
+  SCM s = me->get_elt_property ("elements");
   for (; gh_pair_p (s); s = gh_cdr (s))
     {
       Score_element * se = unsmob_element (gh_car (s));
@@ -225,7 +225,3 @@ Collision::forced_shift (Score_element *me)
 
 
 
-Collision::Collision (Score_element* c)
-{
-  elt_l_ = c;
-}