lilypond-1.3.28
[lilypond.git] / lily / musical-request.cc
blob192ea5d48eef3547f5a9dc49604431a2534c0a17
1 /*
2 request.cc -- implement all musical requests.
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
9 #include "musical-request.hh"
10 #include "misc.hh"
11 #include "debug.hh"
12 #include "music-list.hh"
14 void
15 Span_req::do_print () const
17 #ifndef NPRINT
18 DEBUG_OUT << span_dir_;
19 #endif
22 Tremolo_req::Tremolo_req ()
24 type_i_ = 0;
27 void
28 Tremolo_req::do_print () const
30 #ifndef NPRINT
31 DEBUG_OUT << "type " << type_i_ << '\n';
32 #endif
35 void
36 Melodic_req::transpose (Musical_pitch delta)
38 pitch_.transpose (delta);
40 if (abs (pitch_.accidental_i_) > 2)
42 warning (_f ("Transposition by %s makes accidental larger than two",
43 delta.str ()));
49 bool
50 Melodic_req::do_equal_b (Request const* r) const
52 Melodic_req const* m= dynamic_cast <Melodic_req const*> (r);
53 return m&& !compare (*m, *this);
56 int
57 Melodic_req::compare (Melodic_req const &m1 , Melodic_req const&m2)
59 return Musical_pitch::compare (m1.pitch_, m2.pitch_);
62 void
63 Melodic_req::do_print () const
65 pitch_.print ();
71 int
72 Rhythmic_req::compare (Rhythmic_req const &r1, Rhythmic_req const &r2)
74 return (r1.length_mom () - r2.length_mom ());
77 bool
78 Rhythmic_req::do_equal_b (Request const* r) const
80 Rhythmic_req const* rh = dynamic_cast <Rhythmic_req const*> (r);
82 return rh && !compare (*this, *rh);
85 void
86 Rhythmic_req::do_print () const
88 #ifndef NPRINT
89 DEBUG_OUT << "duration { " <<duration_.str () << "}";
90 #endif
94 Moment
95 Rhythmic_req::length_mom () const
97 return duration_.length_mom ();
100 void
101 Rhythmic_req::compress (Moment m)
103 duration_.compress (m);
106 void
107 Lyric_req::do_print () const
109 #ifndef NPRINT
110 Rhythmic_req::do_print ();
111 DEBUG_OUT << "text = " << text_str_;
112 #endif
116 bool
117 Note_req::do_equal_b (Request const* r) const
119 Note_req const* n = dynamic_cast<Note_req const*> (r);
120 return n&& Rhythmic_req::do_equal_b (n) && Melodic_req::do_equal_b (n);
124 Note_req::Note_req ()
126 cautionary_b_ = false;
127 forceacc_b_ = false;
132 void
133 Note_req::do_print () const
135 #ifndef NPRINT
136 Melodic_req::do_print ();
137 if (cautionary_b_)
139 DEBUG_OUT << " force cautionary accidental\n";
141 else if (forceacc_b_)
143 DEBUG_OUT << " force accidental\n";
145 Rhythmic_req::do_print ();
146 #endif
150 bool
151 Span_req::do_equal_b (Request const*r) const
153 Span_req const* s = dynamic_cast <Span_req const*> (r);
154 return s && span_dir_ == s->span_dir_;
157 Span_req::Span_req ()
159 span_dir_ = CENTER;
162 Chord_tremolo_req::Chord_tremolo_req ()
164 type_i_ = 0;
167 void
168 Chord_tremolo_req::do_print () const
170 #ifndef NPRINT
171 DEBUG_OUT << type_i_;
172 #endif
175 void
176 Text_script_req::do_print () const
178 DEBUG_OUT << "text" << text_str_
179 << ", style = " << style_str_;
182 bool
183 Text_script_req::do_equal_b (Request const* r) const
185 Text_script_req const* t = dynamic_cast<Text_script_req const*> (r);
186 return t && t->text_str_ == text_str_ && t->style_str_ == style_str_;
189 void
190 Articulation_req::do_print () const
192 DEBUG_OUT << articulation_str_;
195 bool
196 Articulation_req::do_equal_b (Request const* r) const
198 Articulation_req const* a = dynamic_cast<Articulation_req const*> (r);
200 return a && articulation_str_ == a->articulation_str_;
204 Script_req::Script_req ()
206 set_direction (CENTER);