lilypond-0.1.27
[lilypond.git] / lily / command-request.cc
blobee9d34567427ac3d18c81a8bce1bfeddb21ab3ab
1 /*
2 commandrequest.cc -- implement Nonmusical reqs
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
9 #include "command-request.hh"
10 #include "debug.hh"
11 #include "musical-request.hh"
13 void
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);
23 void
24 Cadenza_req::do_print() const
26 #ifndef NPRINT
27 DOUT << on_b_;
28 #endif
31 bool
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)
41 on_b_ =b;
43 /* *************** */
46 bool
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);
56 void
57 Bar_req::do_print() const
59 DOUT << type_str_;
62 Bar_req::Bar_req (String s)
64 type_str_ = s;
67 Partial_measure_req::Partial_measure_req (Moment m)
69 duration_ =m;
72 bool
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);
83 void
84 Timing_req::do_print() const{}
87 IMPLEMENT_IS_TYPE_B1(Command_req,Request);
89 void
90 Command_req::do_print() const{}
92 IMPLEMENT_IS_TYPE_B1(Disallow_break_req,Command_req);
94 void
95 Disallow_break_req::do_print() const
98 /* *************** */
100 IMPLEMENT_IS_TYPE_B1(Barcheck_req,Timing_req);
102 void
103 Barcheck_req::do_print() const{}
105 bool
106 Barcheck_req::do_equal_b (Request*) const
108 return true;
110 /* *************** */
112 IMPLEMENT_IS_TYPE_B1(Clef_change_req,Command_req);
114 void
115 Clef_change_req::do_print() const
117 #ifndef NPRINT
118 DOUT << clef_str_ ;
119 #endif
122 Clef_change_req::Clef_change_req (String s)
124 clef_str_ = s;
127 /* *************** */
130 IMPLEMENT_IS_TYPE_B1(Partial_measure_req,Timing_req);
132 void
133 Partial_measure_req::do_print() const
135 DOUT << duration_;
139 IMPLEMENT_IS_TYPE_B1(Meter_change_req,Timing_req);
141 void
142 Meter_change_req::do_print() const
144 #ifndef NPRINT
145 DOUT << beats_i_ << "/" << one_beat_i_;
146 #endif
149 bool
150 Meter_change_req::do_equal_b (Request * r) const
152 Meter_change_req * m = r->command()->timing ()->meterchange ();
154 return m->beats_i_ == beats_i_
155 && one_beat_i_ == m->one_beat_i_;
158 Meter_change_req::Meter_change_req()
160 beats_i_ = 0;
161 one_beat_i_ =0;
164 void
165 Meter_change_req::set (int b,int o)
167 beats_i_=b;
168 one_beat_i_=o;
172 Tempo_req::Tempo_req()
174 metronome_i_ = 60;
175 dur_. durlog_i_ = 2;
178 void
179 Tempo_req::do_print() const
181 DOUT << dur_.str() << " = " <<metronome_i_ ;
183 IMPLEMENT_IS_TYPE_B1(Tempo_req, Timing_req);
185 bool
186 Tempo_req::do_equal_b (Request *r) const
188 Tempo_req *t = r->command()->timing ()->tempo ();
190 return t->dur_.length()== dur_.length () && metronome_i_ == t->metronome_i_;
193 /* *************** */
196 IMPLEMENT_IS_TYPE_B1(Measure_grouping_req,Timing_req);
198 void
199 Measure_grouping_req::do_print() const
201 for (int i=0; i < elt_length_arr_.size(); i++)
203 DOUT << beat_i_arr_[i] <<"*" << elt_length_arr_[i]<<" ";
208 bool
209 Measure_grouping_req::do_equal_b (Request*) const
211 return false; // todo
214 /* *************** */
216 void
217 Key_change_req::transpose (Melodic_req const * d) const
219 WARN << _("don't know how to transpose a key. \n");
220 for (int i=0; i < melodic_p_arr_.size(); i++)
222 melodic_p_arr_[i]->transpose (d);
227 IMPLEMENT_IS_TYPE_B1(Key_change_req,Command_req);
228 void
229 Key_change_req::squash_octaves()
231 for (int i=0; i < melodic_p_arr_.size(); i++)
233 melodic_p_arr_[i]->octave_i_ = 0;
237 void
238 Key_change_req::do_print() const
240 #ifndef NPRINT
241 for (int i=0; i < melodic_p_arr_.size(); i++)
243 melodic_p_arr_[i]->print();
245 #endif
248 Key_change_req::Key_change_req()
250 minor_b_ = false;
251 multi_octave_b_= false;
254 Key_change_req::Key_change_req (Key_change_req const&c)
256 for (int i=0; i < c.melodic_p_arr_.size(); i++)
257 melodic_p_arr_.push (c.melodic_p_arr_[i]->clone()->musical ()->melodic ());
258 minor_b_ = c.minor_b_;
259 multi_octave_b_ = c.multi_octave_b_;
262 Key_change_req::~Key_change_req()
264 for (int i=0; i < melodic_p_arr_.size(); i++)
265 delete melodic_p_arr_[i];
269 Key_change_req::flats_i()
271 int flats_i = 0;
272 for (int i = 0; i < melodic_p_arr_.size(); i++)
274 Melodic_req* mel_l = melodic_p_arr_[i]->melodic();
275 assert (mel_l);
276 if (mel_l->accidental_i_ < 0)
277 flats_i -= mel_l->accidental_i_;
279 return flats_i;
283 Key_change_req::minor_b()
285 return minor_b_;
289 Key_change_req::sharps_i()
291 int sharps_i = 0;
292 for (int i = 0; i < melodic_p_arr_.size(); i++)
294 Melodic_req* mel_l = melodic_p_arr_[i]->melodic();
295 assert (mel_l);
296 if (mel_l->accidental_i_ > 0)
297 sharps_i+= mel_l->accidental_i_;
299 return sharps_i;