]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/stem.cc
release: 1.1.27
[lilypond.git] / lily / stem.cc
index 2f1f141a12629d3752c8b999e3f64594a9c20593..7c780fadd7244aab8c69e6f95b70ebd09d665644 100644 (file)
@@ -31,7 +31,7 @@ Stem::Stem ()
   /*
     TODO: staff-size
     */
-  beams_i_drul_[LEFT] = beams_i_drul_[RIGHT] = 0;
+  beams_i_drul_[LEFT] = beams_i_drul_[RIGHT] = -1;
   mult_i_ = 0;
 
   yextent_drul_[DOWN] = yextent_drul_[UP] = 0;
@@ -43,11 +43,22 @@ Stem::Stem ()
   staff_size_i_ = 8;
 
   beam_gap_i_ = 0;
+  beam_l_ = 0;
 }
 
 Interval_t<int>
 Stem::head_positions () const
 {
+  /* 
+    Mysterious FreeBSD fix by John Galbraith.  Somehow, the empty intervals 
+    trigger FP exceptions on FreeBSD.  Fix: do not return infinity 
+
+   */
+  if (!head_l_arr_.size ())
+    {
+      return Interval_t<int> (100,-100);       
+    }
+
   Interval_t<int> r;
   for (int i =0; i < head_l_arr_.size (); i++)
     {
@@ -163,41 +174,32 @@ Stem::set_default_dir ()
 void
 Stem::set_default_stemlen ()
 {
-  /*
-   TODO
-   urg; this should be handled by Stem_info
-   */
-
-  Real length_f = paper ()->get_var ("stem_length");
-  Real shorten_f = paper ()->get_var ("forced_stem_shorten");
-
   Real internote_f = paper ()->internote_f ();
-  length_f /= internote_f;
-  shorten_f /= internote_f;
+  Real length_f = paper ()->get_var ("stem_length0") / internote_f;
+  Real shorten_f = paper ()->get_var ("forced_stem_shorten0") / internote_f;
 
-  Real len = length_f;
   if (!dir_)
     set_default_dir ();
   /* 
     stems in unnatural (forced) direction should be shortened, 
     accoding to [Roush & Gourlay]
    */
-  else if (dir_ != get_default_dir ())
-    len -= shorten_f / internote_f;
+  if (((int)chord_start_f ())
+      && (dir_ != get_default_dir ()))
+    length_f -= shorten_f;
 
   if (flag_i_ >= 5)
-    len += 2.0;
+    length_f += 2.0;
   if (flag_i_ >= 6)
-    len += 1.0;
+    length_f += 1.0;
   
-  set_stemend ((dir_ > 0) ? head_positions()[BIGGER] + len :
-              head_positions()[SMALLER] - len);
+  set_stemend ((dir_ > 0) ? head_positions()[BIGGER] + length_f:
+              head_positions()[SMALLER] - length_f);
 
   if (dir_ * stem_end_f () < 0)
-    {
-      set_stemend (0);
-    }
+    set_stemend (0);
 }
+
 //xxx
 void
 Stem::set_default_extents ()
@@ -279,7 +281,7 @@ Stem::do_width () const
 const Real ANGLE = 20* (2.0*M_PI/360.0); // ugh!
 
 Molecule*
-Stem::brew_molecule_p () const
+Stem::do_brew_molecule_p () const
 {
   Molecule *mol_p =new Molecule;
   Drul_array<Real> stem_y = yextent_drul_;
@@ -287,7 +289,7 @@ Stem::brew_molecule_p () const
 
   Real head_wid = 0;
   if (head_l_arr_.size ())
-    head_wid = head_l_arr_[0]->width ().length ();
+    head_wid = head_l_arr_[0]->extent (X_AXIS).length ();
   stem_y[Direction(-dir_)] += dir_ * head_wid * tan(ANGLE)/(2*dy);
   
   if (!invisible_b ())
@@ -317,7 +319,7 @@ Stem::note_delta_f () const
   Real r=0;
   if (head_l_arr_.size())
     {
-      Interval head_wid(0,  head_l_arr_[0]->width ().length ());
+      Interval head_wid(0,  head_l_arr_[0]->extent (X_AXIS).length ());
       Real rule_thick(paper ()->rule_thickness ());
       Interval stem_wid(-rule_thick/2, rule_thick/2);
       if (stem_xdir_ == CENTER)
@@ -338,10 +340,10 @@ Stem::hpos_f () const
   TODO:  head_l_arr_/rest_l_arr_ in  do_substitute_dependent ()
  */
 void
- Stem::do_substitute_dependency (Score_element*o,Score_element*n)
+Stem::do_substitute_dependency (Score_element*o,Score_element*n)
 {
-  Item * o_l = dynamic_cast <Item *> (o);
-  Item * n_l = n? dynamic_cast <Item *> (n) : 0;
-  head_l_arr_.substitute ((Note_head*)o_l, (Note_head*)n_l);
-  rest_l_arr_.substitute ((Rest*)o_l, (Rest*)n_l);
+  if (Note_head*h=dynamic_cast<Note_head*> (o))
+  head_l_arr_.substitute (h, dynamic_cast<Note_head*>(n));
+  if (Rest *r=dynamic_cast<Rest*> (o))
+    rest_l_arr_.substitute (r, dynamic_cast<Rest*>(n));
 }