d2aea13d89a32957270c9967b90ca9d3ae5555f9
1 #define INKSCAPE_LPE_PATH_LENGTH_CPP
2 /** \file
3 * LPE <path_length> implementation.
4 */
5 /*
6 * Authors:
7 * Maximilian Albert <maximilian.albert@gmail.com>
8 * Johan Engelen
9 *
10 * Copyright (C) 2007-2008 Authors
11 *
12 * Released under GNU GPL, read the file 'COPYING' for more information
13 */
15 #include "live_effects/lpe-path_length.h"
17 #include "2geom/sbasis-geometric.h"
19 namespace Inkscape {
20 namespace LivePathEffect {
22 LPEPathLength::LPEPathLength(LivePathEffectObject *lpeobject) :
23 Effect(lpeobject),
24 info_text(_("Info text"), _("Parameter for text creation"), "info_text", &wr, this, "")
25 {
26 /* uncomment the next line if you want the original path to be
27 permanently displayed as a helperpath while the item is selected */
28 //show_orig_path = true;
30 registerParameter(dynamic_cast<Parameter *>(&info_text));
31 }
33 LPEPathLength::~LPEPathLength()
34 {
36 }
38 Geom::Piecewise<Geom::D2<Geom::SBasis> >
39 LPEPathLength::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in)
40 {
41 using namespace Geom;
43 gchar *arc_length = g_strdup_printf("%.2f", Geom::length(pwd2_in));
44 info_text.param_setValue(arc_length);
45 g_free(arc_length);
47 info_text.setPosAndAnchor(pwd2_in, 0.5, 20);
49 Piecewise<D2<SBasis> > A = integral(pwd2_in);
50 Point c;
51 double area;
52 if (centroid(pwd2_in, c, area)) {
53 g_print ("Area is zero\n");
54 }
55 //g_print ("Area: %f\n", area);
57 return pwd2_in;
58 }
60 } //namespace LivePathEffect
61 } /* namespace Inkscape */
63 /*
64 Local Variables:
65 mode:c++
66 c-file-style:"stroustrup"
67 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
68 indent-tabs-mode:nil
69 fill-column:99
70 End:
71 */
72 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :