]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/tie-formatting-problem.cc
Issue 4550 (2/2) Avoid "using namespace std;" in included files
[lilypond.git] / lily / tie-formatting-problem.cc
index 304e4b3b2ad0d06e62ce2ea2598c1334f6d9169d..d4a7be2cfb7cbab6117edceaf08c63ff3ed7667b 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 2005--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 2005--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
 
   LilyPond is free software: you can redistribute it and/or modify
@@ -29,6 +29,7 @@
 #include "misc.hh"
 #include "note-head.hh"
 #include "rhythmic-head.hh"
+#include "semi-tie.hh"
 #include "spanner.hh"
 #include "staff-symbol-referencer.hh"
 #include "stem.hh"
 #include "pointer-group-interface.hh"
 #include "output-def.hh"
 
+using std::set;
+using std::string;
+using std::vector;
+
 void
 Tie_formatting_problem::print_ties_configuration (Ties_configuration const *ties)
 {
@@ -98,11 +103,11 @@ Tie_formatting_problem::set_column_chord_outline (vector<Item *> bounds,
   for (vsize i = 0; i < bounds.size (); i++)
     {
       Grob *head = bounds[i];
-      if (!Note_head::has_interface (head))
+      if (!has_interface<Note_head> (head))
         continue;
 
       if (!stem)
-        stem = unsmob_grob (head->get_object ("stem"));
+        stem = unsmob<Grob> (head->get_object ("stem"));
 
       Real p = Staff_symbol_referencer::get_position (head);
       Interval y ((p - 1) * 0.5 * staff_space,
@@ -151,7 +156,7 @@ Tie_formatting_problem::set_column_chord_outline (vector<Item *> bounds,
                 stem_end_position = stem->extent (stem, Y_AXIS)[get_grob_direction (stem)];
               else
                 // May want to change this to the stem's pure height...
-                stem_end_position = Stem::note_head_positions (stem)[get_grob_direction (stem)]
+                stem_end_position = Stem::head_positions (stem)[get_grob_direction (stem)]
                                     * staff_space * .5;
             }
 
@@ -211,9 +216,9 @@ Tie_formatting_problem::set_column_chord_outline (vector<Item *> bounds,
               boxes.push_back (Box (x, y));
             }
 
-          Grob *acc = unsmob_grob (heads[i]->get_object ("accidental-grob"));
+          Grob *acc = unsmob<Grob> (heads[i]->get_object ("accidental-grob"));
           if (acc)
-            acc->get_property ("stencil"); /* trigger tie-related suicide */
+            acc->get_property ("after-line-breaking"); /* trigger tie-related suicide */
 
           if (acc && acc->is_live () && dir == RIGHT)
             {
@@ -279,7 +284,7 @@ Tie_formatting_problem::set_chord_outline (vector<Item *> bounds,
   for (vsize i = 0; i < bounds.size (); i++)
     ranks.push_back (bounds[i]->get_column ()->get_rank ());
 
-  vector_sort (ranks, less<int> ());
+  vector_sort (ranks, std::less<int> ());
   uniq (ranks);
 
   for (vsize i = 0; i < ranks.size (); i++)
@@ -342,7 +347,8 @@ Tie_formatting_problem::from_ties (vector<Grob *> const &ties)
 
       for (vsize i = 0; i < ties.size (); i++)
         {
-          Item *it = dynamic_cast<Spanner *> (ties[i])->get_bound (d);
+          Spanner *tie = dynamic_cast<Spanner *> (ties[i]);
+          Item *it = tie->get_bound (d);
           if (it->break_status_dir ())
             it = it->get_column ();
 
@@ -354,13 +360,14 @@ Tie_formatting_problem::from_ties (vector<Grob *> const &ties)
 
   for (vsize i = 0; i < ties.size (); i++)
     {
+      Spanner *tie = dynamic_cast<Spanner *> (ties[i]);
       Tie_specification spec;
-      spec.from_grob (ties[i]);
+      spec.from_grob (tie);
 
       for (LEFT_and_RIGHT (d))
         {
-          spec.note_head_drul_[d] = Tie::head (ties[i], d);
-          spec.column_ranks_[d] = Tie::get_column_rank (ties[i], d);
+          spec.note_head_drul_[d] = Tie::head (tie, d);
+          spec.column_ranks_[d] = Tie::get_column_rank (tie, d);
         }
       specifications_.push_back (spec);
     }
@@ -379,8 +386,9 @@ Tie_formatting_problem::from_semi_ties (vector<Grob *> const &semi_ties, Directi
   int column_rank = -1;
   for (vsize i = 0; i < semi_ties.size (); i++)
     {
+      Item *semi_tie = dynamic_cast<Item *> (semi_ties[i]);
       Tie_specification spec;
-      Item *head = unsmob_item (semi_ties[i]->get_object ("note-head"));
+      Item *head = Semi_tie::head (semi_tie);
 
       if (!head)
         programming_error ("LV tie without head?!");
@@ -390,10 +398,10 @@ Tie_formatting_problem::from_semi_ties (vector<Grob *> const &semi_ties, Directi
           spec.position_ = int (Staff_symbol_referencer::get_position (head));
         }
 
-      spec.from_grob (semi_ties[i]);
+      spec.from_grob (semi_tie);
 
       spec.note_head_drul_[head_dir] = head;
-      column_rank = Tie::get_column_rank (semi_ties[i], head_dir);
+      column_rank = Semi_tie::get_column_rank (semi_tie);
       spec.column_ranks_ = Drul_array<int> (column_rank, column_rank);
       heads.push_back (head);
       specifications_.push_back (spec);
@@ -473,7 +481,7 @@ Tie_formatting_problem::generate_configuration (int pos, Direction dir,
     }
 
   if (y_tune
-      && max (fabs (get_head_extent (columns[LEFT], LEFT, Y_AXIS)[dir] - y),
+      && std::max (fabs (get_head_extent (columns[LEFT], LEFT, Y_AXIS)[dir] - y),
               fabs (get_head_extent (columns[RIGHT], RIGHT, Y_AXIS)[dir] - y)) < 0.25
       && !Staff_symbol_referencer::on_line (details_.staff_symbol_referencer_, pos))
     {
@@ -569,7 +577,7 @@ Tie_formatting_problem::generate_configuration (int pos, Direction dir,
             continue;
 
           conf->attachment_x_[d]
-            = d * min (d * conf->attachment_x_[d],
+            = d * std::min (d * conf->attachment_x_[d],
                        d * (get_stem_extent (conf->column_ranks_[d], d, X_AXIS)[-d] - d * details_.stem_gap_));
         }
     }
@@ -617,7 +625,7 @@ Tie_formatting_problem::score_aptitude (Tie_configuration *conf,
     }
 
   {
-    Real relevant_dist = max (fabs (curve_y - tie_y) - 0.5, 0.0);
+    Real relevant_dist = std::max (fabs (curve_y - tie_y) - 0.5, 0.0);
     Real p = details_.vertical_distance_penalty_factor_ * convex_amplifier (1.0, 0.9, relevant_dist);
     if (ties_conf)
       ties_conf->add_tie_score (p, tie_idx, "vdist");
@@ -655,7 +663,7 @@ Tie_formatting_problem::score_aptitude (Tie_configuration *conf,
           if (!spec.note_head_drul_[d])
             continue;
 
-          Grob *stem = unsmob_grob (spec.note_head_drul_[d]->get_object ("stem"));
+          Grob *stem = unsmob<Grob> (spec.note_head_drul_[d]->get_object ("stem"));
           if (stem
               && Stem::is_normal_stem (stem))
             stems[d] = stem;
@@ -1200,7 +1208,8 @@ Tie_formatting_problem::set_manual_tie_configuration (SCM manual_configs)
             {
               spec.has_manual_position_ = true;
               spec.manual_position_ = scm_to_double (scm_car (entry));
-              spec.has_manual_delta_y_ = (scm_inexact_p (scm_car (entry)) == SCM_BOOL_T);
+              /* TODO: check whether inexact? is an appropriate condition here */
+              spec.has_manual_delta_y_ = (scm_is_true (scm_inexact_p (scm_car (entry))));
             }
 
           if (scm_is_number (scm_cdr (entry)))