]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/command-request.cc
release: 1.3.93
[lilypond.git] / lily / command-request.cc
index 7e33d78a9dd67493fc0000041b7bbad45b710ab6..8ea0ef54dd175a2b63e1f3f7e40702d9137d5f14 100644 (file)
@@ -1,9 +1,9 @@
 /*
-  commandrequest.cc -- implement Nonmusical reqs
+  command-request.cc -- implement non-musical reqs
 
-  source file of the LilyPond music typesetter
+  source file of the GNU LilyPond music typesetter
 
-  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+  (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 #include "command-request.hh"
 #include "musical-request.hh"
 
 
-void
-Cadenza_req::do_print()const
+Bar_req::Bar_req (String s)
 {
-    mtor << on_b_;
+  set_mus_property ("type", ly_str02scm (s.ch_C()));
 }
 
-Cadenza_req::Cadenza_req(bool b)
+bool
+Barcheck_req::do_equal_b (Request const *r) const
 {
-    on_b_ =b;
+  Barcheck_req  const*b = dynamic_cast<Barcheck_req const*> (r);
+  return b;
 }
-/* *************** */
 
 
-int
-Bar_req::compare(Bar_req const &c1)const
+Clef_change_req::Clef_change_req (String s)
 {
-    return type_str_ == c1.type_str_;
+  clef_str_ = s;
 }
 
-void
-Bar_req::do_print() const
-{
-    mtor << type_str_;
-}
 
-Bar_req::Bar_req(String s)
+bool
+Time_signature_change_req::do_equal_b (Request const *r) const
 {
-    type_str_ = s;
-}
+  Time_signature_change_req  const* m
+    = dynamic_cast <Time_signature_change_req  const*> (r);
 
-Partial_measure_req::Partial_measure_req(Moment m)
-{
-    duration_ =m;
+  return m && m->beats_i_ == beats_i_
+    && one_beat_i_ == m->one_beat_i_;
 }
-/* *************** */
-Meter_change_req::Meter_change_req()
+
+Time_signature_change_req::Time_signature_change_req ()
 {
-    beats_i_ = 0;
-    one_beat_i_ =0;
+  beats_i_ = 0;
+  one_beat_i_ =0;
 }
-void
-Meter_change_req::set(int b,int o)
+
+
+Tempo_req::Tempo_req ()
 {
-    beats_i_=b;
-    one_beat_i_=o;
+  metronome_i_ = 60;
+  dur_. durlog_i_ = 2;
 }
 
-void
-Timing_req::do_print()const{}
 
-void
-Command_req::do_print()const{}
-/* *************** */
-void
-Barcheck_req::do_print() const{}
 
-/* *************** */
-void
-Clef_change_req::do_print() const
+bool
+Tempo_req::do_equal_b (Request const *r) const
 {
-    mtor << clef_str_ ;
-}
+  Tempo_req const *t = dynamic_cast <Tempo_req const*> (r);
 
-Clef_change_req::Clef_change_req(String s)
-{
-    clef_str_ = s;
-}
-/* *************** */
-void
-Group_feature_req::do_print() const
-{
-    mtor << "stemdir " << stemdir_i_;
+  return t&& t->dur_.length_mom ()== dur_.length_mom () && metronome_i_ == t->metronome_i_;
 }
 
-Group_feature_req::Group_feature_req()
-{
-    stemdir_i_ = 0;
-}
 
-void
-Group_change_req::do_print()const
-{
-    mtor << "id : " << newgroup_str_;
-}
-/* *************** */
-void
-Terminate_voice_req::do_print()const
-{
-}
 
-/* *************** */
-void
-Partial_measure_req::do_print() const
-{
-    mtor << duration_;
-}
 
-void
-Meter_change_req::do_print() const
+bool
+Key_change_req::do_equal_b (Request const * req) const
 {
-    mtor << beats_i_ << "*" << one_beat_i_;
+  Key_change_req const * k = dynamic_cast<Key_change_req const*> (req);
+  return k && scm_equal_p (get_mus_property ("pitch-alist"), k->get_mus_property ("pitch-alist"));
 }
 
-/* *************** */
 
 void
-Measure_grouping_req::do_print() const
-{
-    for (int i=0; i < elt_length_arr_.size(); i++) {
-       mtor << beat_i_arr_[i] <<"*" << elt_length_arr_[i]<<" ";
-    }
-}
-/* *************** */
-void
-Key_change_req::do_print() const
-{
-    for (int i=0; i < melodic_p_arr_.size(); i++) {
-       melodic_p_arr_[i]->print();
+Key_change_req::transpose (Musical_pitch p)
+{
+  SCM newlist = SCM_EOL;
+  SCM pa = get_mus_property ("pitch-alist");
+  for (SCM s = pa; gh_pair_p (s); s = gh_cdr (s))
+    {
+      SCM k = gh_caar (s);
+
+      if (gh_pair_p (k))
+       {
+         Musical_pitch orig (gh_list (gh_car (k), gh_cdr (k), gh_cdr (s), SCM_UNDEFINED));
+
+         orig.transpose (p);
+
+         SCM key = gh_cons (gh_int2scm (orig.octave_i_),
+                            gh_int2scm (orig.notename_i_));
+
+         newlist = gh_cons (gh_cons (key, gh_int2scm (orig.accidental_i_)),
+                            newlist);
+       }
+      else if (gh_number_p (k))
+       {
+         Musical_pitch orig (gh_list (gh_int2scm (0), k, gh_cdar (s), SCM_UNDEFINED));
+         orig.transpose (p);
+
+         SCM key =gh_int2scm (orig.notename_i_);
+         newlist = gh_cons (gh_cons (key, gh_int2scm (orig.accidental_i_)),
+                            newlist);
+       }
     }
+
+  set_mus_property ("pitch-alist", newlist);
 }
 
-Key_change_req::Key_change_req()
+Break_req::Break_req ()
 {
 }
-Key_change_req::Key_change_req(Key_change_req const&c)
-{
-    for (int i=0; i < c.melodic_p_arr_.size(); i++) {
-       melodic_p_arr_.push( c.melodic_p_arr_[i]->clone()->melodic() );
-    }
-}
 
-Key_change_req::~Key_change_req()
+
+bool
+Mark_req::do_equal_b (Request const * r) const
 {
-    for (int i=0; i < melodic_p_arr_.size(); i++)
-       delete melodic_p_arr_[i];
+  Mark_req const * other = dynamic_cast<Mark_req const*> (r);
+  return other && scm_equal_p (other->get_mus_property ("mark-label"),
+                              get_mus_property ("mark-label"));
 }