]> git.donarmstrong.com Git - lilypond.git/commitdiff
patch::: 1.0.14.jcn1: braak
authorJan Nieuwenhuizen <janneke@gnu.org>
Sat, 10 Oct 1998 15:37:44 +0000 (18:37 +0300)
committerJan Nieuwenhuizen <janneke@gnu.org>
Sat, 10 Oct 1998 15:37:44 +0000 (18:37 +0300)
pl 14.jcn1
- moved most ugly lookup stuff
- {Ps,Tex}_{def,score}.{cc,hh}

*********
pl 14

37 files changed:
NEWS
VERSION
lily/atom.cc
lily/dimensions.cc [new file with mode: 0644]
lily/include/dimensions.hh
lily/include/file-results.hh
lily/include/lily-proto.hh
lily/include/lookup.hh
lily/include/main.hh
lily/include/music-output-def.hh
lily/include/p-score.hh
lily/include/paper-def.hh
lily/include/ps-def.hh [new file with mode: 0644]
lily/include/ps-lookup.hh
lily/include/ps-score.hh [new file with mode: 0644]
lily/include/tex-def.hh [new file with mode: 0644]
lily/include/tex-lookup.hh
lily/include/tex-score.hh [new file with mode: 0644]
lily/line-spacer.cc
lily/lookup.cc
lily/main.cc
lily/music-output-def.cc
lily/my-lily-parser.cc
lily/p-score.cc
lily/paper-def.cc
lily/paper-outputter.cc
lily/parser.yy
lily/ps-def.cc [new file with mode: 0644]
lily/ps-lookup.cc
lily/ps-score.cc [new file with mode: 0644]
lily/score-engraver.cc
lily/scores.cc
lily/spring-spacer.cc
lily/tex-def.cc [new file with mode: 0644]
lily/tex-lookup.cc
lily/tex-score.cc [new file with mode: 0644]
make/STATE-VECTOR

diff --git a/NEWS b/NEWS
index c615f4cf69a9e64460e8706571a9c07c2a2b771b..5b362a2de4f0b7464bf51775d951828e4140167d 100644 (file)
--- 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 41cbf150653767029d33f902ebf39914e9627088..fc233366619af2498107c5f329fdc974fd97ee4f 100644 (file)
--- 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.
index 76b59197d39219634b934a0f5761588a76705558..8e32fd013397d4cc4450000c71698638acac032f 100644 (file)
@@ -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 (file)
index 0000000..26a5c08
--- /dev/null
@@ -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;
+}
+
index 777d80e89c001fd3e81b7fa2dab29818bafee567..91b6e0c4d6f1644aeea52321d780ec2f2c0b2eb7 100644 (file)
@@ -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
 
index f4cf779c174e6124ec2731782b903c0dd79899d8..a9cf1abdafde4dd55c887e50c3ad7c150a057078 100644 (file)
@@ -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;
index 25682a4cc45fb4292f17edc31f2fa0a544aca9ab..f1884ac8cfd85b36c23fb74685308cf3335dc77a 100644 (file)
@@ -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;
index 40dc740c1454dcc380468537ed5a4140ce0a537e..9b1e198a4433cdc92051b07f91c2c8dc77c61266 100644 (file)
@@ -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<Offset> 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<Scalar>) const;
index 072813b2f1226b9ebf8e4d99b6aba102b1d33790..38399f71c595d2f0e579ce40dcb2a989a2a7acda 100644 (file)
@@ -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;
 
index 5940cc417738e83fe285cbec42671c9f636991bb..aaa93383afe2809bdbb83f148f33afdfb6319c5a 100644 (file)
@@ -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;
index 6b627f9377fe789b893e3174cd1a2075f6d14f25..3bf58582b5315f108d7ca2e2bb8c07f0a9e8dbb1 100644 (file)
@@ -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:
 
   
index 87bfe545731de4472bebe79619131a29990badc7..b42c400af4155494e75534b73bbc438bf127a663 100644 (file)
@@ -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<Interval> 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 (file)
index 0000000..676d335
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+  ps-def.hh -- declare Ps_def
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1998 Jan Nieuwenhuizen <jannneke@gnu.org>
+*/
+
+#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
index 84f4abdcee602789ad3daf0c8a98313d5444aed1..2ffb9af3b6c73f812ef89a266dcd581e2838a71a 100644 (file)
@@ -24,16 +24,11 @@ public:
   virtual String character_str (int i) const;
   virtual Atom dashed_slur (Array<Offset> 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<Offset> 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 (file)
index 0000000..d83a503
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+  ps-score.hh -- declare Ps_score
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1998 Jan Nieuwenhuizen <jannneke@gnu.org>
+*/
+
+#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 (file)
index 0000000..92f8783
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+  tex-def.hh -- declare Tex_def
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1998 Jan Nieuwenhuizen <jannneke@gnu.org>
+*/
+
+#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
index 24aadf16449e89c7d7df9315357a87ad2f982741..6b17bfa8728d604a06207c1bc8235562b2cd3b5a 100644 (file)
@@ -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<Offset> 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 (file)
index 0000000..0bfa12b
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+  tex-score.hh -- declare Tex_score
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1998 Jan Nieuwenhuizen <jannneke@gnu.org>
+*/
+
+#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
index ffd65ff34e248bffb6ec5a063ad924179f0f0114..b39be2aedaaa0f4895c980197b5312277eca8f3a 100644 (file)
@@ -3,22 +3,24 @@
 
   source file of the GNU LilyPond music typesetter
 
 (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 
 #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_;
+}
+
index 8ba88483f5f080c3bf4fdf17d0a2274863318bf8..7f09106f3bdf5496f8f1ea4d1be3c28e7cf62d88 100644 (file)
@@ -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
index 33df5a1c83840b46686a2c2b62abae9da944831b..24278fb5770fa75da6abc2f53f38987918a5fe31 100644 (file)
@@ -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_;
index 86a20a731e862e20bc8a2bdd42501d555b8d56f0..7af3146edac5458f531ad4c6553fea77a096feef 100644 (file)
@@ -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
 {
index ea2cbe6b5ab32078da1b07a22c56f10744bdcbd2..de8ae42c14ba2a53ec12aede95e2fdd4fbced160 100644 (file)
@@ -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*
index 25eaac2aa4493a7009fd83715399beb2881aaa37..901cfa48d2d7e22f4afeef88119192fdfa5d60c3 100644 (file)
@@ -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<Column_x_positions> 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<Line_of_score> 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;
 }
 
index d3d4a6795476f3d07af96b7cc857b9c7e1ef7207..a0e81bb96ceeffb0136686cea51c9abbae2fe783 100644 (file)
 #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<int, Lookup*>;
 }
 
+Paper_def::Paper_def (Paper_def const&s)
+  : Music_output_def (s)
+{
+  lookup_p_assoc_p_ = new Assoc<int, Lookup*>;
+  for (Assoc_iter<int, Lookup*> 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<int, Lookup*>;
-  for (Assoc_iter<int, Lookup*> 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) <? d);
+}
+
+Real
+Paper_def::arithmetic_spacing (Moment d ,Real k) const
+{
+  return (log_2 (d) + k)* get_var ("arithmetic_multiplier");
+}
+
+Real
+Paper_def::beam_thickness_f () const
+{
+  return get_var ("beam_thickness");
+}
+
+Real
+Paper_def::duration_to_dist (Moment d,Real k) const
+{
+  return arithmetic_spacing (d,k);
+}
+
+int
+Paper_def::get_next_default_count () const
+{
+  return default_count_i_ ++;
 }
 
 Real
@@ -82,46 +125,6 @@ Paper_def::line_dimensions_int (int n) const
   return shape_int_a_[n];
 }
 
-Real
-Paper_def::beam_thickness_f () const
-{
-  return get_var ("beam_thickness");
-}
-
-Real
-Paper_def::linewidth_f () const
-{
-  return get_var ("linewidth");
-}
-
-Real
-Paper_def::duration_to_dist (Moment d,Real k) const
-{
-  return arithmetic_spacing (d,k);
-}
-
-
-/**
-  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
-{
-  return get_var ("arithmetic_basicspace") - log_2 (Moment (1,8) <? d);
-}
-
-Real
-Paper_def::arithmetic_spacing (Moment d ,Real k) const
-{
-  return (log_2 (d) + k)* get_var ("arithmetic_multiplier");
-}
-
 Real
 Paper_def::geometric_spacing (Moment d) const
 {
@@ -129,17 +132,6 @@ Paper_def::geometric_spacing (Moment d) const
   return get_var ("basicspace") + get_var ("unitspace")  * dur_f;
 }
 
-void
-Paper_def::set_lookup (int i, Lookup*l)
-{
-  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;
-}
-
 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<String,Identifier*> 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<String,Identifier*> 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 "";
+}
 
index 1e8d450c7b31b2969df751f4e66dbf555371b6c5..17231564b8555774d6be312d1e4c7d67af9a639d 100644 (file)
@@ -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<String> 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;
index bc323e061f969c8c011cd5c89b25975d34924f52..f6e9764a17d55a379bb222255a4b3b9e3329da54 100644 (file)
@@ -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 (file)
index 0000000..f0aa1e1
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+  ps-def.cc -- implement Ps_def
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#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<String,Identifier*> 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 ";
+}
+
index f488b5e92a31358f17b14463e79472a0b44ca9ac..cb839468a1d7ed9a99c8fcdd73be0b2dfd3a0ae4 100644 (file)
@@ -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 ("<stdout>") : 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 (file)
index 0000000..05137ec
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+  ps-score.cc -- implement Ps_score
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#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 ("<stdout>") : outname ) << endl;
+  target_str_global_array.push (outname);
+  return new Ps_stream (outname);
+}
+
index 1b30731fd710d69d6e5f80516fb1e6adf5433d2d..c5350418efa622c5e552380c47ea23fdae424d07 100644 (file)
@@ -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_;
 }
index 9b2a80bee33760cfbfdb4cb993dc00d0e3352aac..47ee1c9a318f3052409b89e55f01a6af9904103b 100644 (file)
@@ -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_)
       {
index 99939fcd6b55900401845a3e83ca78550723c234..83aecfa94eddee9e37baafe6ff4687f508dd6ac3 100644 (file)
@@ -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<Real>;               // 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<int> fixed;
-  for (PCursor<Idealspacing*> i (ideal_p_list_.top()); i.ok (); i++)
+  for (PCursor<Idealspacing*> 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<bool> 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 <? sol_vec (i);
     }
-  Vector v (fix_b_arr.size());
+  Vector v (fix_b_arr.size ());
   int j =0;
   int k =0;
-  for (int i=0; i < v.dim(); i++)
+  for (int i=0; i < v.dim (); i++)
     {
       if (fix_b_arr[i])
        {
@@ -127,9 +127,9 @@ Spring_spacer::position_loose_cols (Vector &sol_vec) const
          Real left_pos_f =
            (j>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<sol_vec.dim()) ? cols_[j].rank_i_ : sol_vec.dim ();
+         int right_rank = (j<sol_vec.dim ()) ? cols_[j].rank_i_ : sol_vec.dim ();
 
          int d_r = right_rank - left_rank;
          Column_info loose=loose_col_arr_[k++];
@@ -146,13 +146,13 @@ Spring_spacer::position_loose_cols (Vector &sol_vec) const
 bool
 Spring_spacer::check_constraints (Vector v) const
 {
-  int dim=v.dim();
-  assert (dim == cols_.size());
+  int dim=v.dim ();
+  assert (dim == cols_.size ());
   DOUT << "checking " << v;
   for (int i=0; i < dim; i++)
     {
-      if (cols_[i].fixed_b() &&
-         abs (cols_[i].fixed_position() - v (i)) > 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<Spacer_rod> const &sr_arr(cols_[i].rods_[LEFT]);
+      Array<Spacer_rod> 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<Idealspacing*> i (ideal_p_list_.top()); i.ok (); i++)
+  for (PCursor<Idealspacing*> 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<Spacer_rod> 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<Idealspacing*> i (ideal_p_list_.top()); i.ok(); i++)
+  for (PCursor<Idealspacing*> 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<Paper_column*> 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<Idealspacing*> j (ideal_p_list_.top()); j.ok (); j++)
+  for (PCursor<Idealspacing*> 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<Idealspacing*> i (ideal_p_list_.top()); i.ok (); i++)
+  for (PCursor<Idealspacing*> 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<Moment> &shortest_playing_arr,
+Spring_spacer::get_ruling_durations (Array<Moment> &shortest_playing_arr,
                                    Array<Moment> &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<Moment> &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 <? scol_l(i)->durations[0];
+         context_shortest = context_shortest <? scol_l (i)->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 <? scol_l(ji)->durations[k];
+             shortest_playing = shortest_playing <? scol_l (ji)->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<Moment> &shortest_playing_arr,
 
   */
 void
-Spring_spacer::calc_idealspacing()
+Spring_spacer::calc_idealspacing ()
 {
   Array<Moment> shortest_playing_arr;
   Array<Moment> 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<Real> ideal_arr_;
   Array<Real> 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 (file)
index 0000000..bd9d61a
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+  tex-def.cc -- implement Tex_def
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#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<String,Identifier*> 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";
+}
+
index 3e82c82a59bb116c44426c4f1a23c4bef0917b79..c87589f1a13d476abaf22ffcfb982077efd4bced 100644 (file)
@@ -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 ("<stdout>") : 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 (file)
index 0000000..07e1108
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+  tex-score.cc -- implement Tex_score
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#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 ("<stdout>") : outname ) << endl;
+  p = new Tex_stream (outname);
+  target_str_global_array.push (outname);
+  return p;
+}
+
index 1b57fde05f66bc0cdbd5e9f72928b32dbb10bf7f..14f696dc06e6dabcba8de765334df22e621ab213 100644 (file)
@@ -98,3 +98,4 @@
 1.0.13.jcn4
 1.0.13.jcn5
 1.0.14
+1.0.14.jcn1