#define STAFFELEM_HH
#include "parray.hh"
-#include "lily-proto.hh"
-#include "offset.hh"
#include "virtual-methods.hh"
#include "directed-graph.hh"
+#include "graphical-element.hh"
#define SCORE_ELEM_CLONE(T) VIRTUAL_COPY_CONS(T, Score_elem)
+typedef void (Score_elem::*Score_elem_method_pointer)(void);
/** Both Spanner and Item are Score_elem's. Most Score_elem's depend
on other Score_elem's, eg, Beam needs to know and set direction of
form an acyclic graph.
(elem) */
-class Score_elem : private Directed_graph_node {
-
- /// member: the symbols
- Molecule *output; // should scrap, and use temp var?
-
-
-
- /**
- for administration of what was done already
- */
- enum Status {
- ORPHAN, // not yet added to pstaff
- VIRGIN, // added to pstaff
- PREBREAKING,
- PREBROKEN,
- PRECALCING,
- PRECALCED, // calcs before spacing done
- BREAKING,
- BROKEN,
- POSTCALCING, // busy calculating. This is used to trap cyclic deps.
- POSTCALCED, // after spacing calcs done
- BREWED,
- TEXOUTPUT, // molecule has been output
- DELETED, // to catch malloc mistakes.
- };
-
- Status status_;
-
- Score_elem* dependency (int) const;
- Score_elem* dependent (int) const;
- int dependent_size() const;
- int dependency_size() const;
+class Score_elem : private Directed_graph_node, public Graphical_element {
public:
- /**
- This is needed, because #output# may still be
- NULL.
- */
- Offset offset_;
-
-
-
-
Paper_score *pscore_l_;
- Axis_group_element * axis_group_l_a_[NO_AXES];
+ Score_elem();
Score_elem (Score_elem const&);
- virtual String TeX_output_str () const ;
- virtual void print() const;
+ virtual void print() const;
Paper_def *paper() const;
virtual ~Score_elem();
- Score_elem();
DECLARE_MY_RUNTIME_TYPEINFO;
-
- Interval extent (Axis) const;
- Interval width() const;
- Interval height() const;
- Status status() const;
-
- /**
- translate the symbol. The symbol does not have to be created yet.
- */
- void translate (Offset);
- /**
- translate in one direction
- */
-
- void translate (Real, Axis);
- Real relative_coordinate (Axis_group_element*, Axis) const;
- Offset absolute_offset() const;
- Real absolute_coordinate (Axis) const;
- Axis_group_element*common_group (Score_elem const* s, Axis a) const;
void add_processing();
- void OK() const;
- void pre_processing();
- void breakable_col_processing();
- void break_processing();
-
- void post_processing();
- void molecule_processing();
/**
Remove all links (dependencies, dependents, Axis_group_elements.
*/
void unlink();
- void unlink_all();
void substitute_dependency (Score_elem*,Score_elem*);
void remove_dependency (Score_elem*);
/**
virtual bool linked_b() const;
SCORE_ELEM_CLONE(Score_elem);
- /// no dimension, translation is noop
- bool empty_b_;
/// do not print anything black
bool transparent_b_;
+
+ // ugh: no protection. Denk na, Vrij Veilig
+ void calcalute_dependencies (int final, int busy, Score_elem_method_pointer funcptr);
+
protected:
+ /**
+ Administration: Where are we?. This is mainly used by Super_elem and
+ Score_elem::calcalute_dependencies ()
+
+ 0 means ORPHAN,
+ -1 means deleted
+
+ */
+ int status_i_;
+ Score_elem* dependency (int) const;
+ Score_elem* dependent (int) const;
+ int dependent_size() const;
+ int dependency_size() const;
+
+ virtual void do_brew_molecule ();
+ void junk_links();
virtual Interval do_height() const;
virtual Interval do_width() const;
virtual void do_breakable_col_processing();
/// do calculations after determining horizontal spacing
virtual void do_post_processing();
- virtual String do_TeX_output_str () const;
virtual void do_substitute_dependency (Score_elem * , Score_elem *);
virtual void do_substitute_dependent (Score_elem *, Score_elem *);
virtual Link_array<Score_elem> get_extra_dependencies() const;
virtual void do_unlink();
virtual void do_junk_links();
- String make_TeX_string (Offset) const;
};
#include "header.hh"
#include "word-wrap.hh"
#include "gourlay-breaking.hh"
+#include "outputter.hh"
Paper_score::Paper_score ()
{
+ outputter_l_ =0;
super_elem_l_ = new Super_elem;
typeset_element (super_elem_l_);
}
span_p_list_.bottom ().add (span_p);
span_p->pscore_l_=this;
-
// do not init start/stop fields. These are for broken spans only.
span_p->add_processing ();
}
-void
-Paper_score::OK () const
-{
-#ifndef NDEBUG
- for (PCursor<Score_elem*> i (elem_p_list_.top ()); i.ok (); i++)
- i->OK ();
-#endif
-}
-
void
Paper_score::print () const
{
#endif
}
-void
-Paper_score::preprocess ()
-{
- super_elem_l_->breakable_col_processing ();
- super_elem_l_->pre_processing ();
-}
-
-void
-Paper_score::postprocess ()
-{
- super_elem_l_->post_processing ();
- super_elem_l_->molecule_processing ();
-}
-
PCursor<Paper_column *>
Paper_score::find_col (Paper_column const *c) const
{
clean_cols ();
print ();
*mlog << "Preprocessing elements... " <<flush;
- preprocess ();
+ super_elem_l_->breakable_col_processing ();
+ super_elem_l_->pre_processing ();
*mlog << "\nCalculating column positions ... " <<flush;
calc_breaking ();
*mlog << "\nPostprocessing elements..." << endl;
- postprocess ();
+ super_elem_l_->post_processing ();
+ tex_output ();
+}
+
+void
+Paper_score::tex_output ()
+{
// output
String outname = paper_l_->outfile_str_ ;
if (!outname)
*mlog << "TeX output to " << outname << " ...\n";
- Tex_stream the_output (outname);
+ Tex_stream tex_out (outname);
+ Tex_outputter interfees (&tex_out);
+
+ outputter_l_ = &interfees;
- the_output << "% outputting Score, defined at: " << origin_str_ << "\n";
+ tex_out << "% outputting Score, defined at: " << origin_str_ << "\n";
if (header_l_)
{
- the_output << header_l_->TeX_string();
+ tex_out << header_l_->TeX_string();
}
- the_output << "\n "<< paper_l_->lookup_l ()->texsetting << "%(Tex id)\n";
- the_output<< super_elem_l_->TeX_output_str ();
- the_output << "\n\\EndLilyPondOutput";
+ tex_out << "\n "<< paper_l_->lookup_l ()->texsetting << "%(Tex id)\n";
+ super_elem_l_->output_all ();
+ tex_out << "\n\\EndLilyPondOutput";
+ outputter_l_ = 0;
}
/** Get all breakable columns between l and r, (not counting l and r). */