Midi_item*
Audio_instrument::midi_item_p()
{
- return str_.length_i() ? new Midi_instrument( 0, str_ ) : 0;
+ return str_.length_i() ? new Midi_instrument(0, str_) : 0;
}
Audio_item::Audio_item (Request* req_l)
Midi_item*
Audio_text::midi_item_p()
{
- return text_str_.length_i() ? new Midi_text( this ) : 0;
+ return text_str_.length_i() ? new Midi_text(this) : 0;
}
{
Midi_track midi_track;
midi_track.number_i_ = track_i;
- for ( Midi_walker i (this, &midi_track); i.ok(); i++ )
+ for (Midi_walker i (this, &midi_track); i.ok(); i++)
i.process();
midi_stream_r << midi_track;
}
Link_array<Score_elem> elems = axis_admin_.elem_l_arr_;
for (int i=0; i < elems.size(); i++)
{
- Item * it_l = elems[i]->item();
- assert (it_l);
-
- // somebody probably broke it in pieces
- assert (it_l->pcol_l_ == pcol_l_);
+ Item * it_l = elems[i]->item();
+ assert (it_l);
}
}
void
Axis_group_item::do_breakable_col_processing()
{
- if (!pcol_l_->breakable_b())
- return;
+ if (!breakable_b_)
+ return;
+
OK();
copy_breakable_items();
Link_array<Score_elem> elems = axis_admin_.elem_l_arr_;
for (int i=0; i < elems.size(); i++)
{
- Item* it_l = elems[i]->item();
- for ( int j=0; j < 2; j++)
- {
- Item *new_l = it_l->find_prebroken_piece (broken_to_a_[j]->pcol_l_);
- ((Axis_group_item*)broken_to_a_[j])->add_element (new_l);
- }
+ Item* it_l = elems[i]->item();
+ Direction j=LEFT;
+ do
+ {
+ Item *new_l =
+ it_l->find_prebroken_piece (broken_to_drul_[j]->break_status_i_);
+ ((Axis_group_item*)broken_to_drul_[j])->add_element (new_l);
+ }
+ while ((j*=-1)!=LEFT);
}
Item::do_breakable_col_processing();
}
Line_of_score *my_line = line_l();
for (int i=0; i < elems.size(); i++)
{
- if (!elems[i]->line_l())
- {
- Item * item_l = elems[i]->item();
- if (item_l
- && item_l->breakable_b_
- && item_l->break_status_i() == 0)
- {
- // last two checks are paranoia
- Item * broken_item_l =
- item_l->find_prebroken_piece (my_line);
- add_element (broken_item_l);
- }
- remove_element (elems[i]);
- }
+ if (!elems[i]->line_l())
+ {
+ Item * item_l = elems[i]->item();
+ if (item_l
+ && item_l->breakable_b_
+ && item_l->break_status_i() == 0)
+ {
+ // last two checks are paranoia
+ Item * broken_item_l =
+ item_l->find_prebroken_piece (my_line);
+ add_element (broken_item_l);
+ }
+ remove_element (elems[i]);
+ }
}
-
}
void
Axis_group_spanner::do_break_processing()
{
- set_my_columns();
bool breaking_self_b = ! Spanner::line_l();
if (!breaking_self_b)
{
- do_break_processing_if_unbroken();
- Spanner::do_break_processing();
- return;
+ do_break_processing_if_unbroken();
+ Spanner::do_break_processing();
+ return;
}
- break_into_pieces (true);
+ break_into_pieces ();
Link_array<Score_elem> loose_elems = axis_admin_.elem_l_arr_;
remove_all();
for (int i=0; i < loose_elems.size(); i++)
{
- Score_elem * elt = loose_elems[i];
- Line_of_score *elt_line = elt->line_l();
+ Score_elem * elt = loose_elems[i];
+ Line_of_score *elt_line = elt->line_l();
- if ( ! elt_line)
- {
- /* this piece doesn't know where it belongs.
- Find out if it was broken, and use the broken remains
- */
- if (elt->spanner())
- {
- Spanner * sp = elt->spanner();
+ if (! elt_line)
+ {
+ /* this piece doesn't know where it belongs.
+ Find out if it was broken, and use the broken remains
+ */
+ if (elt->spanner())
+ {
+ Spanner * sp = elt->spanner();
- for (int j =0; j < broken_into_l_arr_.size(); j++)
- {
- Axis_group_spanner * my_broken_l
- = (Axis_group_spanner*)broken_into_l_arr_[j];
+ for (int j =0; j < broken_into_l_arr_.size(); j++)
+ {
+ Axis_group_spanner * my_broken_l
+ = (Axis_group_spanner*)broken_into_l_arr_[j];
- Spanner * broken_span_l
- = sp->find_broken_piece (
- ((Score_elem*)my_broken_l)->line_l());
+ Spanner * broken_span_l
+ = sp->find_broken_piece (
+ ((Score_elem*)my_broken_l)->line_l());
- if (broken_span_l)
- my_broken_l->add_element (broken_span_l);
-
- }
- }
- else if (elt->item()
- && elt->item()->breakable_b_
- && elt->item()->break_status_i () == 0)
- {
-
- // broken items
- for (int j =0; j < 2; j++)
- {
- Item * my_item = elt->item()->broken_to_a_[j];
- Line_of_score * item_line_l = my_item->line_l() ;
- if ( ! item_line_l)
- continue;
+ if (broken_span_l)
+ my_broken_l->add_element (broken_span_l);
- Axis_group_spanner * v
- = (Axis_group_spanner*)find_broken_piece (item_line_l);
- if (v)
- v->add_element (my_item);
- }
+ }
+ }
+ else if (elt->item()
+ && elt->item()->breakable_b_
+ && elt->item()->break_status_i () == 0)
+ {
+ // broken items
+ Direction j=LEFT;
+ do
+ {
+ Item * my_item = elt->item()->broken_to_drul_[j];
+ Line_of_score * item_line_l = my_item->line_l() ;
+ if (! item_line_l)
+ continue;
- }
- }
- else
- {
+ Axis_group_spanner * v
+ = (Axis_group_spanner*)find_broken_piece (item_line_l);
+ if (v)
+ v->add_element (my_item);
+ }
+ while ((j*=-1) != LEFT);
+ }
+ }
+ else
+ {
/* this piece *does* know where it belongs.
Put it in appropriate piece of this spanner
*/
- Axis_group_spanner * my_broken_l
- = (Axis_group_spanner*)find_broken_piece (elt->line_l());
- my_broken_l->add_element (elt);
- }
+ Axis_group_spanner * my_broken_l
+ = (Axis_group_spanner*)find_broken_piece (elt->line_l());
+ my_broken_l->add_element (elt);
+ }
}
Spanner::do_break_processing();
bar_l_ = (Bar*)info.elem_l_->item();
}
- if ( bar_l_ && !barcol_p_)
+ if (bar_l_ && !barcol_p_)
{
barcol_p_ = new Bar_column;
barcol_p_->breakable_b_ =true;
Bar_column::do_substitute_dependency (Score_elem*o,Score_elem*n)
{
Script_column::do_substitute_dependency (o,n);
- if ( o == bar_l_)
+ if (o == bar_l_)
{
bar_l_ = n ? (Bar*)n->item() : 0;
}
IMPLEMENT_IS_TYPE_B1(Bar,Item);
void
-Bar::do_print()const
+Bar::do_print() const
{
DOUT << type_str_;
}
Molecule*
-Bar::brew_molecule_p()const
+Bar::brew_molecule_p() const
{
Paper_def *p = paper();
Symbol s = p->lookup_l()->bar (type_str_,
String s (count_i_);
s += " lines";
if (count_i_)
- s += String (Real (cols_i_)/count_i_, ", (with an average of %.1f columns)");
+ s += String (Real (cols_i_)/count_i_, ", (with an average of %.1f columns)");
return s;
}
/* **************************************************************** */
Line_of_cols
-Break_algorithm::all_cols()const
+Break_algorithm::all_cols() const
{
Line_of_cols retval;
- for (PCursor<PCol*> c (pscore_l_->col_p_list_.top());
- c.ok(); c++)
- {
+ for (PCursor<Paper_column*> c (pscore_l_->col_p_list_.top());
+ c.ok(); c++)
+ {
- retval.push (c);
+ retval.push (c);
}
return retval;
}
Array<int> retval;
for (int i=0; i < all.size(); i++)
- if (all[i]->breakable_b())
- retval.push (i);
+ if (all[i]->breakable_b_)
+ retval.push (i);
- if ( linelength <=0)
- while ( retval.size() >2)
- retval.del (1);
+ if (linelength <=0)
+ while (retval.size() >2)
+ retval.del (1);
return retval;
}
Line_of_cols retval;
for (int i=0; i < all.size(); i++)
- if (all[i]->breakable_b())
- retval.push (all[i]);
+ if (all[i]->breakable_b_)
+ retval.push (all[i]);
- if ( linelength <=0)
- while ( retval.size() >2)
- retval.del (1);
+ if (linelength <=0)
+ while (retval.size() >2)
+ retval.del (1);
return retval;
}
Line_spacer*
-Break_algorithm::generate_spacing_problem (Line_of_cols curline)const
+Break_algorithm::generate_spacing_problem (Line_of_cols curline) const
{
Line_spacer * sp= (*get_line_spacer)();
sp->paper_l_ = pscore_l_->paper_l_;
sp->add_column (curline[0], true, 0.0);
for (int i=1; i< curline.size()-1; i++)
- sp->add_column (curline[i]);
+ sp->add_column (curline[i]);
- if ( linelength > 0)
- sp->add_column (curline.top(), true, linelength);
+ if (linelength > 0)
+ sp->add_column (curline.top(), true, linelength);
else
- sp->add_column (curline.top());
+ sp->add_column (curline.top());
sp->prepare();
return sp;
Break_algorithm::feasible (Line_of_cols curline) const
{
if (linelength <= 0)
- return true;
+ return true;
Real l =0;
for (int i=0; i < curline.size(); i++)
- l +=curline[i]->width().length ();
+ l +=curline[i]->width().length ();
return l < linelength;
}
Break_algorithm::problem_OK() const
{
if (!pscore_l_->col_p_list_.size())
- error ("Score does not have any columns");
+ error ("Score does not have any columns");
OK();
}
void
-Break_algorithm::OK()const
+Break_algorithm::OK() const
{
#ifndef NDEBUG
iter_top (pscore_l_->col_p_list_,start);
- PCursor<PCol *> end (pscore_l_->col_p_list_.bottom());
+ PCursor<Paper_column *> end (pscore_l_->col_p_list_.bottom());
- assert (start->breakable_b());
- assert (end->breakable_b());
+ assert (start->breakable_b_);
+ assert (end->breakable_b_);
#endif
}
Array<Col_hpositions>
-Break_algorithm::solve()const
+Break_algorithm::solve() const
{
return do_solve();
}
}
void
-Break_algorithm::print_stats()const
+Break_algorithm::print_stats() const
{
if (approx_stats_.count_i_)
- *mlog << "\nApproximated: " << approx_stats_.str() << "\n";
+ *mlog << "\nApproximated: " << approx_stats_.str() << "\n";
if (exact_stats_.count_i_)
- *mlog << "Calculated exactly: " << exact_stats_.str() << "\n";
+ *mlog << "Calculated exactly: " << exact_stats_.str() << "\n";
}
--- /dev/null
+/*
+ chord-iter.cc -- implement Chord_iterator
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "translator.hh"
+#include "debug.hh"
+#include "chord-iterator.hh"
+
+#include "music-list.hh"
+
+
+Chord_iterator::~Chord_iterator()
+{
+}
+
+Chord_iterator::Chord_iterator (Chord const *chord_C)
+{
+ chord_C_ = chord_C;
+}
+
+void
+Chord_iterator::construct_children()
+{
+ int j = 0;
+ for (PCursor<Music*> i (chord_C_->music_p_list_.top()); //, int j = 0;
+ i.ok(); j++, i++)
+ {
+ Music_iterator * mi = get_iterator_p (i.ptr());
+ if (mi->ok())
+ {
+ set_translator (mi->report_to_l()->ancestor_l (chord_C_->multi_level_i_));
+ children_p_list_.bottom().add (mi);
+ }
+ else
+ delete mi;
+ }
+}
+void
+Chord_iterator::do_print() const
+{
+#ifndef NPRINT
+ for (PCursor<Music_iterator*> i (children_p_list_.top()); i.ok (); i++)
+ {
+ i->print();
+ }
+#endif
+}
+
+void
+Chord_iterator::process_and_next (Moment until)
+{
+ for (PCursor<Music_iterator*> i (children_p_list_.top()); i.ok ();)
+ {
+ if (i->next_moment() == until)
+ {
+ i->process_and_next (until);
+ }
+ if (!i->ok())
+ delete i.remove_p();
+ else
+ i++;
+ }
+ Music_iterator::process_and_next (until);
+}
+
+
+IMPLEMENT_IS_TYPE_B1(Chord_iterator,Music_iterator);
+
+Moment
+Chord_iterator::next_moment() const
+{
+ Moment next_ = infinity_mom;
+ for (PCursor<Music_iterator*> i (children_p_list_.top()); i.ok (); i++)
+ next_ = next_ <? i->next_moment() ;
+ return next_;
+}
+
+
+
+bool
+Chord_iterator::ok() const
+{
+ return children_p_list_.size();
+}
if (info.elem_l_->name() == Bar::static_name ())
{
create_clef();
- if ( !clef_req_l_)
+ if (!clef_req_l_)
clef_p_->default_b_ = true;
}
}
#ifndef NPRINT
DOUT << "column { ";
if (fixed())
- DOUT << "fixed at " << fixed_position()<<", ";
+ DOUT << "fixed at " << fixed_position()<<", ";
assert (pcol_l_);
DOUT << "[" << minleft() << ", " << minright () << "]";
DOUT <<"}\n";
#endif
}
-Colinfo::Colinfo (PCol *col_l, Real const *fixed_C)
+Colinfo::Colinfo (Paper_column *col_l, Real const *fixed_C)
{
if (fixed_C)
- fixpos_p_.set_l (fixed_C);
+ fixpos_p_.set_l (fixed_C);
ugh_b_ = false;
pcol_l_ = col_l;
width = pcol_l_->width();
+ if (width.empty_b())
+ width = Interval(0,0);
}
}
void
-Col_hpositions::add (PCol*c)
+Col_hpositions::add (Paper_column*c)
{
cols.push (c);
}
}
void
-Col_hpositions::OK()const
+Col_hpositions::OK() const
{
#ifndef NDEBUG
assert (config.size() == cols.size ());
#include "p-col.hh"
void
-Horizontal_vertical_group_item::do_print()const
+Horizontal_vertical_group_item::do_print() const
{
Horizontal_vertical_group_element::do_print();
}
remove_all();
}
+void
+Axis_group_element::do_junk_links()
+{
+ axis_admin_.elem_l_arr_.set_size (0);
+}
+
bool
-Axis_group_element::contains_b (Score_elem const*e)const
+Axis_group_element::contains_b (Score_elem const*e) const
{
return axis_admin_.contains_b (e);
}
Link_array<Score_elem>
-Axis_group_element::get_extra_dependencies()const
+Axis_group_element::get_extra_dependencies() const
{
return axis_admin_.elem_l_arr_;
}
void
-Axis_group_element::do_print()const
+Axis_group_element::do_print() const
{
axis_admin_.print();
}
+
+Axis_group_element::Axis_group_element()
+{
+ transparent_b_ = true;
+}
+
// ****************
{
axis_admin_.remove_all (Y_AXIS,Y_AXIS);
}
+
// ****************
void
Interval
-Horizontal_group_element::do_width()const
+Horizontal_group_element::do_width() const
{
return axis_admin_.extent (X_AXIS);
}
*/
Array<Col_hpositions>
-Gourlay_breaking::do_solve()const
+Gourlay_breaking::do_solve() const
{
Array<Break_node> optimal_paths;
Line_of_cols line = all.slice (breaks[start_idx], breaks[break_idx]+1);
- line[0] = line[0]->postbreak_p_;
- line.top() = line.top ()->prebreak_p_;
+ line[0] = line[0]->postbreak_l();
+ line.top() = line.top ()->prebreak_l();
if (!feasible (line))
break;
for (int j=0; j < candidates.size(); j++)
{
int start = candidates[j];
- if ( optimal_paths[start].line_config_.energy_f_
+ if (optimal_paths[start].line_config_.energy_f_
+ candidate_lines[j].energy_f_ > minimal_energy)
continue;
- if ( !candidate_lines[j].satisfies_constraints_b_)
+ if (!candidate_lines[j].satisfies_constraints_b_)
{
candidate_lines[j].solve_line();
- ((Break_algorithm*)this)->exact_stats_.add ( candidate_lines[j].cols);
+ ((Break_algorithm*)this)->exact_stats_.add (candidate_lines[j].cols);
}
Real this_energy
= optimal_paths[start].line_config_.energy_f_
+ candidate_lines[j].energy_f_ ;
- if ( this_energy < minimal_energy)
+ if (this_energy < minimal_energy)
{
minimal_j = j;
minimal_energy = this_energy;
optimal_paths[break_idx].line_config_ = candidate_lines[minimal_j];
}
- if ( !(break_idx % HAPPY_DOTS_I))
+ if (!(break_idx % HAPPY_DOTS_I))
*mlog << "[" << break_idx << "]"<<flush;
}
- if ( break_idx % HAPPY_DOTS_I)
+ if (break_idx % HAPPY_DOTS_I)
*mlog << "[" << break_idx << "]"<<flush;
Array<int> final_breaks;
Array<Col_hpositions> lines;
- Real min_energy_f_ = infinity_f;
- Real max_energy_f_ = 0;
+
+ Real max_energy_f = 0;
/* skip 0-th element, since it is a "dummy" elt*/
for (int i = optimal_paths.size()-1; i> 0;)
{
- final_breaks.push ( i);
- assert ( i > optimal_paths[i].prev_break_i_);
+ final_breaks.push (i);
+ assert (i > optimal_paths[i].prev_break_i_);
// there was no "feasible path"
if (!optimal_paths[i].line_config_.config.size()) {
/*
TODO print variation in energy
*/
- if (max_energy_f_ )
+ if (max_energy_f)
{
;
}
for (int i= final_breaks.size(); i--;)
- lines.push ( optimal_paths[final_breaks[i]].line_config_);
+ lines.push (optimal_paths[final_breaks[i]].line_config_);
return lines;
}
void
-Rhythmic_grouping::OK()const
+Rhythmic_grouping::OK() const
{
#ifndef NDEBUG
assert (bool (children.size()) != bool (interval_));
}
MInterval
-Rhythmic_grouping::interval()const
+Rhythmic_grouping::interval() const
{
if (interval_)
return *interval_;
Array<Rhythmic_grouping*> ch;
while (1)
{
- if ( i >= children.size() || j >= splitpoints.size ())
+ if (i >= children.size() || j >= splitpoints.size ())
break;
assert (
}
void
-Rhythmic_grouping::print()const
+Rhythmic_grouping::print() const
{
#ifndef NPRINT
DOUT << "{ \n";
Rhythmic_grouping::child_fit_b (Moment start)
{
if (children.size())
- return ( children.top()->interval ().right== start);
+ return (children.top()->interval ().right== start);
return true;
}
}
void
-Rhythmic_grouping::extend (MInterval m)const
+Rhythmic_grouping::extend (MInterval m) const
{
assert (m.left >= interval().left);
while (m.right >interval().right)
IMPLEMENT_IS_TYPE_B1(Horizontal_align_item,Item);
-void
-Horizontal_align_item::OK() const
-{
- for (int i =0; i < item_l_arr_.size(); i++)
- assert ( pcol_l_ == item_l_arr_[i]->pcol_l_);
-}
+
bool
-Horizontal_align_item::contains_b (Item *i)const
+Horizontal_align_item::contains_b (Item *i) const
{
return item_l_arr_.find_l (i);
}
int i;
while ((i = item_l_arr_.find_i (o->item())) >=0)
{
- if (n)
- item_l_arr_[i] = n->item();
- else
- item_l_arr_.del (i);
+ if (n)
+ item_l_arr_[i] = n->item();
+ else
+ item_l_arr_.del (i);
}
}
Item * item_l_;
int priority_i_;
static int compare (Horizontal_align_item_content const &h1,
- Horizontal_align_item_content const &h2)
- {
- return h1.priority_i_ - h2.priority_i_;
- }
+ Horizontal_align_item_content const &h2)
+ {
+ return h1.priority_i_ - h2.priority_i_;
+ }
Horizontal_align_item_content (Item*i, int p)
- {
- priority_i_ = p;
- item_l_ = i;
- }
+ {
+ priority_i_ = p;
+ item_l_ = i;
+ }
Horizontal_align_item_content(){item_l_ =0; priority_i_ =0; }
};
void
Horizontal_align_item::do_pre_processing()
{
- OK();
{
- Array<Horizontal_align_item_content> content;
- for (int i =0; i < item_l_arr_.size(); i++)
- content.push (
- Horizontal_align_item_content (
- item_l_arr_[i], priority_i_arr_[i]));
- content.sort (Horizontal_align_item_content::compare);
- item_l_arr_.clear();
- priority_i_arr_.clear();
- for (int i =0; i < content.size(); i++)
- {
- item_l_arr_.push (content[i].item_l_);
- priority_i_arr_.push (content[i].priority_i_);
- }
- }
+ Array<Horizontal_align_item_content> content;
+ for (int i =0; i < item_l_arr_.size(); i++)
+ content.push (
+ Horizontal_align_item_content (
+ item_l_arr_[i], priority_i_arr_[i]));
+ content.sort (Horizontal_align_item_content::compare);
+ item_l_arr_.clear();
+ priority_i_arr_.clear();
+ for (int i =0; i < content.size(); i++)
+ {
+ item_l_arr_.push (content[i].item_l_);
+ priority_i_arr_.push (content[i].priority_i_);
+ }
+ }
Array<Interval> dims;
Real total =0;
for (int i =0; i < item_l_arr_.size(); i++)
{
- Interval item_width= item_l_arr_[i]->width();
- if (item_width.empty_b())
- {
- item_width = Interval (0,0);
- }
- dims.push (item_width);
- total += item_width.length();
+ Interval item_width= item_l_arr_[i]->width();
+ if (item_width.empty_b())
+ {
+ item_width = Interval (0,0);
+ }
+ dims.push (item_width);
+ total += item_width.length();
}
Real where_f= total * (align_i_-1.0)/2.0;
Real center_dx_f = 0;
- for ( int i=0 ; i < item_l_arr_.size(); i++)
+ for (int i=0 ; i < item_l_arr_.size(); i++)
{
- Real dx = where_f -dims[i][-1];
- item_l_arr_[i]->translate (dx , X_AXIS);
- if (item_l_arr_[i] == center_l_)
- center_dx_f = where_f;
- where_f += dims[i].length();
+ Real dx = where_f -dims[i][-1];
+ item_l_arr_[i]->translate (dx , X_AXIS);
+ if (item_l_arr_[i] == center_l_)
+ center_dx_f = where_f;
+ where_f += dims[i].length();
}
if (center_dx_f && !align_i_)
- for ( int i=0 ; i < item_l_arr_.size(); i++)
- item_l_arr_[i]->translate (- center_dx_f , X_AXIS);
+ for (int i=0 ; i < item_l_arr_.size(); i++)
+ item_l_arr_[i]->translate (- center_dx_f , X_AXIS);
}
}
void
-Horizontal_align_item::do_print()const
+Horizontal_align_item::do_print() const
{
}
::error (e);
}
-Identifier::Identifier ( int code)
+Identifier::Identifier (int code)
{
token_code_i_ = code;
accessed_b_ = 0;
}
void
-Identifier::print()const
+Identifier::print() const
{
DOUT << "identifier ";
do_print();
void
-Duration_id::do_print()const
+Duration_id::do_print() const
{}
void
Vector
-Ineq_constrained_qp::solve (Vector start)const
+Ineq_constrained_qp::solve (Vector start) const
{
/* no hassle if no constraints*/
- if ( ! cons.size())
+ if (! cons.size())
{
Choleski_decomposition chol (quad);
return - chol.solve (lin);
Input_translator::print() const
{
#ifndef NPRINT
- if ( ! check_debug)
+ if (! check_debug)
return ;
DOUT << base_str_ <<" " << type_str_<<" {\n";
DOUT << "Consists of ";
Input_translator *
Input_translator::recursive_find (String nm)
{
- if ( is_name_b (nm))
+ if (is_name_b (nm))
return this;
Input_translator * r =0;
Input_translator*
Input_translator::get_default_itrans_l()
{
- if ( contains_itrans_p_list_.size())
+ if (contains_itrans_p_list_.size())
return contains_itrans_p_list_.top();
else
return 0;
#include "item.hh"
#include "p-col.hh"
#include "elem-group.hh"
+#include "spanner.hh"
Item::Item()
{
breakable_b_ = false;
break_status_i_ = 0;
- pcol_l_ = 0;
- broken_to_a_[0] = broken_to_a_[1]=0;
+ broken_to_drul_[LEFT] = broken_to_drul_[RIGHT]=0;
}
IMPLEMENT_IS_TYPE_B1(Item, Score_elem);
Item::do_print() const
{
#ifndef NPRINT
- DOUT << "(unknown)";
+ DOUT << "breakable_b_: " << breakable_b_;
+ DOUT << "break_status_i_: " <<break_status_i_;
#endif
}
Real
-Item::hpos_f()const
+Item::hpos_f() const
{
- return pcol_l_->hpos_f_ + absolute_coordinate (X_AXIS);
+ return absolute_coordinate (X_AXIS);
}
Line_of_score *
-Item::line_l()const
+Item::line_l() const
{
- return pcol_l_->line_l_;
+ return (axis_group_l_a_[X_AXIS])? axis_group_l_a_[X_AXIS]->line_l() : 0;
}
int
void
Item::copy_breakable_items()
{
- if ( broken_to_a_[0] || broken_to_a_[1])
- return;
- Item *new_copies[2];
- for (int i=0; i < 2; i++)
+ if (broken_to_drul_[LEFT] || broken_to_drul_[RIGHT])
+ return;
+ Drul_array<Item *> new_copies;
+ Direction i=LEFT;
+ do
{
- Item * item_p = clone()->item ();
- item_p->copy_dependencies (*this);
-
- item_p->break_status_i_ = -1+ 2*i;
- pscore_l_->typeset_item (item_p, pcol_l_);
- item_p->handle_prebroken_dependencies();
- new_copies[i] =item_p;
+ Item * item_p = clone()->item ();
+
+ item_p->break_status_i_ = i;
+ pscore_l_->typeset_element (item_p);
+ item_p->handle_prebroken_dependencies();
+ new_copies[i] =item_p;
}
- broken_to_a_= new_copies;
+ while ((i *= -1) != LEFT);
+ broken_to_drul_= new_copies;
}
void
Item::do_breakable_col_processing()
{
- if (!breakable_b_ || !pcol_l_->breakable_b())
- return;
+ if (!breakable_b_)
+ return;
copy_breakable_items();
handle_prebroken_dependencies();
/*
Otherwise the broken items won't be pre_process()'ed.
- */
- add_dependency (broken_to_a_[0]);
- add_dependency (broken_to_a_[1]);
+ */
+ add_dependency (broken_to_drul_[LEFT]);
+ add_dependency (broken_to_drul_[RIGHT]);
}
Item::find_prebroken_piece (Line_of_score*l) const
{
if (line_l() == l)
- return (Item*)this;
- else if (broken_to_a_[0] && broken_to_a_[0]->line_l() == l)
- return broken_to_a_[0];
- else if (broken_to_a_[1] && broken_to_a_[1]->line_l() == l)
- return broken_to_a_[1];
+ return (Item*)this;
+ else if (broken_to_drul_[LEFT] && broken_to_drul_[LEFT]->line_l() == l)
+ return broken_to_drul_[LEFT];
+ else if (broken_to_drul_[RIGHT] && broken_to_drul_[RIGHT]->line_l() == l)
+ return broken_to_drul_[RIGHT];
return 0;
}
Item*
-Item::find_prebroken_piece (PCol*c)const
+Item::find_prebroken_piece (int breakstatus) const
{
- if (c == pcol_l_)
- return (Item *) this; // ugh
+ if (!breakstatus)
+ return (Item *) this; // ugh
+ else
+ return (Item*) broken_to_drul_[(Direction)breakstatus];
+}
- if (c == pcol_l_->prebreak_p_)
- return (Item *) broken_to_a_[0];
- else if (c==pcol_l_->postbreak_p_)
- return (Item *)broken_to_a_[1];
+void
+Item::handle_prebroken_dependencies()
+{
+ if (breakable_b_)
+ Score_elem::handle_prebroken_dependencies();
+}
- assert (false);
+int
+Item::left_right_compare(Item const *l, Item const *r)
+{
+ while (!l->is_type_b (Paper_column::static_name ()))
+ l = l->axis_group_l_a_[X_AXIS]->item();
+ while (!r->is_type_b (Paper_column::static_name ()))
+ r = r->axis_group_l_a_[X_AXIS]->item();
+
+ Paper_column *p1 = (Paper_column*)l;
+ Paper_column* p2 = (Paper_column*)r;
+ return p1->rank_i () - p2->rank_i ();
+}
+
+
+bool
+Item::linked_b() const
+{
+ return Score_elem::linked_b() || attached_span_l_arr_.size();
}
void
-Item::handle_prebroken_dependencies()
+Item::do_junk_links()
+{
+ attached_span_l_arr_.set_size(0);
+}
+
+void
+Item::do_unlink()
{
- if ( breakable_b_)
- Score_elem::handle_prebroken_dependencies();
+ for (int i=0; i < attached_span_l_arr_.size (); i++) {
+ Spanner *&s= attached_span_l_arr_[i];
+ if (s->spanned_drul_[LEFT] == this)
+ s->set_bounds (LEFT, 0);
+ if (s->spanned_drul_[RIGHT] == this)
+ s->set_bounds (RIGHT,0);
+ s =0;
+ }
+ attached_span_l_arr_.set_size (0);
}
}
else if (info.elem_l_->name() == Bar::static_name ())
{
- if ( !keyreq_l_)
+ if (!keyreq_l_)
default_key_b_ = true;
create_key();
}
Molecule*
-Key_item::brew_molecule_p()const
+Key_item::brew_molecule_p() const
{
Molecule*output = new Molecule;
Real inter = paper()->internote_f ();
Molecule m (a);
output->add_right (m);
}
- if ( pitch.size())
+ if (pitch.size())
{
Molecule m (paper()->lookup_l ()->fill (Box (
Interval (0, paper()->note_width ()),
Key_performer::do_print() const
{
#ifndef NPRINT
- if ( key_req_l_)
+ if (key_req_l_)
key_req_l_->print();
#endif
}
void
Key_performer::process_requests()
{
- if ( key_req_l_)
- play (new Audio_key (key_req_l_) );
+ if (key_req_l_)
+ play (new Audio_key (key_req_l_));
key_req_l_ = 0;
}
bool
Key_performer::do_try_request (Request* req_l)
{
- if ( key_req_l_)
+ if (key_req_l_)
return false;
- if ( req_l->command())
+ if (req_l->command())
key_req_l_ = req_l->command()->keychange ();
- if ( key_req_l_)
+ if (key_req_l_)
return true;
return false;
lookup with binsearch, return tokencode.
*/
int
-Keyword_table::lookup (char const *s)const
+Keyword_table::lookup (char const *s) const
{
int lo,
hi,
#include "bar.hh"
#include "debug.hh"
#include "line-group-grav.hh"
+#include "p-col.hh"
Line_group_engraver::Line_group_engraver()
{
void
Line_group_engraver::acknowledge_element (Score_elem_info elem)
{
- if ( !elem.elem_l_->axis_group_l_a_[Y_AXIS])
+ if (!elem.elem_l_->axis_group_l_a_[Y_AXIS])
staffline_p_->add_element (elem.elem_l_);
}
void
Line_group_engraver::do_removal_processing()
{
- staffline_p_->right_col_l_ = get_staff_info().command_pcol_l ();
+ staffline_p_->set_bounds(RIGHT,get_staff_info().command_pcol_l ());
typeset_element (staffline_p_);
staffline_p_ = 0;
}
Line_group_engraver::do_creation_processing()
{
staffline_p_ = new Vertical_group_spanner ;
- staffline_p_->left_col_l_ = get_staff_info().command_pcol_l ();
+ staffline_p_->set_bounds(LEFT,get_staff_info().command_pcol_l ());
// don't broadcast to self.
announce_element (Score_elem_info (staffline_p_,0));
paper_l_ =0;
}
Paper_def*
-Line_spacer::paper_l()const
+Line_spacer::paper_l() const
{
return paper_l_ ;
}
}
Molecule*
-Local_key_item::brew_molecule_p()const
+Local_key_item::brew_molecule_p() const
{
Molecule* output = new Molecule;
Molecule*octmol = 0;
Lyric_performer::do_print() const
{
#ifndef NPRINT
- if ( lreq_arr_.size())
+ if (lreq_arr_.size())
lreq_arr_[ 0 ]->print();
#endif
}
void
Lyric_performer::process_requests()
{
- if ( lreq_arr_.size() && lreq_arr_[ 0 ]->tdef_p_->text_str_.length_i() )
- play (new Audio_text (Audio_text::LYRIC, lreq_arr_[ 0 ]->tdef_p_->text_str_) );
+ if (lreq_arr_.size() && lreq_arr_[ 0 ]->tdef_p_->text_str_.length_i())
+ play (new Audio_text (Audio_text::LYRIC, lreq_arr_[ 0 ]->tdef_p_->text_str_));
lreq_arr_.clear();
}
Lyric_performer::do_try_request (Request* req_l)
{
Musical_req* m_l = req_l->musical();
- if ( !m_l || ! m_l->lreq_l())
+ if (!m_l || ! m_l->lreq_l())
return false;
lreq_arr_.push (m_l->lreq_l());
void
do_one_file (String init_str, String file_str)
{
- if ( init_str != "" && "" == path.find (init_str) )
+ if (init_str != "" && "" == path.find (init_str))
{
- error ( "Can not find `" + init_str +"\'");
+ error ("Can not find `" + init_str +"\'");
return ;
}
- if ( file_str!= "" && path.find (file_str) == "" )
+ if (file_str!= "" && path.find (file_str) == "")
{
- error ( "Can not find `" + file_str + "'");
+ error ("Can not find `" + file_str + "'");
return ;
}
path.add (env_l);
}
path.add ("");
- path.add (String (DIR_DATADIR) + "/init/" );
+ path.add (String (DIR_DATADIR) + "/init/");
path.push (DIR_DATADIR);
while (Long_option_init const * opt = oparser())
{
- switch ( opt->shortname)
+ switch (opt->shortname)
{
case 'o':
set_default_output (oparser.optional_argument_ch_C_);
int p=0;
const char *arg ;
- while ( (arg= oparser.get_next_arg()))
+ while ((arg= oparser.get_next_arg()))
{
String f (arg);
destill_inname (f);
void
destill_inname (String &name_str_r)
{
- if ( name_str_r.length_i())
+ if (name_str_r.length_i())
{
if (name_str_r[ 0 ] != '-')
{
Meter_performer::do_print() const
{
#ifndef NPRINT
- if ( meter_req_l_)
- meter_req_l_->print();
+ if (meter_req_l_)
+ meter_req_l_->print();
#endif
}
void
Meter_performer::process_requests()
{
- if ( meter_req_l_)
- play (new Audio_meter (meter_req_l_) );
+ if (meter_req_l_)
+ play (new Audio_meter (meter_req_l_));
meter_req_l_ = 0;
}
bool
Meter_performer::do_try_request (Request* req_l)
{
- if ( meter_req_l_)
- return false;
+ if (meter_req_l_)
+ return false;
- if ( req_l->command())
- meter_req_l_ = req_l->command()->meterchange ();
+ if (req_l->command())
+ meter_req_l_ = req_l->command()->meterchange ();
- if ( meter_req_l_)
- return true;
+ if (meter_req_l_)
+ return true;
return false;
}
}
Molecule*
-Meter::brew_molecule_p()const
+Meter::brew_molecule_p() const
{
Symbol s = paper()->lookup_l ()->meter (args);
return new Molecule (Atom (s));
String
Midi_duration::str() const
{
- return String ("<duration: ") + String (seconds_f_ ) + ">";
+ return String ("<duration: ") + String (seconds_f_) + ">";
}
Midi_header::Midi_header (int format_i, int tracks_i, int clocks_per_4_i)
Midi_instrument::str() const
{
Byte program_byte = 0;
- for ( int i = 0; instrument_name_sz_a_[i]; i++)
- if ( instrument_str_ == String (instrument_name_sz_a_[ i ]))
+ for (int i = 0; instrument_name_sz_a_[i]; i++)
+ if (instrument_str_ == String (instrument_name_sz_a_[ i ]))
{
program_byte = (Byte)i;
break;
}
- String str = String ((char)( 0xc0 + channel_i_) );
+ String str = String ((char)(0xc0 + channel_i_));
str += String ((char)program_byte);
return str;
}
Midi_item::i2varint_str (int i)
{
int buffer_i = i & 0x7f;
- while ( (i >>= 7) > 0)
+ while ((i >>= 7) > 0)
{
buffer_i <<= 8;
buffer_i |= 0x80;
}
String str;
- while ( 1)
+ while (1)
{
str += (char)buffer_i;
- if ( buffer_i & 0x80)
+ if (buffer_i & 0x80)
buffer_i >>= 8;
else
break;
int flats_i = k->flats_i();
// midi cannot handle non-conventional keys
- if ( flats_i && sharps_i)
+ if (flats_i && sharps_i)
return "";
int accidentals_i = sharps_i - flats_i;
String str = "ff5804";
str += String_convert::i2hex_str (num_i, 2, '0');
- str += String_convert::i2hex_str (intlog2( den_i) , 2, '0' );
+ str += String_convert::i2hex_str (intlog2(den_i) , 2, '0');
str += String_convert::i2hex_str (clocks_per_1_i_, 2, '0');
str += String_convert::i2hex_str (8, 2, '0');
return String_convert::hex2bin_str (str);
String
Midi_note::str() const
{
- if ( pitch_i() == INT_MAX)
+ if (pitch_i() == INT_MAX)
return String ("");
- Byte status_byte = (char)( 0x90 + channel_i_);
+ Byte status_byte = (char)(0x90 + channel_i_);
String str = String ((char)status_byte);
- str += (char)( pitch_i() + c0_pitch_i_c_);
+ str += (char)(pitch_i() + c0_pitch_i_c_);
// poor man's staff dynamics:
- str += (char)( dynamic_byte_ - 0x10 * channel_i_);
+ str += (char)(dynamic_byte_ - 0x10 * channel_i_);
return str;
}
String
Midi_note_off::str() const
{
- if ( pitch_i() == INT_MAX)
+ if (pitch_i() == INT_MAX)
return String ("");
- Byte status_byte = (char)( 0x80 + channel_i_);
+ Byte status_byte = (char)(0x80 + channel_i_);
String str = String ((char)status_byte);
- str += (char)( pitch_i() + Midi_note::c0_pitch_i_c_);
+ str += (char)(pitch_i() + Midi_note::c0_pitch_i_c_);
str += (char)aftertouch_byte_;
return str;
}
Midi_tempo::Midi_tempo (Audio_item* audio_item_l)
: Midi_item (audio_item_l)
{
- per_minute_4_i_ = ( (Audio_tempo*)audio_item_l_)->per_minute_4_i_;
+ per_minute_4_i_ = ((Audio_tempo*)audio_item_l_)->per_minute_4_i_;
}
Midi_tempo::Midi_tempo (int per_minute_4_i)
Midi_text::Midi_text (Audio_item* audio_item_l)
: Midi_item (audio_item_l)
{
- text_str_ = ( (Audio_text*)audio_item_l_)->text_str_;
- type_ = (Type)( (Audio_text*)audio_item_l_)->type_;
+ text_str_ = ((Audio_text*)audio_item_l_)->text_str_;
+ type_ = (Type)((Audio_text*)audio_item_l_)->type_;
}
Midi_text::Midi_text (Midi_text::Type type, String text_str)
void
Midi_track::add (int delta_time_i, String event_str)
{
- if ( delta_time_i < 0)
+ if (delta_time_i < 0)
{
- cout << String_convert::bin2hex_str (i2varint_str (delta_time_i) ) << endl;
+ cout << String_convert::bin2hex_str (i2varint_str (delta_time_i)) << endl;
cout << String_convert::bin2hex_str (event_str) << endl;
}
assert (delta_time_i >= 0);
assert(event_str.length_i());
- Midi_chunk::add (i2varint_str (delta_time_i) + event_str );
+ Midi_chunk::add (i2varint_str (delta_time_i) + event_str);
}
void
{
// use convention of 384 clocks per 4
// use Duration_convert
- int delta_time_i = delta_time_moment * Moment (384) / Moment (1, 4 );
- // ? int ( delta_time_moment * 4 * 384)
+ int delta_time_i = delta_time_moment * Moment (384) / Moment (1, 4);
+ // ? int (delta_time_moment * 4 * 384)
add (delta_time_i, mitem_l->str());
}
}
Midi_stream&
-Midi_stream::operator <<( String str)
+Midi_stream::operator <<(String str)
{
- if ( check_debug)
+ if (check_debug)
str = String_convert::bin2hex_str (str);
*os_p_ << str;
- if ( check_debug)
+ if (check_debug)
*os_p_ << "\n";
return *this;
}
Midi_stream&
-Midi_stream::operator <<( Midi_item const& mitem_c_r)
+Midi_stream::operator <<(Midi_item const& mitem_c_r)
{
// *this << mitem_c_r.str();
mitem_c_r.output (this);
- if ( check_debug)
+ if (check_debug)
*os_p_ << "\n";
return *this;
}
Midi_stream&
-Midi_stream::operator <<( int i)
+Midi_stream::operator <<(int i)
{
// output binary string ourselves
*this << Midi_item::i2varint_str (i);
Midi_stream::open()
{
os_p_ = new ofstream (filename_str_);
- if ( !*os_p_)
+ if (!*os_p_)
error ("can't open `" + filename_str_ + "\'");
}
}
Midi_walker::Midi_walker (Audio_staff* audio_staff_l, Midi_track* track_l)
- : PCursor<Audio_item*>( audio_staff_l->audio_item_l_list_)
+ : PCursor<Audio_item*>(audio_staff_l->audio_item_l_list_)
{
track_l_ = track_l;
last_mom_ = 0;
Midi_walker::~Midi_walker()
{
// ugh
- do_stop_notes (last_mom_ + Moment (10, 1) );
+ do_stop_notes (last_mom_ + Moment (10, 1));
}
/**
Midi_walker::do_start_note (Midi_note* note_l)
{
Moment stop_mom = note_l->duration() + ptr ()->audio_column_l_->at_mom ();
- for ( int i=0; i < stop_note_queue.size(); i++)
+ for (int i=0; i < stop_note_queue.size(); i++)
{
- if ( stop_note_queue[ i ].val->pitch_i() == note_l->pitch_i ())
+ if (stop_note_queue[ i ].val->pitch_i() == note_l->pitch_i ())
{
- if ( stop_note_queue[ i ].key < stop_mom)
+ if (stop_note_queue[ i ].key < stop_mom)
stop_note_queue[ i ].ignore_b_ = true;
else // skip the stopnote
return;
void
Midi_walker::do_stop_notes (Moment max_mom)
{
- while ( stop_note_queue.size() && stop_note_queue.front ().key <= max_mom)
+ while (stop_note_queue.size() && stop_note_queue.front ().key <= max_mom)
{
Midi_note_event e = stop_note_queue.get();
- if ( e.ignore_b_)
+ if (e.ignore_b_)
continue;
Moment stop_mom = e.key;
do_stop_notes (ptr()->audio_column_l_->at_mom ());
Midi_item* p = ptr()->midi_item_p ();
- if ( !p )
+ if (!p)
return;
p->channel_i_ = track_l_->number_i_;
- if ( p->name() != Midi_note::static_name ())
+ if (p->name() != Midi_note::static_name ())
output_event (ptr()->audio_column_l_->at_mom (), p);
else
do_start_note ((Midi_note*)p);
/*
- music-iterator.cc -- implement {Music,Chord,Voice}_iterator
+ music-iterator.cc -- implement Music_iterator
source file of the GNU LilyPond music typesetter
(c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
*/
-
+#include "debug.hh"
#include "music-list.hh"
#include "music-iterator.hh"
+#include "voice-iterator.hh"
+#include "chord-iterator.hh"
+#include "request-iterator.hh"
#include "translator.hh"
-#include "request.hh"
-#include "debug.hh"
IMPLEMENT_IS_TYPE_B(Music_iterator);
-Chord_iterator::~Chord_iterator()
-{
-}
void
-Music_iterator::do_print()const
+Music_iterator::do_print() const
{
}
Music_iterator::print() const
{
#ifndef NPRINT
- if ( !check_debug)
- return ;
+ if (!check_debug)
+ return ;
DOUT << name() << "{";
DOUT << "report to " <<
- report_to_l() << " (" << report_to_l ()->name () << ")\n";
- DOUT << "next at " << next_moment() << " ";
+ report_to_l() << " (" << report_to_l ()->name () << ")\n";
+ if (ok())
+ DOUT << "next at " << next_moment() << " ";
+ else
+ DOUT << "not feeling well today..";
do_print();
DOUT << "}\n";
#endif
{
assert (report_to_l());
if (report_to_l()->is_bottom_engraver_b ())
- return report_to_l();
+ return report_to_l();
set_translator (report_to_l()->get_default_interpreter ());
return report_to_l();
}
Translator*
-Music_iterator::report_to_l()const
+Music_iterator::report_to_l() const
{
if (! report_to_l_arr_.size())
- return 0;
+ return 0;
return report_to_l_arr_.top();
}
Music_iterator::set_translator (Translator*trans)
{
if (report_to_l()==trans)
- return;
- if ( report_to_l())
- pop_translator();
+ return;
+ if (report_to_l())
+ pop_translator();
if (trans)
- push_translator (trans);
+ push_translator (trans);
}
void
}
Moment
-Music_iterator::next_moment()const
+Music_iterator::next_moment() const
{
return 0;
}
}
bool
-Music_iterator::ok()const
+Music_iterator::ok() const
{
return first_b_;
}
Music_iterator*
Music_iterator::static_get_iterator_p (Music *m,
- Translator *report_l)
+ Translator *report_l)
{
Music_iterator * p =0;
if (m->is_type_b (Request_chord::static_name()))
- p = new Request_chord_iterator ((Request_chord*) m);
+ p = new Request_chord_iterator ((Request_chord*) m);
else if (m->is_type_b (Chord::static_name()))
- p = new Chord_iterator ((Chord*) m);
+ p = new Chord_iterator ((Chord*) m);
else if (m->is_type_b (Voice::static_name()))
- p = new Voice_iterator ((Voice*) m);
+ p = new Voice_iterator ((Voice*) m);
if (m -> type_str_ != "")
{
- Translator * a =report_l->
- find_get_translator_l (m-> type_str_, m->id_str_);
- p->set_translator (a);
+ Translator * a =report_l->
+ find_get_translator_l (m-> type_str_, m->id_str_);
+ p->set_translator (a);
}
if (! p->report_to_l())
- p ->set_translator (report_l);
+ p ->set_translator (report_l);
return p;
}
Music_iterator*
-Music_iterator::get_iterator_p (Music*m)const
+Music_iterator::get_iterator_p (Music*m) const
{
Music_iterator*p = static_get_iterator_p (m,report_to_l());
p->daddy_iter_l_ = (Music_iterator*)this;
first_b_ = true;
}
-/* ************** */
-
-Chord_iterator::Chord_iterator (Chord const *chord_C)
-{
- chord_C_ = chord_C;
-}
-
-void
-Chord_iterator::construct_children()
-{
- int j = 0;
- for (PCursor<Music*> i (chord_C_->music_p_list_.top()); //, int j = 0;
- i.ok(); j++, i++)
- {
- Music_iterator * mi = get_iterator_p (i.ptr());
- if ( mi->ok())
- {
- set_translator (mi->report_to_l()->ancestor_l (
- chord_C_->multi_level_i_) );
- children_p_list_.bottom().add (mi);
- }
- else
- delete mi;
- }
-}
-void
-Chord_iterator::do_print() const
-{
-#ifndef NPRINT
- for (PCursor<Music_iterator*> i (children_p_list_.top()); i.ok (); i++)
- {
- i->print();
- }
-#endif
-}
-
-void
-Chord_iterator::process_and_next (Moment until)
-{
- for (PCursor<Music_iterator*> i (children_p_list_.top()); i.ok ();)
- {
- if (i->next_moment() == until)
- {
- i->process_and_next (until);
- }
- if (!i->ok())
- delete i.remove_p();
- else
- i++;
- }
- Music_iterator::process_and_next (until);
-}
-
-
-IMPLEMENT_IS_TYPE_B1(Chord_iterator,Music_iterator);
-
-Moment
-Chord_iterator::next_moment()const
-{
- Moment next_ = infinity_mom;
- for (PCursor<Music_iterator*> i (children_p_list_.top()); i.ok (); i++)
- next_ = next_ <? i->next_moment() ;
- return next_;
-}
-
-
-
-bool
-Chord_iterator::ok()const
-{
- return children_p_list_.size();
-}
-
-/* ************** */
-
-void
-Voice_iterator::do_print()const
-{
- if (iter_p_)
- iter_p_->print();
-}
-
-Voice_iterator::Voice_iterator (Voice const*v)
- : PCursor<Music*> ( v->music_p_list_)
-{
- here_mom_ = v->offset_mom_;
- voice_C_ = v;
- iter_p_ =0;
-}
-
-void
-Voice_iterator::construct_children()
-{
- while (PCursor<Music*>::ok())
- {
- start_next_element();
- if ( !iter_p_->ok())
- {
- leave_element();
- }
- else
- {
- set_voice_translator();
- break;
- }
- }
-}
-
-void
-Voice_iterator::leave_element()
-{
- delete iter_p_;
- iter_p_ =0;
- MInterval elt_time = ptr()->time_int ();
- if (!elt_time.empty_b())
- here_mom_ += elt_time.length();
- PCursor<Music*>::next();
-}
-
-void
-Voice_iterator::start_next_element()
-{
- assert (!iter_p_);
- iter_p_ = get_iterator_p (ptr());
-}
-
-void
-Voice_iterator::set_voice_translator()
-{
- if (iter_p_->report_to_l()->depth_i () > report_to_l ()->depth_i ())
- set_translator (iter_p_->report_to_l());
-}
-
-Voice_iterator::~Voice_iterator()
-{
- assert (! iter_p_);
-}
-
-
-IMPLEMENT_IS_TYPE_B1(Voice_iterator,Music_iterator);
-
-void
-Voice_iterator::process_and_next (Moment until)
-{
- while (1)
- {
- Moment local_until = until - here_mom_;
- while ( iter_p_->ok())
- {
- Moment here = iter_p_->next_moment();
- if (here != local_until)
- goto loopexit;
-
- iter_p_->process_and_next (local_until);
- }
-
- if (!iter_p_->ok())
- {
- leave_element();
- if ( PCursor<Music*>::ok())
- {
- start_next_element();
- set_voice_translator();
- }
- else
- {
- goto loopexit;
- }
- }
- }
-
-loopexit:
-
- Music_iterator::process_and_next (until);
-}
-
-Moment
-Voice_iterator::next_moment()const
-{
- return iter_p_->next_moment() + here_mom_;
-}
-
-bool
-Voice_iterator::ok()const
-{
- return iter_p_;
-}
-
-
-IMPLEMENT_IS_TYPE_B1(Request_chord_iterator,Music_iterator);
-
-void
-Request_chord_iterator::construct_children()
-{
- get_req_translator_l();
-}
-
-Request_chord_iterator::Request_chord_iterator (Request_chord*el_l)
-{
- elt_l_ = el_l;
- elt_duration_ = el_l->time_int().length ();
- last_b_ = false;
-}
-
-
-bool
-Request_chord_iterator::ok()const
-{
- return (elt_duration_ && !last_b_) || first_b_;
-}
-
-
-
-Moment
-Request_chord_iterator::next_moment()const
-{
- Moment m (0);
- if (!first_b_)
- m = elt_duration_;
- return m;
-}
-
-void
-Request_chord_iterator::do_print() const
-{
-#ifndef NPRINT
- DOUT << "duration: " << elt_duration_;
-#endif
-}
-void
-Request_chord_iterator::process_and_next (Moment mom)
-{
- if ( first_b_)
- {
- for (PCursor<Music*> i (elt_l_->music_p_list_); i.ok(); i++)
- {
- assert (i->is_type_b (Request::static_name()));
- Request * req_l = (Request*)i.ptr();
- bool gotcha = report_to_l()->try_request (req_l);
- if (!gotcha)
- req_l->warning ("Junking request: " + String (req_l->name()));
-
- }
- first_b_ = false;
- }
-
- if ( mom >= elt_duration_)
- last_b_ = true;
-}
IMPLEMENT_IS_TYPE_B1(Chord,Music_list);
MInterval
-Chord::time_int()const
+Chord::time_int() const
{
MInterval m;
for (iter (music_p_list_.top(), i); i.ok (); i++)
/*
c4 <> c4
*/
- if ( !interval.empty_b())
+ if (!interval.empty_b())
last += interval.length();
}
return offset_mom_ + MInterval (0,last);
}
void
-Music_list::do_print()const
+Music_list::do_print() const
{
#ifndef NPRINT
for (iter (music_p_list_.top(),i); i.ok (); i++)
}
void
-Music::print()const
+Music::print() const
{
#ifndef NPRINT
- if ( ! check_debug)
+ if (! check_debug)
return ;
DOUT << name() << "{";
if (type_str_!="" || id_str_!="")
}
void
-Music::do_print()const
+Music::do_print() const
{
}
Identifier *old = lookup_identifier (name_str);
if (old)
{
- old->warning( "redeclaration of \\" + name_str);
+ old->warning("redeclaration of \\" + name_str);
delete old;
}
(*identifier_assoc_p_)[name_str] = i;
delete identifier_assoc_p_;
}
void
-My_lily_lexer::print_declarations (bool init_b)const
+My_lily_lexer::print_declarations (bool init_b) const
{
for (Assoc_iter<String,Identifier*> ai (*identifier_assoc_p_); ai.ok();
ai++)
Note_performer::do_print() const
{
#ifndef NPRINT
- if ( note_req_l_)
+ if (note_req_l_)
{
note_req_l_->print();
}
Note_performer::process_requests()
{
// this is _really_ braindead, but it generates some output
- if ( !note_req_l_ || !note_req_l_->melodic() || !note_req_l_->rhythmic ())
+ if (!note_req_l_ || !note_req_l_->melodic() || !note_req_l_->rhythmic ())
return;
- play (new Audio_note (note_req_l_) );
+ play (new Audio_note (note_req_l_));
note_req_l_ = 0;
}
bool
Note_performer::do_try_request (Request* req_l)
{
- if ( note_req_l_)
+ if (note_req_l_)
return false;
- if ( !req_l->musical() || !req_l->musical ()->note ())
+ if (!req_l->musical() || !req_l->musical ()->note ())
return false;
note_req_l_ = req_l->musical()->melodic ();
/*
- p-col.cc -- implement PCol
+ p-col.cc -- implement Paper_column
source file of the GNU LilyPond music typesetter
#include "p-col.hh"
#include "p-score.hh"
-
#include "debug.hh"
-Interval
-PCol::width() const
-{
- Interval w;
-
- for (iter_top (its,i); i.ok(); i++)
- w.unite (i->width());
- if (w.empty_b())
- w.unite (Interval (0,0));
- return w;
-}
-
-void
-PCol::clean_breakable_items()
-{
- if (!line_l_)
- {
- its.junk_links();
- }
- if (prebreak_p_)
- prebreak_p_->clean_breakable_items();
- if (postbreak_p_)
- postbreak_p_->clean_breakable_items();
-}
int
-PCol::rank_i() const
+Paper_column::rank_i() const
{
return rank_i_;
}
void
-PCol::set_rank (int i)
+Paper_column::set_rank (int i)
{
rank_i_ = i;
- if (prebreak_p_)
- prebreak_p_->rank_i_ = i;
- if (postbreak_p_)
- postbreak_p_->rank_i_ = i;
+ if (prebreak_l())
+ prebreak_l()->rank_i_ = i;
+ if (postbreak_l())
+ postbreak_l()->rank_i_ = i;
}
void
-PCol::print() const
+Paper_column::do_print() const
{
#ifndef NPRINT
- DOUT << "PCol {";
-
DOUT << "rank: " << rank_i_ << '\n';
-
- DOUT << "# symbols: " << its.size() ;
- if (prebreak_p_){
- DOUT << "\npre: ";
- prebreak_p_->print();
+ if (prebreak_l())
+ {
+ DOUT << "\npre: ";
+ prebreak_l()->print();
}
- if (postbreak_p_) {
+ if (postbreak_l())
+ {
DOUT << "post: ";
- postbreak_p_->print();
+ postbreak_l()->print();
}
- else if (daddy_l_)
+ if (break_status_i_)
{
- DOUT <<'\n' << ((this == daddy_l_->prebreak_p_) ?
- "prebreak" : "postbreak");
- DOUT << '\n';
+ DOUT <<'\n' << ((break_status_i_ == -1)? "prebreak" : "postbreak");
+ DOUT << '\n';
}
DOUT << "extent: " << width().str () << "\n";
- DOUT << "}\n";
#endif
}
int
-PCol::compare (PCol const &c1, PCol const &c2)
+Paper_column::compare (Paper_column const &c1, Paper_column const &c2)
{
return c1.rank_i() - c2.rank_i ();
}
-void
-PCol::OK() const
+Paper_column*
+Paper_column::prebreak_l() const
{
-#ifndef NDEBUG
- if (prebreak_p_ || postbreak_p_)
- {
- assert (prebreak_p_&&postbreak_p_);
- assert (prebreak_p_->daddy_l_ == this);
- assert (postbreak_p_->daddy_l_ == this);
- }
-#endif
+ return (Paper_column*)broken_to_drul_[LEFT];
}
-void
-PCol::set_breakable()
+Paper_column*
+Paper_column::postbreak_l() const
{
- if (breakable_b())
- return;
-
- do_set_breakable();
- prebreak_p_->pscore_l_ = pscore_l_;
- postbreak_p_->pscore_l_ = pscore_l_;
-
- prebreak_p_->daddy_l_ = postbreak_p_->daddy_l_ = this;
+ return(Paper_column*) broken_to_drul_[RIGHT];
}
-void
-PCol::do_set_breakable()
-{
- prebreak_p_ = new PCol;
- postbreak_p_ = new PCol;
-}
-
-
bool
-PCol::breakpoint_b() const
+Paper_column::breakpoint_b() const
{
return !line_l_;
}
-bool
-PCol::breakable_b() const
-{
- return prebreak_p_||postbreak_p_||daddy_l_;
-}
-
-PCol::PCol()
+Paper_column::Paper_column()
{
used_b_ = false;
error_mark_b_ = false;
- daddy_l_ = 0;
- prebreak_p_=0;
- postbreak_p_=0;
line_l_=0;
- hpos_f_ = -1.0;
- pscore_l_ = 0;
rank_i_ = -1;
}
-PCol::~PCol()
-{
- delete prebreak_p_;
- delete postbreak_p_;
-}
-
-void
-PCol::add (Item *i)
+Line_of_score*
+Paper_column::line_l() const
{
- its.bottom().add (i);
- i->pcol_l_ = this;
+ return line_l_;
}
bool
-PCol::used_b()const
+Paper_column::used_b() const
{
- return daddy_l_ || breakable_b() || its.size ()|| used_b_;
+ return linked_b();
}
+
+IMPLEMENT_IS_TYPE_B1(Paper_column, Horizontal_group_item);
+
void
Performer_group_performer::do_creation_processing()
{
- for ( PCursor<Performer*> i (perf_p_list_.top()); i.ok (); i++ )
+ for (PCursor<Performer*> i (perf_p_list_.top()); i.ok (); i++)
i->creation_processing();
}
void
-Performer_group_performer::do_print()const
+Performer_group_performer::do_print() const
{
#ifndef NPRINT
- if ( !check_debug)
+ if (!check_debug)
return ;
- for ( PCursor<Performer*> i (perf_p_list_.top()); i.ok (); i++ )
+ for (PCursor<Performer*> i (perf_p_list_.top()); i.ok (); i++)
i->print();
#endif
}
void
Performer_group_performer::do_removal_processing()
{
- for ( PCursor<Performer*> i (perf_p_list_.top()); i.ok (); i++ )
+ for (PCursor<Performer*> i (perf_p_list_.top()); i.ok (); i++)
i->do_removal_processing();
}
bool hebbes_b =false;
for (int i =0; !hebbes_b && i < nongroup_l_arr_.size() ; i++)
hebbes_b =nongroup_l_arr_[i]->try_request (req_l);
- if ( !hebbes_b && daddy_perf_l_)
+ if (!hebbes_b && daddy_perf_l_)
hebbes_b = daddy_perf_l_->try_request (req_l);
return hebbes_b ;
}
Performer_group_performer::find_get_translator_l (String n,String id)
{
Translator * ret=0;
- Input_translator* itrans_l= itrans_l_-> recursive_find ( n);
+ Input_translator* itrans_l= itrans_l_-> recursive_find (n);
if (itrans_l)
{
ret = find_performer_l (n,id);
add (group);
ret = group;
- if (group->itrans_l_->is_name_b (n) )
+ if (group->itrans_l_->is_name_b (n))
ret ->id_str_ = id;
else
return ret->find_get_translator_l (n,id);
Performer_group_performer::get_default_interpreter()
{
// ?
- if ( is_bottom_performer_b())
+ if (is_bottom_performer_b())
return daddy_perf_l_->get_default_interpreter();
Performer_group_performer *perf_p= itrans_l_->
void
Performer_group_performer::process_requests()
{
- for ( PCursor<Performer*> i (perf_p_list_.top()); i.ok (); i++ )
+ for (PCursor<Performer*> i (perf_p_list_.top()); i.ok (); i++)
i->process_requests();
}
}
int
-Performer::get_tempo_i()const
+Performer::get_tempo_i() const
{
return daddy_perf_l_->get_tempo_i();
}
--- /dev/null
+/*
+ request-iterator.cc -- implement Request_chord_iterator
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "translator.hh"
+#include "debug.hh"
+#include "request-iterator.hh"
+#include "music-list.hh"
+#include "request.hh"
+
+IMPLEMENT_IS_TYPE_B1(Request_chord_iterator,Music_iterator);
+
+void
+Request_chord_iterator::construct_children()
+{
+ get_req_translator_l();
+}
+
+Request_chord_iterator::Request_chord_iterator (Request_chord*el_l)
+{
+ elt_l_ = el_l;
+ MInterval elt_dur =el_l->time_int();
+ elt_duration_ = elt_dur.length ();
+ last_b_ = false;
+}
+
+
+bool
+Request_chord_iterator::ok() const
+{
+ return (elt_duration_ && !last_b_) || first_b_;
+}
+
+
+
+Moment
+Request_chord_iterator::next_moment() const
+{
+ Moment m (0);
+ if (!first_b_)
+ m = elt_duration_;
+ return m;
+}
+
+void
+Request_chord_iterator::do_print() const
+{
+#ifndef NPRINT
+ DOUT << "duration: " << elt_duration_;
+#endif
+}
+void
+Request_chord_iterator::process_and_next (Moment mom)
+{
+ if (first_b_)
+ {
+ for (PCursor<Music*> i (elt_l_->music_p_list_); i.ok(); i++)
+ {
+ assert (i->is_type_b (Request::static_name()));
+ Request * req_l = (Request*)i.ptr();
+ bool gotcha = report_to_l()->try_request (req_l);
+ if (!gotcha)
+ req_l->warning ("Junking request: " + String (req_l->name()));
+
+ }
+ first_b_ = false;
+ }
+
+ if (mom >= elt_duration_)
+ last_b_ = true;
+}
bool
-Request::equal_b (Request *r)const
+Request::equal_b (Request *r) const
{
- if ( is_type_b ( r->name()) )
+ if (is_type_b (r->name()))
return r->do_equal_b ((Request*)this);
- if ( r->is_type_b (name()))
+ if (r->is_type_b (name()))
return do_equal_b (r);
return false;
}
bool
-Request::do_equal_b (Request*)const
+Request::do_equal_b (Request*) const
{
return false;
}
Rest_collision_engraver::do_print() const
{
#ifndef NPRINT
- if ( rest_collision_p_)
+ if (rest_collision_p_)
rest_collision_p_->print();
#endif
}
announce_element (Score_elem_info (align_p_,0));
}
Score_elem * unbound_elem = inf.elem_l_;
- while ( unbound_elem->axis_group_l_a_[X_AXIS])
+ while (unbound_elem->axis_group_l_a_[X_AXIS])
unbound_elem = unbound_elem->axis_group_l_a_[X_AXIS];
align_p_->add_element (unbound_elem);
}
}
void
-Score_column::print() const
+Score_column::do_print() const
{
#ifndef NPRINT
- DOUT << "Score_column { mus "<< musical_b_ <<" at " << when_<<'\n';
+ DOUT << "mus "<< musical_b_ <<" at " << when_<<'\n';
DOUT << "durations: [";
for (int i=0; i < durations.size(); i++)
- DOUT << durations[i] << " ";
+ DOUT << durations[i] << " ";
DOUT << "]\n";
- PCol::print();
- DOUT << "}\n";
+ Paper_column::do_print();
#endif
}
assert (d);
for (int i = 0; i< durations.size(); i++)
{
- if (d == durations[i])
- return ;
+ if (d == durations[i])
+ return ;
}
durations.push (d);
}
-void
-Score_column::do_set_breakable()
-{
- Score_column *c1 = new Score_column (when_);
- Score_column *c2 = new Score_column (when_);
- prebreak_p_ =c1;
- postbreak_p_ = c2;
- c1->durations = durations;
- c2->durations = durations;
- c1->musical_b_
- = c2->musical_b_ = musical_b_;
-}
+IMPLEMENT_IS_TYPE_B1(Score_column, Paper_column);
#include "p-col.hh"
Score_elem*
-Score_elem::dependency (int i)const
+Score_elem::dependency (int i) const
{
- return (Score_elem*) get_out_edge_arr()[i];
+ return (Score_elem*) get_out_edge_arr ()[i];
}
int
-Score_elem::dependency_size() const
+Score_elem::dependency_size () const
{
- return get_out_edge_arr().size ();
+ return get_out_edge_arr ().size ();
}
Score_elem*
return get_in_edge_arr().size ();
}
-
-
String
-Score_elem::TeX_string_without_offset (Offset o)const
+Score_elem::make_TeX_string (Offset o)const
{
- if (transparent_b_)
- return "";
String s ("\\placebox{%}{%}{%}");
Array<String> a;
a.push (print_dimen (o.y()));
a.push (print_dimen (o.x()));
String t = output->TeX_string();
if (t == "")
- return t;
+ return t;
a.push (t);
String r;
if (check_debug)
- r = String ("\n%start: ") + name() + "\n";
- r += substitute_args (s, a);;
+ r = String ("\n%start: ") + name() + "\n";
+ r += substitute_args (s, a);
return r;
}
-
String
-Score_elem::TeX_string() const
+Score_elem::do_TeX_output_str () const
{
- assert (status_ > POSTCALCED);
- return TeX_string_without_offset (offset_);
+ return make_TeX_string(absolute_offset());
}
-void
-Score_elem::copy_dependencies (Score_elem const &s)
+Score_elem::Score_elem (Score_elem const&s)
{
/* called from derived ctor, so most info points to the same deps
- as (Directed_graph_node&)s. Nobody points to us, so don't copy
- dependents.
+ as (Directed_graph_node&)s. Nobody points to us, so don't copy
+ dependents.
*/
copy_edges_out (s);
-}
-
-Score_elem::Score_elem (Score_elem const&s)
-{
transparent_b_ = s.transparent_b_;
empty_b_ = s.empty_b_;
axis_group_l_a_[0] = axis_group_l_a_[1] =0;
delete output;
status_ = DELETED;
output = 0;
-
}
/*
GEOMETRY
*/
Real
-Score_elem::absolute_coordinate (Axis a)const
+Score_elem::absolute_coordinate (Axis a) const
{
Real r = offset_[a];
- for ( Axis_group_element * axis_group_l = axis_group_l_a_[a];
- axis_group_l; axis_group_l = axis_group_l->axis_group_l_a_[a])
+ for (Axis_group_element * axis_group_l = axis_group_l_a_[a];
+ axis_group_l; axis_group_l = axis_group_l->axis_group_l_a_[a])
- r += axis_group_l->offset_[a];
+ r += axis_group_l->offset_[a];
return r;
}
return Offset (absolute_coordinate (X_AXIS), absolute_coordinate (Y_AXIS));
}
- void
+void
Score_elem::translate (Real y, Axis a)
{
offset_[a] += y;
}
Real
-Score_elem::relative_coordinate (Axis_group_element*e, Axis a)const
+Score_elem::relative_coordinate (Axis_group_element*e, Axis a) const
{
Real r =0.0;
- for ( Axis_group_element * axis_group_l = axis_group_l_a_[a];
- axis_group_l != e;
- axis_group_l = axis_group_l->axis_group_l_a_[a])
- r += axis_group_l->offset_[a];
+ for (Axis_group_element * axis_group_l = axis_group_l_a_[a];
+ axis_group_l != e;
+ axis_group_l = axis_group_l->axis_group_l_a_[a])
+ r += axis_group_l->offset_[a];
return r;
}
Axis_group_element*
-Score_elem::common_group (Score_elem const* s, Axis a)const
+Score_elem::common_group (Score_elem const* s, Axis a) const
{
Link_array<Axis_group_element> my_groups;
- for ( Axis_group_element * axis_group_l = axis_group_l_a_[a];
- axis_group_l;
- axis_group_l = axis_group_l->axis_group_l_a_[a])
- my_groups.push (axis_group_l);
+ for (Axis_group_element * axis_group_l = axis_group_l_a_[a];
+ axis_group_l;
+ axis_group_l = axis_group_l->axis_group_l_a_[a])
+ my_groups.push (axis_group_l);
Axis_group_element* common_l=0;
- for ( Axis_group_element * axis_group_l = s->axis_group_l_a_[a];
- !common_l && axis_group_l;
- axis_group_l = axis_group_l->axis_group_l_a_[a])
- common_l = my_groups.find_l (axis_group_l);
+ for (Axis_group_element * axis_group_l = s->axis_group_l_a_[a];
+ !common_l && axis_group_l;
+ axis_group_l = axis_group_l->axis_group_l_a_[a])
+ common_l = my_groups.find_l (axis_group_l);
return common_l;
}
if (!output)
{
- Molecule*m = brew_molecule_p();
- r = m->extent().x ();
- delete m;
+ Molecule*m = brew_molecule_p();
+ r = m->extent().x ();
+ delete m;
}
else
- r = output->extent().x ();
+ r = output->extent().x ();
return r;
}
}
Interval
-Score_elem::extent (Axis a)const
+Score_elem::extent (Axis a) const
{
Interval r;
- if ( !empty_b_)
+ if (!empty_b_)
{
- r = (a == X_AXIS)? do_width(): do_height ();
+ r = (a == X_AXIS)? do_width(): do_height ();
}
if (!r.empty_b()) // float exception on DEC Alpha
- r+=offset_[a];
+ r+=offset_[a];
return r;
}
Interval r;
if (!output)
{
- Molecule*m = brew_molecule_p();
- r = m->extent().y ();
- delete m;
+ Molecule*m = brew_molecule_p();
+ r = m->extent().y ();
+ delete m;
}
else
- r = output->extent().y ();
+ r = output->extent().y ();
return r;
}
STANDARD METHS
*/
void
-Score_elem::print()const
+Score_elem::print() const
{
#ifndef NPRINT
DOUT << name() << "{\n";
DOUT << "dets: " << dependent_size() << "dependencies: " <<
- dependency_size();
+ dependency_size();
if (offset_.x() || offset_.y ())
- DOUT << "offset (" << offset_.x() << ", " << offset_.y () <<")";
+ DOUT << "offset (" << offset_.x() << ", " << offset_.y () <<")";
DOUT << "\n";
do_print();
if (output)
- output->print();
+ output->print();
DOUT << "}\n";
#endif
Score_elem::add_processing()
{
if (status_ >= VIRGIN)
- return;
+ return;
status_ = VIRGIN;
do_add_processing();
}
Score_elem::pre_processing()
{
if (status_ >= PRECALCED)
- return;
+ return;
assert (status_ != PRECALCING); // cyclic dependency
status_ = PRECALCING;
for (int i=0; i < dependency_size(); i++)
- dependency (i)->pre_processing();
+ dependency (i)->pre_processing();
Link_array<Score_elem> extra (get_extra_dependencies());
for (int i=0; i < extra.size(); i++)
- extra[i]->pre_processing();
+ extra[i]->pre_processing();
do_pre_processing();
status_ = PRECALCED;
Score_elem::breakable_col_processing()
{
if (status_ >= PREBROKEN)
- return;
+ return;
if (status_== PREBREAKING)
{
- status_ = PREBROKEN;
- return ;
+ status_ = PREBROKEN;
+ return ;
}
status_ = PREBREAKING;
for (int i=0; i < dependency_size(); i++)
- dependency (i)->breakable_col_processing();
+ dependency (i)->breakable_col_processing();
- Link_array<Score_elem> extra (get_extra_dependencies());
+ Link_array<Score_elem> extra (get_extra_dependencies());
for (int i=0; i < extra.size(); i++)
- extra[i]->breakable_col_processing();
+ extra[i]->breakable_col_processing();
do_breakable_col_processing();
Score_elem::break_processing()
{
if (status_ >= BROKEN)
- return;
+ return;
if (status_ == BREAKING)
{
- status_ = BROKEN;
- return;
+ status_ = BROKEN;
+ return;
}
status_ = BREAKING;
for (int i=0; i < dependency_size(); i++)
- dependency (i)->break_processing();
+ dependency (i)->break_processing();
Link_array<Score_elem> extra (get_extra_dependencies());
for (int i=0; i < extra.size(); i++)
- extra[i]->break_processing();
+ extra[i]->break_processing();
Score_elem::post_processing()
{
if (status_ >= POSTCALCED)
- return;
+ return;
assert (status_ != POSTCALCING);// cyclic dependency
status_=POSTCALCING;
for (int i=0; i < dependency_size(); i++)
- dependency (i)->post_processing();
+ dependency (i)->post_processing();
Link_array<Score_elem> extra (get_extra_dependencies());
for (int i=0; i < extra.size(); i++)
- extra[i]->post_processing();
+ extra[i]->post_processing();
do_post_processing();
}
Score_elem::Status
-Score_elem::status()const
+Score_elem::status() const
{
return status_;
}
void
Score_elem::molecule_processing()
{
- if (status_ >= OUTPUT)
- return;
- status_ = OUTPUT; // do it only once.
+ if (status_ >= BREWED)
+ return;
+ status_ = BREWED; // do it only once.
for (int i=0; i < dependency_size(); i++)
- dependency (i)->molecule_processing();
+ dependency (i)->molecule_processing();
Link_array<Score_elem> extra (get_extra_dependencies());
for (int i=0; i < extra.size(); i++)
- extra[i]->molecule_processing();
+ extra[i]->molecule_processing();
if (transparent_b_)
- return ;
+ return ;
output= brew_molecule_p();
}
+String
+Score_elem::TeX_output_str() const
+{
+ String s;
+ if (status_ >= TEXOUTPUT)
+ return "";
+
+ ((Score_elem*)this)->status_ = TEXOUTPUT;
+
+ for (int i=0; i < dependency_size(); i++)
+ s += dependency (i)->TeX_output_str();
+
+ Link_array<Score_elem> extra (get_extra_dependencies());
+ for (int i=0; i < extra.size(); i++)
+ s += extra[i]->TeX_output_str ();
+
+ if (!transparent_b_)
+ s+= do_TeX_output_str();
+
+ return s;
+}
+
/*
VIRTUAL STUBS
void
Score_elem::do_unlink()
-{}
+{
+}
+
+void
+Score_elem::do_junk_links()
+{
+}
IMPLEMENT_IS_TYPE_B(Score_elem);
Molecule*
-Score_elem::brew_molecule_p()const
+Score_elem::brew_molecule_p() const
{
Atom a (paper()->lookup_l ()->fill (Box (Interval (0,0), Interval (0,0))));
return new Molecule (a);
Line_of_score *
-Score_elem::line_l()const
+Score_elem::line_l() const
{
return 0;
}
old->do_substitute_dependent (this, 0);
}
-void
-Score_elem::junk_dependencies()
-{
- while ( dependency_size())
- {
- remove_edge_out (dependency (0));
- }
-}
-
void
Score_elem::handle_broken_dependencies()
{
Line_of_score *line = line_l();
if (!line)
- return;
+ return;
Link_array<Score_elem> remove_us_arr;
for (int i=0; i < dependency_size(); i++)
{
- Score_elem * elt = dependency (i);
- if (elt->line_l() != line)
- {
- if (elt->spanner())
- {
- Spanner * sp = elt->spanner();
- Spanner * broken = sp->find_broken_piece (line);
- substitute_dependency (sp, broken);
-
- add_dependency (broken);
- }
- else if (elt->item() && elt->item ()->pcol_l_->breakpoint_b ()
- && elt->item()->break_status_i () == 0)
- {
- Item * my_item = elt->item()->find_prebroken_piece (line);
- substitute_dependency (elt, my_item);
- if (my_item)
- add_dependency (my_item);
- }
- remove_us_arr.push (elt);
- }
+ Score_elem * elt = dependency (i);
+ if (elt->line_l() != line)
+ {
+ if (elt->spanner())
+ {
+ Spanner * sp = elt->spanner();
+ Spanner * broken = sp->find_broken_piece (line);
+ substitute_dependency (sp, broken);
+
+ add_dependency (broken);
+ }
+ else if (elt->item())
+ {
+ Item * my_item = elt->item()->find_prebroken_piece (line);
+
+ substitute_dependency (elt, my_item);
+ if (my_item)
+ add_dependency (my_item);
+ }
+ remove_us_arr.push (elt);
+ }
}
remove_us_arr.default_sort();
remove_us_arr.uniq();
for (int i=0; i <remove_us_arr.size(); i++)
- remove_dependency (remove_us_arr[i]);
+ remove_dependency (remove_us_arr[i]);
status_ = BROKEN;
}
for (int i=0; i < dependency_size(); i++)
{
- Score_elem * elt = dependency (i);
- Item *it_l = elt->item();
- if (it_l && it_l->breakable_b_)
- if (item())
- {
- Score_elem *new_l = it_l->find_prebroken_piece (item()->pcol_l_);
- if (new_l != elt)
- {
- new_arr.push (new_l);
- old_arr.push (elt);
- }
- }else
+ Score_elem * elt = dependency (i);
+ Item *it_l = elt->item();
+ if (it_l && it_l->breakable_b_)
+ if (item())
+ {
+ Score_elem *new_l = it_l->find_prebroken_piece (item()->break_status_i_);
+ if (new_l != elt)
{
- new_arr.push (it_l->broken_to_a_[0]);
- old_arr.push (0);
- old_arr.push (0);
- new_arr.push (it_l->broken_to_a_[1]);
+ new_arr.push (new_l);
+ old_arr.push (elt);
}
+ }
+ else
+ {
+ new_arr.push (it_l->broken_to_drul_[LEFT]);
+ old_arr.push (0);
+ old_arr.push (0);
+ new_arr.push (it_l->broken_to_drul_[RIGHT]);
+ }
}
for (int i=0; i < old_arr.size(); i++)
- if (old_arr[i])
- substitute_dependency (old_arr[i], new_arr[i]);
+ if (old_arr[i])
+ substitute_dependency (old_arr[i], new_arr[i]);
status_ = PREBROKEN;
Score_elem::unlink_all()
{
for (int i=0; i < dependency_size(); i++)
- dependency (i)->unlink_all();
+ dependency (i)->unlink_all();
Link_array<Score_elem> extra (get_extra_dependencies());
for (int i=0; i < extra.size(); i++)
- extra[i]->unlink_all();
+ extra[i]->unlink_all();
junk_links();
- axis_group_l_a_[0] = axis_group_l_a_[1] =0;
+ axis_group_l_a_[X_AXIS] = axis_group_l_a_[Y_AXIS] =0;
+ do_unlink();
}
void
Score_elem::unlink()
{
do_unlink();
- while ( dependency_size())
+ while (dependency_size())
{
- do_substitute_dependency (dependency (0),0);
- remove_edge_out_idx (0);
+ do_substitute_dependency (dependency (0),0);
+ remove_edge_out_idx (0);
}
- while ( dependent_size())
+ while (dependent_size())
{
- dependent (0)->remove_dependency (this);
+ dependent (0)->remove_dependency (this);
}
for (int j=0; j < 2; j++)
- if ( axis_group_l_a_[j])
- axis_group_l_a_[j]->remove_element (this);
+ if (axis_group_l_a_[j])
+ axis_group_l_a_[j]->remove_element (this);
}
void
-Score_elem::OK()const
+Score_elem::OK() const
{
#ifndef NDEBUG
for (int i=0; i < dependency_size(); i++)
{
- dependency (i)->OK();
+ dependency (i)->OK();
}
#endif
}
Link_array<Score_elem>
-Score_elem::get_extra_dependencies()const
+Score_elem::get_extra_dependencies() const
{
Link_array<Score_elem> empty;
return empty;
}
+
+bool
+Score_elem::linked_b() const
+{
+ return get_extra_dependencies().size() ||
+ dependency_size();
+}
take out hard coded TeX stuff.
*/
String
-Line_of_score::TeX_string() const
+Line_of_score::TeX_output_str () const
{
- String s ("\\hbox{%<- line of score\n");
- if (error_mark_b_)
- s+= "\\scorelineerrormark";
-
-
- Real lastpos = cols[0]->hpos_f_;
- for (int i=0; i < cols.size(); i++)
- {
- PCol* col_l= cols[i];
- // all items in the current line & staff.
- String chunk_str;
-
-
- Link_array<Score_elem> elems;
-
- if (col_l->error_mark_b_)
- {
- chunk_str += String ("\\columnerrormark");
- }
-
- // now output the items.
- for (iter_top (col_l->its,j); j.ok(); j++)
- {
- elems.push (j);
- }
-
- // spanners.
- for (iter_top (col_l->starters,j); j.ok(); j++)
- {
- if (j->name() != name ())
- elems.push (j);
- }
-
- for (int j =0; j< elems.size(); j++)
- {
- Offset o = elems[j]->absolute_offset();
- o[X_AXIS] += cols[i]->hpos_f_;
- s += elems[j]->TeX_string_without_offset (o);
- }
- }
- s += "}";
- return s;
+ String s ("\\hbox{%<- line of score\n");
+ if (error_mark_b_)
+ s+= "\\scorelineerrormark";
+
+ s+= Score_elem::TeX_output_str();
+ s += "}";
+ return s;
}
}
-
-
-
IMPLEMENT_IS_TYPE_B1(Line_of_score,Spanner);
void
Line_of_score::add (Score_elem*e)
{
// avoid excess dependencies.
- if (!( e->axis_group_l_a_[0] || e->axis_group_l_a_[1]))
- add_dependency (e);
+ if (!(e->axis_group_l_a_[0] || e->axis_group_l_a_[1]))
+ add_dependency (e);
}
bool
-Line_of_score::contains_b (PCol const* c)const
+Line_of_score::contains_b (Paper_column const* c) const
{
- return cols.find_l ((PCol*)c);
+ return cols.find_l ((Paper_column*)c);
}
void
{
for (int j=0; j < breaking.size(); j++)
{
- const Array<PCol*> &curline (breaking[j].cols);
- const Array<PCol*> &errors (breaking[j].error_col_l_arr_);
- const Array<Real> &config (breaking[j].config);
+ const Array<Paper_column*> &curline (breaking[j].cols);
+ const Array<Paper_column*> &errors (breaking[j].error_col_l_arr_);
+ const Array<Real> &config (breaking[j].config);
- for (int i=0; i < errors.size(); i++)
- errors[i]->error_mark_b_ = true;
+ for (int i=0; i < errors.size(); i++)
+ errors[i]->error_mark_b_ = true;
- Line_of_score *line_l=0;
- Line_of_score *line_p =0;
-
- if (breaking.size() >1)
- {
- line_p = (Line_of_score*)clone()->spanner ();
- line_p->copy_dependencies (*this);
- line_l = line_p;
- }
- else
- line_l = this;
+ Line_of_score *line_l=0;
+ Line_of_score *line_p =0;
- ((Array<PCol*> &)line_l->cols) = curline;
- line_l->left_col_l_ = curline[0];
- line_l->right_col_l_= curline.top();
+ if (breaking.size() >1)
+ {
+ line_p = (Line_of_score*)clone()->spanner ();
+ line_l = line_p;
+ }
+ else
+ line_l = this;
- if (line_p)
- {
- pscore_l_->typeset_broken_spanner (line_p);
- broken_into_l_arr_.push (line_p);
- }
+ ((Array<Paper_column*> &)line_l->cols) = curline;
+ line_l->set_bounds(LEFT,curline[0]);
+
+ line_l->set_bounds(RIGHT,curline.top());
- for (int i=0; i < curline.size(); i++)
- {
- curline[i]->hpos_f_ = config[i];
- curline[i]->line_l_ = (Line_of_score*)line_l;
- }
+ if (line_p)
+ {
+ pscore_l_->typeset_broken_spanner (line_p);
+ broken_into_l_arr_.push (line_p);
+ }
+
+ for (int i=0; i < curline.size(); i++)
+ {
+ curline[i]->translate(config[i],X_AXIS);
+ curline[i]->line_l_ = (Line_of_score*)line_l;
+ }
}
}
+
void
Line_of_score::break_into_pieces (bool)
{
+
}
Link_array<Line_of_score>
-Line_of_score::get_lines()const
+Line_of_score::get_lines() const
{
Link_array<Line_of_score> ret;
if (broken_into_l_arr_.size())
- for (int i=0; i < broken_into_l_arr_.size(); i++)
- {
- ret.push ((Line_of_score*)broken_into_l_arr_[i]);
- }
+ for (int i=0; i < broken_into_l_arr_.size(); i++)
+ {
+ ret.push ((Line_of_score*)broken_into_l_arr_[i]);
+ }
else
- ret.push ((Line_of_score*)this); // ugh
+ ret.push ((Line_of_score*)this); // ugh
return ret;
}
void
-Line_of_score::do_print()const
+Line_of_score::do_print() const
{
Spanner::do_print();
}
Interval
-Line_of_score::do_width()const
+Line_of_score::do_width() const
{
return Spanner::do_width();
}
+
+void
+Line_of_score::do_breakable_col_processing()
+{
+ for (int i=0; i < cols.size (); i++)
+ cols[i]->breakable_col_processing();
+ Spanner::do_breakable_col_processing();
+}
void
Span_bar::do_pre_processing()
{
- if ( spanning_l_arr_.size() < 1)
+ if (spanning_l_arr_.size() < 1)
{
transparent_b_ = true;
empty_b_ =true;
transparent_b_=true;
empty_b_ = true;
}
- else if ( type_str_ == "|:")
+ else if (type_str_ == "|:")
{
type_str_ = ".|";
}
- else if ( type_str_ == ":|")
+ else if (type_str_ == ":|")
{
type_str_ = "|.";
}
Molecule*
-Span_bar::brew_molecule_p()const
+Span_bar::brew_molecule_p() const
{
Interval y_int;
for (int i=0; i < spanning_l_arr_.size(); i++)
Symbol s = get_bar_sym (y_int.length());
Molecule*output = new Molecule (Atom (s));
- output->translate ( y_int[-1], Y_AXIS);
+ output->translate (y_int[-1], Y_AXIS);
return output;
}
{
Span_bar::do_pre_processing();
- if ( break_status_i() != 1)
+ if (break_status_i() != 1)
{
empty_b_ = transparent_b_ = true;
}
Symbol
-Piano_brace::get_bar_sym (Real dy)const
+Piano_brace::get_bar_sym (Real dy) const
{
return paper()->lookup_l ()->vbrace (dy);
}
Interval
-Piano_brace::do_width()const
+Piano_brace::do_width() const
{
return Interval (0,0);
}
IMPLEMENT_IS_TYPE_B1(Spanner,Score_elem);
void
-Spanner::do_print()const
+Spanner::do_print() const
{
#ifndef NPRINT
DOUT << "Between col ";
- if ( left_col_l_)
- DOUT << left_col_l_->rank_i();
- else
- DOUT << "nop";
- DOUT << ", ";
- if ( right_col_l_)
- DOUT << right_col_l_->rank_i();
- else
- DOUT << "nop";
if (broken_into_l_arr_.size())
- DOUT << "with broken pieces\n";
+ DOUT << "with broken pieces\n";
#endif
}
void
-Spanner::break_into_pieces (bool copy_deps_b)
+Spanner::break_into_pieces ()
{
- if ( broken_into_l_arr_.size())
- return;
+ if (broken_into_l_arr_.size())
+ return;
- PCol * left = left_col_l_;
- PCol * right = right_col_l_;
- if (left->daddy_l_) left = left->daddy_l_;
- if (right->daddy_l_) right = right->daddy_l_;
+ Item * left = spanned_drul_[LEFT];
+ Item * right = spanned_drul_[RIGHT];
- Link_array<PCol> break_cols = pscore_l_->broken_col_range (left,right);
+ Link_array<Item> break_cols = pscore_l_->broken_col_range (left,right);
Link_array<Spanner> broken_into_l_arr;
break_cols.insert (left,0);
for (int i=1; i < break_cols.size(); i++)
{
- Spanner* span_p = clone()->spanner ();
- if (copy_deps_b)
- span_p->copy_dependencies (*this);
- left = break_cols[i-1];
- right = break_cols[i];
- if (!right->line_l_)
- right = right->prebreak_p_;
- if (!left->line_l_)
- left = left->postbreak_p_;
-
- assert (left&&right && left->line_l_ == right->line_l_);
-
- span_p->left_col_l_ = left;
- span_p->right_col_l_ = right;
+ Spanner* span_p = clone()->spanner ();
+ left = break_cols[i-1];
+ right = break_cols[i];
+ if (!right->line_l())
+ right = right->find_prebroken_piece(-1);
+ if (!left->line_l())
+ left = left->find_prebroken_piece(1);
+
+ assert (left&&right && left->line_l() == right->line_l());
+
+ span_p->set_bounds(LEFT,left);
+ span_p->set_bounds(RIGHT,right);
- pscore_l_->typeset_broken_spanner (span_p);
- broken_into_l_arr.push (span_p);
+ pscore_l_->typeset_broken_spanner (span_p);
+ broken_into_l_arr.push (span_p);
}
broken_into_l_arr_ = broken_into_l_arr;
void
Spanner::set_my_columns()
{
- if (!left_col_l_->line_l_)
- left_col_l_ = left_col_l_->postbreak_p_;
- if (!right_col_l_->line_l_)
- right_col_l_ = right_col_l_->prebreak_p_;
+ Direction i = (Direction)1;
+ do
+ {
+ if (!spanned_drul_[i]->line_l())
+ set_bounds(i,spanned_drul_[i]->find_prebroken_piece(-i));
+ }
+ while ((i*=-1) != 1);
}
+
void
-Spanner::do_break_processing()
+Spanner::set_bounds(Direction d, Item*i)
{
- set_my_columns();
+ if (spanned_drul_[d])
+ spanned_drul_[d]->attached_span_l_arr_.substitute(this,0);
- if (!line_l())
+ spanned_drul_[d] =i;
+ if (i)
+ i->attached_span_l_arr_.push(this);
+}
+
+void
+Spanner::do_break_processing()
+{
+ if (!line_l())
{
- break_into_pieces (true);
- for (int i=0; i < broken_into_l_arr_.size(); i++)
- broken_into_l_arr_[i]->handle_broken_dependencies();
+ break_into_pieces ();
+ for (int i=0; i < broken_into_l_arr_.size(); i++)
+ broken_into_l_arr_[i]->handle_broken_dependencies();
}
else
{
- handle_broken_dependencies();
+ handle_broken_dependencies();
}
}
Spanner::Spanner()
{
- left_col_l_ = right_col_l_ = 0;
+ spanned_drul_[LEFT]=0;
+ spanned_drul_[RIGHT]=0;
}
+String
+Spanner::do_TeX_output_str () const
+{
+ Offset left_off (spanned_drul_[LEFT]->absolute_coordinate(X_AXIS), 0);
+ return make_TeX_string (absolute_offset() + left_off);
+}
Interval
-Spanner::do_width()const
+Spanner::do_width() const
{
- Real r = right_col_l_->hpos_f_;
- Real l = left_col_l_->hpos_f_;
- assert (*left_col_l_ < *right_col_l_);
+ Real l = spanned_drul_[LEFT]->absolute_coordinate (X_AXIS);
+ Real r = spanned_drul_[RIGHT]->absolute_coordinate (X_AXIS);
assert (r>=l);
return Interval (0, r-l);
}
Line_of_score *
-Spanner::line_l()const
+Spanner::line_l() const
{
- if ( left_col_l_->line_l_ != right_col_l_->line_l_)
- return 0;
- return left_col_l_->line_l_;
+ if (!spanned_drul_[LEFT] || !spanned_drul_[RIGHT])
+ return 0;
+ if (spanned_drul_[LEFT]->line_l() != spanned_drul_[RIGHT]->line_l())
+ return 0;
+ return spanned_drul_[LEFT]->line_l();
}
Spanner*
-Spanner::find_broken_piece (Line_of_score*l)const
+Spanner::find_broken_piece (Line_of_score*l) const
{
for (int i=0; i < broken_into_l_arr_.size(); i++)
- if (broken_into_l_arr_[i]->line_l() == l)
- return broken_into_l_arr_[i];
+ if (broken_into_l_arr_[i]->line_l() == l)
+ return broken_into_l_arr_[i];
return 0;
}
bool
-Spanner::broken_b()const
+Spanner::broken_b() const
{
return broken_into_l_arr_.size();
}
+
+void
+Spanner::do_unlink()
+{
+ if (spanned_drul_[LEFT])
+ {
+ spanned_drul_[LEFT]->attached_span_l_arr_.substitute (this,0);
+ spanned_drul_[LEFT] =0;
+ }
+ if (spanned_drul_[RIGHT])
+ {
+ spanned_drul_[RIGHT]->attached_span_l_arr_.substitute (this,0);
+ spanned_drul_[RIGHT] = 0;
+ }
+}
+
+void
+Spanner::do_junk_links()
+{
+ spanned_drul_[LEFT] = spanned_drul_[RIGHT] =0;
+}
return command_l_;
}
-PCol*
+Paper_column*
Staff_info::command_pcol_l()
{
return command_l();
}
-PCol*
+Paper_column*
Staff_info::musical_pcol_l()
{
return musical_l();
if (instrument_str().length_i())
{
// staff name
- play (new Audio_text ( Audio_text::TRACK_NAME, instrument_str ()));
+ play (new Audio_text (Audio_text::TRACK_NAME, instrument_str ()));
// instrument description
play (new Audio_text (Audio_text::INSTRUMENT_NAME, instrument_str ()));
}
#include "p-col.hh"
const NO_LINES = 5;
+
void
Staff_sym_engraver::fill_staff_info (Staff_info&i)
{
Staff_sym_engraver::do_creation_processing()
{
span_p_ = new Staff_symbol (NO_LINES);
- span_p_->left_col_l_ = get_staff_info().command_pcol_l (); // ugh
+ span_p_->set_bounds(LEFT,get_staff_info().command_pcol_l ());
announce_element (Score_elem_info (span_p_, 0));
}
void
Staff_sym_engraver::do_removal_processing()
{
- span_p_->right_col_l_ = get_staff_info().command_pcol_l ();
+ span_p_->set_bounds(RIGHT,get_staff_info().command_pcol_l ());
typeset_element (span_p_);
span_p_ =0;
}
IMPLEMENT_IS_TYPE_B1(Staff_symbol,Spanner);
void
-Staff_symbol::do_print()const
+Staff_symbol::do_print() const
{
#ifndef NPRINT
Spanner::do_print();
return new Molecule (a);
}
-void
-Staff_symbol::set_extent (PCol*p1, PCol*p2)
-{
- assert (p1&&p2);
- left_col_l_ = p1;
- right_col_l_ = p2;
-}
-
Real
-Staff_symbol::inter_note_f()const
+Staff_symbol::inter_note_f() const
{
return paper()->internote_f ();
}
#include "string.hh"
String
-Super_elem::TeX_string()const
+Super_elem::TeX_output_str() const
{
String s;
for (int i=0; i < lines_arr_.size(); i++)
{
- s += lines_arr_[i]->TeX_string();
- if (i + 1<lines_arr_.size())
- s += "\\interscoreline"; // TODO
+ s += lines_arr_[i]->TeX_output_str();
+ if (i + 1<lines_arr_.size())
+ s += "\\interscoreline"; // TODO
}
return s;
}
{
lines_arr_ = line_of_score_l_->get_lines();
for (int i =0; i < lines_arr_.size(); i++)
- add_dependency (lines_arr_[i]);
+ add_dependency (lines_arr_[i]);
}
Super_elem::do_substitute_dependency (Score_elem*o,Score_elem* n)
{
if (line_of_score_l_ == o->spanner())
- line_of_score_l_ = n?(Line_of_score*)n->spanner():0;
+ line_of_score_l_ = n? (Line_of_score*) n->spanner() : 0;
}
Super_elem::Super_elem()
add_dependency (line_of_score_l_);
}
-
-
-
IMPLEMENT_IS_TYPE_B1(Super_elem,Score_elem);
String
-Symbol::str()const
+Symbol::str() const
{
return "symbol (\'"+tex+"\', (" + dim.x().str () + ", " + dim.y ().str () + "))";
}
void
-Translator::print()const
+Translator::print() const
{
}
}
Real where_f=0;
- for ( int i=0 ; i < elem_l_arr_.size(); i++)
+ for (int i=0 ; i < elem_l_arr_.size(); i++)
{
elem_l_arr_[i]->translate (- dims[i][1] - where_f, Y_AXIS);
where_f += dims[i].length();
}
bool
-Vertical_align_element::contains_b (Score_elem const *e)const
+Vertical_align_element::contains_b (Score_elem const *e) const
{
return elem_l_arr_.find_l (e);
}
(c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
*/
-
+#include "p-col.hh"
#include "vertical-align-grav.hh"
#include "vertical-align-spanner.hh"
Vertical_align_engraver::do_creation_processing()
{
valign_p_ =new Vertical_align_spanner;
- valign_p_->left_col_l_ = get_staff_info().command_pcol_l () ;
+ valign_p_->set_bounds(LEFT,get_staff_info().command_pcol_l ());
announce_element (Score_elem_info (valign_p_ , 0));
}
void
Vertical_align_engraver::do_removal_processing()
{
- valign_p_->right_col_l_ = get_staff_info().command_pcol_l ();
+ valign_p_->set_bounds(RIGHT,get_staff_info().command_pcol_l ());
typeset_element (valign_p_);
valign_p_ =0;
}
void
Vertical_align_engraver::acknowledge_element (Score_elem_info i)
{
- if ( i.origin_grav_l_arr_.size() == 2 &&
- i.elem_l_->is_type_b (Vertical_group_element::static_name()) &&
- !i.elem_l_->axis_group_l_a_[Y_AXIS] )
- {
- assert (!valign_p_->contains_b (i.elem_l_));
+ if (i.origin_grav_l_arr_.size() == 2 &&
+ i.elem_l_->is_type_b (Vertical_group_element::static_name()) &&
+ !i.elem_l_->axis_group_l_a_[Y_AXIS])
+ {
+ assert (!valign_p_->contains_b (i.elem_l_));
- valign_p_->add ( i.elem_l_);
+ valign_p_->add (i.elem_l_);
}
}
--- /dev/null
+/*
+ voice-iter.cc -- implement Voice_iterator
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "translator.hh"
+#include "debug.hh"
+#include "voice-iterator.hh"
+#include "music-list.hh"
+
+
+void
+Voice_iterator::do_print() const
+{
+ if (iter_p_)
+ iter_p_->print();
+}
+
+Voice_iterator::Voice_iterator (Voice const*v)
+ : PCursor<Music*> (v->music_p_list_)
+{
+ here_mom_ = v->offset_mom_;
+ voice_C_ = v;
+ iter_p_ =0;
+}
+
+void
+Voice_iterator::construct_children()
+{
+ while (PCursor<Music*>::ok())
+ {
+ start_next_element();
+ if (!iter_p_->ok())
+ {
+ leave_element();
+ }
+ else
+ {
+ set_voice_translator();
+ break;
+ }
+ }
+}
+
+void
+Voice_iterator::leave_element()
+{
+ delete iter_p_;
+ iter_p_ =0;
+ MInterval elt_time = ptr()->time_int ();
+ if (!elt_time.empty_b())
+ here_mom_ += elt_time.length();
+ PCursor<Music*>::next();
+}
+
+void
+Voice_iterator::start_next_element()
+{
+ assert (!iter_p_);
+ iter_p_ = get_iterator_p (ptr());
+}
+
+void
+Voice_iterator::set_voice_translator()
+{
+ if (iter_p_->report_to_l()->depth_i () > report_to_l ()->depth_i ())
+ set_translator (iter_p_->report_to_l());
+}
+
+Voice_iterator::~Voice_iterator()
+{
+ assert (! iter_p_);
+}
+
+
+IMPLEMENT_IS_TYPE_B1(Voice_iterator,Music_iterator);
+
+void
+Voice_iterator::process_and_next (Moment until)
+{
+ while (1)
+ {
+ Moment local_until = until - here_mom_;
+ while (iter_p_->ok())
+ {
+ Moment here = iter_p_->next_moment();
+ if (here != local_until)
+ goto loopexit;
+
+ iter_p_->process_and_next (local_until);
+ }
+
+ if (!iter_p_->ok())
+ {
+ leave_element();
+
+ if (PCursor<Music*>::ok())
+ {
+ start_next_element();
+ set_voice_translator();
+ }
+ else
+ {
+ goto loopexit;
+ }
+ }
+ }
+
+loopexit:
+
+ Music_iterator::process_and_next (until);
+}
+
+Moment
+Voice_iterator::next_moment() const
+{
+ return iter_p_->next_moment() + here_mom_;
+}
+
+bool
+Voice_iterator::ok() const
+{
+ return iter_p_;
+}
+
+
*/
Array<Col_hpositions>
-Word_wrap::do_solve()const
+Word_wrap::do_solve() const
{
problem_OK();
- PCursor<PCol*> curcol (pscore_l_->col_p_list_.top());
+ PCursor<Paper_column*> curcol (pscore_l_->col_p_list_.top());
Array<Col_hpositions> breaking;
Line_of_cols breakpoints (find_breaks());
assert (breakpoints.size()>=2);
int break_idx_i=0;
- while ( break_idx_i < breakpoints.size() -1)
+ while (break_idx_i < breakpoints.size() -1)
{
- Col_hpositions minimum;
- Col_hpositions current;
+ Col_hpositions minimum;
+ Col_hpositions current;
// do another line
- PCol *post = breakpoints[break_idx_i]->postbreak_p_;
- current.add (post);
- curcol++; // skip the breakable.
- break_idx_i++;
+ Paper_column *post = breakpoints[break_idx_i]->postbreak_l();
+ current.add (post);
+ curcol++; // skip the breakable.
+ break_idx_i++;
- while (break_idx_i < breakpoints.size())
- {
+ while (break_idx_i < breakpoints.size())
+ {
- // add another measure.
- while (breakpoints[break_idx_i] != curcol.ptr())
- {
- current.add (curcol);
- curcol++;
- }
- current.add (breakpoints[break_idx_i]->prebreak_p_);
-
- current.spacer_l_ = generate_spacing_problem (current.cols);
-
- // try to solve
- if (!feasible (current.cols))
- {
- if (!minimum.cols.size())
- {
- warning ("Ugh, this measure is too long, breakpoint: "
- + String (break_idx_i) +
- " (generating stupido solution)");
- current.stupid_solution();
- current.energy_f_ = - 1; // make sure we break out.
- }
- else
- current.energy_f_ = infinity_f; // make sure we go back
- }
- else
- {
+ // add another measure.
+ while (breakpoints[break_idx_i] != curcol.ptr())
+ {
+ current.add (curcol);
+ curcol++;
+ }
+ current.add (breakpoints[break_idx_i]->prebreak_l());
+
+ current.spacer_l_ = generate_spacing_problem (current.cols);
+
+ // try to solve
+ if (!feasible (current.cols))
+ {
+ if (!minimum.cols.size())
+ {
+ warning ("Ugh, this measure is too long, breakpoint: "
+ + String (break_idx_i) +
+ " (generating stupido solution)");
+ current.stupid_solution();
+ current.energy_f_ = - 1; // make sure we break out.
+ }
+ else
+ current.energy_f_ = infinity_f; // make sure we go back
+ }
+ else
+ {
- current.solve_line();
- current.print();
- }
-
- delete current.spacer_l_;
- current.spacer_l_ =0;
-
- // update minimum, or backup.
- if (current.energy_f_ < minimum.energy_f_ || current.energy_f_ < 0)
- {
- minimum = current;
- }
- else { // we're one col too far.
- break_idx_i--;
- while (curcol.ptr() != breakpoints[break_idx_i])
- curcol --;
- break; // do the next line.
- }
-
-
- // add nobreak version of breakable column
- current.cols.top()=breakpoints[break_idx_i];
- curcol ++;
- break_idx_i++;
+ current.solve_line();
+ current.print();
+ }
+
+ delete current.spacer_l_;
+ current.spacer_l_ =0;
+
+ // update minimum, or backup.
+ if (current.energy_f_ < minimum.energy_f_ || current.energy_f_ < 0)
+ {
+ minimum = current;
+ }
+ else { // we're one col too far.
+ break_idx_i--;
+ while (curcol.ptr() != breakpoints[break_idx_i])
+ curcol --;
+ break; // do the next line.
}
- *mlog << "[" <<break_idx_i<<"]"<<flush;
- breaking.push (minimum);
+
+ // add nobreak version of breakable column
+ current.cols.top()=breakpoints[break_idx_i];
+ curcol ++;
+ break_idx_i++;
+ }
+
+ *mlog << "[" <<break_idx_i<<"]"<<flush;
+ breaking.push (minimum);
}
print_stats();
return breaking;