Doc-de: NR 4.4.3 (ex.1) \override -> \overrideProperty
[lilypond/mpolesky.git] / lily / ambitus.cc
blob85fb2978869c338590a47916ae1d4b2d93fcbdb6
1 /*
2 ambitus.cc -- implement Ambitus
4 source file of the GNU LilyPond music typesetter
6 (c) 2002--2009 Juergen Reuter <reuter@ipd.uka.de>
7 */
9 #include "ambitus.hh"
11 #include "staff-symbol-referencer.hh"
12 #include "pitch.hh"
13 #include "note-head.hh"
14 #include "item.hh"
15 #include "font-interface.hh"
16 #include "output-def.hh"
17 #include "lookup.hh"
18 #include "pointer-group-interface.hh"
20 MAKE_SCHEME_CALLBACK (Ambitus, print, 1);
21 SCM
22 Ambitus::print (SCM smob)
24 Item *me = (Item *) unsmob_grob (smob);
25 Stencil stencil;
27 // FIXME : should be Ambitus_line join heads
28 extract_grob_set (me, "note-heads", heads);
29 if (to_boolean (me->get_property ("join-heads"))
30 && heads.size () > 1)
32 Grob *common
33 = common_refpoint_of_array (vector<Grob*> (heads.begin (),
34 heads.begin () + 2),
35 me, Y_AXIS);
37 Grob *minh = heads[0];
38 Grob *maxh = heads[1];
40 if (minh->relative_coordinate (common, Y_AXIS)
41 > maxh->relative_coordinate (common, Y_AXIS))
43 Grob *t = maxh;
44 maxh = minh;
45 minh = t;
48 Real pad = 0.35;
49 Real pmax = maxh->extent (common, Y_AXIS)[DOWN] - pad;
50 Real pmin = minh->extent (common, Y_AXIS)[UP] + pad;
52 if (pmin < pmax)
54 Real linethickness = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness"))
55 * robust_scm2double (me->get_property ("thickness"), 1.0);
56 Real blotdiameter = me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter"));
57 Interval x_extent = 0.5 * linethickness * Interval (-1, 1);
58 Interval y_extent = Interval (pmin, pmax);
59 Box line_box (x_extent, y_extent);
61 Stencil line = Lookup::round_filled_box (line_box, blotdiameter);
62 line.translate_axis (- me->relative_coordinate (common, Y_AXIS),
63 Y_AXIS);
64 return line.smobbed_copy ();
68 return SCM_EOL;
71 ADD_INTERFACE (Ambitus,
72 "The line between note heads for a pitch range.",
74 /* properties */
75 "join-heads "
76 "note-heads "
77 "thickness "