+++ /dev/null
-/*
- engravergroup.cc -- implement Engraver_group_engraver
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-#include "proto.hh"
-#include "engraver-group-engraver.hh"
-#include "engraver.hh"
-#include "debug.hh"
-#include "p-score.hh"
-#include "score-element.hh"
-
-
-ADD_THIS_TRANSLATOR(Engraver_group_engraver);
-
-void
-Engraver_group_engraver::announce_element (Score_element_info info)
-{
- announce_info_arr_.push (info);
- Engraver::announce_element (info);
-}
-
-void
-Engraver_group_engraver::do_announces()
-{
- Link_array<Translator_group> groups = group_l_arr ();
- for (int i=0; i < groups.size(); i++)
- {
- Engraver_group_engraver * group = dynamic_cast<Engraver_group_engraver*> (groups[i]);
- if (group)
- {
- group->do_announces();
- }
- }
-
- Request dummy_req;
-
- Link_array<Translator> nongroups = nongroup_l_arr ();
- while (announce_info_arr_.size ())
- {
- for (int j =0; j < announce_info_arr_.size(); j++)
- {
- Score_element_info info = announce_info_arr_[j];
-
- if (!info.req_l_)
- info.req_l_ = &dummy_req;
- for (int i=0; i < nongroups.size(); i++)
- { // Is this good enough?
- Engraver * eng = dynamic_cast<Engraver*> (nongroups[i]);
- if (eng && eng!= info.origin_trans_l_arr_[0])
- eng->acknowledge_element (info);
- }
- }
- announce_info_arr_.clear ();
- for (int i=0; i < nongroups.size(); i++)
- {
- Engraver * eng = dynamic_cast<Engraver*> (nongroups[i]);
- if (eng)
- eng->process_acknowledged ();
- }
-
- }
-}
-
-
-Staff_info
-Engraver_group_engraver::get_staff_info() const
-{
- Staff_info inf = Engraver::get_staff_info();
-
- Link_array<Translator> simple_translators = nongroup_l_arr ();
- for (int i=0; i < simple_translators.size(); i++)
- {
- Engraver * eng = dynamic_cast<Engraver*> (simple_translators[i]);
- if (eng)
- eng->fill_staff_info (inf);
- }
- return inf;
-}
-
-
-
+++ /dev/null
-/*
- head-grav.cc -- part of GNU LilyPond
-
- (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-#include "note-head.hh"
-#include "heads-engraver.hh"
-#include "paper-def.hh"
-#include "musical-request.hh"
-#include "dots.hh"
-#include "dot-column.hh"
-
-Note_heads_engraver::Note_heads_engraver()
-{
-}
-
-bool
-Note_heads_engraver::do_try_music (Music *m)
-{
- if (Note_req * n =dynamic_cast <Note_req *> (m))
- {
- note_req_l_arr_.push (n);
- return true;
- }
- if (Tonic_req* t = dynamic_cast<Tonic_req*> (m))
- {
- return true;
- }
- return false;
-}
-
-void
-Note_heads_engraver::do_process_requests()
-{
- if (note_p_arr_.size ())
- return ;
-
- String noteheadstyle = get_property ("noteHeadStyle", 0);
- for (int i=0; i < note_req_l_arr_.size (); i++)
- {
- Note_head *note_p = new Note_head;
- Note_req * note_req_l = note_req_l_arr_[i];
- note_p->balltype_i_ = note_req_l->duration_.durlog_i_;
- note_p->dots_i_ = note_req_l->duration_.dots_i_;
- if (note_p->dots_i_)
- {
- Dots * d = new Dots;
- note_p->dots_l_ = d;
- announce_element (Score_element_info (d,0));
- dot_p_arr_.push (d);
- }
-
- // note_p->steps_i_ = note_req_l->pitch_.steps ();
- note_p->position_i_ = note_req_l->pitch_.steps ();
-
-
- if (noteheadstyle == "transparent")
- note_p->set_elt_property (transparent_scm_sym, SCM_BOOL_T);
- else
- note_p->set_elt_property (style_scm_sym,
- gh_str02scm (noteheadstyle.ch_C()));
-
-
- Score_element_info itinf (note_p,note_req_l);
- announce_element (itinf);
- note_p_arr_.push (note_p);
- }
-}
-
-void
-Note_heads_engraver::do_pre_move_processing()
-{
- for (int i=0; i < note_p_arr_.size (); i++)
- {
- typeset_element (note_p_arr_[i]);
- }
- note_p_arr_.clear ();
- for (int i=0; i < dot_p_arr_.size (); i++)
- {
- typeset_element (dot_p_arr_[i]);
- }
- dot_p_arr_.clear ();
-
- note_req_l_arr_.clear ();
-}
-
-void
-Note_heads_engraver::do_post_move_processing()
-{
-
-}
-
-
-
-ADD_THIS_TRANSLATOR(Note_heads_engraver);
+++ /dev/null
-/*
- head-engraver.hh -- part of GNU LilyPond
-
- (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-
-#ifndef HEADSGRAV_HH
-#define HEADSGRAV_HH
-#include "engraver.hh"
-
-/**
- make balls and rests
- */
-class Note_heads_engraver : public Engraver {
- Link_array<Note_head> note_p_arr_;
- Link_array<Dots> dot_p_arr_;
- Link_array<Note_req> note_req_l_arr_;
-
-public:
- VIRTUAL_COPY_CONS(Translator);
- Note_heads_engraver();
-
-protected:
- virtual bool do_try_music (Music *req_l) ;
- virtual void do_process_requests();
- virtual void do_pre_move_processing();
- virtual void do_post_move_processing();
-};
-
-
-#endif // HEADSGRAV_HH
+++ /dev/null
-/*
- p-col.hh -- declare Paper_column
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-
-#ifndef P_COL_HH
-#define P_COL_HH
-
-#include "axis-group-item.hh"
-#include "rod.hh"
-#include "spring.hh"
-
-/**
- stuff grouped vertically.
- This is a class to address items vertically. It contains the data for:
- \begin{itemize}
- \item
- unbroken score
- \item
- broken score
- \item
- the linespacing problem
- \end{itemize}
- */
-
-class Paper_column : public Axis_group_item {
-public:
- VIRTUAL_COPY_CONS(Score_element);
- Drul_array<Array<Column_rod> > minimal_dists_arr_drul_;
- Drul_array<Array<Column_spring> > spring_arr_drul_;
- void preprocess ();
- /// set a minimum distance
- void add_rod (Paper_column * to, Real distance);
- void add_spring (Paper_column * to, Real dist, Real strength);
-
- virtual Paper_column * column_l () const;
- /// if lines are broken then this column is in #line#
- Line_of_score *line_l_;
-
- virtual Line_of_score *line_l () const;
-
- /// which one (left =0)
- int rank_i() const;
-
- bool breakpoint_b() const;
- void add_item (Item *i);
-
- Paper_column();
-
- void set_rank (int);
-
- void OK() const;
- virtual void do_print() const;
-private:
-
- /**
- The ranking: left is smaller than right
- -1 is uninitialised.
- */
- int rank_i_;
-
-};
-
-
-// #include "compare.hh"
-// INSTANTIATE_COMPARE(Paper_column &, Paper_column::compare);
-
-#endif // P_COL_HH
-
+++ /dev/null
-/*
- p-score.hh -- declare Paper_score
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1996, 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-
-#ifndef P_SCORE_HH
-#define P_SCORE_HH
-
-#include "colhpos.hh"
-#include "parray.hh"
-#include "lily-proto.hh"
-#include "music-output.hh"
-#include "lily-guile.hh"
-
-/** all stuff which goes onto paper. notes, signs, symbols in a score
- #Paper_score# contains the items, the columns.
-
- */
-
-class Paper_score : public Music_output
-{
- /// crescs etc; no particular order
- Link_array<Spanner> span_p_arr_;
-
- /// other elements
- Link_array<Score_element> elem_p_arr_;
- Link_array<Score_element> break_helpers_arr_;
-
- SCM protected_scms_;
-public:
- Paper_def *paper_l_;
-
- /// the columns, ordered left to right
- Link_array<Paper_column> col_l_arr_;
-
- Paper_outputter *outputter_l_;
- Line_of_score * line_l_;
-
- Paper_score ();
-
-
- /// add to bottom of pcols
- void add_column (Paper_column*);
-
- /**
- @return index of argument.
- */
- int find_col_idx (Paper_column const *) const;
-
- Link_array<Item> broken_col_range (Item const*,Item const*) const;
-
-
- /* STANDARD ROUTINES */
- void print() const;
-
- void typeset_element (Score_element*);
- void typeset_broken_spanner (Spanner*);
- /// add a Spanner
- void typeset_unbroken_spanner (Spanner*);
-
-
- virtual ~Paper_score();
-protected:
- /* MAIN ROUTINES */
- virtual void process();
-
-private:
- /// before calc_breaking
- void preprocess();
-
- void calc_idealspacing();
- /// calculate where the lines are to be broken, and use results
- Array<Column_x_positions> calc_breaking();
-
- /// after calc_breaking
- void postprocess();
- Paper_score (Paper_score const &);
-};
-
-#endif
+++ /dev/null
-/*
- plet-engraver.hh -- declare Plet_engraver
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1997--1999 Jan Nieuwenhuizen <janneke@gnu.org>
-*/
-
-#ifndef PLET_ENGRAVER_HH
-#define PLET_ENGRAVER_HH
-
-#include "engraver.hh"
-#include "drul-array.hh"
-#include "plet-spanner.hh"
-
-/**
- Generate a plet.
- Should make a Plet_spanner that typesets a nice bracket.
- */
-class Plet_engraver : public Engraver
-{
-public:
- VIRTUAL_COPY_CONS(Translator);
-
- Plet_engraver ();
-
-protected:
- virtual void acknowledge_element (Score_element_info);
- virtual void do_removal_processing();
- virtual void do_process_requests();
- virtual bool do_try_music (Music*);
- virtual void do_pre_move_processing();
-
-private:
- Drul_array<Plet_req*> span_reqs_drul_;
- Drul_array<Moment> beam_mom_drul_;
- Drul_array<Moment> span_mom_drul_;
- Plet_spanner* plet_spanner_p_;
-};
-
-#endif // PLET_ENGRAVER_HH
+++ /dev/null
-/*
- request-iter.hh -- declare Request_chord_iterator
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-
-#ifndef REQUEST_ITER_HH
-#define REQUEST_ITER_HH
-
-#include "music-iterator.hh"
-
-/**
- Walk through a Request_chord
- */
-class Request_chord_iterator : public Music_iterator {
- Request_chord * elt_l () const;
- /**
- cache elt_l ()->length_mom ().
- */
- Moment elt_length_mom_;
- bool last_b_;
- Cons<Music>* cursor_;
-
-public:
- Request_chord_iterator ();
-
-
-protected:
- virtual void do_process_and_next (Moment);
- virtual Moment next_moment() const;
- virtual Music* next_music_l ();
- virtual void construct_children();
- virtual bool ok() const;
- virtual void do_print() const;
-};
-
-
-#endif // REQUEST_ITER_HH
+++ /dev/null
-/*
- p-score.cc -- implement Paper_score
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1996, 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-#include "main.hh"
-#include "debug.hh"
-#include "lookup.hh"
-#include "spanner.hh"
-#include "paper-def.hh"
-#include "line-of-score.hh"
-#include "p-col.hh"
-#include "p-score.hh"
-#include "p-col.hh"
-#include "scope.hh"
-#include "word-wrap.hh"
-#include "gourlay-breaking.hh"
-#include "paper-stream.hh"
-#include "paper-outputter.hh"
-#include "file-results.hh"
-#include "misc.hh"
-
-Paper_score::Paper_score ()
-{
- protected_scms_ = scm_protect_object (gh_cons (SCM_BOOL_T, SCM_EOL));
- paper_l_ =0;
- outputter_l_ =0;
- Line_of_score * line_p = new Line_of_score;
- typeset_unbroken_spanner (line_p);
-
- line_l_ = line_p;
-}
-
-Paper_score::Paper_score (Paper_score const &s)
- : Music_output (s)
-{
- assert (false);
-}
-
-Paper_score::~Paper_score ()
-{
- for (int i=span_p_arr_.size (); --i >=0 ; )
- delete span_p_arr_[i];
- for (int i=elem_p_arr_.size (); --i >=0 ; )
- delete elem_p_arr_[i];
-
- scm_unprotect_object (protected_scms_);
-}
-
-void
-Paper_score::typeset_element (Score_element * elem_p)
-{
- elem_p_arr_.push (elem_p);
- elem_p->pscore_l_ = this;
-
- // take over protection.
- SCM_CDR(protected_scms_) = gh_cons (elem_p->element_property_alist_,
- SCM_CDR (protected_scms_));
- scm_unprotect_object (elem_p->element_property_alist_);
-
- SCM p = elem_p->remove_elt_property (break_helper_only_scm_sym);
- if (p != SCM_BOOL_F)
- break_helpers_arr_.push (elem_p);
-}
-
-
-void
-Paper_score::typeset_unbroken_spanner (Spanner*span_p)
-{
- span_p_arr_.push (span_p);
- span_p->pscore_l_=this;
-
- SCM p = span_p->remove_elt_property (break_helper_only_scm_sym);
- if (p != SCM_BOOL_F)
- break_helpers_arr_.push (span_p);
-}
-
-void
-Paper_score::add_column (Paper_column *p)
-{
- p->set_rank (col_l_arr_.size ());
- col_l_arr_.push (p);
- typeset_element(p);
-}
-
-
-
-void
-Paper_score::print () const
-{
-#ifndef NPRINT
- if (!check_debug)
- return ;
- DOUT << "Paper_score { ";
- DOUT << "\n elements: ";
- for (int i=0; i < span_p_arr_.size (); i++)
- span_p_arr_[i]->print ();
- for (int i=0; i < elem_p_arr_.size (); i++)
- elem_p_arr_[i]->print();
-
- DOUT << "}\n";
-#endif
-}
-
-int
-Paper_score::find_col_idx (Paper_column const *c) const
-{
- Paper_column const *what = c;
-
- return col_l_arr_.find_i ((Paper_column*)what);
-}
-
-Array<Column_x_positions>
-Paper_score::calc_breaking ()
-{
- Break_algorithm *algorithm_p=0;
- Array<Column_x_positions> sol;
- bool try_wrap = !paper_l_->get_var ("castingalgorithm");
-
- if (!try_wrap)
- {
- algorithm_p = new Gourlay_breaking ;
- algorithm_p->set_pscore (this);
- sol = algorithm_p->solve ();
- delete algorithm_p;
- if (! sol.size ())
- {
- warning (_ ("Can't solve this casting problem exactly; revert to Word_wrap"));
- try_wrap = true;
- }
- }
- if (try_wrap)
- {
- algorithm_p = new Word_wrap;
- algorithm_p->set_pscore (this);
- sol = algorithm_p->solve ();
- delete algorithm_p;
- }
- return sol;
-}
-
-
-
-void
-Paper_score::process ()
-{
- Dictionary<int> type_stats;
- type_stats["Item"] =0;
- type_stats["Spanner"] =0;
- type_stats["Total"]=0;
-
- print ();
- *mlog << _ ("Preprocessing elements...") << " " << flush;
- line_l_->breakable_col_processing ();
- line_l_->pre_processing ();
-
- *mlog << '\n' << _ ("Calculating column positions...") << " " << flush;
- line_l_->space_processing ();
-
- Array<Column_x_positions> breaking = calc_breaking ();
-
-
- Paper_stream* paper_stream_p = paper_l_->paper_stream_p ();
- outputter_l_ = paper_l_->paper_outputter_p (paper_stream_p, header_l_, origin_str_);
-
- Link_array<Line_of_score> lines;
- for (int i=0; i < breaking.size (); i++)
- {
- Line_of_score *line_l = line_l_->set_breaking (breaking, i);
- lines.push (line_l);
- if (line_l != line_l_)
- typeset_element (line_l);
- }
-
- if (experimental_features_global_b)
- *mlog << elem_p_arr_.size () + span_p_arr_.size () << _ (" elements. ");
-
- *mlog << "\n";
- *mlog << _ ("Line ... ");
- line_l_->break_processing ();
- for (int i=0; i < lines.size (); i++)
- {
- *mlog << '[' << flush;
-
- Line_of_score *line_l = lines[i];
-
- line_l->post_processing ();
- *mlog << i << flush;
- line_l->output_all (i + 1 == lines.size());
- if (experimental_features_global_b)
- *mlog << '(' << elem_p_arr_.size () + span_p_arr_.size () << ')';
-
- *mlog << ']' << flush;
- }
-
- // huh?
- delete outputter_l_;
- delete paper_stream_p;
- outputter_l_ = 0;
-
-
- /*
- todo: sort output
- */
- if (experimental_features_global_b)
- {
- for (Dictionary_iter<int> i(type_stats); i.ok(); i++)
- {
- *mlog << i.key () << ": " << i.val () << " objects\n";
- }
- }
- *mlog << '\n' << flush;
-
-}
-
-Link_array<Item>
-Paper_score::broken_col_range (Item const*l, Item const*r) const
-{
- Link_array<Item> ret;
-
- l = l->column_l ();
- r = r->column_l ();
-
- int start = l
- ? find_col_idx (dynamic_cast<Paper_column*> ((Item*)l))+1
- : 0;
-
- int stop = r
- ? find_col_idx (dynamic_cast<Paper_column*>((Item*)r))
- : col_l_arr_.size ();
-
- while (start < stop)
- {
- Paper_column *c = col_l_arr_[start];
- if (c->breakable_b () && !c->line_l_)
- ret.push (c);
- start++;
- }
-
- return ret;
-}
+++ /dev/null
-/*
- request-iterator.cc -- implement Request_chord_iterator
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-#include "translator-group.hh"
-#include "debug.hh"
-#include "request-iterator.hh"
-#include "music-list.hh"
-#include "request.hh"
-
-
-
-void
-Request_chord_iterator::construct_children()
-{
- elt_length_mom_ =elt_l ()->length_mom ();
- get_req_translator_l();
-}
-
-Request_chord*
-Request_chord_iterator::elt_l () const
-{
- return (Request_chord*) music_l_;
-}
-
-Request_chord_iterator::Request_chord_iterator ()
-{
- last_b_ = false;
- // cursor_ = elt_l ()->music_p_list_p_->head_;
- cursor_ = 0;
-}
-
-
-bool
-Request_chord_iterator::ok() const
-{
- return (elt_length_mom_ && !last_b_) || first_b_;
-}
-
-Moment
-Request_chord_iterator::next_moment() const
-{
- Moment m (0);
- if (!first_b_)
- m = elt_length_mom_;
- return m;
-}
-
-Music*
-Request_chord_iterator::next_music_l ()
-{
- if (first_b_)
- {
- cursor_ = elt_l ()->music_p_list_p_->head_;
- first_b_ = false;
- }
- else
- {
- if (cursor_)
- cursor_ = cursor_->next_;
- }
- if (cursor_)
- return cursor_->car_;
- else
- return 0;
-}
-
-void
-Request_chord_iterator::do_print() const
-{
-#ifndef NPRINT
- DOUT << "duration: " << elt_length_mom_;
-#endif
-}
-
-void
-Request_chord_iterator::do_process_and_next (Moment mom)
-{
- if (first_b_)
- {
- for (Cons<Music> *i = elt_l ()->music_p_list_p_->head_; i; i = i->next_)
- {
- if (Request * req_l = dynamic_cast<Request*> (i->car_))
- {
- bool gotcha = report_to_l()->try_music (req_l);
- if (!gotcha)
- req_l->warning (_f ("junking request: `%s\'", classname( req_l)));
- }
- else
- i->car_->warning (_f ("Huh? Not a Request: `%s\'",
- classname (i->car_)));
- }
- first_b_ = false;
- }
-
- if (mom >= elt_length_mom_)
- last_b_ = true;
-}