- Array<Moment> shortest_playing_arr;
- Array<Moment> context_shortest_arr;
- get_ruling_durations(shortest_playing_arr, context_shortest_arr);
-
- Real interline_f = paper_l ()->interline_f ();
- Real nw_f = paper_l ()->note_width ();
-
- Array<Real> ideal_arr_;
- Array<Real> hooke_arr_;
- for (int i=0; i < cols_.size() - 1; i++){
- ideal_arr_.push (-1.0);
- hooke_arr_.push (1.0);
- }
-
- /*
- First do all non-musical columns
- */
- for (int i=0; i < cols_.size(); i++)
- {
- if (!scol_l (i)->musical_b() && i+1 < cols_.size())
- {
- Real symbol_distance =cols_[i].width_[RIGHT] + 2 PT;
- Real durational_distance = 0;
-
-
- Moment delta_t = scol_l (i+1)->when() - scol_l (i)->when () ;
-
- Real k= paper_l()->arithmetic_constant (context_shortest_arr[i]);
- /*
- ugh should use shortest_playing distance
- */
- if (delta_t)
- durational_distance = paper_l()->duration_to_dist (delta_t,k);
- symbol_distance += -cols_[i+1].width_[LEFT];
-
-
- ideal_arr_[i] = symbol_distance >? durational_distance;
- hooke_arr_[i] = 1; //2.0;
- }
- }
-
- /*
- Then musicals
- */
- for (int i=0; i < cols_.size(); i++)
- {
- if (scol_l (i)->musical_b())
- {
- Moment shortest_playing_len = shortest_playing_arr[i];
- Moment context_shortest = context_shortest_arr[i];
- if (! shortest_playing_len)
- {
- warning (_("Can't find a ruling note at ")
- +scol_l (i)->when().str ());
- shortest_playing_len = 1;
- }
- if (! context_shortest)
- {
- warning(_("No minimum in measure at ")
- + scol_l (i)->when().str ());
- context_shortest = 1;
- }
- Moment delta_t = scol_l (i+1)->when() - scol_l (i)->when ();
- Real k= paper_l()->arithmetic_constant(context_shortest);
- Real dist = paper_l()->duration_to_dist (shortest_playing_len, k);
- dist *= (double)(delta_t / shortest_playing_len);
-
- /*
- According to [Ross] and [Wanske], and from what i've seen:
-
- * whitespace at the begin of the bar should be fixed at
- (about) one interline.
- [Ross]:
- when spacing gets real tight, a smaller fixed value may be
- used, so that there are two discrete amounts of whitespace
- possible at the begin of a bar; but this is not implemented
- right now.
-
- * whitespace at the end of the bar is the normal amount of
- "hinterfleish" that would have been used, had there been
- yet another note in the bar.
- [Ross]:
- some editors argue that the bar line should not take any
- space, not to hinder the flow of music spaced around a bar
- line.
- [Ross] and [Wanske] do not suggest this, however. Further,
- it introduces some spacing problems and think that it is ugly
- too.
- [jcn]
- */
-
- /*
- first musical column of bar
- */
- if (i && scol_l (i - 1)->breakable_b_)
- {
- // fixed: probably should set minimum (rod/spring)?
- cols_[i-1].width_[RIGHT] += interline_f;
- // should adjust dist too?
- ideal_arr_[i-1] = ideal_arr_[i-1] >? interline_f;
- }
-
- /*
- last musical column of bar
- */
- if (i + 1 < cols_.size () && scol_l(i+1)->breakable_b_)
- {
- // hmm, how bout?
- dist = dist >? interline_f;
-
- /*
- uhuh, this code looks fine, already?
- someone was junking this last "hinterfleisch" whitespace?!
-
- but this seems to be fixed now :-)
- */
- // set minimum rod
- cols_[i].width_[RIGHT] += interline_f;
- }
-
- // ugh, do we need this?
- if (i < cols_.size () - 1 && !scol_l (i + 1)->musical_b ())
- {
- Real minimum = -cols_[i + 1].width_[LEFT] + cols_[i].width_[RIGHT]
- + interline_f / 2;
- dist = dist >? minimum;
- }
-
- // ugh: never let columns touch... try to set over here...
- // ugh: use j iso i triggers ice in gcc-2.7.2.3
- cols_[i].width_[LEFT] -= nw_f / 4;
- ideal_arr_[i] = dist;
- }
- }
-
- for (int i=0; i < ideal_arr_.size(); i++)
- {
- assert (ideal_arr_[i] >=0 && hooke_arr_[i] >=0);
- connect (i, i+1, ideal_arr_[i], hooke_arr_[i]);
- }