summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2014-09-29 01:44:50 +0000
committerJabiertxof <jtx@jtx.marker.es>2014-09-29 01:44:50 +0000
commitb2514a837cdb7f41b6928baf9fd8678b388bbc08 (patch)
treed986c16e60334edd1d655a481152d3e090dd8a0a /src
parentFillet-Chamfer update. Two things. (diff)
downloadinkscape-b2514a837cdb7f41b6928baf9fd8678b388bbc08.tar.gz
inkscape-b2514a837cdb7f41b6928baf9fd8678b388bbc08.zip
Add helper paths to BSPline
(bzr r13341.1.226)
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/lpe-bspline.cpp33
-rw-r--r--src/live_effects/lpe-bspline.h4
2 files changed, 37 insertions, 0 deletions
diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp
index eb0604273..5dfad95dc 100644
--- a/src/live_effects/lpe-bspline.cpp
+++ b/src/live_effects/lpe-bspline.cpp
@@ -80,6 +80,13 @@ LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) :
LPEBSpline::~LPEBSpline() {}
+void LPEBSpline::doBeforeEffect (SPLPEItem const* lpeitem)
+{
+ if(!hp.empty()){
+ hp.clear();
+ }
+}
+
void LPEBSpline::createAndApply(const char *name, SPDocument *doc, SPItem *item)
{
if (!SP_IS_SHAPE(item)) {
@@ -109,6 +116,11 @@ void LPEBSpline::doEffect(SPCurve *curve)
Geom::PathVector const original_pathv = curve->get_pathvector();
curve->reset();
+ double radiusHelperNodes = 6.0;
+ if (SP_ACTIVE_DESKTOP) {
+ radiusHelperNodes /= SP_ACTIVE_DESKTOP->current_zoom();
+ }
+
for (Geom::PathVector::const_iterator path_it = original_pathv.begin();
path_it != original_pathv.end(); ++path_it) {
if (path_it->empty())
@@ -228,6 +240,9 @@ void LPEBSpline::doEffect(SPCurve *curve)
node = curve_it1->finalPoint();
}
nCurve->curveto(pointAt1, pointAt2, node);
+ if(!are_near(node,curve_it1->finalPoint())){
+ drawHandle(node, radiusHelperNodes);
+ }
}
++curve_it1;
++curve_it2;
@@ -239,9 +254,27 @@ void LPEBSpline::doEffect(SPCurve *curve)
curve->append(nCurve, false);
nCurve->reset();
delete nCurve;
+ Geom::PathVector const pathv = curve->get_pathvector();
+ hp.push_back(pathv[0]);
}
}
+void
+LPEBSpline::drawHandle(Geom::Point p, double radiusHelperNodes)
+{
+ char const * svgd = "M 1,0.5 A 0.5,0.5 0 0 1 0.5,1 0.5,0.5 0 0 1 0,0.5 0.5,0.5 0 0 1 0.5,0 0.5,0.5 0 0 1 1,0.5 Z";
+ Geom::PathVector pathv = sp_svg_read_pathv(svgd);
+ pathv *= Geom::Affine(radiusHelperNodes,0,0,radiusHelperNodes,0,0);
+ pathv += p - Geom::Point(0.5*radiusHelperNodes, 0.5*radiusHelperNodes);
+ hp.push_back(pathv[0]);
+}
+
+void
+LPEBSpline::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec)
+{
+ hp_vec.push_back(hp);
+}
+
Gtk::Widget *LPEBSpline::newWidget()
{
// use manage here, because after deletion of Effect object, others might
diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h
index f37741a4a..e066015ad 100644
--- a/src/live_effects/lpe-bspline.h
+++ b/src/live_effects/lpe-bspline.h
@@ -24,6 +24,9 @@ public:
return SUPPRESS_FLASH;
}
virtual void doEffect(SPCurve *curve);
+ virtual void doBeforeEffect(SPLPEItem const* lpeitem);
+ void drawHandle(Geom::Point p, double radiusHelperNodes);
+ void addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec);
void doBSplineFromWidget(SPCurve *curve, double value);
bool nodeIsSelected(Geom::Point nodePoint);
@@ -43,6 +46,7 @@ private:
BoolParam ignoreCusp;
BoolParam onlySelected;
ScalarParam weight;
+ Geom::PathVector hp;
LPEBSpline(const LPEBSpline &);
LPEBSpline &operator=(const LPEBSpline &);