From eda0b8d4348f476fd54738dcc9ac3c2e85675ab3 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Thu, 1 May 2008 16:44:21 -0300 Subject: [PATCH] Move Skyline_pair and Paper_system bindings into their own files. --- lily/align-interface.cc | 11 ++-- lily/axis-group-interface.cc | 1 + lily/include/lily-proto.hh | 1 + lily/include/prob.hh | 5 ++ lily/include/skyline-pair.hh | 35 +++++++++++++ lily/include/skyline.hh | 19 ------- lily/paper-column.cc | 23 +++++---- lily/paper-system-scheme.cc | 44 ++++++++++++++++ lily/prob-scheme.cc | 34 ------------- lily/separation-item.cc | 8 +-- lily/skyline-pair.cc | 97 ++++++++++++++++++++++++++++++++++++ lily/skyline.cc | 81 ------------------------------ lily/spacing-interface.cc | 1 + lily/spacing-spanner.cc | 1 + lily/system.cc | 3 +- 15 files changed, 209 insertions(+), 155 deletions(-) create mode 100644 lily/include/skyline-pair.hh create mode 100644 lily/paper-system-scheme.cc create mode 100644 lily/skyline-pair.cc diff --git a/lily/align-interface.cc b/lily/align-interface.cc index daffa298fb..057e233f44 100644 --- a/lily/align-interface.cc +++ b/lily/align-interface.cc @@ -7,16 +7,17 @@ */ #include "align-interface.hh" -#include "spanner.hh" -#include "item.hh" #include "axis-group-interface.hh" -#include "pointer-group-interface.hh" -#include "hara-kiri-group-spanner.hh" #include "grob-array.hh" +#include "hara-kiri-group-spanner.hh" #include "international.hh" +#include "item.hh" +#include "paper-column.hh" +#include "pointer-group-interface.hh" +#include "spanner.hh" +#include "skyline-pair.hh" #include "system.hh" #include "warn.hh" -#include "paper-column.hh" /* TODO: for vertical spacing, should also include a rod & spring diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc index 121b0ba159..186205195a 100644 --- a/lily/axis-group-interface.cc +++ b/lily/axis-group-interface.cc @@ -18,6 +18,7 @@ #include "paper-column.hh" #include "paper-score.hh" #include "separation-item.hh" +#include "skyline-pair.hh" #include "stencil.hh" #include "system.hh" #include "warn.hh" diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh index 8de07c990b..e9a82a756b 100644 --- a/lily/include/lily-proto.hh +++ b/lily/include/lily-proto.hh @@ -154,6 +154,7 @@ class Simultaneous_music; class Simultaneous_music_iterator; class Skyline; class Skyline_entry; +class Skyline_pair; class Slur_configuration; class Slur_score_state; class Source_file; diff --git a/lily/include/prob.hh b/lily/include/prob.hh index b01fb4d42d..635df370e1 100644 --- a/lily/include/prob.hh +++ b/lily/include/prob.hh @@ -20,6 +20,7 @@ formatted content of the grob is put into a Property_object. Page-breaking handles Property_object objects. */ + class Prob { DECLARE_SMOBS (Prob); @@ -45,8 +46,12 @@ public: void instrumented_set_property (SCM, SCM, const char*, int, const char*); void internal_set_property (SCM sym, SCM val); }; + DECLARE_UNSMOB(Prob,prob); + SCM ly_prob_set_property_x (SCM system, SCM sym, SCM value); SCM ly_prob_property (SCM system, SCM sym, SCM dfault); +SCM ly_prob_type_p (SCM obj, SCM sym); + #endif /* PROPERTY_OBJECT_HH */ diff --git a/lily/include/skyline-pair.hh b/lily/include/skyline-pair.hh new file mode 100644 index 0000000000..4b57100159 --- /dev/null +++ b/lily/include/skyline-pair.hh @@ -0,0 +1,35 @@ +/* + skyline-pair.hh -- declare Skyline_pair + + source file of the GNU LilyPond music typesetter + + (c) 2008 Han-Wen Nienhuys + +*/ + +#ifndef SKYLINE_PAIR_HH +#define SKYLINE_PAIR_HH + +#include "skyline.hh" + +class Skyline_pair +{ +private: + Drul_array skylines_; + + DECLARE_SIMPLE_SMOBS(Skyline_pair); +public: + Skyline_pair (); + Skyline_pair (vector const &boxes, Real horizon_padding, Axis a); + Skyline_pair (Box const &, Real horizon_padding, Axis a); + void raise (Real); + void shift (Real); + void insert (Box const &, Real horizon_padding, Axis); + void merge (Skyline_pair const &other); + Skyline &operator [] (Direction d); + Skyline const &operator [] (Direction d) const; + bool is_empty () const; + void print () const; +}; + +#endif /* SKYLINE_PAIR_HH */ diff --git a/lily/include/skyline.hh b/lily/include/skyline.hh index 5dadbacaf7..312fae8265 100644 --- a/lily/include/skyline.hh +++ b/lily/include/skyline.hh @@ -70,24 +70,5 @@ public: bool is_empty () const; }; -class Skyline_pair -{ -private: - Drul_array skylines_; - - DECLARE_SIMPLE_SMOBS(Skyline_pair); -public: - Skyline_pair (); - Skyline_pair (vector const &boxes, Real horizon_padding, Axis a); - Skyline_pair (Box const &, Real horizon_padding, Axis a); - void raise (Real); - void shift (Real); - void insert (Box const &, Real horizon_padding, Axis); - void merge (Skyline_pair const &other); - Skyline &operator [] (Direction d); - Skyline const &operator [] (Direction d) const; - bool is_empty () const; -}; - #endif /* SKYLINE_HH */ diff --git a/lily/paper-column.cc b/lily/paper-column.cc index 8c9e0aea4e..0eb40d1b97 100644 --- a/lily/paper-column.cc +++ b/lily/paper-column.cc @@ -8,23 +8,24 @@ #include "paper-column.hh" -#include "break-align-interface.hh" -#include "moment.hh" -#include "paper-score.hh" -#include "warn.hh" #include "axis-group-interface.hh" -#include "spaceable-grob.hh" -#include "text-interface.hh" -#include "lookup.hh" +#include "break-align-interface.hh" #include "font-interface.hh" -#include "output-def.hh" -#include "pointer-group-interface.hh" #include "grob-array.hh" -#include "system.hh" -#include "spring.hh" #include "lookup.hh" +#include "lookup.hh" +#include "moment.hh" +#include "output-def.hh" +#include "paper-score.hh" +#include "pointer-group-interface.hh" #include "separation-item.hh" +#include "skyline-pair.hh" +#include "spaceable-grob.hh" +#include "spring.hh" #include "string-convert.hh" +#include "system.hh" +#include "text-interface.hh" +#include "warn.hh" Grob * Paper_column::clone () const diff --git a/lily/paper-system-scheme.cc b/lily/paper-system-scheme.cc new file mode 100644 index 0000000000..6935110611 --- /dev/null +++ b/lily/paper-system-scheme.cc @@ -0,0 +1,44 @@ +/* + paper-system-scheme.cc -- implement Paper_system bindings. + + source file of the GNU LilyPond music typesetter + + (c) 2008 Han-Wen Nienhuys + +*/ + +#include "prob.hh" + +#include "skyline-pair.hh" + +LY_DEFINE (ly_paper_system_p, "ly:paper-system?", + 1, 0, 0, (SCM obj), + "Type predicate.") +{ + return ly_prob_type_p (obj, ly_symbol2scm ("paper-system")); +} + +LY_DEFINE (ly_paper_system_minimum_distance, "ly:paper-system-minimum-distance", + 2, 0, 0, (SCM sys1, SCM sys2), + "Measure the minimum distance between these two paper-systems," + " using their stored skylines if possible and falling back to" + " their extents otherwise.") +{ + Real ret = 0; + Prob *p1 = unsmob_prob (sys1); + Prob *p2 = unsmob_prob (sys2); + Skyline_pair *sky1 = Skyline_pair::unsmob (p1->get_property ("vertical-skylines")); + Skyline_pair *sky2 = Skyline_pair::unsmob (p2->get_property ("vertical-skylines")); + + if (sky1 && sky2) + ret = (*sky1)[DOWN].distance ((*sky2)[UP]); + else + { + Stencil *s1 = unsmob_stencil (p1->get_property ("stencil")); + Stencil *s2 = unsmob_stencil (p2->get_property ("stencil")); + Interval iv1 = s1->extent (Y_AXIS); + Interval iv2 = s2->extent (Y_AXIS); + ret = iv2[UP] - iv1[DOWN]; + } + return scm_from_double (ret); +} diff --git a/lily/prob-scheme.cc b/lily/prob-scheme.cc index 8c5d640ad0..52b32b96f5 100644 --- a/lily/prob-scheme.cc +++ b/lily/prob-scheme.cc @@ -7,7 +7,6 @@ */ #include "prob.hh" -#include "skyline.hh" LY_DEFINE (ly_prob_set_property_x, "ly:prob-set-property!", 2, 1, 0, (SCM obj, SCM sym, SCM value), @@ -76,36 +75,3 @@ LY_DEFINE (ly_make_prob, "ly:make-prob", return pr->unprotect (); } - - -LY_DEFINE (ly_paper_system_p, "ly:paper-system?", - 1, 0, 0, (SCM obj), - "Type predicate.") -{ - return ly_prob_type_p (obj, ly_symbol2scm ("paper-system")); -} - -LY_DEFINE (ly_paper_system_minimum_distance, "ly:paper-system-minimum-distance", - 2, 0, 0, (SCM sys1, SCM sys2), - "Measure the minimum distance between these two paper-systems," - " using their stored skylines if possible and falling back to" - " their extents otherwise.") -{ - Real ret = 0; - Prob *p1 = unsmob_prob (sys1); - Prob *p2 = unsmob_prob (sys2); - Skyline_pair *sky1 = Skyline_pair::unsmob (p1->get_property ("vertical-skylines")); - Skyline_pair *sky2 = Skyline_pair::unsmob (p2->get_property ("vertical-skylines")); - - if (sky1 && sky2) - ret = (*sky1)[DOWN].distance ((*sky2)[UP]); - else - { - Stencil *s1 = unsmob_stencil (p1->get_property ("stencil")); - Stencil *s2 = unsmob_stencil (p2->get_property ("stencil")); - Interval iv1 = s1->extent (Y_AXIS); - Interval iv2 = s2->extent (Y_AXIS); - ret = iv2[UP] - iv1[DOWN]; - } - return scm_from_double (ret); -} diff --git a/lily/separation-item.cc b/lily/separation-item.cc index 5c9eb9ef10..8e48cf5ccc 100644 --- a/lily/separation-item.cc +++ b/lily/separation-item.cc @@ -8,15 +8,15 @@ #include "separation-item.hh" +#include "accidental-placement.hh" #include "axis-group-interface.hh" #include "lookup.hh" #include "note-head.hh" -#include "stencil.hh" -#include "skyline.hh" #include "paper-column.hh" -#include "warn.hh" #include "pointer-group-interface.hh" -#include "accidental-placement.hh" +#include "skyline-pair.hh" +#include "stencil.hh" +#include "warn.hh" void Separation_item::add_item (Grob *s, Item *i) diff --git a/lily/skyline-pair.cc b/lily/skyline-pair.cc new file mode 100644 index 0000000000..4ce44586d5 --- /dev/null +++ b/lily/skyline-pair.cc @@ -0,0 +1,97 @@ +/* + skyline-pair.cc -- implement Skyline_pair + + source file of the GNU LilyPond music typesetter + + (c) 2008 Han-Wen Nienhuys + +*/ + +#include "skyline-pair.hh" + +#include "ly-smobs.icc" + +Skyline_pair::Skyline_pair () + : skylines_ (Skyline (DOWN), Skyline (UP)) +{ +} + +Skyline_pair::Skyline_pair (vector const &boxes, Real padding, Axis a) + : skylines_ (Skyline (boxes, padding, a, DOWN), Skyline (boxes, padding, a, UP)) +{ +} + +Skyline_pair::Skyline_pair (Box const &b, Real padding, Axis a) + : skylines_ (Skyline (b, padding, a, DOWN), Skyline (b, padding, a, UP)) +{ +} + +void +Skyline_pair::raise (Real r) +{ + skylines_[UP].raise (r); + skylines_[DOWN].raise (r); +} + +void +Skyline_pair::shift (Real r) +{ + skylines_[UP].shift (r); + skylines_[DOWN].shift (r); +} + +void +Skyline_pair::insert (Box const &b, Real padding, Axis a) +{ + skylines_[UP].insert (b, padding, a); + skylines_[DOWN].insert (b, padding, a); +} + +void +Skyline_pair::merge (Skyline_pair const &other) +{ + skylines_[UP].merge (other[UP]); + skylines_[DOWN].merge (other[DOWN]); +} + + +bool +Skyline_pair::is_empty () const +{ + return skylines_[UP].is_empty () + && skylines_[DOWN].is_empty (); +} + +Skyline& +Skyline_pair::operator [] (Direction d) +{ + return skylines_[d]; +} + +Skyline const& +Skyline_pair::operator [] (Direction d) const +{ + return skylines_[d]; +} + +IMPLEMENT_SIMPLE_SMOBS (Skyline_pair); +IMPLEMENT_TYPE_P (Skyline_pair, "ly:skyline-pair?"); +IMPLEMENT_DEFAULT_EQUAL_P (Skyline_pair); + + + +SCM +Skyline_pair::mark_smob (SCM) +{ + return SCM_EOL; +} + +int +Skyline_pair::print_smob (SCM s, SCM port, scm_print_state *) +{ + Skyline_pair *r = (Skyline_pair *) SCM_CELL_WORD_1 (s); + (void) r; + + scm_puts ("#", port); + return 1; +} diff --git a/lily/skyline.cc b/lily/skyline.cc index e0139a6866..5297f6359a 100644 --- a/lily/skyline.cc +++ b/lily/skyline.cc @@ -541,67 +541,6 @@ Skyline::is_empty () const return b.end_ == infinity_f && b.y_intercept_ == -infinity_f; } -Skyline_pair::Skyline_pair () - : skylines_ (Skyline (DOWN), Skyline (UP)) -{ -} - -Skyline_pair::Skyline_pair (vector const &boxes, Real padding, Axis a) - : skylines_ (Skyline (boxes, padding, a, DOWN), Skyline (boxes, padding, a, UP)) -{ -} - -Skyline_pair::Skyline_pair (Box const &b, Real padding, Axis a) - : skylines_ (Skyline (b, padding, a, DOWN), Skyline (b, padding, a, UP)) -{ -} - -void -Skyline_pair::raise (Real r) -{ - skylines_[UP].raise (r); - skylines_[DOWN].raise (r); -} - -void -Skyline_pair::shift (Real r) -{ - skylines_[UP].shift (r); - skylines_[DOWN].shift (r); -} - -void -Skyline_pair::insert (Box const &b, Real padding, Axis a) -{ - skylines_[UP].insert (b, padding, a); - skylines_[DOWN].insert (b, padding, a); -} - -void -Skyline_pair::merge (Skyline_pair const &other) -{ - skylines_[UP].merge (other[UP]); - skylines_[DOWN].merge (other[DOWN]); -} - -bool -Skyline_pair::is_empty () const -{ - return skylines_[UP].is_empty () - && skylines_[DOWN].is_empty (); -} - -Skyline& -Skyline_pair::operator [] (Direction d) -{ - return skylines_[d]; -} - -Skyline const& -Skyline_pair::operator [] (Direction d) const -{ - return skylines_[d]; -} /****************************************************************/ @@ -610,10 +549,6 @@ IMPLEMENT_SIMPLE_SMOBS (Skyline); IMPLEMENT_TYPE_P (Skyline, "ly:skyline?"); IMPLEMENT_DEFAULT_EQUAL_P (Skyline); -IMPLEMENT_SIMPLE_SMOBS (Skyline_pair); -IMPLEMENT_TYPE_P (Skyline_pair, "ly:skyline-pair?"); -IMPLEMENT_DEFAULT_EQUAL_P (Skyline_pair); - SCM Skyline::mark_smob (SCM) { @@ -631,19 +566,3 @@ Skyline::print_smob (SCM s, SCM port, scm_print_state *) return 1; } - -SCM -Skyline_pair::mark_smob (SCM) -{ - return SCM_EOL; -} - -int -Skyline_pair::print_smob (SCM s, SCM port, scm_print_state *) -{ - Skyline_pair *r = (Skyline_pair *) SCM_CELL_WORD_1 (s); - (void) r; - - scm_puts ("#", port); - return 1; -} diff --git a/lily/spacing-interface.cc b/lily/spacing-interface.cc index 2033cfcac4..d494c318c5 100644 --- a/lily/spacing-interface.cc +++ b/lily/spacing-interface.cc @@ -17,6 +17,7 @@ #include "paper-column.hh" #include "separation-item.hh" #include "skyline.hh" +#include "skyline-pair.hh" #include "system.hh" /* return the right-pointing skyline of the left-items and the left-pointing diff --git a/lily/spacing-spanner.cc b/lily/spacing-spanner.cc index e580e33267..74e54e7eac 100644 --- a/lily/spacing-spanner.cc +++ b/lily/spacing-spanner.cc @@ -21,6 +21,7 @@ #include "paper-score.hh" #include "pointer-group-interface.hh" #include "separation-item.hh" +#include "skyline-pair.hh" #include "spaceable-grob.hh" #include "spacing-interface.hh" #include "staff-spacing.hh" diff --git a/lily/system.cc b/lily/system.cc index a2ad71ece3..6143d7acb0 100644 --- a/lily/system.cc +++ b/lily/system.cc @@ -13,15 +13,16 @@ #include "axis-group-interface.hh" #include "grob-array.hh" #include "international.hh" +#include "lookup.hh" #include "main.hh" #include "output-def.hh" #include "paper-column.hh" #include "paper-score.hh" #include "paper-system.hh" #include "pointer-group-interface.hh" +#include "skyline-pair.hh" #include "staff-symbol-referencer.hh" #include "warn.hh" -#include "lookup.hh" extern bool debug_skylines; -- 2.39.5