]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/collision.cc
release: 0.1.8
[lilypond.git] / lily / collision.cc
index f9a15bc4fa4a11615a42c022e713fa9c8dc1e197..798c74be456131b13f0ccce229078b192759d6d2 100644 (file)
 
 Collision::Collision()
 {
-    empty_b_ = transparent_b_ =true;
 }
 
 void
-Collision::add(Note_column* ncol_l)
+Collision::add (Note_column* ncol_l)
 {
-    clash_l_arr_.push(ncol_l);
-    add_dependency(ncol_l);
+    clash_l_arr_.push (ncol_l);
+    add_element (ncol_l);
+    add_dependency (ncol_l);
 }
 /**
   should derive of Array.
  */
 static 
-int idx(int dir, bool h_shift_b)
+int idx (int dir, bool h_shift_b)
 {
-    assert(abs (dir) == 1);
+    assert (abs (dir) == 1);
     int j = dir > 0 ? 0 : 3;
-    if ( h_shift_b 
+    if ( h_shift_b) 
        j += dir;
     return j;
 }
@@ -62,21 +62,21 @@ Collision::do_pre_processing()
        }
        int d = (c_l->dir_i_);
        
-       clash_group_arr_a[idx(d, c_l->h_shift_b_)].push(c_l);
+       clash_group_arr_a[idx (d, c_l->h_shift_b_)].push (c_l);
     }
     
     
     for (int j=0; j < 4; j++) {
        if (clash_group_arr_a[j].size() > 1) {
-           warning("Too many clashing notecolumns. Ignoring them.");
+           warning ("Too many clashing notecolumns. Ignoring them.");
            return;
        }
     }
     int d = 1;
     do {
-       if (!clash_group_arr_a[idx(d, false)].size()){
-           clash_group_arr_a[idx(d,  false)] = clash_group_arr_a[idx(d, true)];
-           clash_group_arr_a[idx(d, true)].set_size(0);
+       if (!clash_group_arr_a[idx (d, false)].size()){
+           clash_group_arr_a[idx (d,  false)] = clash_group_arr_a[idx (d, true)];
+           clash_group_arr_a[idx (d, true)].clear();
        }
     } while ((d *= -1) != 1);
                                  
@@ -102,41 +102,45 @@ Collision::do_pre_processing()
     }
     
     do {
-       x_off[idx(d, true)] = d*0.5;
+       x_off[idx (d, true)] = d*0.5;
     } while ((d *= -1) != 1);
 
   
     // y_extent: smallest y-pos noteball interval containing all balls
     // 4 (0..3) groups: stem up/down; shift on/off; 
-    Interval_t<int> middle( y_extent[idx(-1,0)].max(),
-                           y_extent[idx(1,0)].min() );
-    Interval_t<int> open_middle( y_extent[idx(-1,0)].max()+1, y_extent[idx(1,0)].min()-1);
+    Interval_t<int> middle (y_extent[idx (-1,0)].max(),
+                           y_extent[idx (1,0)].min());
+    Interval_t<int> open_middle (y_extent[idx (-1,0)].max()+1, y_extent[idx (1,0)].min ()-1);
     do{
-       if (!open_middle.contains_b(y_extent[idx(d,true)]))
-           x_off[idx(d, true)] = d *1.0 ;
+       if (!open_middle.contains_b (y_extent[idx (d,true)]))
+           x_off[idx (d, true)] = d *1.0 ;
     } while ((d *= -1) != 1);
    
     if (!middle.empty_b() 
-       && middle.length() < 2 && col_l_a[idx(1,0)] && col_l_a[idx(-1,0)]) {    
+       && middle.length() < 2 && col_l_a[idx (1,0)] && col_l_a[idx (-1,0)]) {  
 // reproduction of bugfix at 3am ?
-       Note_head * nu_l= col_l_a[idx(1,0)]->head_l_arr_[0];
-       Note_head * nd_l = col_l_a[idx(-1,0)]->head_l_arr_.top();
+       Note_head * nu_l= col_l_a[idx (1,0)]->head_l_arr_[0];
+       Note_head * nd_l = col_l_a[idx (-1,0)]->head_l_arr_.top();
        if (! (nu_l->balltype_i_ == nd_l->balltype_i_ 
-              && nu_l->dots_i_ == nd_l->dots_i_  && middle.length() == 0 )) {
-           x_off[idx(1,0)] -= 0.5;
-           x_off[idx(1,1)] -= 0.5;
-           x_off[idx(-1,1)] += 0.5;
-           x_off[idx(-1,0)] += 0.5;
+              && nu_l->dots_i_ == nd_l->dots_i_  && middle.length() == 0)) {
+           x_off[idx (1,0)] -= 0.5;
+           x_off[idx (1,1)] -= 0.5;
+           x_off[idx (-1,1)] += 0.5;
+           x_off[idx (-1,0)] += 0.5;
        }
        
     }    
-    Real inter_f = paper()->internote_f();
-    Real wid_f = paper()->note_width();
+    Real inter_f = paper()->internote_f ();
+    Real wid_f = paper()->note_width ();
     for (int j=0; j < 4; j++) {
-       if (col_l_a[j])
-           col_l_a[j]->translate(Offset(x_off[j] * wid_f,
-                                        y_off[j] * inter_f));
-       
+       if (col_l_a[j]) {
+           /* collision.cc:138: request for method `translate' is ambiguous 
+              
+              (shaddup)
+            */
+           Offset o (x_off[j] * wid_f, y_off[j] * inter_f);
+           ((Score_elem*)col_l_a[j])->translate (o);
+       }
     }
 }
 
@@ -144,8 +148,8 @@ Collision::do_pre_processing()
 IMPLEMENT_IS_TYPE_B1(Collision, Item);
 
 void
-Collision::do_substitute_dependency(Score_elem*o_l,Score_elem*n_l)
+Collision::do_substitute_dependency (Score_elem*o_l,Score_elem*n_l)
 {
-    clash_l_arr_.substitute((Note_column*)o_l->item(), 
+    clash_l_arr_.substitute ((Note_column*)o_l->item(), 
                            (Note_column*)(n_l?n_l->item():0));
 }