]> git.donarmstrong.com Git - lilypond.git/blob - lily/line-of-score.cc
release: 1.3.37
[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--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "axis-group-interface.hh"
10 #include "debug.hh"
11 #include "line-of-score.hh"
12 #include "main.hh"
13 #include "paper-column.hh"
14 #include "paper-def.hh"
15 #include "paper-outputter.hh"
16 #include "paper-score.hh"
17 #include "string.hh"
18 #include "warn.hh"
19
20
21 Line_of_score::Line_of_score()
22 {
23   set_elt_property ("columns", SCM_EOL);
24   Axis_group_interface (this).set_interface ();
25   Axis_group_interface (this).set_axes (Y_AXIS,X_AXIS);
26 }
27
28
29
30 void
31 Line_of_score::output_lines ()
32 {
33   for (int i=0; i < broken_into_l_arr_.size (); i++)
34     {
35       Line_of_score *line_l = dynamic_cast<Line_of_score*> (broken_into_l_arr_[i]);
36
37       progress_indication ("[");
38       line_l->post_processing ();
39       progress_indication (to_str (i));
40       line_l->output_line (i + 1 == broken_into_l_arr_.size ());
41       progress_indication ("]");
42     }
43 }
44
45 // const?
46 void
47 Line_of_score::break_into_pieces (Array<Column_x_positions> const &breaking)
48 {
49   for (int i=0; i < breaking.size (); i++)
50     {
51       Line_of_score *line_l = dynamic_cast <Line_of_score*> (clone());
52       line_l->rank_i_ = i;
53       Link_array<Paper_column> c (breaking[i].cols_);
54       pscore_l_->typeset_element (line_l);
55       line_l->set_bound(LEFT,c[0]);
56       line_l->set_bound(RIGHT,c.top ());
57       for (int j=0; j < c.size(); j++)
58         {
59           c[j]->translate_axis (breaking[i].config_[j],X_AXIS);
60           c[j]->line_l_ = line_l;
61         }
62       
63       broken_into_l_arr_.push (line_l);
64     }
65 }
66
67 void
68 Line_of_score::add_column (Paper_column*p)
69 {
70   set_elt_property ("columns",
71                     gh_cons (p->self_scm_, get_elt_property ("columns")));
72   Axis_group_interface (this).add_element (p);
73 }
74
75
76 void
77 Line_of_score::output_line (bool last_line)
78 {
79   Interval i(extent(Y_AXIS));
80   if (i.empty_b())
81     programming_error ("Huh?  Empty Line_of_score?");
82   else
83     translate_axis (- i[MAX], Y_AXIS);
84   
85   pscore_l_->outputter_l_->start_line (i.length ());
86   output_all ();
87   if (last_line)
88     pscore_l_->outputter_l_->stop_last_line();
89   else
90     pscore_l_->outputter_l_->stop_line ();
91 }
92
93 int
94 Line_of_score::compare (Line_of_score* const &p1,Line_of_score* const &p2)
95 {
96   return p1->rank_i_ - p2->rank_i_;
97 }
98
99
100
101 /**
102     for administration of what was done already
103     */
104 enum Score_element_status {
105   ORPHAN=0,                     // not yet added to pstaff
106   VIRGIN,                       // added to pstaff
107   PREBROKEN,
108   PREBROKEN_SECOND,
109   PRECALCING,
110   PRECALCED,            // calcs before spacing done
111   SPACING,
112   SPACED,
113   BROKEN,
114   BROKEN_SECOND,
115   POSTCALCING,          // busy calculating. This is used to trap cyclic deps.
116   POSTCALCED,           // after spacing calcs done
117   BREWING,
118   BREWED,
119 };
120
121 void
122 Line_of_score::pre_processing ()
123 {
124   calculate_dependencies (PRECALCED, PRECALCING, &Score_element::before_line_breaking);
125 }
126
127 void
128 Line_of_score::space_processing ()
129 {
130   calculate_dependencies (SPACED, SPACING, &Score_element::do_space_processing);
131 }
132
133 /* for break processing, use only one status, because copies have to
134   have correct status. (Previously,
135   Score_element::handle_[pre]broken_dependencies assigned to status_i_
136   */
137 void
138 Line_of_score::breakable_col_processing ()
139 {
140   calculate_dependencies (PREBROKEN, PREBROKEN, &Score_element::do_breakable_col_processing);
141   //  calculate_dependencies (PREBROKEN_SECOND, PREBROKEN_SECOND, &Score_element::handle_prebroken_dependents);
142 }
143
144
145 void
146 Line_of_score::post_processing ()
147 {
148   //  calculate_dependencies (BROKEN_SECOND, BROKEN_SECOND,
149   //              &Score_element::handle_broken_dependents);
150   calculate_dependencies (POSTCALCED, POSTCALCING, &Score_element::after_line_breaking);
151 }
152
153 void
154 Line_of_score::output_all () 
155 {
156   calculate_dependencies (BREWED, BREWING, &Score_element::output_processing);
157 }
158
159
160
161