]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/line-of-score.cc
release: 1.3.37
[lilypond.git] / lily / line-of-score.cc
index ac6c0a10bbf67b98c13fd25910e461dd9a1befe0..89d6de0dd42aed901ce63ee957d5bdd9bbbbfddb 100644 (file)
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1996,  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1996--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
+#include "axis-group-interface.hh"
+#include "debug.hh"
 #include "line-of-score.hh"
-#include "spanner.hh"
-
+#include "main.hh"
+#include "paper-column.hh"
 #include "paper-def.hh"
-#include "p-col.hh"
-#include "p-score.hh"
+#include "paper-outputter.hh"
+#include "paper-score.hh"
+#include "string.hh"
+#include "warn.hh"
 
 
 Line_of_score::Line_of_score()
 {
-  error_mark_b_ = 0;
+  set_elt_property ("columns", SCM_EOL);
+  Axis_group_interface (this).set_interface ();
+  Axis_group_interface (this).set_axes (Y_AXIS,X_AXIS);
 }
 
 
 
-
 void
-Line_of_score::add_element (Score_element*e)
+Line_of_score::output_lines ()
 {
-  // avoid excess dependencies.
-  if (! (e->parent_l (X_AXIS) || e->parent_l (Y_AXIS)) )
-    add_dependency (e);
-}
+  for (int i=0; i < broken_into_l_arr_.size (); i++)
+    {
+      Line_of_score *line_l = dynamic_cast<Line_of_score*> (broken_into_l_arr_[i]);
 
-bool
-Line_of_score::contains_b (Paper_column const* c) const
-{
-  return cols_.find_l ((Paper_column*)(c));
+      progress_indication ("[");
+      line_l->post_processing ();
+      progress_indication (to_str (i));
+      line_l->output_line (i + 1 == broken_into_l_arr_.size ());
+      progress_indication ("]");
+    }
 }
 
-Line_of_score*
-Line_of_score::set_breaking (Array<Column_x_positions> const &breaking, int j) const
+// const?
+void
+Line_of_score::break_into_pieces (Array<Column_x_positions> const &breaking)
 {
-  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;
-
-  Line_of_score *line_l=0;
-       
-  if (breaking.size() >1) 
+  for (int i=0; i < breaking.size (); i++)
     {
-      line_l = dynamic_cast <Line_of_score*> (clone());
-    }
-  else 
-    line_l = (Line_of_score*)( this);
-
-  line_l->cols_ = curline;
-  /*  Array<Paper_column*> &
-      ((Array<Paper_column*> &)) = */
-  line_l->set_bounds(LEFT,curline[0]);
+      Line_of_score *line_l = dynamic_cast <Line_of_score*> (clone());
+      line_l->rank_i_ = i;
+      Link_array<Paper_column> c (breaking[i].cols_);
+      pscore_l_->typeset_element (line_l);
+      line_l->set_bound(LEFT,c[0]);
+      line_l->set_bound(RIGHT,c.top ());
+      for (int j=0; j < c.size(); j++)
+       {
+         c[j]->translate_axis (breaking[i].config_[j],X_AXIS);
+         c[j]->line_l_ = line_l;
+       }
       
-  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);
+      broken_into_l_arr_.push (line_l);
     }
+}
+
+void
+Line_of_score::add_column (Paper_column*p)
+{
+  set_elt_property ("columns",
+                   gh_cons (p->self_scm_, get_elt_property ("columns")));
+  Axis_group_interface (this).add_element (p);
+}
+
+
+void
+Line_of_score::output_line (bool last_line)
+{
+  Interval i(extent(Y_AXIS));
+  if (i.empty_b())
+    programming_error ("Huh?  Empty Line_of_score?");
+  else
+    translate_axis (- i[MAX], Y_AXIS);
+  
+  pscore_l_->outputter_l_->start_line (i.length ());
+  output_all ();
+  if (last_line)
+    pscore_l_->outputter_l_->stop_last_line();
+  else
+    pscore_l_->outputter_l_->stop_line ();
+}
 
-  return line_l;
+int
+Line_of_score::compare (Line_of_score* const &p1,Line_of_score* const &p2)
+{
+  return p1->rank_i_ - p2->rank_i_;
 }
 
 
 
+/**
+    for administration of what was done already
+    */
+enum Score_element_status {
+  ORPHAN=0,                    // not yet added to pstaff
+  VIRGIN,                      // added to pstaff
+  PREBROKEN,
+  PREBROKEN_SECOND,
+  PRECALCING,
+  PRECALCED,           // calcs before spacing done
+  SPACING,
+  SPACED,
+  BROKEN,
+  BROKEN_SECOND,
+  POSTCALCING,         // busy calculating. This is used to trap cyclic deps.
+  POSTCALCED,          // after spacing calcs done
+  BREWING,
+  BREWED,
+};
 
 void
-Line_of_score::do_print() const
+Line_of_score::pre_processing ()
 {
-  Spanner::do_print();
+  calculate_dependencies (PRECALCED, PRECALCING, &Score_element::before_line_breaking);
 }
 
-Interval
-Line_of_score::do_width() const
-{ 
-  return Spanner::do_width();
+void
+Line_of_score::space_processing ()
+{
+  calculate_dependencies (SPACED, SPACING, &Score_element::do_space_processing);
 }
 
-Link_array<Score_element>
-Line_of_score::get_extra_dependencies () const
+/* for break processing, use only one status, because copies have to
+  have correct status. (Previously,
+  Score_element::handle_[pre]broken_dependencies assigned to status_i_
+  */
+void
+Line_of_score::breakable_col_processing ()
 {
-  Link_array<Score_element> r;
-  for (int i=0; i < cols_.size (); i++)
-    r.push (cols_[i]);
-  return r;
+  calculate_dependencies (PREBROKEN, PREBROKEN, &Score_element::do_breakable_col_processing);
+  //  calculate_dependencies (PREBROKEN_SECOND, PREBROKEN_SECOND, &Score_element::handle_prebroken_dependents);
 }
 
 
+void
+Line_of_score::post_processing ()
+{
+  //  calculate_dependencies (BROKEN_SECOND, BROKEN_SECOND,
+  //             &Score_element::handle_broken_dependents);
+  calculate_dependencies (POSTCALCED, POSTCALCING, &Score_element::after_line_breaking);
+}
+
+void
+Line_of_score::output_all () 
+{
+  calculate_dependencies (BREWED, BREWING, &Score_element::output_processing);
+}
+
+
+