X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fgourlay-breaking.cc;h=ac250e9684a96c6dd382d373fa0a0c75c1715ed2;hb=71cc3b4a5adf79c361d2af39f1a361a36a03f273;hp=86914fcd0eab394751b69378dad3e74a73fa4e7d;hpb=5f68ba5ca0edd64f0f6723e65c27993c2dfb1e96;p=lilypond.git diff --git a/lily/gourlay-breaking.cc b/lily/gourlay-breaking.cc index 86914fcd0e..ac250e9684 100644 --- a/lily/gourlay-breaking.cc +++ b/lily/gourlay-breaking.cc @@ -3,18 +3,19 @@ source file of the GNU LilyPond music typesetter - (c) 1997--2001 Han-Wen Nienhuys + (c) 1997--2002 Han-Wen Nienhuys */ #include // rint #include "gourlay-breaking.hh" #include "column-x-positions.hh" -#include "debug.hh" +#include "warn.hh" +#include "main.hh" #include "paper-column.hh" #include "paper-score.hh" #include "paper-def.hh" #include "simple-spacer.hh" -#include "line-of-score.hh" +#include "system.hh" /// How often to print operator pacification marks? const int HAPPY_DOTS_I = 3; @@ -64,7 +65,7 @@ Gourlay_breaking::do_solve () const Real worst_force = 0.0; - for ( int break_idx=1; break_idx< breaks.size (); break_idx++) + for (int break_idx=1; break_idx< breaks.size (); break_idx++) { /* start with a short line, add measures. At some point @@ -76,6 +77,8 @@ Gourlay_breaking::do_solve () const Real minimal_demerits = infinity_f; + bool ragged = to_boolean (pscore_l_->paper_l_->get_scmvar ("raggedright")); + for (int start_idx = break_idx; start_idx--;) { Link_array line = all.slice (breaks[start_idx], breaks[break_idx]+1); @@ -89,7 +92,7 @@ Gourlay_breaking::do_solve () const Interval line_dims = pscore_l_->paper_l_->line_dimensions_int (optimal_paths[start_idx].line_i_); Simple_spacer * sp = generate_spacing_problem (line, line_dims); - sp->solve (&cp); + sp->solve (&cp, ragged); delete sp; if (fabs (cp.force_f_) > worst_force) @@ -187,6 +190,10 @@ Gourlay_breaking::Gourlay_breaking () /* TODO: uniformity parameter to control rel. importance of spacing differences. + + TODO: + + mixing break penalties and constraint-failing solutions is confusing. */ Real Gourlay_breaking::combine_demerits (Column_x_positions const &prev, @@ -197,24 +204,33 @@ Gourlay_breaking::combine_demerits (Column_x_positions const &prev, if (pc->original_l_) { SCM pen = pc->get_grob_property ("penalty"); - if (gh_number_p (pen)) + if (gh_number_p (pen) && fabs (gh_scm2double (pen)) < 10000) { break_penalties += gh_scm2double (pen); } } - Real demerit = abs (this_one.force_f_) + abs (prev.force_f_ - this_one.force_f_) +#if 1 + /* + Q: do want globally non-cramped lines, or locally equally cramped lines. + */ + Real demerit = abs (this_one.force_f_) + 0.1 *abs (prev.force_f_ - this_one.force_f_) + break_penalties; - +#else + Real demerit = abs (this_one.force_f_) + break_penalties; +#endif if (!this_one.satisfies_constraints_b_) { /* If it doesn't satisfy constraints, we make this one really unattractive. - */ - demerit += 10; - demerit *= 100; + + add 20000 to the demerits, so that a break penalty + of -10000 won't change the result */ + demerit = (demerit + 20000) >? 2000; + + demerit *= 10; } return demerit;