]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/side-position-interface.cc (out_of_staff): move contents of
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 27 Jan 2004 00:37:42 +0000 (00:37 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 27 Jan 2004 00:37:42 +0000 (00:37 +0000)
out_of_staff into aligned_side.

* input/regression/measure-grouping.ly: fix warning.

* lily/side-position-interface.cc: add staff-padding support to
Side_position_interface::aligned_side.

* lily/system-start-delimiter-engraver.cc (process_music): whoops,
one get_property too many.

* flower/include/drul-array.hh (linear_combination): new function
(scale_drul): new function

* lily/beam.cc: use Drul_array<Real> iso. interval, because *=
operations on empty intervals are silly.

15 files changed:
ChangeLog
VERSION
flower/include/drul-array.hh
flower/include/interval.hh
flower/interval.cc
input/regression/measure-grouping.ly
lily/beam-quanting.cc
lily/beam.cc
lily/include/beam.hh
lily/include/lily-guile.hh
lily/lily-guile.cc
lily/side-position-interface.cc
lily/staff-symbol.cc
lily/system-start-delimiter-engraver.cc
scm/define-grobs.scm

index 1a02b08fedbe12e0417f9b6987a3512247301437..d4c2f81d9a57b4212464193d6d26ec5124379f74 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2004-01-27  Han-Wen Nienhuys   <hanwen@xs4all.nl>
+
+       * lily/side-position-interface.cc (out_of_staff): move contents of
+       out_of_staff into aligned_side.
+
+       * input/regression/measure-grouping.ly: fix warning.
+
+       * lily/side-position-interface.cc: add staff-padding support to
+       Side_position_interface::aligned_side.
+
+       * lily/system-start-delimiter-engraver.cc (process_music): whoops,
+       one get_property too many.
+
+       * flower/include/drul-array.hh (linear_combination): new function
+       (scale_drul): new function
+
+       * lily/beam.cc: use Drul_array<Real> iso. interval, because *=
+       operations on empty intervals are silly.
+
 2004-01-26  Jan Nieuwenhuizen  <janneke@gnu.org>
 
        * lily/note-heads-engraver.cc (process_music): use robust_scm2int
diff --git a/VERSION b/VERSION
index aaa77e5b2b118b8f68a679c8dab5144b581fd3a5..044df009bcf071efd1369d6ea699b533cbc640b1 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -2,5 +2,5 @@ PACKAGE_NAME=LilyPond
 MAJOR_VERSION=2
 MINOR_VERSION=1
 PATCH_LEVEL=15
-MY_PATCH_LEVEL=
+MY_PATCH_LEVEL=hwn1
 
index 0e4dc34e210f09d79df1ee208c7b9bd10d2498df..7078bdaa0c5ff95e899ccf76ccc7c1935dedb953 100644 (file)
@@ -11,6 +11,7 @@
 #define DRUL_ARRAY_HH
 
 #include "direction.hh"
+#include "real.hh"
 
 #include <assert.h>
 
@@ -50,4 +51,18 @@ struct Drul_array
     }
 };
 
+template<class T>
+void
+scale_drul (Drul_array<T> * dr, T x)
+{
+  dr->elem (LEFT) *= x;
+  dr->elem (RIGHT) *= x;
+}
+
+inline Real
+linear_combination (Drul_array<Real> const &d, Real x)
+{
+  return ((1.0 - x) * Real (d.elem (LEFT))  + (x + 1.0) * Real (d.elem (RIGHT))) * 0.5;
+}
+
 #endif // DRUL_ARRAY_HH
index 413b6b78d5ca164deecca23f854a6b355aaf0dab..7168a2d51beb2cc2fc6a0ed30ff4b72d6e263dfc 100644 (file)
@@ -88,7 +88,9 @@ struct Interval_t : public Drul_array<T> {
   }
 
   Real linear_combination (Real x) const {
-    return ((1.0 - x) * Real (elem (LEFT))  + (x + 1.0) * Real (elem (RIGHT))) * 0.5;
+    Drul_array<Real> da (elem (LEFT),
+                        elem (RIGHT));
+    return ::linear_combination (da, x);
   }
   String to_string () const;    
 
index 10239516e6db19338243a0d45c84019e782f9eaf..8e34952be7d052db649ccf0341487fffcec234a7 100644 (file)
@@ -39,3 +39,4 @@ Interval_t<int>::T_to_string (int i)
 template INTERVAL__INSTANTIATE (int);
 template INTERVAL__INSTANTIATE (Real);
 
+
index a416e5a8bbe001be210c877d154a28e85d8c2ec9..6662a20f4a173d659be14f7c21d7aed477a42248 100644 (file)
@@ -3,8 +3,7 @@
 {
 
     texidoc = "The @code{Measure_grouping_engraver} adds triangles and
-brackets above beats when you set beatGrouping.  This shows a fragment
-of Steve Martland's Dance Works. "
+brackets above beats when you set beatGrouping.  "
 
 }
 
@@ -22,7 +21,7 @@ of Steve Martland's Dance Works. "
             \time 2/4
             c,8 g'4 g8~
             #(set-time-signature 5 8 '(3 2)) 
-            g8 a4 g a->
+            g8 a4 g a4.->
         }
         \paper  {
             raggedright = ##t
index ae084a2ddf2f4aaf128936a9dd3235ea0b111879..178d8da48437e271adb9f0f22f1cf1f56903fd4a 100644 (file)
@@ -274,15 +274,14 @@ Beam::quanting (SCM smob)
   if (debug_beam_quanting_flag
       && gh_pair_p (inspect_quants))
     {
-      Real il = gh_scm2double (gh_car (inspect_quants));
-      Real ir = gh_scm2double (gh_cdr (inspect_quants));
+      Drul_array<Real> ins = ly_scm2interval (inspect_quants);
 
       int i = 0;
 
       Real mindist = 1e6;
       for (; i < qscores.size(); i ++)
        {
-         Real d =fabs (qscores[i].yl-il) + fabs (qscores[i].yr - ir);
+         Real d =fabs (qscores[i].yl- ins[LEFT]) + fabs (qscores[i].yr - ins[RIGHT]);
          if (d < mindist)
            {
              best_idx = i;
@@ -295,8 +294,8 @@ Beam::quanting (SCM smob)
 #endif
   
   me->set_grob_property ("positions",
-                        gh_cons (gh_double2scm (qscores[best_idx].yl),
-                                 gh_double2scm (qscores[best_idx].yr)));
+                        ly_interval2scm (Drul_array<Real> (qscores[best_idx].yl,
+                                         qscores[best_idx].yr)));
 #if DEBUG_QUANTING
   if (debug_beam_quanting_flag)
     {
index 60b6944a804bc5f5b4889c527f4dbe61f9984267..c6e6f1112df70818826aa99b7b509c8ae1d16139 100644 (file)
@@ -10,8 +10,6 @@
 /*
 TODO:
 
-  * Use Number_pair i.s.o Interval to represent (yl, yr).
-  
   - Determine auto knees based on positions if it's set by the user.
 
   - the code is littered with * and / staff_space calls for
@@ -46,8 +44,6 @@ Notes:
 #include "spanner.hh"
 #include "warn.hh"
 
-
-
 bool debug_beam_quanting_flag;
 
 
@@ -332,24 +328,24 @@ Beam::brew_molecule (SCM grob)
     }
 
   SCM posns = me->get_grob_property ("positions");
-  Interval pos;
+  Drul_array<Real> pos;
   if (!is_number_pair (posns))
     {
       programming_error ("No beam posns");
       pos = Interval (0,0);
     }
   else
-    pos= ly_scm2interval (posns);
-
+    pos= ly_scm2realdrul (posns);
 
-  pos *= Staff_symbol_referencer::staff_space (me); 
-  Real dy = pos.delta ();
+  scale_drul (  &pos,  Staff_symbol_referencer::staff_space (me));
+  
+  Real dy = pos[RIGHT] - pos[LEFT];
   Real dydx = (dy && dx) ? dy/dx : 0;
   
   Real thick = get_thickness (me);
   Real bdy = get_beam_translation (me);
 
-  SCM last_beaming = SCM_EOL;;
+  SCM last_beaming = SCM_EOL;
   Real last_xposn = -1;
   Real last_stem_width = -1 ;
 
@@ -932,7 +928,7 @@ Beam::least_squares (SCM smob)
   /*
     "position" is relative to the staff.
    */
-  pos *= 1/ Staff_symbol_referencer::staff_space (me); 
+  scale_drul (&pos,  1/ Staff_symbol_referencer::staff_space (me)); 
   
   me->set_grob_property ("positions", ly_interval2scm (pos));
  
@@ -982,11 +978,11 @@ Beam::shift_region_to_valid (SCM grob)
   
   Real dx = lvs->relative_coordinate (commonx, X_AXIS) - x0;
 
-  Interval pos = ly_scm2interval ( me->get_grob_property ("positions"));
+  Drul_array<Real> pos = ly_scm2interval ( me->get_grob_property ("positions"));
 
-  pos  *= Staff_symbol_referencer::staff_space (me);
+  scale_drul (&pos,  Staff_symbol_referencer::staff_space (me));
   
-  Real dy = pos.delta();
+  Real dy = pos[RIGHT] - pos[LEFT];
   Real y = pos[LEFT];
   Real dydx =dy/dx;
 
@@ -1038,8 +1034,8 @@ Beam::shift_region_to_valid (SCM grob)
        y = feasible_left_point.center ();
     }
   
-  pos = Interval (y, (y+dy));
-  pos *= 1/ Staff_symbol_referencer::staff_space (me);
+  pos = Drul_array<Real> (y, (y+dy));
+  scale_drul (&pos, 1/ Staff_symbol_referencer::staff_space (me));
   
   me->set_grob_property ("positions", ly_interval2scm (pos));
   return SCM_UNSPECIFIED;
@@ -1162,11 +1158,11 @@ Beam::check_concave (SCM smob)
   /* TODO: some sort of damping iso -> plain horizontal */
   if (concaveness1 || concaveness2 > r2)
     {
-      Interval pos = ly_scm2interval (me->get_grob_property ("positions"));
-      Real r = pos.linear_combination (0);
+      Drul_array<Real> pos = ly_scm2interval (me->get_grob_property ("positions"));
+      Real r = linear_combination (pos, 0);
 
       r /= Staff_symbol_referencer::staff_space (me);
-      me->set_grob_property ("positions", ly_interval2scm (Interval (r, r)));
+      me->set_grob_property ("positions", ly_interval2scm (Drul_array<Real> (r, r)));
       me->set_grob_property ("least-squares-dy", gh_double2scm (0));
     }
 
@@ -1190,10 +1186,10 @@ Beam::slope_damping (SCM smob)
 
   if (damping)
     {
-      Interval pos = ly_scm2interval (me->get_grob_property ("positions"));
-      pos *= Staff_symbol_referencer::staff_space (me);
+      Drul_array<Real>  pos = ly_scm2interval (me->get_grob_property ("positions"));
+      scale_drul (&pos,  Staff_symbol_referencer::staff_space (me));
       
-      Real dy = pos.delta ();
+      Real dy = pos[RIGHT] - pos[LEFT];
 
       Grob *fvs  = first_visible_stem (me);
       Grob *lvs  = last_visible_stem (me);
@@ -1210,7 +1206,7 @@ Beam::slope_damping (SCM smob)
       pos[LEFT] += (dy - damped_dy) / 2;
       pos[RIGHT] -= (dy - damped_dy) / 2;
 
-      pos *= 1/ Staff_symbol_referencer::staff_space (me);
+      scale_drul (&pos, 1/Staff_symbol_referencer::staff_space (me));
       
       me->set_grob_property ("positions", ly_interval2scm (pos));
     }
@@ -1241,13 +1237,13 @@ where_are_the_whole_beams(SCM beaming)
 Real
 Beam::calc_stem_y (Grob *me, Grob* s, Grob ** common,
                   Real xl, Real xr,
-                  Interval pos, bool french) 
+                  Drul_array<Real> pos, bool french) 
 {
   Real beam_translation = get_beam_translation (me);
 
     
   Real r = s->relative_coordinate (common[X_AXIS], X_AXIS) - xl;
-  Real dy = pos.delta ();
+  Real dy = pos[RIGHT] - pos[LEFT];
   Real dx = xr - xl;
   Real stem_y_beam0 = (dy && dx
                       ? r / dx
@@ -1294,9 +1290,9 @@ Beam::set_stem_lengths (Grob *me)
   for (int a = 2; a--;)
     common[a] = common_refpoint_of_array (stems, me, Axis(a));
   
-  Interval pos = ly_scm2interval (me->get_grob_property ("positions"));
+  Drul_array<Real> pos = ly_scm2realdrul (me->get_grob_property ("positions"));
   Real staff_space = Staff_symbol_referencer::staff_space (me);
-  pos  *= staff_space;
+  scale_drul (&pos,  staff_space);
 
   bool gap = false;
   Real thick =0.0;
@@ -1473,16 +1469,16 @@ Beam::rest_collision_callback (SCM element_smob, SCM axis)
       || !Beam::visible_stem_count (beam))
     return gh_double2scm (0.0);
 
-  Interval pos (0, 0);
+  Drul_array<Real> pos (0, 0);
   SCM s = beam->get_grob_property ("positions");
   if (gh_pair_p (s) && gh_number_p (ly_car (s)))
     pos = ly_scm2interval (s);
   Real staff_space = Staff_symbol_referencer::staff_space (rest);
 
-  pos  *= staff_space;
+  scale_drul (&pos, staff_space);
   
 
-  Real dy = pos.delta ();
+  Real dy = pos[RIGHT] - pos[LEFT];
   
   // ugh -> use commonx
   Real x0 = first_visible_stem (beam)->relative_coordinate (0, X_AXIS);
index ed610a9975797896ab5f9e3f0dd2c6512e44d0f5..a3c34ea86ec8e1519d65f96edeefaa1d9268665f 100644 (file)
@@ -67,7 +67,7 @@ private:
   static void set_stem_shorten (Grob*);
   static Real calc_stem_y (Grob*, Grob* s, Grob**c,
                           Real, Real,
-                          Interval pos, bool french);
+                          Drul_array<Real> pos, bool french);
   static void set_stem_lengths (Grob*);
   static int forced_stem_count (Grob*);
 };
index 353d1fe798bb6786a15d87203d2083a9da65a620..1a8883b9ab87461b12910234b2a0dfda1be25a0d 100644 (file)
@@ -156,6 +156,7 @@ Offset ly_scm2offset (SCM);
 SCM ly_assoc_chain (SCM key, SCM achain);
 SCM ly_assoc_cdr (SCM key, SCM alist);
 Interval ly_scm2interval (SCM);
+Drul_array<Real> ly_scm2realdrul (SCM);
 Slice int_list_to_slice (SCM l);
 SCM ly_interval2scm (Drul_array<Real>);
 
index a7c8b58919ee7badfc53bd63077f245120943569..104fffc3ba0837624f4e811135c4c9cea574108d 100644 (file)
@@ -253,6 +253,13 @@ ly_scm2interval (SCM p)
                    gh_scm2double (ly_cdr (p)));
 }
 
+Drul_array<Real>
+ly_scm2realdrul (SCM p)
+{
+  return  Drul_array<Real> (gh_scm2double (ly_car (p)),
+                           gh_scm2double (ly_cdr (p)));
+}
+
 SCM
 ly_interval2scm (Drul_array<Real> i)
 {
index 081d84d9934c60c4f7aced662db9608c3a439984..42ae7dfd04d13d0688b992c68d81044c9c25ee4b 100644 (file)
@@ -107,6 +107,9 @@ Side_position_interface::general_side_position (Grob * me, Axis a, bool use_exte
   if (fabs (total_off) > 100 CM)
     programming_error ("Huh ? Improbable staff side dim.");
 
+
+  
+  
   return gh_double2scm (total_off);
 }
 
@@ -193,6 +196,23 @@ Side_position_interface::aligned_side (SCM element_smob, SCM axis)
        }
       o += - iv[-d];
     }
+
+  Grob * st = Staff_symbol_referencer::get_staff_symbol (me);
+  if (st && a == Y_AXIS
+      && gh_number_p (me->get_grob_property ("staff-padding")))
+    {
+      Real padding=
+      Staff_symbol_referencer::staff_space (me)
+      * gh_scm2double (me->get_grob_property ("staff-padding"));
+  
+      Grob *common = me->common_refpoint (st, Y_AXIS);
+      
+      Interval staff_size = st->extent (common, Y_AXIS);
+      Interval me_ext = me->extent (common, a);
+      Real diff =  d*staff_size[d] + padding - d*(o + iv[-d]);
+      o += (d*  (diff >? 0));
+    }
+      
   return gh_double2scm (o);
 }
 
@@ -205,28 +225,7 @@ MAKE_SCHEME_CALLBACK (Side_position_interface,out_of_staff,2);
 SCM
 Side_position_interface::out_of_staff (SCM element_smob, SCM axis)
 {
-  Grob *me = unsmob_grob (element_smob);
-  Axis a = (Axis) gh_scm2int (axis);
-
-  Grob * st = Staff_symbol_referencer::get_staff_symbol (me);
-
-  if (!st)
-    return gh_int2scm (0);
-
-  SCM scm_padding = me->get_grob_property ("staff-padding");
-  if (!gh_number_p (scm_padding))
-    return gh_int2scm (0);
-  
-  Real padding=
-    Staff_symbol_referencer::staff_space (me)
-    * gh_scm2double (scm_padding);
-  
-  Grob *common = me->common_refpoint (st, Y_AXIS);
-  Direction d = Side_position_interface::get_direction (me);
-  Interval staff_size = st->extent (common, Y_AXIS);
-  Interval me_ext = me->extent (common, a);
-  Real diff =  d*staff_size[d] + padding - d*me_ext[-d];
-  return gh_double2scm (d*  (diff >? 0));
+  return gh_double2scm (0);
 }
 
 void
index 011e330c86aba03c7316bcc8694e270d7b361a95..9a3c034352784ca714d5702cfe3a93f0dda888c9 100644 (file)
@@ -114,8 +114,6 @@ Staff_symbol::get_line_thickness (Grob* me)
 Real
 Staff_symbol::get_ledger_line_thickness (Grob * me)
 {
-  Real lt = me->get_paper ()->get_realvar (ly_symbol2scm ("linethickness"));
-
   SCM lt_pair = me->get_grob_property ("ledger-line-thickness");
   Offset z = robust_scm2offset (lt_pair, Offset (1.0, 0.1));
   
index 049bcb1d855a7e4db1992c249571baada4f9d56a..f5865c343c1277855af8cf7f02c7f384f85c2779 100644 (file)
@@ -73,7 +73,7 @@ System_start_delimiter_engraver::process_music ()
   if (!delim_)
     {
       SCM delim_name =get_property ("systemStartDelimiter");
-      delim_ = internal_make_spanner (internal_get_property (delim_name));
+      delim_ = internal_make_spanner (delim_name);
 
       delim_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn")));
       announce_grob (delim_, SCM_EOL);
index dcdb6964101785d7998b92d49c38ffbb6451732c..395eab13f48ccc8fb9d17de6d1baadde4b123f42 100644 (file)
        ))
     (MeasureGrouping
      . (
-       (Y-offset-callbacks . (,Side_position_interface::out_of_staff 
-                              ,Side_position_interface::aligned_side))
+       (Y-offset-callbacks . (,Side_position_interface::aligned_side))
        (molecule-callback . ,Measure_grouping::brew_molecule)
        (padding . 2)
        (direction . 1)
     
     (OttavaBracket
      . (
-       (Y-offset-callbacks . (,Side_position_interface::out_of_staff
-                              ,Side_position_interface::aligned_side))
+       (Y-offset-callbacks . (,Side_position_interface::aligned_side))
        (molecule-callback . ,Ottava_bracket::brew_molecule)
        (font-shape . italic)
        (font-family . roman)