]> git.donarmstrong.com Git - lilypond.git/blob - lily/bar-check-iterator.cc
* lily/include/grob-info.hh: origin_contexts() now does not
[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--2004  Han-Wen Nienhuys <hanwen@cs.uu.nl>
8
9  */
10
11 #include "simple-music-iterator.hh"
12 #include "event.hh"
13 #include "context.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 void process (Moment);
23   Bar_check_iterator( );
24   DECLARE_SCHEME_CALLBACK(constructor, ());
25 };
26
27 IMPLEMENT_CTOR_CALLBACK(Bar_check_iterator);
28
29 Bar_check_iterator::Bar_check_iterator()
30 {
31 }
32
33 void
34 Bar_check_iterator::process (Moment m)
35 {
36   Simple_music_iterator::process(m);
37   if (!m.to_bool ())
38     {
39       Context *tr = get_outlet ();
40
41       SCM mp = tr->get_property ("measurePosition");
42       SCM sync= tr->get_property ("barCheckSynchronize");
43
44       Moment * where =unsmob_moment (mp);
45       if (!where)
46         return;
47       
48       if (where->main_part_)
49         {
50           bool warn =true;
51           if (to_boolean (sync))
52             {
53               tr = tr->where_defined (ly_symbol2scm("measurePosition"));
54               Moment zero;
55               tr->set_property ("measurePosition", zero.smobbed_copy ());
56             }
57           else
58             {
59               SCM lf = tr->get_property ("barCheckLastFail");
60               if (unsmob_moment (lf)
61                   && *unsmob_moment (lf) == *where)
62                 warn = false;
63               else
64                 tr->set_property ("barCheckLastFail", mp);
65             }
66
67           if (warn)
68             get_music ()->origin ()->warning (_f ("barcheck failed at: %s", 
69                                               where->to_string ()));
70         }
71     }
72 }