From 6dfa9e3be119a27e17be77c6374ada2e173cda3e Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sat, 10 Oct 1998 18:37:44 +0300 Subject: [PATCH] patch::: 1.0.14.jcn1: braak pl 14.jcn1 - moved most ugly lookup stuff - {Ps,Tex}_{def,score}.{cc,hh} ********* pl 14 --- NEWS | 7 ++ VERSION | 2 +- lily/atom.cc | 6 +- lily/dimensions.cc | 16 +++ lily/include/dimensions.hh | 2 + lily/include/file-results.hh | 4 +- lily/include/lily-proto.hh | 4 + lily/include/lookup.hh | 8 +- lily/include/main.hh | 1 + lily/include/music-output-def.hh | 3 + lily/include/p-score.hh | 7 +- lily/include/paper-def.hh | 16 +-- lily/include/ps-def.hh | 28 +++++ lily/include/ps-lookup.hh | 5 - lily/include/ps-score.hh | 21 ++++ lily/include/tex-def.hh | 29 +++++ lily/include/tex-lookup.hh | 6 - lily/include/tex-score.hh | 21 ++++ lily/line-spacer.cc | 18 +-- lily/lookup.cc | 23 +--- lily/main.cc | 7 ++ lily/music-output-def.cc | 12 ++ lily/my-lily-parser.cc | 2 +- lily/p-score.cc | 22 +++- lily/paper-def.cc | 204 ++++++++++++++++-------------- lily/paper-outputter.cc | 5 +- lily/parser.yy | 4 +- lily/ps-def.cc | 53 ++++++++ lily/ps-lookup.cc | 53 -------- lily/ps-score.cc | 48 +++++++ lily/score-engraver.cc | 22 +++- lily/scores.cc | 2 + lily/spring-spacer.cc | 206 +++++++++++++++---------------- lily/tex-def.cc | 59 +++++++++ lily/tex-lookup.cc | 69 ----------- lily/tex-score.cc | 52 ++++++++ make/STATE-VECTOR | 1 + 37 files changed, 656 insertions(+), 392 deletions(-) create mode 100644 lily/dimensions.cc create mode 100644 lily/include/ps-def.hh create mode 100644 lily/include/ps-score.hh create mode 100644 lily/include/tex-def.hh create mode 100644 lily/include/tex-score.hh create mode 100644 lily/ps-def.cc create mode 100644 lily/ps-score.cc create mode 100644 lily/tex-def.cc create mode 100644 lily/tex-score.cc diff --git a/NEWS b/NEWS index c615f4cf69..5b362a2de4 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,10 @@ +pl 14.jcn1 + - moved most ugly lookup stuff + - {Ps,Tex}_{def,score}.{cc,hh} + +********* +pl 14 + pl 13.uu1 - bfs for footer - bf: init/{book,center}-fragment.ly, YODL nofooter stuff. diff --git a/VERSION b/VERSION index 41cbf15065..fc23336661 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=0 PATCH_LEVEL=14 -MY_PATCH_LEVEL= +MY_PATCH_LEVEL=jcn1 # use the above to send patches: MY_PATCH_LEVEL is always empty for a # released version. diff --git a/lily/atom.cc b/lily/atom.cc index 76b59197d3..8e32fd0133 100644 --- a/lily/atom.cc +++ b/lily/atom.cc @@ -13,7 +13,7 @@ #include "array.hh" #include "debug.hh" #include "dimensions.hh" -#include "lookup.hh" +#include "paper-def.hh" #include "main.hh" inline bool @@ -29,7 +29,7 @@ Atom::check_infinity_b ()const if (abs (off_[ax]) >= 100 CM) { warning (_f ("ridiculous dimension: %s, %s", axis_name_str (ax), - global_lookup_l->print_dimen (off_[ax]))); + dimension_str (off_[ax]))); if (experimental_features_global_b) assert (false); @@ -76,7 +76,7 @@ Atom::Atom () But Atom is used as a simple type *everywhere*, and we don't have virtual contructors. */ - str_ = global_lookup_l->unknown_str (); + str_ = global_paper_l->unknown_str (); } Atom::Atom (String s, Box b) diff --git a/lily/dimensions.cc b/lily/dimensions.cc new file mode 100644 index 0000000000..26a5c082e8 --- /dev/null +++ b/lily/dimensions.cc @@ -0,0 +1,16 @@ + +#include "warn.hh" +#include "dimensions.hh" + +String +dimension_str (Real r) +{ + String s = to_str (r, "%.3f"); + if (s.index_i ("NaN") != -1) + { + warning (_ ("NaN")); + s = "0.0"; + } + return s; +} + diff --git a/lily/include/dimensions.hh b/lily/include/dimensions.hh index 777d80e89c..91b6e0c4d6 100644 --- a/lily/include/dimensions.hh +++ b/lily/include/dimensions.hh @@ -14,5 +14,7 @@ const Real PT_TO_PT =1.0; #define CM *CM_TO_PT #define INCH *INCH_TO_PT +String dimension_str (Real r); + #endif // DIMENSIONS_HH diff --git a/lily/include/file-results.hh b/lily/include/file-results.hh index f4cf779c17..a9cf1abdaf 100644 --- a/lily/include/file-results.hh +++ b/lily/include/file-results.hh @@ -9,7 +9,9 @@ #ifndef FILE_RESULTS_HH #define FILE_RESULTS_HH -#include "fproto.hh" + +#include "lily-proto.hh" +#include "string.hh" void do_one_file (String init_str, String file_str); extern Header *header_global_p; diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh index 25682a4cc4..f1884ac8cf 100644 --- a/lily/include/lily-proto.hh +++ b/lily/include/lily-proto.hh @@ -173,6 +173,8 @@ struct Piano_brace; struct Performer; struct Performer_group_performer; struct Property_iterator; +struct Ps_score; +struct Ps_def; struct Ps_lookup; struct Ps_outputter; struct Ps_stream; @@ -227,6 +229,8 @@ struct Symtables; struct Super_element; struct Translation_property; struct Tempo_req; +struct Tex_def; +struct Tex_score; struct Tex_lookup; struct Tex_outputter; struct Tex_stream; diff --git a/lily/include/lookup.hh b/lily/include/lookup.hh index 40dc740c14..9b1e198a44 100644 --- a/lily/include/lookup.hh +++ b/lily/include/lookup.hh @@ -36,7 +36,6 @@ public: virtual Atom* atom_p (String, int, Box) const = 0; Atom ball (int) const; Atom bar (String, Real height) const; - String base_output_str () const; Atom beam (Real,Real, Real) const; virtual String character_str (int i) const; Atom clef (String) const; @@ -46,14 +45,10 @@ public: Atom fill (Box b) const; Atom flag (int, Direction) const; virtual Atom hairpin (Real width, bool decresc, bool continued) const = 0; - virtual Lookup* lookup_p (Lookup const&) const = 0; - virtual Lookup* lookup_p (Symtables const&) const = 0; - virtual Paper_outputter* paper_outputter_p (Paper_stream*, Paper_def*, Header*, String) const = 0; - virtual Paper_stream* paper_stream_p () const = 0; virtual Atom plet (Real dy, Real dx, Direction dir) const = 0; void print () const; virtual Atom ps_beam (Real slope, Real width, Real thick) const = 0; - virtual String print_dimen (Real) const; + String print_dimen (Real) const; Atom rest (int, bool outside) const; Atom rule_symbol (Real height, Real width) const; Atom script (String idx) const; @@ -71,7 +66,6 @@ public: virtual Atom slur (Array controls) const = 0; Atom streepje (int type) const; virtual Atom text (String style, String text) const; - virtual String unknown_str () const = 0; Atom vbrace (Real &dy) const; virtual Atom vbracket (Real &dy) const = 0; Atom special_time_signature (String, Array) const; diff --git a/lily/include/main.hh b/lily/include/main.hh index 072813b2f1..38399f71c5 100644 --- a/lily/include/main.hh +++ b/lily/include/main.hh @@ -25,6 +25,7 @@ extern bool find_quarts_global_b; extern int exit_status_i_; extern bool experimental_features_global_b; extern Lookup* global_lookup_l; +extern Paper_def* global_paper_l; extern bool dependency_global_b; extern bool version_ignore_global_b; diff --git a/lily/include/music-output-def.hh b/lily/include/music-output-def.hh index 5940cc4177..aaa93383af 100644 --- a/lily/include/music-output-def.hh +++ b/lily/include/music-output-def.hh @@ -38,6 +38,9 @@ public: DECLARE_MY_RUNTIME_TYPEINFO; virtual void print () const; + virtual Paper_def* paper_l (); + virtual Paper_score* paper_score_p () const; + Global_translator *get_global_translator_p (); Translator_group *get_group_translator_p (String type) const; String get_default_output () const; diff --git a/lily/include/p-score.hh b/lily/include/p-score.hh index 6b627f9377..3bf58582b5 100644 --- a/lily/include/p-score.hh +++ b/lily/include/p-score.hh @@ -39,7 +39,12 @@ public: Line_of_score * line_l_; Paper_score (); + + virtual ~Paper_score(); + String base_output_str () const; + virtual Paper_outputter* paper_outputter_p (Paper_stream*) const = 0; + virtual Paper_stream* paper_stream_p () const = 0; /// add to bottom of pcols void add_column (Paper_column*); @@ -62,8 +67,6 @@ public: /// add a Spanner void typeset_unbroken_spanner (Spanner*); - - virtual ~Paper_score(); protected: diff --git a/lily/include/paper-def.hh b/lily/include/paper-def.hh index 87bfe54573..b42c400af4 100644 --- a/lily/include/paper-def.hh +++ b/lily/include/paper-def.hh @@ -40,12 +40,10 @@ class Paper_def : public Music_output_def static int default_count_i_; bool ps_b_; -protected: - VIRTUAL_COPY_CONS(Paper_def,Music_output_def); - public: virtual ~Paper_def (); DECLARE_MY_RUNTIME_TYPEINFO; + VIRTUAL_COPY_CONS (Paper_def,Music_output_def); Array shape_int_a_; @@ -84,6 +82,12 @@ public: Lookup const * lookup_l (int sz) const; // TODO naming + virtual Paper_def* paper_l (); + virtual String dimension_str (Real r) const; + virtual Lookup* lookup_p (Lookup const&) const; + virtual Lookup* lookup_p (Symtables const&) const; + virtual String unknown_str () const; + /** convert a duration to an idealspacing influence using the geometric_ and paratime_signatures. */ @@ -92,12 +96,10 @@ public: Real arithmetic_constant (Moment minimal_mom) const; Real arithmetic_spacing (Moment mom,Real constant) const; virtual int get_next_default_count () const; - //urg - String tex_output_settings_str () const; - String ps_output_settings_str () const; + virtual String output_settings_str () const; // urg friend int yyparse (void*); }; -#endif // Paper_def_HH +#endif // PAPER_DEF_HH diff --git a/lily/include/ps-def.hh b/lily/include/ps-def.hh new file mode 100644 index 0000000000..676d335e37 --- /dev/null +++ b/lily/include/ps-def.hh @@ -0,0 +1,28 @@ +/* + ps-def.hh -- declare Ps_def + + source file of the GNU LilyPond music typesetter + + (c) 1998 Jan Nieuwenhuizen +*/ + +#ifndef PS_DEF_HH +#define PS_DEF_HH + +#include "paper-def.hh" + +class Ps_def : public Paper_def +{ +public: + VIRTUAL_COPY_CONS (Ps_def, Paper_def); + DECLARE_MY_RUNTIME_TYPEINFO; + + virtual Lookup* lookup_p (Lookup const&) const; + virtual Lookup* lookup_p (Symtables const&) const; + + virtual String output_settings_str () const; + virtual Paper_score* paper_score_p () const; + virtual String unknown_str () const; +}; + +#endif // PS_DEF_HH diff --git a/lily/include/ps-lookup.hh b/lily/include/ps-lookup.hh index 84f4abdcee..2ffb9af3b6 100644 --- a/lily/include/ps-lookup.hh +++ b/lily/include/ps-lookup.hh @@ -24,16 +24,11 @@ public: virtual String character_str (int i) const; virtual Atom dashed_slur (Array controls, Real thick, Real dash) const; virtual Atom hairpin (Real width, bool decresc, bool continued) const; - virtual Lookup* lookup_p (Lookup const&) const; - virtual Lookup* lookup_p (Symtables const&) const; - virtual Paper_outputter* paper_outputter_p (Paper_stream*, Paper_def*, Header*, String) const; - virtual Paper_stream* paper_stream_p () const; virtual Atom plet (Real dy , Real dx, Direction dir) const; virtual Atom ps_beam (Real slope, Real width, Real thick) const; virtual Atom slur (Array controls) const; virtual Atom stem (Real y1, Real y2) const; virtual Atom text (String style, String text) const; - virtual String unknown_str () const; virtual Atom vbracket (Real &y) const; }; diff --git a/lily/include/ps-score.hh b/lily/include/ps-score.hh new file mode 100644 index 0000000000..d83a503d86 --- /dev/null +++ b/lily/include/ps-score.hh @@ -0,0 +1,21 @@ +/* + ps-score.hh -- declare Ps_score + + source file of the GNU LilyPond music typesetter + + (c) 1998 Jan Nieuwenhuizen +*/ + +#ifndef PS_SCORE_HH +#define PS_SCORE_HH + +#include "p-score.hh" + +class Ps_score : public Paper_score +{ +public: + virtual Paper_outputter* paper_outputter_p (Paper_stream*) const; + virtual Paper_stream* paper_stream_p () const; +}; + +#endif // PS_SCORE_HH diff --git a/lily/include/tex-def.hh b/lily/include/tex-def.hh new file mode 100644 index 0000000000..92f8783b9a --- /dev/null +++ b/lily/include/tex-def.hh @@ -0,0 +1,29 @@ +/* + tex-def.hh -- declare Tex_def + + source file of the GNU LilyPond music typesetter + + (c) 1998 Jan Nieuwenhuizen +*/ + +#ifndef TEX_DEF_HH +#define TEX_DEF_HH + +#include "paper-def.hh" + +class Tex_def : public Paper_def +{ +public: + VIRTUAL_COPY_CONS (Tex_def, Paper_def); + DECLARE_MY_RUNTIME_TYPEINFO; + + virtual String dimension_str (Real r) const; + virtual Lookup* lookup_p (Lookup const&) const; + virtual Lookup* lookup_p (Symtables const&) const; + + virtual String output_settings_str () const; + virtual Paper_score* paper_score_p () const; + virtual String unknown_str () const; +}; + +#endif // TEX_DEF_HH diff --git a/lily/include/tex-lookup.hh b/lily/include/tex-lookup.hh index 24aadf1644..6b17bfa872 100644 --- a/lily/include/tex-lookup.hh +++ b/lily/include/tex-lookup.hh @@ -26,17 +26,11 @@ public: virtual Atom* atom_p (String, int, Box) const; Atom embed (Atom a) const; virtual Atom hairpin (Real width, bool decresc, bool continued) const; - virtual Lookup* lookup_p (Lookup const&) const; - virtual Lookup* lookup_p (Symtables const&) const; - virtual Paper_outputter* paper_outputter_p (Paper_stream*, Paper_def*, Header*, String) const; - virtual Paper_stream* paper_stream_p () const; virtual Atom plet (Real dy , Real dx, Direction dir) const; - virtual String print_dimen (Real) const; virtual Atom ps_beam (Real slope, Real width, Real thick) const; virtual Atom slur (Array controls) const; virtual Atom stem (Real y1, Real y2) const; virtual Atom text (String style, String text) const; - virtual String unknown_str () const; virtual Atom vbracket (Real &y) const; }; diff --git a/lily/include/tex-score.hh b/lily/include/tex-score.hh new file mode 100644 index 0000000000..0bfa12b0d6 --- /dev/null +++ b/lily/include/tex-score.hh @@ -0,0 +1,21 @@ +/* + tex-score.hh -- declare Tex_score + + source file of the GNU LilyPond music typesetter + + (c) 1998 Jan Nieuwenhuizen +*/ + +#ifndef TEX_SCORE_HH +#define TEX_SCORE_HH + +#include "p-score.hh" + +class Tex_score : public Paper_score +{ +public: + virtual Paper_outputter* paper_outputter_p (Paper_stream*) const; + virtual Paper_stream* paper_stream_p () const; +}; + +#endif // TEX_SCORE_HH diff --git a/lily/line-spacer.cc b/lily/line-spacer.cc index ffd65ff34e..b39be2aeda 100644 --- a/lily/line-spacer.cc +++ b/lily/line-spacer.cc @@ -3,22 +3,24 @@ source file of the GNU LilyPond music typesetter - (c) 1997--1998 Han-Wen Nienhuys + (c) 1997--1998 Han-Wen Nienhuys */ #include "line-spacer.hh" -Line_spacer::Line_spacer() +Line_spacer::Line_spacer () { - paper_l_ =0; -} -Paper_def* -Line_spacer::paper_l() const -{ - return paper_l_ ; + paper_l_ = 0; } Line_spacer::~Line_spacer () { } + +Paper_def* +Line_spacer::paper_l () const +{ + return paper_l_; +} + diff --git a/lily/lookup.cc b/lily/lookup.cc index 8ba88483f5..7f09106f3b 100644 --- a/lily/lookup.cc +++ b/lily/lookup.cc @@ -109,21 +109,6 @@ Lookup::bar (String str, Real h) const return s; } -String -Lookup::base_output_str () const -{ - assert (paper_l_); - String str = paper_l_->get_default_output (); - - if (str.empty_b ()) - { - str = default_outname_base_global; - int def = paper_l_->get_next_default_count (); - if (def) - str += "-" + to_str (def); - } - return str; -} Atom Lookup::beam (Real slope, Real width, Real thick) const @@ -190,13 +175,7 @@ Lookup::print () const String Lookup::print_dimen (Real r) const { - String s = to_str (r, "%.3f"); - if (s.index_i ("NaN") != -1) - { - warning (_ ("NaN")); - s = "0.0"; - } - return s; + return paper_l_->dimension_str (r); } Atom diff --git a/lily/main.cc b/lily/main.cc index 33df5a1c83..24278fb577 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -21,6 +21,8 @@ #include "config.hh" #include "file-results.hh" #include "debug.hh" +#include "ps-def.hh" +#include "tex-def.hh" #include "ps-lookup.hh" #include "tex-lookup.hh" @@ -41,6 +43,10 @@ Ps_lookup ps_lookup; Tex_lookup tex_lookup; Lookup* global_lookup_l = &tex_lookup; +Ps_def ps_def; +Tex_def tex_def; +Paper_def* global_paper_l = &tex_def; + bool experimental_features_global_b = false; bool dependency_global_b = false; @@ -241,6 +247,7 @@ main (int argc, char **argv) case 't': experimental_features_global_b = true; global_lookup_l = &ps_lookup; + global_paper_l = &ps_def; break; case 'o': outname_str = oparser.optional_argument_ch_C_; diff --git a/lily/music-output-def.cc b/lily/music-output-def.cc index 86a20a731e..7af3146eda 100644 --- a/lily/music-output-def.cc +++ b/lily/music-output-def.cc @@ -82,6 +82,18 @@ Music_output_def::get_global_translator_p () return g; } +Paper_def* +Music_output_def::paper_l () +{ + return 0; +} + +Paper_score* +Music_output_def::paper_score_p () const +{ + return 0; +} + void Music_output_def::print () const { diff --git a/lily/my-lily-parser.cc b/lily/my-lily-parser.cc index ea2cbe6b5a..de8ae42c14 100644 --- a/lily/my-lily-parser.cc +++ b/lily/my-lily-parser.cc @@ -314,7 +314,7 @@ Paper_def* My_lily_parser::default_paper_p () { Identifier *id = lexer_p_->lookup_identifier ("$defaultpaper"); - return id ? id->access_Paper_def () : new Paper_def ; + return id ? id->access_Paper_def () : (Paper_def*)global_paper_l->clone (); } Midi_def* diff --git a/lily/p-score.cc b/lily/p-score.cc index 25eaac2aa4..901cfa48d2 100644 --- a/lily/p-score.cc +++ b/lily/p-score.cc @@ -58,6 +58,22 @@ Paper_score::~Paper_score () #endif } +String +Paper_score::base_output_str () const +{ + assert (paper_l_); + String str = paper_l_->get_default_output (); + + if (str.empty_b ()) + { + str = default_outname_base_global; + int def = paper_l_->get_next_default_count (); + if (def) + str += "-" + to_str (def); + } + return str; +} + void Paper_score::typeset_element (Score_element * elem_p) { @@ -208,8 +224,8 @@ Paper_score::process () Array breaking = calc_breaking (); - Paper_stream* paper_stream_p = global_lookup_l->paper_stream_p (); - outputter_l_ = global_lookup_l->paper_outputter_p (paper_stream_p, paper_l_, header_l_, origin_str_); + Paper_stream* pstream_p = paper_stream_p (); + outputter_l_ = paper_outputter_p (pstream_p); Link_array lines; for (int i=0; i < breaking.size (); i++) @@ -238,7 +254,7 @@ Paper_score::process () // huh? delete outputter_l_; - delete paper_stream_p; + delete pstream_p; outputter_l_ = 0; } diff --git a/lily/paper-def.cc b/lily/paper-def.cc index d3d4a67954..a0e81bb96c 100644 --- a/lily/paper-def.cc +++ b/lily/paper-def.cc @@ -23,12 +23,28 @@ #include "scope.hh" #include "assoc.hh" #include "assoc-iter.hh" +#include "dimensions.hh" + +IMPLEMENT_IS_TYPE_B1 (Paper_def, Music_output_def); + +int Paper_def::default_count_i_ = 0; Paper_def::Paper_def () { lookup_p_assoc_p_ = new Assoc; } +Paper_def::Paper_def (Paper_def const&s) + : Music_output_def (s) +{ + lookup_p_assoc_p_ = new Assoc; + for (Assoc_iter ai(*s.lookup_p_assoc_p_); ai.ok (); ai++) + { + Lookup * l = lookup_p (*ai.val ()); + l->paper_l_ = this; + set_lookup (ai.key(), l); + } +} Paper_def::~Paper_def () { @@ -40,16 +56,43 @@ Paper_def::~Paper_def () delete lookup_p_assoc_p_; } -Paper_def::Paper_def (Paper_def const&s) - : Music_output_def (s) +/** + Get the measure wide constant for arithmetic. + + @see + John S. Gourlay. ``Spacing a Line of Music,'' Technical Report + OSU-CISRC-10/87-TR35, Department of Computer and Information Science, + The Ohio State University, 1987. + + */ +Real +Paper_def::arithmetic_constant (Moment d) const { - lookup_p_assoc_p_ = new Assoc; - for (Assoc_iter ai(*s.lookup_p_assoc_p_); ai.ok (); ai++) - { - Lookup * l = global_lookup_l->lookup_p (*ai.val ()); - l->paper_l_ = this; - set_lookup (ai.key(), l); - } + return get_var ("arithmetic_basicspace") - log_2 (Moment (1,8) elem_b (i)) - { - delete lookup_p_assoc_p_->elem (i); - } - l ->paper_l_ = this; - (*lookup_p_assoc_p_)[i] = l; -} - Real Paper_def::interline_f () const { @@ -147,23 +139,17 @@ Paper_def::interline_f () const } Real -Paper_def::rule_thickness () const +Paper_def::linewidth_f () const { - return get_var ("rulethickness"); + return get_var ("linewidth"); } Real -Paper_def::staffline_f () const +Paper_def::rule_thickness () const { return get_var ("rulethickness"); } -Real -Paper_def::staffheight_f () const -{ - return get_var ("staffheight"); -} - Real Paper_def::interbeam_f (int multiplicity_i) const { @@ -179,12 +165,43 @@ Paper_def::internote_f () const return get_var ("interline") /2.0 ; } +// urg, how c++ sucks +// virtual_copy_cons wants these... + +// aarg, its even worse, Paper_def gets constructed via Identifier, +// another input->output hardlink. +Lookup* +Paper_def::lookup_p (Lookup const& l) const +{ + // return 0; + return global_paper_l->lookup_p (l); +} + +Lookup* +Paper_def::lookup_p (Symtables const& s) const +{ + // return 0; + return global_paper_l->lookup_p (s); +} + +String +Paper_def::output_settings_str () const +{ + return ""; +} + Real Paper_def::note_width () const { return get_var ("notewidth"); } +Paper_def* +Paper_def::paper_l () +{ + return this; +} + void Paper_def::print () const { @@ -202,43 +219,44 @@ Paper_def::print () const #endif } +String +Paper_def::dimension_str (Real r) const +{ + return ::dimension_str (r); +} + Lookup const * Paper_def::lookup_l (int i) const { return (*lookup_p_assoc_p_)[i]; } -IMPLEMENT_IS_TYPE_B1 (Paper_def, Music_output_def); - -String -Paper_def::ps_output_settings_str () const +void +Paper_def::set_lookup (int i, Lookup*l) { - String s ("\n "); - for (Assoc_iter i (*scope_p_); i.ok (); i++) - s += String ("/mudelapaper") + i.key () - + "{" + i.val ()->str () + "} bind def\n"; - s += *scope_p_->elem ("pssetting")->access_String (); - return s; + if (lookup_p_assoc_p_->elem_b (i)) + { + delete lookup_p_assoc_p_->elem (i); + } + l ->paper_l_ = this; + (*lookup_p_assoc_p_)[i] = l; } -String -Paper_def::tex_output_settings_str () const +Real +Paper_def::staffline_f () const { - String s ("\n "); - for (Assoc_iter i (*scope_p_); i.ok (); i++) - s += String ("\\def\\mudelapaper") + i.key () - + "{" + i.val ()->str () + "}\n"; - s += *scope_p_->elem ("texsetting")->access_String (); - return s; + return get_var ("rulethickness"); } -int Paper_def::default_count_i_ = 0; - -int -Paper_def::get_next_default_count () const +Real +Paper_def::staffheight_f () const { - return default_count_i_ ++; + return get_var ("staffheight"); } - +String +Paper_def::unknown_str () const +{ + return ""; +} diff --git a/lily/paper-outputter.cc b/lily/paper-outputter.cc index 1e8d450c7b..17231564b8 100644 --- a/lily/paper-outputter.cc +++ b/lily/paper-outputter.cc @@ -9,6 +9,7 @@ #include "paper-outputter.hh" #include "paper-stream.hh" +#include "paper-def.hh" #include "molecule.hh" #include "atom.hh" #include "array.hh" @@ -42,8 +43,8 @@ Paper_outputter::output_molecule (Molecule const*m, Offset o, char const *nm, St Array a; String r; - a.push (global_lookup_l->print_dimen (a_off.y())); - a.push (global_lookup_l->print_dimen (a_off.x())); + a.push (global_paper_l->dimension_str (a_off.y())); + a.push (global_paper_l->dimension_str (a_off.x())); a.push (i->str_); r += global_lookup_l->substitute_args (s, a); *outstream_l_ << r; diff --git a/lily/parser.yy b/lily/parser.yy index bc323e061f..f6e9764a17 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -16,8 +16,6 @@ #include "script-def.hh" #include "symtable.hh" #include "lookup.hh" -#include "ps-lookup.hh" -#include "tex-lookup.hh" #include "misc.hh" #include "my-lily-lexer.hh" #include "paper-def.hh" @@ -564,7 +562,7 @@ paper_def_body: $$ = p; } | paper_def_body int '=' symtables { // ugh, what a syntax - Lookup * l = global_lookup_l->lookup_p (*$4); + Lookup * l = THIS->default_paper_p ()->lookup_p (*$4); $$->set_lookup ($2, l); } | paper_def_body STRING '=' simple_identifier_init ';' { diff --git a/lily/ps-def.cc b/lily/ps-def.cc new file mode 100644 index 0000000000..f0aa1e18ff --- /dev/null +++ b/lily/ps-def.cc @@ -0,0 +1,53 @@ +/* + ps-def.cc -- implement Ps_def + + source file of the GNU LilyPond music typesetter + + (c) 1998 Jan Nieuwenhuizen +*/ + +#include "assoc.hh" +#include "assoc-iter.hh" +#include "identifier.hh" +#include "ps-def.hh" +#include "ps-lookup.hh" +#include "ps-score.hh" +#include "scope.hh" + +IMPLEMENT_IS_TYPE_B1 (Ps_def, Paper_def); + +Lookup* +Ps_def::lookup_p (Lookup const& l) const +{ + return new Ps_lookup (l); +} + +Lookup* +Ps_def::lookup_p (Symtables const& s) const +{ + return new Ps_lookup (s); +} + +String +Ps_def::output_settings_str () const +{ + String s ("\n "); + for (Assoc_iter i (*scope_p_); i.ok (); i++) + s += String ("/mudelapaper") + i.key () + + "{" + i.val ()->str () + "} bind def\n"; + s += *scope_p_->elem ("pssetting")->access_String (); + return s; +} + +Paper_score* +Ps_def::paper_score_p () const +{ + return new Ps_score (); +} + +String +Ps_def::unknown_str () const +{ + return "unknown "; +} + diff --git a/lily/ps-lookup.cc b/lily/ps-lookup.cc index f488b5e92a..cb839468a1 100644 --- a/lily/ps-lookup.cc +++ b/lily/ps-lookup.cc @@ -112,53 +112,6 @@ Ps_lookup::hairpin (Real width, bool decresc, bool continued) const return a; } -Lookup* -Ps_lookup::lookup_p (Lookup const& l) const -{ - return new Ps_lookup (l); -} - -Lookup* -Ps_lookup::lookup_p (Symtables const& s) const -{ - return new Ps_lookup (s); -} - -Paper_outputter* -Ps_lookup::paper_outputter_p (Paper_stream* os_p, Paper_def* paper_l, Header* header_l, String origin_str) const -{ - if (header_global_p) - *os_p << header_global_p->ps_string (); - - *os_p << _ ("\n% outputting Score, defined at: ") << origin_str << '\n'; - - if (header_l) - *os_p << header_l->ps_string (); - *os_p << paper_l->ps_output_settings_str (); - - if (experimental_features_global_b) - *os_p << "turnOnExperimentalFeatures\n"; - - return new Ps_outputter (os_p); -} - -Paper_stream* -Ps_lookup::paper_stream_p () const -{ -#if 1 - String outname = base_output_str (); -#else - String outname = "lelie"; -#endif - - if (outname != "-") - outname += ".ps"; - *mlog << _f ("PostScript output to %s...", - outname == "-" ? String ("") : outname ) << endl; - target_str_global_array.push (outname); - return new Ps_stream (outname); -} - Atom Ps_lookup::plet (Real dy , Real dx, Direction dir) const { @@ -233,12 +186,6 @@ Ps_lookup::text (String style, String text) const return Lookup::text (style, "(" + text + ")"); } -String -Ps_lookup::unknown_str () const -{ - return "unknown "; -} - Atom Ps_lookup::vbracket (Real &y) const { diff --git a/lily/ps-score.cc b/lily/ps-score.cc new file mode 100644 index 0000000000..05137ecb9b --- /dev/null +++ b/lily/ps-score.cc @@ -0,0 +1,48 @@ +/* + ps-score.cc -- implement Ps_score + + source file of the GNU LilyPond music typesetter + + (c) 1998 Jan Nieuwenhuizen +*/ + +#include "debug.hh" +#include "file-results.hh" +#include "header.hh" +#include "main.hh" +#include "paper-def.hh" +#include "ps-stream.hh" +#include "ps-outputter.hh" +#include "ps-score.hh" + +Paper_outputter* +Ps_score::paper_outputter_p (Paper_stream* os_p) const +{ + if (header_global_p) + *os_p << header_global_p->ps_string (); + + *os_p << _ ("\n% outputting Score, defined at: ") << origin_str_ << '\n'; + + if (header_l_) + *os_p << header_l_->ps_string (); + *os_p << paper_l_->output_settings_str (); + + if (experimental_features_global_b) + *os_p << "turnOnExperimentalFeatures\n"; + + return new Ps_outputter (os_p); +} + +Paper_stream* +Ps_score::paper_stream_p () const +{ + String outname = base_output_str (); + + if (outname != "-") + outname += ".ps"; + *mlog << _f ("PostScript output to %s...", + outname == "-" ? String ("") : outname ) << endl; + target_str_global_array.push (outname); + return new Ps_stream (outname); +} + diff --git a/lily/score-engraver.cc b/lily/score-engraver.cc index 1b30731fd7..c5350418ef 100644 --- a/lily/score-engraver.cc +++ b/lily/score-engraver.cc @@ -16,6 +16,7 @@ #include "score-column.hh" #include "command-request.hh" #include "paper-def.hh" +#include "main.hh" Score_engraver::Score_engraver() @@ -267,8 +268,23 @@ void Score_engraver::do_add_processing () { Translator_group::do_add_processing (); - assert (output_def_l_->is_type_b (Paper_def::static_name ())); + //assert (output_def_l_->is_type_b (Paper_def::static_name ())); + // urg + pscore_p_ = output_def_l_->paper_score_p (); + // assert (pscore_p_); + // urg, via parser a Paper_def gets constructed + // this should never happen, but can't be prevented (Paper_def can't be + // abstract bo virtual_copy_cons etc. + if (!pscore_p_) + { + printf ("\nBRAAK\n"); + output_def_l_ = global_paper_l->paper_l ()->clone (); + // pscore_p_ = output_def_l_->paper_score_p (); + pscore_p_ = global_paper_l->paper_score_p (); + pscore_p_->paper_l_ = global_paper_l->paper_l (); + } + else + pscore_p_->paper_l_ = output_def_l_->paper_l (); + assert (pscore_p_->paper_l_); assert (!daddy_trans_l_); - pscore_p_ = new Paper_score; - pscore_p_->paper_l_ = (Paper_def*)output_def_l_; } diff --git a/lily/scores.cc b/lily/scores.cc index 9b2a80bee3..47ee1c9a31 100644 --- a/lily/scores.cc +++ b/lily/scores.cc @@ -125,6 +125,7 @@ do_one_file (String init_str, String file_str) parser.set_version_check (version_ignore_global_b); parser.parse_file (init_str, file_str); +#if 0 /* urg when calling {Ps,Tex}_lookup::paper_stream_p (), @@ -134,6 +135,7 @@ do_one_file (String init_str, String file_str) (deleted without being reset maybe?) */ global_lookup_l->paper_l_ = parser.default_paper_p (); +#endif if (parser.error_level_i_) { diff --git a/lily/spring-spacer.cc b/lily/spring-spacer.cc index 99939fcd6b..83aecfa94e 100644 --- a/lily/spring-spacer.cc +++ b/lily/spring-spacer.cc @@ -22,9 +22,9 @@ #include "colhpos.hh" Vector -Spring_spacer::default_solution() const +Spring_spacer::default_solution () const { - return try_initial_solution() ; + return try_initial_solution () ; } Score_column* @@ -39,7 +39,7 @@ template class P; // ugh. bool Spring_spacer::contains_b (Paper_column const *w) { - for (int i=0; i< cols_.size(); i++) + for (int i=0; i< cols_.size (); i++) if (cols_[i].pcol_l_ == w) return true; return false; @@ -47,12 +47,12 @@ Spring_spacer::contains_b (Paper_column const *w) void -Spring_spacer::OK() const +Spring_spacer::OK () const { #ifndef NDEBUG - for (int i = 1; i < cols_.size(); i++) + for (int i = 1; i < cols_.size (); i++) assert (cols_[i].rank_i_ > cols_[i-1].rank_i_); - for (int i = 1; i < loose_col_arr_.size(); i++) + for (int i = 1; i < loose_col_arr_.size (); i++) assert (loose_col_arr_[i].rank_i_ > loose_col_arr_[i-1].rank_i_); #endif } @@ -61,21 +61,21 @@ Spring_spacer::OK() const Make sure no unconnected columns happen. */ void -Spring_spacer::handle_loose_cols() +Spring_spacer::handle_loose_cols () { - Union_find connected (cols_.size()); + Union_find connected (cols_.size ()); Array fixed; - for (PCursor i (ideal_p_list_.top()); i.ok (); i++) + for (PCursor i (ideal_p_list_.top ()); i.ok (); i++) { connected.connect (i->left_i_,i->right_i_); } - for (int i = 0; i < cols_.size(); i++) - if (cols_[i].fixed_b()) + for (int i = 0; i < cols_.size (); i++) + if (cols_[i].fixed_b ()) fixed.push (i); - for (int i=1; i < fixed.size(); i++) + for (int i=1; i < fixed.size (); i++) connected.connect (fixed[i-1], fixed[i]); - for (int i = cols_.size(); i--;) + for (int i = cols_.size (); i--;) { if (! connected.equiv (fixed[0], i)) { @@ -83,7 +83,7 @@ Spring_spacer::handle_loose_cols() loosen_column (i); } } - OK(); + OK (); } @@ -94,28 +94,28 @@ Spring_spacer::handle_loose_cols() void Spring_spacer::position_loose_cols (Vector &sol_vec) const { - if (!loose_col_arr_.size()) + if (!loose_col_arr_.size ()) return ; - assert (sol_vec.dim()); + assert (sol_vec.dim ()); Array fix_b_arr; - fix_b_arr.set_size (cols_.size() + loose_col_arr_.size ()); + fix_b_arr.set_size (cols_.size () + loose_col_arr_.size ()); Real utter_right_f=-infinity_f; Real utter_left_f =infinity_f; - for (int i=0; i < loose_col_arr_.size(); i++) + for (int i=0; i < loose_col_arr_.size (); i++) { fix_b_arr[loose_col_arr_[i].rank_i_] = false; } - for (int i=0; i < cols_.size(); i++) + for (int i=0; i < cols_.size (); i++) { int r= cols_[i].rank_i_; fix_b_arr[r] = true; utter_right_f = utter_right_f >? sol_vec (i); utter_left_f = utter_left_f 0) ?sol_vec (j-1) : utter_left_f; Real right_pos_f = - (j < sol_vec.dim()) ? sol_vec (j) : utter_right_f; + (j < sol_vec.dim ()) ? sol_vec (j) : utter_right_f; int left_rank = (j>0) ? cols_[j-1].rank_i_ : 0; - int right_rank = (j COLFUDGE) + if (cols_[i].fixed_b () && + abs (cols_[i].fixed_position () - v (i)) > COLFUDGE) { DOUT << "Fixpos broken\n"; return false; @@ -178,7 +178,7 @@ Spring_spacer::check_constraints (Vector v) const /** try to generate a solution which obeys the min distances and fixed positions */ Vector -Spring_spacer::try_initial_solution() const +Spring_spacer::try_initial_solution () const { Vector v; if (!try_initial_solution_and_tell (v)) @@ -192,7 +192,7 @@ Spring_spacer::try_initial_solution() const bool Spring_spacer::try_initial_solution_and_tell (Vector &v) const { - int dim=cols_.size(); + int dim=cols_.size (); bool succeeded = true; Vector initsol (dim); @@ -201,16 +201,16 @@ Spring_spacer::try_initial_solution_and_tell (Vector &v) const for (int i=0; i < dim; i++) { Real min_x = i ? initsol (i-1) : cols_[0].fixed_position (); - Array const &sr_arr(cols_[i].rods_[LEFT]); + Array const &sr_arr (cols_[i].rods_[LEFT]); for (int j=0; j < sr_arr.size (); j++) { min_x = min_x >? (initsol (sr_arr[j].other_idx_) + sr_arr[j].distance_f_); } initsol (i) = min_x; - if (cols_[i].fixed_b()) + if (cols_[i].fixed_b ()) { - initsol (i)=cols_[i].fixed_position(); + initsol (i)=cols_[i].fixed_position (); if (initsol (i) < min_x ) { DOUT << "failing: init, min : " << initsol (i) << " " << min_x << '\n'; @@ -223,7 +223,7 @@ Spring_spacer::try_initial_solution_and_tell (Vector &v) const DOUT << "tried and told solution: " << v; if (!succeeded) - DOUT << "(failed)\n"; + DOUT << " (failed)\n"; return succeeded; } @@ -237,7 +237,7 @@ Spring_spacer::make_matrices (Matrix &quad, Vector &lin, Real &c) const lin.fill (0); c = 0; - for (PCursor i (ideal_p_list_.top()); i.ok (); i++) + for (PCursor i (ideal_p_list_.top ()); i.ok (); i++) { int l = i->left_i_; int r = i->right_i_; @@ -253,8 +253,8 @@ Spring_spacer::make_matrices (Matrix &quad, Vector &lin, Real &c) const c += sqr (i->space_f_); } - if (quad.dim() > 10) - quad.set_band(); + if (quad.dim () > 10) + quad.set_band (); } @@ -262,25 +262,25 @@ Spring_spacer::make_matrices (Matrix &quad, Vector &lin, Real &c) const void Spring_spacer::set_fixed_cols (Mixed_qp &qp) const { - for (int j=0; j < cols_.size(); j++) - if (cols_[j].fixed_b()) - qp.add_fixed_var (j,cols_[j].fixed_position()); + for (int j=0; j < cols_.size (); j++) + if (cols_[j].fixed_b ()) + qp.add_fixed_var (j,cols_[j].fixed_position ()); } // put the constraints into the LP problem void Spring_spacer::make_constraints (Mixed_qp& lp) const { - int dim=cols_.size(); + int dim=cols_.size (); for (int j=0; j < dim -1; j++) { Array const&rod_arr (cols_[j].rods_[RIGHT]); for (int i = 0; i < rod_arr.size (); i++) { - Vector c1(dim); - c1(rod_arr[i].other_idx_)=1.0 ; - c1(j)=-1.0 ; + Vector c1 (dim); + c1 (rod_arr[i].other_idx_)=1.0 ; + c1 (j)=-1.0 ; lp.add_inequality_cons (c1, rod_arr[i].distance_f_); } @@ -292,9 +292,9 @@ Real Spring_spacer::calculate_energy_f (Vector solution) const { Real e = 0.0; - for (PCursor i (ideal_p_list_.top()); i.ok(); i++) + for (PCursor i (ideal_p_list_.top ()); i.ok (); i++) { - e += i->energy_f(solution(i->right_i_) - solution(i->left_i_)); + e += i->energy_f (solution (i->right_i_) - solution (i->left_i_)); } return e; @@ -302,11 +302,11 @@ Spring_spacer::calculate_energy_f (Vector solution) const void Spring_spacer::lower_bound_solution (Column_x_positions*positions) const { - Mixed_qp lp (cols_.size()); + Mixed_qp lp (cols_.size ()); make_matrices (lp.quad_,lp.lin_, lp.const_term_); set_fixed_cols (lp); - Vector start (cols_.size()); + Vector start (cols_.size ()); start.fill (0.0); Vector solution_vec (lp.solve (start)); @@ -331,7 +331,7 @@ Spring_spacer::solve (Column_x_positions*positions) const bool constraint_satisfaction = try_initial_solution_and_tell (solution_try); if (constraint_satisfaction) { - Mixed_qp lp (cols_.size()); + Mixed_qp lp (cols_.size ()); make_matrices (lp.quad_,lp.lin_, lp.const_term_); make_constraints (lp); set_fixed_cols (lp); @@ -346,7 +346,7 @@ Spring_spacer::solve (Column_x_positions*positions) const position_loose_cols (solution_vec); positions->energy_f_ = calculate_energy_f (solution_vec); positions->config = solution_vec; - positions->error_col_l_arr_ = error_pcol_l_arr(); + positions->error_col_l_arr_ = error_pcol_l_arr (); } else { @@ -361,8 +361,8 @@ Spring_spacer::solve (Column_x_positions*positions) const void Spring_spacer::add_column (Paper_column *col, bool fixed, Real fixpos) { - Column_info c (col,(fixed)? &fixpos : 0); - int this_rank = cols_.size(); + Column_info c (col, (fixed)? &fixpos : 0); + int this_rank = cols_.size (); c.rank_i_ = this_rank; for (int i=0; i < col->minimal_dists_arr_drul_[LEFT].size (); i++) @@ -390,13 +390,13 @@ Spring_spacer::add_column (Paper_column *col, bool fixed, Real fixpos) } Line_of_cols -Spring_spacer::error_pcol_l_arr() const +Spring_spacer::error_pcol_l_arr () const { Array retval; - for (int i=0; i< cols_.size(); i++) + for (int i=0; i< cols_.size (); i++) if (cols_[i].ugh_b_) retval.push (cols_[i].pcol_l_); - for (int i=0; i < loose_col_arr_.size(); i++) + for (int i=0; i < loose_col_arr_.size (); i++) { retval.push (loose_col_arr_[i].pcol_l_); } @@ -407,17 +407,17 @@ void Spring_spacer::loosen_column (int i) { Column_info c=cols_.get (i); - for (PCursor j (ideal_p_list_.top()); j.ok (); j++) + for (PCursor j (ideal_p_list_.top ()); j.ok (); j++) { if (j->left_i_ == i|| j->right_i_ == i) - j.del(); + j.del (); else j++; } c.ugh_b_ = true; int j=0; - for (; j < loose_col_arr_.size(); j++) + for (; j < loose_col_arr_.size (); j++) { if (loose_col_arr_[j].rank_i_ > c.rank_i_) break; @@ -427,17 +427,17 @@ Spring_spacer::loosen_column (int i) void -Spring_spacer::print() const +Spring_spacer::print () const { #ifndef NPRINT - for (int i=0; i < cols_.size(); i++) + for (int i=0; i < cols_.size (); i++) { DOUT << "col " << i << " "; - cols_[i].print(); + cols_[i].print (); } - for (PCursor i (ideal_p_list_.top()); i.ok (); i++) + for (PCursor i (ideal_p_list_.top ()); i.ok (); i++) { - i->print(); + i->print (); } #endif } @@ -446,8 +446,8 @@ Spring_spacer::print() const void Spring_spacer::connect (int i, int j, Real d, Real h) { - assert(d >= 0 && d <= 100 CM); - assert(h >=0); + assert (d >= 0 && d <= 100 CM); + assert (h >=0); Idealspacing * s = new Idealspacing; @@ -456,24 +456,24 @@ Spring_spacer::connect (int i, int j, Real d, Real h) s->space_f_ = d; s->hooke_f_ = h; - ideal_p_list_.bottom().add (s); + ideal_p_list_.bottom ().add (s); } void -Spring_spacer::prepare() +Spring_spacer::prepare () { DOUT << "Preparing.."; - calc_idealspacing(); - handle_loose_cols(); - print(); + calc_idealspacing (); + handle_loose_cols (); + print (); DOUT << "finished preparing.\n"; } Line_spacer* -Spring_spacer::constructor() +Spring_spacer::constructor () { return new Spring_spacer; } @@ -483,22 +483,22 @@ Spring_spacer::constructor() /** get the shortest_playing running note at a time. */ void -Spring_spacer::get_ruling_durations(Array &shortest_playing_arr, +Spring_spacer::get_ruling_durations (Array &shortest_playing_arr, Array &context_shortest_arr) { - for (int i=0; i < cols_.size(); i++) + for (int i=0; i < cols_.size (); i++) { - scol_l (i)->preprocess(); + scol_l (i)->preprocess (); scol_l (i)->print (); } int start_context_i=0; Moment context_shortest; context_shortest.set_infinite (1); - context_shortest_arr.set_size(cols_.size()); + context_shortest_arr.set_size (cols_.size ()); - for (int i=0; i < cols_.size(); i++) + for (int i=0; i < cols_.size (); i++) { - Moment now = scol_l (i)->when(); + Moment now = scol_l (i)->when (); Moment shortest_playing; shortest_playing.set_infinite (1); @@ -509,31 +509,31 @@ Spring_spacer::get_ruling_durations(Array &shortest_playing_arr, start_context_i = i; context_shortest.set_infinite (1); } - if (scol_l (i)->durations.size()) + if (scol_l (i)->durations.size ()) { - context_shortest = context_shortest durations[0]; + context_shortest = context_shortest durations[0]; } // ji was j, but triggered ICE for (int ji=i+1; ji --;) { - if (scol_l(ji)->durations.size() && - now - scol_l(ji)->when() >= shortest_playing) + if (scol_l (ji)->durations.size () && + now - scol_l (ji)->when () >= shortest_playing) break; - for (int k = scol_l (ji)->durations.size(); - k-- && scol_l(ji)->durations[k] + scol_l(ji)->when() > now; + for (int k = scol_l (ji)->durations.size (); + k-- && scol_l (ji)->durations[k] + scol_l (ji)->when () > now; ) { - shortest_playing = shortest_playing durations[k]; + shortest_playing = shortest_playing durations[k]; } } - shortest_playing_arr.push(shortest_playing); + shortest_playing_arr.push (shortest_playing); } #ifndef NPRINT DOUT << "shortest_playing/:[ "; - for (int i=0; i < shortest_playing_arr.size(); i++) + for (int i=0; i < shortest_playing_arr.size (); i++) { DOUT << shortest_playing_arr[i] << " "; DOUT << context_shortest_arr[i] << ", "; @@ -563,18 +563,18 @@ Spring_spacer::get_ruling_durations(Array &shortest_playing_arr, */ void -Spring_spacer::calc_idealspacing() +Spring_spacer::calc_idealspacing () { Array shortest_playing_arr; Array context_shortest_arr; - get_ruling_durations(shortest_playing_arr, context_shortest_arr); + get_ruling_durations (shortest_playing_arr, context_shortest_arr); Real interline_f = paper_l ()->interline_f (); Array ideal_arr_; Array hooke_arr_; - for (int i=0; i < cols_.size() - 1; i++){ + for (int i=0; i < cols_.size () - 1; i++){ ideal_arr_.push (-1.0); hooke_arr_.push (1.0); } @@ -582,15 +582,15 @@ Spring_spacer::calc_idealspacing() /* First do all non-musical columns */ - for (int i=0; i < cols_.size(); i++) + for (int i=0; i < cols_.size (); i++) { - if (!scol_l (i)->musical_b() && i+1 < cols_.size()) + if (!scol_l (i)->musical_b () && i+1 < cols_.size ()) { Real symbol_distance =cols_[i].width_[RIGHT] + 2 PT; Real durational_distance = 0; - Moment delta_t = scol_l (i+1)->when() - scol_l (i)->when () ; + Moment delta_t = scol_l (i+1)->when () - scol_l (i)->when () ; /* @@ -598,8 +598,8 @@ Spring_spacer::calc_idealspacing() */ if (delta_t) { - Real k= paper_l()->arithmetic_constant (context_shortest_arr[i]); - durational_distance = paper_l()->duration_to_dist (delta_t,k); + Real k= paper_l ()->arithmetic_constant (context_shortest_arr[i]); + durational_distance = paper_l ()->duration_to_dist (delta_t,k); } symbol_distance += -cols_[i+1].width_[LEFT]; @@ -612,28 +612,28 @@ Spring_spacer::calc_idealspacing() /* Then musicals */ - for (int i=0; i < cols_.size(); i++) + for (int i=0; i < cols_.size (); i++) { - if (scol_l (i)->musical_b()) + if (scol_l (i)->musical_b ()) { Moment shortest_playing_len = shortest_playing_arr[i]; Moment context_shortest = context_shortest_arr[i]; if (! shortest_playing_len) { warning (_f ("can't find a ruling note at %s", - scol_l (i)->when().str ())); + scol_l (i)->when ().str ())); shortest_playing_len = 1; } if (! context_shortest) { warning (_f ("no minimum in measure at %s", - scol_l (i)->when().str ())); + scol_l (i)->when ().str ())); context_shortest = 1; } - Moment delta_t = scol_l (i+1)->when() - scol_l (i)->when (); - Real k= paper_l()->arithmetic_constant(context_shortest); - Real dist = paper_l()->duration_to_dist (shortest_playing_len, k); - dist *= (double)(delta_t / shortest_playing_len); + Moment delta_t = scol_l (i+1)->when () - scol_l (i)->when (); + Real k= paper_l ()->arithmetic_constant (context_shortest); + Real dist = paper_l ()->duration_to_dist (shortest_playing_len, k); + dist *= (double) (delta_t / shortest_playing_len); /* According to [Ross] and [Wanske], and from what i've seen: @@ -673,7 +673,7 @@ Spring_spacer::calc_idealspacing() /* last musical column of bar */ - if (i + 1 < cols_.size () && scol_l(i+1)->breakable_b_) + if (i + 1 < cols_.size () && scol_l (i+1)->breakable_b_) { // hmm, how bout? dist = dist >? interline_f; @@ -699,7 +699,7 @@ Spring_spacer::calc_idealspacing() } } - for (int i=0; i < ideal_arr_.size(); i++) + for (int i=0; i < ideal_arr_.size (); i++) { assert (ideal_arr_[i] >=0 && hooke_arr_[i] >=0); connect (i, i+1, ideal_arr_[i], hooke_arr_[i]); diff --git a/lily/tex-def.cc b/lily/tex-def.cc new file mode 100644 index 0000000000..bd9d61acb2 --- /dev/null +++ b/lily/tex-def.cc @@ -0,0 +1,59 @@ +/* + tex-def.cc -- implement Tex_def + + source file of the GNU LilyPond music typesetter + + (c) 1998 Jan Nieuwenhuizen +*/ + +#include "assoc.hh" +#include "assoc-iter.hh" +#include "identifier.hh" +#include "scope.hh" +#include "tex-def.hh" +#include "tex-lookup.hh" +#include "tex-score.hh" + +IMPLEMENT_IS_TYPE_B1 (Tex_def, Paper_def); + +String +Tex_def::dimension_str (Real r) const +{ + return Paper_def::dimension_str (r) + "pt"; +} + +Lookup* +Tex_def::lookup_p (Lookup const& l) const +{ + return new Tex_lookup (l); +} + +Lookup* +Tex_def::lookup_p (Symtables const& s) const +{ + return new Tex_lookup (s); +} + +String +Tex_def::output_settings_str () const +{ + String s ("\n "); + for (Assoc_iter i (*scope_p_); i.ok (); i++) + s += String ("\\def\\mudelapaper") + i.key () + + "{" + i.val ()->str () + "}\n"; + s += *scope_p_->elem ("texsetting")->access_String (); + return s; +} + +Paper_score* +Tex_def::paper_score_p () const +{ + return new Tex_score (); +} + +String +Tex_def::unknown_str () const +{ + return "\\unknown"; +} + diff --git a/lily/tex-lookup.cc b/lily/tex-lookup.cc index 3e82c82a59..c87589f1a1 100644 --- a/lily/tex-lookup.cc +++ b/lily/tex-lookup.cc @@ -86,69 +86,6 @@ Tex_lookup::plet (Real dy , Real dx, Direction dir) const return embed (Ps_lookup::plet (dy, dx, dir)); } -Lookup* -Tex_lookup::lookup_p (Lookup const& l) const -{ - return new Tex_lookup (l); -} - -Lookup* -Tex_lookup::lookup_p (Symtables const& s) const -{ - return new Tex_lookup (s); -} - -Paper_outputter* -Tex_lookup::paper_outputter_p (Paper_stream* os_p, Paper_def* paper_l, Header* header_l, String origin_str) const -{ - if (header_global_p) - *os_p << header_global_p->tex_string (); - - *os_p << _ ("\n% outputting Score, defined at: ") << origin_str << '\n'; - - if (header_l) - *os_p << header_l->tex_string(); - *os_p << paper_l->tex_output_settings_str (); - - if (experimental_features_global_b) - *os_p << "\\turnOnExperimentalFeatures%\n"; - - *os_p << "\\turnOnPostScript%\n"; - - return new Tex_outputter (os_p); -} - -Paper_stream * -Tex_lookup::paper_stream_p () const -{ -#if 1 - String outname = base_output_str (); -#else - String outname = "lelie"; -#endif - - Paper_stream* p; - if (outname != "-") - outname += ".tex"; - *mlog << _f ("TeX output to %s...", - outname == "-" ? String ("") : outname ) << endl; - p = new Tex_stream (outname); - target_str_global_array.push (outname); - return p; -} - -String -Tex_lookup::print_dimen (Real r) const -{ - String s = to_str (r, "%.3f"); - if (s.index_i ("NaN") != -1) - { - warning (_ ("NaN")); - s = "0.0"; - } - return Lookup::print_dimen (r) + "pt"; -} - Atom Tex_lookup::ps_beam (Real slope, Real width, Real thick) const { @@ -173,12 +110,6 @@ Tex_lookup::text (String style, String text) const return Lookup::text (style, text); } -String -Tex_lookup::unknown_str () const -{ - return "\\unknown"; -} - Atom Tex_lookup::vbracket (Real &y) const { diff --git a/lily/tex-score.cc b/lily/tex-score.cc new file mode 100644 index 0000000000..07e1108c08 --- /dev/null +++ b/lily/tex-score.cc @@ -0,0 +1,52 @@ +/* + tex-score.cc -- implement Tex_score + + source file of the GNU LilyPond music typesetter + + (c) 1998 Jan Nieuwenhuizen +*/ + +#include "debug.hh" +#include "file-results.hh" +#include "header.hh" +#include "main.hh" +#include "paper-def.hh" +#include "tex-stream.hh" +#include "tex-outputter.hh" +#include "tex-score.hh" + +Paper_outputter* +Tex_score::paper_outputter_p (Paper_stream* os_p) const +{ + if (header_global_p) + *os_p << header_global_p->tex_string (); + + *os_p << _ ("\n% outputting Score, defined at: ") << origin_str_ << '\n'; + + if (header_l_) + *os_p << header_l_->tex_string(); + *os_p << paper_l_->output_settings_str (); + + if (experimental_features_global_b) + *os_p << "\\turnOnExperimentalFeatures%\n"; + + *os_p << "\\turnOnPostScript%\n"; + + return new Tex_outputter (os_p); +} + +Paper_stream * +Tex_score::paper_stream_p () const +{ + String outname = base_output_str (); + + Paper_stream* p; + if (outname != "-") + outname += ".tex"; + *mlog << _f ("TeX output to %s...", + outname == "-" ? String ("") : outname ) << endl; + p = new Tex_stream (outname); + target_str_global_array.push (outname); + return p; +} + diff --git a/make/STATE-VECTOR b/make/STATE-VECTOR index 1b57fde05f..14f696dc06 100644 --- a/make/STATE-VECTOR +++ b/make/STATE-VECTOR @@ -98,3 +98,4 @@ 1.0.13.jcn4 1.0.13.jcn5 1.0.14 +1.0.14.jcn1 -- 2.39.5