};
/// wordwrap type algorithm
-/* el stupido. This should be optimised...
+/* el stupido. This should be optimised:
+
+ It would be nice to have a Dynamic Programming type of algorithm
+ similar to TeX's
+
*/
void
}
current.add(breakpoints[i]->prebreak );
current.setsol(solve_line(current.line));
-
+ mtor << "energy : " << current.energy << '\n';
if (current.energy < minimum.energy) {
minimum = current;
curcol ++;
i++;
}
-
+ mtor << "Adding line, next breakpoint " << i << '\n';
add_line(minimum.line, minimum.config);
}
}
#include "line.hh"
+#include "symbol.hh"
#include "cols.hh"
#include "pscore.hh"
Line_of_staff::TeXstring() const
{
String s("%line_of_staff\n\\vbox to ");
- s += String(height * VERT_TO_PT) +"pt{";
+ s += String(maxheight() * VERT_TO_PT) +"pt{";
//make some room
s += vstrut(base* VERT_TO_PT);
brokenspans.bottom().add(sp->broken_at(brokenstop, brokenstart));
}
}
+
+
+Real
+Line_of_staff::maxheight() const
+{
+ Interval y;
+ y = pstaff_->stafsym->height(scor->score->linewidth);
+ PCursor<const PCol *> cc(scor->cols);
+
+ // all items in the current line & staff.
+ for (; cc.ok(); cc++) {
+
+
+ for (PCursor<const Item *> ic(cc->its); ic.ok(); ic++) {
+ if (ic->pstaff_ == pstaff_) {
+ y.unite(ic->height());
+ }
+
+ // spanners.
+ for (PCursor<const Spanner *> sc(cc->starters); sc.ok(); sc++)
+ if (sc->pstaff_ == pstaff_)
+ assert(false);
+ }
+ }
+ return y.max;
+}
+
+
const Real PHI = (1+sqrt(5))/2;
const double ENGRAVERS_SPACE = PHI;
-const double WHOLE_SPACE = 10.0;
+const double WHOLE_SPACE = 5.0; // should be settable from input
+
Real
// see Roelofs, p. 57
return WHOLE_SPACE * pow(ENGRAVERS_SPACE, log2(d));
}
+
+
+
+
void
Score::add(Command *c)
{
- commands_.bottom().add(new Command(*c));
+ if (c->code == TYPESET && c->args[0] == "BAR") {
+ /* should be encapsulated in BREAKs
+
+ THIS SUX.
+
+ */
+ Command k;
+
+ k.when = c->when;
+ k.code = BREAK_PRE;
+ commands_.bottom().add(new Command(k));
+ commands_.bottom().add(new Command(*c));
+ k.code = BREAK_MIDDLE;
+ commands_.bottom().add(new Command(k));
+ commands_.bottom().add(new Command(*c));
+ k.code = BREAK_POST;
+ commands_.bottom().add(new Command(k));
+ k.code = BREAK_END;
+ commands_.bottom().add(new Command(k));
+ }
+ else
+ commands_.bottom().add(new Command(*c));
+
+
}
void
sc->set_output(pscore_);
sc->process();
}
+
+ // do this after processing, staffs first have to generate PCols.
do_pcols();
calc_idealspacing();
clean_cols();
OK();
// print();
pscore_->calc_breaking();
+ // TODO: calculate vertical structs
+ // TODO: calculate mixed structs.
}
// remove empty cols with no spacing attached.