Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
lpe-path_length.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
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 v2+, read the file 'COPYING' for more information.
13 */
14
16#include "util/units.h"
17// TODO due to internal breakage in glibmm headers, this must be last:
18#include <glibmm/i18n.h>
19
20namespace Inkscape {
21namespace LivePathEffect {
22
24 Effect(lpeobject),
25 scale(_("Scale:"), _("Scaling factor"), "scale", &wr, this, 1.0),
26 info_text(this),
27 unit(_("Unit:"), _("Unit"), "unit", &wr, this),
28 display_unit(_("Display unit"), _("Print unit after path length"), "display_unit", &wr, this, true)
29{
34}
35
37
40{
41 using namespace Geom;
42
43 /* convert the measured length to the correct unit ... */
44 double lengthval = Geom::length(pwd2_in) * scale;
45 lengthval = Inkscape::Util::Quantity::convert(lengthval, "px", unit.get_abbreviation());
46
47 /* ... set it as the canvas text ... */
48 gchar *arc_length = g_strdup_printf("%.2f %s", lengthval,
51 g_free(arc_length);
52
53 info_text.setPosAndAnchor(pwd2_in, 0.5, 10);
54
55 // TODO: how can we compute the area (such that cw turns don't count negative)?
56 // should we display the area here, too, or write a new LPE for this?
57 Piecewise<D2<SBasis> > A = integral(pwd2_in);
58 Point c;
59 double area;
60 if (centroid(pwd2_in, c, area)) {
61 //g_warning ("Area is zero");
62 }
63 //g_warning ("Area: %f", area);
64 if (!this->isVisible()) {
66 }
67 return pwd2_in;
68}
69
70} //namespace LivePathEffect
71} /* namespace Inkscape */
72
73/*
74 Local Variables:
75 mode:c++
76 c-file-style:"stroustrup"
77 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
78 indent-tabs-mode:nil
79 fill-column:99
80 End:
81*/
82// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
double scale
Definition aa.cpp:228
double arc_length(double t, void *params)
Adaptor that creates 2D functions from 1D ones.
Definition d2.h:55
Function defined as discrete pieces.
Definition piecewise.h:71
Two-dimensional point that doubles as a vector.
Definition point.h:66
void registerParameter(Parameter *param)
Definition effect.cpp:1704
Geom::Piecewise< Geom::D2< Geom::SBasis > > doEffect_pwd2(Geom::Piecewise< Geom::D2< Geom::SBasis > > const &pwd2_in) override
LPEPathLength(LivePathEffectObject *lpeobject)
void setPosAndAnchor(const Geom::Piecewise< Geom::D2< Geom::SBasis > > &pwd2, const double t, const double length, bool use_curvature=false)
Definition text.cpp:72
void param_setValue(Glib::ustring newvalue)
Definition text.cpp:144
const gchar * get_abbreviation() const
Definition unit.cpp:77
static double convert(double from_dist, Unit const *from, Unit const *to)
Convert distances.
Definition units.cpp:588
double c[8][4]
LPE <path_length> implementation.
Various utility functions.
Definition affine.h:22
Coord length(LineSegment const &seg)
int centroid(std::vector< Geom::Point > const &p, Geom::Point &centroid, double &area)
polyCentroid: Calculates the centroid (xCentroid, yCentroid) and area of a polygon,...
Definition geom.cpp:366
static double area(Geom::Point a, Geom::Point b, Geom::Point c)
Bezier integral(Bezier const &a)
Definition bezier.cpp:294
Helper class to stream background task notifications as a series of messages.