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;
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);
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;
&& !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]);
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;
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);
}
}
"elements "
"common-refpoint-of-elements "
"pure-relevant-elements "
+ "skyline-max-slope "
"skyline-spacing "
"cached-pure-extents "
);
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;
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;
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);
}
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 ();
}
else if (size == 1)
{
- single_skyline (buildings->front (), result, max_slope_);
+ single_skyline (buildings->front (), result, max_slope);
return;
}
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 ();
Skyline::Skyline (Direction sky)
{
- max_slope_ = 2;
sky_ = sky;
empty_skyline (&buildings_);
}
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++)
{
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));
}
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;
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 ());
}
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);
}
}
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];
(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.")