#include "main.hh"
#include "paper-column.hh"
#include "paper-score.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
#include "simple-spacer.hh"
#include "system.hh"
This algorithms is adapted from the OSU Tech report on breaking lines.
this function is longish, but not very complicated.
-
*/
Array<Column_x_positions>
Gourlay_breaking::do_solve () const
Break_node first_node ;
optimal_paths.push (first_node);
+ bool ragged_right = to_boolean (pscore_->paper_->c_variable ("raggedright"));
+ bool ragged_last = to_boolean (pscore_->paper_->c_variable ("raggedlast"));
+
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
Real minimal_demerits = infinity_f;
- bool ragged = to_boolean (pscore_->paper_->get_scmvar ("raggedright"));
-
for (int start_idx = break_idx; start_idx--;)
{
Link_array<Grob> line = all.slice (breaks[start_idx], breaks[break_idx]+1);
- line[0] = dynamic_cast<Item*> (line[0]) ->find_prebroken_piece (RIGHT);
+ line[0] = dynamic_cast<Item*> (line[0])->find_prebroken_piece (RIGHT);
line.top () = dynamic_cast<Item*> (line.top ())->find_prebroken_piece (LEFT);
Column_x_positions cp;
cp.cols_ = line;
Interval line_dims
- = pscore_->paper_->line_dimensions_int (optimal_paths[start_idx].line_);
+ = line_dimensions_int (pscore_->paper_, optimal_paths[start_idx].line_);
Simple_spacer * sp = generate_spacing_problem (line, line_dims);
+ bool last_line = break_idx == breaks.size ()-1;
+ bool ragged = ragged_right
+ || (last_line && ragged_last);
+
sp->solve (&cp, ragged);
+
delete sp;
+ if (ragged && last_line)
+ cp.force_ = 0.0;
+
if (fabs (cp.force_) > worst_force)
worst_force = fabs (cp.force_);
/* do the last one */
if (breaks.size () % HAPPY_DOTS_I)
- progress_indication (String ("[") + to_string (breaks.size()) + "]");
+ progress_indication (String ("[") + to_string (breaks.size ()) + "]");
progress_indication ("\n");
Column_x_positions cp (optimal_paths[final_breaks[i]].line_config_);
lines.push (cp);
- if(!cp.satisfies_constraints_)
+ if (!cp.satisfies_constraints_)
warning ("Could not find line breaking that satisfies constraints.");
}
return lines;
Grob * pc = this_one.cols_.top ();
if (pc->original_)
{
- SCM pen = pc->get_grob_property ("penalty");
- if (gh_number_p (pen) && fabs (gh_scm2double (pen)) < 10000)
+ SCM pen = pc->get_property ("penalty");
+ if (ly_c_number_p (pen) && fabs (ly_scm2double (pen)) < 10000)
{
- break_penalties += gh_scm2double (pen);
+ break_penalties += ly_scm2double (pen);
}
}