]> git.donarmstrong.com Git - lilypond.git/blob - lily/line-of-score.cc
release: 1.3.10
[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_elt_property ("columns", SCM_EOL);
21   set_axes (Y_AXIS,X_AXIS);
22 }
23
24
25
26 void
27 Line_of_score::output_lines ()
28 {
29   for (int i=0; i < broken_into_l_arr_.size (); i++)
30     {
31       Line_of_score *line_l = dynamic_cast<Line_of_score*> (broken_into_l_arr_[i]);
32
33       *mlog << '[' << flush;
34       line_l->post_processing ();
35       *mlog << i << flush;
36       line_l->output_line (i + 1 == broken_into_l_arr_.size ());
37       *mlog << ']' << flush;
38     }
39 }
40
41 // const?
42 void
43 Line_of_score::break_into_pieces (Array<Column_x_positions> const &breaking)
44 {
45   for (int i=0; i < breaking.size (); i++)
46     {
47       Line_of_score *line_l = dynamic_cast <Line_of_score*> (clone());
48       line_l->rank_i_ = i;
49       Link_array<Paper_column> c (breaking[i].cols_);
50       pscore_l_->typeset_element (line_l);
51       line_l->set_bounds(LEFT,c[0]);
52       line_l->set_bounds(RIGHT,c.top ());
53       for (int j=0; j < c.size(); j++)
54         {
55           c[j]->translate_axis (breaking[i].config_[j],X_AXIS);
56           c[j]->line_l_ = line_l;
57         }
58       
59       broken_into_l_arr_.push (line_l);
60     }
61
62   for (int i=0; i < broken_into_l_arr_.size (); i++)
63     {
64       broken_into_l_arr_[i]->handle_broken_dependencies ();
65     }
66
67   handle_broken_dependencies ();
68 }
69
70 void
71 Line_of_score::add_column (Paper_column*p)
72 {
73   set_elt_property ("columns",
74                     gh_cons (p->self_scm_, get_elt_property ("columns")));
75   add_element (p);
76 }
77
78 void
79 Line_of_score::do_print() const
80 {
81   Spanner::do_print();
82   Axis_group_spanner::do_print ();
83 }
84
85 void
86 Line_of_score::output_line (bool last_line)
87 {
88   Interval i(extent(Y_AXIS));
89   if (i.empty_b())
90     programming_error ("Huh?  Empty Line_of_score?");
91   else
92     translate_axis (- i[MAX], Y_AXIS);
93   
94   pscore_l_->outputter_l_->start_line (i.length ());
95   Super_element::output_all ();
96   if (last_line)
97     pscore_l_->outputter_l_->stop_last_line();
98   else
99     pscore_l_->outputter_l_->stop_line ();
100 }
101
102 int
103 Line_of_score::compare (Line_of_score* const &p1,Line_of_score* const &p2)
104 {
105   return p1->rank_i_ - p2->rank_i_;
106 }