]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/gourlay-breaking.cc
* The grand 2005-2006 replace.
[lilypond.git] / lily / gourlay-breaking.cc
index dc6649dfb279467eed33d67a3fa5308890bd118a..df64d3e171f5a6a7ae02fc6f1898ed911270cc49 100644 (file)
@@ -3,13 +3,14 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
 #include "gourlay-breaking.hh"
 
-#include <math.h>              // rint
+#include <cmath>               // rint
 #include <cstdio>
+using namespace std;
 
 #include "warn.hh"
 #include "main.hh"
@@ -77,15 +78,15 @@ Gourlay_breaking::do_solve () const
 {
   Array<Break_node> optimal_paths;
   Link_array<Grob> all
-    = pscore_->system_->columns ();
+    = pscore_->root_system ()->columns ();
 
   Array<int> breaks = find_break_indices ();
 
   Break_node first_node;
   optimal_paths.push (first_node);
 
-  bool ragged_right = to_boolean (pscore_->layout_->c_variable ("raggedright"));
-  bool ragged_last = to_boolean (pscore_->layout_->c_variable ("raggedlast"));
+  bool ragged_right = to_boolean (pscore_->layout ()->c_variable ("raggedright"));
+  bool ragged_last = to_boolean (pscore_->layout ()->c_variable ("raggedlast"));
 
   Real worst_force = 0.0;
   for (int break_idx = 1; break_idx < breaks.size (); break_idx++)
@@ -111,7 +112,7 @@ Gourlay_breaking::do_solve () const
          cp.cols_ = line;
 
          Interval line_dims
-           = line_dimensions_int (pscore_->layout_, optimal_paths[start_idx].line_);
+           = line_dimensions_int (pscore_->layout (), optimal_paths[start_idx].line_);
          Simple_spacer_wrapper *sp = generate_spacing_problem (line, line_dims);
          bool last_line = break_idx == breaks.size () - 1;
          bool ragged = ragged_right
@@ -196,12 +197,12 @@ Gourlay_breaking::do_solve () const
 
   if (be_verbose_global)
     {
-      progress_indication (_f ("Optimal demerits: %f",
-                              optimal_paths.top ().demerits_) + "\n");
+      message (_f ("Optimal demerits: %f",
+                  optimal_paths.top ().demerits_) + "\n");
     }
 
   if (optimal_paths.top ().demerits_ >= infinity_f)
-    warning (_ ("No feasible line breaking found"));
+    warning (_ ("no feasible line breaking found"));
 
   for (int i = final_breaks.size (); i--;)
     {
@@ -209,7 +210,7 @@ Gourlay_breaking::do_solve () const
 
       lines.push (cp);
       if (!cp.satisfies_constraints_)
-       warning ("Could not find line breaking that satisfies constraints.");
+       warning (_ ("can't find line breaking that satisfies constraints"));
     }
   return lines;
 }
@@ -231,13 +232,11 @@ Gourlay_breaking::combine_demerits (Column_x_positions const &prev,
 {
   Real break_penalties = 0.0;
   Grob *pc = this_one.cols_.top ();
-  if (pc->original_)
+  if (pc->original ())
     {
       SCM pen = pc->get_property ("penalty");
       if (scm_is_number (pen) && fabs (scm_to_double (pen)) < 10000)
-       {
-         break_penalties += scm_to_double (pen);
-       }
+       break_penalties += scm_to_double (pen);
     }
 
   /*
@@ -263,7 +262,7 @@ Gourlay_breaking::combine_demerits (Column_x_positions const &prev,
 
        add 20000 to the demerits, so that a break penalty
        of -10000 won't change the result */
-      demerit = (demerit + 20000) >? 2000;
+      demerit = max ((demerit + 20000), 2000.0);
 
       demerit *= 10;
     }