*/
-
+/* snapnie now also works */
+#define SNAPNIE
#include <math.h> // tanh.
dirs_found[stem_infos.top ().dir_] = true;
#ifdef SNAPNIE
- Real b = calc_stem_y (me, s, Interval (1,0));
+ Real b = calc_stem_y (me, s, Interval (1,0), false);
lbase_lengths.push (b);
- Real a = calc_stem_y (me, s, Interval (0,1));
+ Real a = calc_stem_y (me, s, Interval (0,1), false);
rbase_lengths.push (a);
#endif
}
/*
Calculate the Y position of the stem-end, given the Y-left, Y-right
in POS, and for stem S.
+
+ If CORRECT, correct for multiplicity of beam in case of knees.
*/
Real
-Beam::calc_stem_y (Grob *me, Grob* s, Interval pos)
+Beam::calc_stem_y (Grob *me, Grob* s, Interval pos, bool correct)
{
int beam_multiplicity = get_multiplicity (me);
int stem_multiplicity = (Stem::duration_log (s) - 2) >? 0;
+
+ int first_multiplicity = (Stem::duration_log (first_visible_stem (me))
+ - 2) >? 0;
+ int last_multiplicity = (Stem::duration_log (last_visible_stem (me))
+ - 2) >? 0;
Real thick = gh_scm2double (me->get_grob_property ("thickness"));
Real interbeam = get_interbeam (me);
Real dx = last_visible_stem (me)->relative_coordinate (0, X_AXIS) - x0;
Real dy = pos.delta ();
Real stem_y = (dy && dx
- ? r / dx //(s->relative_coordinate (0, X_AXIS) - x0) / dx
+ ? r / dx
* dy
: 0) + pos[LEFT];
Direction first_dir = Directional_element_interface::get (first_visible_stem (me));
Direction my_dir = Directional_element_interface::get (s);
- if (my_dir != first_dir)
+ if (correct && my_dir != first_dir)
{
/*
WTF is happening here ?
--hwn.
*/
+
+ // FIXME, hairy stuff
stem_y += my_dir * (thick / 2 + (beam_multiplicity - 1) * interbeam);
// huh, why not for first visible?
else
programming_error ("No last visible stem");
}
-
return stem_y;
}
if (Stem::invisible_b (s))
continue;
- Real stem_y = calc_stem_y (me, s, pos);
+ Real stem_y = calc_stem_y (me, s, pos, true);
#if 0
// doesn't play well with dvips
static void set_stem_directions (Grob*, Direction );
static void consider_auto_knees (Grob*, Direction d);
static void set_stem_shorten (Grob*);
- static Real calc_stem_y (Grob*, Grob* s, Interval pos);
+ static Real calc_stem_y (Grob*, Grob* s, Interval pos, bool correct);
static void set_stem_lengths (Grob*);
static int forced_stem_count (Grob*);
};
Real thick = gh_scm2double (beam->get_grob_property ("thickness"));
Real ideal_y = chord_start_y (me);
+
+ /* from here on, calculate as if dir == UP */
ideal_y *= mydir;
+
SCM grace_prop = me->get_grob_property ("grace");
-
bool grace_b = to_boolean (grace_prop);
Real stem_length = a[multiplicity <? (a.size () - 1)] * staff_space;
- if (multiplicity)
- ideal_y += thick + (multiplicity - 1) * interbeam_f;
+ Direction first_dir = Directional_element_interface::get
+ (Beam::first_visible_stem (beam));
+ // FIXME, hairy. see beam::calc_stem_y, for knees it's not trival
+ // to calculate where secondary, ternary beams will go.
+ if (multiplicity && first_dir == mydir)
+ ideal_y += thick + (multiplicity - 1) * interbeam_f;
+
Real shortest_y = ideal_y;
ideal_y += stem_length;