From 3c41f585e2d515d6ea71dc86d7e2d084694d359d Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sun, 14 Nov 2004 02:06:30 +0000 Subject: [PATCH] * lily/lookup.cc (triangle): rewrite, obviating symmetric_x_triangle(). * lily/context.cc (Context): take key argument in ctor. (create_context): new function * lily/include/object-key.hh (class Object_key): new file. --- ChangeLog | 3 +++ lily/context.cc | 41 ++++++++++++++++++++++-------------- lily/include/context.hh | 1 + lily/include/object-key.hh | 3 +++ lily/lookup.cc | 18 +++++++++------- ps/music-drawing-routines.ps | 11 ---------- scm/lily.scm | 1 - scm/output-ps.scm | 5 ----- scm/output-tex.scm | 5 ----- 9 files changed, 42 insertions(+), 46 deletions(-) diff --git a/ChangeLog b/ChangeLog index 14afb90984..023d20da13 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,9 @@ 2004-11-14 Han-Wen Nienhuys + * lily/lookup.cc (triangle): rewrite, obviating symmetric_x_triangle(). + * lily/context.cc (Context): take key argument in ctor. + (create_context): new function * lily/grob.cc (Grob): take key argument in ctor. diff --git a/lily/context.cc b/lily/context.cc index cf678b4e21..b57a98459e 100644 --- a/lily/context.cc +++ b/lily/context.cc @@ -148,18 +148,11 @@ Context::find_create_context (SCM n, String id, SCM operations) { this_id = id; } - - Object_key const *key = get_context_key (ly_symbol2string (path[i]->get_context_name()), this_id); - - Context * new_group - = path[i]->instantiate (ops, key); - scm_gc_unprotect_object (key->self_scm ()); - - new_group->id_string_ = this_id; - current->add_context (new_group); - apply_property_operations (new_group, ops); - - current = new_group; + + + current = create_context (path[i], + this_id, + ops); } return current; @@ -181,6 +174,25 @@ Context::find_create_context (SCM n, String id, SCM operations) return ret; } + +Context* +Context::create_context (Context_def * cdef, + String id, + SCM ops) +{ + String type = ly_symbol2string (cdef->get_context_name()); + Object_key const *key = get_context_key (type, id); + Context * new_group + = cdef->instantiate (ops, key); + scm_gc_unprotect_object (key->self_scm ()); + + new_group->id_string_ = this_id; + add_context (new_group); + apply_property_operations (new_group, ops); + + return new_group; +} + Object_key const* Context::get_context_key (String type, String id) { @@ -256,10 +268,7 @@ Context::get_default_interpreter () t = unsmob_context_def (this->definition_); } - Object_key const *key = get_context_key (name, ""); - - Context *tg = t->instantiate (SCM_EOL, key); - add_context (tg); + Context *tg = create_context (t, "", SCM_EOL) if (!tg->is_bottom_context ()) return tg->get_default_interpreter (); else diff --git a/lily/include/context.hh b/lily/include/context.hh index bb45f7254b..8c2901e372 100644 --- a/lily/include/context.hh +++ b/lily/include/context.hh @@ -51,6 +51,7 @@ public: Object_key const *get_grob_key (String); Object_key const *get_context_key (String, String); + Context *create_context (Context_def*, String, SCM); String id_string () const { return id_string_; } SCM children_contexts () const { return context_list_; } SCM default_child_context_name () const; diff --git a/lily/include/object-key.hh b/lily/include/object-key.hh index c64fcc9deb..400ee4c12a 100644 --- a/lily/include/object-key.hh +++ b/lily/include/object-key.hh @@ -28,6 +28,7 @@ protected: virtual void derived_mark () const; virtual int get_type () const; virtual int do_compare (Object_key const * other) const; + public: int compare (Object_key const *other) const; }; @@ -45,10 +46,12 @@ class Copied_key : public Object_key private: Object_key const * original_; int copy_count_; + protected: virtual void derived_mark () const; virtual int get_type () const; virtual int do_compare (Object_key const * other) const; + public: Copied_key (Object_key const*, int); }; diff --git a/lily/lookup.cc b/lily/lookup.cc index 69db6c1086..42fbb1cf29 100644 --- a/lily/lookup.cc +++ b/lily/lookup.cc @@ -690,14 +690,16 @@ Lookup::triangle (Interval iv, Real thick, Real protude) b[X_AXIS] = Interval (0, iv.length()); b[Y_AXIS] = Interval (0 ? protude); - SCM s = scm_list_n (ly_symbol2scm ("symmetric-x-triangle"), - scm_make_real (thick), - scm_make_real (iv.length ()), - scm_make_real (protude), SCM_UNDEFINED); - - Stencil stc (b, s); - stc.translate_axis (iv[LEFT], X_AXIS); - return stc; + + Offset z1(iv[LEFT], 0); + Offset z2(iv[RIGHT], 0); + Offset z3(z2[X_AXIS]/2, protude); + + Stencil tri = make_line (z1, z2); + tri.add_stencil (make_line (z2, z3)); + tri.add_stencil (make_line (z3, z1)); + + return tri; } diff --git a/ps/music-drawing-routines.ps b/ps/music-drawing-routines.ps index 7ee1498305..ed6b76bb09 100644 --- a/ps/music-drawing-routines.ps +++ b/ps/music-drawing-routines.ps @@ -49,17 +49,6 @@ } bind def -/draw_symmetric_x_triangle % h w th -{ - setlinewidth - 0 0 moveto - dup 0 lineto - 2 div - exch lineto - 0 0 lineto - stroke -} bind def - /draw_round_box % breapth width depth height blot { /blot exch def diff --git a/scm/lily.scm b/scm/lily.scm index 0b69cc7ebe..d9c9a01492 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -134,7 +134,6 @@ predicates. Print a message at LOCATION if any predicate failed." polygon repeat-slash round-filled-box - symmetric-x-triangle text tuplet white-dot diff --git a/scm/output-ps.scm b/scm/output-ps.scm index 5db157f282..e150896a66 100644 --- a/scm/output-ps.scm +++ b/scm/output-ps.scm @@ -29,7 +29,6 @@ char dashed-line zigzag-line - symmetric-x-triangle ez-ball comment repeat-slash @@ -217,10 +216,6 @@ (ly:numbers->string (list breapth width depth height)) " draw_box" )) -(define (symmetric-x-triangle thick w h) - (string-append - (ly:numbers->string (list h w thick)) - " draw_symmetric_x_triangle")) (define (text font s) (let* diff --git a/scm/output-tex.scm b/scm/output-tex.scm index 4ea8fbe77d..70da599df2 100644 --- a/scm/output-tex.scm +++ b/scm/output-tex.scm @@ -32,7 +32,6 @@ char dashed-line zigzag-line - symmetric-x-triangle ez-ball comment repeat-slash @@ -101,10 +100,6 @@ (define (zigzag-line centre? zzw zzh thick dx dy) (embedded-ps (list 'zigzag-line centre? zzw zzh thick dx dy))) -(define (symmetric-x-triangle t w h) - (embedded-ps (list 'symmetric-x-triangle t w h))) - - (define (ez-ball c l b) (embedded-ps (list 'ez-ball c l b))) -- 2.39.2