]> git.donarmstrong.com Git - lilypond.git/blob - lily/scoreline.cc
release: 0.0.68pre
[lilypond.git] / lily / scoreline.cc
1 /*
2   scoreline.cc -- implement Line_of_score
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1996, 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9 #include "scoreline.hh"
10 #include "staffline.hh"
11 #include "dimen.hh"
12 #include "spanner.hh"
13 #include "symbol.hh"
14 #include "paper-def.hh"
15 #include "p-col.hh"
16 #include "p-score.hh"
17
18
19 /* To do:
20    take out hard coded TeX stuff.
21    
22    */
23 String
24 Line_of_score::TeX_string() const
25 {
26      String s("\\hbox{%<- line of score\n");
27      if (error_mark_b_)
28          s+= "\\scorelineerrormark";
29      
30      
31      Real lastpos = cols[0]->hpos;
32      for (int i=0; i < cols.size();  i++){
33          PCol* col_l= cols[i];
34          // all items in the current line & staff.
35          String chunk_str;
36          Real delta  = col_l->hpos - lastpos;
37             
38             
39          if (col_l->error_mark_b_) {
40              chunk_str += String("\\columnerrormark");
41          }
42          // now output the items.
43          for (iter_top(col_l->its,j); j.ok(); j++) {
44              chunk_str += j->TeX_string();
45          }
46          // spanners.
47          for (iter_top(col_l->starters,j); j.ok(); j++) {
48              if (j->name() != name())
49                  chunk_str += j->TeX_string();
50          }
51          if (chunk_str!="") {
52              // moveover
53              if (delta)
54                  s +=String( "\\kern ") + print_dimen(delta);
55              s += chunk_str;
56              lastpos = col_l->hpos;
57          }
58      }
59      s += "}";
60      return s;
61 }
62
63
64 Line_of_score::Line_of_score()
65 {
66     error_mark_b_ = 0;
67 }
68
69
70
71
72 IMPLEMENT_STATIC_NAME(Line_of_score);
73 IMPLEMENT_IS_TYPE_B2(Line_of_score,Spanner,Vertical_align_elem);
74
75 void
76 Line_of_score::add(Score_elem*e)
77 {
78     if (e->is_type_b( Line_of_staff::static_name()) 
79             && ! Vertical_align_elem::contains_b( e) ) 
80             
81         Vertical_align_elem::add(e);
82     else { 
83         add_dependency(e);
84     }
85 }
86
87 bool
88 Line_of_score::contains_b(PCol const* c)const
89 {
90     return cols.find_l((PCol*)c);
91 }
92
93 void
94 Line_of_score::set_breaking(Array<Col_hpositions> const &breaking)
95 {
96     for (int j=0; j < breaking.size(); j++) {
97         const Array<PCol*> &curline(breaking[j].cols);
98         const Array<PCol*> &errors(breaking[j].error_col_l_arr_);
99         const Array<Real> &config(breaking[j].config);
100         
101         for (int i=0; i < errors.size(); i++)
102             errors[i]->error_mark_b_ = true;
103
104         Line_of_score *line_l=0;
105         Line_of_score *line_p =0;
106         
107         if (breaking.size() >1) {
108             line_p = (Line_of_score*)clone()->spanner();
109             line_l = line_p;
110         } else 
111             line_l =  this;
112         
113         ((Array<PCol*> &)line_l->cols) = curline;
114         line_l->left_col_l_ =  curline[0];
115         line_l->right_col_l_= curline.top();
116         
117         if (line_p) {  
118             pscore_l_->typeset_broken_spanner(line_p);
119             broken_into_l_arr_.push(line_p);
120         }
121         
122         for (int i=0; i < curline.size(); i++){
123             curline[i]->hpos = config[i];
124             curline[i]->line_l_ = (Line_of_score*)line_l;
125         }
126     }
127 }
128
129 void
130 Line_of_score::break_into_pieces()
131 {
132 }
133
134 Link_array<Line_of_score>
135 Line_of_score::get_lines()const
136 {
137     Link_array<Line_of_score> ret;
138
139     if(broken_into_l_arr_.size())
140         for (int i=0; i < broken_into_l_arr_.size(); i++) {
141             ret.push((Line_of_score*)broken_into_l_arr_[i]);
142         }
143     else 
144         ret.push((Line_of_score*)this); // ugh
145     
146     return ret;
147 }
148
149 void
150 Line_of_score::do_print()const
151 {
152     Spanner::do_print();
153 }
154
155 Interval
156 Line_of_score::do_width()const
157
158     return Spanner::do_width();
159 }
160
161 void
162 Line_of_score::do_substitute_dependency(Score_elem*o,Score_elem*n)
163 {
164     Spanner::do_substitute_dependency(o,n);
165     Vertical_align_elem::do_substitute_dependency(o,n);
166 }