2 spanner.cc -- implement Spanner
4 source file of the GNU LilyPond music typesetter
6 (c) 1996, 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
13 #include "molecule.hh"
14 #include "paper-outputter.hh"
19 Spanner::do_print() const
22 DOUT << "Between " << classname (spanned_drul_[LEFT])
23 << " and " << classname (spanned_drul_[RIGHT]) << '\n';
24 if (broken_into_l_arr_.size())
26 DOUT << "with broken pieces:\n";
27 for (int i=0; i < broken_into_l_arr_.size (); i++)
28 broken_into_l_arr_[i]->print ();
34 Spanner::break_into_pieces ()
36 if (broken_into_l_arr_.size())
39 Item * left = spanned_drul_[LEFT];
40 Item * right = spanned_drul_[RIGHT];
44 warning (_ ("left spanpoint is right spanpoint\n"));
48 Link_array<Item> break_cols = pscore_l_->broken_col_range (left,right);
49 Link_array<Spanner> broken_into_l_arr;
51 break_cols.insert (left,0);
52 break_cols.push (right);
54 for (int i=1; i < break_cols.size(); i++)
56 Spanner* span_p = dynamic_cast<Spanner*> (clone());
57 Item *left = break_cols[i-1];
58 Item *right = break_cols[i];
60 right = right->find_prebroken_piece(LEFT);
62 left = left->find_prebroken_piece(RIGHT);
64 assert (left&&right && left->line_l() == right->line_l());
66 span_p->set_bounds(LEFT,left);
67 span_p->set_bounds(RIGHT,right);
69 pscore_l_->typeset_broken_spanner (span_p);
70 broken_into_l_arr.push (span_p);
73 broken_into_l_arr_ = broken_into_l_arr;
77 Spanner::set_my_columns()
79 Direction i = (Direction)1;
82 if (!spanned_drul_[i]->line_l())
83 set_bounds(i,spanned_drul_[i]->find_prebroken_piece((Direction)-i));
85 while (flip(&i) != 1);
90 Spanner::set_bounds(Direction d, Item*i)
93 spanned_drul_[d]->attached_span_l_arr_.substitute(this,0);
97 i->attached_span_l_arr_.push(this);
99 if (spanned_drul_[Direction(-d)] == spanned_drul_[d]
101 warning (_f ("Spanner `%s\' with equal left and right spanpoints", classname (this)));
105 Spanner::do_break_processing()
109 break_into_pieces ();
110 for (int i=0; i < broken_into_l_arr_.size(); i++)
112 broken_into_l_arr_[i]->handle_broken_dependencies();
117 handle_broken_dependencies();
123 unbroken_original_l_ =0;
124 spanned_drul_[LEFT]=0;
125 spanned_drul_[RIGHT]=0;
128 Spanner::Spanner (Spanner const &s)
131 spanned_drul_[LEFT] = spanned_drul_[RIGHT] =0;
132 unbroken_original_l_ = &s;
136 Spanner::do_brew_molecule ()
140 Molecule *output= brew_molecule_p ();
141 Offset left_off (spanned_drul_[LEFT]->absolute_coordinate(X_AXIS), 0);
142 Offset o = absolute_offset() + left_off;
143 pscore_l_->outputter_l_->output_molecule (output, o, classname (this));
148 Spanner::do_width() const
150 Real l = spanned_drul_[LEFT]->absolute_coordinate (X_AXIS);
151 Real r = spanned_drul_[RIGHT]->absolute_coordinate (X_AXIS);
154 return Interval (0, r-l);
158 Spanner::line_l() const
160 if (!spanned_drul_[LEFT] || !spanned_drul_[RIGHT])
162 if (spanned_drul_[LEFT]->line_l() != spanned_drul_[RIGHT]->line_l())
164 return spanned_drul_[LEFT]->line_l();
169 Spanner::find_broken_piece (Line_of_score*l) const
171 for (int i=0; i < broken_into_l_arr_.size(); i++)
172 if (broken_into_l_arr_[i]->line_l() == l)
173 return broken_into_l_arr_[i];
179 Spanner::broken_b() const
181 return broken_into_l_arr_.size();
187 set_bounds (LEFT, 0);
188 set_bounds (RIGHT, 0);
190 if (unbroken_original_l_)
192 unbroken_original_l_->broken_into_l_arr_.substitute (this, 0);
193 unbroken_original_l_ =0;
198 Spanner::do_junk_links()
200 spanned_drul_[LEFT] = spanned_drul_[RIGHT] =0;
204 Spanner::get_rods () const
211 Spanner::do_space_processing ()
213 Array<Rod> rs (get_rods ());
214 for (int i=0; i < rs.size (); i++)
216 rs[i].add_to_cols ();