summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMaximilian Albert <maximilian.albert@gmail.com>2008-07-31 15:49:10 +0000
committercilix42 <cilix42@users.sourceforge.net>2008-07-31 15:49:10 +0000
commit1ecbdf18f775ac7de080d4797cb10c94ba419592 (patch)
tree5284ffa347ff8d0e4b6148d0c70a80a5ad1f89e9 /src
parentRemove UI stuff from internal text parameter (diff)
downloadinkscape-1ecbdf18f775ac7de080d4797cb10c94ba419592.tar.gz
inkscape-1ecbdf18f775ac7de080d4797cb10c94ba419592.zip
Add unit selector for lpe-path-length, too
(bzr r6489)
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/lpe-path_length.cpp20
-rw-r--r--src/live_effects/lpe-path_length.h3
2 files changed, 15 insertions, 8 deletions
diff --git a/src/live_effects/lpe-path_length.cpp b/src/live_effects/lpe-path_length.cpp
index d2aea13d8..7ff154412 100644
--- a/src/live_effects/lpe-path_length.cpp
+++ b/src/live_effects/lpe-path_length.cpp
@@ -13,6 +13,7 @@
*/
#include "live_effects/lpe-path_length.h"
+#include "sp-metrics.h"
#include "2geom/sbasis-geometric.h"
@@ -21,13 +22,11 @@ namespace LivePathEffect {
LPEPathLength::LPEPathLength(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
- info_text(_("Info text"), _("Parameter for text creation"), "info_text", &wr, this, "")
+ info_text(_("Info text"), _("Parameter for text creation"), "info_text", &wr, this, ""),
+ unit(_("Unit"), _("Unit"), "unit", &wr, this)
{
- /* uncomment the next line if you want the original path to be
- permanently displayed as a helperpath while the item is selected */
- //show_orig_path = true;
-
registerParameter(dynamic_cast<Parameter *>(&info_text));
+ registerParameter(dynamic_cast<Parameter *>(&unit));
}
LPEPathLength::~LPEPathLength()
@@ -40,12 +39,19 @@ LPEPathLength::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p
{
using namespace Geom;
- gchar *arc_length = g_strdup_printf("%.2f", Geom::length(pwd2_in));
+ /* convert the measured length to the correct unit ... */
+ double lengthval = Geom::length(pwd2_in);
+ gboolean success = sp_convert_distance(&lengthval, &sp_unit_get_by_id(SP_UNIT_PX), unit);
+
+ /* ... set it as the canvas text ... */
+ gchar *arc_length = g_strdup_printf("%8.2f %s", lengthval, success ? unit.get_abbreviation() : "px");
info_text.param_setValue(arc_length);
g_free(arc_length);
- info_text.setPosAndAnchor(pwd2_in, 0.5, 20);
+ info_text.setPosAndAnchor(pwd2_in, 0.5, 10);
+ // TODO: how can we compute the area (such that cw turns don't count negative)?
+ // should we display the area here, too, or write a new LPE for this?
Piecewise<D2<SBasis> > A = integral(pwd2_in);
Point c;
double area;
diff --git a/src/live_effects/lpe-path_length.h b/src/live_effects/lpe-path_length.h
index db4993df5..63f5ad397 100644
--- a/src/live_effects/lpe-path_length.h
+++ b/src/live_effects/lpe-path_length.h
@@ -8,7 +8,6 @@
/*
* Authors:
* Maximilian Albert <maximilian.albert@gmail.com>
- * Johan Engelen
*
* Copyright (C) 2007-2008 Authors
*
@@ -17,6 +16,7 @@
#include "live_effects/effect.h"
#include "live_effects/parameter/text.h"
+#include "live_effects/parameter/unit.h"
namespace Inkscape {
namespace LivePathEffect {
@@ -32,6 +32,7 @@ private:
LPEPathLength(const LPEPathLength&);
LPEPathLength& operator=(const LPEPathLength&);
TextParam info_text;
+ UnitParam unit;
};
} //namespace LivePathEffect