Tie_formatting_problem): new file.
* lily/tie-formatting-problem.cc (common_x_refpoint): new file.
class Tie;
class Tie_details;
class Tie_configuration;
+class Tie_formatting_problem;
+class Ties_configuration;
class Tie_performer;
class Time_scaled_music;
class Time_scaled_music_iterator;
Link_array<Item> bounds,
Grob *common,
Direction d);
-void set_tie_config_directions (Array<Tie_configuration> *tie_configs_ptr);
-void shift_small_ties (Array<Tie_configuration> *tie_configs,
+void set_tie_config_directions (Ties_configuration *tie_configs_ptr);
+void shift_small_ties (Ties_configuration *tie_configs,
Grob *staff_referencer,
Tie_details const &details);
void final_shape_adjustment (Tie_configuration &conf,
- Drul_array< Array<Skyline_entry> > const &skylines,
+ Tie_formatting_problem const&,
Grob *staff_referencer,
Tie_details const &details);
void
Grob *common);
void
-set_manual_tie_configuration (Array<Tie_configuration> *tie_configs,
+set_manual_tie_configuration (Ties_configuration *tie_configs,
bool *manual_override,
SCM manual_configs
);
--- /dev/null
+/*
+ tie-formatting-problem.hh -- declare
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+*/
+
+#ifndef TIE_FORMATTING_PROBLEM_HH
+#define TIE_FORMATTING_PROBLEM_HH
+
+#include "drul-array.hh"
+#include "parray.hh"
+#include "skyline.hh"
+#include "lily-proto.hh"
+
+class Tie_formatting_problem
+{
+ Drul_array< Array<Skyline_entry> > chord_outlines_;
+ Grob *x_refpoint_;
+public:
+ Tie_formatting_problem ();
+
+ void from_ties (Link_array<Grob> const &ties);
+ void from_tie (Grob *tie);
+ void from_lv_ties (Link_array<Grob> const &);
+ void set_chord_outline (Link_array<Item>, Direction);
+
+ Interval get_attachment (Real) const;
+ Grob *common_x_refpoint () const;
+};
+
+#endif /* TIE_FORMATTING_PROBLEM_HH */
-Interval
-get_skyline_attachment (Drul_array< Array < Skyline_entry > > const &skylines,
- Real y1);
-
struct Tie_details
{
Real height_limit_;
void init (Grob *);
};
-struct Tie_configuration
+class Tie_configuration
{
- int head_position_;
+public:
int position_;
-
Direction dir_;
- Interval attachment_x_;
Real delta_y_;
+
+
+ Interval attachment_x_;
+ Grob *tie_;
+ int head_position_;
Tie_configuration ();
void center_tie_vertically (Tie_details const &);
INSTANTIATE_COMPARE (Tie_configuration, Tie_configuration::compare);
+class Ties_configuration
+{
+public:
+ Array<Tie_configuration> ties_;
+
+};
+
+
class Tie
{
public:
static int get_column_rank (Grob *, Direction);
static int get_position (Grob *);
static Direction get_default_dir (Grob *);
- static void get_configuration (Grob *, Grob *, Tie_configuration *,
- Drul_array< Array<Skyline_entry> > const *,
+ static void get_configuration (Grob *, Tie_configuration *,
+ Tie_formatting_problem const &,
Tie_details const &
);
- static void set_control_points (Grob *, Grob *,Tie_configuration const&,
- Tie_details const&
- );
+ static void set_control_points (Grob *, Grob *,
+ Tie_configuration const&,
+ Tie_details const&);
static void set_default_control_points (Grob *);
DECLARE_SCHEME_CALLBACK (print, (SCM));
DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM));
#include "staff-symbol-referencer.hh"
#include "item.hh"
#include "tie-column-format.hh"
+#include "tie-formatting-problem.hh"
ADD_INTERFACE(Laissez_vibrer_tie_column,
lv_ties.sort (&Laissez_vibrer_tie::compare);
- Array<Tie_configuration> tie_configs;
- Link_array<Item> heads;
+ Ties_configuration ties_config;
for (int i = 0; i < lv_ties.size (); i++)
{
Tie_configuration conf;
conf.dir_ = CENTER;
Item *head = unsmob_item (lv_ties[i]->get_object ("note-head"));
- heads.push (head);
if (head)
conf.position_ = (int) Staff_symbol_referencer::get_position (head);
- tie_configs.push (conf);
+ ties_config.ties_.push (conf);
}
bool manual_override = false;
SCM manual_configs = me->get_property ("tie-configuration");
- set_manual_tie_configuration (&tie_configs,
+ set_manual_tie_configuration (&ties_config,
&manual_override,
manual_configs
);
- set_tie_config_directions (&tie_configs);
+ set_tie_config_directions (&ties_config);
- Grob *common = me;
- for (int i = 0; i < lv_ties.size (); i++)
- {
- common = lv_ties[i]->common_refpoint (common, X_AXIS);
- }
-
- Drul_array< Array<Skyline_entry> > skylines;
- set_chord_outline (&skylines[LEFT],
- heads,
- common, LEFT);
-
- Real right_most = - infinity_f;
- for (int i = 0; i < skylines[LEFT].size (); i++)
- {
- right_most = max (right_most, skylines[LEFT][i].height_);
- }
-
- Skyline_entry right_entry;
- right_entry.width_.set_full ();
- right_entry.height_ = right_most + 1.5;
-
- skylines[RIGHT].push (right_entry);
+ Tie_formatting_problem problem;
+ problem.from_lv_ties (lv_ties);
Tie_details details;
details.init (lv_ties[0]);
*/
for (int i = 0; i < lv_ties.size(); i++)
{
- final_shape_adjustment (tie_configs[i],
- skylines,
+ final_shape_adjustment (ties_config.ties_[i],
+ problem,
lv_ties[0],
details);
}
*/
if (!manual_override)
{
- shift_small_ties (&tie_configs, lv_ties[0], details);
+ shift_small_ties (&ties_config, lv_ties[0], details);
}
for (int i = 0; i < lv_ties.size(); i++)
{
- Tie::set_control_points (lv_ties[i], common, tie_configs[i],
+ Tie::set_control_points (lv_ties[i], problem.common_x_refpoint (), ties_config.ties_[i],
details );
- set_grob_direction (lv_ties[i], tie_configs[i].dir_);
+ set_grob_direction (lv_ties[i], ties_config.ties_[i].dir_);
}
return SCM_BOOL_T;
#include "staff-symbol-referencer.hh"
#include "directional-element-interface.hh"
#include "rhythmic-head.hh"
+#include "tie-formatting-problem.hh"
#include <set>
void
-set_manual_tie_configuration (Array<Tie_configuration> *tie_configs,
+set_manual_tie_configuration (Ties_configuration *ties_config,
bool *manual_override,
SCM manual_configs
)
*manual_override = false;
int k = 0;
for (SCM s = manual_configs;
- scm_is_pair (s) && k < tie_configs->size(); s = scm_cdr (s))
+ scm_is_pair (s) && k < ties_config->ties_.size(); s = scm_cdr (s))
{
SCM entry = scm_car (s);
if (!scm_is_pair (entry))
continue;
*manual_override = true;
- Tie_configuration &conf = tie_configs->elem_ref (k);
+ Tie_configuration &conf = ties_config->ties_.elem_ref (k);
Real complete_pos = robust_scm2double (scm_car (entry),
conf.position_);
}
void
-set_chord_outline (Array<Skyline_entry> *skyline,
- Link_array<Item> bounds,
- Grob *common,
- Direction d)
-{
- Real staff_space = Staff_symbol_referencer::staff_space (bounds[0]);
-
- Array<Box> boxes;
-
- Grob *stem = 0;
- for (int i = 0; i < bounds.size (); i++)
- {
- Grob *head = bounds[i];
- if (!Note_head::has_interface (head))
- continue;
-
- if (!stem)
- stem = unsmob_grob (head->get_object ("stem"));
-
- Real p = Staff_symbol_referencer::get_position (head);
- Interval y ((p-1) * 0.5 * staff_space,
- (p+1) * 0.5 * staff_space);
-
- Interval x = head->extent (common, X_AXIS);
- boxes.push (Box (x, y));
-
- Grob *dots = Rhythmic_head::get_dots (head);
- if (d == LEFT && dots)
- {
- Interval x = dots->extent (common, X_AXIS);
- Interval y (-0.5, 0.5);
- y.translate (Staff_symbol_referencer::get_position (dots));
- y *= staff_space * 0.5;
-
- boxes.push (Box (x, y));
- }
- }
-
- (*skyline) = empty_skyline (-d);
-
- if (bounds[0]->break_status_dir ())
- {
- Real x = robust_relative_extent (bounds[0], common, X_AXIS)[-d];
- skyline->elem_ref (0).height_ = x;
- }
-
- for (int i = 0; i < boxes.size (); i++)
- insert_extent_into_skyline (skyline,
- boxes[i], Y_AXIS, -d);
- if (stem
- && !Stem::is_invisible (stem))
- {
- Interval x;
- x.add_point (stem->relative_coordinate (common, X_AXIS));
- x.widen (staff_space / 20); // ugh.
- Interval y;
- y.add_point (Stem::stem_end_position (stem) * staff_space * .5);
-
- Direction stemdir = get_grob_direction (stem);
- y.add_point (Stem::head_positions (stem)[-stemdir]
- * staff_space * .5);
-
- insert_extent_into_skyline (skyline, Box (x,y), Y_AXIS, -d);
-
-
-
- if (d == LEFT)
- {
- Box flag_box = Stem::get_translated_flag (stem).extent_box ();
- flag_box.translate( Offset (x[RIGHT], X_AXIS));
- insert_extent_into_skyline (skyline, flag_box,
- Y_AXIS, -d);
- }
- }
-
- Direction updowndir = DOWN;
- do
- {
- Interval x ;
- Interval y;
- if (boxes.size())
- {
- Box b = boxes.boundary (updowndir, 0);
- x = b[X_AXIS];
- x[-d] = b[X_AXIS].linear_combination (-d / 2);
- y[-updowndir] = b[Y_AXIS][updowndir];
- y[updowndir] = updowndir * infinity_f;
- }
-
- if (!x.is_empty ())
- insert_extent_into_skyline (skyline,
- Box (x,y),
- Y_AXIS, -d);
- }
- while (flip (&updowndir) != DOWN);
-
- for (int i = 0; i < bounds.size (); i++)
- {
- if (!Note_head::has_interface (bounds[i]))
- continue;
-
-
- Grob *dots = unsmob_grob (bounds[i]->get_object ("dot"));
- if (dots && d == LEFT)
- {
- Interval x = dots->extent (common, X_AXIS);
- Real p = Staff_symbol_referencer::get_position (dots);
-
- Interval y (-1,1);
- y *= (staff_space /4);
- y.translate (p * staff_space * .5);
-
- insert_extent_into_skyline (skyline,
- Box (x,y), Y_AXIS, -d);
- }
- }
-}
-
-void
-set_chord_outlines (Drul_array< Array<Skyline_entry> > *skyline_drul,
- Link_array<Grob> ties,
- Grob *common)
-{
- Direction d = LEFT;
-
- do
- {
- Link_array<Item> bounds;
-
- for (int i = 0; i < ties.size (); i++)
- {
- Item *it = dynamic_cast<Spanner*> (ties[i])->get_bound (d);
-
- bounds.push (it);
- }
-
- set_chord_outline (&skyline_drul->elem_ref (d),
- bounds, common, d);
- }
- while (flip (&d) != LEFT);
-}
-
-void
-shift_small_ties (Array<Tie_configuration> *tie_configs,
+shift_small_ties (Ties_configuration *tie_configs,
Grob *staff_referencer,
Tie_details const &details)
{
set<int> positions_taken;
- for (int i = 0; i < tie_configs->size (); i++)
- positions_taken.insert (int (rint (tie_configs->elem (i).position_)));
+ for (int i = 0; i < tie_configs->ties_.size (); i++)
+ positions_taken.insert (int (rint (tie_configs->ties_.elem (i).position_)));
- for (int i = 0; i < tie_configs->size (); i++)
+ for (int i = 0; i < tie_configs->ties_.size (); i++)
{
- Tie_configuration * conf = &tie_configs->elem_ref (i);
+ Tie_configuration * conf = &tie_configs->ties_.elem_ref (i);
/*
on staff line and small enough, translate a little further
void
final_shape_adjustment (Tie_configuration &conf,
- Drul_array< Array<Skyline_entry> > const &skylines,
+ Tie_formatting_problem const &problem,
Grob *staff_referencer,
Tie_details const &details)
{
Real y = conf.position_ * details.staff_space_ * 0.5
+ line_dy;
- conf.attachment_x_ = get_skyline_attachment (skylines, y);
- conf.attachment_x_.intersect (get_skyline_attachment (skylines,
- y + conf.dir_ * details.staff_space_ * 0.5));
+ conf.attachment_x_ = problem.get_attachment (y);
+ conf.attachment_x_.intersect (problem.get_attachment (y + conf.dir_ * details.staff_space_ * 0.5));
conf.delta_y_ += line_dy;
conf.attachment_x_.widen (-details.x_gap_);
}
void
-set_tie_config_directions (Array<Tie_configuration> *tie_configs_ptr)
+set_tie_config_directions (Ties_configuration *tie_configs_ptr)
{
- Array<Tie_configuration> &tie_configs (*tie_configs_ptr);
+ Array<Tie_configuration> &tie_configs (tie_configs_ptr->ties_);
if (!tie_configs[0].dir_)
tie_configs[0].dir_ = DOWN;
*/
for (int i = 1; i < tie_configs.size(); i++)
{
- Real diff = tie_configs[i-1].position_ - tie_configs[i].position_;
+ Real diff = tie_configs[i-1].position_
+ - tie_configs[i].position_;
+
if (fabs (diff) <= 1)
{
if (!tie_configs[i-1].dir_)
for (int i = 1; i < tie_configs.size() - 1; i++)
{
- if (tie_configs[i].dir_)
+ Tie_configuration &conf = tie_configs.elem_ref (i);
+ if (conf.dir_)
continue;
- Direction position_dir = (Direction) sign (tie_configs[i].position_);
+ Direction position_dir =
+ Direction (sign (conf.position_));
if (!position_dir)
position_dir = DOWN;
-
- tie_configs[i].dir_ = position_dir;
+
+ conf.dir_ = position_dir;
}
}
#include "tie.hh"
#include "directional-element-interface.hh"
#include "tie-column-format.hh"
+#include "tie-formatting-problem.hh"
using namespace std;
ties.sort (&Tie::compare);
- Array<Tie_configuration> tie_configs;
+ Ties_configuration ties_config;
for (int i = 0; i < ties.size (); i++)
{
Tie_configuration conf;
- conf.dir_ = get_grob_direction (ties[i]);
+ if (scm_is_number (ties[i]->get_property_data (ly_symbol2scm ("direction"))))
+ conf.dir_ = get_grob_direction (ties[i]);
conf.position_ = Tie::get_position (ties[i]);
- tie_configs.push (conf);
+ ties_config.ties_.push (conf);
}
SCM manual_configs = me->get_property ("tie-configuration");
bool manual_override = false;
- set_manual_tie_configuration (&tie_configs,
+ set_manual_tie_configuration (&ties_config,
&manual_override,
manual_configs);
- set_tie_config_directions (&tie_configs);
+ set_tie_config_directions (&ties_config);
- Grob *common = me;
- for (int i = 0; i < ties.size (); i++)
- {
- common = dynamic_cast<Spanner*> (ties[i])->get_bound (LEFT)->common_refpoint (common, X_AXIS);
- common = dynamic_cast<Spanner*> (ties[i])->get_bound (RIGHT)->common_refpoint (common, X_AXIS);
- }
-
- Drul_array< Array<Skyline_entry> > skylines;
- set_chord_outlines (&skylines, ties, common);
+ Tie_formatting_problem problem;
+ problem.from_ties (ties);
Tie_details details;
details.init (ties[0]);
*/
if (!manual_override)
{
- Tie::get_configuration (ties[0], common, &tie_configs.elem_ref (0),
- &skylines,
- details
- );
- Tie::get_configuration (ties.top (), common,
- &tie_configs.elem_ref (tie_configs.size()-1),
- &skylines,
+ Tie::get_configuration (ties[0], &ties_config.ties_.elem_ref (0),
+ problem,
+ details);
+ Tie::get_configuration (ties.top (),
+ &ties_config.ties_.elem_ref (ties_config.ties_.size()-1),
+ problem,
details
);
}
continue;
- final_shape_adjustment (tie_configs[i],
- skylines,
+ final_shape_adjustment (ties_config.ties_[i],
+ problem,
ties[0],
details);
}
*/
if (!manual_override)
{
- shift_small_ties (&tie_configs, ties[0], details);
+ shift_small_ties (&ties_config, ties[0], details);
}
for (int i = 0; i < ties.size(); i++)
{
- Tie::set_control_points (ties[i], common, tie_configs[i],
+ Tie::set_control_points (ties[i], problem.common_x_refpoint (), ties_config.ties_[i],
details
);
- set_grob_direction (ties[i], tie_configs[i].dir_);
+ set_grob_direction (ties[i], ties_config.ties_[i].dir_);
}
return SCM_BOOL_T;
}
--- /dev/null
+/*
+ tie-formatting-problem.cc -- implement Tie_formatting_problem6
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+*/
+
+#include "tie-formatting-problem.hh"
+
+#include "directional-element-interface.hh"
+#include "staff-symbol-referencer.hh"
+#include "tie.hh"
+
+#include "item.hh"
+#include "spanner.hh"
+
+#include "stem.hh"
+#include "note-head.hh"
+#include "rhythmic-head.hh"
+
+Interval
+Tie_formatting_problem::get_attachment (Real y) const
+{
+ Interval attachments;
+ Direction d = LEFT;
+ do
+ {
+ attachments[d] = skyline_height (chord_outlines_[d], y, -d);
+ }
+ while (flip (&d) != LEFT);
+
+ return attachments;
+}
+
+
+
+
+Tie_formatting_problem::Tie_formatting_problem()
+{
+ x_refpoint_ = 0;
+
+}
+
+void
+Tie_formatting_problem::set_chord_outline (Link_array<Item> bounds,
+ Direction d)
+{
+ Real staff_space = Staff_symbol_referencer::staff_space (bounds[0]);
+
+ Array<Box> boxes;
+
+ Grob *stem = 0;
+ for (int i = 0; i < bounds.size (); i++)
+ {
+ Grob *head = bounds[i];
+ if (!Note_head::has_interface (head))
+ continue;
+
+ if (!stem)
+ stem = unsmob_grob (head->get_object ("stem"));
+
+ Real p = Staff_symbol_referencer::get_position (head);
+ Interval y ((p-1) * 0.5 * staff_space,
+ (p+1) * 0.5 * staff_space);
+
+ Interval x = head->extent (x_refpoint_, X_AXIS);
+ boxes.push (Box (x, y));
+
+ Grob *dots = Rhythmic_head::get_dots (head);
+ if (d == LEFT && dots)
+ {
+ Interval x = dots->extent (x_refpoint_, X_AXIS);
+ Interval y (-0.5, 0.5);
+ y.translate (Staff_symbol_referencer::get_position (dots));
+ y *= staff_space * 0.5;
+
+ boxes.push (Box (x, y));
+ }
+ }
+
+ chord_outlines_[d] = empty_skyline (-d);
+
+ if (bounds[0]->break_status_dir ())
+ {
+ Real x = robust_relative_extent (bounds[0], x_refpoint_, X_AXIS)[-d];
+ chord_outlines_[d].elem_ref (0).height_ = x;
+ }
+
+ for (int i = 0; i < boxes.size (); i++)
+ insert_extent_into_skyline (&chord_outlines_[d] ,
+ boxes[i], Y_AXIS, -d);
+
+ if (stem
+ && !Stem::is_invisible (stem))
+ {
+ Interval x;
+ x.add_point (stem->relative_coordinate (x_refpoint_, X_AXIS));
+ x.widen (staff_space / 20); // ugh.
+ Interval y;
+ y.add_point (Stem::stem_end_position (stem) * staff_space * .5);
+
+ Direction stemdir = get_grob_direction (stem);
+ y.add_point (Stem::head_positions (stem)[-stemdir]
+ * staff_space * .5);
+
+ insert_extent_into_skyline (&chord_outlines_[d], Box (x,y), Y_AXIS, -d);
+
+
+
+ if (d == LEFT)
+ {
+ Box flag_box = Stem::get_translated_flag (stem).extent_box ();
+ flag_box.translate( Offset (x[RIGHT], X_AXIS));
+ insert_extent_into_skyline (&chord_outlines_[d], flag_box,
+ Y_AXIS, -d);
+ }
+ }
+
+ Direction updowndir = DOWN;
+ do
+ {
+ Interval x ;
+ Interval y;
+ if (boxes.size())
+ {
+ Box b = boxes.boundary (updowndir, 0);
+ x = b[X_AXIS];
+ x[-d] = b[X_AXIS].linear_combination (-d / 2);
+ y[-updowndir] = b[Y_AXIS][updowndir];
+ y[updowndir] = updowndir * infinity_f;
+ }
+
+ if (!x.is_empty ())
+ insert_extent_into_skyline (&chord_outlines_[d],
+ Box (x,y),
+ Y_AXIS, -d);
+ }
+ while (flip (&updowndir) != DOWN);
+
+ for (int i = 0; i < bounds.size (); i++)
+ {
+ if (!Note_head::has_interface (bounds[i]))
+ continue;
+
+
+ Grob *dots = unsmob_grob (bounds[i]->get_object ("dot"));
+ if (dots && d == LEFT)
+ {
+ Interval x = dots->extent (x_refpoint_, X_AXIS);
+ Real p = Staff_symbol_referencer::get_position (dots);
+
+ Interval y (-1,1);
+ y *= (staff_space /4);
+ y.translate (p * staff_space * .5);
+
+ insert_extent_into_skyline (&chord_outlines_[d],
+ Box (x,y), Y_AXIS, -d);
+ }
+ }
+}
+
+
+void
+Tie_formatting_problem::from_tie (Grob *tie)
+{
+ Link_array<Grob> ties;
+ ties.push (tie);
+
+ from_ties (ties);
+}
+
+Grob *
+Tie_formatting_problem::common_x_refpoint () const
+{
+ return x_refpoint_;
+}
+
+void
+Tie_formatting_problem::from_ties (Link_array<Grob> const &ties)
+{
+ if (ties.is_empty ())
+ return;
+
+ x_refpoint_ = ties[0];
+ for (int i = 0; i < ties.size (); i++)
+ {
+ x_refpoint_ = dynamic_cast<Spanner*> (ties[i])->get_bound (LEFT)->common_refpoint (x_refpoint_, X_AXIS);
+ x_refpoint_ = dynamic_cast<Spanner*> (ties[i])->get_bound (RIGHT)->common_refpoint (x_refpoint_, X_AXIS);
+ }
+
+ Direction d = LEFT;
+ do
+ {
+ Link_array<Item> bounds;
+
+ for (int i = 0; i < ties.size (); i++)
+ {
+ Item *it = dynamic_cast<Spanner*> (ties[i])->get_bound (d);
+
+ bounds.push (it);
+ }
+
+ set_chord_outline (bounds, d);
+ }
+ while (flip (&d) != LEFT);
+}
+
+void
+Tie_formatting_problem::from_lv_ties (Link_array<Grob> const &lv_ties)
+{
+ if (lv_ties.is_empty ())
+ return ;
+
+ Link_array<Item> heads;
+ for (int i = 0; i < lv_ties.size (); i++)
+ {
+ Item *head = unsmob_item (lv_ties[i]->get_object ("note-head"));
+ heads.push (head);
+ }
+
+ x_refpoint_ = lv_ties [0];
+ for (int i = 0; i < lv_ties.size (); i++)
+ {
+ x_refpoint_ = lv_ties[i]->common_refpoint (x_refpoint_, X_AXIS);
+ }
+
+ set_chord_outline (heads, LEFT);
+
+ Real right_most = - infinity_f;
+
+ for (int i = 0; i < chord_outlines_[LEFT].size (); i++)
+ {
+ right_most = max (right_most, chord_outlines_[LEFT][i].height_);
+ }
+
+ Skyline_entry right_entry;
+ right_entry.width_.set_full ();
+ right_entry.height_ = right_most + 1.5;
+
+ chord_outlines_[RIGHT].push (right_entry);
+}
#include "note-head.hh"
#include "tie-column.hh"
#include "grob-array.hh"
+#include "tie-formatting-problem.hh"
+
int
Tie::compare (Grob *const &s1,
return attachments;
}
-
-Interval
-get_skyline_attachment (Drul_array< Array < Skyline_entry > > const &skylines,
- Real y)
-{
- Interval attachments;
- Direction d = LEFT;
- do
- {
- attachments[d] = skyline_height (skylines[d], y, -d);
- }
- while (flip (&d) != LEFT);
-
- return attachments;
-}
void
-Tie::get_configuration (Grob *me_grob, Grob *common,
+Tie::get_configuration (Grob *me_grob,
Tie_configuration *conf,
- Drul_array< Array < Skyline_entry > > const *skylines,
+ Tie_formatting_problem const &problem,
Tie_details const &details
)
{
if (conf->attachment_x_.is_empty())
{
+#if 0
if (!skylines)
conf->attachment_x_ = get_default_attachments (me, common, gap,
&conf->position_,
&in_between, details);
- else
- {
- Real y = staff_space * 0.5 * conf->position_;
- conf->attachment_x_ = get_skyline_attachment (*skylines, y);
- conf->attachment_x_.widen (-gap);
- }
+#endif
+ Real y = staff_space * 0.5 * conf->position_;
+ conf->attachment_x_ = problem.get_attachment (y);
+ conf->attachment_x_.widen (-gap);
}
Bezier b = slur_shape (conf->attachment_x_.length(),
in_space = !in_space;
}
- if (skylines)
- {
- Real y = staff_space * 0.5 * conf->position_;
- conf->attachment_x_ = get_skyline_attachment (*skylines, y);
- conf->attachment_x_.widen (-gap);
- Bezier b = slur_shape (conf->attachment_x_.length(),
- details.height_limit_,
- details.ratio_);
- Offset middle = b.curve_point (0.5);
- Offset edge = b.curve_point (0.0);
- dy = fabs (middle[Y_AXIS] - edge[Y_AXIS]);
- fits_in_space =
- (dy < 0.6 * staff_space);
- }
+ Real y = staff_space * 0.5 * conf->position_;
+ conf->attachment_x_ = problem.get_attachment (y);
+ conf->attachment_x_.widen (-gap);
+ Bezier b = slur_shape (conf->attachment_x_.length(),
+ details.height_limit_,
+ details.ratio_);
+ Offset middle = b.curve_point (0.5);
+ Offset edge = b.curve_point (0.0);
+ dy = fabs (middle[Y_AXIS] - edge[Y_AXIS]);
+ fits_in_space =
+ (dy < 0.6 * staff_space);
}
/*
/*
ugh: code dup.
- */
- if (skylines)
- {
- Real y = staff_space * 0.5 * conf->position_;
- conf->attachment_x_ = get_skyline_attachment (*skylines, y);
- conf->attachment_x_.widen (-gap);
+ */
+ Real y = staff_space * 0.5 * conf->position_;
+ conf->attachment_x_ = problem.get_attachment (y);
+ conf->attachment_x_.widen (-gap);
- Bezier b = slur_shape (conf->attachment_x_.length(),
- details.height_limit_,
- details.ratio_);
- Offset middle = b.curve_point (0.5);
- Offset edge = b.curve_point (0.0);
- dy = fabs (middle[Y_AXIS] - edge[Y_AXIS]);
- fits_in_space =
- (dy < 0.6 * staff_space);
- }
+ Bezier b = slur_shape (conf->attachment_x_.length(),
+ details.height_limit_,
+ details.ratio_);
+ Offset middle = b.curve_point (0.5);
+ Offset edge = b.curve_point (0.0);
+ dy = fabs (middle[Y_AXIS] - edge[Y_AXIS]);
+ fits_in_space =
+ (dy < 0.6 * staff_space);
}
}
- if (skylines)
- {
- Real half_space = 0.5 * staff_space;
- Real y = conf->position_ * half_space;
+ Real half_space = 0.5 * staff_space;
+ Real y = conf->position_ * half_space;
- conf->attachment_x_ = get_skyline_attachment (*skylines, y);
- conf->attachment_x_.widen (-gap);
- }
+ conf->attachment_x_ = problem.get_attachment (y);
+ conf->attachment_x_.widen (-gap);
}
Tie_details details;
details.init (me);
- get_configuration (me, common, &conf, 0, details);
- set_control_points (me, common, conf, details);
+
+ Tie_formatting_problem problem;
+ problem.from_tie (me);
+
+ get_configuration (me, &conf, problem, details);
+ set_control_points (me, problem.common_x_refpoint (),
+ conf, details);
}
void