]> git.donarmstrong.com Git - lilypond.git/blob - lily/line-of-score.cc
patch::: 1.3.9.hwn2
[lilypond.git] / lily / line-of-score.cc
1 /*
2   scoreline.cc -- implement Line_of_score
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1996,  1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "line-of-score.hh"
10 #include "paper-def.hh"
11 #include "paper-outputter.hh"
12 #include "paper-column.hh"
13 #include "paper-score.hh"
14 #include "warn.hh"
15 #include "main.hh"
16 #include "debug.hh"
17
18 Line_of_score::Line_of_score()
19 {
20   set_axes (Y_AXIS,X_AXIS);
21 }
22
23
24
25 void
26 Line_of_score::output_lines ()
27 {
28   for (int i=0; i < broken_into_l_arr_.size (); i++)
29     {
30       Line_of_score *line_l = dynamic_cast<Line_of_score*> (broken_into_l_arr_[i]);
31
32       *mlog << '[' << flush;
33       line_l->post_processing ();
34       *mlog << i << flush;
35       line_l->output_line (i + 1 == broken_into_l_arr_.size ());
36       *mlog << ']' << flush;
37     }
38 }
39
40 // const?
41 void
42 Line_of_score::break_into_pieces (Array<Column_x_positions> const &breaking)
43 {
44   for (int i=0; i < breaking.size (); i++)
45     {
46       Line_of_score *line_l = dynamic_cast <Line_of_score*> (clone());
47       line_l->rank_i_ = i;
48       Link_array<Paper_column> c (breaking[i].cols_);
49       pscore_l_->typeset_element (line_l);
50       line_l->set_bounds(LEFT,c[0]);
51       line_l->set_bounds(RIGHT,c.top ());
52       for (int j=0; j < c.size(); j++)
53         {
54           c[i]->translate_axis (breaking[i].config_[j],X_AXIS);
55           c[i]->line_l_ = line_l;
56         }
57       
58       broken_into_l_arr_.push (line_l);
59     }
60
61   for (int i=0; i < broken_into_l_arr_.size (); i++)
62     {
63       broken_into_l_arr_[i]->handle_broken_dependencies ();
64     }
65
66   handle_broken_dependencies ();
67 }
68
69 void
70 Line_of_score::add_column (Paper_column*p)
71 {
72   set_elt_property ("columns",
73                     gh_cons (p->self_scm_, get_elt_property ("columns")));
74   add_element (p);
75 }
76
77 void
78 Line_of_score::do_print() const
79 {
80   Spanner::do_print();
81   Axis_group_spanner::do_print ();
82 }
83
84 void
85 Line_of_score::output_line (bool last_line)
86 {
87   Interval i(extent(Y_AXIS));
88   if (i.empty_b())
89     programming_error ("Huh?  Empty Line_of_score?");
90   else
91     translate_axis (- i[MAX], Y_AXIS);
92   
93   pscore_l_->outputter_l_->start_line (i.length ());
94   Super_element::output_all ();
95   if (last_line)
96     pscore_l_->outputter_l_->stop_last_line();
97   else
98     pscore_l_->outputter_l_->stop_line ();
99 }
100
101 int
102 Line_of_score::compare (Line_of_score* const &p1,Line_of_score* const &p2)
103 {
104   return p1->rank_i_ - p2->rank_i_;
105 }