source file of the GNU LilyPond music typesetter
- (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
+#include <math.h> // ceil
+
+
#include "dot-column.hh"
#include "note-column.hh"
#include "beam.hh"
#include "debug.hh"
#include "paper-def.hh"
#include "group-interface.hh"
+#include "staff-symbol-referencer.hh"
bool
Note_column::rest_b () const
SCM s1 = p1->get_elt_property ("horizontal-shift");
SCM s2 = p2->get_elt_property ("horizontal-shift");
- int h1 = (s1 == SCM_UNDEFINED) ? 0 : gh_scm2int (s1);
- int h2 = (s2 == SCM_UNDEFINED) ? 0 : gh_scm2int (s2);
+ int h1 = (gh_number_p (s1))? gh_scm2int (s1) :0;
+ int h2 = (gh_number_p (s2)) ? gh_scm2int (s2):0;
return h1 - h2;
}
for (; gh_pair_p (h); h = gh_cdr (h))
{
Score_element *se = unsmob_element (gh_car (h));
+ Staff_symbol_referencer_interface si (se);
- int j = int (dynamic_cast<Staff_symbol_referencer*> (se)->position_f ());
+ int j = int (si.position_f ());
iv.unite (Slice (j,j));
}
return iv;
void
Note_column::translate_rests (int dy_i)
{
- invalidate_cache (Y_AXIS);
-
SCM s = get_elt_property ("rests");
for (; gh_pair_p (s); s = gh_cdr (s))
{
- Score_element * se = unsmob_element ( gh_car (s));
- Staff_symbol_referencer *str = dynamic_cast<Staff_symbol_referencer*> (se);
- se->translate_axis (dy_i * str->staff_line_leading_f ()/2.0, Y_AXIS);
+ Score_element * se = unsmob_element (gh_car (s));
+ Staff_symbol_referencer_interface si (se);
+
+ se->translate_axis (dy_i * si.staff_space ()/2.0, Y_AXIS);
}
}
Should lookup
rest -> stem -> beam -> interpolate_y_position ()
-
*/
void
return;
Beam * b = stem_l ()->beam_l ();
- if (!b || !b->stem_count ())
+ if (!b || !b->visible_stem_count ())
return;
- /* ugh. Should be done by beam. */
+ /* ugh. Should be done by beam.
+ (what? should be done --jcn)
+ scary too?: height is calculated during post_processing
+ */
+ Real beam_dy = 0;
+ Real beam_y = 0;
+
+ SCM s = b->get_elt_property ("height");
+ if (gh_number_p (s))
+ beam_dy = gh_scm2double (s);
+
+ s = b->get_elt_property ("y-position");
+ if (gh_number_p (s))
+ beam_y = gh_scm2double (s);
+
+
+ Real x0 = b->first_visible_stem ()->hpos_f ();
+ Real dx = b->last_visible_stem ()->hpos_f () - x0;
+ Real dydx = beam_dy && dx ? beam_dy/dx : 0;
+
Direction d = stem_l ()->get_direction ();
- Real beamy = (stem_l ()->hpos_f () - b->stem(0)->hpos_f ()) * b->slope_f_ + b->left_y_;
+ Real beamy = (stem_l ()->hpos_f () - x0) * dydx + beam_y;
- SCM s = get_elt_property ("rests");
+ s = get_elt_property ("rests");
Score_element * se = unsmob_element (gh_car (s));
- Staff_symbol_referencer *str = dynamic_cast<Staff_symbol_referencer*> (se);
+ Staff_symbol_referencer_interface si (se);
- Real staff_space = str->staff_line_leading_f ();
+ Real staff_space = si.staff_space ();
Real rest_dim = extent (Y_AXIS)[d]*2.0 /staff_space ;
Real minimum_dist
Real dist =
minimum_dist + -d * (beamy - rest_dim) >? 0;
- int stafflines = str->lines_i ();
+ int stafflines = si.line_count ();
// move discretely by half spaces.
int discrete_dist = int (ceil (dist ));
{
Stem * st = stem_l ();
return st? st->first_head (): 0;
-
}