#include "sp-path.h"
#include "sp-item-group.h"
#include "display/curve.h"
-#include <libnr/n-art-bpath.h>
-#include <libnr/nr-matrix-fns.h>
-#include "libnr/n-art-bpath-2geom.h"
#include "svg/svg.h"
#include "ui/widget/scalar.h"
LPEEnvelope::LPEEnvelope(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
- bend_path1(_("Top bend path"), _("Top path along which to bend the original path"), "bendpath1", &wr, this, "M0,0 L1,0"),
- bend_path2(_("Right bend path"), _("Right path along which to bend the original path"), "bendpath2", &wr, this, "M0,0 L1,0"),
- bend_path3(_("Bottom bend path"), _("Bottom path along which to bend the original path"), "bendpath3", &wr, this, "M0,0 L1,0"),
- bend_path4(_("Left bend path"), _("Left path along which to bend the original path"), "bendpath4", &wr, this, "M0,0 L1,0"),
- xx(_("Enable left & right paths"), _("Enable the left and right deformation paths"), "xx", &wr, this, true),
- yy(_("Enable top & bottom paths"), _("Enable the top and bottom deformation paths"), "yy", &wr, this, true)
+ bend_path1(_("Top bend path:"), _("Top path along which to bend the original path"), "bendpath1", &wr, this, "M0,0 L1,0"),
+ bend_path2(_("Right bend path:"), _("Right path along which to bend the original path"), "bendpath2", &wr, this, "M0,0 L1,0"),
+ bend_path3(_("Bottom bend path:"), _("Bottom path along which to bend the original path"), "bendpath3", &wr, this, "M0,0 L1,0"),
+ bend_path4(_("Left bend path:"), _("Left path along which to bend the original path"), "bendpath4", &wr, this, "M0,0 L1,0"),
+ xx(_("E_nable left & right paths"), _("Enable the left and right deformation paths"), "xx", &wr, this, true),
+ yy(_("_Enable top & bottom paths"), _("Enable the top and bottom deformation paths"), "yy", &wr, this, true)
{
registerParameter( dynamic_cast<Parameter *>(&yy) );
registerParameter( dynamic_cast<Parameter *>(&xx) );
using namespace Geom;
+ // Don't allow empty path parameters:
+ if ( bend_path1.get_pathvector().empty()
+ || bend_path2.get_pathvector().empty()
+ || bend_path3.get_pathvector().empty()
+ || bend_path4.get_pathvector().empty() )
+ {
+ return pwd2_in;
+ }
+
/*
The code below is inspired from the Bend Path code developed by jfb and mgsloan
Please, read it before tring to understand this one
n4 = force_continuity(remove_short_cuts(n4,.1));
- D2<Piecewise<SBasis> > patternd2 = make_cuts_independant(pwd2_in);
+ D2<Piecewise<SBasis> > patternd2 = make_cuts_independent(pwd2_in);
Piecewise<SBasis> x = Piecewise<SBasis>(patternd2[0]);
Piecewise<SBasis> y = Piecewise<SBasis>(patternd2[1]);
@@ -215,11 +221,16 @@ LPEEnvelope::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd
/*Of course, the result is not perfect, but on a graphical point of view, this is sufficent.*/
}
+
+ // do nothing when xx and yy are both false
+ return pwd2_in;
}
void
LPEEnvelope::resetDefaults(SPItem * item)
{
+ Effect::resetDefaults(item);
+
original_bbox(SP_LPE_ITEM(item));
Geom::Point Up_Left(boundingbox_X.min(), boundingbox_Y.min());
Geom::Path path1;
path1.start( Up_Left );
path1.appendNew<Geom::LineSegment>( Up_Right );
- bend_path1.param_set_and_write_new_value( path1.toPwSb() );
+ bend_path1.set_new_value( path1.toPwSb(), true );
Geom::Path path2;
path2.start( Up_Right );
path2.appendNew<Geom::LineSegment>( Down_Right );
- bend_path2.param_set_and_write_new_value( path2.toPwSb() );
+ bend_path2.set_new_value( path2.toPwSb(), true );
Geom::Path path3;
path3.start( Down_Left );
path3.appendNew<Geom::LineSegment>( Down_Right );
- bend_path3.param_set_and_write_new_value( path3.toPwSb() );
+ bend_path3.set_new_value( path3.toPwSb(), true );
Geom::Path path4;
path4.start( Up_Left );
path4.appendNew<Geom::LineSegment>( Down_Left );
- bend_path4.param_set_and_write_new_value( path4.toPwSb() );
-}
-
-void
-LPEEnvelope::transform_multiply(Geom::Matrix const& postmul, bool set)
-{
- // TODO: implement correct transformation instead of this default behavior
- Effect::transform_multiply(postmul, set);
+ bend_path4.set_new_value( path4.toPwSb(), true );
}