summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2017-02-21 14:16:20 +0000
committerjabiertxof <info@marker.es>2017-02-21 14:16:20 +0000
commit960d9ec3486bc6c7a106ce78a25de4b3cac823bf (patch)
treef9e22144fd1b94b55665d8be4aa66295ec71e94e /src
parentThis patch fixes the bug #1664632. (diff)
downloadinkscape-960d9ec3486bc6c7a106ce78a25de4b3cac823bf.tar.gz
inkscape-960d9ec3486bc6c7a106ce78a25de4b3cac823bf.zip
Improvements to fill between strokes and fill between many LPE's
(bzr r15537)
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/lpe-clone-original.cpp1
-rw-r--r--src/live_effects/lpe-fill-between-many.cpp37
-rw-r--r--src/live_effects/lpe-fill-between-many.h7
-rw-r--r--src/live_effects/lpe-fill-between-strokes.cpp63
-rw-r--r--src/live_effects/lpe-fill-between-strokes.h7
-rw-r--r--src/sp-path.cpp7
6 files changed, 100 insertions, 22 deletions
diff --git a/src/live_effects/lpe-clone-original.cpp b/src/live_effects/lpe-clone-original.cpp
index b1cd6b0e5..440af6f9c 100644
--- a/src/live_effects/lpe-clone-original.cpp
+++ b/src/live_effects/lpe-clone-original.cpp
@@ -347,7 +347,6 @@ void
LPECloneOriginal::transform_multiply(Geom::Affine const& postmul, bool set)
{
if (linked_item.linksToItem()) {
- bool changed = false;
linked_item.getObject()->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
}
diff --git a/src/live_effects/lpe-fill-between-many.cpp b/src/live_effects/lpe-fill-between-many.cpp
index 2690ce160..2e1fe0dc1 100644
--- a/src/live_effects/lpe-fill-between-many.cpp
+++ b/src/live_effects/lpe-fill-between-many.cpp
@@ -4,13 +4,13 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include <gtkmm/box.h>
#include "live_effects/lpe-fill-between-many.h"
#include "display/curve.h"
#include "sp-shape.h"
#include "sp-text.h"
+#include "svg/svg.h"
// TODO due to internal breakage in glibmm headers, this must be last:
#include <glibmm/i18n.h>
@@ -20,11 +20,17 @@ namespace LivePathEffect {
LPEFillBetweenMany::LPEFillBetweenMany(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
linked_paths(_("Linked path:"), _("Paths from which to take the original path data"), "linkedpaths", &wr, this),
- fuse(_("Fuse coincident points"), _("Fuse coincident points"), "fuse", &wr, this)
+ fuse(_("Fuse coincident points"), _("Fuse coincident points"), "fuse", &wr, this, false),
+ allow_transforms(_("Allow transforms"), _("Allow transforms"), "allow_transforms", &wr, this, false),
+ join(_("Join subpaths"), _("Join subpaths"), "join", &wr, this, true),
+ close(_("Close"), _("Close path"), "close", &wr, this, true)
{
registerParameter( dynamic_cast<Parameter *>(&linked_paths) );
registerParameter( dynamic_cast<Parameter *>(&fuse) );
- //perceived_path = true;
+ registerParameter( dynamic_cast<Parameter *>(&allow_transforms) );
+ registerParameter( dynamic_cast<Parameter *>(&join) );
+ registerParameter( dynamic_cast<Parameter *>(&close) );
+ transformmultiply = false;
}
LPEFillBetweenMany::~LPEFillBetweenMany()
@@ -46,7 +52,7 @@ void LPEFillBetweenMany::doEffect (SPCurve * curve)
linked_path = (*iter)->_pathvector.front();
}
- if (!res_pathv.empty()) {
+ if (!res_pathv.empty() && join) {
linked_path = linked_path * SP_ITEM(obj)->getRelativeTransform(firstObj);
if (!are_near(res_pathv.front().finalPoint(), linked_path.initialPoint(), 0.01) || !fuse) {
res_pathv.front().appendNew<Geom::LineSegment>(linked_path.initialPoint());
@@ -56,19 +62,40 @@ void LPEFillBetweenMany::doEffect (SPCurve * curve)
res_pathv.front().append(linked_path);
} else {
firstObj = SP_ITEM(obj);
+ if (close && !join) {
+ linked_path.close();
+ }
res_pathv.push_back(linked_path);
}
}
}
- if (!res_pathv.empty()) {
+ if (!res_pathv.empty() && close) {
res_pathv.front().close();
}
if (res_pathv.empty()) {
res_pathv = curve->get_pathvector();
}
+ if(!allow_transforms && !transformmultiply) {
+ Geom::Affine affine = Geom::identity();
+ sp_svg_transform_read(SP_ITEM(sp_lpe_item)->getAttribute("transform"), &affine);
+ res_pathv *= affine.inverse();
+ }
+ if(transformmultiply) {
+ transformmultiply = false;
+ }
curve->set_pathvector(res_pathv);
}
+void
+LPEFillBetweenMany::transform_multiply(Geom::Affine const& postmul, bool set)
+{
+ if(!allow_transforms && sp_lpe_item) {
+ SP_ITEM(sp_lpe_item)->transform *= postmul.inverse();
+ transformmultiply = true;
+ sp_lpe_item_update_patheffect(sp_lpe_item, false, false);
+ }
+}
+
} // namespace LivePathEffect
} /* namespace Inkscape */
diff --git a/src/live_effects/lpe-fill-between-many.h b/src/live_effects/lpe-fill-between-many.h
index 552c8037d..fe824e936 100644
--- a/src/live_effects/lpe-fill-between-many.h
+++ b/src/live_effects/lpe-fill-between-many.h
@@ -19,13 +19,16 @@ class LPEFillBetweenMany : public Effect {
public:
LPEFillBetweenMany(LivePathEffectObject *lpeobject);
virtual ~LPEFillBetweenMany();
-
+ virtual void transform_multiply(Geom::Affine const& postmul, bool set);
virtual void doEffect (SPCurve * curve);
private:
OriginalPathArrayParam linked_paths;
BoolParam fuse;
-
+ BoolParam allow_transforms;
+ BoolParam join;
+ BoolParam close;
+ bool transformmultiply;
private:
LPEFillBetweenMany(const LPEFillBetweenMany&);
LPEFillBetweenMany& operator=(const LPEFillBetweenMany&);
diff --git a/src/live_effects/lpe-fill-between-strokes.cpp b/src/live_effects/lpe-fill-between-strokes.cpp
index 8dc55357f..43fef4288 100644
--- a/src/live_effects/lpe-fill-between-strokes.cpp
+++ b/src/live_effects/lpe-fill-between-strokes.cpp
@@ -8,6 +8,7 @@
#include "display/curve.h"
#include "sp-shape.h"
#include "sp-text.h"
+#include "svg/svg.h"
// TODO due to internal breakage in glibmm headers, this must be last:
#include <glibmm/i18n.h>
@@ -19,15 +20,19 @@ LPEFillBetweenStrokes::LPEFillBetweenStrokes(LivePathEffectObject *lpeobject) :
linked_path(_("Linked path:"), _("Path from which to take the original path data"), "linkedpath", &wr, this),
second_path(_("Second path:"), _("Second path from which to take the original path data"), "secondpath", &wr, this),
reverse_second(_("Reverse Second"), _("Reverses the second path order"), "reversesecond", &wr, this),
- close(_("Close path"), _("Close path"), "close", &wr, this),
- fuse(_("Fuse coincident points"), _("Fuse coincident points"), "fuse", &wr, this)
+ fuse(_("Fuse coincident points"), _("Fuse coincident points"), "fuse", &wr, this, false),
+ allow_transforms(_("Allow transforms"), _("Allow transforms"), "allow_transforms", &wr, this, false),
+ join(_("Join subpaths"), _("Join subpaths"), "join", &wr, this, true),
+ close(_("Close"), _("Close path"), "close", &wr, this, true)
{
registerParameter( dynamic_cast<Parameter *>(&linked_path) );
registerParameter( dynamic_cast<Parameter *>(&second_path) );
registerParameter( dynamic_cast<Parameter *>(&reverse_second) );
- registerParameter( dynamic_cast<Parameter *>(&close) );
registerParameter( dynamic_cast<Parameter *>(&fuse) );
- //perceived_path = true;
+ registerParameter( dynamic_cast<Parameter *>(&allow_transforms) );
+ registerParameter( dynamic_cast<Parameter *>(&join) );
+ registerParameter( dynamic_cast<Parameter *>(&close) );
+ transformmultiply = false;
}
LPEFillBetweenStrokes::~LPEFillBetweenStrokes()
@@ -38,6 +43,13 @@ LPEFillBetweenStrokes::~LPEFillBetweenStrokes()
void LPEFillBetweenStrokes::doEffect (SPCurve * curve)
{
if (curve) {
+ Geom::Affine affine = Geom::identity();
+ if(!allow_transforms && !transformmultiply) {
+ sp_svg_transform_read(SP_ITEM(sp_lpe_item)->getAttribute("transform"), &affine);
+ }
+ if(transformmultiply) {
+ transformmultiply = false;
+ }
if ( linked_path.linksToPath() && second_path.linksToPath() && linked_path.getObject() && second_path.getObject() ) {
Geom::PathVector linked_pathv = linked_path.get_pathvector();
Geom::PathVector second_pathv = second_path.get_pathvector();
@@ -58,19 +70,30 @@ void LPEFillBetweenStrokes::doEffect (SPCurve * curve)
if (reverse_second.get_value()) {
result_second_pathv.front() = result_second_pathv.front().reversed();
}
- if (!are_near(result_linked_pathv.front().finalPoint(), result_second_pathv.front().initialPoint(),0.01) || !fuse) {
- result_linked_pathv.front().appendNew<Geom::LineSegment>(result_second_pathv.front().initialPoint());
+ if (join) {
+ if (!are_near(result_linked_pathv.front().finalPoint(), result_second_pathv.front().initialPoint(),0.01) || !fuse) {
+ result_linked_pathv.front().appendNew<Geom::LineSegment>(result_second_pathv.front().initialPoint());
+ } else {
+ result_second_pathv.front().setInitial(result_linked_pathv.front().finalPoint());
+ }
+ result_linked_pathv.front().append(result_second_pathv.front());
+ if (close) {
+ result_linked_pathv.front().close();
+ }
} else {
- result_second_pathv.front().setInitial(result_linked_pathv.front().finalPoint());
- }
- result_linked_pathv.front().append(result_second_pathv.front());
- if (close) {
- result_linked_pathv.front().close();
+ if (close) {
+ result_linked_pathv.front().close();
+ result_second_pathv.front().close();
+ }
+ result_linked_pathv.push_back(result_second_pathv.front());
}
+ result_linked_pathv *= affine.inverse();
curve->set_pathvector(result_linked_pathv);
} else if ( !result_linked_pathv.empty() ) {
+ result_linked_pathv *= affine.inverse();
curve->set_pathvector(result_linked_pathv);
} else if ( !result_second_pathv.empty() ) {
+ result_second_pathv *= affine.inverse();
curve->set_pathvector(result_second_pathv);
}
}
@@ -83,6 +106,10 @@ void LPEFillBetweenStrokes::doEffect (SPCurve * curve)
result_pathv.push_back((*iter));
}
if ( !result_pathv.empty() ) {
+ result_pathv *= affine.inverse();
+ if (close) {
+ result_pathv.front().close();
+ }
curve->set_pathvector(result_pathv);
}
}
@@ -95,12 +122,26 @@ void LPEFillBetweenStrokes::doEffect (SPCurve * curve)
result_pathv.push_back((*iter));
}
if ( !result_pathv.empty() ) {
+ result_pathv *= affine.inverse();
+ if (close) {
+ result_pathv.front().close();
+ }
curve->set_pathvector(result_pathv);
}
}
}
}
+void
+LPEFillBetweenStrokes::transform_multiply(Geom::Affine const& postmul, bool set)
+{
+ if(!allow_transforms && sp_lpe_item) {
+ SP_ITEM(sp_lpe_item)->transform *= postmul.inverse();
+ transformmultiply = true;
+ sp_lpe_item_update_patheffect(sp_lpe_item, false, false);
+ }
+}
+
} // namespace LivePathEffect
} /* namespace Inkscape */
diff --git a/src/live_effects/lpe-fill-between-strokes.h b/src/live_effects/lpe-fill-between-strokes.h
index 14eb9167c..5bbd6e7da 100644
--- a/src/live_effects/lpe-fill-between-strokes.h
+++ b/src/live_effects/lpe-fill-between-strokes.h
@@ -19,15 +19,18 @@ class LPEFillBetweenStrokes : public Effect {
public:
LPEFillBetweenStrokes(LivePathEffectObject *lpeobject);
virtual ~LPEFillBetweenStrokes();
-
+ virtual void transform_multiply(Geom::Affine const& postmul, bool set);
virtual void doEffect (SPCurve * curve);
private:
OriginalPathParam linked_path;
OriginalPathParam second_path;
BoolParam reverse_second;
- BoolParam close;
BoolParam fuse;
+ BoolParam allow_transforms;
+ BoolParam join;
+ BoolParam close;
+ bool transformmultiply;
private:
LPEFillBetweenStrokes(const LPEFillBetweenStrokes&);
diff --git a/src/sp-path.cpp b/src/sp-path.cpp
index b593b7937..c6ec5559e 100644
--- a/src/sp-path.cpp
+++ b/src/sp-path.cpp
@@ -292,9 +292,14 @@ Geom::Affine SPPath::set_transform(Geom::Affine const &transform) {
// Transform the original-d path if this is a valid LPE this, other else the (ordinary) path
if (_curve_before_lpe && hasPathEffectRecursive()) {
- if (this->hasPathEffectOfType(Inkscape::LivePathEffect::CLONE_ORIGINAL) || this->hasPathEffectOfType(Inkscape::LivePathEffect::BEND_PATH)) {
+ if (this->hasPathEffectOfType(Inkscape::LivePathEffect::CLONE_ORIGINAL) ||
+ this->hasPathEffectOfType(Inkscape::LivePathEffect::BEND_PATH) ||
+ this->hasPathEffectOfType(Inkscape::LivePathEffect::FILL_BETWEEN_MANY) ||
+ this->hasPathEffectOfType(Inkscape::LivePathEffect::FILL_BETWEEN_STROKES) )
+ {
// if path has the CLONE_ORIGINAL LPE applied, don't write the transform to the pathdata, but write it 'unoptimized'
// also if the effect is type BEND PATH to fix bug #179842
+ this->adjust_livepatheffect(transform);
return transform;
} else {
_curve_before_lpe->transform(transform);