]> git.donarmstrong.com Git - lilypond.git/blob - lily/grob-info.cc
Fix some bugs in the dynamic engraver and PostScript backend
[lilypond.git] / lily / grob-info.cc
1 /*
2   grob-info.cc -- implement Grob_info
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "grob-info.hh"
10 #include "grob.hh"
11 #include "music.hh"
12 #include "translator-group.hh"
13 #include "context.hh"
14 #include "spanner.hh"
15 #include "item.hh"
16
17 Grob_info::Grob_info (Translator *t, Grob *g)
18 {
19   origin_trans_ = t;
20   grob_ = g;
21   start_end_ = START;
22 }
23
24 Grob_info::Grob_info ()
25 {
26   grob_ = 0;
27   start_end_ = START;
28   origin_trans_ = 0;
29 }
30
31 Music *
32 Grob_info::music_cause () const
33 {
34   SCM cause = grob_->get_property ("cause");
35   return unsmob_music (cause);
36 }
37
38 vector<Context*>
39 Grob_info::origin_contexts (Translator *end) const
40 {
41   Context *t = origin_trans_->context ();
42   vector<Context*> r;
43   do
44     {
45       r.push_back (t);
46       t = t->get_parent_context ();
47     }
48   while (t && t != end->context ());
49
50   return r;
51 }
52
53 Context *
54 Grob_info::context () const
55 {
56   return origin_trans_->context ();
57 }
58
59 Spanner *
60 Grob_info::spanner () const
61 {
62   return dynamic_cast<Spanner *> (grob_);
63 }
64
65 Item *
66 Grob_info::item () const
67 {
68   return dynamic_cast<Item *> (grob_);
69 }
70
71 Music *
72 Grob_info::ultimate_music_cause () const
73 {
74   SCM cause = grob_->self_scm ();
75   while (unsmob_grob (cause))
76     {
77       cause = unsmob_grob (cause)->get_property ("cause");
78     }
79
80   return unsmob_music (cause);
81 }
82