(c) 2000--2003 Jan Nieuwenhuizen <janneke@gnu.org>
*/
+#include <math.h>
+
#include "molecule.hh"
#include "item.hh"
#include "spanner.hh"
#include "warn.hh"
#include "align-interface.hh"
#include "lookup.hh"
+#include "line-interface.hh"
-#include <math.h>
-
-/*
- TODO: convert all Molecule functions to taking arguments of the form
-
- Offset FROM, Offset TO.
-
-
- TODO:
-
- Introduce line-interface that allows dots/dashes/etc. to be set as
- grob-properties. Make arbitrary paths.
-
- */
Molecule
-dashed_line_molecule (Grob *me, Real thick, Offset from, Offset to)
-{
- SCM type = me->get_grob_property ("style");
- if (type == ly_symbol2scm ("dotted-line")
- || type == ly_symbol2scm ("dashed-line"))
- {
- Real fraction = (type == ly_symbol2scm ("dotted-line")) ? 0.0 : 0.4;
-
-
- SCM s = me->get_grob_property ("dash-fraction");
- if (gh_number_p (s))
- fraction = gh_scm2double (s);
-
- fraction = (fraction >? 0) <? 1.0;
-
- Real period = Staff_symbol_referencer::staff_space (me);
- s = me->get_grob_property ("dash-period");
- if (gh_number_p (s))
- period *= gh_scm2double (s);
-
- if (period < 0)
- return Molecule ();
-
- return Lookup::dashed_line (thick, from, to, period, fraction);
- }
- else
- {
- return Lookup::line (thick, from, to);
- }
-}
-
-Molecule
-zigzag_molecule (Grob *me, Real thick,
+zigzag_molecule (Grob *me,
Offset from,
Offset to)
{
Offset dz = to -from;
Real dx = dz[X_AXIS];
Real dy = dz[Y_AXIS];
+
+ Real thick = Staff_symbol_referencer::line_thickness (me);
+ thick *= robust_scm2double (me->get_grob_property ("thickness"), 1.0); // todo: staff sym referencer?
Real staff_space = Staff_symbol_referencer::staff_space (me);
- SCM ws = me->get_grob_property ("zigzag-width");
- SCM ls = me->get_grob_property ("zigzag-length");
- double w = (gh_number_p(ws) ? gh_scm2double(ws) : 1)*staff_space;
- double l = (gh_number_p(ls) ? gh_scm2double(ls) : 1)*w;
+
+ double w = robust_scm2double (me->get_grob_property ("zigzag-width"), 1)*staff_space;
+ double l = robust_scm2double ( me->get_grob_property ("zigzag-length"), 1)* w;
double h = l>w/2 ? sqrt(l*l-w*w/4) : 0;
SCM list = scm_list_n (ly_symbol2scm ("zigzag-line"),
Molecule
-Line_spanner::line_molecule (Grob *me, Real thick,
+Line_spanner::line_molecule (Grob *me,
Offset from,
Offset to)
{
|| (type == ly_symbol2scm ("trill") && dz[Y_AXIS] != 0)))
{
return (type == ly_symbol2scm ("zigzag"))
- ? zigzag_molecule (me, thick, from, to)
- : dashed_line_molecule (me, thick, from, to);
+ ? zigzag_molecule (me, from, to)
+ : Line_interface::line (me, from, to);
}
else if (gh_symbol_p (type)
&& type == ly_symbol2scm ("trill"))
me->get_bound (RIGHT));
- Real gap = gh_scm2double (me->get_grob_property ("gap"));
+ Real gap = robust_scm2double (me->get_grob_property ("gap"), 0.0);
Offset ofxy (gap, 0); /*offset from start point to start of line*/
Offset dxy ;
Offset my_off;
Offset his_off;
- Real thick = me->get_paper ()->get_realvar (ly_symbol2scm ("linethickness"));
-
- SCM s = me->get_grob_property ("thickness");
- if (gh_number_p (s))
- thick *= gh_scm2double (s);
if (bound[RIGHT]->break_status_dir())
{
dz = (dz.length () - 2*gap) *dir;
- Molecule l (line_molecule (me, thick, Offset(0, 0), dz));
+ Molecule l (line_molecule (me, Offset(0, 0), dz));
l.translate (dir * gap + p1
- Offset (me->relative_coordinate (commonx, X_AXIS),
ofxy = dxy * (off/dxy.length ());
dxy -= 2*ofxy;
- Molecule line = line_molecule (me, thick, Offset (0,0),dxy);
+ Molecule line = line_molecule (me, Offset (0,0),dxy);
line.translate_axis (bound[LEFT]->extent (bound[LEFT], X_AXIS).length ()/2, X_AXIS);
line.translate (ofxy - my_off + his_off);
"gap is measured in staff-spaces.\n"
"The property 'type is one of: line, dashed-line, trill, dotted-line or zigzag.\n"
"\n",
- "gap dash-period dash-fraction zigzag-width zigzag-length thickness style");
+ "gap zigzag-width zigzag-length thickness");