]> git.donarmstrong.com Git - lilypond.git/blob - lily/bar-check-iterator.cc
release commit
[lilypond.git] / lily / bar-check-iterator.cc
1 /*   
2
3      bar-check-iterator.cc -- implement Bar_check_iterator
4
5      source file of the GNU LilyPond music typesetter
6
7      (c) 2001--2003  Han-Wen Nienhuys <hanwen@cs.uu.nl>
8
9  */
10
11 #include "simple-music-iterator.hh"
12 #include "event.hh"
13 #include "translator-group.hh"
14
15 /*
16   Check bar checks. We do this outside the engravers so that you can
17   race through the score using skipTypesetting to correct durations.
18  */
19 class Bar_check_iterator : Simple_music_iterator
20 {
21 public:
22   VIRTUAL_COPY_CONS(Bar_check_iterator);
23   virtual void process (Moment);
24   Bar_check_iterator( );
25   DECLARE_SCHEME_CALLBACK(constructor, ());
26 };
27
28 IMPLEMENT_CTOR_CALLBACK(Bar_check_iterator);
29
30 Bar_check_iterator::Bar_check_iterator()
31 {
32 }
33
34 void
35 Bar_check_iterator::process (Moment m)
36 {
37   Simple_music_iterator::process(m);
38   if (!m.to_bool ())
39     {
40       Translator_group *tr = report_to ();
41
42       SCM mp = tr->get_property ("measurePosition");
43       SCM sync= tr->get_property ("barCheckSynchronize");
44
45       Moment * where =unsmob_moment (mp);
46       if (!where)
47         return;
48       
49       if (where->main_part_)
50         {
51           bool warn =true;
52           if (to_boolean (sync))
53             {
54               tr = tr->where_defined (ly_symbol2scm("measurePosition"));
55               Moment zero;
56               tr->set_property ("measurePosition", zero.smobbed_copy ());
57             }
58           else
59             {
60               SCM lf = tr->get_property ("barCheckLastFail");
61               if (unsmob_moment (lf)
62                   && *unsmob_moment (lf) == *where)
63                 warn = false;
64               else
65                 tr->set_property ("barCheckLastFail", mp);
66             }
67
68           if (warn)
69             get_music ()->origin ()->warning (_f ("barcheck failed at: %s", 
70                                               where->to_string ()));
71         }
72     }
73 }