+
+pl 10.uu1
+ - various small bfs
+ - bf: alignment reversed
+ - Staff_symbol_referencer -> Staff_symbol_referencer_interface
+ - bf: staccato pos
+ - Knee fixes (thanks, Jan)
+
+pl 10.jcn2
+ - fixes for invisible beamed stems
+ - removed steminfo from properties, don't cache Stem_info
+
+pl 10.jcn1
+ - steminfo to properties
+ - dropped internote dim for stem-beams
+
+**********
pl 9.hwn1
- abstracting Staff_symbol_referencer to an interface.
- quantised_position for staccato dots.
tremolo must be parallel to the beam. If the stem is invisible
(eg. on a whole note), the tremolo must be centered on the note.
-@mudelafile{stem-tremolo.ly}
+@c @mu delafile{stem-tremolo.ly}
Chord tremolos look like beams, but are a kind of repeat symbol.
To avoid confusion, chord tremolo beams do not reach the stems, but
as half notes cannot appear in a regular beam, and should reach the
stems.
-@mudelafile{chord-tremolo.sly}
+@c miudelafile{chord-tremolo.sly}
Beams, stems and noteheads often have communication troubles, since
the two systems for y dimensions (1 unit = staffspace, 1 unit = 1
.* TODO
. * use hash tabs iso. alist_ for elt property?
. * agressive type-checking for SCM stuff.
+. * use "staff-space" and "half-space" iso interline,
+ staff_line_leading () etc.
. * TODO^2:
. * make a TODO.texi, like http://www.gnu.org/software/guile/ideas.html
ctor_dict["Score_element"]->create_func ();
. * acc at tied note after linebreak.
. * fix font-naming and selecting
-. * fix naming: \interline Context.staffLineLeading, staff_line_leading (),
-staff_position staff_space
. * chord tonic: placement of accidental C#, Cb (from scm and C++)
. * note head on stem err msg in dutch.
. * why need to run -C mf twice?
if (center_f)
translate_axis ( - center_f, axis ());
- dim_cache_[axis ()]->invalidate ();
+
+ // dim_cache_[axis ()]->invalidate ();
+
}
Align_element::Align_element()
{
- ordered_b_ = true;
threshold_interval_ = Interval (0, Interval::infinity ());
stacking_dir_ = DOWN;
align_dir_ = CENTER;
(c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-#include "axis-group-element.hh"
#include "axis-group-element.hh"
#include "dimension-cache.hh"
+#include "group-interface.hh"
Link_array<Score_element>
Axis_group_element::get_extra_dependencies() const
Link_array<Score_element>
Axis_group_element::elem_l_arr () const
{
- /*
- ugh. I know
- */
- Link_array<Score_element> r;
- for (SCM s = get_elt_property ("elements"); gh_pair_p (s); s = gh_cdr (s))
- {
- SCM e=gh_car (s);
- r.push (unsmob_element (e));
- }
-
- return r;
+ return
+ Group_interface__extract_elements (this, (Score_element*)0, "elements");
}
Link_array<Score_element>
}
-/*
- UGH.
- */
-void
-Axis_group_element::add_extra_element (Score_element *e)
-{
- add_element (e);
-}
-
void
Axis_group_element::add_element (Score_element *e)
if (!e->parent_l (axes_[i]))
e->set_parent (this, axes_[i]);
}
- set_elt_property ("elements",
- gh_cons (e->self_scm_,
- get_elt_property ("elements")));
-
- assert (e->parent_l(Y_AXIS) == this || e->parent_l (X_AXIS) == this);
+ Group_interface gi (this);
+ gi.add_element (e);
}
-
-
-
-
-
-
&& ! dynamic_cast<Axis_group_element*> (elts_[i]->parent_l (Y_AXIS)))
{
- staffline_p_->add_extra_element (elts_[i]);
+ staffline_p_->add_element (elts_[i]);
}
}
elts_.clear ();
#include "bar-script-engraver.hh"
#include "bar.hh"
#include "clef-item.hh"
-#include "staff-side.hh"
+#include "side-position-interface.hh"
#include "text-item.hh"
#include "lily-guile.hh"
#include "paper-column.hh"
return;
}
- stem_l->flag_i_ = rhythmic_req->duration_.durlog_i_;
+ stem_l->set_elt_property ("duration-log",
+ gh_int2scm (rhythmic_req->duration_.durlog_i_));
Moment stem_location = now_mom () - beam_start_mom_ + beam_start_location_;
beam_info_p_->add_stem (stem_location, rhythmic_req->duration_.durlog_i_ - 2);
beam_p_->add_stem (stem_l);
[TODO]
* center beam symbol
* less hairy code
- * redo grouping
-
-TODO:
-
-The relationship Stem <-> Beam is way too hairy. Let's figure who
-needs what, and what information should be available when.
*/
#include "paper-def.hh"
#include "lookup.hh"
#include "group-interface.hh"
+#include "staff-symbol-referencer.hh"
+#include "cross-staff.hh"
Beam::Beam ()
{
slope_f_ = 0;
left_y_ = 0;
- multiple_i_ = 0;
+ multiplicity_i_ = 0;
}
/*
return gi.count ();
}
+Stem*
+Beam::stem_top ()const
+{
+ return Group_interface__extract_elements ((Beam*) this, (Stem*) 0, "stems")[stem_count () - 1];
+}
+
+/* burp */
+int
+Beam::visible_stem_count () const
+{
+ int c = 0;
+ for (int i = 0; i < stem_count (); i++)
+ {
+ if (!stem (i)->invisible_b ())
+ c++;
+ }
+ return c;
+}
+
+Stem*
+Beam::first_visible_stem () const
+{
+ for (int i = 0; i < stem_count (); i++)
+ {
+ Stem* s = stem (i);
+ if (!s->invisible_b ())
+ return s;
+ }
+
+ assert (0);
+ // sigh
+ return 0;
+}
+
+Stem*
+Beam::last_visible_stem () const
+{
+ for (int i = stem_count (); i > 0; i--)
+ {
+ Stem* s = stem (i - 1);
+ if (!s->invisible_b ())
+ return s;
+ }
+
+ assert (0);
+ // sigh
+ return 0;
+}
void
Beam::add_stem (Stem*s)
set_bounds (RIGHT,s);
}
-Stem_info
-Beam::get_stem_info (Stem *s)
-{
- Stem_info i;
- for (int i=0; i < sinfo_.size (); i++)
- {
- if (sinfo_[i].stem_l_ == s)
- return sinfo_[i];
- }
- assert (false);
- return i;
-}
-
Molecule*
Beam::do_brew_molecule_p () const
{
Molecule *mol_p = new Molecule;
- if (!sinfo_.size ())
+ if (!stem_count ())
return mol_p;
- Real x0 = stem (0)->hpos_f ();
+ Real x0 = first_visible_stem ()->hpos_f ();
for (int j=0; j <stem_count (); j++)
{
Stem *i = stem (j);
Molecule sb = stem_beams (i, next, prev);
Real x = i->hpos_f ()-x0;
- sb.translate (Offset (x, (x * slope_f_ + left_y_) *
- i->staff_line_leading_f ()/2 ));
+ sb.translate (Offset (x, x * slope_f_ + left_y_));
mol_p->add_molecule (sb);
}
mol_p->translate_axis (x0
Offset
Beam::center () const
{
- Stem_info si = sinfo_[0];
-
- Real w= (si.stem_l_->note_delta_f () + extent (X_AXIS).length ())/2.0;
- return Offset (w, ( w* slope_f_) *
- si.stem_l_->staff_line_leading_f ()/2);
+ Real w = (first_visible_stem ()->note_delta_f () + extent (X_AXIS).length ())/2.0;
+ return Offset (w, w * slope_f_);
}
/*
{
bool knee = false;
int knee_y = 0;
- Real internote_f = stem (0)->staff_line_leading_f ()/2;
if (gap != SCM_UNDEFINED)
{
int auto_gap_i = gh_scm2int (gap);
for (int i=1; i < stem_count (); i++)
{
- bool is_b = (bool)(sinfo_[i].interstaff_f_ - sinfo_[i-1].interstaff_f_);
- int l_y = (int)(stem (i-1)->chord_start_f () / internote_f)
- + (int)sinfo_[i-1].interstaff_f_;
- int r_y = (int)(stem (i)->chord_start_f () / internote_f)
- + (int)sinfo_[i].interstaff_f_;
+ bool is_b = (bool)(calc_interstaff_dist (stem (i), this)
+ - calc_interstaff_dist (stem (i-1), this));
+ int l_y = (int)(stem (i-1)->chord_start_f ())
+ + (int)calc_interstaff_dist (stem (i-1), this);
+ int r_y = (int)(stem (i)->chord_start_f ())
+ + (int)calc_interstaff_dist (stem (i), this);
int gap_i = r_y - l_y;
/*
{
for (int i=0; i < stem_count (); i++)
{
- int y = (int)(stem (i)->chord_start_f () / internote_f)
- + (int)sinfo_[i].interstaff_f_;
+ int y = (int)(stem (i)->chord_start_f ())
+ + (int)calc_interstaff_dist (stem (i), this);
stem (i)->set_direction ( y < knee_y ? UP : DOWN);
stem (i)->set_elt_property ("dir-forced", SCM_BOOL_T);
}
void
Beam::do_post_processing ()
{
- if (stem_count () < 2)
+ if (visible_stem_count () < 2)
{
warning (_ ("beam with less than two stems"));
set_elt_property ("transparent", SCM_BOOL_T);
return;
}
- set_steminfo ();
+ set_stem_shorten ();
if (auto_knees ())
{
/*
if auto-knee did its work, most probably stem directions
have changed, so we must recalculate all.
*/
- set_direction ( get_default_dir ());
+ set_direction (get_default_dir ());
set_direction (get_direction ());
/* auto-knees used to only work for slope = 0
set_elt_property ("damping", gh_int2scm(1000));
*/
- sinfo_.clear ();
- set_steminfo ();
+ set_stem_shorten ();
}
calculate_slope ();
set_stemlens ();
}
-#if 0
-Interval
-Beam::do_width () const
-{
- return Interval (stem (0)->hpos_f (),
- stems_.top ()->hpos_f ());
-}
-#endif
+
Direction
Beam::get_default_dir () const
Stem *s = stem (i);
s->set_elt_property ("beam-dir", gh_int2scm (d));
- SCM force = s->remove_elt_property ("dir-forced");
+ SCM force = s->get_elt_property ("dir-forced"); // remove_prop?
if (force == SCM_UNDEFINED)
s->set_direction ( d);
}
void
Beam::solve_slope ()
{
- assert (sinfo_.size () > 1);
+ assert (visible_stem_count () > 1);
Least_squares l;
- for (int i=0; i < sinfo_.size (); i++)
+ Real x0 = first_visible_stem ()->hpos_f ();
+ for (int i=0; i < stem_count (); i++)
{
- l.input.push (Offset (sinfo_[i].x_, sinfo_[i].idealy_f_));
+ Stem* s = stem (i);
+ if (s->invisible_b ())
+ continue;
+ l.input.push (Offset (s->hpos_f () - x0, s->calc_stem_info ().idealy_f_));
}
l.minimise (slope_f_, left_y_);
}
/*
ugh. Naming: this doesn't check, but sets as well.
*/
-
Real
Beam::check_stemlengths_f (bool set_b)
{
- Real interbeam_f = paper_l ()->interbeam_f (multiple_i_);
+ Real interbeam_f = paper_l ()->interbeam_f (multiplicity_i_);
Real beam_f = gh_scm2double (get_elt_property ("beam-thickness"));
Real staffline_f = paper_l ()-> get_var ("stafflinethickness");
Real epsilon_f = staffline_f / 8;
Real dy_f = 0.0;
- for (int i=0; i < sinfo_.size (); i++)
+ Real x0 = first_visible_stem ()->hpos_f ();
+ Real internote_f = paper_l ()->get_var ("interline");
+ for (int i=0; i < stem_count (); i++)
{
- Real y = sinfo_[i].x_ * slope_f_ + left_y_;
+ Stem* s = stem (i);
+ if (s->invisible_b ())
+ continue;
+ Real y = (s->hpos_f () - x0) * slope_f_ + left_y_;
+ Stem_info info = s->calc_stem_info ();
// correct for knee
- if (get_direction () != sinfo_[i].get_direction ())
+ if (get_direction () != s->get_direction ())
{
- Real internote_f = sinfo_[i].stem_l_->staff_line_leading_f ()/2;
y -= get_direction () * (beam_f / 2
- + (sinfo_[i].mult_i_ - 1) * interbeam_f) / internote_f;
- if (!i && sinfo_[i].stem_l_->staff_symbol_l () !=
- sinfo_.top ().stem_l_->staff_symbol_l ())
- y += get_direction () * (multiple_i_ - (sinfo_[i].stem_l_->flag_i_ - 2) >? 0)
- * interbeam_f / internote_f;
+ + (multiplicity_i_ - 1) * interbeam_f);
+
+
+ Staff_symbol_referencer_interface s1 (s);
+ Staff_symbol_referencer_interface s2 (stem_top ());
+
+ if (!i
+ && s1.staff_symbol_l () != s2.staff_symbol_l ())
+ y += get_direction () * (multiplicity_i_ - (s->flag_i () - 2) >? 0)
+ * interbeam_f;
}
+ /* caution: stem measures in staff-positions */
if (set_b)
- sinfo_[i].stem_l_->set_stemend (y - sinfo_[i].interstaff_f_);
+ s->set_stemend ((y - calc_interstaff_dist (s, this))
+ / internote_f);
y *= get_direction ();
- if (y > sinfo_[i].maxy_f_)
- dy_f = dy_f <? sinfo_[i].maxy_f_ - y;
- if (y < sinfo_[i].miny_f_)
+ if (y > info.maxy_f_)
+ dy_f = dy_f <? info.maxy_f_ - y;
+ if (y < info.miny_f_)
{
// when all too short, normal stems win..
if (dy_f < -epsilon_f)
warning (_ ("weird beam vertical offset"));
- dy_f = dy_f >? sinfo_[i].miny_f_ - y;
+ dy_f = dy_f >? info.miny_f_ - y;
}
}
return dy_f;
}
void
-Beam::set_steminfo ()
+Beam::set_stem_shorten ()
{
if(!stem_count ())
return;
- assert (multiple_i_);
+ assert (multiplicity_i_);
int total_count_i = 0;
int forced_count_i = 0;
total_count_i++;
}
+ Real internote_f = paper_l ()->get_var ("interline");
bool grace_b = get_elt_property ("grace") == SCM_BOOL_T;
String type_str = grace_b ? "grace_" : "";
int stem_max = (int)rint(paper_l ()->get_var ("stem_max"));
Real shorten_f = paper_l ()->get_var (type_str + "forced_stem_shorten"
- + to_str (multiple_i_ <? stem_max));
+ + to_str (multiplicity_i_ <? stem_max)) * internote_f;
- Real leftx = 0;
for (int i=0; i < stem_count (); i++)
{
Stem *s = stem (i);
continue;
}
- Stem_info info (s, multiple_i_);
- if (leftx == 0)
- leftx = info.x_;
- info.x_ -= leftx;
- if (info.get_direction () == get_direction ())
+ if (s->get_direction () == get_direction ())
{
if (forced_count_i == total_count_i)
- info.idealy_f_ -= shorten_f;
+ s->set_real ("shorten", shorten_f);
else if (forced_count_i > total_count_i / 2)
- info.idealy_f_ -= shorten_f / 2;
+ s->set_real ("shorten", shorten_f/2);
}
- sinfo_.push (info);
}
}
void
Beam::calculate_slope ()
{
- if (!sinfo_.size ())
+ if (!stem_count ())
slope_f_ = left_y_ = 0;
- else if (sinfo_[0].idealy_f_ == sinfo_.top ().idealy_f_)
+ else if (first_visible_stem ()->calc_stem_info ().idealy_f_ == last_visible_stem ()->calc_stem_info ().idealy_f_)
{
slope_f_ = 0;
- left_y_ = sinfo_[0].idealy_f_;
+ left_y_ = first_visible_stem ()->calc_stem_info ().idealy_f_;
left_y_ *= get_direction ();
}
else
/*
steep slope running against lengthened stem is suspect
*/
- Real dx_f = stem (stem_count () -1)->hpos_f () - stem (0)->hpos_f ();
+ Real dx_f = stem (stem_count () -1)->hpos_f () - first_visible_stem ()->hpos_f ();
- // urg, these y internote-y-dimensions
- Real internote_f = stem (0)->staff_line_leading_f ()/2;
-
- Real lengthened = paper_l ()->get_var ("beam_lengthened") / internote_f;
- Real steep = paper_l ()->get_var ("beam_steep_slope") / internote_f;
- if (((left_y_ - sinfo_[0].idealy_f_ > lengthened)
+ Real lengthened = paper_l ()->get_var ("beam_lengthened");
+ Real steep = paper_l ()->get_var ("beam_steep_slope");
+ if (((left_y_ - first_visible_stem ()->calc_stem_info ().idealy_f_ > lengthened)
&& (slope_f_ > steep))
- || ((left_y_ + slope_f_ * dx_f - sinfo_.top ().idealy_f_ > lengthened)
+ || ((left_y_ + slope_f_ * dx_f - last_visible_stem ()->calc_stem_info ().idealy_f_ > lengthened)
&& (slope_f_ < -steep)))
{
slope_f_ = 0;
if (q == ly_symbol2scm ("none"))
return;
- Real interline_f = stem (0)->staff_line_leading_f ();
- Real internote_f = interline_f / 2;
+ Staff_symbol_referencer_interface st (this);
+ Real interline_f = st.staff_line_leading_f ();
+
Real staffline_f = paper_l ()->get_var ("stafflinethickness");
Real beam_f = gh_scm2double (get_elt_property ("beam-thickness"));;
- Real dx_f = stem (stem_count () -1 )->hpos_f () - stem (0)->hpos_f ();
+ Real dx_f = stem (stem_count () -1 )->hpos_f () - first_visible_stem ()->hpos_f ();
- // dim(y) = internote; so slope = (y/internote)/x
- Real dy_f = dx_f * abs (slope_f_ * internote_f);
+ Real dy_f = dx_f * abs (slope_f_);
Real quanty_f = 0.0;
allowed_fraction[1] = (beam_f / 2 + staffline_f / 2);
allowed_fraction[2] = (beam_f + staffline_f);
-
Interval iv = quantise_iv (allowed_fraction, interline_f, dy_f);
quanty_f = (dy_f - iv[SMALLER] <= iv[BIGGER] - dy_f)
? iv[SMALLER]
: iv[BIGGER];
-
- slope_f_ = (quanty_f / dx_f) / internote_f * sign (slope_f_);
+ slope_f_ = (quanty_f / dx_f) * sign (slope_f_);
}
/*
hang straddle sit inter hang
*/
- Real space = stem (0)->staff_line_leading_f ();
- Real internote_f = space /2;
+ Staff_symbol_referencer_interface sinf (this);
+ Real space = sinf.staff_line_leading_f ();
Real staffline_f = paper_l ()->get_var ("stafflinethickness");
Real beam_f = gh_scm2double (get_elt_property ("beam-thickness"));;
*/
// isn't this asymmetric ? --hwn
- // dim(left_y_) = internote
- Real dy_f = get_direction () * left_y_ * internote_f;
+ Real dy_f = get_direction () * left_y_;
- Real beamdx_f = stem (stem_count () -1)->hpos_f () - stem (0)->hpos_f ();
- Real beamdy_f = beamdx_f * slope_f_ * internote_f;
+ Real beamdx_f = stem (stem_count () -1)->hpos_f () - first_visible_stem ()->hpos_f ();
+ Real beamdy_f = beamdx_f * slope_f_;
Array<Real> allowed_position;
if (q == ly_symbol2scm ("normal"))
{
- if ((multiple_i_ <= 2) || (abs (beamdy_f) >= staffline_f / 2))
+ if ((multiplicity_i_ <= 2) || (abs (beamdy_f) >= staffline_f / 2))
allowed_position.push (straddle);
- if ((multiple_i_ <= 1) || (abs (beamdy_f) >= staffline_f / 2))
+ if ((multiplicity_i_ <= 1) || (abs (beamdy_f) >= staffline_f / 2))
allowed_position.push (sit);
allowed_position.push (hang);
}
else if (q == ly_symbol2scm ("traditional"))
{
// TODO: check and fix TRADITIONAL
- if ((multiple_i_ <= 2) || (abs (beamdy_f) >= staffline_f / 2))
+ if ((multiplicity_i_ <= 2) || (abs (beamdy_f) >= staffline_f / 2))
allowed_position.push (straddle);
- if ((multiple_i_ <= 1) && (beamdy_f <= staffline_f / 2))
+ if ((multiplicity_i_ <= 1) && (beamdy_f <= staffline_f / 2))
allowed_position.push (sit);
if (beamdy_f >= -staffline_f / 2)
allowed_position.push (hang);
if (extend_b)
quanty_f = iv[BIGGER];
- // dim(left_y_) = internote
- left_y_ = get_direction () * quanty_f / internote_f;
+ left_y_ = get_direction () * quanty_f;
}
void
{
Direction d = LEFT;
do {
- multiple_i_ = multiple_i_ >? stem (i)->beams_i_drul_[d];
+ multiplicity_i_ = multiplicity_i_ >? stem (i)->beams_i_drul_[d];
} while ((flip (&d)) != LEFT);
}
- /*
- Why?
- */
- if (stem_count ())
- {
- stem (0)->beams_i_drul_[LEFT] =0;
- stem (stem_count () -1)->beams_i_drul_[RIGHT] =0;
- }
}
programming_error ("Beams are not left-to-right");
Real staffline_f = paper_l ()->get_var ("stafflinethickness");
- Real interbeam_f = paper_l ()->interbeam_f (multiple_i_);
-
- Real internote_f = here->staff_line_leading_f ()/2;
+ Real interbeam_f = paper_l ()->interbeam_f (multiplicity_i_);
Real beam_f = gh_scm2double (get_elt_property ("beam-thickness"));;
Real dy = interbeam_f;
Real stemdx = staffline_f;
- Real sl = slope_f_* internote_f;
+ Real sl = slope_f_;
Molecule leftbeams;
Molecule rightbeams;
(c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
Jan Nieuwenhuizen <janneke@gnu.org>
*/
-#include "dimension-cache.hh"
+#include "dimension-cache.hh"
#include "bow.hh"
#include "debug.hh"
#include "paper-def.hh"
*/
+#include "staff-symbol-referencer.hh"
#include "breathing-sign-engraver.hh"
#include "breathing-sign.hh"
#include "musical-request.hh"
{
if(breathing_sign_req_l_) {
breathing_sign_p_ = new Breathing_sign;
+ Staff_symbol_referencer_interface st (breathing_sign_p_);
+ st.set_interface ();
announce_element (Score_element_info (breathing_sign_p_, breathing_sign_req_l_));
}
TODO: --> see breathing-sign-engraver.cc
*/
+#include "staff-symbol-referencer.hh"
#include "breathing-sign.hh"
#include "string.hh"
Molecule*
Breathing_sign::do_brew_molecule_p () const
{
- Real dl = staff_line_leading_f();
+ Staff_symbol_referencer_interface si (this);
+
+ Real dl = si.staff_line_leading_f();
Interval i1(0, dl / 6), i2(-dl / 2, dl / 2);
Box b(i1, i2);
void
Breathing_sign::do_post_processing()
{
- Real dl = staff_line_leading_f();
+ Real dl = Staff_symbol_referencer_interface (this).staff_line_leading_f();
translate_axis(2.0 * dl * get_direction (), Y_AXIS);
}
if (Stem* s = dynamic_cast<Stem *> (i.elem_l_))
{
int type_i = prev_start_req_->type_i_;
- s->flag_i_ = intlog2 (type_i) - 2;
+ s->set_elt_property ("duration-log", gh_int2scm (intlog2 (type_i) - 2));
- s->beams_i_drul_[LEFT] = s->flag_i_;
- s->beams_i_drul_[RIGHT] = s->flag_i_;
+ s->beams_i_drul_[LEFT] = s->flag_i ();
+ s->beams_i_drul_[RIGHT] = s->flag_i ();
- abeam_p_->multiple_i_ = s->flag_i_;
+ abeam_p_->multiplicity_i_ = s->flag_i ();
/*
abbrev gaps on all but half note
*/
#if 0
if (s->type_i () != 1)
{
- int gap_i =s->flag_i_ - ((s->type_i () >? 2) - 2);
+ int gap_i =s->flag_i () - ((s->type_i () >? 2) - 2);
s->set_elt_property ("beam-gap", gh_int2scm(gap_i));
}
#else
if (s->type_i () != 1)
{
- int gap_i =s->flag_i_ - ((s->type_i () >? 2) - 2);
+ int gap_i =s->flag_i () - ((s->type_i () >? 2) - 2);
abeam_p_->set_elt_property ("beam-gap", gh_int2scm(gap_i));
}
#endif
*/
#include <ctype.h>
+#include "staff-symbol-referencer.hh"
#include "bar.hh"
#include "clef-engraver.hh"
#include "clef-item.hh"
{
if (Note_head * h = dynamic_cast<Note_head*>(it_l))
{
- h->set_position (int (h->position_f ()) + c0_position_i_);
+ Staff_symbol_referencer_interface si (h);
+ si.set_position (int (si.position_f ()) + c0_position_i_);
}
else if (Local_key_item *i = dynamic_cast<Local_key_item*> (it_l))
{
Clef_item *c= new Clef_item;
c->set_elt_property ("break-aligned", SCM_BOOL_T);
announce_element (Score_element_info (c, clef_req_l_));
+
+ Staff_symbol_referencer_interface si(c);
+ si.set_interface ();
+
clef_p_ = c;
}
-
+ Staff_symbol_referencer_interface si(clef_p_);
clef_p_->symbol_ = clef_type_str_;
- clef_p_->set_position(clef_position_i_);
+ si.set_position (clef_position_i_);
if (octave_dir_)
{
clef_p_->set_elt_property ("octave-dir", gh_int2scm (octave_dir_));
#include "text-item.hh"
#include "paper-score.hh"
#include "dimension-cache.hh"
-#include "staff-side.hh"
+#include "side-position-interface.hh"
void
Clef_item::do_pre_processing()
{
- Staff_symbol_referencer::do_pre_processing();
SCM style_sym =get_elt_property ("style");
String style;
if (style_sym != SCM_UNDEFINED)
set_elt_property ("breakable", SCM_BOOL_T);
symbol_ = "treble";
- set_position(-2);
}
void
bool merge =
downpos == uppos
- && nu_l->balltype_i_ == nd_l->balltype_i_
+ && nu_l->balltype_i () == nd_l->balltype_i ()
&& nu_l->dots_i () == nd_l->dots_i ();
/*
void
Dimension_cache::invalidate ()
{
- off_valid_b_ =false;
- valid_b_ = false;
+ /* off_valid_b_ =false;
+ valid_b_ = false;*/
}
Real
Dimension_cache::get_offset () const
{
- if (!off_valid_b_)
+ Dimension_cache *me = (Dimension_cache*) this;
+ while (off_callbacks_.size ())
{
- Dimension_cache *d = (Dimension_cache*) this;
-
- d->basic_offset_ =0.0;
- d->off_valid_b_ = true;
- for (int i=0; i < off_callbacks_.size (); i++)
- d->basic_offset_ += (*off_callbacks_[i]) (d);
+ Offset_cache_callback c = me->off_callbacks_[0];
+ me->off_callbacks_.del (0);
+ me->basic_offset_ += (*c) (me);
}
-
return basic_offset_ + extra_offset_;
}
set_direction (get_default_dir());
}
-#if 0
-Offset
-Directional_spanner::center () const
-{
- Real w= extent (X_AXIS).length ();
- Offset o (w/2, 0);
- return o;
-}
-#endif
+
#include "dot-column.hh"
#include "rhythmic-head.hh"
#include "group-interface.hh"
+#include "staff-symbol-referencer.hh"
void
Dot_column::add_dots (Dots *d)
int
Dot_column::compare (Dots * const &d1, Dots * const &d2)
{
- return int (d1->position_f () - d2->position_f ());
+ Staff_symbol_referencer_interface s1(d1);
+ Staff_symbol_referencer_interface s2(d2);
+
+
+ return int (s1.position_f () - s2.position_f ());
}
int conflicts = 0;
for (int i=0; i < dots.size (); i++)
{
+ Real p = Staff_symbol_referencer_interface (dots[i]).position_f ();
for (int j=0; j < taken_posns.size (); j++)
- if (taken_posns[j] == (int) dots[i]->position_f ())
- conflicts++;
- taken_posns.push ((int)dots[i]->position_f ());
- s.unite (Slice ((int)dots[i]->position_f (),
- (int)dots[i]->position_f ()));
+ {
+ if (taken_posns[j] == (int) p)
+ conflicts++;
+ }
+ taken_posns.push ((int)p);
+ s.unite (Slice ((int)p,
+ (int)p));
}
if (!conflicts)
for (int i=0; i <dots.size (); pos += 2, i++)
{
- dots[i]->set_position(pos);
+ staff_symbol_referencer_interface (dots[i]).set_position(pos);
}
}
#include "molecule.hh"
#include "paper-def.hh"
#include "lookup.hh"
+#include "staff-symbol-referencer.hh"
Dots::Dots ()
{
if (!get_direction ())
set_direction (UP);
- int p = int (position_f ());
+ Staff_symbol_referencer_interface si (this);
+ int p = si.position_f ();
if (!(p % 2))
- set_position (p + get_direction ());
+ si.set_position (p + get_direction ());
}
}
Molecule*
#include "staff-symbol.hh"
#include "note-column.hh"
#include "text-item.hh"
-#include "staff-side.hh"
+#include "side-position-interface.hh"
#include "engraver.hh"
#include "stem.hh"
#include "note-head.hh"
return;
warning (_("Unattached grace notes. Attaching to last musical column."));
- Axis_group_element * ae = dynamic_cast<Axis_group_element*> (elt);
/* if (ae)
ae->remove_element (align_l_);
else if (elt)*/
- align_l_->set_parent (0, X_AXIS);
+
+
+ align_l_->set_parent (0, X_AXIS);
last_musical_col_l_->add_element (align_l_);
}
name_ = s;
}
bool
-Group_interface::supports_interface_b ()
+Group_interface::has_interface_b ()
{
SCM el = elt_l_->get_elt_property (name_);
void
Group_interface::add_element (Score_element*p)
{
+ p->used_b_ = true;
+ elt_l_->used_b_ = true;
+
elt_l_->set_elt_property (name_,
gh_cons (p->self_scm_, elt_l_->get_elt_property (name_)));
}
void
Group_interface::set_interface ()
{
- if (!supports_interface_b ())
+ if (!has_interface_b ())
{
elt_l_->set_elt_property (name_, SCM_EOL);
}
{
/// modify fields of E for removal.
void do_remove (Score_element*e);
- void purge_extra ();
-
-
protected:
virtual Link_array<Score_element> get_extra_dependencies() const;
virtual Link_array<Score_element> elem_l_arr() const;
static Interval extent_callback (Dimension_cache const*);
-
-
- Interval extra_extent (Axis a) const;
public:
- // keep array in order.
- bool ordered_b_;
Axis axes_[2];
- Interval my_extent (Axis) const;
-
-
-
- bool contains_b (Score_element const *) const;
void add_element (Score_element*);
- /**
- add an element that only influences size, but does not have X/Y parent
- relationship with THIS.
- */
- void add_extra_element (Score_element*);
-
-
Axis_group_element ();
void set_axes (Axis,Axis);
*/
class Axis_group_item : public virtual Axis_group_element,
- public virtual Item {
-protected:
- virtual void do_breakable_col_processing();
+ public virtual Item
+{
public:
VIRTUAL_COPY_CONS(Score_element);
};
public virtual Spanner
{
- void do_break_processing_if_unbroken();
-protected:
- virtual void do_break_processing();
public:
VIRTUAL_COPY_CONS(Score_element);
};
#include "lily-proto.hh"
#include "directional-spanner.hh"
-#include "stem-info.hh"
/** a beam connects multiple stems.
class Beam : public Directional_spanner {
public:
- int stem_count ()const;
- Stem * stem (int )const;
+ int stem_count () const;
+ Stem* stem (int) const;
+ Stem* stem_top () const;
+ int visible_stem_count () const;
+ Stem* first_visible_stem () const;
+ Stem* last_visible_stem () const;
/**
the slope of the beam in (staffpositions) per (X-dimension, in PT).
/// position of leftmost end of beam
Real left_y_;
+ /**
+ highest number of beams present, for opening-up of beam-spacing
+ and calculation of stem lengths
+ */
+ int multiplicity_i_;
- /// maximum number of beams (for opening-up of beam-spacing)
- int multiple_i_;
-
- Array<Stem_info> sinfo_;
-
- Beam();
+ Beam ();
void add_stem (Stem*);
- Stem_info get_stem_info (Stem*);
void set_grouping (Rhythmic_grouping def, Rhythmic_grouping current);
void set_beaming (Beaming_info_list *);
Offset center () const;
Direction get_default_dir () const;
void set_direction (Direction);
- void set_steminfo ();
+ void set_stem_shorten ();
bool auto_knee (SCM gap, bool interstaff_b);
bool auto_knees ();
#define BREATHING_SIGN_HH
#include "item.hh"
-#include "staff-symbol-referencer.hh"
#include "parray.hh"
#include "directional-element.hh"
class Breathing_sign : public Item,
- public Staff_symbol_referencer,
public Directional_element
{
public:
#include "direction.hh"
#include "pointer.hh"
-#include "staff-symbol-referencer.hh"
+
/**
Set a clef in a staff.
change: is this a change clef (smaller size)?
*/
-class Clef_item : public Item, public Staff_symbol_referencer {
+class Clef_item : public Item
+{
protected:
virtual void do_pre_processing();
virtual Molecule* do_brew_molecule_p() const;
#define DOTS_HH
#include "item.hh"
-#include "staff-symbol-referencer.hh"
+
#include "directional-element.hh"
/**
The dots to go with a notehead/rest. A separate class, since they
are a party in collision resolution.
*/
-class Dots : public Item, public Staff_symbol_referencer,
+class Dots :
+ public Item,
public Directional_element
{
protected:
Group_interface (Score_element const*);
Group_interface (Score_element const*, String);
int count ();
- bool supports_interface_b ();
+ bool has_interface_b ();
void set_interface ();
void add_element (Score_element*);
};
#include "item.hh"
#include "array.hh"
-#include "staff-symbol-referencer.hh"
+
/// An item which places accidentals at the start of the line
-class Key_item :public Item, public Staff_symbol_referencer {
+class Key_item :public Item
+{
Array<int> pitch_arr_;
Array<int> acc_arr_;
Array<int> old_pitch_arr_;
#include "item.hh"
#include "array.hh"
#include "musical-pitch.hh"
-#include "staff-symbol-referencer.hh"
+
#include "note-head-side.hh"
struct Local_key_cautionary_tuple
*/
-class Local_key_item : public Note_head_side, public Staff_symbol_referencer {
+class Local_key_item : public Note_head_side
+{
Array<Local_key_cautionary_tuple> accidental_arr_;
Molecule accidental (int,bool,bool) const;
#define MULTI_MEASURE_REST_HH
#include "spanner.hh"
-#include "staff-symbol-referencer.hh"
-class Multi_measure_rest : public Spanner, public Staff_symbol_referencer
+
+class Multi_measure_rest : public Spanner
{
public:
Multi_measure_rest ();
virtual void do_add_processing ();
virtual void do_post_processing ();
- virtual void do_print () const;
virtual Array<Rod> get_rods () const;
};
*/
-class Note_head : public Rhythmic_head {
+class Note_head : public Rhythmic_head
+{
public:
-
Note_head ();
void flip_around_stem (Direction);
static int compare (Note_head * const &a, Note_head *const &b) ;
protected:
Molecule make_molecule () const;
-
static Interval dim_callback (Dimension_cache const*);
virtual void do_pre_processing();
class Rest : public Rhythmic_head
{
-public:
-
protected:
- virtual void do_add_processing ();
virtual void do_post_processing ();
virtual Molecule * do_brew_molecule_p () const;
};
#define RHYTHMIC_HEAD_HH
#include "item.hh"
-#include "staff-symbol-referencer.hh"
-class Rhythmic_head : public Item, public Staff_symbol_referencer
+
+class Rhythmic_head : public Item
{
- Dots * dots_l_;
- Stem * stem_l_;
public:
-
- int balltype_i_;
+ int balltype_i () const;
void add_dots (Dots *);
- Rhythmic_head ();
Stem * stem_l ()const;
Dots * dots_l ()const;
int dots_i ()const;
protected:
virtual void do_post_processing ();
-
- virtual void do_print () const;
};
#endif // RHYTHMIC_HEAD_HH
*/
SCM element_property_alist_;
- Link_array<Score_element> dependency_arr_;
/**
The lookup, determined by the font size. Cache this value.
*/
void set_elt_property (String, SCM val);
SCM remove_elt_property (String nm);
+ void Score_element::set_real (String, Real);
+ Real Score_element::get_real (String s) const;
+
/*
related classes.
*/
static SCM handle_broken_smobs (SCM, SCM criterion);
void recurse_into_smobs (SCM s, void (Score_element::*meth_ptr)());
-
+ virtual void do_break_processing ();
virtual Score_element *find_broken_piece (Line_of_score*) const;
protected:
be handled by GUILE gc. */
virtual ~Score_element ();
- Score_element* dependency (int) const;
- int dependency_size () const;
-
virtual void output_processing ();
static Interval molecule_extent (Dimension_cache const*);
/// do calculations after determining horizontal spacing
virtual void do_post_processing ();
- virtual void do_break_processing ();
-
virtual Link_array<Score_element> get_extra_dependencies () const;
static Interval dim_cache_callback (Dimension_cache const*);
--- /dev/null
+/*
+ side-position-interface.hh -- declare Side_position_interface
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+ */
+
+#ifndef SIDE_POSITION_INTERFACE_HH
+#define SIDE_POSITION_INTERFACE_HH
+
+#include "spanner.hh"
+#include "item.hh"
+
+#include "directional-element.hh"
+
+struct Side_position_interface
+{
+ Score_element * elt_l_;
+public:
+ Side_position_interface (Score_element const*);
+ static Real side_position (Dimension_cache const *);
+ static Real self_alignment (Dimension_cache const *);
+ static Real aligned_side (Dimension_cache const *);
+ static Real quantised_position (Dimension_cache const*);
+ void set_axis (Axis);
+ void set_quantised (Axis);
+ Axis get_axis () const;
+
+ bool supported_b () const;
+ bool has_interface_b () const;
+ void add_support (Score_element*);
+
+ Direction get_direction () const;
+ void set_direction (Direction);
+};
+
+
+#endif /* SIDE_POSITION_INTERFACE_HH */
+
friend Axis_group_spanner; // UGH
virtual void do_space_processing ();
- // void handle_broken_dependents ();
virtual void do_break_processing ();
Real spanner_length () const;
virtual Line_of_score*line_l () const;
#define STAFF_BAR_HH
#include "bar.hh"
-#include "staff-symbol-referencer.hh"
+
/**
A bar that is on a staff.
Ugh. Entita non multiplicandum ...
*/
-class Staff_bar : public Bar, public Staff_symbol_referencer
+class Staff_bar : public Bar
{
public:
- virtual void do_pre_processing ();
VIRTUAL_COPY_CONS(Score_element);
virtual Real get_bar_size () const;
};
/// this many lines.
int no_lines_i_;
Real staff_line_leading_f_;
+ Real staff_line_leading_f ();
+
Staff_symbol ();
int steps_i() const;
#include "real.hh"
-struct Stem_info {
- Real x_;
- Direction dir_;
- void set_direction (Direction d ) { dir_ = d; }
- Direction get_direction () const { return dir_; }
-
- int beam_dir_;
+struct Stem_info
+{
Real idealy_f_;
Real miny_f_;
Real maxy_f_;
- int mult_i_;
- Real interstaff_f_;
- Stem* stem_l_;
-
- Stem_info ();
- Stem_info (Stem *, int);
};
#endif // STEM_INFO_HH
#ifndef STEM_HH
#define STEM_HH
+
#include "item.hh"
#include "array.hh"
#include "moment.hh"
#include "molecule.hh"
-#include "staff-symbol-referencer.hh"
#include "directional-element.hh"
+#include "stem-info.hh"
/**the rule attached to the ball.
takes care of:
*/
-// todo: remove baseclass Staff_symbol_referencer, since stem
-// can be across a staff.
-class Stem : public Item, public Staff_symbol_referencer,
+class Stem : public Item,
public Directional_element
{
/**extent of the stem (positions).
fractional, since Beam has to adapt them.
*/
- Drul_array<Real> yextent_drul_;
+ Interval yextent_;
public:
-
-
/// log of the duration. Eg. 4 -> 16th note -> 2 flags
- int flag_i_;
+ int flag_i () const;
+
+ Drul_array<int> beams_i_drul_;
+
/**
don't print flag when in beam.
*/
Beam* beam_l () const;
Note_head * first_head () const;
-
- Drul_array<int> beams_i_drul_;
Stem ();
/// ensure that this Stem also encompasses the Notehead #n#
void add_head (Rhythmic_head*n);
Real hpos_f () const;
+ Stem_info calc_stem_info () const;
+
Real chord_start_f () const;
int type_i () const;
-
- void do_print() const;
void set_stemend (Real);
Direction get_default_dir() const;
#include "local-key-item.hh"
#include "bar.hh"
#include "timing-translator.hh"
+#include "staff-symbol-referencer.hh"
Key_engraver::Key_engraver ()
{
if (!item_p_)
{
item_p_ = new Key_item;
+ Staff_symbol_referencer_interface st (item_p_);
+ st.set_interface ();
+
item_p_->set_elt_property ("break-aligned", SCM_BOOL_T); // ugh
item_p_->multi_octave_b_ = key_.multi_octave_b_;
#include "paper-def.hh"
#include "lookup.hh"
#include "musical-pitch.hh"
+#include "staff-symbol-referencer.hh"
const int FLAT_TOP_PITCH=2; /* fes,ges,as and bes typeset in lower octave */
const int SHARP_TOP_PITCH=4; /* ais and bis typeset in lower octave */
Key_item::do_brew_molecule_p() const
{
Molecule*output = new Molecule;
- Real inter = staff_line_leading_f ()/2.0;
+
+ Staff_symbol_referencer_interface si (this);
+ Real inter = si.staff_line_leading_f ()/2.0;
int j;
if ((break_status_dir () == LEFT || break_status_dir () == CENTER)
broken_into_l_arr_.push (line_l);
}
-
- for (int i=0; i < broken_into_l_arr_.size (); i++)
- {
- broken_into_l_arr_[i]->handle_broken_dependencies ();
- }
-
- handle_broken_dependencies ();
}
void
#include "timing-translator.hh"
#include "engraver-group-engraver.hh"
#include "grace-align-item.hh"
+#include "staff-symbol-referencer.hh"
Local_key_engraver::Local_key_engraver()
{
if (!key_item_p_)
{
key_item_p_ = new Local_key_item;
+ Staff_symbol_referencer_interface si(key_item_p_);
+ si.set_interface ();
+
announce_element (Score_element_info (key_item_p_, 0));
}
*/
#include "local-key-item.hh"
#include "molecule.hh"
+#include "staff-symbol-referencer.hh"
#include "lookup.hh"
#include "paper-def.hh"
Local_key_item::do_brew_molecule_p() const
{
Molecule*output = new Molecule;
- Real note_distance = staff_line_leading_f ()/2;
+ Staff_symbol_referencer_interface si (this);
+ Real note_distance = si.staff_line_leading_f ()/2;
Molecule *octave_mol_p = 0;
int lastoct = -100;
#include "engraver-group-engraver.hh"
#include "timing-translator.hh"
#include "bar.hh"
+#include "staff-symbol-referencer.hh"
ADD_THIS_TRANSLATOR (Multi_measure_rest_engraver);
Timing_translator * time = dynamic_cast<Timing_translator*> (tr);
mmrest_p_ = new Multi_measure_rest;
+ Staff_symbol_referencer_interface si (mmrest_p_);
+ si.set_interface ();
+
+
if(dynamic_cast<Repetitions_req *> (multi_measure_req_l_))
mmrest_p_->set_elt_property ("alt-symbol",
ly_str02scm ("scripts-repeatsign"));
#include "misc.hh"
#include "group-interface.hh"
#include "stem.hh"
+#include "staff-symbol-referencer.hh"
Multi_measure_rest::Multi_measure_rest ()
{
set_elt_property ("columns", SCM_EOL);
}
-void
-Multi_measure_rest::do_print () const
-{
-#ifndef NPRINT
- DEBUG_OUT << "measures_i_ " << measures_i_;
-#endif
-}
+
}
mol_p->add_molecule (s);
- Real interline_f = staff_line_leading_f ();
+ Real interline_f
+ = staff_symbol_referencer_interface (this).staff_line_leading_f ();
if (measures_i_ == 1 && rest_symbol)
{
mol_p->translate_axis (interline_f, Y_AXIS);
#include "debug.hh"
#include "paper-def.hh"
#include "group-interface.hh"
+#include "staff-symbol-referencer.hh"
bool
Note_column::rest_b () const
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);
+ // 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_line_leading_f ()/2.0, Y_AXIS);
}
}
SCM 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_line_leading_f ();
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.lines_i ();
// move discretely by half spaces.
int discrete_dist = int (ceil (dist ));
*/
-#include "staff-side.hh"
+#include "side-position-interface.hh"
#include "note-head-side.hh"
void
Note_head_side::add_support (Item*head_l)
#include "molecule.hh"
#include "musical-request.hh"
#include "dimension-cache.hh"
+#include "staff-symbol-referencer.hh"
void
Note_head::flip_around_stem (Direction d)
void
Note_head::do_pre_processing ()
{
- Rhythmic_head::do_pre_processing ();
-
// 8 ball looks the same as 4 ball:
String type;
SCM style = get_elt_property ("style");
}
- if (balltype_i_ > 2 || type == "harmonic" || type == "cross")
- balltype_i_ = 2;
+ if (balltype_i () > 2 || type == "harmonic" || type == "cross")
+ set_elt_property ("duration-log", gh_int2scm (2));
- if (dots_l ()) // move into Rhythmic_head?
- dots_l ()->set_position(int (position_f ()));
+ if (Dots *d = dots_l ())
+ { // move into Rhythmic_head?
-
+ Staff_symbol_referencer_interface si (d);
+ Staff_symbol_referencer_interface me (this);
+
+ si.set_position(int (me.position_f ()));
+ }
}
-
-
int
Note_head::compare (Note_head *const &a, Note_head * const &b)
{
- return sign(a->position_f () - b->position_f ());
-}
-
+ Staff_symbol_referencer_interface s1(a);
+ Staff_symbol_referencer_interface s2(b);
+ return sign(s1.position_f () - s2.position_f ());
+}
Molecule
Note_head::make_molecule () const
}
return lookup_l()->afm_find (String ("noteheads-")
- + to_str (balltype_i_) + type);
+ + to_str (balltype_i ()) + type);
}
Molecule*
Note_head::do_brew_molecule_p() const
{
- Real inter_f = staff_line_leading_f ()/2;
- int sz = lines_i ()-1;
-
- int streepjes_i = abs (position_f ()) < sz
+ Staff_symbol_referencer_interface si (this);
+
+ Real inter_f = si.staff_line_leading_f ()/2;
+ int sz = si.lines_i ()-1;
+ Real p = si.position_f ();
+ int streepjes_i = abs (p) < sz
? 0
- : (abs((int)position_f ()) - sz) /2;
+ : (abs((int)p) - sz) /2;
Molecule* out = new Molecule (make_molecule ());
if (streepjes_i)
{
- Direction dir = (Direction)sign (position_f ());
+ Direction dir = (Direction)sign (p);
Interval hd = out->dim_[X_AXIS];
Real hw = hd.length ()/4;
= lookup_l ()->ledger_line (Interval (hd[LEFT] - hw,
hd[RIGHT] + hw));
- int parity = abs(int (position_f ())) % 2;
+ int parity = abs(int (p)) % 2;
for (int i=0; i < streepjes_i; i++)
{
#include "musical-request.hh"
#include "dots.hh"
#include "dot-column.hh"
+#include "staff-symbol-referencer.hh"
Note_heads_engraver::Note_heads_engraver()
{
for (int i=0; i < note_req_l_arr_.size (); i++)
{
Note_head *note_p = new Note_head;
+
+ Staff_symbol_referencer_interface si (note_p);
+ si.set_interface ();
+
+
Note_req * note_req_l = note_req_l_arr_[i];
- note_p->balltype_i_ = note_req_l->duration_.durlog_i_ <? 2;
+ note_p->set_elt_property ("duration-log",
+ gh_int2scm (note_req_l->duration_.durlog_i_ <? 2));
if (note_req_l->duration_.dots_i_)
{
Dots * d = new Dots;
+
+ Staff_symbol_referencer_interface sd (d);
+ sd.set_interface ();
+
note_p->add_dots (d);
d->dots_i_ = note_req_l->duration_.dots_i_;
announce_element (Score_element_info (d,0));
dot_p_arr_.push (d);
}
- note_p->set_position(note_req_l->pitch_.steps ());
+ si.set_position(note_req_l->pitch_.steps ());
/*
TODO: transparent note heads.
Array<Column_x_positions> breaking = calc_breaking ();
line_l_->break_into_pieces (breaking);
+ for (SCM s = element_smob_list_; gh_pair_p (s); s = gh_cdr (s))
+ {
+ Score_element *sc = unsmob_element (gh_car (s));
+ sc->do_break_processing ();
+ }
+ for (SCM s = element_smob_list_; gh_pair_p (s); s = gh_cdr (s))
+ {
+ Score_element *sc = unsmob_element (gh_car (s));
+ sc->handle_broken_dependencies ();
+ }
+
outputter_l_ = new Paper_outputter ;
outputter_l_->output_header ();
(c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
+#include "staff-symbol-referencer.hh"
#include "pitch-squash-engraver.hh"
#include "note-head.hh"
{
if (Note_head *nh = dynamic_cast<Note_head *> (i.elem_l_))
{
- nh->set_position(0);
+ Staff_symbol_referencer_interface (nh).set_position(0);
}
}
(c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-
+#include "staff-symbol-referencer.hh"
#include "rest-engraver.hh"
#include "musical-request.hh"
#include "dots.hh"
if (rest_req_l_ && !rest_p_)
{
rest_p_ = new Rest;
- rest_p_->balltype_i_ = rest_req_l_->duration_.durlog_i_;
-
+ Staff_symbol_referencer_interface si (rest_p_);
+ si.set_interface ();
+
+ rest_p_->set_elt_property ("duration-log",
+ gh_int2scm (rest_req_l_->duration_.durlog_i_));
+
if (rest_req_l_->duration_.dots_i_)
{
dot_p_ = new Dots;
+
+ Staff_symbol_referencer_interface si (dot_p_);
+ si.set_interface ();
+
rest_p_->add_dots (dot_p_);
dot_p_->dots_i_ = rest_req_l_->duration_.dots_i_;
announce_element (Score_element_info (dot_p_,0));
#include "dots.hh"
#include "axis-group-element.hh"
#include "paper-score.hh"
+#include "staff-symbol-referencer.hh"
-void
-Rest::do_add_processing ()
-{
- if (balltype_i_ == 0)
- set_position (position_f () + 2);
-
- Rhythmic_head::do_add_processing ();
-}
void
Rest::do_post_processing ()
{
- Rhythmic_head::do_post_processing ();
- if (dots_l ()
- && balltype_i_ > 4) // UGH.
+ if (balltype_i () == 0)
+ {
+ Staff_symbol_referencer_interface si (this);
+ si.set_position (si.position_f () + 2);
+ }
+
+ Dots * d = dots_l ();
+ if (d && balltype_i () > 4) // UGH.
{
/*
UGH.
*/
- if (balltype_i_ == 7)
- dots_l ()->set_position (4);
- else
- dots_l ()->set_position (3);
+ staff_symbol_referencer_interface (d)
+ .set_position ((balltype_i () == 7) ? 4 : 3);
}
}
{
bool ledger_b =false;
- if (balltype_i_ == 0 || balltype_i_ == 1)
- ledger_b = abs(position_f () - (2* balltype_i_ - 1)) > lines_i ();
-
+ if (balltype_i () == 0 || balltype_i () == 1)
+ {
+ Staff_symbol_referencer_interface si(this);
+ ledger_b = abs(si.position_f () - (2* balltype_i () - 1))
+ > si.lines_i ();
+ }
String style;
SCM style_sym =get_elt_property ("style");
- if (balltype_i_ >= 2 && style_sym != SCM_UNDEFINED)
+ if (balltype_i () >= 2 && style_sym != SCM_UNDEFINED)
{
style = ly_scm2string (style_sym);
}
- String idx = ("rests-") + to_str (balltype_i_) + (ledger_b ? "o" : "") + style;
+ String idx = ("rests-") + to_str (balltype_i ()) + (ledger_b ? "o" : "") + style;
return new Molecule(lookup_l ()->afm_find (idx));
}
#include "axis-group-element.hh"
#include "paper-score.hh"
#include "stem.hh"
+#include "staff-symbol-referencer.hh"
Dots*
return dynamic_cast<Dots*> (unsmob_element (s));
}
+int
+Rhythmic_head::balltype_i () const
+{
+ SCM s = get_elt_property ("duration-log");
+
+ return gh_number_p (s) ? gh_scm2int (s) : 0;
+}
+
Stem*
Rhythmic_head::stem_l () const
{
void
Rhythmic_head::do_post_processing ()
{
- if (dots_l ())
+ if (Dots *d = dots_l ())
{
- dots_l ()->set_position(int (position_f ()));
+ Staff_symbol_referencer_interface si (d);
+ Staff_symbol_referencer_interface me (d);
+ si.set_position(int (me.position_f ()));
}
}
dot_l->add_dependency (this);
}
-Rhythmic_head::Rhythmic_head ()
-{
- balltype_i_ =0;
-}
-
-
-
-void
-Rhythmic_head::do_print () const
-{
-#ifndef NPRINT
- DEBUG_OUT << "balltype = "<< balltype_i_ << "dots = " << dots_i ();
-#endif
-}
#include <string.h>
+#include "group-interface.hh"
#include "misc.hh"
#include "paper-score.hh"
#include "paper-def.hh"
#include "misc.hh"
#include "paper-outputter.hh"
#include "dimension-cache.hh"
-#include "staff-side.hh"
+#include "side-position-interface.hh"
#include "item.hh"
-
Score_element::Score_element()
{
output_p_ =0;
element_property_alist_ = SCM_EOL;
smobify_self ();
+
+
+ set_elt_property ("dependencies", SCM_EOL);
}
SCM ly_deep_copy (SCM);
should protect because smobify_self () might trigger GC.
*/
element_property_alist_ = scm_protect_object (ly_deep_copy (s.element_property_alist_));
- dependency_arr_ = s.dependency_arr_;
+
output_p_ =0;
status_i_ = s.status_i_;
lookup_l_ = s.lookup_l_;
delete dim_cache_[Y_AXIS];
}
-Score_element*
-Score_element::dependency (int i) const
+
+Real
+Score_element::get_real (String s) const
{
- return dependency_arr_ [i];
+ return gh_scm2double (get_elt_property (s));
}
-int
-Score_element::dependency_size () const
+void
+Score_element::set_real (String s, Real r)
{
- return dependency_arr_.size ();
+ set_elt_property (s, gh_double2scm (r));
}
// should also have one that takes SCM arg.
if (flower_dstream && !flower_dstream->silent_b ("Score_element"))
ly_display_scm (element_property_alist_);
- DEBUG_OUT << "dependencies: " << dependency_size();
if (original_l_)
DEBUG_OUT << "Copy ";
do_print();
Paper_def*
Score_element::paper_l () const
{
- return pscore_l_->paper_l_;
+ return pscore_l_ ? pscore_l_->paper_l_ : 0;
}
Lookup const *
assert (status_i_!= busy);
status_i_= busy;
- for (int i=0; i < dependency_arr_.size(); i++)
- dependency_arr_[i]->calculate_dependencies (final, busy, funcptr);
+ Link_array<Score_element> dependency_arr =
+ Group_interface__extract_elements (this, (Score_element*)0, "dependencies");
+
+ for (int i=0; i < dependency_arr.size(); i++)
+ dependency_arr[i]->calculate_dependencies (final, busy, funcptr);
Link_array<Score_element> extra (get_extra_dependencies());
for (int i=0; i < extra.size(); i++)
void
Score_element::do_break_processing()
{
- handle_broken_dependencies();
}
void
{
if (e)
{
- dependency_arr_.push (e);
- e->used_b_ = true;
+ Group_interface gi (this, "dependencies");
+ gi.add_element (e);
}
else
programming_error ("Null dependency added");
gh_set_car_x (s, handle_broken_smobs (gh_car (s), criterion));
gh_set_cdr_x (s, handle_broken_smobs (gh_cdr (s), criterion));
- if (gh_car (s) == SCM_UNDEFINED && gh_list_p (gh_cdr(s)))
- return gh_cdr (s);
+ SCM c = gh_cdr(s);
+
+ // gh_list_p () is linear, this is O(1)
+ bool list = gh_pair_p (c) || c == SCM_EOL;
+
+ if (gh_car (s) == SCM_UNDEFINED && list)
+ return c;
}
return s;
}
-
+#if 0
void
Score_element::recurse_into_smobs (SCM s, void (Score_element::*meth_ptr)())
{
recurse_into_smobs (gh_cdr (s), meth_ptr);
}
}
+#endif
void
Score_element::handle_broken_dependencies()
line ? line->self_scm_ : SCM_UNDEFINED);
- recurse_into_smobs (element_property_alist_,
- &Score_element::handle_broken_dependencies);
-
if (!line)
return;
-
-
- Link_array<Score_element> new_deps;
-
- for (int i=0; i < dependency_size(); i++)
- {
- Score_element * elt = dependency (i);
- if (elt->line_l() != line)
- {
- Score_element * broken = elt->find_broken_piece (line);
- elt = broken ;
- }
- if (elt)
- new_deps.push (elt);
- }
- dependency_arr_ = new_deps;
}
void
Score_element::invalidate_cache (Axis a)
{
- dim_cache_[a]->invalidate ();
+ // dim_cache_[a]->invalidate ();
}
Score_element*
#include "engraver.hh"
#include "script-column.hh"
-#include "staff-side.hh"
+#include "side-position-interface.hh"
#include "dimension-cache.hh"
/**
if (!thing)
return;
- if (Side_position_interface (thing).is_staff_side_b ())
+ if (Side_position_interface (thing).has_interface_b ())
{
if (!thing->breakable_b () && Side_position_interface (thing).get_axis () == Y_AXIS)
{
*/
#include "script-column.hh"
-#include "staff-side.hh"
+#include "side-position-interface.hh"
#include "dimension-cache.hh"
#include "group-interface.hh"
#include "script-engraver.hh"
#include "script.hh"
-#include "staff-side.hh"
+#include "side-position-interface.hh"
#include "musical-request.hh"
#include "stem.hh"
#include "staff-symbol.hh"
continue;
}
Script *p =new Script;
- Side_position_interface stafy (p);
+ Side_position_interface stafy (p);
+
list = gh_cdr (list);
p->set_elt_property ("molecule",
#include "debug.hh"
#include "script.hh"
#include "lookup.hh"
-#include "staff-side.hh"
+#include "side-position-interface.hh"
#include "paper-def.hh"
#include "dimension-cache.hh"
span_p->set_bounds(RIGHT,bounds[RIGHT]);
pscore_l_->typeset_element (span_p);
- span_p->handle_broken_dependencies();
-
broken_into_l_arr_.push (span_p);
}
Spanner::do_break_processing()
{
break_into_pieces ();
- handle_broken_dependencies();
}
Spanner::Spanner ()
Spanner::find_broken_piece (Line_of_score*l) const
{
Spanner* me = (Spanner*) this;
- break_into_pieces ();
+ me->break_into_pieces ();
int idx = binsearch_link_array (broken_into_l_arr_, (Spanner*)l, Spanner::compare);
if(sc != NULL &&
sc->break_status_dir () == RIGHT)
{
- // We could possibly return the right edge of the whole Score_column here,
- // but we do a full search for the Break_align_item.
-
/*
- In fact that doesn't make a difference, since the Score_column
+
+ We used to do a full search for the Break_align_item.
+ But that doesn't make a difference, since the Score_column
is likely to contain only a Break_align_item.
*/
-#if 0
- for(SCM s = sc->get_elt_property ("elements"); gh_pair_p (s);
- s = gh_cdr (s))
- {
- Score_element *e = SMOB_TO_TYPE (Score_element, gh_car (s));
- if(dynamic_cast<Break_align_item*> (e))
- {
- return e->extent (X_AXIS) [RIGHT];
- }
- }
-#endif
return sc->extent (X_AXIS)[RIGHT];
}
*/
#include "staff-bar.hh"
+#include "staff-symbol-referencer.hh"
Real
Staff_bar::get_bar_size () const
if (gh_number_p (size))
return gh_scm2double (size);
else
- return (lines_i () -1) * staff_line_leading_f ();
+ {
+ Staff_symbol_referencer_interface si (this);
+ return (si.lines_i () -1) * si.staff_line_leading_f ();
+ }
}
-void
-Staff_bar::do_pre_processing ()
-{
- Bar::do_pre_processing ();
- Staff_symbol_referencer::do_pre_processing ();
-}
#include "bar.hh"
#include "timing-translator.hh"
#include "text-item.hh"
-#include "staff-side.hh"
+#include "side-position-interface.hh"
ADD_THIS_TRANSLATOR (Staff_margin_engraver);
--- /dev/null
+/*
+ staff-sym-reg.cc -- implement Staff_symbol_engraver
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
+
+#include "staff-symbol.hh"
+#include "score.hh"
+#include "paper-column.hh"
+#include "paper-def.hh"
+#include "side-position-interface.hh"
+#include "engraver.hh"
+#include "moment.hh"
+
+/**
+ Manage the staff symbol.
+ */
+class Staff_symbol_engraver : public Engraver {
+ Staff_symbol *span_p_;
+public:
+ VIRTUAL_COPY_CONS(Translator);
+ Staff_symbol_engraver();
+
+protected:
+ virtual ~Staff_symbol_engraver();
+
+ virtual void acknowledge_element (Score_element_info);
+ virtual void do_removal_processing();
+ virtual void do_creation_processing();
+
+};
+
+
+Staff_symbol_engraver::~Staff_symbol_engraver()
+{
+ assert (!span_p_);
+}
+
+Staff_symbol_engraver::Staff_symbol_engraver()
+{
+ span_p_ = 0;
+}
+
+void
+Staff_symbol_engraver::do_creation_processing()
+{
+ span_p_ = new Staff_symbol;
+ span_p_->set_bounds(LEFT,get_staff_info().command_pcol_l ());
+ announce_element (Score_element_info (span_p_, 0));
+}
+
+void
+Staff_symbol_engraver::do_removal_processing()
+{
+ SCM l (get_property ("numberOfStaffLines", 0));
+ if (gh_number_p(l))
+ {
+ span_p_->no_lines_i_ = gh_scm2int (l);
+ }
+
+ SCM sz (get_property ("staffLineLeading", 0));
+ if (gh_number_p(sz))
+ {
+ span_p_->staff_line_leading_f_ = gh_scm2double (sz);
+ }
+ else
+ {
+ span_p_->staff_line_leading_f_ = paper_l ()->get_var ("interline");
+ }
+ span_p_->set_bounds(RIGHT,get_staff_info().command_pcol_l ());
+ typeset_element (span_p_);
+ span_p_ =0;
+}
+
+void
+Staff_symbol_engraver::acknowledge_element (Score_element_info s)
+{
+ s.elem_l_->set_elt_property ("staff-symbol", span_p_->self_scm_);
+ s.elem_l_->add_dependency (span_p_); // UGH. UGH. UGH
+
+ SCM ss =s.elem_l_->remove_elt_property ("staff-support");
+ if (gh_boolean_p (ss) && gh_scm2bool (ss))
+ {
+ Side_position_interface si (s.elem_l_);
+ if (si.has_interface_b ())
+ si.add_support (span_p_);
+ }
+}
+
+
+ADD_THIS_TRANSLATOR(Staff_symbol_engraver);
+
--- /dev/null
+/*
+ staffsym.cc -- implement Staff_symbol
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
+#include "staff-symbol.hh"
+#include "lookup.hh"
+#include "dimensions.hh"
+#include "paper-def.hh"
+#include "molecule.hh"
+#include "debug.hh"
+#include "item.hh"
+
+
+Staff_symbol::Staff_symbol ()
+{
+ no_lines_i_ = 5;
+ staff_line_leading_f_ = 5.0 PT;
+}
+
+void
+Staff_symbol::do_print() const
+{
+#ifndef NPRINT
+ Spanner::do_print();
+ DEBUG_OUT << "lines: " << no_lines_i_;
+#endif
+}
+
+
+Molecule*
+Staff_symbol::do_brew_molecule_p() const
+{
+ Score_element * common
+ = spanned_drul_[LEFT]->common_refpoint (spanned_drul_[RIGHT], X_AXIS);
+
+#if 0
+ Interval r = spanned_drul_[RIGHT]->extent (X_AXIS);
+ Interval l = spanned_drul_[LEFT]->extent (X_AXIS);
+
+ Real left_shift =l.empty_b () ? 0.0: l[LEFT];
+ Real right_shift =r.empty_b () ? 0.0: r[RIGHT];
+#endif
+ Real width =
+ // right_shift - left_shift
+ + spanned_drul_[RIGHT]->relative_coordinate (common , X_AXIS)
+ - spanned_drul_[LEFT]->relative_coordinate (common, X_AXIS)
+ ;
+
+ Real t = paper_l ()->get_var ("stafflinethickness");
+ Molecule rule = lookup_l ()->filledbox (Box (Interval (0,width),
+ Interval (-t/2, t/2)));
+
+ Real height = (no_lines_i_-1) * staff_line_leading_f_ /2;
+ Molecule * m = new Molecule;
+ for (int i=0; i < no_lines_i_; i++)
+ {
+ Molecule a (rule);
+ a.translate_axis (height - i * staff_line_leading_f_, Y_AXIS);
+ m->add_molecule (a);
+ }
+
+ // m->translate_axis (left_shift, X_AXIS);
+ return m;
+}
+
+
+int
+Staff_symbol::steps_i() const
+{
+ return no_lines_i_*2;
+}
+Real
+Staff_symbol::staff_line_leading_f ()
+{
+ return staff_line_leading_f_;
+}
(c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
+#include "staff-symbol-referencer.hh"
#include "stem-engraver.hh"
#include "note-head.hh"
#include "stem.hh"
if (!stem_p_)
{
stem_p_ = new Stem;
- stem_p_->flag_i_ = duration_log;
+ Staff_symbol_referencer_interface st(stem_p_);
+ st.set_interface ();
+
+ stem_p_->set_elt_property ("duration-log", gh_int2scm (duration_log));
if (abbrev_req_l_)
{
announce_element (Score_element_info (stem_p_, r));
}
- if (stem_p_->flag_i_ != duration_log)
+ if (stem_p_->flag_i () != duration_log)
{
- r->warning (_f ("Adding note head to incompatible stem (type = %d)", 1 << stem_p_->flag_i_));
+ r->warning (_f ("Adding note head to incompatible stem (type = %d)", 1 << stem_p_->flag_i ()));
}
stem_p_->add_head (h);
// UGH. Should mark non-forced instead.
SCM dir = stem_p_->get_elt_property ("direction");
- if (gh_number_p (dir) && gh_int2scm (dir))
+ if (gh_number_p (dir) && to_dir(dir))
{
stem_p_->set_elt_property ("dir-forced", SCM_BOOL_T);
}
#include "stem.hh"
#include "offset.hh"
#include "dimension-cache.hh"
+#include "staff-symbol-referencer.hh"
+
Stem_tremolo::Stem_tremolo ()
{
Stem_tremolo::dim_callback (Dimension_cache const *c)
{
Stem_tremolo * s = dynamic_cast<Stem_tremolo*> (c->element_l ());
- Real space = s->stem_l ()->staff_line_leading_f ();
+ Real space = Staff_symbol_referencer_interface (s->stem_l ())
+ .staff_line_leading_f ();
return Interval (-space, space);
}
int mult =0;
if (Beam * b = st->beam_l ())
{
- Stem_info i = b->get_stem_info (st);
- mult = i.mult_i_;
+ mult = b->multiplicity_i_;
}
Real interbeam_f = paper_l ()->interbeam_f (mult);
Real w = gh_scm2double (get_elt_property ("beam-width"));
- Real space = st->staff_line_leading_f ();
- Real internote_f = space/2;
-
+ Real space = Staff_symbol_referencer_interface (st).staff_line_leading_f ();
+ Real internote_f = space / 2;
Real beam_f = gh_scm2double (get_elt_property ("beam-thickness"));
int beams_i = 0;
- Real slope_f = internote_f / 4 / internote_f; // HUH?
+ Real slope_f = 0.25;
if (st && st->beam_l ()) {
slope_f = st->beam_l ()->slope_f_;
// ugh, rather calc from Stem_tremolo_req
beams_i = st->beams_i_drul_[RIGHT] >? st->beams_i_drul_[LEFT];
}
- Real sl = slope_f * internote_f;
- Molecule a (lookup_l ()->beam (sl, w, beam_f));
+ Molecule a (lookup_l ()->beam (slope_f, w, beam_f));
a.translate (Offset (-w/2, w / 2 * slope_f));
Molecule *beams= new Molecule;
? -st->get_direction () * st->note_delta_f ()/2
: 0.0;
- /*
- UGH. Internote fudging.
- */
- dy /= internote_f;
dy += st->stem_end_f ();
- dy *= internote_f;
beams->translate (Offset(st->hpos_f () - hpos_f ()+
whole_note_correction, dy));
}
source file of the GNU LilyPond music typesetter
(c) 1996, 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ Jan Nieuwenhuizen <janneke@gnu.org>
TODO: This is way too hairy
*/
#include "beam.hh"
#include "rest.hh"
#include "group-interface.hh"
+#include "cross-staff.hh"
+#include "staff-symbol-referencer.hh"
Stem::Stem ()
{
beams_i_drul_[LEFT] = beams_i_drul_[RIGHT] = -1;
- yextent_drul_[DOWN] = yextent_drul_[UP] = 0;
- flag_i_ = 2;
}
Interval_t<int>
Interval_t<int> r;
for (int i =0; i < head_l_arr.size (); i++)
{
- int p = (int)head_l_arr[i]->position_f ();
+ Staff_symbol_referencer_interface si (head_l_arr[i]);
+ int p = (int)si.position_f ();
r[BIGGER] = r[BIGGER] >? p;
r[SMALLER] = r[SMALLER] <? p;
}
return r;
}
-void
-Stem::do_print () const
-{
-#ifndef NPRINT
- DEBUG_OUT << "flag "<< flag_i_;
-#endif
-}
Real
Stem::stem_length_f () const
{
- return yextent_drul_[UP]-yextent_drul_[DOWN] ;
+ return yextent_.length();
}
Real
Stem::stem_begin_f () const
{
- return yextent_drul_[Direction(-get_direction ())];
+ return yextent_[Direction(-get_direction ())];
}
Real
Stem::chord_start_f () const
{
- return head_positions()[get_direction ()] * staff_line_leading_f ()/2.0;
+ return head_positions()[get_direction ()]
+ * Staff_symbol_referencer_interface (this).staff_line_leading_f ()/2.0;
}
Real
Stem::stem_end_f () const
{
- return yextent_drul_[get_direction ()];
+ return yextent_[get_direction ()];
}
void
warning (_ ("Weird stem size; check for narrow beams"));
- yextent_drul_[get_direction ()] = se;
- yextent_drul_[Direction(-get_direction ())] = head_positions()[-get_direction ()];
+ yextent_[get_direction ()] = se;
+ yextent_[Direction(-get_direction ())] = head_positions()[-get_direction ()];
}
int
Stem::type_i () const
{
-
- return first_head ()->balltype_i_;
+ return first_head ()->balltype_i ();
}
Note_head*
bool
Stem::invisible_b () const
{
- return !(first_head () && first_head()->balltype_i_ >= 1);
+ return !(first_head () && first_head()->balltype_i () >= 1);
}
int
return Direction (int(paper_l ()->get_var ("stem_default_neutral_direction")));
}
-
-
void
Stem::set_default_stemlen ()
{
if (((int)chord_start_f ())
&& (get_direction () != get_default_dir ()))
length_f -= shorten_f;
-
- if (flag_i_ >= 5)
+
+ if (flag_i () >= 5)
length_f += 2.0;
- if (flag_i_ >= 6)
+ if (flag_i () >= 6)
length_f += 1.0;
set_stemend ((get_direction () > 0) ? head_positions()[BIGGER] + length_f:
set_stemend (0);
}
+int
+Stem::flag_i () const
+{
+ SCM s = get_elt_property ("duration-log");
+ return (gh_number_p (s)) ? gh_scm2int (s) : 2;
+}
+
//xxx
void
Stem::set_default_extents ()
head_l_arr.top ()->set_elt_property ("extremal", SCM_BOOL_T);
int parity=1;
- int lastpos = int (beginhead->position_f ());
+ int lastpos = int (Staff_symbol_referencer_interface (beginhead).position_f ());
for (int i=1; i < head_l_arr.size (); i ++)
{
- int dy =abs (lastpos- (int)head_l_arr[i]->position_f ());
+ Real p = Staff_symbol_referencer_interface (head_l_arr[i]).position_f ();
+ int dy =abs (lastpos- (int)p);
if (dy <= 1)
{
}
else
parity = 1;
- lastpos = int (head_l_arr[i]->position_f ());
+ lastpos = int (p);
}
}
void
Stem::do_pre_processing ()
{
- if (yextent_drul_[DOWN]== yextent_drul_[UP])
+ if (yextent_.empty_b ())
set_default_extents ();
set_noteheads ();
char c = (get_direction () == UP) ? 'u' : 'd';
Molecule m = lookup_l ()->afm_find (String ("flags-") + to_str (c) +
- to_str (flag_i_));
+ to_str (flag_i ()));
if (!style.empty_b ())
m.add_molecule(lookup_l ()->afm_find (String ("flags-") + to_str (c) + style));
return m;
Stem * s = dynamic_cast<Stem*> (c->element_l ());
Interval r (0, 0);
- if (s->get_elt_property ("beam") != SCM_UNDEFINED || abs (s->flag_i_) <= 2)
+ if (s->get_elt_property ("beam") != SCM_UNDEFINED || abs (s->flag_i ()) <= 2)
; // TODO!
else
{
Stem::do_brew_molecule_p () const
{
Molecule *mol_p =new Molecule;
- Drul_array<Real> stem_y = yextent_drul_;
- Real dy = staff_line_leading_f ()/2.0;
+ Interval stem_y = yextent_;
+ Real dy = staff_symbol_referencer_interface (this)
+ .staff_line_leading_f ()/2.0;
Real head_wid = 0;
if (first_head ())
}
if (get_elt_property ("beam") == SCM_UNDEFINED
- && abs (flag_i_) > 2)
+ && abs (flag_i ()) > 2)
{
Molecule fl = flag ();
fl.translate_axis(stem_y[get_direction ()]*dy, Y_AXIS);
SCM b= get_elt_property ("beam");
return dynamic_cast<Beam*> (unsmob_element (b));
}
+
+
+Stem_info
+Stem::calc_stem_info () const
+{
+ assert (beam_l ());
+
+ SCM bd = get_elt_property ("beam-dir");
+ Real internote_f
+ = staff_symbol_referencer_interface (this).staff_line_leading_f ()/2;
+
+ Direction beam_dir;
+ Stem_info info;
+
+ if (isdir_b (bd))
+ {
+ beam_dir = to_dir (bd);
+ }
+ else
+ {
+ programming_error ("Beam direction not set.");
+ beam_dir = UP; // GURAUGRNAGURAGU! urg !
+ }
+
+ Real interbeam_f = paper_l ()->interbeam_f (beam_l ()->multiplicity_i_);
+ Real beam_f = gh_scm2double (beam_l ()->get_elt_property ("beam-thickness"));
+
+ info.idealy_f_ = chord_start_f ();
+
+ // for simplicity, we calculate as if dir == UP
+ info.idealy_f_ *= beam_dir;
+
+ bool grace_b = get_elt_property ("grace") != SCM_UNDEFINED;
+ bool no_extend_b = get_elt_property ("no-stem-extend") != SCM_UNDEFINED;
+
+ int stem_max = (int)rint(paper_l ()->get_var ("stem_max"));
+ String type_str = grace_b ? "grace_" : "";
+ Real min_stem_f = paper_l ()->get_var (type_str + "minimum_stem_length"
+ + to_str (beam_l ()->multiplicity_i_ <? stem_max)) * internote_f;
+ Real stem_f = paper_l ()->get_var (type_str + "stem_length"
+ + to_str (beam_l ()->multiplicity_i_ <? stem_max)) * internote_f;
+
+ if (!beam_dir || (beam_dir == get_direction ()))
+ /* normal beamed stem */
+ {
+ if (beam_l ()->multiplicity_i_)
+ {
+ info.idealy_f_ += beam_f;
+ info.idealy_f_ += (beam_l ()->multiplicity_i_ - 1) * interbeam_f;
+ }
+ info.miny_f_ = info.idealy_f_;
+ info.maxy_f_ = INT_MAX;
+
+ info.idealy_f_ += stem_f;
+ info.miny_f_ += min_stem_f;
+
+ /*
+ lowest beam of (UP) beam must never be lower than second staffline
+
+ Hmm, reference (Wanske?)
+
+ Although this (additional) rule is probably correct,
+ I expect that highest beam (UP) should also never be lower
+ than middle staffline, just as normal stems.
+
+ */
+ if (!grace_b && !no_extend_b)
+ {
+ //highest beam of (UP) beam must never be lower than middle staffline
+ info.miny_f_ = info.miny_f_ >? 0;
+ //lowest beam of (UP) beam must never be lower than second staffline
+ info.miny_f_ = info.miny_f_ >? (- 2 * internote_f - beam_f
+ + (beam_l ()->multiplicity_i_ > 0) * beam_f + interbeam_f * (beam_l ()->multiplicity_i_ - 1));
+ }
+ }
+ else
+ /* knee */
+ {
+ info.idealy_f_ -= beam_f;
+ info.maxy_f_ = info.idealy_f_;
+ info.miny_f_ = -INT_MAX;
+
+ info.idealy_f_ -= stem_f;
+ info.maxy_f_ -= min_stem_f;
+ }
+
+ info.idealy_f_ = info.maxy_f_ <? info.idealy_f_;
+ info.idealy_f_ = info.miny_f_ >? info.idealy_f_;
+
+ Real interstaff_f = calc_interstaff_dist (this, beam_l ());
+ info.idealy_f_ += interstaff_f * beam_dir;
+
+ SCM s = get_elt_property ("shorten");
+ if (s != SCM_UNDEFINED)
+ info.idealy_f_ -= gh_double2scm (s);
+ info.miny_f_ += interstaff_f * beam_dir;
+ info.maxy_f_ += interstaff_f * beam_dir;
+
+ return info;
+}
+
#include "note-head.hh"
#include "paper-column.hh"
#include "debug.hh"
-#include "group-interface.hh"
-
-
-
+#include "staff-symbol-referencer.hh"
void
Tie::set_head (Direction d, Note_head * head_l)
assert (!head (d));
if (d == LEFT)
gh_set_car_x (get_elt_property ("heads"), head_l->self_scm_ );
- else if (d == LEFT)
+ else if (d == RIGHT)
gh_set_cdr_x (get_elt_property ("heads"), head_l->self_scm_ );
set_bounds (d, head_l);
Direction
Tie::get_default_dir () const
{
- int m = int (head (LEFT)->position_f ()
- + head (RIGHT)->position_f ()) /2;
+ Real p1 = Staff_symbol_referencer_interface (head (LEFT)).position_f () ;
+ Real p2 = Staff_symbol_referencer_interface (head (RIGHT)).position_f () ;
+
+ int m = int (p1 + p2);
/*
If dir is not determined: inverse of stem: down
void
Tie::do_post_processing()
{
- assert (head (LEFT) || head (RIGHT));
+ if (!head (LEFT) && !head (RIGHT))
+ {
+ programming_error ("Tie without heads.");
+ set_elt_property ("transparent", SCM_BOOL_T);
+ set_empty (X_AXIS);
+ set_empty (Y_AXIS);
+ return;
+ }
Real interline_f = paper_l ()->get_var ("interline");
Real internote_f = interline_f / 2;
for smal slurs
*/
- Real ypos = head (LEFT) ? head (LEFT)->position_f ()
- : head (RIGHT)->position_f ();
+
+ Real ypos = head (LEFT)
+ ? Staff_symbol_referencer_interface (head (LEFT)).position_f ()
+ : Staff_symbol_referencer_interface (head (RIGHT)).position_f () ;
Real y_f = internote_f * ypos;
int ypos_i = int (ypos);
bool
Vertical_align_engraver::qualifies_b (Score_element_info i) const
{
-#if 0
- Translator * t = i.origin_trans_l_arr_[0];
-#endif
int sz = i.origin_trans_l_arr_.size() ;
-#if 0
- return (sz == 1 && dynamic_cast<Translator_group*> (t))
- || (sz == 2 && dynamic_cast<Axis_group_engraver*> (t));
-#endif
Axis_group_element * elt = dynamic_cast<Axis_group_element *> (i.elem_l_);
%{ Specify length of stems for notes in the staff
that don't have beams.
- Measured in staff positions.
+ Measured in staff positions.
%}
stem_length0 = 7.;
stem_length1 = 5.;
% only used for beams
minimum_stem_length0 = 0.0 ; % not used
-minimum_stem_length1 = 3. ;
+minimum_stem_length1 = 3.;
minimum_stem_length2 = 2.5;
minimum_stem_length3 = 2.0;