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