#include "slur-scoring.hh"
-#include "libc-extension.hh"
-#include "slur-configuration.hh"
+
+#include "accidental-interface.hh"
#include "beam.hh"
#include "directional-element-interface.hh"
-#include "pointer-group-interface.hh"
-#include "slur.hh"
+#include "libc-extension.hh"
+#include "main.hh"
#include "note-column.hh"
#include "output-def.hh"
+#include "paper-column.hh"
#include "pitch.hh"
+#include "pointer-group-interface.hh"
+#include "slur-configuration.hh"
+#include "slur.hh"
#include "spanner.hh"
#include "staff-symbol-referencer.hh"
#include "staff-symbol.hh"
#include "stem.hh"
#include "warn.hh"
-#include "paper-column.hh"
-#include "accidental-interface.hh"
/*
TODO:
junk_pointers (configurations_);
}
-Real
-get_detail (SCM alist, SCM sym)
-{
- SCM entry = scm_assq (sym, alist);
- return robust_scm2double (scm_is_pair (entry)
- ? scm_cdr (entry)
- : SCM_EOL,
- 0.0);
-}
-
-void
-Slur_score_parameters::fill (Grob *me)
-{
- SCM details = me->get_property ("details");
-
- region_size_
- = (int) get_detail (details, ly_symbol2scm ("region-size"));
- head_encompass_penalty_
- = get_detail (details, ly_symbol2scm ("head-encompass-penalty"));
- stem_encompass_penalty_
- = get_detail (details, ly_symbol2scm ("stem-encompass-penalty"));
- closeness_factor_
- = get_detail (details, ly_symbol2scm ("closeness-factor"));
- edge_attraction_factor_
- = get_detail (details, ly_symbol2scm ("edge-attraction-factor"));
- same_slope_penalty_
- = get_detail (details, ly_symbol2scm ("same-slope-penalty"));
- steeper_slope_factor_
- = get_detail (details, ly_symbol2scm ("steeper-slope-factor"));
- non_horizontal_penalty_
- = get_detail (details, ly_symbol2scm ("non-horizontal-penalty"));
- max_slope_
- = get_detail (details, ly_symbol2scm ("max-slope"));
- max_slope_factor_
- = get_detail (details, ly_symbol2scm ("max-slope-factor"));
- free_head_distance_
- = get_detail (details, ly_symbol2scm ("free-head-distance"));
- absolute_closeness_measure_
- = get_detail (details, ly_symbol2scm ("absolute-closeness-measure"));
- extra_object_collision_penalty_
- = get_detail (details, ly_symbol2scm ("extra-object-collision-penalty"));
- accidental_collision_
- = get_detail (details, ly_symbol2scm ("accidental-collision"));
- extra_encompass_free_distance_
- = get_detail (details, ly_symbol2scm ("extra-encompass-free-distance"));
- head_slur_distance_factor_
- = get_detail (details, ly_symbol2scm ("head-slur-distance-factor"));
- head_slur_distance_max_ratio_
- = get_detail (details, ly_symbol2scm ("head-slur-distance-max-ratio"));
- free_slur_distance_
- = get_detail (details, ly_symbol2scm ("free-slur-distance"));
- edge_slope_exponent_
- = get_detail (details, ly_symbol2scm ("edge-slope-exponent"));
-}
-
Real
broken_trend_y (Slur_score_state const &state, Direction hdir)
{
{
vsize k = broken_spanner_index (state.slur_);
int j = int (k) + hdir;
- if (j < 0 || j >= mother->broken_intos_.size ())
+ if (j < 0 || vsize (j) >= mother->broken_intos_.size ())
return by;
Grob *neighbor = mother->broken_intos_[j];
= broken_spanner_index (dynamic_cast<Spanner *> (state.common_[Y_AXIS]));
int common_j = common_k + hdir;
- if (common_j < 0 || common_j >= common_mother->broken_intos_.size ())
+ if (common_j < 0 || vsize (common_j) >= common_mother->broken_intos_.size ())
return by;
Grob *common_next_system = common_mother->broken_intos_[common_j];
if (Spanner *mother = dynamic_cast<Spanner *> (slur_->original ()))
{
- vsize k = broken_spanner_index (slur_);
- vsize j = k + 1;
- if (j < 0 || j >= mother->broken_intos_.size ())
+ vsize j = 1 + broken_spanner_index (slur_);
+ if (j >= mother->broken_intos_.size ())
return;
Grob *neighbor = mother->broken_intos_[j];
Real opt = 1e6;
#if DEBUG_SLUR_SCORING
+ bool debug_slurs = to_boolean (slur_->layout ()
+ ->lookup_variable (ly_symbol2scm ("debug-slur-scoring")));
SCM inspect_quants = slur_->get_property ("inspect-quants");
- if (to_boolean (slur_->layout ()
- ->lookup_variable (ly_symbol2scm ("debug-slur-scoring")))
- && scm_is_pair (inspect_quants))
+ SCM inspect_index = slur_->get_property ("inspect-index");
+ if (debug_slurs
+ && scm_is_integer (inspect_index))
+ {
+ opt_idx = scm_to_int (inspect_index);
+ configurations_[opt_idx]->calculate_score (*this);
+ opt = configurations_[opt_idx]->score ();
+ }
+ else if (debug_slurs
+ && scm_is_pair (inspect_quants))
{
opt_idx = get_closest_index (inspect_quants);
- configurations_[opt_idx]->score (*this);
- opt = configurations_[opt_idx]->score_;
+ configurations_[opt_idx]->calculate_score (*this);
+ opt = configurations_[opt_idx]->score ();
}
else
#endif
{
for (vsize i = 0; i < configurations_.size (); i++)
- configurations_[i]->score (*this);
+ configurations_[i]->calculate_score (*this);
for (vsize i = 0; i < configurations_.size (); i++)
{
- if (configurations_[i]->score_ < opt)
+ if (configurations_[i]->score () < opt)
{
- opt = configurations_[i]->score_;
+ opt = configurations_[i]->score ();
opt_idx = i;
}
}
}
#if DEBUG_SLUR_SCORING
- if (opt_idx >= 0)
+ if (debug_slurs)
{
- configurations_[opt_idx]->score_card_ += to_string ("=%.2f", opt);
- configurations_[opt_idx]->score_card_ += to_string ("i%d", opt_idx);
+ string total;
+ if (opt_idx >= 0)
+ {
+ total = configurations_[opt_idx]->card ();
+ total += to_string (" TOTAL=%.2f idx=%d", configurations_[opt_idx]->score (), opt_idx);
+ }
+ else
+ {
+ total = "no sol?";
+ }
+
+ slur_->set_property ("quant-score",
+ scm_makfrom0str (total.c_str ()));
}
- else
+#endif
+
+ if (opt_idx < 0)
{
- programming_error ("No optimal slur found. Guessing 0.");
opt_idx = 0;
+ programming_error ("No optimal slur found. Guessing 0.");
}
- // debug quanting
- slur_->set_property ("quant-score",
- scm_makfrom0str (configurations_[opt_idx]->score_card_.c_str ()));
+ return configurations_[opt_idx]->curve_;
+}
-#endif
+Grob *
+Slur_score_state::breakable_bound_item (Direction d) const
+{
+ Grob *col = slur_->get_bound (d)->get_column ();
- return configurations_[opt_idx]->curve_;
+ extract_grob_set (slur_, "encompass-objects", extra_encompasses);
+
+ for (vsize i = 0; i < extra_encompasses.size (); i++)
+ {
+ Item *item = dynamic_cast<Item*> (extra_encompasses[i]);
+ if (item && col == item->get_column ())
+ return item;
+ }
+
+ return 0;
}
int
{
end_ys[d] = dir_
* max (max (dir_ * (base_attachments_[d][Y_AXIS]
- + parameters_.region_size_ * dir_),
+ + parameters_.region_size_ * dir_),
dir_ * (dir_ + extremes_[d].note_column_->extent (common_[Y_AXIS], Y_AXIS)[dir_])),
dir_ * base_attachments_[-d][Y_AXIS]);
}
{
if (!extremes_[d].note_column_)
{
- Real x, y;
- if (d == RIGHT)
+ Real x = 0;
+ Real y = 0;
+
+ if (Grob *g = breakable_bound_item (d))
+ {
+ x = robust_relative_extent (g, common_[X_AXIS], X_AXIS)[RIGHT];
+ }
+ else if (d == RIGHT)
x = robust_relative_extent (extremes_[d].bound_, common_[X_AXIS], X_AXIS)[d];
else
x = slur_->get_broken_left_end_align ();
+
Grob *col = (d == LEFT) ? columns_[0] : columns_.back ();
if (extremes_[-d].bound_ != col)
for (int k = 0; k < 3; k++)
{
- Direction hdir = Direction (k / 2 - 1);
+ Direction hdir = Direction (k - 1);
/*
Only take bound into account if small slur starts
Interval xext (-1, 1);
xext = xext * (thickness_ * 2) + z[X_AXIS];
Extra_collision_info info (small_slur,
- k - 1.0,
+ hdir,
xext,
yext,
parameters_.extra_object_collision_penalty_);