+2005-04-18 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ * lily/paper-score.cc (process): run get_paper_systems() only once.
+
+ * lily/line-interface.cc (make_arrow): new function. Patch by
+ Jonatan Liljedahl <http://kymatica.com>
+ (arrows): idem.
+
+ * lily/line-spanner.cc (line_stencil): add arrows.
+
+
2005-04-18 Mathieu Giraud <magiraud@free.fr>
* input/test/chord-names-german.ly: update for italian/french chords
Heikki Junes
Jeff Smith
John Williams
+Jonatan Liljedahl
Juergen Reuter
Juliusz Chroboczek
Matthias Neeracher
static bool has_interface (Grob *);
static Stencil make_dashed_line (Real th, Offset from, Offset to, Real, Real);
static Stencil make_line (Real th, Offset from, Offset to);
+ static Stencil make_arrow (Offset beg, Offset end, Real thick,
+ Real length, Real width);
+ static Stencil arrows (Grob *me, Offset from, Offset to,
+ bool from_arrow,
+ bool to_arrow);
+
};
#endif /* LINE_INTERFACE_HH */
Output_def *layout_;
System *system_;
SCM systems_;
+ SCM paper_systems_;
public:
Paper_score (Output_def *);
#include "lookup.hh"
#include "output-def.hh"
+Stencil
+Line_interface::make_arrow (Offset beg, Offset end,
+ Real thick,
+ Real length, Real width)
+{
+ Real angle = (end - beg).arg();
+ Array<Offset> points;
+
+ //construct the arrow
+ points.push (Offset (0, 0));
+ points.push (Offset (length, width));
+ points.push (Offset (length, -width));
+
+ // rotate and translate the arrow
+ for (int i = 0; i < points.size(); i++)
+ points[i] = points[i] * complex_exp (Offset (0, angle)) + beg;
+
+ // we must shorten the line half of arrow length
+ // to prevent the line from sticking out
+ beg = beg + Offset (length/2,0) * complex_exp (Offset (0, angle));
+
+ return (Lookup::round_filled_polygon (points, thick));
+}
+
Stencil
Line_interface::make_dashed_line (Real thick, Offset from, Offset to,
Real dash_period, Real dash_fraction)
return Stencil (box, at);
}
+Stencil
+Line_interface::arrows (Grob *me, Offset from, Offset to,
+ bool from_arrow,
+ bool to_arrow)
+{
+ Stencil a;
+ if (from_arrow || to_arrow)
+ {
+ Real thick = Staff_symbol_referencer::line_thickness (me)
+ * robust_scm2double (me->get_property ("thickness"), 1);
+ Real len = robust_scm2double (me->get_property ("arrow-length"), 1.3);
+ Real wid = robust_scm2double (me->get_property ("arrow-width"), 0.5);
+
+ if (to_arrow)
+ a.add_stencil (make_arrow (from, to, thick, len, wid));
+
+ if (from_arrow)
+ a.add_stencil (make_arrow (to, from, thick, len, wid));
+ }
+
+ return a;
+}
+
+
Stencil
Line_interface::line (Grob *me, Offset from, Offset to)
{
SCM type = me->get_property ("style");
+ Stencil l;
+
SCM dash_fraction = me->get_property ("dash-fraction");
if (scm_is_number (dash_fraction) || type == ly_symbol2scm ("dotted-line"))
{
if (period < 0)
return Stencil ();
- return make_dashed_line (thick, from, to, period, fraction);
+ l = make_dashed_line (thick, from, to, period, fraction);
}
else
{
- return make_line (thick, from, to);
+ l = make_line (thick, from, to);
}
+
+ return l;
}
ADD_INTERFACE (Line_interface, "line-interface",
"produced. If @code{dash-fraction} is negative, the line is made "
"transparent.",
- "dash-period dash-fraction thickness style")
+ "dash-period dash-fraction thickness style arrow-length arrow-width")
{
Offset dz = to -from;
SCM type = me->get_property ("style");
+
+ Stencil line;
+
if (scm_is_symbol (type)
&& (type == ly_symbol2scm ("line")
|| type == ly_symbol2scm ("dashed-line")
|| type == ly_symbol2scm ("zigzag")
|| (type == ly_symbol2scm ("trill") && dz[Y_AXIS] != 0)))
{
- return (type == ly_symbol2scm ("zigzag"))
+ line = (type == ly_symbol2scm ("zigzag"))
? zigzag_stencil (me, from, to)
: Line_interface::line (me, from, to);
}
+ mol.extent (Y_AXIS).length ()) / 2, Y_AXIS);
mol.translate (from);
- return mol;
+ line = mol;
}
+
+ if (to_boolean (me->get_property ("arrow")))
+ line.add_stencil (Line_interface::arrows (me, from, to, false, true));
+
return Stencil ();
}
"@code{dashed-line}, @code{trill}, \n"
"@code{dotted-line} or @code{zigzag}.\n"
"\n",
- "gap zigzag-width zigzag-length thickness");
+ "gap zigzag-width zigzag-length thickness arrow");
layout_ = layout;
system_ = 0;
systems_ = SCM_EOL;
+ paper_systems_ = SCM_EOL;
}
Paper_score::Paper_score (Paper_score const &s)
Paper_score::derived_mark () const
{
scm_gc_mark (systems_);
+ scm_gc_mark (paper_systems_);
}
void
Array<Column_x_positions> breaking = calc_breaking ();
system_->break_into_pieces (breaking);
- system_->get_paper_systems ();
+
+ paper_systems_ = system_->get_paper_systems ();
}
System *
SCM
Paper_score::get_systems () const
{
- return root_system ()->get_paper_systems ();
+ return paper_systems_;
}
if (!span_points.is_empty ())
{
- Stencil l = Line_spanner::line_stencil (me, Offset (span_points[LEFT], 0),
+ Stencil l = Line_spanner::line_stencil (me,
+ Offset (span_points[LEFT], 0),
Offset (span_points[RIGHT], 0));
m.add_stencil (l);
}
dash-period. Should be between 0.0 (no line) and 1.0 (continuous
line).")
+ (arrow ,boolean? "Add an arrow to the line.")
+ (arrow-length ,number? "Arrow length.")
+ (arrow-width ,number? "Arrow width.")
+
;; todo: why is this tunable?
(dir-function ,procedure? "The function to determine the
direction of a beam. Choices include: