]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/line-of-score.cc
release: 1.2.9
[lilypond.git] / lily / line-of-score.cc
index 9d563be580885368a300c3632f12745926c7a13e..b648ea10c5822d970c494206671ddf54b9ff2e00 100644 (file)
@@ -7,27 +7,15 @@
 */
 
 #include "line-of-score.hh"
-#include "spanner.hh"
-
 #include "paper-def.hh"
-#include "p-col.hh"
-#include "p-score.hh"
-
+#include "paper-outputter.hh"
+#include "paper-column.hh"
+#include "paper-score.hh"
+#include "warn.hh"
 
 Line_of_score::Line_of_score()
 {
-  error_mark_b_ = 0;
-}
-
-
-
-
-void
-Line_of_score::add_element (Score_element*e)
-{
-  // avoid excess dependencies.
-  if (! (e->parent_l (X_AXIS) || e->parent_l (Y_AXIS)) )
-    add_dependency (e);
+  set_axes (Y_AXIS,X_AXIS);
 }
 
 bool
@@ -36,77 +24,80 @@ Line_of_score::contains_b (Paper_column const* c) const
   return cols_.find_l ((Paper_column*)(c));
 }
 
+// const?
 Line_of_score*
-Line_of_score::set_breaking (Array<Column_x_positions> const &breaking, int j) const
+Line_of_score::set_breaking (Array<Column_x_positions> const &breaking, int j) 
 {
-  const Link_array<Paper_column> &curline (breaking[j].cols);
-  const Link_array<Paper_column> &errors (breaking[j].error_col_l_arr_);
-  const Array<Real> &config (breaking[j].config);
-       
-  for (int i=0; i < errors.size(); i++)
-    errors[i]->error_mark_b_ = true;
-
+  const Link_array<Paper_column> &curline (breaking[j].cols_);
+  const Array<Real> &config (breaking[j].config_);
   Line_of_score *line_l=0;
-       
-  if (breaking.size() >1) 
-    {
-      line_l = dynamic_cast <Line_of_score*> (clone());
-    }
-  else 
-    line_l = (Line_of_score*)( this);
 
+  line_l = dynamic_cast <Line_of_score*> (clone());
+  line_l->rank_i_ = j;
+  
   line_l->cols_ = curline;
-  /*  Array<Paper_column*> &
-      ((Array<Paper_column*> &)) = */
   line_l->set_bounds(LEFT,curline[0]);
-      
   line_l->set_bounds(RIGHT,curline.top());
        
   for (int i=0; i < curline.size(); i++)
     {
       curline[i]->translate_axis (config[i],X_AXIS);
-      curline[i]->line_l_ = dynamic_cast<Line_of_score*>(line_l);
+      curline[i]->line_l_ = dynamic_cast<Line_of_score*> (line_l);
     }
 
+  broken_into_l_arr_.push (line_l);
   return line_l;
 }
 
-
-
+void
+Line_of_score::add_column (Paper_column*p)
+{
+  cols_.push (p);
+  add_element (p);
+}
 
 void
 Line_of_score::do_print() const
 {
   Spanner::do_print();
-}
-
-Interval
-Line_of_score::do_width() const
-{ 
-  return Spanner::do_width();
+  Axis_group_spanner::do_print ();
 }
 
 Link_array<Score_element>
 Line_of_score::get_extra_dependencies () const
 {
-  Link_array<Score_element> r;
+  Link_array<Score_element> r (Axis_group_spanner::get_extra_dependencies ());
   for (int i=0; i < cols_.size (); i++)
     r.push (cols_[i]);
   return r;
 }
 
 void
-Line_of_score::do_unlink () 
+Line_of_score::do_substitute_element_pointer (Score_element*o, Score_element*n)
 {
-  Spanner::do_unlink ();
-  for (int i=0; i < cols_.size (); i++)
-    cols_[i]->line_l_ =0;
-  cols_.set_size (0);
+  if (Paper_column *p = dynamic_cast<Paper_column*>(o))
+    cols_.substitute (p, dynamic_cast<Paper_column*>(n));
 }
 
-
 void
-Line_of_score::do_junk_links () 
+Line_of_score::output_all (bool last_line)
+{
+  Interval i(extent(Y_AXIS));
+  if (i.empty_b())
+    warning (_ ("Huh?  Empty Line_of_score?"));
+  else
+    translate_axis (- i[MAX], Y_AXIS);
+  
+  pscore_l_->outputter_l_->start_line (i.length ());
+  Super_element::output_all ();
+  if (last_line)
+    pscore_l_->outputter_l_->stop_last_line();
+  else
+    pscore_l_->outputter_l_->stop_line ();
+}
+
+int
+Line_of_score::compare (Line_of_score* const &p1,Line_of_score* const &p2)
 {
-  cols_.set_size (0);
+  return p1->rank_i_ - p2->rank_i_;
 }