From 2f5eb047d9e05be5e68549ef6b75070d2faa7d2f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sat, 11 Oct 2008 11:16:23 -0400 Subject: Merging from trunk (bzr r6884) --- src/live_effects/lpe-ruler.cpp | 66 +++++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 24 deletions(-) (limited to 'src/live_effects/lpe-ruler.cpp') diff --git a/src/live_effects/lpe-ruler.cpp b/src/live_effects/lpe-ruler.cpp index 52ccc29e1..1df0e127a 100644 --- a/src/live_effects/lpe-ruler.cpp +++ b/src/live_effects/lpe-ruler.cpp @@ -19,6 +19,7 @@ #include "inkscape.h" #include "desktop.h" + namespace Inkscape { namespace LivePathEffect { @@ -110,34 +111,51 @@ LPERuler::doEffect_pwd2 (Geom::Piecewise > const & pwd2_i { using namespace Geom; - Piecewise > pwd2_arclength = arc_length_parametrization(pwd2_in); - Point A(pwd2_arclength.firstValue()); - Point B(pwd2_arclength.lastValue()); - double path_length = Geom::length(pwd2_arclength); - - Piecewise > n = -rot90(unitVector(derivative(pwd2_arclength))); - Piecewise >output(pwd2_arclength); - - if (mark_dir == MARKDIR_RIGHT) { - n *= -1.0; - } - - int j = 0; const int mminterval = static_cast(major_mark_steps); - const int j_shift = static_cast(shift) % mminterval; - - /* draw the ruler */ - if ((border_marks == BORDERMARK_START || border_marks == BORDERMARK_BOTH) && (offset != 0.0 || j_shift != 0)) - output.concat (ruler_mark(A, n.firstValue(), MARK_MAJOR)); - for (double t = offset; t < path_length; t += mark_distance, ++j) { - if ((j % mminterval) == j_shift) { - output.concat (ruler_mark(pwd2_arclength(t), n(t), MARK_MAJOR)); + const int i_shift = static_cast(shift) % mminterval; + int sign = (mark_dir == MARKDIR_RIGHT ? 1 : -1 ); + + Piecewise >output(pwd2_in); + Piecewise >speed = derivative(pwd2_in); + Piecewise arclength = arcLengthSb(pwd2_in); + double totlength = arclength.lastValue(); + + //find at which times to draw a mark: + std::vector s_cuts; + for (double s = offset; s > roots = multi_roots(arclength, s_cuts); + std::vector t_cuts; + g_warning("times:"); + for (unsigned v=0; v0) + t_cuts.push_back(roots[v][0]); + } + //draw the marks + for (unsigned i=0; i