From: Han-Wen Nienhuys Date: Wed, 5 Jul 2000 13:41:25 +0000 (+0200) Subject: release: 1.3.70 X-Git-Tag: release/1.3.70 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=3c2f386f1385a10dafbb811be245f5a75d6b132c;p=lilypond.git release: 1.3.70 ====== * Cleanup auto-beam-engraver: use properties for retrieving timing information. * Fixed: Multi measure rests don't cause crashes. * Fixed: don't invoke Hara_kiri::consider_suicide too early. * Fixed: property engraver. * Fixed: don't crash on multiple ties. * Cleanups of Beam, should also be a little faster. * Reunite properties and pointers. In implementation we make a distinction between mutable and immutable properties * Add {has|set}_interface () static methods to interface classes. * Made Side_position_interface and Staff_symbol_interface an all statics class, and stripped _interface suffix. * Make Align_interface and Axis_group_interface an all-statics class * Rhythmic_head, Staff_symbol, Grace_align_item, Break_align_item, Bar, Span_bar are now interfaces, Staff_bar was removed. Use a callback for determining barsize. * Removed all GLUE_SCORE_ELEMENT callbacks. * Added test for repeats to trip.ly 1.3 --- diff --git a/CHANGES b/CHANGES index 36ed28852a..fd106120c2 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,18 @@ -1.3.68.hwn1 -=========== +* Fixed: long standing problem in optical-illusion code. + +* Fixed: stop beam if stem *has* a beam in auto-beam-engraver. + +* Made interface of Multi_measure_rest, System_start_delimiter, +Spacing_spanner, Separating_group_spanner, Beam, Slur and +Rhythmic_head. + +* Use properties for minimum distances and spring parameters. Move +spacing related functions from Paper_column into Spaceable_element. + +* Removed most Paper_column typecasts. + +1.3.69 +====== * Cleanup auto-beam-engraver: use properties for retrieving timing information. @@ -32,8 +45,6 @@ callback for determining barsize. * Added test for repeats to trip.ly -* - 1.3.68 ====== diff --git a/VERSION b/VERSION index 45f7a19dcf..7da8041297 100644 --- a/VERSION +++ b/VERSION @@ -1,8 +1,8 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=3 -PATCH_LEVEL=69 -MY_PATCH_LEVEL=cb1 +PATCH_LEVEL=70 +MY_PATCH_LEVEL= # use the above to send patches: MY_PATCH_LEVEL is always empty for a # released version. diff --git a/buildscripts/ps-to-pfa.py b/buildscripts/ps-to-pfa.py index 796c5d8b37..ef3c94a291 100755 --- a/buildscripts/ps-to-pfa.py +++ b/buildscripts/ps-to-pfa.py @@ -21,6 +21,8 @@ from string import * import re import time +logfile = sys.stdout + def program_id (): return name + ' version ' + version; @@ -58,19 +60,19 @@ for opt in options: def gulp_file (f): - sys.stderr.write ('[%s' % f) + logfile.write ('[%s' % f) try: i = open (f) i.seek (0, 2) n = i.tell () i.seek (0,0) except: - sys.stderr.write ('can\'t open file %s\n ' % f) + logfile.write ('can\'t open file %s\n ' % f) return '' s = i.read (n) - sys.stderr.write (']') + logfile.write (']') if len (s) <= 0: - sys.stderr.write ('gulped empty file: %s\n'% f) + logfile.write ('gulped empty file: %s\n'% f) return s mf = files[0] @@ -81,7 +83,7 @@ if not output_name: output_name = font_name + '.pfa' -sys.stderr.write ('Font: %s\n'% font_name) +logfile.write ('Font: %s\n'% font_name) def header (f): f.write ('%!PS-AdobeFont-3.0: ' + font_name + '\n') @@ -125,7 +127,7 @@ end % of font dictionary suspect_re = re.compile ('closepath ((gsave )*fill( grestore stroke)*) 1 setgray newpath (.*?) closepath fill') def characters (f): - sys.stderr.write ('[') + logfile.write ('[') files = [] import find # q @@ -179,14 +181,14 @@ def characters (f): f.write ('end % of CharProcs\n') f.write (encoding) f.write ('\n') - sys.stderr.write (']') + logfile.write (']') ps_file = open (output_name, 'w') header (ps_file) characters (ps_file) footer (ps_file) -sys.stderr.write ('\n') +logfile.write ('\n') ps_file.close () -sys.stderr.write ('Wrote PostScript font: %s\n' % output_name) +logfile.write ('Wrote PostScript font: %s\n' % output_name) diff --git a/input/bugs/auto-beam.ly b/input/bugs/auto-beam.ly new file mode 100644 index 0000000000..5acc702a01 --- /dev/null +++ b/input/bugs/auto-beam.ly @@ -0,0 +1,6 @@ +% bug or feature? +\score { \notes { c8 c8 + % needed to force auto-beam: + % c4 + +}} diff --git a/input/bugs/f.ly b/input/bugs/f.ly new file mode 100644 index 0000000000..5acc702a01 --- /dev/null +++ b/input/bugs/f.ly @@ -0,0 +1,6 @@ +% bug or feature? +\score { \notes { c8 c8 + % needed to force auto-beam: + % c4 + +}} diff --git a/lily/align-note-column-engraver.cc b/lily/align-note-column-engraver.cc index cbe7a931f0..05a51c710b 100644 --- a/lily/align-note-column-engraver.cc +++ b/lily/align-note-column-engraver.cc @@ -22,7 +22,7 @@ class Align_note_column_engraver: public Engraver { Item * align_item_p_; - Note_column * now_column_l_; + Score_element * now_column_l_; Score_element * accidental_l_; virtual void process_acknowledged (); @@ -71,9 +71,9 @@ Align_note_column_engraver::do_removal_processing () void Align_note_column_engraver::acknowledge_element (Score_element_info inf) { - if (Note_column * n = dynamic_cast (inf.elem_l_)) + if (Note_column::has_interface(inf.elem_l_)) { - now_column_l_ =n; + now_column_l_ =inf.elem_l_; } else if (Local_key_item::has_interface (inf.elem_l_)) { diff --git a/lily/all-font-metrics.cc b/lily/all-font-metrics.cc index f014ef3e46..f8e2c0cee1 100644 --- a/lily/all-font-metrics.cc +++ b/lily/all-font-metrics.cc @@ -16,10 +16,6 @@ #include "lily-guile.hh" #include "tfm-reader.hh" -extern "C" { -#include -} - const char * default_font_sz_ = "cmr10"; All_font_metrics::All_font_metrics (String path) @@ -36,11 +32,8 @@ All_font_metrics::find_afm (String name) String path = name + ".afm"; path = search_path_.find (path); if (path.empty_b ()) - { - path = kpse_find_file(name.ch_C(), kpse_afm_format, true); - if (path.empty_b()) - return 0; - } + return 0; + if (verbose_global_b) progress_indication ("[" + path); Adobe_font_metric * afm_p = read_afm_file (path); @@ -85,13 +78,8 @@ All_font_metrics::find_tfm (String name) { String path = name + ".tfm"; path = search_path_.find (path); - path = search_path_.find (path); if (path.empty_b ()) - { - path = kpse_find_tfm(name.ch_C()); - if (path.empty_b()) - return 0; - } + return 0; if (verbose_global_b) progress_indication ("[" + path); Tex_font_metric * tfm_p = Tex_font_metric_reader::read_file (path); diff --git a/lily/auto-beam-engraver.cc b/lily/auto-beam-engraver.cc index d912bb9585..316cc56f62 100644 --- a/lily/auto-beam-engraver.cc +++ b/lily/auto-beam-engraver.cc @@ -16,6 +16,8 @@ #include "bar.hh" #include "rest.hh" #include "engraver.hh" +#include "item.hh" +#include "spanner.hh" class Auto_beam_engraver : public Engraver { @@ -34,14 +36,14 @@ protected: private: void begin_beam (); void consider_end_and_begin (Moment test_mom); - Beam* create_beam_p (); + Spanner* create_beam_p (); void end_beam (); void junk_beam (); bool same_grace_state_b (Score_element* e); void typeset_beam (); Moment shortest_mom_; - Beam *finished_beam_p_; + Spanner *finished_beam_p_; Link_array* stem_l_arr_p_; Moment last_add_mom_; @@ -234,10 +236,11 @@ Auto_beam_engraver::begin_beam () beam_start_location_ = *unsmob_moment (get_property ("measurePosition")); } -Beam* +Spanner* Auto_beam_engraver::create_beam_p () { - Beam* beam_p = new Beam (get_property ("basicBeamProperties")); + Spanner* beam_p = new Spanner (get_property ("basicBeamProperties")); + Beam::set_interface (beam_p); for (int i = 0; i < stem_l_arr_p_->size (); i++) { @@ -248,7 +251,7 @@ Auto_beam_engraver::create_beam_p () { return 0; } - beam_p->add_stem ((*stem_l_arr_p_)[i]); + Beam::add_stem (beam_p,(*stem_l_arr_p_)[i]); } announce_element (Score_element_info (beam_p, 0)); @@ -281,7 +284,7 @@ Auto_beam_engraver::typeset_beam () if (finished_beam_p_) { finished_grouping_p_->beamify (); - finished_beam_p_->set_beaming (finished_grouping_p_); + Beam::set_beaming (finished_beam_p_, finished_grouping_p_); typeset_element (finished_beam_p_); finished_beam_p_ = 0; @@ -338,7 +341,7 @@ Auto_beam_engraver::acknowledge_element (Score_element_info info) if (stem_l_arr_p_) { - if (Beam *b = dynamic_cast (info.elem_l_)) + if (Beam::has_interface (info.elem_l_)) { end_beam (); } @@ -373,7 +376,7 @@ Auto_beam_engraver::acknowledge_element (Score_element_info info) return; } - if (!Stem::beam_l (stem_l)) + if (Stem::beam_l (stem_l)) { if (stem_l_arr_p_) junk_beam (); diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc index 12eac16329..3b144f624f 100644 --- a/lily/axis-group-interface.cc +++ b/lily/axis-group-interface.cc @@ -125,6 +125,6 @@ Axis_group_interface::set_interface (Score_element*me) if (!has_interface (me)) { me->set_interface (ly_symbol2scm ("axis-group-interface")); - me->set_elt_property ("elements", SCM_EOL); } + me->set_elt_property ("elements", SCM_EOL); } diff --git a/lily/beam-engraver.cc b/lily/beam-engraver.cc index dedbad0dd0..1678dff784 100644 --- a/lily/beam-engraver.cc +++ b/lily/beam-engraver.cc @@ -16,13 +16,15 @@ #include "score-engraver.hh" #include "rest.hh" #include "drul-array.hh" +#include "item.hh" +#include "spanner.hh" class Beam_engraver : public Engraver { Drul_array reqs_drul_; - Beam *finished_beam_p_; - Beam *beam_p_; + Spanner *finished_beam_p_; + Spanner *beam_p_; Span_req * prev_start_req_; Beaming_info_list * beam_info_p_; @@ -120,8 +122,9 @@ Beam_engraver::do_process_music () } prev_start_req_ = reqs_drul_[START]; - beam_p_ = new Beam (get_property ("basicBeamProperties")); - + beam_p_ = new Spanner (get_property ("basicBeamProperties")); + Beam::set_interface (beam_p_); + SCM smp = get_property ("measurePosition"); Moment mp = (unsmob_moment (smp)) ? *unsmob_moment (smp) : Moment (0); @@ -143,7 +146,7 @@ Beam_engraver::typeset_beam () { finished_beam_info_p_->beamify (); - finished_beam_p_->set_beaming (finished_beam_info_p_); + Beam::set_beaming (finished_beam_p_, finished_beam_info_p_); typeset_element (finished_beam_p_); delete finished_beam_info_p_; finished_beam_info_p_ =0; @@ -229,7 +232,7 @@ Beam_engraver::acknowledge_element (Score_element_info info) Moment stem_location = now_mom () - beam_start_mom_ + beam_start_location_; beam_info_p_->add_stem (stem_location, (rhythmic_req->duration_.durlog_i_ - 2) >? 1); - beam_p_->add_stem (stem_l); + Beam::add_stem (beam_p_, stem_l); } } } diff --git a/lily/beam.cc b/lily/beam.cc index 604c4d356b..9e59ec6485 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -18,12 +18,12 @@ #include // tanh. + + #include "directional-element-interface.hh" #include "beaming.hh" -#include "dimensions.hh" #include "beam.hh" #include "misc.hh" -#include "debug.hh" #include "least-squares.hh" #include "stem.hh" #include "paper-def.hh" @@ -31,38 +31,27 @@ #include "group-interface.hh" #include "staff-symbol-referencer.hh" #include "cross-staff.hh" - -Beam::Beam (SCM s) - : Spanner (s) -{ - Score_element*me =this; - - Pointer_group_interface g (me, "stems"); - g.set_interface (); - - set_elt_property ("height", gh_int2scm (0)); // ugh. - set_elt_property ("y-position" ,gh_int2scm (0)); -} +#include "item.hh" +#include "spanner.hh" +#include "warn.hh" void -Beam::add_stem (Score_element*s) +Beam::add_stem (Score_element*me, Score_element*s) { - Score_element*me =this; Pointer_group_interface gi (me, "stems"); gi.add_element (s); s->add_dependency (me); assert (!Stem::beam_l (s)); - s->set_elt_property ("beam", self_scm_); + s->set_elt_property ("beam", me->self_scm_); add_bound_item (dynamic_cast (me), dynamic_cast (s)); } int -Beam::get_multiplicity () const +Beam::get_multiplicity (Score_element*me) { - Score_element*me =(Score_element*)this; int m = 0; for (SCM s = me->get_elt_property ("stems"); gh_pair_p (s); s = gh_cdr (s)) { @@ -86,23 +75,20 @@ MAKE_SCHEME_CALLBACK(Beam,before_line_breaking); SCM Beam::before_line_breaking (SCM smob) { - - Score_element * beam = unsmob_element (smob); - Beam * me =dynamic_cast (beam); + Score_element * me = unsmob_element (smob); // Why? - if (me->visible_stem_count () < 2) + if (visible_stem_count (me) < 2) { warning (_ ("beam has less than two stems")); - } if (!Directional_element_interface (me).get ()) - Directional_element_interface (me).set (me->get_default_dir ()); + Directional_element_interface (me).set (get_default_dir (me)); - me->auto_knees (); - me->set_stem_directions (); - me->set_stem_shorten (); + auto_knees (me); + set_stem_directions (me); + set_stem_shorten (me); return SCM_EOL; } @@ -111,14 +97,14 @@ Beam::before_line_breaking (SCM smob) FIXME */ Direction -Beam::get_default_dir () const +Beam::get_default_dir (Score_element*me) { Drul_array total; total[UP] = total[DOWN] = 0; Drul_array count; count[UP] = count[DOWN] = 0; Direction d = DOWN; - Spanner*me = (Spanner*)this; + Link_array stems= Pointer_group_interface__extract_elements (me, (Item*)0, "stems"); @@ -150,7 +136,7 @@ Beam::get_default_dir () const /* If dir is not determined: get default */ - return to_dir (get_elt_property ("default-neutral-direction")); + return to_dir (me->get_elt_property ("default-neutral-direction")); } @@ -160,11 +146,11 @@ Beam::get_default_dir () const once stem gets cleaned-up. */ void -Beam::set_stem_directions () +Beam::set_stem_directions (Score_element*me) { Link_array stems - =Pointer_group_interface__extract_elements (this, (Item*) 0, "stems"); - Direction d = Directional_element_interface (this).get (); + =Pointer_group_interface__extract_elements (me, (Item*) 0, "stems"); + Direction d = Directional_element_interface (me).get (); for (int i=0; i get_elt_property (gap_str.ch_C()); Direction d = Directional_element_interface (me).get (); Link_array stems= @@ -203,15 +188,16 @@ Beam::auto_knee (String gap_str, bool interstaff_b) if (gh_number_p (gap)) { + Spanner*sp = dynamic_cast (me); int auto_gap_i = gh_scm2int (gap); for (int i=1; i < stems.size (); i++) { - bool is_b = (bool)(calc_interstaff_dist (stems[i], me) - - calc_interstaff_dist (stems[i-1], me)); + bool is_b = (bool)(calc_interstaff_dist (stems[i], sp) + - calc_interstaff_dist (stems[i-1], sp)); int l_y = (int)(Stem::head_positions(stems[i-1])[d]) - + (int)calc_interstaff_dist (stems[i-1], me); + + (int)calc_interstaff_dist (stems[i-1], sp); int r_y = (int)(Stem::head_positions(stems[i])[d]) - + (int)calc_interstaff_dist (stems[i], me); + + (int)calc_interstaff_dist (stems[i], sp); int gap_i = r_y - l_y; if ((abs (gap_i) >= auto_gap_i) && (!interstaff_b || is_b)) @@ -228,7 +214,7 @@ Beam::auto_knee (String gap_str, bool interstaff_b) { Item *s = stems[i]; int y = (int)(Stem::head_positions(s)[d]) - + (int)calc_interstaff_dist (s, me); + + (int)calc_interstaff_dist (s, dynamic_cast (me)); Directional_element_interface (s).set (y < knee_y ? UP : DOWN); s->set_elt_property ("dir-forced", SCM_BOOL_T); @@ -244,17 +230,17 @@ Beam::auto_knee (String gap_str, bool interstaff_b) scmify forced-fraction */ void -Beam::set_stem_shorten () +Beam::set_stem_shorten (Score_element*m) { - Spanner*me = this; - if (!visible_stem_count ()) + Spanner*me = dynamic_cast (m); + if (!visible_stem_count (me)) return; - Real forced_fraction = forced_stem_count () / visible_stem_count (); + Real forced_fraction = forced_stem_count (me) / visible_stem_count (me); if (forced_fraction < 0.5) return; - int multiplicity = get_multiplicity (); + int multiplicity = get_multiplicity (me); // grace stems? SCM shorten = scm_eval (ly_symbol2scm ("beamed-stem-shorten")); @@ -268,7 +254,7 @@ Beam::set_stem_shorten () SCM shorten_elt = scm_list_ref (shorten, gh_int2scm (multiplicity (beam); + Score_element * me = unsmob_element (smob); /* first, calculate y, dy */ Real y, dy; - me->calc_default_position_and_height (&y, &dy); - if (me->visible_stem_count ()) +calc_default_position_and_height (me, &y, &dy); + if (visible_stem_count (me)) { - if (me->suspect_slope_b (y, dy)) + if (suspect_slope_b (me, y, dy)) dy = 0; - Real damped_dy = me->calc_slope_damping_f (dy); - Real quantised_dy = me->quantise_dy_f (damped_dy); + Real damped_dy = calc_slope_damping_f (me, dy); + Real quantised_dy = quantise_dy_f (me, damped_dy); y += (dy - quantised_dy) / 2; dy = quantised_dy; @@ -336,11 +321,11 @@ Beam::after_line_breaking (SCM smob) else { /* we can modify y, so we should quantise y */ - Real y_shift = me->check_stem_length_f (y, dy); + Real y_shift = check_stem_length_f (me, y, dy); y += y_shift; - y = me->quantise_y_f (y, dy, 0); - me->set_stem_length (y, dy); - y_shift = me->check_stem_length_f (y, dy); + y = quantise_y_f (me,y, dy, 0); + set_stem_length (me, y, dy); + y_shift = check_stem_length_f (me, y, dy); if (y_shift > half_space / 4) { @@ -353,12 +338,12 @@ Beam::after_line_breaking (SCM smob) int quant_dir = 0; if (abs (y_shift) > half_space / 2) quant_dir = sign (y_shift) * Directional_element_interface (me).get (); - y = me->quantise_y_f (y, dy, quant_dir); + y = quantise_y_f (me, y, dy, quant_dir); } } // UGH. Y is not in staff position unit? // Ik dacht datwe daar juist van weg wilden? - me->set_stem_length (y, dy); + set_stem_length (me, y, dy); me->set_elt_property ("y-position", gh_double2scm (y)); return SCM_UNDEFINED; @@ -368,16 +353,15 @@ Beam::after_line_breaking (SCM smob) See Documentation/tex/fonts.doc */ void -Beam::calc_default_position_and_height (Real* y, Real* dy) const +Beam::calc_default_position_and_height (Score_element*me,Real* y, Real* dy) { - Spanner*me = (Spanner*)this; *y = 0; *dy = 0; - if (visible_stem_count () <= 1) + if (visible_stem_count (me) <= 1) return; - Real first_ideal = Stem::calc_stem_info (first_visible_stem ()).idealy_f_; - if (first_ideal == Stem::calc_stem_info (last_visible_stem ()).idealy_f_) + Real first_ideal = Stem::calc_stem_info (first_visible_stem (me)).idealy_f_; + if (first_ideal == Stem::calc_stem_info (last_visible_stem (me)).idealy_f_) { *dy = 0; *y = first_ideal; @@ -385,7 +369,7 @@ Beam::calc_default_position_and_height (Real* y, Real* dy) const } Array ideals; - Real x0 = first_visible_stem ()->relative_coordinate (0, X_AXIS); + Real x0 = first_visible_stem (me)->relative_coordinate (0, X_AXIS); Link_array stems= Pointer_group_interface__extract_elements (me, (Item*)0, "stems"); @@ -400,23 +384,23 @@ Beam::calc_default_position_and_height (Real* y, Real* dy) const Real dydx; minimise_least_squares (&dydx, y, ideals); // duh, takes references - Real dx = last_visible_stem ()->relative_coordinate (0, X_AXIS) - x0; + Real dx = last_visible_stem (me)->relative_coordinate (0, X_AXIS) - x0; *dy = dydx * dx; } bool -Beam::suspect_slope_b (Real y, Real dy) const +Beam::suspect_slope_b (Score_element*me, Real y, Real dy) { /* first, calculate y, dy */ /* steep slope running against lengthened stem is suspect */ - Real first_ideal = Stem::calc_stem_info (first_visible_stem ()).idealy_f_; - Real last_ideal = Stem::calc_stem_info (last_visible_stem ()).idealy_f_; - Real lengthened = paper_l ()->get_var ("beam_lengthened"); - Real steep = paper_l ()->get_var ("beam_steep_slope"); + Real first_ideal = Stem::calc_stem_info (first_visible_stem (me)).idealy_f_; + Real last_ideal = Stem::calc_stem_info (last_visible_stem (me)).idealy_f_; + Real lengthened = me->paper_l ()->get_var ("beam_lengthened"); + Real steep = me->paper_l ()->get_var ("beam_steep_slope"); - Real dx = last_visible_stem ()->relative_coordinate (0, X_AXIS) - first_visible_stem ()->relative_coordinate (0, X_AXIS); + Real dx = last_visible_stem (me)->relative_coordinate (0, X_AXIS) - first_visible_stem (me)->relative_coordinate (0, X_AXIS); Real dydx = dy && dx ? dy/dx : 0; if (((y - first_ideal > lengthened) && (dydx > steep)) @@ -433,15 +417,15 @@ Beam::suspect_slope_b (Real y, Real dy) const corresponds with some tables in [Wanske] */ Real -Beam::calc_slope_damping_f (Real dy) const +Beam::calc_slope_damping_f (Score_element*me,Real dy) { - SCM damp = get_elt_property ("damping"); + SCM damp = me->get_elt_property ("damping"); int damping = gh_scm2int (damp); if (damping) { - Real dx = last_visible_stem ()->relative_coordinate (0, X_AXIS) - - first_visible_stem ()->relative_coordinate (0, X_AXIS); + Real dx = last_visible_stem (me)->relative_coordinate (0, X_AXIS) + - first_visible_stem (me)->relative_coordinate (0, X_AXIS); Real dydx = dy && dx ? dy/dx : 0; dydx = 0.6 * tanh (dydx) / damping; return dydx * dx; @@ -450,18 +434,17 @@ Beam::calc_slope_damping_f (Real dy) const } Real -Beam::calc_stem_y_f (Item* s, Real y, Real dy) const +Beam::calc_stem_y_f (Score_element*me,Item* s, Real y, Real dy) { - Score_element*me = (Score_element*)this; - Real thick = gh_scm2double (get_elt_property ("beam-thickness")); - thick *= paper_l ()->get_var ("staffspace"); + Real thick = gh_scm2double (me->get_elt_property ("beam-thickness")); + thick *= me->paper_l ()->get_var ("staffspace"); - int beam_multiplicity = get_multiplicity (); + int beam_multiplicity = get_multiplicity (me); int stem_multiplicity = (Stem::flag_i (s) - 2) >? 0; - Real interbeam_f = paper_l ()->interbeam_f (beam_multiplicity); - Real x0 = first_visible_stem ()->relative_coordinate (0, X_AXIS); - Real dx = last_visible_stem ()->relative_coordinate (0, X_AXIS) - x0; + Real interbeam_f = me->paper_l ()->interbeam_f (beam_multiplicity); + Real x0 = first_visible_stem (me)->relative_coordinate (0, X_AXIS); + Real dx = last_visible_stem (me)->relative_coordinate (0, X_AXIS) - x0; Real stem_y = (dy && dx ? (s->relative_coordinate (0, X_AXIS) - x0) / dx * dy : 0) + y; /* knee */ @@ -478,7 +461,7 @@ Beam::calc_stem_y_f (Item* s, Real y, Real dy) const // huh, why not for first visible? if (Staff_symbol_referencer::staff_symbol_l (s) - != Staff_symbol_referencer::staff_symbol_l (last_visible_stem ())) + != Staff_symbol_referencer::staff_symbol_l (last_visible_stem (me))) stem_y += Directional_element_interface (me).get () * (beam_multiplicity - stem_multiplicity) * interbeam_f; } @@ -487,9 +470,8 @@ Beam::calc_stem_y_f (Item* s, Real y, Real dy) const } Real -Beam::check_stem_length_f (Real y, Real dy) const +Beam::check_stem_length_f (Score_element*me,Real y, Real dy) { - Score_element * me = (Score_element*)this; Real shorten = 0; Real lengthen = 0; Direction dir = Directional_element_interface (me).get (); @@ -503,7 +485,7 @@ Beam::check_stem_length_f (Real y, Real dy) const if (Stem::invisible_b (s)) continue; - Real stem_y = calc_stem_y_f (s, y, dy); + Real stem_y = calc_stem_y_f (me, s, y, dy); stem_y *= dir; Stem_info info = Stem::calc_stem_info (s); @@ -526,10 +508,8 @@ Beam::check_stem_length_f (Real y, Real dy) const stem directions and length should set to relative to the chord's position of the beam. */ void -Beam::set_stem_length (Real y, Real dy) +Beam::set_stem_length (Score_element*me,Real y, Real dy) { - Beam*me = this; - Real half_space = Staff_symbol_referencer::staff_space (me)/2; Link_array stems= Pointer_group_interface__extract_elements (me, (Item*)0, "stems"); @@ -541,10 +521,10 @@ Beam::set_stem_length (Real y, Real dy) if (Stem::invisible_b (s)) continue; - Real stem_y = calc_stem_y_f (s, y, dy); + Real stem_y = calc_stem_y_f (me, s, y, dy); /* caution: stem measures in staff-positions */ - Stem::set_stemend (s,(stem_y + calc_interstaff_dist (s, me)) / half_space); + Stem::set_stemend (s,(stem_y + calc_interstaff_dist (s, dynamic_cast (me))) / half_space); } } @@ -557,9 +537,8 @@ Beam::set_stem_length (Real y, Real dy) + n * staff_space */ Real -Beam::quantise_dy_f (Real dy) const +Beam::quantise_dy_f (Score_element*me,Real dy) { - Score_element*me = (Score_element*)this; Array a; for (SCM s = scm_eval (ly_symbol2scm ("beam-height-quants")); s !=SCM_EOL; s = gh_cdr (s)) a.push (gh_scm2double (gh_car (s))); @@ -586,10 +565,9 @@ Beam::quantise_dy_f (Real dy) const if extend_b then stems must *not* get shorter */ Real -Beam::quantise_y_f (Real y, Real dy, int quant_dir) +Beam::quantise_y_f (Score_element*me,Real y, Real dy, int quant_dir) { - int multiplicity = get_multiplicity (); - Score_element*me = (Score_element*)this; + int multiplicity = get_multiplicity (me); Real staff_space = Staff_symbol_referencer::staff_space (me); SCM quants = scm_eval (gh_list (ly_symbol2scm ("beam-vertical-position-quants"), @@ -617,9 +595,8 @@ Beam::quantise_y_f (Real y, Real dy, int quant_dir) } void -Beam::set_beaming (Beaming_info_list *beaming) +Beam::set_beaming (Score_element*me,Beaming_info_list *beaming) { - Score_element*me = this; Link_array stems= Pointer_group_interface__extract_elements (me, (Score_element*)0, "stems"); @@ -644,28 +621,27 @@ Beam::set_beaming (Beaming_info_list *beaming) clean me up. */ Molecule -Beam::stem_beams (Item *here, Item *next, Item *prev) const +Beam::stem_beams (Score_element*me,Item *here, Item *next, Item *prev) { - Score_element*me = (Score_element*)this; if ((next && !(next->relative_coordinate (0, X_AXIS) > here->relative_coordinate (0, X_AXIS))) || (prev && !(prev->relative_coordinate (0, X_AXIS) < here->relative_coordinate (0, X_AXIS)))) programming_error ("Beams are not left-to-right"); - Real staffline_f = paper_l ()->get_var ("stafflinethickness"); - int multiplicity = get_multiplicity (); + Real staffline_f = me->paper_l ()->get_var ("stafflinethickness"); + int multiplicity = get_multiplicity (me); - Real interbeam_f = paper_l ()->interbeam_f (multiplicity); - Real thick = gh_scm2double (get_elt_property ("beam-thickness")); - thick *= paper_l ()->get_var ("staffspace"); + Real interbeam_f = me->paper_l ()->interbeam_f (multiplicity); + Real thick = gh_scm2double (me->get_elt_property ("beam-thickness")); + thick *= me->paper_l ()->get_var ("staffspace"); Real bdy = interbeam_f; Real stemdx = staffline_f; - Real dx = visible_stem_count () ? - last_visible_stem ()->relative_coordinate (0, X_AXIS) - first_visible_stem ()->relative_coordinate (0, X_AXIS) + Real dx = visible_stem_count (me) ? + last_visible_stem (me)->relative_coordinate (0, X_AXIS) - first_visible_stem (me)->relative_coordinate (0, X_AXIS) : 0.0; - Real dy = gh_scm2double (get_elt_property ("height")); + Real dy = gh_scm2double (me->get_elt_property ("height")); Real dydx = dy && dx ? dy/dx : 0; Molecule leftbeams; @@ -676,11 +652,11 @@ Beam::stem_beams (Item *here, Item *next, Item *prev) const if (!Stem::first_head (here)) nw_f = 0; else if (Stem::type_i (here)== 1) - nw_f = paper_l ()->get_var ("wholewidth"); + nw_f = me->paper_l ()->get_var ("wholewidth"); else if (Stem::type_i (here) == 2) - nw_f = paper_l ()->get_var ("notewidth") * 0.8; + nw_f = me->paper_l ()->get_var ("notewidth") * 0.8; else - nw_f = paper_l ()->get_var ("quartwidth"); + nw_f = me->paper_l ()->get_var ("quartwidth"); Direction dir = Directional_element_interface (me).get (); @@ -698,7 +674,7 @@ Beam::stem_beams (Item *here, Item *next, Item *prev) const w = w/2 beam (dydx, w, thick); + a = me->lookup_l ()->beam (dydx, w, thick); a.translate (Offset (-w, -w * dydx)); for (int j = 0; j < lhalfs; j++) { @@ -714,12 +690,12 @@ Beam::stem_beams (Item *here, Item *next, Item *prev) const int rwholebeams= Stem::beam_count (here,RIGHT) relative_coordinate (0, X_AXIS) - here->relative_coordinate (0, X_AXIS); - Molecule a = lookup_l ()->beam (dydx, w + stemdx, thick); + Molecule a = me->lookup_l ()->beam (dydx, w + stemdx, thick); a.translate_axis( - stemdx/2, X_AXIS); int j = 0; Real gap_f = 0; - SCM gap = get_elt_property ("beam-gap"); + SCM gap = me->get_elt_property ("beam-gap"); if (gh_number_p (gap)) { int gap_i = gh_scm2int ( (gap)); @@ -734,7 +710,7 @@ Beam::stem_beams (Item *here, Item *next, Item *prev) const // TODO: notehead widths differ for different types gap_f = nw_f / 2; w -= 2 * gap_f; - a = lookup_l ()->beam (dydx, w + stemdx, thick); + a = me->lookup_l ()->beam (dydx, w + stemdx, thick); } for (; j < rwholebeams; j++) @@ -746,7 +722,7 @@ Beam::stem_beams (Item *here, Item *next, Item *prev) const w = w/2 beam (dydx, w, thick); + a = me->lookup_l ()->beam (dydx, w, thick); for (; j < rwholebeams + rhalfs; j++) { @@ -769,19 +745,18 @@ MAKE_SCHEME_CALLBACK(Beam,brew_molecule); SCM Beam::brew_molecule (SCM smob) { - Score_element * beam = unsmob_element (smob); - Beam * me =dynamic_cast (beam); + Score_element * me =unsmob_element (smob); Molecule mol; if (!gh_pair_p (me->get_elt_property ("stems"))) return SCM_EOL; Real x0,dx; Link_arraystems = - Pointer_group_interface__extract_elements ((Beam*) me, (Item*) 0, "stems"); - if (me->visible_stem_count ()) + Pointer_group_interface__extract_elements (me, (Item*) 0, "stems"); + if (visible_stem_count (me)) { - x0 = me->first_visible_stem ()->relative_coordinate (0, X_AXIS); - dx = me->last_visible_stem ()->relative_coordinate (0, X_AXIS) - x0; + x0 = first_visible_stem (me)->relative_coordinate (0, X_AXIS); + dx = last_visible_stem (me)->relative_coordinate (0, X_AXIS) - x0; } else { @@ -801,23 +776,22 @@ Beam::brew_molecule (SCM smob) Item * prev = (j > 0)? stems[j-1] : 0; Item * next = (j < stems.size()-1) ? stems[j+1] :0; - Molecule sb = me->stem_beams (i, next, prev); + Molecule sb = stem_beams (me, i, next, prev); Real x = i->relative_coordinate (0, X_AXIS)-x0; sb.translate (Offset (x, x * dydx + y)); mol.add_molecule (sb); } mol.translate_axis (x0 - - me->get_bound (LEFT)->relative_coordinate (0, X_AXIS), X_AXIS); + - dynamic_cast (me)->get_bound (LEFT)->relative_coordinate (0, X_AXIS), X_AXIS); return mol.create_scheme (); } int -Beam::forced_stem_count () const +Beam::forced_stem_count (Score_element*me) { - Score_element* me = (Score_element*)this; Link_arraystems = - Pointer_group_interface__extract_elements ((Beam*) me, (Item*) 0, "stems"); + Pointer_group_interface__extract_elements ( me, (Item*) 0, "stems"); int f = 0; for (int i=0; i < stems.size (); i++) { @@ -840,9 +814,8 @@ Beam::forced_stem_count () const use filter and standard list functions. */ int -Beam::visible_stem_count () const +Beam::visible_stem_count (Score_element*me) { - Score_element * me = (Score_element*)this; Link_arraystems = Pointer_group_interface__extract_elements (me, (Item*) 0, "stems"); int c = 0; @@ -855,11 +828,10 @@ Beam::visible_stem_count () const } Item* -Beam::first_visible_stem() const +Beam::first_visible_stem(Score_element*me) { - Score_element * me = (Score_element*)this; Link_arraystems = - Pointer_group_interface__extract_elements ((Beam*) me, (Item*) 0, "stems"); + Pointer_group_interface__extract_elements ( me, (Item*) 0, "stems"); for (int i = 0; i < stems.size (); i++) { @@ -870,11 +842,10 @@ Beam::first_visible_stem() const } Item* -Beam::last_visible_stem() const +Beam::last_visible_stem(Score_element*me) { - Score_element * me = (Score_element*)this; Link_arraystems = - Pointer_group_interface__extract_elements ((Beam*) me, (Item*) 0, "stems"); + Pointer_group_interface__extract_elements ( me, (Item*) 0, "stems"); for (int i = stems.size (); i--;) { if (!Stem::invisible_b (stems[i])) @@ -902,8 +873,8 @@ Beam::rest_collision_callback (Score_element *rest, Axis a ) Score_element * stem = st; if (!stem) return 0.0; - Beam * beam = dynamic_cast (unsmob_element (stem->get_elt_property ("beam"))); - if (!beam || !beam->visible_stem_count ()) + Score_element * beam = unsmob_element (stem->get_elt_property ("beam")); + if (!beam || !Beam::has_interface (beam) || !Beam::visible_stem_count (beam)) return 0.0; // make callback for rest from this. @@ -920,8 +891,8 @@ Beam::rest_collision_callback (Score_element *rest, Axis a ) if (gh_number_p (s)) beam_y = gh_scm2double (s); - Real x0 = beam->first_visible_stem()->relative_coordinate (0, X_AXIS); - Real dx = beam->last_visible_stem()->relative_coordinate (0, X_AXIS) - x0; + Real x0 = first_visible_stem(beam)->relative_coordinate (0, X_AXIS); + Real dx = last_visible_stem(beam)->relative_coordinate (0, X_AXIS) - x0; Real dydx = beam_dy && dx ? beam_dy/dx : 0; Direction d = Stem::get_direction (stem); @@ -946,3 +917,21 @@ Beam::rest_collision_callback (Score_element *rest, Axis a ) return (-d * discrete_dist); } + + +bool +Beam::has_interface (Score_element*me) +{ + return me->has_interface (ly_symbol2scm ("beam-interface")); +} + +void +Beam::set_interface (Score_element*me) +{ + Pointer_group_interface g (me, "stems"); + g.set_interface (); + + me->set_elt_property ("height", gh_int2scm (0)); // ugh. + me->set_elt_property ("y-position" ,gh_int2scm (0)); + me->set_interface (ly_symbol2scm("beam-interface")); +} diff --git a/lily/break-algorithm.cc b/lily/break-algorithm.cc index 7c679d76fb..4802e0507c 100644 --- a/lily/break-algorithm.cc +++ b/lily/break-algorithm.cc @@ -22,13 +22,11 @@ Array Break_algorithm::find_break_indices () const { - Link_array all = pscore_l_->line_l_->column_l_arr (); - - + Link_array all = pscore_l_->line_l_->column_l_arr (); Array retval; for (int i=0; i < all.size (); i++) - if (all[i]->breakable_b ()) + if (Item::breakable_b (all[i])) retval.push (i); if (linewidth_f_ <=0) @@ -39,15 +37,14 @@ Break_algorithm::find_break_indices () const } -Link_array +Link_array Break_algorithm::find_breaks () const { - Link_array all = pscore_l_->line_l_->column_l_arr (); - - Link_array retval; + Link_array all = pscore_l_->line_l_->column_l_arr (); + Link_array retval; for (int i=0; i < all.size (); i++) - if (all[i]->breakable_b ()) + if (Item::breakable_b (all[i])) retval.push (all[i]); if (linewidth_f_ <=0) @@ -59,7 +56,7 @@ Break_algorithm::find_breaks () const Simple_spacer* -Break_algorithm::generate_spacing_problem (Link_array curline, Interval line) const +Break_algorithm::generate_spacing_problem (Link_array curline, Interval line) const { Simple_spacer * sp = new Simple_spacer; Paper_def * d = pscore_l_->paper_l_; diff --git a/lily/chord-tremolo-engraver.cc b/lily/chord-tremolo-engraver.cc index d670feb130..87fdecbce8 100644 --- a/lily/chord-tremolo-engraver.cc +++ b/lily/chord-tremolo-engraver.cc @@ -17,6 +17,8 @@ #include "warn.hh" #include "misc.hh" #include "note-head.hh" +#include "spanner.hh" +#include "item.hh" /** This acknowledges repeated music with "tremolo" style. It typesets @@ -49,8 +51,8 @@ protected: int note_head_i_; - Beam * beam_p_; - Beam * finished_beam_p_; + Spanner * beam_p_; + Spanner * finished_beam_p_; protected: virtual void do_removal_processing(); @@ -91,7 +93,8 @@ Chord_tremolo_engraver::do_process_music () { if (repeat_ && !beam_p_) { - beam_p_ = new Beam (get_property ("basicBeamProperties")); + beam_p_ = new Spanner (get_property ("basicBeamProperties")); + Beam::set_interface (beam_p_); beam_p_->set_elt_property ("chord-tremolo", SCM_BOOL_T); @@ -160,7 +163,7 @@ Chord_tremolo_engraver::acknowledge_element (Score_element_info info) if (Rhythmic_req* r = dynamic_cast (info.req_l_)) { - beam_p_->add_stem (s); + Beam::add_stem (beam_p_, s); Moment stem_location = now_mom () - start_mom_ + beam_start_location_; } diff --git a/lily/collision-engraver.cc b/lily/collision-engraver.cc index 8816100638..9b3218de78 100644 --- a/lily/collision-engraver.cc +++ b/lily/collision-engraver.cc @@ -17,7 +17,7 @@ a collision object. */ class Collision_engraver : public Engraver { Item * col_p_; - Link_array note_column_l_arr_; + Link_array note_column_l_arr_; protected: virtual void acknowledge_element (Score_element_info); @@ -50,13 +50,13 @@ Collision_engraver::process_acknowledged () void Collision_engraver::acknowledge_element (Score_element_info i) { - if (Note_column * c = dynamic_cast (i.elem_l_)) + if (Note_column::has_interface (i.elem_l_)) { /*should check Y axis? */ - if (c->rest_b () || c->parent_l(X_AXIS)) + if (Note_column::rest_b (i.elem_l_) || i.elem_l_->parent_l(X_AXIS)) return ; - note_column_l_arr_.push (c); + note_column_l_arr_.push (i.elem_l_); } } diff --git a/lily/collision.cc b/lily/collision.cc index a52c130048..8d1f6d1232 100644 --- a/lily/collision.cc +++ b/lily/collision.cc @@ -14,7 +14,7 @@ #include "item.hh" void -Collision::add_column (Score_element*me,Note_column* ncol_l) +Collision::add_column (Score_element*me,Score_element* ncol_l) { ncol_l->add_offset_callback (force_shift_callback, X_AXIS); Axis_group_interface::add_element (me, ncol_l); @@ -77,7 +77,7 @@ Collision::do_shifts(Score_element* me) SCM Collision::automatic_shift (Score_element *me) { - Drul_array > clash_groups; + Drul_array > clash_groups; Drul_array > shifts; SCM tups = SCM_EOL; @@ -87,8 +87,8 @@ Collision::automatic_shift (Score_element *me) SCM car = gh_car (s); Score_element * se = unsmob_element (car); - if (Note_column * col = dynamic_cast (se)) - clash_groups[col->dir ()].push (col); + if (Note_column::has_interface (se)) + clash_groups[Note_column::dir (se)].push (se); } @@ -96,7 +96,7 @@ Collision::automatic_shift (Score_element *me) do { Array & shift (shifts[d]); - Link_array & clashes (clash_groups[d]); + Link_array & clashes (clash_groups[d]); clashes.sort (Note_column::shift_compare); @@ -157,15 +157,15 @@ Collision::automatic_shift (Score_element *me) all of them again. */ if (extents[UP].size () && extents[DOWN].size ()) { - Note_column *cu_l =clash_groups[UP][0]; - Note_column *cd_l =clash_groups[DOWN][0]; + Score_element *cu_l =clash_groups[UP][0]; + Score_element *cd_l =clash_groups[DOWN][0]; /* TODO. */ - Score_element * nu_l= cu_l->first_head(); - Score_element * nd_l = cd_l->first_head(); + Score_element * nu_l= Note_column::first_head(cu_l); + Score_element * nd_l = Note_column::first_head(cd_l); int downpos = Note_column::head_positions_interval (cd_l)[BIGGER]; int uppos = Note_column::head_positions_interval (cu_l)[SMALLER]; diff --git a/lily/dynamic-engraver.cc b/lily/dynamic-engraver.cc index 967dcc1886..f0390d4798 100644 --- a/lily/dynamic-engraver.cc +++ b/lily/dynamic-engraver.cc @@ -333,12 +333,12 @@ Dynamic_engraver::typeset_all () void Dynamic_engraver::acknowledge_element (Score_element_info i) { - if (Note_column* n = dynamic_cast (i.elem_l_)) + if (Note_column::has_interface (i.elem_l_)) { if (line_spanner_) { - Side_position::add_support (line_spanner_,n); - add_bound_item (line_spanner_,n); + Side_position::add_support (line_spanner_,i.elem_l_); + add_bound_item (line_spanner_,dynamic_cast(i.elem_l_)); } } } diff --git a/lily/gourlay-breaking.cc b/lily/gourlay-breaking.cc index 3f9662a99a..192ece0a69 100644 --- a/lily/gourlay-breaking.cc +++ b/lily/gourlay-breaking.cc @@ -54,7 +54,7 @@ Array Gourlay_breaking::do_solve () const { Array optimal_paths; - Link_array all = + Link_array all = pscore_l_->line_l_->column_l_arr (); Array breaks = find_break_indices (); @@ -80,10 +80,10 @@ Gourlay_breaking::do_solve () const for (int start_idx = break_idx; start_idx--;) { - Link_array line = all.slice (breaks[start_idx], breaks[break_idx]+1); + Link_array line = all.slice (breaks[start_idx], breaks[break_idx]+1); - line[0] = dynamic_cast (line[0] ->find_prebroken_piece (RIGHT)); - line.top () = dynamic_cast (line.top ()->find_prebroken_piece (LEFT)); + line[0] = dynamic_cast (line[0]) ->find_prebroken_piece (RIGHT); + line.top () = dynamic_cast (line.top ())->find_prebroken_piece (LEFT); Column_x_positions cp; cp.cols_ = line; @@ -177,7 +177,7 @@ Gourlay_breaking::combine_demerits (Column_x_positions const &prev, Column_x_positions const &this_one) const { Real break_penalties = 0.0; - Paper_column * pc = this_one.cols_.top (); + Score_element * pc = this_one.cols_.top (); if (pc->original_l_) { SCM pen = pc->get_elt_property ("penalty"); diff --git a/lily/grace-align-item.cc b/lily/grace-align-item.cc index 2b7aec2beb..a8150dac67 100644 --- a/lily/grace-align-item.cc +++ b/lily/grace-align-item.cc @@ -13,15 +13,6 @@ #include "paper-column.hh" #include "paper-def.hh" -void -Grace_align_item::set_interface (Score_element*me) -{ - me->set_interface (ly_symbol2scm ("grace-align-interface")); - me->set_elt_property ("stacking-dir", gh_int2scm (RIGHT)); - Align_interface::set_interface(me); - Align_interface::set_axis (me,X_AXIS); -} - /* TODO: cfg-able */ @@ -41,6 +32,17 @@ Grace_align_item::before_line_breaking (SCM smob) return SCM_UNDEFINED; } +void +Grace_align_item::set_interface (Score_element*me) +{ + me->set_interface (ly_symbol2scm ("grace-align-interface")); + me->set_elt_property ("stacking-dir", gh_int2scm (RIGHT)); + Align_interface::set_interface(me); + Align_interface::set_axis (me,X_AXIS); +} + + + bool Grace_align_item::has_interface (Score_element*m) { diff --git a/lily/include/beam.hh b/lily/include/beam.hh index dba75f2045..b83254e1c5 100644 --- a/lily/include/beam.hh +++ b/lily/include/beam.hh @@ -8,7 +8,7 @@ #define BEAM_HH #include "lily-proto.hh" -#include "spanner.hh" +#include "lily-guile.hh" /** a beam connects multiple stems. @@ -25,44 +25,41 @@ damping -- amount of beam slope damping. (int) should beam slope be damped? 0: no, 1: yes, 100000: horizontal beams */ -class Beam : public Spanner +class Beam { public: - - - int visible_stem_count () const; - Item* first_visible_stem () const; - Item* last_visible_stem () const; + static int visible_stem_count (Score_element*); + static Item* first_visible_stem (Score_element*); + static Item* last_visible_stem (Score_element*); + static bool has_interface (Score_element*); + static void set_interface (Score_element*); static Real rest_collision_callback (Score_element *,Axis); Beam (SCM); - void add_stem (Score_element*); - void set_grouping (Rhythmic_grouping def, Rhythmic_grouping current); - void set_beaming (Beaming_info_list *); - void set_stemlens (); - VIRTUAL_COPY_CONS(Score_element); - - int get_multiplicity () const; - + static void add_stem (Score_element*,Score_element*); + static void set_grouping (Score_element*,Rhythmic_grouping def, Rhythmic_grouping current); + static void set_beaming (Score_element*,Beaming_info_list *); + static void set_stemlens (Score_element*); + static int get_multiplicity (Score_element*me); static SCM brew_molecule (SCM); static SCM before_line_breaking (SCM); static SCM after_line_breaking (SCM); + static Molecule stem_beams (Score_element*,Item *here, Item *next, Item *prev); - Molecule stem_beams (Item *here, Item *next, Item *prev) const; private: - Direction get_default_dir () const; - void set_stem_directions (); - void auto_knees (); - bool auto_knee (String gap_str, bool interstaff_b); - void set_stem_shorten (); - void calc_default_position_and_height (Real* y, Real* dy) const; - bool suspect_slope_b (Real y, Real dy) const; - Real calc_slope_damping_f (Real dy) const; - Real calc_stem_y_f (Item* s, Real y, Real dy) const; - Real check_stem_length_f (Real y, Real dy) const; - void set_stem_length (Real y, Real dy); - Real quantise_dy_f (Real dy) const; - Real quantise_y_f (Real y, Real dy, int quant_dir); - int forced_stem_count () const; + static Direction get_default_dir (Score_element*); + static void set_stem_directions (Score_element*); + static void auto_knees (Score_element*); + static bool auto_knee (Score_element*,String gap_str, bool interstaff_b); + static void set_stem_shorten (Score_element*); + static void calc_default_position_and_height (Score_element*,Real* y, Real* dy); + static bool suspect_slope_b (Score_element*, Real y, Real dy); + static Real calc_slope_damping_f (Score_element*, Real dy); + static Real calc_stem_y_f (Score_element*, Item* s, Real y, Real dy); + static Real check_stem_length_f (Score_element*, Real y, Real dy); + static void set_stem_length (Score_element*, Real y, Real dy); + static Real quantise_dy_f (Score_element*, Real dy); + static Real quantise_y_f (Score_element*, Real y, Real dy, int quant_dir); + static int forced_stem_count (Score_element*); }; #endif // BEAM_HH diff --git a/lily/include/break-algorithm.hh b/lily/include/break-algorithm.hh index 7e0c341544..fa0b0d7770 100644 --- a/lily/include/break-algorithm.hh +++ b/lily/include/break-algorithm.hh @@ -28,7 +28,7 @@ protected: Real linewidth_f_; /// search all pcols which are breakable. - Link_array find_breaks() const; + Link_array find_breaks() const; Array find_break_indices() const; @@ -37,10 +37,10 @@ protected: void solve_line (Column_x_positions*) const; /// does curline fit on the paper? - bool feasible (Link_array) const; + bool feasible (Link_array) const; - Simple_spacer* generate_spacing_problem (Link_array, Interval) const; + Simple_spacer* generate_spacing_problem (Link_array, Interval) const; virtual Array do_solve() const=0; diff --git a/lily/include/collision.hh b/lily/include/collision.hh index 469dfeacbd..10c5397a6e 100644 --- a/lily/include/collision.hh +++ b/lily/include/collision.hh @@ -43,6 +43,6 @@ public: static SCM forced_shift (Score_element*); static Real force_shift_callback (Score_element *, Axis); static void do_shifts (Score_element*); - static void add_column (Score_element*me,Note_column*ncol_l); + static void add_column (Score_element*me,Score_element*ncol_l); }; #endif // COLLISION_HH diff --git a/lily/include/column-x-positions.hh b/lily/include/column-x-positions.hh index 23bea78d2e..aec9602223 100644 --- a/lily/include/column-x-positions.hh +++ b/lily/include/column-x-positions.hh @@ -13,7 +13,7 @@ struct Column_x_positions { - Link_array cols_; + Link_array cols_; Array config_; Real force_f_; bool satisfies_constraints_b_; diff --git a/lily/include/item.hh b/lily/include/item.hh index c036dd2e52..16f298f7f2 100644 --- a/lily/include/item.hh +++ b/lily/include/item.hh @@ -43,7 +43,7 @@ public: Item (SCM); Item (Item const &); - bool breakable_b () const; + static bool breakable_b (Score_element*me); bool broken_b () const; Direction break_status_dir () const; diff --git a/lily/include/line-of-score.hh b/lily/include/line-of-score.hh index 9d510c692c..96b3d6b265 100644 --- a/lily/include/line-of-score.hh +++ b/lily/include/line-of-score.hh @@ -44,7 +44,7 @@ public: void output_lines (); Link_array broken_col_range (Item const*, Item const*) const; - Link_array column_l_arr () const; + Link_array column_l_arr () const; void add_column (Paper_column*); void typeset_element (Score_element*); diff --git a/lily/include/multi-measure-rest.hh b/lily/include/multi-measure-rest.hh index 71353da3b1..4b57a9662c 100644 --- a/lily/include/multi-measure-rest.hh +++ b/lily/include/multi-measure-rest.hh @@ -10,20 +10,18 @@ #ifndef MULTI_MEASURE_REST_HH #define MULTI_MEASURE_REST_HH -#include "spanner.hh" +#include "lily-proto.hh" +#include "lily-guile.hh" +#include "rod.hh" - -class Multi_measure_rest : public Spanner +class Multi_measure_rest { public: - Multi_measure_rest (SCM); - static void set_interface (Score_element*); static bool has_interface (Score_element*); static SCM brew_molecule (SCM); static void add_column (Score_element*,Item*); - VIRTUAL_COPY_CONS (Score_element); - virtual Array get_rods () const; + static SCM set_spacing_rods (SCM); }; #endif /* MULTI_MEASURE_REST_HH */ diff --git a/lily/include/note-column.hh b/lily/include/note-column.hh index 7bf51956d5..855d655cd6 100644 --- a/lily/include/note-column.hh +++ b/lily/include/note-column.hh @@ -18,33 +18,30 @@ UGR. Junkme. refpoint should be the notehead, dir should come from stem. */ -class Note_column : public Item +class Note_column { public: - static int shift_compare (Note_column *const &, Note_column*const&); + static int shift_compare (Score_element *const &, Score_element*const&); /** The relative position of the "voice" containing this chord. Normally this would be the same as the stem direction, JUNKME. */ - Direction dir () const; - - static Slice head_positions_interval(Score_element* me) ; + static Direction dir (Score_element*me); + static Slice head_positions_interval(Score_element* me); static Direction static_dir (Score_element*); - void translate_rests(int dy); - Score_element * first_head ()const; - Interval rest_dim ()const ; - Note_column (SCM); - void set_stem (Score_element*); - void set_dotcol (Score_element*); - void add_head (Score_element*); - bool rest_b () const; - + static void translate_rests(Score_element*me,int dy); + static Score_element * first_head (Score_element*me); + static Interval rest_dim (Score_element*me); + static void set_stem (Score_element*me,Score_element*); + static void set_dotcol (Score_element*me,Score_element*); + static void add_head (Score_element*me,Score_element*); + static bool rest_b (Score_element*me); static bool has_interface (Score_element*); - - Item *stem_l()const; + static void set_interface (Score_element*); + static Item *stem_l(Score_element*); }; #endif // NOTE_COLUMN_HH diff --git a/lily/include/paper-column.hh b/lily/include/paper-column.hh index 3b1756e8f1..5633cb0fb2 100644 --- a/lily/include/paper-column.hh +++ b/lily/include/paper-column.hh @@ -15,16 +15,14 @@ #include "spring.hh" /** - stuff grouped vertically. - This is a class to address items vertically. It contains the data for: - \begin{itemize} - \item - unbroken score - \item - broken score - \item - the linespacing problem - \end{itemize} + bounded-by-me -- list of elts. + + shortest-starter-duration -- rational signifying shortest moment that starts here + + + Interfaces: + + axis-group, spaceable-element. */ class Paper_column : public Item @@ -32,29 +30,11 @@ class Paper_column : public Item public: VIRTUAL_COPY_CONS(Score_element); - /* - ugh. - - TODO: - - * junk these after spacing is done. - - * Put these in Scheme. - */ - - - Array minimal_dists_; - Array springs_; - - /* Not (yet) in scm, because of messy effects when a column commits suicide. */ int rank_i_; - /// set a minimum distance - void add_rod (Paper_column * to, Real distance); - void add_spring (Paper_column * to, Real dist, Real strength); - + virtual void do_break_processing (); virtual Paper_column *column_l () const; virtual Line_of_score *line_l () const; @@ -65,10 +45,10 @@ public: static int rank_i(Score_element*); Paper_column (SCM); - Moment when_mom ()const; - bool musical_b () const; - bool used_b () const; + static Moment when_mom (Score_element*); + + static bool used_b (Score_element*) ; void set_rank (int); }; diff --git a/lily/include/rest-collision.hh b/lily/include/rest-collision.hh index 39a9fcd120..79b7b8aa72 100644 --- a/lily/include/rest-collision.hh +++ b/lily/include/rest-collision.hh @@ -16,7 +16,7 @@ class Rest_collision // interface { public: - static void add_column (Score_element*me,Note_column*); + static void add_column (Score_element*me,Score_element*); static void set_interface (Score_element*me); static bool has_interface (Score_element*); static Real force_shift_callback (Score_element *, Axis); diff --git a/lily/include/rod.hh b/lily/include/rod.hh index f76a4e5b0c..d795f539ad 100644 --- a/lily/include/rod.hh +++ b/lily/include/rod.hh @@ -13,13 +13,6 @@ #include "direction.hh" #include "drul-array.hh" -struct Column_rod -{ - Paper_column *other_l_; - Real distance_f_; - - Column_rod (); -}; struct Rod diff --git a/lily/include/score-element.hh b/lily/include/score-element.hh index 0fd7fd077f..ebd656070d 100644 --- a/lily/include/score-element.hh +++ b/lily/include/score-element.hh @@ -139,8 +139,6 @@ public: virtual void do_break_processing (); virtual Score_element *find_broken_piece (Line_of_score*) const; - /// generate rods & springs - virtual void do_space_processing (); virtual void discretionary_processing (); virtual void do_derived_mark (); diff --git a/lily/include/script.hh b/lily/include/script.hh index b983b54716..0e4dfae387 100644 --- a/lily/include/script.hh +++ b/lily/include/script.hh @@ -10,19 +10,20 @@ #ifndef SCRIPT_HH #define SCRIPT_HH -#include "item.hh" -#include "drul-array.hh" +#include "lily-guile.hh" +#include "lily-proto.hh" /** Articulation marks (and the like) that are attached to notes/stems. Needs support from Staff_side for proper operation. Staff_side handles the positioning. */ -class Script : public Item +class Script { public: - static Molecule get_molecule (Score_element*,Direction d); - Script (SCM); + static Molecule get_molecule (Score_element*,Direction d); + static void set_interface (Score_element*); + static bool has_interface (Score_element*); static SCM brew_molecule (SCM); static SCM after_line_breaking (SCM); }; diff --git a/lily/include/separating-group-spanner.hh b/lily/include/separating-group-spanner.hh index 5c46dc3f8d..d01b6dbb51 100644 --- a/lily/include/separating-group-spanner.hh +++ b/lily/include/separating-group-spanner.hh @@ -12,14 +12,12 @@ #include "spanner.hh" -class Separating_group_spanner : public Spanner +class Separating_group_spanner { public: static void add_spacing_unit (Score_element*me, Item*); - Separating_group_spanner(SCM); -protected: - VIRTUAL_COPY_CONS(Score_element); - virtual Array get_rods () const; + static void set_interface (Score_element*); + static SCM set_spacing_rods (SCM); }; #endif /* SEPARATING_GROUP_SPANNER_HH */ diff --git a/lily/include/simple-spacer.hh b/lily/include/simple-spacer.hh index 0cc519fdbb..4f317b148a 100644 --- a/lily/include/simple-spacer.hh +++ b/lily/include/simple-spacer.hh @@ -73,7 +73,7 @@ struct Simple_spacer Simple_spacer (); void solve (Column_x_positions *) const; - void add_columns (Link_array); + void add_columns (Link_array); void my_solve_linelen (); void my_solve_natural_len (); Real active_springs_stiffness () const; diff --git a/lily/include/slur.hh b/lily/include/slur.hh index c9f6052d5a..83d0900834 100644 --- a/lily/include/slur.hh +++ b/lily/include/slur.hh @@ -7,34 +7,28 @@ #ifndef SLUR_HH #define SLUR_HH -#include "spanner.hh" +#include "lily-guile.hh" +#include "lily-proto.hh" #include "rod.hh" -/** - A #Bow# which tries to drape itself around the stems too. - */ -class Slur : public Spanner +class Slur { public: - Slur (SCM); - VIRTUAL_COPY_CONS(Score_element); - - void add_column (Note_column*); - static SCM brew_molecule (SCM); - - Array get_encompass_offset_arr () const; - Bezier get_curve () const; - - Direction get_default_dir () const; + static void add_column (Score_element*me,Score_element*col); + static SCM brew_molecule (SCM); + static void set_interface (Score_element*); + static bool has_interface (Score_element*); + static Array get_encompass_offset_arr (Score_element*me) ; + static Bezier get_curve (Score_element*me) ; + static Direction get_default_dir (Score_element*me) ; static SCM after_line_breaking (SCM); - Array get_rods () const; - Offset get_attachment (Direction dir, Score_element**common) const; - + static SCM set_spacing_rods (SCM); private: - void de_uglyfy (Slur_bezier_bow* bb, Real default_height); - void set_extremities (); - void set_control_points (); - Offset encompass_offset (Score_element *col,Score_element**common)const; + static Offset get_attachment (Score_element*me,Direction dir, Score_element**common) ; + static void de_uglyfy (Score_element*me,Slur_bezier_bow* bb, Real default_height); + static void set_extremities (Score_element*me); + static void set_control_points (Score_element*me); + static Offset encompass_offset (Score_element*me,Score_element *col,Score_element**common); }; #endif // SLUR_HH diff --git a/lily/include/spaceable-element.hh b/lily/include/spaceable-element.hh new file mode 100644 index 0000000000..72a713ed4c --- /dev/null +++ b/lily/include/spaceable-element.hh @@ -0,0 +1,29 @@ +/* + spaceable-element.hh -- declare Spaceable_element + + source file of the GNU LilyPond music typesetter + + (c) 2000 Han-Wen Nienhuys + + */ + +#ifndef SPACEABLE_ELEMENT_HH +#define SPACEABLE_ELEMENT_HH + +#include "lily-guile.hh" +#include "lily-proto.hh" + + +struct Spaceable_element +{ + /// set a minimum distance + static void add_rod (Score_element*me, Score_element * to, Real distance); + static void add_spring (Score_element*me,Score_element * to, Real dist, Real strength); + static void set_interface (Score_element*); + static void remove_interface (Score_element*); + static SCM get_minimum_distances (Score_element*); + static SCM get_ideal_distances (Score_element*); +}; + +#endif /* SPACEABLE_ELEMENT_HH */ + diff --git a/lily/include/spacing-engraver.hh b/lily/include/spacing-engraver.hh deleted file mode 100644 index be6c44ff3c..0000000000 --- a/lily/include/spacing-engraver.hh +++ /dev/null @@ -1,57 +0,0 @@ -/* - spacing-engraver.hh -- declare Spacing_engraver - - source file of the GNU LilyPond music typesetter - - (c) 1999--2000 Han-Wen Nienhuys - - */ - -#ifndef SPACING_ENGRAVER_HH -#define SPACING_ENGRAVER_HH - -#include "engraver.hh" -#include "pqueue.hh" - -struct Rhythmic_tuple -{ - Score_element_info info_; - Moment end_; - - Rhythmic_tuple () - { - } - Rhythmic_tuple (Score_element_info i, Moment m ) - { - info_ = i; - end_ = m; - } - static int time_compare (Rhythmic_tuple const &, Rhythmic_tuple const &); -}; - -/** - Acknowledge rhythmic elements, for initializing spacing fields in - the columns. - - should be the last one of the toplevel context -*/ -class Spacing_engraver : public Engraver -{ - PQueue playing_durations_; - Array now_durations_; - Array stopped_durations_; - - Spacing_spanner * spacing_p_; -protected: - VIRTUAL_COPY_CONS(Translator); - virtual void acknowledge_element (Score_element_info); - virtual void do_post_move_processing (); - virtual void do_pre_move_processing (); - virtual void do_creation_processing (); - virtual void do_removal_processing (); -public: - Spacing_engraver (); -}; - -#endif /* SPACING_ENGRAVER_HH */ - diff --git a/lily/include/spacing-spanner.hh b/lily/include/spacing-spanner.hh index c6e4bdd7cd..917b5fdc89 100644 --- a/lily/include/spacing-spanner.hh +++ b/lily/include/spacing-spanner.hh @@ -12,21 +12,17 @@ #include "spanner.hh" -class Spacing_spanner : public Spanner +class Spacing_spanner { public: - Spacing_spanner (SCM); - - VIRTUAL_COPY_CONS(Score_element); - Array do_measure (Link_array) const; - -protected: - virtual Array get_springs () const; - - Real stem_dir_correction (Paper_column*,Paper_column*) const; - Real default_bar_spacing (Paper_column*,Paper_column*,Moment) const; - Real note_spacing (Paper_column*,Paper_column*,Moment) const; - Real get_duration_space (Moment dur, Moment shortest) const; + static void set_interface (Score_element*); + static void do_measure (Score_element*,Link_array) ; + + static SCM set_springs (SCM); + static Real stem_dir_correction (Score_element*,Score_element*,Score_element*) ; + static Real default_bar_spacing (Score_element*,Score_element*,Score_element*,Moment) ; + static Real note_spacing (Score_element*,Score_element*,Score_element*,Moment) ; + static Real get_duration_space (Score_element*,Moment dur, Moment shortest) ; }; #endif /* SPACING_SPANNER_HH */ diff --git a/lily/include/spanner.hh b/lily/include/spanner.hh index 4ce355dd4c..dd5a61b21b 100644 --- a/lily/include/spanner.hh +++ b/lily/include/spanner.hh @@ -47,16 +47,11 @@ public: Real spanner_length () const; static int compare (Spanner * const &,Spanner * const &); - virtual Array get_rods () const; - virtual Array get_springs () const; virtual Score_element* find_broken_piece (Line_of_score*) const; virtual void do_derived_mark (); protected: void set_my_columns (); VIRTUAL_COPY_CONS(Score_element); - - - virtual void do_space_processing (); virtual void do_break_processing (); virtual Line_of_score*line_l () const; }; diff --git a/lily/include/stem.hh b/lily/include/stem.hh index d3b9eb8a1e..8c3e6f7691 100644 --- a/lily/include/stem.hh +++ b/lily/include/stem.hh @@ -7,10 +7,8 @@ #ifndef STEM_HH #define STEM_HH -#include "item.hh" -#include "array.hh" -#include "moment.hh" -#include "molecule.hh" +#include "lily-proto.hh" +#include "lily-guile.hh" #include "stem-info.hh" /**the rule attached to the ball. @@ -36,36 +34,29 @@ /// how many abbrev beam don't reach stem? int beam_gap_i_; - - */ -class Stem : public Item +class Stem { public: static SCM brew_molecule (SCM); /// log of the duration. Eg. 4 -> 16th note -> 2 flags static int flag_i (Score_element*) ; - static int beam_count (Score_element*,Direction) ; static void set_beaming (Score_element*,int, Direction d); /** don't print flag when in beam. our beam, for aligning abbrev flags */ - static Beam * beam_l (Score_element*); + static Score_element * beam_l (Score_element*); static Score_element * first_head (Score_element*) ; static Drul_array extremal_heads (Score_element*); - static Score_element * support_head (Score_element*) ; - Stem (SCM); - + /// ensure that this Stem also encompasses the Notehead #n# static void add_head (Score_element*me, Score_element*n); - static Stem_info calc_stem_info (Score_element *) ; - static Real chord_start_f (Score_element *) ; static Direction get_direction (Score_element*) ; static int type_i (Score_element *) ; @@ -73,13 +64,10 @@ public: static Direction get_default_dir(Score_element *) ; static int get_center_distance(Score_element *,Direction) ; static int heads_i (Score_element *) ; - static bool invisible_b(Score_element *) ; /// heads that the stem encompasses (positions) static Interval head_positions(Score_element *) ; - - static Real get_default_stem_end_position (Score_element*me) ; static void position_noteheads(Score_element*); static Real stem_end_position (Score_element*) ; diff --git a/lily/include/system-start-delimiter.hh b/lily/include/system-start-delimiter.hh index b5c500c6f7..121713d9e6 100644 --- a/lily/include/system-start-delimiter.hh +++ b/lily/include/system-start-delimiter.hh @@ -10,25 +10,24 @@ #ifndef SYSTEM_START_DELIMITER_HH #define SYSTEM_START_DELIMITER_HH -#include "spanner.hh" +#include "lily-guile.hh" +#include "lily-proto.hh" /* Braces/brackets across staffs. */ -class System_start_delimiter : public Spanner +class System_start_delimiter { public: - System_start_delimiter (SCM); static SCM brew_molecule (SCM); - VIRTUAL_COPY_CONS (Score_element); - + static void set_interface (Score_element*me); + static bool has_interface (Score_element*); static SCM after_line_breaking (SCM); static void try_collapse (Score_element*); - - Molecule staff_bracket (Real) const; - Molecule staff_brace (Real) const; - Molecule simple_bar (Real) const; + static Molecule staff_bracket (Score_element*,Real) ; + static Molecule staff_brace (Score_element*,Real) ; + static Molecule simple_bar (Score_element*,Real) ; }; #endif /* SYSTEM_START_DELIMITER_HH */ diff --git a/lily/include/tie-column.hh b/lily/include/tie-column.hh index bbee8fede5..8dfab669bd 100644 --- a/lily/include/tie-column.hh +++ b/lily/include/tie-column.hh @@ -11,17 +11,15 @@ #ifndef TIE_COLUMN_HH #define TIE_COLUMN_HH -#include "spanner.hh" +#include "lily-proto.hh" +#include "lily-guile.hh" -class Tie_column : public Spanner +class Tie_column { public: - Tie_column (SCM s); - VIRTUAL_COPY_CONS (Score_element); static void set_interface (Score_element*me); static bool has_interface (Score_element*); static void add_tie (Score_element*me,Tie*); - static SCM after_line_breaking (SCM); static void set_directions (Score_element*me); }; diff --git a/lily/include/tie.hh b/lily/include/tie.hh index ea1f5f97f3..422a9fa375 100644 --- a/lily/include/tie.hh +++ b/lily/include/tie.hh @@ -38,7 +38,7 @@ public: Bezier get_curve () const; Drul_array dy_f_drul_; Drul_array dx_f_drul_; - virtual Array get_rods () const; + static SCM set_spacing_rods (SCM); Array get_controls () const; }; diff --git a/lily/instrument-name-engraver.cc b/lily/instrument-name-engraver.cc index 910a8f8ef5..8b65565b94 100644 --- a/lily/instrument-name-engraver.cc +++ b/lily/instrument-name-engraver.cc @@ -17,7 +17,7 @@ class Instrument_name_engraver : public Engraver { Item *text_; - System_start_delimiter * delim_ ; + Spanner * delim_ ; void create_text (SCM s); public: @@ -84,10 +84,10 @@ Instrument_name_engraver::acknowledge_element (Score_element_info i) } } - if (dynamic_cast (i.elem_l_) + if (System_start_delimiter::has_interface (i.elem_l_) && i.origin_trans_l_->daddy_trans_l_ == daddy_trans_l_) { - delim_ = dynamic_cast (i.elem_l_); + delim_ = dynamic_cast (i.elem_l_); } } diff --git a/lily/item.cc b/lily/item.cc index 319c402842..4e995bfd77 100644 --- a/lily/item.cc +++ b/lily/item.cc @@ -31,15 +31,23 @@ Item::Item (Item const &s) } - bool -Item::breakable_b () const +Item::breakable_b (Score_element*me) { - if (original_l_ ) + if (me->original_l_) return false; + + if (!dynamic_cast(me)) + programming_error ("only items can be breakable."); - Item * i =dynamic_cast (parent_l (X_AXIS)); - return (i) ? i->breakable_b () : to_boolean (get_elt_property ("breakable")); + Item * i =dynamic_cast (me->parent_l (X_AXIS)); + return (i) ? Item::breakable_b (i) : to_boolean (me->get_elt_property ("breakable")); +} + +Paper_column * +Item::column_l () const +{ + return dynamic_cast (parent_l (X_AXIS))->column_l (); } Line_of_score * @@ -83,7 +91,7 @@ Item::discretionary_processing() if (broken_b ()) return; - if (breakable_b ()) + if (Item::breakable_b (this)) copy_breakable_items(); } @@ -114,11 +122,6 @@ Item::find_prebroken_piece (Direction d) const return dynamic_cast (broken_to_drul_[d]); } -Paper_column * -Item::column_l () const -{ - return dynamic_cast (parent_l (X_AXIS))->column_l (); -} Direction Item::break_status_dir () const diff --git a/lily/line-of-score.cc b/lily/line-of-score.cc index 464212d3cb..ff641c0c24 100644 --- a/lily/line-of-score.cc +++ b/lily/line-of-score.cc @@ -133,7 +133,7 @@ Line_of_score::break_into_pieces (Array const &breaking) Line_of_score *line_l = dynamic_cast (clone()); line_l->rank_i_ = i; // line_l->set_immutable_elt_property ("rank", gh_int2scm( i)); - Link_array c (breaking[i].cols_); + Link_array c (breaking[i].cols_); pscore_l_->typeset_line (line_l); line_l->set_bound(LEFT,c[0]); @@ -141,7 +141,7 @@ Line_of_score::break_into_pieces (Array const &breaking) for (int j=0; j < c.size(); j++) { c[j]->translate_axis (breaking[i].config_[j],X_AXIS); - c[j]->line_l_ = line_l; + dynamic_cast (c[j])->line_l_ = line_l; } broken_into_l_arr_.push (line_l); @@ -233,7 +233,12 @@ Line_of_score::pre_processing () progress_indication ("\n" + _ ("Calculating column positions...") + " " ); for (SCM s = get_elt_property ("all-elements"); gh_pair_p (s); s = gh_cdr (s)) - unsmob_element (gh_car (s))->do_space_processing (); + { + Score_element * e = unsmob_element (gh_car (s)); + SCM proc = e->get_elt_property ("spacing-procedure"); + if (gh_procedure_p (proc)) + gh_call1 (proc, e->self_scm_); + } } void @@ -325,9 +330,8 @@ Line_of_score::broken_col_range (Item const*l, Item const*r) const while (gh_pair_p (s) && gh_car (s) != l->self_scm_) { - Paper_column *c - = dynamic_cast (unsmob_element (gh_car (s))); - if (c->breakable_b () && !c->line_l_) + Paper_column*c = dynamic_cast ( unsmob_element (gh_car (s))); + if (Item::breakable_b (c) && !c->line_l_) ret.push (c); s = gh_cdr (s); @@ -341,15 +345,15 @@ Line_of_score::broken_col_range (Item const*l, Item const*r) const Return all columns, but filter out any unused columns , since they might disrupt the spacing problem. */ -Link_array +Link_array Line_of_score::column_l_arr ()const { - Link_array acs - = Pointer_group_interface__extract_elements (this, (Paper_column*) 0, "columns"); + Link_array acs + = Pointer_group_interface__extract_elements (this, (Score_element*) 0, "columns"); bool bfound = false; for (int i= acs.size (); i -- ; ) { - bool brb = acs[i]->breakable_b(); + bool brb = Item::breakable_b (acs[i]); bfound = bfound || brb; /* @@ -357,7 +361,7 @@ Line_of_score::column_l_arr ()const seem empty. We need to retain breakable columns, in case someone forced a breakpoint. */ - if (!bfound || !acs[i]->used_b ()) + if (!bfound || !Paper_column::used_b (acs[i])) acs.del (i); } return acs; diff --git a/lily/main.cc b/lily/main.cc index fe92bbafa3..d575245570 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -33,9 +33,6 @@ #include #endif -extern "C" { -#include -} bool verbose_global_b = false; bool no_paper_global_b = false; @@ -312,12 +309,6 @@ main (int argc, char **argv) setenv ("GUILE_INIT_SEGMENT_SIZE_1", "4194304", 0); setenv ("GUILE_MAX_SEGMENT_SIZE", "8388608", 0); - /* - initialize kpathsea - */ - kpse_set_program_name(argv[0], NULL); - kpse_maketex_option("tfm", TRUE); - oparser_global_p = new Getopt_long(argc, argv,theopts); while (Long_option_init const * opt = (*oparser_global_p)()) { diff --git a/lily/multi-measure-rest-engraver.cc b/lily/multi-measure-rest-engraver.cc index 84d5061e7f..6a5d06ed7d 100644 --- a/lily/multi-measure-rest-engraver.cc +++ b/lily/multi-measure-rest-engraver.cc @@ -111,7 +111,8 @@ Multi_measure_rest_engraver::do_process_music () if (busy_span_req_l_ && !mmrest_p_) { - mmrest_p_ = new Multi_measure_rest (get_property ("basicMultiMeasureRestProperties")); + mmrest_p_ = new Spanner (get_property ("basicMultiMeasureRestProperties")); + Multi_measure_rest::set_interface (mmrest_p_); Staff_symbol_referencer::set_interface (mmrest_p_); diff --git a/lily/multi-measure-rest.cc b/lily/multi-measure-rest.cc index 6d95336d3a..ba2e2cbc24 100644 --- a/lily/multi-measure-rest.cc +++ b/lily/multi-measure-rest.cc @@ -11,24 +11,20 @@ #include "debug.hh" #include "paper-def.hh" #include "paper-column.hh" // urg -#include "bar.hh" #include "lookup.hh" #include "rest.hh" #include "molecule.hh" #include "misc.hh" #include "group-interface.hh" -#include "stem.hh" +#include "spanner.hh" #include "staff-symbol-referencer.hh" + void Multi_measure_rest::set_interface (Score_element*me) { me->set_elt_property ("columns", SCM_EOL); } -Multi_measure_rest::Multi_measure_rest (SCM s) - : Spanner(s) -{} - /* [TODO] 17 * variable-sized multi-measure rest symbol: |====| ?? @@ -151,19 +147,22 @@ Multi_measure_rest::add_column (Score_element*me,Item* c) } -Array -Multi_measure_rest::get_rods () const +MAKE_SCHEME_CALLBACK (Multi_measure_rest, set_spacing_rods); + +SCM +Multi_measure_rest::set_spacing_rods (SCM smob) { - Array a; + Score_element*me = unsmob_element (smob); - if (!(get_bound (LEFT) && get_bound (RIGHT))) + Spanner*sp = dynamic_cast (me); + if (!(sp->get_bound (LEFT) && sp->get_bound (RIGHT))) { programming_error ("Multi_measure_rest::get_rods (): I am not spanned!"); - return a; + return SCM_UNDEFINED; } - Item * l = get_bound (LEFT)->column_l (); - Item * r = get_bound (RIGHT)->column_l (); + Item * l = sp->get_bound (LEFT)->column_l (); + Item * r = sp->get_bound (RIGHT)->column_l (); Item * lb = l->find_prebroken_piece (RIGHT); Item * rb = r->find_prebroken_piece (LEFT); @@ -184,11 +183,10 @@ Multi_measure_rest::get_rods () const should do something more advanced. */ rod.distance_f_ = l->extent (X_AXIS)[BIGGER] - r->extent (X_AXIS)[SMALLER] - + paper_l ()->get_var ("multi_measure_rest_x_minimum"); + + me->paper_l ()->get_var ("multi_measure_rest_x_minimum"); - a.push (rod); + rod.add_to_cols (); } - - return a; + return SCM_UNDEFINED; } diff --git a/lily/note-column.cc b/lily/note-column.cc index 7616a119b5..473c014663 100644 --- a/lily/note-column.cc +++ b/lily/note-column.cc @@ -18,13 +18,13 @@ #include "note-head.hh" bool -Note_column::rest_b () const +Note_column::rest_b (Score_element*me) { - return unsmob_element (get_elt_property ("rest")); + return unsmob_element (me->get_elt_property ("rest")); } int -Note_column::shift_compare (Note_column *const &p1, Note_column*const&p2) +Note_column::shift_compare (Score_element *const &p1, Score_element *const&p2) { SCM s1 = p1->get_elt_property ("horizontal-shift"); SCM s2 = p2->get_elt_property ("horizontal-shift"); @@ -34,10 +34,9 @@ Note_column::shift_compare (Note_column *const &p1, Note_column*const&p2) return h1 - h2; } -Note_column::Note_column( SCM s) - : Item (s) +void +Note_column::set_interface (Score_element* me) { - Score_element* me = this; me->set_elt_property ("note-heads", SCM_EOL); me->set_interface (ly_symbol2scm ("note-column-interface")); @@ -46,12 +45,11 @@ Note_column::Note_column( SCM s) } Item * -Note_column::stem_l () const +Note_column::stem_l (Score_element*me) { - SCM s = get_elt_property ("stem"); + SCM s = me->get_elt_property ("stem"); return dynamic_cast(unsmob_element (s)); } - Slice Note_column::head_positions_interval(Score_element *me) @@ -72,7 +70,7 @@ Note_column::head_positions_interval(Score_element *me) } Direction -Note_column::static_dir (Score_element* me) +Note_column::dir (Score_element* me) { Score_element *stem = unsmob_element (me->get_elt_property ("stem")); if (stem && Stem::has_interface (stem)) @@ -85,43 +83,36 @@ Note_column::static_dir (Score_element* me) } -Direction -Note_column::dir () const -{ - return static_dir ((Score_element*) this); -} - void -Note_column::set_stem (Score_element * stem_l) +Note_column::set_stem (Score_element*me,Score_element * stem_l) { - set_elt_property ("stem", stem_l->self_scm_); - - add_dependency (stem_l); - Axis_group_interface::add_element (this, stem_l); + me->set_elt_property ("stem", stem_l->self_scm_); + me->add_dependency (stem_l); + Axis_group_interface::add_element (me, stem_l); } void -Note_column::add_head (Score_element *h) +Note_column::add_head (Score_element*me,Score_element *h) { if (Rest::has_interface (h)) { - this->set_elt_property ("rest", h->self_scm_); + me->set_elt_property ("rest", h->self_scm_); } else if (Note_head::has_interface (h)) { - Pointer_group_interface gi (this, "note-heads"); + Pointer_group_interface gi (me, "note-heads"); gi.add_element (h); } - Axis_group_interface::add_element (this, h); + Axis_group_interface::add_element (me, h); } /** translate the rest symbols vertically by amount DY_I. */ void -Note_column::translate_rests (int dy_i) +Note_column::translate_rests (Score_element*me,int dy_i) { - Score_element * r = unsmob_element (get_elt_property ("rest")); + Score_element * r = unsmob_element (me->get_elt_property ("rest")); if (r) { r->translate_axis (dy_i * Staff_symbol_referencer::staff_space (r)/2.0, Y_AXIS); @@ -130,24 +121,24 @@ Note_column::translate_rests (int dy_i) void -Note_column::set_dotcol (Score_element *d) +Note_column::set_dotcol (Score_element*me,Score_element *d) { - Axis_group_interface::add_element (this, d); + Axis_group_interface::add_element (me, d); } Interval -Note_column::rest_dim () const +Note_column::rest_dim (Score_element*me) { - Score_element * r = unsmob_element (get_elt_property ("rest")); + Score_element * r = unsmob_element (me->get_elt_property ("rest")); return r->extent (Y_AXIS); } Score_element* -Note_column::first_head () const +Note_column::first_head (Score_element*me) { - Score_element * st = stem_l (); + Score_element * st = stem_l (me); return st? Stem::first_head (st): 0; } diff --git a/lily/paper-column.cc b/lily/paper-column.cc index 579d028256..fcdc933f9a 100644 --- a/lily/paper-column.cc +++ b/lily/paper-column.cc @@ -10,62 +10,13 @@ #include "paper-score.hh" #include "debug.hh" #include "axis-group-interface.hh" +#include "spaceable-element.hh" void -Paper_column::add_rod (Paper_column * p, Real d) +Paper_column::do_break_processing () { - Direction dir = Direction (sign (rank_i(p) -rank_i (this))); - - if (dir != RIGHT) - { - programming_error ("Must set minimum distance LTOR."); - return; - } - - for (int i=0; i < minimal_dists_.size (); i++) - { - Column_rod &rod = minimal_dists_[i]; - if (rod.other_l_ == p) - { - rod.distance_f_ = rod.distance_f_ >? d; - return ; - } - } - - Column_rod cr; - cr.distance_f_ = d; - cr.other_l_ = p; - - minimal_dists_.push (cr); -} - -void -Paper_column::add_spring (Paper_column * p, Real d, Real s) -{ - Direction dir = Direction (sign (rank_i(p) -rank_i (this))); - - if (dir != RIGHT) - { - programming_error ("Must set springs LTOR"); - return; - } - - for (int i=0; i < springs_.size (); i++) - { - Column_spring &spring = springs_[i]; - if (spring.other_l_ == p) - { - spring.distance_f_ = spring.distance_f_ >? d; - return ; - } - } - - Column_spring cr; - cr.distance_f_ = d; - cr.strength_f_ = s; - cr.other_l_ = p; - - springs_.push (cr); + Spaceable_element::remove_interface(this); + Item::do_break_processing (); } int @@ -91,19 +42,20 @@ Paper_column::Paper_column (SCM l) { Axis_group_interface::set_interface (this); Axis_group_interface::set_axes (this, X_AXIS, X_AXIS); + Spaceable_element::set_interface (this); set_elt_property ("bounded-by-me", SCM_EOL); line_l_=0; rank_i_ = -1; } Moment -Paper_column::when_mom () const +Paper_column::when_mom (Score_element*me) { - SCM m = get_elt_property ("when"); + SCM m = me->get_elt_property ("when"); Moment s (0); - if (SMOB_IS_TYPE_B(Moment, m)) + if (unsmob_moment (m)) { - s = *SMOB_TO_TYPE (Moment,m); + return *unsmob_moment (m); } return s; } @@ -113,17 +65,17 @@ Paper_column::musical_b () const { SCM m = get_elt_property ("shortest-starter-duration"); Moment s (0); - if (SMOB_IS_TYPE_B(Moment, m)) + if (unsmob_moment (m)) { - s = *SMOB_TO_TYPE (Moment,m); + s = *unsmob_moment (m); } return s != Moment(0); } bool -Paper_column::used_b ()const +Paper_column::used_b (Score_element*me ) { - return gh_pair_p (get_elt_property ("elements")) || breakable_b () - || gh_pair_p (get_elt_property ("bounded-by-me")) + return gh_pair_p (me->get_elt_property ("elements")) || Item::breakable_b (me) + || gh_pair_p (me->get_elt_property ("bounded-by-me")) ; } diff --git a/lily/paper-score.cc b/lily/paper-score.cc index 601ce748cb..86797de758 100644 --- a/lily/paper-score.cc +++ b/lily/paper-score.cc @@ -79,7 +79,7 @@ Paper_score::process () /* Be sure to set breakability on first & last column. */ - Link_array pc (line_l_->column_l_arr ()); + Link_array pc (line_l_->column_l_arr ()); pc[0]->set_elt_property ("breakable", SCM_BOOL_T); pc.top ()->set_elt_property ("breakable", SCM_BOOL_T); diff --git a/lily/rest-collision-engraver.cc b/lily/rest-collision-engraver.cc index fc310aef05..e748b88c01 100644 --- a/lily/rest-collision-engraver.cc +++ b/lily/rest-collision-engraver.cc @@ -16,7 +16,7 @@ class Rest_collision_engraver : public Engraver { Item* rest_collision_p_; - Link_array note_column_l_arr_; + Link_array note_column_l_arr_; protected: virtual void acknowledge_element (Score_element_info); virtual void process_acknowledged (); @@ -50,8 +50,8 @@ Rest_collision_engraver::process_acknowledged () void Rest_collision_engraver::acknowledge_element (Score_element_info i) { - if (dynamic_cast (i.elem_l_)) - note_column_l_arr_.push (dynamic_cast (i.elem_l_)); + if (Note_column::has_interface (i.elem_l_)) + note_column_l_arr_.push (i.elem_l_); } void diff --git a/lily/rest-collision.cc b/lily/rest-collision.cc index 7a26dee1a9..9d86cbb81b 100644 --- a/lily/rest-collision.cc +++ b/lily/rest-collision.cc @@ -41,7 +41,7 @@ Rest_collision::force_shift_callback (Score_element *them, Axis a) } void -Rest_collision::add_column (Score_element*me,Note_column *p) +Rest_collision::add_column (Score_element*me,Score_element *p) { me->add_dependency (p); Pointer_group_interface gi (me); @@ -72,16 +72,16 @@ Rest_collision::do_shift (Score_element *me, SCM elts) /* ugh. -> score elt type */ - Link_array rests; - Link_array notes; + Link_array rests; + Link_array notes; for (SCM s = elts; gh_pair_p (s); s = gh_cdr (s)) { Score_element * e = unsmob_element (gh_car (s)); if (e && unsmob_element (e->get_elt_property ("rest"))) - rests.push (dynamic_cast (e)); + rests.push (e); else - notes.push (dynamic_cast (e)); + notes.push (e); } @@ -147,8 +147,8 @@ Rest_collision::do_shift (Score_element *me, SCM elts) int dy = display_count > 2 ? 6 : 4; if (display_count > 1) { - rests[0]->translate_rests (dy); - rests[1]->translate_rests (-dy); + Note_column::translate_rests (rests[0],dy); + Note_column::translate_rests (rests[1], -dy); } } // meisjes met jongetjes @@ -162,12 +162,12 @@ Rest_collision::do_shift (Score_element *me, SCM elts) { warning (_("too many notes for rest collision")); } - Note_column * rcol = rests[0]; + Score_element * rcol = rests[0]; // try to be opposite of noteheads. - Direction dir = - notes[0]->dir(); + Direction dir = - Note_column::dir (notes[0]); - Interval restdim = rcol->rest_dim (); + Interval restdim = Note_column::rest_dim (rcol); if (restdim.empty_b ()) return SCM_UNDEFINED; @@ -208,7 +208,7 @@ Rest_collision::do_shift (Score_element *me, SCM elts) if (discrete_dist < stafflines+1) discrete_dist = int (ceil (discrete_dist / 2.0)* 2.0); - rcol->translate_rests (dir * discrete_dist); + Note_column::translate_rests (rcol,dir * discrete_dist); } return SCM_UNDEFINED; } diff --git a/lily/rhythmic-column-engraver.cc b/lily/rhythmic-column-engraver.cc index b83520535c..82c02d9a4a 100644 --- a/lily/rhythmic-column-engraver.cc +++ b/lily/rhythmic-column-engraver.cc @@ -19,9 +19,9 @@ class Rhythmic_column_engraver :public Engraver { Link_array rhead_l_arr_; - Link_array grace_slur_endings_; + Link_array grace_slur_endings_; Score_element * stem_l_; - Note_column *ncol_p_; + Score_element *ncol_p_; Score_element *dotcol_l_; protected: @@ -52,14 +52,15 @@ Rhythmic_column_engraver::process_acknowledged () { if (!ncol_p_) { - ncol_p_ = new Note_column (get_property("basicNoteColumnProperties")); + ncol_p_ = new Item (get_property("basicNoteColumnProperties")); + Note_column::set_interface (ncol_p_); announce_element (Score_element_info (ncol_p_, 0)); } for (int i=0; i < rhead_l_arr_.size (); i++) { if (!rhead_l_arr_[i]->parent_l(X_AXIS)) - ncol_p_->add_head (rhead_l_arr_[i]); + Note_column::add_head (ncol_p_, rhead_l_arr_[i]); } rhead_l_arr_.set_size (0); } @@ -70,13 +71,13 @@ Rhythmic_column_engraver::process_acknowledged () if (dotcol_l_ && !dotcol_l_->parent_l (X_AXIS)) { - ncol_p_->set_dotcol (dotcol_l_); + Note_column::set_dotcol (ncol_p_, dotcol_l_); } if (stem_l_ && !stem_l_->parent_l(X_AXIS)) { - ncol_p_->set_stem (stem_l_); + Note_column::set_stem (ncol_p_, stem_l_); stem_l_ = 0; } @@ -85,7 +86,7 @@ Rhythmic_column_engraver::process_acknowledged () if (!wegrace) for (int i=0; i < grace_slur_endings_.size(); i++) - grace_slur_endings_[i]->add_column (ncol_p_); + Slur::add_column (grace_slur_endings_[i], ncol_p_); grace_slur_endings_.clear (); } } @@ -96,7 +97,7 @@ Rhythmic_column_engraver::acknowledge_element (Score_element_info i) SCM wg = get_property ("weAreGraceContext"); bool wegrace = to_boolean (wg); if (wegrace != to_boolean (i.elem_l_->get_elt_property ("grace")) - && !dynamic_cast (i.elem_l_)) + && !Slur::has_interface (i.elem_l_)) return ; Item * item = dynamic_cast (i.elem_l_); @@ -112,14 +113,14 @@ Rhythmic_column_engraver::acknowledge_element (Score_element_info i) { dotcol_l_ = item; } - else if (Slur *s = dynamic_cast (i.elem_l_)) + else if (Slur::has_interface (i.elem_l_)) { /* end slurs starting on grace notes */ - if (to_boolean (s->get_elt_property ("grace"))) - grace_slur_endings_.push (s); + if (to_boolean (i.elem_l_->get_elt_property ("grace"))) + grace_slur_endings_.push (i.elem_l_); } } diff --git a/lily/rhythmic-head.cc b/lily/rhythmic-head.cc index 9c8cb00b50..63006674fc 100644 --- a/lily/rhythmic-head.cc +++ b/lily/rhythmic-head.cc @@ -16,6 +16,7 @@ #include "paper-score.hh" #include "stem.hh" #include "staff-symbol-referencer.hh" +#include "item.hh" Item* diff --git a/lily/rod.cc b/lily/rod.cc index 15b4c7a808..621fd15de2 100644 --- a/lily/rod.cc +++ b/lily/rod.cc @@ -10,8 +10,7 @@ #include "paper-column.hh" #include "debug.hh" #include "dimensions.hh" -#include "separation-item.hh" - +#include "spaceable-element.hh" Rod::Rod () { @@ -20,11 +19,6 @@ Rod::Rod () } -Column_rod::Column_rod () -{ - distance_f_ = 0; - other_l_ = 0; -} void Rod::columnize () @@ -43,7 +37,8 @@ Rod::add_to_cols () { columnize(); if (item_l_drul_[LEFT] != item_l_drul_[RIGHT]) - dynamic_cast (item_l_drul_[LEFT])-> - add_rod(dynamic_cast(item_l_drul_[RIGHT]), distance_f_ ); + Spaceable_element::add_rod (item_l_drul_[LEFT], + item_l_drul_[RIGHT], + distance_f_ ); } diff --git a/lily/score-element.cc b/lily/score-element.cc index 5b17ffbbd3..47ca5c9eea 100644 --- a/lily/score-element.cc +++ b/lily/score-element.cc @@ -265,10 +265,6 @@ Score_element::do_break_processing() { } -void -Score_element::do_space_processing () -{ -} void Score_element::do_add_processing() diff --git a/lily/score-engraver.cc b/lily/score-engraver.cc index 842a896fb7..1e35503f42 100644 --- a/lily/score-engraver.cc +++ b/lily/score-engraver.cc @@ -195,7 +195,7 @@ Score_engraver::set_columns (Paper_column *new_command_l, if (*current[i]) { scoreline_l_->add_column ((*current[i])); - if (!(*current[i])->used_b()) + if (!Paper_column::used_b (*current[i])) { (*current[i])->suicide (); *current[i] =0; diff --git a/lily/script-column-engraver.cc b/lily/script-column-engraver.cc index 47c37cfcaa..02676f0145 100644 --- a/lily/script-column-engraver.cc +++ b/lily/script-column-engraver.cc @@ -60,7 +60,7 @@ Script_column_engraver::acknowledge_element( Score_element_info inf) { Item *thing = dynamic_cast (inf.elem_l_); if (thing - && !thing->breakable_b () + && !Item::breakable_b (thing) && Side_position::get_axis (inf.elem_l_) == Y_AXIS) { script_l_arr_.push (thing); diff --git a/lily/script-engraver.cc b/lily/script-engraver.cc index 2f433d9d37..effd5b7123 100644 --- a/lily/script-engraver.cc +++ b/lily/script-engraver.cc @@ -10,12 +10,10 @@ #include "musical-request.hh" #include "stem.hh" #include "rhythmic-head.hh" - - #include "engraver.hh" class Script_engraver : public Engraver { - Link_array