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