]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/note-column.cc
release: 1.1.32
[lilypond.git] / lily / note-column.cc
index e528b9e956369d94ace5744e9f76161ee7745808..770157d0738b4f2c369474758763b5734e4008e2 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
+  (c)  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 #include "dot-column.hh"
 #include "note-column.hh"
@@ -13,8 +13,6 @@
 #include "rest.hh"
 #include "debug.hh"
 
-IMPLEMENT_IS_TYPE_B1(Note_column,Script_column);
-
 bool
 Note_column::rest_b () const
 {
@@ -38,31 +36,28 @@ Interval_t<int>
 Note_column::head_positions_interval() const
 {
   ((Note_column*)this)->sort();
-  return Interval_t<int> (head_l_arr_[0]->position_i_, 
-                         head_l_arr_.top()->position_i_);
+  Interval_t<int>  iv;
 
-}
+  iv.set_empty ();
 
-Interval 
-Note_column::width () const
-{
   if (head_l_arr_.size ())
-    return head_l_arr_[0]->width ();
-  else
-    return Interval (0,0);
+    iv = Interval_t<int>(head_l_arr_[0]->position_i_, 
+                        head_l_arr_.top()->position_i_);
+  
+  return iv;
 }
 
 void
 Note_column::do_pre_processing()
 {
-
   if (!dir_)
     {
       if (stem_l_)
        dir_ = stem_l_->dir_;
       else if (head_l_arr_.size ())
        {
-         dir_ = (head_positions_interval().center () >=  5) ? DOWN:UP;
+         //      assert (false);       // looks obsolete?
+         dir_ = sign (head_positions_interval().center ());
        }
     }
   Script_column::do_pre_processing();
@@ -71,58 +66,58 @@ Note_column::do_pre_processing()
   
 
 void
-Note_column::set (Stem * stem_l)
+Note_column::set_stem (Stem * stem_l)
 {
   add_support (stem_l);
   stem_l_ = stem_l;
   /* 
      don't add stem to support; mostly invisible for rest-columns (and possibly taken . .)
-   */
-  Score_elem::add_dependency (stem_l);
+  */
+  Score_element::add_dependency (stem_l);
   for (int i=0; i < script_l_arr_.size(); i++)
     script_l_arr_[i]->set_stem (stem_l);
 }
 
 void
-Note_column::add (Script *script_l)
+Note_column::add_script (Script *script_l)
 {
-  Script_column::add (script_l) ;
+  Script_column::add_script (script_l) ;
   if  (stem_l_)
     script_l->set_stem (stem_l_);
 }
 
 void
-Note_column::do_substitute_dependency (Score_elem*o, Score_elem*n)
+Note_column::do_substitute_element_pointer (Score_element*o, Score_element*n)
 {
   if (stem_l_ == o) 
     {
-      stem_l_ = n ? (Stem*)n->item():0;
+      stem_l_ = n ? dynamic_cast<Stem *> (n):0;
     }
-  if (o->is_type_b (Note_head::static_name ()))
+  if (dynamic_cast<Note_head *> (o))
     {
-      head_l_arr_.substitute ((Note_head*)o->item(), 
-                             (n)? (Note_head*)n->item() : 0);
+      head_l_arr_.substitute (dynamic_cast<Note_head *> (o), 
+                             (n)? dynamic_cast<Note_head *> (n) : 0);
     }
-  Script_column::do_substitute_dependency (o,n);
-  if (o->is_type_b (Rest::static_name ())) 
+  Script_column::do_substitute_element_pointer (o,n);
+  if (dynamic_cast<Rest *> (o)) 
     {
-      rest_l_arr_.substitute ((Rest*)o->item(), 
-                             (n)? (Rest*)n->item() : 0);
+      rest_l_arr_.substitute (dynamic_cast<Rest *> (o), 
+                             (n)? dynamic_cast<Rest *> (n) : 0);
     }
 }
 
 void
-Note_column::add (Rhythmic_head *h)
+Note_column::add_head (Rhythmic_head *h)
 {
-  if (h->is_type_b (Rest::static_name ()))
+  if (Rest*r=dynamic_cast<Rest *> (h))
     {
-      rest_l_arr_.push ((Rest*)h);
-      add_support (h);  
+      rest_l_arr_.push (r);
+      add_support (r);  
     }
-  if (h->is_type_b (Note_head::static_name ()))
+  if (Note_head *nh=dynamic_cast<Note_head *> (h))
     {
-      head_l_arr_.push ((Note_head*) h);
-      add_support (h);
+      head_l_arr_.push (nh);
+      add_support (nh);
     }
 }
 
@@ -147,7 +142,7 @@ Note_column::do_print() const
 }
 
 void
-Note_column::set (Dot_column *d)
+Note_column::set_dotcol (Dot_column *d)
 {
   add_element (d);
 }