X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Ftie-formatting-problem.cc;h=a55f31373519f6519131a5c5fd76bb8724c55cdd;hb=424dee2dd114c4b69c3b58d2ef61e310e5d492f8;hp=d22d54bb6a28d43719a13ca5cc1b5111d6af6e88;hpb=f1be8fc9c6ff873ed9074dfb27fc898a8b001306;p=lilypond.git diff --git a/lily/tie-formatting-problem.cc b/lily/tie-formatting-problem.cc index d22d54bb6a..a55f313735 100644 --- a/lily/tie-formatting-problem.cc +++ b/lily/tie-formatting-problem.cc @@ -12,7 +12,6 @@ #include "paper-column.hh" #include "bezier.hh" #include "directional-element-interface.hh" -#include "item.hh" #include "libc-extension.hh" #include "misc.hh" #include "note-head.hh" @@ -51,7 +50,7 @@ Tie_formatting_problem::get_attachment (Real y, Drul_array columns) const if (i == chord_outlines_.end ()) programming_error ("Can't find chord outline"); else - attachments[d] = skyline_height ((*i).second, y, -d); + attachments[d] = i->second.height (y); } while (flip (&d) != LEFT); @@ -115,28 +114,6 @@ Tie_formatting_problem::set_column_chord_outline (vector bounds, } Tuple2 key (column_rank, int (dir)); - - chord_outlines_[key] = empty_skyline (-dir); - - if (bounds[0]->break_status_dir ()) - { - Real x = robust_relative_extent (bounds[0], x_refpoint_, X_AXIS)[-dir]; - chord_outlines_[key].at (0).height_ = x; - } - else - { - Interval x; - for (vsize j = 0; j < head_boxes.size (); j++) - { - x.unite (head_boxes[j][X_AXIS]); - } - - chord_outlines_[key].at (0).height_ = x[dir]; - } - - for (vsize i = 0; i < boxes.size (); i++) - insert_extent_into_skyline (&chord_outlines_[key] , - boxes[i], Y_AXIS, -dir); if (stem && !Stem::is_invisible (stem)) @@ -150,8 +127,8 @@ Tie_formatting_problem::set_column_chord_outline (vector bounds, Direction stemdir = get_grob_direction (stem); y.add_point (Stem::head_positions (stem)[-stemdir] * staff_space * .5); - - insert_extent_into_skyline (&chord_outlines_[key], Box (x,y), Y_AXIS, -dir); + + boxes.push_back (Box (x, y)); stem_extents_[key].unite (Box (x,y)); @@ -159,8 +136,7 @@ Tie_formatting_problem::set_column_chord_outline (vector bounds, { Box flag_box = Stem::get_translated_flag (stem).extent_box (); flag_box.translate( Offset (x[RIGHT], X_AXIS)); - insert_extent_into_skyline (&chord_outlines_[key], flag_box, - Y_AXIS, -dir); + boxes.push_back (flag_box); } } else if (stem) @@ -176,10 +152,8 @@ Tie_formatting_problem::set_column_chord_outline (vector bounds, Interval y_ext; for (vsize j = 0; j < head_boxes.size (); j++) y_ext.unite (head_boxes[j][Y_AXIS]); - - insert_extent_into_skyline (&chord_outlines_[key], - Box (x_ext, y_ext), - Y_AXIS, -dir); + + boxes.push_back (Box (x_ext, y_ext)); } Direction updowndir = DOWN; @@ -197,12 +171,28 @@ Tie_formatting_problem::set_column_chord_outline (vector bounds, } if (!x.is_empty ()) - insert_extent_into_skyline (&chord_outlines_[key], - Box (x,y), - Y_AXIS, -dir); + boxes.push_back (Box (x, y)); } while (flip (&updowndir) != DOWN); - + + /* todo: the horizon_padding is somewhat arbitrary */ + chord_outlines_[key] = Skyline (boxes, 0.1, Y_AXIS, -dir); + if (bounds[0]->break_status_dir ()) + { + Real x = robust_relative_extent (bounds[0], x_refpoint_, X_AXIS)[-dir]; + chord_outlines_[key].set_minimum_height (x); + } + else + { + Interval x; + for (vsize j = 0; j < head_boxes.size (); j++) + { + x.unite (head_boxes[j][X_AXIS]); + } + + chord_outlines_[key].set_minimum_height (x[dir]); + } + head_extents_[key].set_empty (); for (vsize i = 0; i < head_boxes.size (); i++) { @@ -344,22 +334,12 @@ Tie_formatting_problem::from_semi_ties (vector const &semi_ties, Directio set_chord_outline (heads, head_dir); - Real extremal = head_dir * infinity_f; - Tuple2 head_key (column_rank, head_dir); Tuple2 open_key (column_rank, -head_dir); - - for (vsize i = 0; i < chord_outlines_[head_key].size (); i++) - { - extremal = head_dir * min (head_dir * extremal, - head_dir * chord_outlines_[head_key][i].height_); - } + Real extremal = chord_outlines_[head_key].max_height (); - Skyline_entry right_entry; - right_entry.width_.set_full (); - right_entry.height_ = extremal - head_dir * 1.5; - - chord_outlines_[open_key].push_back (right_entry); + chord_outlines_[open_key] = Skyline (head_dir); + chord_outlines_[open_key].set_minimum_height (extremal - head_dir * 1.5); } @@ -514,13 +494,21 @@ Tie_formatting_problem::generate_configuration (int pos, Direction dir, Interval Tie_formatting_problem::get_head_extent (int col, Direction d, Axis a) const { - return (*head_extents_.find (Tuple2 (col, int (d)))).second[a]; + Column_extent_map::const_iterator i = head_extents_.find (Tuple2 (col, int (d))); + if (i != head_extents_.end ()) + return (*i).second[a]; + else + return Interval (); } Interval Tie_formatting_problem::get_stem_extent (int col, Direction d, Axis a) const { - return (*stem_extents_.find (Tuple2 (col, int (d)))).second[a]; + Column_extent_map::const_iterator i = stem_extents_.find (Tuple2 (col, int (d))); + if (i != stem_extents_.end ()) + return (*i).second[a]; + else + return Interval (); } /**