2 commandrequest.cc -- implement Nonmusical reqs
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
9 #include "command-request.hh"
11 #include "musical-request.hh"
14 Command_script_req::do_print() const
16 Command_script_req::Command_script_req(){}
18 IMPLEMENT_IS_TYPE_B1(Command_script_req,Command_req);
21 IMPLEMENT_IS_TYPE_B1(Cadenza_req, Timing_req);
24 Cadenza_req::do_print()const
32 Cadenza_req::do_equal_b(Request*r)const
34 Cadenza_req*cad = r->command()->timing()->cadenza();
36 return cad->on_b_ == on_b_;
39 Cadenza_req::Cadenza_req(bool b)
47 Bar_req::do_equal_b(Request*r)const
49 Bar_req * b = r->command()->bar();
50 return type_str_ == b->type_str_;
54 IMPLEMENT_IS_TYPE_B1(Bar_req,Command_req);
57 Bar_req::do_print() const
62 Bar_req::Bar_req(String s)
67 Partial_measure_req::Partial_measure_req(Moment m)
73 Partial_measure_req::do_equal_b(Request* r)const
75 Partial_measure_req *p = r->command()->timing()->partial();
77 return p->duration_ == duration_;
81 IMPLEMENT_IS_TYPE_B1(Timing_req,Command_req);
84 Timing_req::do_print()const{}
87 IMPLEMENT_IS_TYPE_B1(Command_req,Request);
90 Command_req::do_print()const{}
92 IMPLEMENT_IS_TYPE_B1(Disallow_break_req,Command_req);
95 Disallow_break_req::do_print()const
100 IMPLEMENT_IS_TYPE_B1(Barcheck_req,Timing_req);
103 Barcheck_req::do_print() const{}
106 Barcheck_req::do_equal_b(Request*)const
110 /* *************** */
112 IMPLEMENT_IS_TYPE_B1(Clef_change_req,Command_req);
115 Clef_change_req::do_print() const
122 Clef_change_req::Clef_change_req(String s)
126 /* *************** */
128 IMPLEMENT_IS_TYPE_B1(Group_feature_req,Command_req);
131 Group_feature_req::do_print() const
134 mtor << type_str_ << "=" << value_str_;
138 /* *************** */
141 IMPLEMENT_IS_TYPE_B1(Partial_measure_req,Timing_req);
144 Partial_measure_req::do_print() const
150 IMPLEMENT_IS_TYPE_B1(Meter_change_req,Timing_req);
153 Meter_change_req::do_print() const
156 mtor << beats_i_ << "/" << one_beat_i_;
161 Meter_change_req::do_equal_b(Request * r)const
163 Meter_change_req * m = r->command()->timing()->meterchange();
165 return m->beats_i_ == beats_i_
166 && one_beat_i_ == m->one_beat_i_;
169 Meter_change_req::Meter_change_req()
176 Meter_change_req::set(int b,int o)
183 Tempo_req::Tempo_req()
190 Tempo_req::do_print()const
192 mtor << dur_.str() << " = " <<metronome_i_ ;
194 IMPLEMENT_IS_TYPE_B1(Tempo_req, Timing_req);
197 Tempo_req::do_equal_b(Request *r)const
199 Tempo_req *t = r->command()->timing()->tempo();
201 return t->dur_.length()== dur_.length() && metronome_i_ == t->metronome_i_;
204 /* *************** */
207 IMPLEMENT_IS_TYPE_B1(Measure_grouping_req,Timing_req);
210 Measure_grouping_req::do_print() const
212 for (int i=0; i < elt_length_arr_.size(); i++) {
213 mtor << beat_i_arr_[i] <<"*" << elt_length_arr_[i]<<" ";
219 Measure_grouping_req::do_equal_b(Request*)const
221 return false; // todo
224 /* *************** */
227 Key_change_req::transpose(Melodic_req const & d)const
229 WARN << "don't know how to transpose a key. \n";
230 for (int i=0; i < melodic_p_arr_.size(); i++) {
231 melodic_p_arr_[i]->transpose(d);
236 IMPLEMENT_IS_TYPE_B1(Key_change_req,Command_req);
238 Key_change_req::squash_octaves()
240 for (int i=0; i < melodic_p_arr_.size(); i++) {
241 melodic_p_arr_[i]->octave_i_ = 0;
246 Key_change_req::do_print() const
249 for (int i=0; i < melodic_p_arr_.size(); i++) {
250 melodic_p_arr_[i]->print();
255 Key_change_req::Key_change_req()
258 multi_octave_b_= false;
261 Key_change_req::Key_change_req(Key_change_req const&c)
263 for (int i=0; i < c.melodic_p_arr_.size(); i++)
264 melodic_p_arr_.push( c.melodic_p_arr_[i]->clone()->musical()->melodic() );
265 minor_b_ = c.minor_b_;
266 multi_octave_b_ = c.multi_octave_b_;
269 Key_change_req::~Key_change_req()
271 for (int i=0; i < melodic_p_arr_.size(); i++)
272 delete melodic_p_arr_[i];
276 Key_change_req::flats_i()
279 for ( int i = 0; i < melodic_p_arr_.size(); i++ ) {
280 Melodic_req* mel_l = melodic_p_arr_[i]->melodic();
282 if ( mel_l->accidental_i_ < 0 )
283 flats_i -= mel_l->accidental_i_;
289 Key_change_req::minor_b()
295 Key_change_req::sharps_i()
298 for ( int i = 0; i < melodic_p_arr_.size(); i++ ) {
299 Melodic_req* mel_l = melodic_p_arr_[i]->melodic();
301 if ( mel_l->accidental_i_ > 0 )
302 sharps_i+= mel_l->accidental_i_;