- Direction position_dir = (Direction) sign (tie_configs[i].position_);
- if (!position_dir)
- position_dir = DOWN;
-
- tie_configs[i].dir_ = position_dir;
- }
-
- 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_details details;
- details.init (ties[0]);
-
- /*
- Let the ties flow out, according to our single-tie formatting.
- */
- 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,
- details
- );
- }
-
- /*
- Calculate final width and shape of the ties.
- */
- Real staff_space = Staff_symbol_referencer::staff_space (ties[0]);
- Real gap = robust_scm2double (ties[0]->get_property ("x-gap"), 0.2);
- for (int i = 0; i < ties.size(); i++)
- {
- if (!manual_override
- && (i == 0 || i == ties.size () -1))
- continue;
-
- Tie_configuration conf = tie_configs[i];
- conf = tie_configs[i];
-
- Real line_dy = 0.0;
- bool on_line = Staff_symbol_referencer::on_staffline (ties[0],
- int (rint (conf.position_)));
- if (on_line)
- line_dy = - sign (conf.height (details) - 0.6 * staff_space)
- * 0.2 * staff_space * conf.dir_;
-
- Real y = conf.position_ * 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_ * staff_space * .5));
-
-
- conf.delta_y_ += line_dy;
- conf.attachment_x_.widen (-gap);
- if (!on_line
- && Staff_symbol_referencer::staff_radius (ties[0]) * staff_space > y)
- conf.center_tie_vertically (details);
-
- tie_configs[i] = conf;
- }
-
- /*
- Try to shift small ties into available spaces.
- */
- if (!manual_override)
- {
- set<int> positions_taken;
- for (int i = 0; i < tie_configs.size (); i++)
- positions_taken.insert (int (rint (tie_configs[i].position_)));
-
- for (int i = 0; i < tie_configs.size (); i++)
- {
- Tie_configuration * conf = &tie_configs.elem_ref (i);
-
- /*
- on staff line and small enough, translate a little further
- */
- Real h = conf->height (details);
- bool next_free = positions_taken.find (int (rint (conf->position_ + conf->dir_)))
- == positions_taken.end ();
- bool on_line = Staff_symbol_referencer::on_staffline (ties[0],
- int (rint (conf->position_ + conf->delta_y_)));
- if (next_free)
- if (on_line && h < 0.4 * staff_space)
- {
- positions_taken.insert (int (rint (conf->position_ + conf->dir_)));
- conf->delta_y_ += 0.2 * staff_space * conf->dir_;
- }
- else if (!on_line && h > 0.6 * staff_space)
- {
- positions_taken.insert (int (rint (conf->position_ + conf->dir_)));
- conf->delta_y_ += 0.5 * staff_space * conf->dir_;
- }
- }
- }
-
- for (int i = 0; i < ties.size(); i++)
- {
- Tie::set_control_points (ties[i], common, tie_configs[i],
- details
- );
- set_grob_direction (ties[i], tie_configs[i].dir_);