]> git.donarmstrong.com Git - lilypond.git/commitdiff
make max-slope configurable on skylines
authorJoe Neeman <joeneeman@gmail.com>
Wed, 6 Dec 2006 22:16:28 +0000 (00:16 +0200)
committerJoe Neeman <joeneeman@gmail.com>
Wed, 6 Dec 2006 22:16:28 +0000 (00:16 +0200)
lily/accidental-placement.cc
lily/axis-group-interface.cc
lily/include/skyline.hh
lily/separation-item.cc
lily/skyline.cc
lily/system.cc
lily/tie-formatting-problem.cc
scm/define-grob-properties.scm

index f8245b0cbf08edd7bd0b00e16fd30735cd563764..bc091cb6afb75e6649112197c8dcaf7ac03c1938 100644 (file)
@@ -340,8 +340,8 @@ Accidental_placement::calc_positioning_done (SCM smob)
 
          ape->extents_.insert (ape->extents_.end (), boxes.begin (), boxes.end ());
        }
-      ape->left_skyline_ = Skyline (ape->extents_, Y_AXIS, LEFT);
-      ape->right_skyline_ = Skyline (ape->extents_, Y_AXIS, RIGHT);
+      ape->left_skyline_ = Skyline (ape->extents_, 4, Y_AXIS, LEFT);
+      ape->right_skyline_ = Skyline (ape->extents_, 4, Y_AXIS, RIGHT);
     }
 
   Interval total;
@@ -373,7 +373,7 @@ Accidental_placement::calc_positioning_done (SCM smob)
                                   stems[i]->pure_height (common[Y_AXIS], 0, very_large)));
     }
 
-  head_ape->left_skyline_ = Skyline (head_extents, Y_AXIS, LEFT);
+  head_ape->left_skyline_ = Skyline (head_extents, 4, Y_AXIS, LEFT);
   head_ape->offset_ = 0.0;
 
   Real padding = robust_scm2double (me->get_property ("padding"), 0.2);
index 7edb236e5eb4ede1562315fb51d68cdcd58a3833..6d7074fe98f18152c84e620d6131e6f08cbebc9e 100644 (file)
@@ -293,6 +293,7 @@ Axis_group_interface::skyline_spacing (Grob *me, vector<Grob*> elements)
   vector_sort (elements, staff_priority_less);
   Grob *x_common = common_refpoint_of_array (elements, me, X_AXIS);
   Grob *y_common = common_refpoint_of_array (elements, me, Y_AXIS);
+  Real max_slope = robust_scm2double (me->get_property ("skyline-max-slope"), 4);
 
   vsize i = 0;
   vector<Box> boxes;
@@ -301,8 +302,8 @@ Axis_group_interface::skyline_spacing (Grob *me, vector<Grob*> elements)
         && !scm_is_number (elements[i]->get_property ("outside-staff-priority")); i++)
     add_boxes (elements[i], x_common, y_common, &boxes);
 
-  Drul_array<Skyline> skylines (Skyline (boxes, X_AXIS, DOWN),
-                               Skyline (boxes, X_AXIS, UP));
+  Drul_array<Skyline> skylines (Skyline (boxes, max_slope, X_AXIS, DOWN),
+                               Skyline (boxes, max_slope, X_AXIS, UP));
   for (; i < elements.size (); i++)
     {
       Direction dir = get_grob_direction (elements[i]);
@@ -322,7 +323,7 @@ Axis_group_interface::skyline_spacing (Grob *me, vector<Grob*> elements)
 
       boxes.clear ();
       boxes.push_back (b);
-      Skyline other = Skyline (boxes, X_AXIS, -dir);
+      Skyline other = Skyline (boxes, max_slope, X_AXIS, -dir);
       Real padding = robust_scm2double (elements[i]->get_property ("outside-staff-padding"), 0.5);
       Real dist = skylines[dir].distance (other) + padding;
 
@@ -331,7 +332,7 @@ Axis_group_interface::skyline_spacing (Grob *me, vector<Grob*> elements)
          b.translate (Offset (0, dir*dist));
          elements[i]->translate_axis (dir*dist, Y_AXIS);
        }
-      skylines[dir].insert (b, X_AXIS);
+      skylines[dir].insert (b, max_slope, X_AXIS);
     }
 }
 
@@ -344,6 +345,7 @@ ADD_INTERFACE (Axis_group_interface,
               "elements "
               "common-refpoint-of-elements "
               "pure-relevant-elements "
+              "skyline-max-slope "
               "skyline-spacing "
               "cached-pure-extents "
               );
index be426185f0e15e0fa33e9808724601585b011c19..de38eae3181f094bb9222f18f7711cf67fba95b6 100644 (file)
@@ -41,11 +41,10 @@ class Skyline
 private:
   list<Building> buildings_;
   Direction sky_;
-  Real max_slope_;             // fixme: not part of skyline per se?
   
   void internal_merge_skyline (list<Building>*, list<Building>*,
                               list<Building> *const result);
-  void internal_build_skyline (list<Building>*,
+  void internal_build_skyline (list<Building>*, Real max_slope,
                               list<Building> *const result);
   bool is_legal_skyline () const;
 
@@ -54,11 +53,11 @@ public:
   Skyline ();
   Skyline (Skyline const &src);
   Skyline (Direction sky);
-  Skyline (vector<Box> const &bldgs, Axis a, Direction sky);
+  Skyline (vector<Box> const &bldgs, Real max_slope, Axis a, Direction sky);
   Skyline (vector<Offset> const &points, Real max_slope, Direction sky);
   vector<Offset> to_points () const;
   void merge (Skyline const &);
-  void insert (Box const &, Axis);
+  void insert (Box const &, Real max_slope, Axis);
   void print () const;
   void raise (Real);
   Real distance (Skyline const &) const;
index 4a7f0f06720bb67d5779f434021ddfc90ac2c3c6..03996bae89b7e397cadb047efcc09f16bafdad96 100644 (file)
@@ -128,7 +128,8 @@ Separation_item::calc_skylines (SCM smob)
   vector<Box> bs = boxes (me);
   do
     {
-      Skyline l (bs, Y_AXIS, d);
+      /* todo: make skyline max-slope configurable? */
+      Skyline l (bs, 2, Y_AXIS, d);
       index_set_cell (lines, d, l.smobbed_copy ());
     }
   while (flip (&d) != LEFT);
index 8fdaeedd0ca95c01691517ea2a2d095ccad91b46..fd8c1357efd964952bf8389baf8950a79b9e3cd1 100644 (file)
@@ -228,7 +228,7 @@ single_skyline (Building const &b, list<Building> *const ret, Real max_slope)
 }
 
 void
-Skyline::internal_build_skyline (list<Building> *buildings, list<Building> *const result)
+Skyline::internal_build_skyline (list<Building> *buildings, Real max_slope, list<Building> *const result)
 {
   vsize size = buildings->size ();
 
@@ -239,7 +239,7 @@ Skyline::internal_build_skyline (list<Building> *buildings, list<Building> *cons
     }
   else if (size == 1)
     {
-      single_skyline (buildings->front (), result, max_slope_);
+      single_skyline (buildings->front (), result, max_slope);
       return;
     }
 
@@ -252,23 +252,19 @@ Skyline::internal_build_skyline (list<Building> *buildings, list<Building> *cons
 
   list<Building> right;
   list<Building> left;
-  internal_build_skyline (&right_half, &right);
-  internal_build_skyline (buildings, &left);
+  internal_build_skyline (&right_half, max_slope, &right);
+  internal_build_skyline (buildings, max_slope, &left);
   internal_merge_skyline (&right, &left, result);
 }
 
 Skyline::Skyline ()
 {
-  max_slope_ = 2;
   sky_ = UP;
-  empty_skyline (&buildings_);
-
-  
+  empty_skyline (&buildings_);  
 }
 
 Skyline::Skyline (Skyline const &src)
 {
-  max_slope_ = src.max_slope_;
   sky_ = src.sky_;
  
   for (list<Building>::const_iterator i = src.buildings_.begin ();
@@ -280,7 +276,6 @@ Skyline::Skyline (Skyline const &src)
 
 Skyline::Skyline (Direction sky)
 {
-  max_slope_ = 2;
   sky_ = sky;
   empty_skyline (&buildings_);
 }
@@ -290,11 +285,10 @@ Skyline::Skyline (Direction sky)
 
   Boxes should have fatness in the horizon_axis, otherwise they are ignored.
  */
-Skyline::Skyline (vector<Box> const &boxes, Axis horizon_axis, Direction sky)
+Skyline::Skyline (vector<Box> const &boxes, Real max_slope, Axis horizon_axis, Direction sky)
 {
   list<Building> bldgs;
   sky_ = sky;
-  max_slope_ = 2;
 
   for (vsize i = 0; i < boxes.size (); i++)
     {
@@ -302,23 +296,22 @@ Skyline::Skyline (vector<Box> const &boxes, Axis horizon_axis, Direction sky)
       Real height = sky * boxes[i][other_axis (horizon_axis)][sky];
       if (!iv.is_empty () && !isinf (height) && !equal (iv[LEFT], iv[RIGHT]))
        bldgs.push_front (Building (iv[LEFT], height, height, iv[RIGHT],
-                                   max_slope_));
+                                   max_slope));
     }
   
-  internal_build_skyline (&bldgs, &buildings_);
+  internal_build_skyline (&bldgs, max_slope, &buildings_);
   assert (is_legal_skyline ());
 }
 
 Skyline::Skyline (vector<Offset> const &points, Real max_slope, Direction sky)
 {
   sky_ = sky;
-  max_slope_ = max_slope;
 
   for (vsize i = 1; i < points.size (); i++)
     {
-      buildings_.push_back (Building (points[i-1][X_AXIS], sky * points[i-1][Y_AXIS],
+      buildings_.push_back (Building (points[i-1][X_AXIS],
+                                     sky * points[i-1][Y_AXIS],
                                      sky * points[i][Y_AXIS],
-
                                      points[i][X_AXIS], 
                                      max_slope));
 
@@ -340,7 +333,7 @@ Skyline::merge (Skyline const &other)
 }
 
 void
-Skyline::insert (Box const &b, Axis a)
+Skyline::insert (Box const &b, Real max_slope, Axis a)
 {
   list<Building> other_bld;
   list<Building> my_bld;
@@ -350,7 +343,7 @@ Skyline::insert (Box const &b, Axis a)
   assert (!iv.is_empty ());
 
   my_bld.splice (my_bld.begin (), buildings_);
-  single_skyline (Building (iv[LEFT], height, height, iv[RIGHT], max_slope_), &other_bld, max_slope_);
+  single_skyline (Building (iv[LEFT], height, height, iv[RIGHT], max_slope), &other_bld, max_slope);
   internal_merge_skyline (&other_bld, &my_bld, &buildings_);
   assert (is_legal_skyline ());
 }
index c53099257f91110d63acdf5c9f2036a9b6aa97ea..b8557a6f046f020dbdbf6c8502f044fb022b8a47 100644 (file)
@@ -531,8 +531,9 @@ System::build_skylines ()
        boxes.push_back (Box (xiv, yiv));
     }
 
-  skylines_[UP] = Skyline (boxes, X_AXIS, UP);
-  skylines_[DOWN] = Skyline (boxes, X_AXIS, DOWN);
+  /* todo: make skyline slope configurable? */
+  skylines_[UP] = Skyline (boxes, 2, X_AXIS, UP);
+  skylines_[DOWN] = Skyline (boxes, 2, X_AXIS, DOWN);
 }
 
 
index 9f05c5b8073bdc2c5edd204acf5c4d3bf6a35b0c..60d9e1bc11171e637dc69171d4de15423b8ee40d 100644 (file)
@@ -175,7 +175,7 @@ Tie_formatting_problem::set_column_chord_outline (vector<Item*> bounds,
     }
   while (flip (&updowndir) != DOWN);
   
-  chord_outlines_[key] = Skyline (boxes, Y_AXIS, -dir);
+  chord_outlines_[key] = Skyline (boxes, 4, Y_AXIS, -dir);
   if (bounds[0]->break_status_dir ())
     {
       Real x = robust_relative_extent (bounds[0],  x_refpoint_, X_AXIS)[-dir];
index 0081da0636302cbd9f1879ae2d1db7bbf36b054f..25861affa54c315b70711665903cda0d99e8b367 100644 (file)
@@ -556,6 +556,7 @@ than a whole rest.")
 
      (spaceable-staves ,ly:grob-array? "Objects to be spaced during page layout.")
      (skyline-distance ,number? "The distance between this staff and the next one, as determined by a skyline algorithm.")
+     (skyline-max-slope ,number? "The maximum slope of buildings in the skyline used in skyline-spacing. If this is small, grobs will be placed away from the staff is there is another grob within a short horizontal distance (even if there would be no collision). If this is large (100, say), grobs will be placed close to the staff even if it means packing them in tightly horizontally.")
      (skyline-spacing ,boolean? "When true, this axis-group will vertically space its children
 using a skyline algorithm.")