]> git.donarmstrong.com Git - lilypond.git/blob - lily/box.cc
Fix some bugs in the dynamic engraver and PostScript backend
[lilypond.git] / lily / box.cc
1 /*
2   box.cc -- implement Box
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1996--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "ly-smobs.icc"
10
11 #include "box.hh"
12 #include "std-vector.hh"
13
14 void
15 Box::translate (Offset o)
16 {
17   for (Axis i = X_AXIS; i < NO_AXES; incr (i))
18     interval_a_[i] += o[i];
19 }
20
21 void
22 Box::unite (Box b)
23 {
24   for (Axis i = X_AXIS; i < NO_AXES; incr (i))
25     interval_a_[i].unite (b[i]);
26 }
27
28 /**
29    Initialize to empty.
30 */
31 Box::Box ()
32 {
33 }
34
35 void
36 Box::set_empty ()
37 {
38   interval_a_[X_AXIS].set_empty ();
39   interval_a_[Y_AXIS].set_empty ();
40 }
41
42 Box::Box (Interval ix, Interval iy)
43 {
44   x () = ix;
45   y () = iy;
46 }
47
48 Interval &
49 Box::operator [] (Axis a)
50 {
51   return interval_a_[a];
52 }
53
54 Interval
55 Box::operator [] (Axis a) const
56 {
57   return interval_a_[a];
58 }
59
60 void
61 Box::scale (Real s)
62 {
63   interval_a_[X_AXIS] *= s;
64   interval_a_[Y_AXIS] *= s;
65 }
66
67 void
68 Box::add_point (Offset o)
69 {
70   interval_a_[X_AXIS].add_point (o[X_AXIS]);
71   interval_a_[Y_AXIS].add_point (o[Y_AXIS]);
72 }
73
74 Offset
75 Box::center () const
76 {
77   return Offset (interval_a_[X_AXIS].center (),
78                  interval_a_[Y_AXIS].center ());
79 }
80
81 void
82 Box::widen (Real x, Real y)
83 {
84   interval_a_[X_AXIS].widen (x);
85   interval_a_[Y_AXIS].widen (y);
86 }
87
88 IMPLEMENT_SIMPLE_SMOBS (Box);
89 IMPLEMENT_TYPE_P (Box, "ly:box?");
90 IMPLEMENT_DEFAULT_EQUAL_P (Box);
91
92 SCM
93 Box::mark_smob (SCM x)
94 {
95   (void)x;
96   return SCM_EOL;
97 }
98
99 int
100 Box::print_smob (SCM x, SCM p, scm_print_state*)
101 {
102   (void)x;
103   scm_puts ("#<Box>", p);
104   return 1;
105 }