2 staff-elem.cc -- implement Score_elem
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
9 #include "paper-def.hh"
14 #include "molecule.hh"
15 #include "staff-elem.hh"
19 Score_elem::TeXstring() const
22 m
.translate(offset_
); // ugh?
26 Score_elem::Score_elem(Score_elem
const&s
)
27 :dependancy_l_arr_(s
.dependancy_l_arr_
),
28 dependant_l_arr_(s
.dependant_l_arr_
)
33 pstaff_l_
= s
.pstaff_l_
;
34 offset_
= Offset(0,0);
39 If deleted, then remove dependant_l_arr_ depency!
41 Score_elem::~Score_elem()
43 assert(status
< DELETED
);
50 Score_elem::translate(Offset O
)
56 Score_elem::do_width() const
61 Molecule
*m
= brew_molecule_p();
65 r
= output
->extent().x
;
70 Score_elem::width() const
72 Interval r
=do_width();
74 if (!r
.empty_b()) // float exception on DEC Alpha
80 Score_elem::do_height() const
84 Molecule
*m
= brew_molecule_p();
88 r
= output
->extent().y
;
93 Score_elem::height() const
95 Interval r
=do_height();
105 Score_elem::print()const
108 mtor
<< name() << "{\n";
119 Score_elem::Score_elem()
122 offset_
= Offset(0,0);
129 Score_elem::paper() const
132 return pstaff_l_
->pscore_l_
->paper_l_
;
136 Score_elem::add_processing()
138 if (status
>= VIRGIN
)
145 Score_elem::pre_processing()
147 if (status
>= PRECALCED
)
149 assert(status
!= PRECALCING
); // cyclic dependency
152 for (int i
=0; i
< dependancy_l_arr_
.size(); i
++)
153 if (dependancy_l_arr_
[i
])
154 dependancy_l_arr_
[i
]->pre_processing();
161 Score_elem::post_processing()
163 if (status
>= POSTCALCED
)
165 assert(status
!= POSTCALCING
);// cyclic dependency
168 for (int i
=0; i
< dependancy_l_arr_
.size(); i
++)
169 if (dependancy_l_arr_
[i
])
170 dependancy_l_arr_
[i
]->post_processing();
171 do_post_processing();
176 Score_elem::molecule_processing()
178 if (status
>= OUTPUT
)
180 status
= OUTPUT
; // do it only once.
181 for (int i
=0; i
< dependancy_l_arr_
.size(); i
++)
182 if (dependancy_l_arr_
[i
])
183 dependancy_l_arr_
[i
]->molecule_processing();
185 output
= brew_molecule_p();
189 Score_elem::do_post_processing()
194 Score_elem::do_pre_processing()
198 Score_elem::do_verticalcing()
203 Score_elem::do_add_processing()
208 Score_elem::substitute_dependency(Score_elem
* old
, Score_elem
* newdep
)
211 for (int i
=0; i
< dependancy_l_arr_
.size(); i
++) {
212 if (dependancy_l_arr_
[i
] == old
){
213 dependancy_l_arr_
[i
] = newdep
;
215 } else if (dependancy_l_arr_
[i
] == newdep
) {
220 dependancy_l_arr_
.push(newdep
);
224 Score_elem::add_dependency(Score_elem
* p
)
226 for (int i
=0; i
< dependancy_l_arr_
.size(); i
++)
227 if (dependancy_l_arr_
[i
] == p
)
230 dependancy_l_arr_
.push(p
);
231 p
->dependant_l_arr_
.push(p
);
233 IMPLEMENT_STATIC_NAME(Score_elem
);
236 Score_elem::brew_molecule_p()const
238 Atom
a(paper()->lookup_l()->fill(Box(Interval(0,0), Interval(0,0))));
239 return new Molecule (a
);
242 Score_elem::offset() const