summaryrefslogtreecommitdiffstats
path: root/src/live_effects
diff options
context:
space:
mode:
authorJabiertxof <jabier.arraiza@marker.es>2018-09-13 12:03:07 +0000
committerJabiertxof <jabier.arraiza@marker.es>2018-09-13 12:03:07 +0000
commitd7142b6c3a90b7606150dc65f658a6953a6006d9 (patch)
tree480ce011b2e549c80b1c66afbeebed9ced611f77 /src/live_effects
parentFix horizontal scrolling direction when using smooth scrolling (diff)
downloadinkscape-d7142b6c3a90b7606150dc65f658a6953a6006d9.tar.gz
inkscape-d7142b6c3a90b7606150dc65f658a6953a6006d9.zip
fixes and improvementes to power clip and powermask
Diffstat (limited to 'src/live_effects')
-rw-r--r--src/live_effects/lpe-powerclip.cpp396
-rw-r--r--src/live_effects/lpe-powerclip.h9
-rw-r--r--src/live_effects/lpe-powermask.cpp35
-rw-r--r--src/live_effects/lpe-powermask.h1
4 files changed, 211 insertions, 230 deletions
diff --git a/src/live_effects/lpe-powerclip.cpp b/src/live_effects/lpe-powerclip.cpp
index 9e5da13cd..f4fb15dae 100644
--- a/src/live_effects/lpe-powerclip.cpp
+++ b/src/live_effects/lpe-powerclip.cpp
@@ -2,6 +2,8 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "live_effects/lpe-powerclip.h"
+#include "live_effects/lpeobject.h"
+#include "live_effects/lpeobject-reference.h"
#include <2geom/path-intersection.h>
#include <2geom/intersection-graph.h>
#include "display/curve.h"
@@ -14,6 +16,7 @@
#include "object/sp-clippath.h"
#include "object/sp-path.h"
#include "object/sp-shape.h"
+#include "object/sp-item.h"
#include "object/sp-item-group.h"
#include "object/uri.h"
@@ -39,7 +42,6 @@ LPEPowerClip::LPEPowerClip(LivePathEffectObject *lpeobject)
registerParameter(&is_inverse);
registerParameter(&message);
message.param_set_min_height(55);
- convert_shapes = false;
}
LPEPowerClip::~LPEPowerClip() = default;
@@ -90,85 +92,26 @@ LPEPowerClip::doBeforeEffect (SPLPEItem const* lpeitem){
clip_box.appendNew<Geom::LineSegment>(bottomright);
clip_box.appendNew<Geom::LineSegment>(bottomleft);
clip_box.close();
- //clip_box *= sp_lpe_item->i2dt_affine();
+
std::vector<SPObject*> clip_path_list = clip_path->childList(true);
for ( std::vector<SPObject*>::const_iterator iter=clip_path_list.begin();iter!=clip_path_list.end();++iter) {
SPObject * clip_data = *iter;
- SPObject * clip_to_path = nullptr;
- if (SP_IS_SHAPE(clip_data) && !SP_IS_PATH(clip_data) && convert_shapes) {
- SPDocument * document = SP_ACTIVE_DOCUMENT;
- if (!document) {
- return;
- }
- Inkscape::XML::Document *xml_doc = document->getReprDoc();
- SP_SHAPE(clip_data)->removeAllPathEffects(true);
- Inkscape::XML::Node *clip_path_node = sp_selected_item_to_curved_repr(SP_ITEM(clip_data), 0);
- // remember the position of the item
- gint pos = clip_data->getRepr()->position();
- Geom::Affine affine = SP_ITEM(clip_data)->transform;
- // remember parent
- Inkscape::XML::Node *parent = clip_data->getRepr()->parent();
- // remember id
- char const *id = clip_data->getRepr()->attribute("id");
- // remember title
- gchar *title = clip_data->title();
- // remember description
- gchar *desc = clip_data->desc();
-
- // It's going to resurrect, so we delete without notifying listeners.
- clip_data->deleteObject(false);
-
- // restore id
- clip_path_node->setAttribute("id", id);
-
- // add the new repr to the parent
- parent->appendChild(clip_path_node);
- clip_to_path = document->getObjectByRepr(clip_path_node);
-
- // transform position
- SPCurve * c = nullptr;
- c = SP_SHAPE(clip_to_path)->getCurve();
- if (c) {
- Geom::PathVector c_pv = c->get_pathvector();
- c_pv *= affine;
- c->set_pathvector(c_pv);
- SP_SHAPE(clip_to_path)->setCurve(c);
- c->unref();
- }
-
- clip_path_node->setAttribute("transform", nullptr);
-
- if (title && clip_to_path) {
- clip_to_path->setTitle(title);
- g_free(title);
- }
- if (desc && clip_to_path) {
- clip_to_path->setDesc(desc);
- g_free(desc);
- }
- // move to the saved position
- clip_path_node->setPosition(pos > 0 ? pos : 0);
- Inkscape::GC::release(clip_path_node);
- clip_to_path->emitModified(SP_OBJECT_MODIFIED_CASCADE);
- }
gchar * is_inverse_str = is_inverse.param_getSVGValue();
if(!strcmp(is_inverse_str,"false") && inverse && isVisible()) {
- if (clip_to_path) {
- addInverse(SP_ITEM(clip_to_path));
- } else {
- addInverse(SP_ITEM(clip_data));
- }
- } else if(!strcmp(is_inverse_str,"true") && !inverse && isVisible()) {
- if (clip_to_path) {
- removeInverse(SP_ITEM(clip_to_path));
- } else {
- removeInverse(SP_ITEM(clip_data));
- }
- } else if (inverse && !is_visible && is_inverse_str == (Glib::ustring)"true"){
- removeInverse(SP_ITEM(clip_data));
+ SPCurve * clipcurve = new SPCurve();
+ addInverse(SP_ITEM(clip_data), clipcurve, true);
+ } else if((!strcmp(is_inverse_str,"true") && !inverse && isVisible()) ||
+ (inverse && !is_visible && is_inverse_str == (Glib::ustring)"true"))
+ {
+ removeInverse(SP_ITEM(clip_data));
+ } else if(inverse && isVisible()) {
+ updateInverse(SP_ITEM(clip_data));
}
g_free(is_inverse_str);
}
+ } else if(!hide_clip) {
+ SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem);
+ item->removeCurrentPathEffect(false);
}
}
@@ -180,16 +123,35 @@ LPEPowerClip::doAfterEffect (SPLPEItem const* lpeitem){
}
void
-LPEPowerClip::addInverse (SPItem * clip_data){
+LPEPowerClip::addInverse (SPItem * clip_data, SPCurve * clipcurve, bool root){
gchar * is_inverse_str = is_inverse.param_getSVGValue();
+ SPDocument * document = SP_ACTIVE_DOCUMENT;
+ if (!document) {
+ return;
+ }
+ SPObject *elemref = NULL;
+ if(root) {
+ Inkscape::XML::Document *xml_doc = document->getReprDoc();
+ SP_SHAPE(clip_data)->removeAllPathEffects(true);
+ Inkscape::XML::Node *clip_path_node = xml_doc->createElement("svg:path");
+ Inkscape::XML::Node *parent = clip_data->getRepr()->parent();
+ parent->appendChild(clip_path_node);
+ elemref = document->getObjectByRepr(clip_path_node);
+ elemref->setAttribute("style","fill-rule:evenodd");
+ elemref->setAttribute("id", (Glib::ustring("lpe_") + Glib::ustring(this->getLPEObj()->getId())).c_str());
+ }
if(!strcmp(is_inverse_str,"false")) {
if (SP_IS_GROUP(clip_data)) {
std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(clip_data));
for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) {
SPItem *subitem = *iter;
- addInverse(subitem);
+ addInverse(subitem, clipcurve, false);
+ if (root) {
+ Geom::Affine affine = SP_ITEM(clip_data)->transform;
+ clip_box *= affine;
+ }
}
- } else if (SP_IS_PATH(clip_data)) {
+ } else if (SP_IS_SHAPE(clip_data)) {
SPCurve * c = nullptr;
c = SP_SHAPE(clip_data)->getCurve();
if (c) {
@@ -200,33 +162,74 @@ LPEPowerClip::addInverse (SPItem * clip_data){
if (dir_a == dir_b) {
clip_box = clip_box.reversed();
}
- c_pv.push_back(clip_box);
- c->set_pathvector(c_pv);
- SP_SHAPE(clip_data)->setCurve(c);
- c->unref();
+ clipcurve->append(c, false);
gchar * is_inverse_str = is_inverse.param_getSVGValue();
if (strcmp(is_inverse_str, "true") != 0) {
is_inverse.param_setValue((Glib::ustring)"true", true);
}
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- if (desktop) {
- if (tools_isactive(desktop, TOOLS_NODES)) {
- Inkscape::Selection * sel = SP_ACTIVE_DESKTOP->getSelection();
- SPItem * item = sel->singleItem();
- if (item != nullptr) {
- sel->remove(item);
- sel->add(item);
- }
+ c->reset();
+ delete c;
+ }
+ Geom::Affine hidetrans = (Geom::Affine)Geom::Translate(0,999999);
+ SP_ITEM(clip_data)->doWriteTransform(hidetrans);
+ }
+ }
+ if(root) {
+ SPCurve * container = new SPCurve;
+ container->set_pathvector(clip_box);
+ clipcurve->append(container, false);
+ SP_SHAPE(elemref)->setCurve(clipcurve);
+ container->reset();
+ delete container;
+ }
+ g_free(is_inverse_str);
+}
+
+void
+LPEPowerClip::updateInverse (SPItem * clip_data) {
+ SPDocument * document = SP_ACTIVE_DOCUMENT;
+ if (!document) {
+ return;
+ }
+ if(inverse && isVisible()) {
+ if (SP_IS_GROUP(clip_data)) {
+ std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(clip_data));
+ for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) {
+ SPItem *subitem = *iter;
+ updateInverse(subitem);
+ }
+ } else if (SP_IS_SHAPE(clip_data)) {
+ SPObject *elemref = nullptr;
+ if (elemref = document->getObjectById(Glib::ustring("lpe_") + Glib::ustring(this->getLPEObj()->getId()))) {
+ SPCurve * c = nullptr;
+ c = SP_SHAPE(elemref)->getCurve();
+ if (c) {
+ Geom::PathVector c_pv = c->get_pathvector();
+ //TODO: this can be not correct but no better way
+ bool dir_a = Geom::path_direction(c_pv[0]);
+ bool dir_b = Geom::path_direction(clip_box);
+ if (dir_a == dir_b) {
+ clip_box = clip_box.reversed();
}
+ if(c_pv.size() > 1) {
+ c_pv.pop_back();
+ }
+ c_pv.push_back(clip_box);
+ c->set_pathvector(c_pv);
+ SP_SHAPE(elemref)->setCurve(c);
+ c->unref();
}
}
}
}
- g_free(is_inverse_str);
}
void
LPEPowerClip::removeInverse (SPItem * clip_data){
+ SPDocument * document = SP_ACTIVE_DOCUMENT;
+ if (!document) {
+ return;
+ }
gchar * is_inverse_str = is_inverse.param_getSVGValue();
if(!strcmp(is_inverse_str,"true")) {
if (SP_IS_GROUP(clip_data)) {
@@ -235,90 +238,28 @@ LPEPowerClip::removeInverse (SPItem * clip_data){
SPItem *subitem = *iter;
removeInverse(subitem);
}
- } else if (SP_IS_PATH(clip_data)) {
- SPCurve * c = nullptr;
- c = SP_SHAPE(clip_data)->getCurve();
- if (c) {
- Geom::PathVector c_pv = c->get_pathvector();
- if(c_pv.size() > 1) {
- c_pv.pop_back();
- }
- c->set_pathvector(c_pv);
- SP_SHAPE(clip_data)->setCurve(c);
- c->unref();
- gchar * is_inverse_str = is_inverse.param_getSVGValue();
- if (strcmp(is_inverse_str, "false") != 0) {
- is_inverse.param_setValue((Glib::ustring)"false", true);
- }
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- if (desktop) {
- if (tools_isactive(desktop, TOOLS_NODES)) {
- Inkscape::Selection * sel = SP_ACTIVE_DESKTOP->getSelection();
- SPItem * item = sel->singleItem();
- if (item != nullptr) {
- sel->remove(item);
- sel->add(item);
- }
- }
- }
+ } else if (SP_IS_SHAPE(clip_data)) {
+ Geom::Affine unhidetrans = (Geom::Affine)Geom::Translate(0,-999999);
+ SP_ITEM(clip_data)->doWriteTransform(unhidetrans);
+ gchar * is_inverse_str = is_inverse.param_getSVGValue();
+ if (strcmp(is_inverse_str, "false") != 0) {
+ is_inverse.param_setValue((Glib::ustring)"false", true);
}
}
+ SPObject *elemref = nullptr;
+ if (elemref = document->getObjectById(Glib::ustring("lpe_") + Glib::ustring(this->getLPEObj()->getId()))) {
+ elemref ->deleteObject(false);
+ }
}
g_free(is_inverse_str);
}
-void
-LPEPowerClip::convertShapes() {
- convert_shapes = true;
- sp_lpe_item_update_patheffect(SP_LPE_ITEM(sp_lpe_item), false, false);
-}
-
-Gtk::Widget *
-LPEPowerClip::newWidget()
-{
- // use manage here, because after deletion of Effect object, others might still be pointing to this widget.
- Gtk::VBox * vbox = Gtk::manage( new Gtk::VBox(Effect::newWidget()));
-
- vbox->set_border_width(5);
- vbox->set_homogeneous(false);
- vbox->set_spacing(6);
-
- std::vector<Parameter *>::iterator it = param_vector.begin();
- while (it != param_vector.end()) {
- if ((*it)->widget_is_visible) {
- Parameter * param = *it;
- Gtk::Widget * widg = dynamic_cast<Gtk::Widget *>(param->param_newWidget());
- Glib::ustring * tip = param->param_getTooltip();
- if (widg) {
- vbox->pack_start(*widg, true, true, 2);
- if (tip) {
- widg->set_tooltip_text(*tip);
- } else {
- widg->set_tooltip_text("");
- widg->set_has_tooltip(false);
- }
- }
- }
- ++it;
- }
- Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false,0));
- Gtk::Button * topaths_button = Gtk::manage(new Gtk::Button(Glib::ustring(_("Convert clips to paths, undoable"))));
- topaths_button->signal_clicked().connect(sigc::mem_fun (*this,&LPEPowerClip::convertShapes));
- topaths_button->set_size_request(220,30);
- hbox->pack_start(*topaths_button, false, false,2);
- vbox->pack_start(*hbox, true,true,2);
- if(Gtk::Widget* widg = defaultParamSet()) {
- vbox->pack_start(*widg, true, true, 2);
- }
- return dynamic_cast<Gtk::Widget *>(vbox);
-}
-
void
LPEPowerClip::doOnRemove (SPLPEItem const* /*lpeitem*/)
{
SPClipPath *clip_path = SP_ITEM(sp_lpe_item)->clip_ref->getObject();
- if(!keep_paths) {
- if(clip_path) {
+ if(clip_path) {
+ if(!keep_paths) {
gchar * is_inverse_str = is_inverse.param_getSVGValue();
std::vector<SPObject*> clip_path_list = clip_path->childList(true);
for ( std::vector<SPObject*>::const_iterator iter=clip_path_list.begin();iter!=clip_path_list.end();++iter) {
@@ -328,9 +269,8 @@ LPEPowerClip::doOnRemove (SPLPEItem const* /*lpeitem*/)
}
}
g_free(is_inverse_str);
- }
- } else {
- if (flatten && clip_path) {
+
+ } else if (flatten) {
clip_path->deleteObject();
}
}
@@ -338,16 +278,37 @@ LPEPowerClip::doOnRemove (SPLPEItem const* /*lpeitem*/)
Geom::PathVector
LPEPowerClip::doEffect_path(Geom::PathVector const & path_in){
- Geom::PathVector path_out = pathv_to_linear_and_cubic_beziers(path_in);
+ Geom::PathVector path_out = path_in;
+ SPClipPath *clip_path = SP_ITEM(sp_lpe_item)->clip_ref->getObject();
if (!hide_clip && flatten && isVisible()) {
- SPClipPath *clip_path = SP_ITEM(sp_lpe_item)->clip_ref->getObject();
- if(clip_path) {
- std::vector<SPObject*> clip_path_list = clip_path->childList(true);
- for ( std::vector<SPObject*>::const_iterator iter=clip_path_list.begin();iter!=clip_path_list.end();++iter) {
- SPObject * clip_data = *iter;
- flattenClip(SP_ITEM(clip_data), path_out);
+ path_out *= sp_item_transform_repr (sp_lpe_item).inverse();
+ SPDocument * document = SP_ACTIVE_DOCUMENT;
+ if (!document) {
+ return path_out;
+ }
+ SPObject *elemref = nullptr;
+ if (elemref = document->getObjectById(Glib::ustring("lpe_") + Glib::ustring(this->getLPEObj()->getId()))) {
+ SPCurve * c = nullptr;
+ c = SP_SHAPE(elemref)->getCurve();
+ if (c) {
+ Geom::PathVector c_pv = c->get_pathvector();
+ c_pv *= sp_item_transform_repr (sp_lpe_item).inverse();
+ Geom::PathIntersectionGraph *pig = new Geom::PathIntersectionGraph(c_pv, path_out);
+ if (pig && !c_pv.empty() && !path_in.empty()) {
+ path_out = pig->getIntersection();
+ }
+ c->unref();
+ }
+ } else {
+ if(clip_path) {
+ std::vector<SPObject*> clip_path_list = clip_path->childList(true);
+ for ( std::vector<SPObject*>::const_iterator iter=clip_path_list.begin();iter!=clip_path_list.end();++iter) {
+ SPObject * clip_data = *iter;
+ flattenClip(SP_ITEM(clip_data), path_out);
+ }
}
}
+ path_out *= sp_item_transform_repr (sp_lpe_item);
}
return path_out;
}
@@ -358,65 +319,22 @@ LPEPowerClip::doOnVisibilityToggled(SPLPEItem const* lpeitem)
doBeforeEffect(lpeitem);
}
-
-//void
-//LPEPowerClip::transform_multiply(Geom::Affine const& postmul, bool set)
-//{
-// SPDocument * doc = SP_ACTIVE_DOCUMENT;
-// SPClipPath *clip_path = SP_ITEM(sp_lpe_item)->clip_ref->getObject();
-// if (clip_path && lock) {
-// std::vector<SPObject*> clip_path_list = clip_path->childList(true);
-// Glib::ustring clip_id = (Glib::ustring)clip_path->getId();
-// Glib::ustring box_id = clip_id + (Glib::ustring)"_box";
-// for ( std::vector<SPObject*>::const_iterator iter=clip_path_list.begin();iter!=clip_path_list.end();++iter) {
-// SPItem * clip_data = SP_ITEM(*iter);
-// if(inverse && lock) {
-// removeInverse(clip_data);
-// }
-// if (lock) {
-// clip_data->transform *= postmul;
-//// if (!inverse) {
-//// SPDesktop *desktop = SP_ACTIVE_DESKTOP;
-//// if (desktop) {
-//// if (tools_isactive(desktop, TOOLS_NODES)) {
-//// Inkscape::Selection * sel = SP_ACTIVE_DESKTOP->getSelection();
-//// SPItem * item = sel->singleItem();
-//// if (item != NULL) {
-//// sel->remove(item);
-//// sel->add(item);
-//// }
-//// }
-//// }
-//// }
-// }
-// if(inverse && lock) {
-// doBeforeEffect(sp_lpe_item);
-// }
-// }
-// }
-// //cycle through all parameters. Most parameters will not need transformation, but path and point params
-// for (std::vector<Parameter *>::iterator it = param_vector.begin(); it != param_vector.end(); ++it) {
-// Parameter * param = *it;
-// param->param_transform_multiply(postmul, set);
-// }
-// toggleClipVisibility();
-// toggleClipVisibility();
-//}
-
void
LPEPowerClip::flattenClip(SPItem * clip_data, Geom::PathVector &path_in)
{
+ SPClipPath *clip_path = SP_ITEM(sp_lpe_item)->clip_ref->getObject();
if (SP_IS_GROUP(clip_data)) {
- std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(clip_data));
- for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) {
- SPItem *subitem = *iter;
- flattenClip(subitem, path_in);
- }
- } else if (SP_IS_PATH(clip_data)) {
+ std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(clip_data));
+ for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) {
+ SPItem *subitem = *iter;
+ flattenClip(subitem, path_in);
+ }
+ } else if (SP_IS_SHAPE(clip_data)) {
SPCurve * c = nullptr;
c = SP_SHAPE(clip_data)->getCurve();
if (c) {
Geom::PathVector c_pv = c->get_pathvector();
+ c_pv *= sp_item_transform_repr (sp_lpe_item).inverse();
Geom::PathIntersectionGraph *pig = new Geom::PathIntersectionGraph(c_pv, path_in);
if (pig && !c_pv.empty() && !path_in.empty()) {
path_in = pig->getIntersection();
@@ -439,7 +357,35 @@ void sp_inverse_powerclip(Inkscape::Selection *sel) {
lpe->getRepr()->setAttribute("inverse", "true");
lpe->getRepr()->setAttribute("flatten", "false");
lpe->getRepr()->setAttribute("hide_clip", "false");
- dynamic_cast<LPEPowerClip *>(lpe)->convertShapes();
+ }
+ }
+ }
+}
+
+void sp_remove_powerclip(Inkscape::Selection *sel) {
+ if (!sel->isEmpty()) {
+ auto selList = sel->items();
+ for(auto i = boost::rbegin(selList); i != boost::rend(selList); ++i) {
+ SPLPEItem* lpeitem = dynamic_cast<SPLPEItem*>(*i);
+ if (lpeitem) {
+ if (lpeitem->hasPathEffect() && lpeitem->pathEffectsEnabled()) {
+ for (PathEffectList::iterator it = lpeitem->path_effect_list->begin(); it != lpeitem->path_effect_list->end(); ++it)
+ {
+ LivePathEffectObject *lpeobj = (*it)->lpeobject;
+ if (!lpeobj) {
+ /** \todo Investigate the cause of this.
+ * For example, this happens when copy pasting an object with LPE applied. Probably because the object is pasted while the effect is not yet pasted to defs, and cannot be found.
+ */
+ g_warning("SPLPEItem::performPathEffect - NULL lpeobj in list!");
+ return;
+ }
+ Inkscape::LivePathEffect::Effect *lpe = lpeobj->get_lpe();
+ if (lpe->getName() == "powerclip") {
+ lpe->doOnRemove(lpeitem);
+ break;
+ }
+ }
+ }
}
}
}
diff --git a/src/live_effects/lpe-powerclip.h b/src/live_effects/lpe-powerclip.h
index 2cd3943cc..6e95ab4ab 100644
--- a/src/live_effects/lpe-powerclip.h
+++ b/src/live_effects/lpe-powerclip.h
@@ -21,14 +21,12 @@ public:
void doBeforeEffect (SPLPEItem const* lpeitem) override;
Geom::PathVector doEffect_path (Geom::PathVector const & path_in) override;
void doOnRemove (SPLPEItem const* /*lpeitem*/) override;
- Gtk::Widget * newWidget() override;
- //virtual void transform_multiply(Geom::Affine const& postmul, bool set);
void doOnVisibilityToggled(SPLPEItem const* lpeitem) override;
void doAfterEffect (SPLPEItem const* lpeitem) override;
- void addInverse (SPItem * clip_data);
+ void addInverse (SPItem * clip_data, SPCurve * clipcurve, bool root);
+ void updateInverse (SPItem * clip_data);
void removeInverse (SPItem * clip_data);
void flattenClip(SPItem * clip_data, Geom::PathVector &path_in);
- void convertShapes();
private:
HiddenParam is_inverse;
HiddenParam uri;
@@ -38,9 +36,10 @@ private:
MessageParam message;
Geom::Path clip_box;
Geom::Affine base;
- bool convert_shapes;
+ Geom::Affine lastapplyed;
};
+void sp_remove_powerclip(Inkscape::Selection *sel);
void sp_inverse_powerclip(Inkscape::Selection *sel);
} //namespace LivePathEffect
diff --git a/src/live_effects/lpe-powermask.cpp b/src/live_effects/lpe-powermask.cpp
index 72cb75dab..54168fdb5 100644
--- a/src/live_effects/lpe-powermask.cpp
+++ b/src/live_effects/lpe-powermask.cpp
@@ -2,6 +2,8 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "live_effects/lpe-powermask.h"
+#include "live_effects/lpeobject.h"
+#include "live_effects/lpeobject-reference.h"
#include <2geom/path-intersection.h>
#include <2geom/intersection-graph.h>
#include "display/curve.h"
@@ -101,6 +103,9 @@ LPEPowerMask::doBeforeEffect (SPLPEItem const* lpeitem){
mask_box.close();
setMask();
}
+ } else if(!hide_mask) {
+ SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem);
+ item->removeCurrentPathEffect(false);
}
g_free(uri_str);
}
@@ -326,6 +331,36 @@ void sp_inverse_powermask(Inkscape::Selection *sel) {
}
}
+
+void sp_remove_powermask(Inkscape::Selection *sel) {
+ if (!sel->isEmpty()) {
+ auto selList = sel->items();
+ for(auto i = boost::rbegin(selList); i != boost::rend(selList); ++i) {
+ SPLPEItem* lpeitem = dynamic_cast<SPLPEItem*>(*i);
+ if (lpeitem) {
+ if (lpeitem->hasPathEffect() && lpeitem->pathEffectsEnabled()) {
+ for (PathEffectList::iterator it = lpeitem->path_effect_list->begin(); it != lpeitem->path_effect_list->end(); ++it)
+ {
+ LivePathEffectObject *lpeobj = (*it)->lpeobject;
+ if (!lpeobj) {
+ /** \todo Investigate the cause of this.
+ * For example, this happens when copy pasting an object with LPE applied. Probably because the object is pasted while the effect is not yet pasted to defs, and cannot be found.
+ */
+ g_warning("SPLPEItem::performPathEffect - NULL lpeobj in list!");
+ return;
+ }
+ Inkscape::LivePathEffect::Effect *lpe = lpeobj->get_lpe();
+ if (lpe->getName() == "powermask") {
+ lpe->doOnRemove(lpeitem);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
}; //namespace LivePathEffect
}; /* namespace Inkscape */
diff --git a/src/live_effects/lpe-powermask.h b/src/live_effects/lpe-powermask.h
index ecf448e53..397356614 100644
--- a/src/live_effects/lpe-powermask.h
+++ b/src/live_effects/lpe-powermask.h
@@ -36,6 +36,7 @@ private:
guint32 previous_color;
};
+void sp_remove_powermask(Inkscape::Selection *sel);
void sp_inverse_powermask(Inkscape::Selection *sel);
} //namespace LivePathEffect