2 stem-info.cc -- implement Stem_info
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Jan Nieuwenhuizen <janneke@gnu.org>
12 #include "cross-staff.hh"
15 #include "paper-def.hh"
17 #include "stem-info.hh"
21 Stem_info::Stem_info ()
27 FIXME: y dims should not be in internote.
30 GURG UGRGINRG INA UG R
32 JUNKME -> this should set elt properties of STEM.
34 Stem_info::Stem_info (Stem
*s
, int mult
)
38 Beam
* beam_l
= stem_l_
->beam_l ();
40 x_
= stem_l_
->hpos_f ();
41 set_direction (stem_l_
->get_direction ());
42 SCM bd
= stem_l_
->remove_elt_property ("beam-dir");
46 beam_dir_
= gh_scm2int (bd
);
50 programming_error ("Beam direction not set.");
51 beam_dir_
= UP
; // GURAUGRNAGURAGU! urg !
54 Paper_def
* paper_l
= stem_l_
->paper_l ();
55 Real internote_f
= stem_l_
->staff_line_leading_f ()/2;
56 Real interbeam_f
= paper_l
->interbeam_f (mult_i_
);
57 Real beam_f
= gh_scm2double (beam_l
->get_elt_property ("beam-thickness"));
60 // strangely enough, dim(chord_start_f) == pt (and not internote!)
61 idealy_f_
= stem_l_
->chord_start_f () / internote_f
;
63 // calculate using dim(y) == pt
64 idealy_f_
*= internote_f
;
66 // for simplicity, we calculate as if dir == UP
67 idealy_f_
*= beam_dir_
;
69 bool grace_b
= stem_l_
->get_elt_property ("grace") != SCM_UNDEFINED
;
70 bool no_extend_b
= stem_l_
->get_elt_property ("no-stem-extend")
73 int stem_max
= (int)rint(paper_l
->get_var ("stem_max"));
74 String type_str
= grace_b
? "grace_" : "";
75 Real min_stem_f
= paper_l
->get_var (type_str
+ "minimum_stem_length"
76 + to_str (mult_i_
<? stem_max
)) * internote_f
;
77 Real stem_f
= paper_l
->get_var (type_str
+ "stem_length"
78 + to_str (mult_i_
<? stem_max
))* internote_f
;
80 if (!beam_dir_
|| (beam_dir_
== get_direction ()))
81 /* normal beamed stem */
86 idealy_f_
+= (mult_i_
- 1) * interbeam_f
;
92 miny_f_
+= min_stem_f
;
95 lowest beam of (UP) beam must never be lower than second staffline
97 Hmm, reference (Wanske?)
99 Although this (additional) rule is probably correct,
100 I expect that highest beam (UP) should also never be lower
101 than middle staffline, just as normal stems.
104 if (!grace_b
&& !no_extend_b
)
106 //highest beam of (UP) beam must never be lower than middle staffline
107 miny_f_
= miny_f_
>? 0;
108 //lowest beam of (UP) beam must never be lower than second staffline
109 miny_f_
= miny_f_
>? (- 2 * internote_f
- beam_f
110 + (mult_i_
> 0) * beam_f
+ interbeam_f
* (mult_i_
- 1));
121 maxy_f_
-= min_stem_f
;
124 // set dim(y) == internote
125 idealy_f_
/= internote_f
;
126 miny_f_
/= internote_f
;
127 maxy_f_
/= internote_f
;
129 idealy_f_
= maxy_f_
<? idealy_f_
;
130 idealy_f_
= miny_f_
>? idealy_f_
;
132 interstaff_f_
= calc_interstaff_dist (stem_l_
, beam_l
) / internote_f
;
133 idealy_f_
+= interstaff_f_
* beam_dir_
;
134 miny_f_
+= interstaff_f_
* beam_dir_
;
135 maxy_f_
+= interstaff_f_
* beam_dir_
;