index 3b9b07c82a1ab81d820a042766917b16530c6db7..e33a160025ccf7fdbce09ddaeaf4c747371fbdbe 100644 (file)
LPEPathLength::LPEPathLength(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
+ scale(_("Scale"), _("Scaling factor"), "scale", &wr, this, 1.0),
info_text(this),
- unit(_("Unit"), _("Unit"), "unit", &wr, this)
+ unit(_("Unit"), _("Unit"), "unit", &wr, this),
+ display_unit(_("Display unit"), _("Print unit after path length"), "display_unit", &wr, this, true)
{
+ registerParameter(dynamic_cast<Parameter *>(&scale));
registerParameter(dynamic_cast<Parameter *>(&info_text));
registerParameter(dynamic_cast<Parameter *>(&unit));
+ registerParameter(dynamic_cast<Parameter *>(&display_unit));
}
LPEPathLength::~LPEPathLength()
}
+void
+LPEPathLength::hideCanvasText() {
+ // this is only used in sp-lpe-item.cpp to hide the canvas text when the effect is invisible
+ info_text.param_setValue("");
+}
+
Geom::Piecewise<Geom::D2<Geom::SBasis> >
LPEPathLength::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in)
{
using namespace Geom;
/* convert the measured length to the correct unit ... */
- double lengthval = Geom::length(pwd2_in);
+ double lengthval = Geom::length(pwd2_in) * scale;
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("%.2f %s", lengthval, success ? unit.get_abbreviation() : "px");
+ gchar *arc_length = g_strdup_printf("%.2f %s", lengthval,
+ display_unit ? (success ? unit.get_abbreviation() : "px") : "");
info_text.param_setValue(arc_length);
g_free(arc_length);