summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2019-05-26 23:05:03 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2019-05-26 23:05:03 +0000
commitdfa9b113caecfbf27f86cc0413e853f2109dafda (patch)
tree820dbd4cc8bbd52fe1b18d0532f9c93c8e76d040 /src
parentUpdate it.po (diff)
downloadinkscape-dfa9b113caecfbf27f86cc0413e853f2109dafda.tar.gz
inkscape-dfa9b113caecfbf27f86cc0413e853f2109dafda.zip
Add hide operand, work on groups and allow shapes as parameters in LPE Bool
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/effect.cpp2
-rw-r--r--src/live_effects/lpe-bool.cpp86
-rw-r--r--src/live_effects/lpe-bool.h4
-rw-r--r--src/live_effects/parameter/originalpath.cpp3
-rw-r--r--src/ui/clipboard.cpp10
5 files changed, 86 insertions, 19 deletions
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index 3db907724..f93e4400d 100644
--- a/src/live_effects/effect.cpp
+++ b/src/live_effects/effect.cpp
@@ -587,7 +587,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, N_("Cut, union, subtract, intersect and divide a path non-destructively with another path.") //description
, true //on_path
, true //on_shape
- , false //on_group
+ , true //on_group
, false //on_image
, false //on_text
, false //experimental
diff --git a/src/live_effects/lpe-bool.cpp b/src/live_effects/lpe-bool.cpp
index 7644f3b8e..cecc575fe 100644
--- a/src/live_effects/lpe-bool.cpp
+++ b/src/live_effects/lpe-bool.cpp
@@ -14,13 +14,14 @@
#include "live_effects/lpe-bool.h"
-#include "display/curve.h"
-
-#include "2geom/path.h"
+#include "2geom/affine.h"
#include "2geom/bezier-curve.h"
#include "2geom/path-sink.h"
-#include "2geom/affine.h"
+#include "2geom/path.h"
#include "2geom/svg-path-parser.h"
+#include "display/curve.h"
+#include "object/sp-shape.h"
+#include "svg/svg.h"
#include "helper/geom.h"
@@ -67,22 +68,29 @@ static const Util::EnumData<fill_typ> FillTypeDataThis[] = {
static const Util::EnumDataConverter<fill_typ> FillTypeConverterThis(FillTypeDataThis, sizeof(FillTypeDataThis) / sizeof(*FillTypeDataThis));
-LPEBool::LPEBool(LivePathEffectObject *lpeobject) :
- Effect(lpeobject),
- operand_path(_("Operand path:"), _("Operand for the boolean operation"), "operand-path", &wr, this),
- bool_operation(_("Operation:"), _("Boolean Operation"), "operation", BoolOpConverter, &wr, this, bool_op_ex_union),
- swap_operands(_("Swap operands:"), _("Swap operands (useful e.g. for difference)"), "swap-operands", &wr, this),
- rmv_inner(_("Remove inner:"), _("For cut operations: remove inner (non-contour) lines of cutting path to avoid invisible extra points"), "rmv-inner", &wr, this),
- fill_type_this(_("Fill type this:"), _("Fill type (winding mode) for this path"), "filltype-this", FillTypeConverterThis, &wr, this, fill_oddEven),
- fill_type_operand(_("Fill type operand:"), _("Fill type (winding mode) for operand path"), "filltype-operand", FillTypeConverter, &wr, this, fill_justDont)
+LPEBool::LPEBool(LivePathEffectObject *lpeobject)
+ : Effect(lpeobject)
+ , operand_path(_("Operand path:"), _("Operand for the boolean operation"), "operand-path", &wr, this)
+ , bool_operation(_("Operation:"), _("Boolean Operation"), "operation", BoolOpConverter, &wr, this, bool_op_ex_union)
+ , swap_operands(_("Swap operands:"), _("Swap operands (useful e.g. for difference)"), "swap-operands", &wr, this)
+ , hide_linked(_("Hide Linked:"), _("Hide linked path"), "hide-linked", &wr, this, true)
+ , rmv_inner(
+ _("Remove inner:"),
+ _("For cut operations: remove inner (non-contour) lines of cutting path to avoid invisible extra points"),
+ "rmv-inner", &wr, this)
+ , fill_type_this(_("Fill type this:"), _("Fill type (winding mode) for this path"), "filltype-this",
+ FillTypeConverterThis, &wr, this, fill_oddEven)
+ , fill_type_operand(_("Fill type operand:"), _("Fill type (winding mode) for operand path"), "filltype-operand",
+ FillTypeConverter, &wr, this, fill_justDont)
{
registerParameter(&operand_path);
registerParameter(&bool_operation);
registerParameter(&swap_operands);
+ registerParameter(&hide_linked);
registerParameter(&rmv_inner);
registerParameter(&fill_type_this);
registerParameter(&fill_type_operand);
-
+ prev = Geom::identity();
show_orig_path = true;
}
@@ -356,13 +364,29 @@ static fill_typ GetFillTyp(SPItem *item)
void LPEBool::doEffect(SPCurve *curve)
{
Geom::PathVector path_in = curve->get_pathvector();
-
- if (operand_path.linksToPath() && operand_path.getObject()) {
+ SPItem *operand = dynamic_cast<SPItem *>(operand_path.getObject());
+ if (operand_path.linksToPath() && operand) {
+ if (!operand->isHidden() && hide_linked) {
+ operand->setHidden(true);
+ }
+ if (operand->isHidden() && !hide_linked) {
+ operand->setHidden(false);
+ }
bool_op_ex op = bool_operation.get_value();
bool swap = swap_operands.get_value();
- Geom::PathVector path_a = swap ? operand_path.get_pathvector() : path_in;
- Geom::PathVector path_b = swap ? path_in : operand_path.get_pathvector();
+ // operand->set_transform(i2anc_affine(sp_lpe_item, sp_lpe_item->parent));
+ Geom::Affine current = sp_item_transform_repr(sp_lpe_item);
+ if (!is_load) {
+ operand->doWriteTransform(prev.inverse() * current);
+ }
+ Geom::PathVector operand_pv = operand_path.get_pathvector();
+ if (!is_load) {
+ operand_pv *= current.inverse();
+ }
+ prev = current;
+ Geom::PathVector path_a = swap ? operand_pv : path_in;
+ Geom::PathVector path_b = swap ? path_in : operand_pv;
// TODO: I would like to use the original objects fill rule if the UI selected rule is fill_justDont.
// But it doesn't seem possible to access them from here, because SPCurve is not derived from SPItem.
@@ -395,5 +419,33 @@ void LPEBool::doEffect(SPCurve *curve)
}
}
+void LPEBool::doOnRemove(SPLPEItem const * /*lpeitem*/)
+{
+ // set "keep paths" hook on sp-lpe-item.cpp
+ SPItem *operand = dynamic_cast<SPItem *>(operand_path.getObject());
+ if (operand_path.linksToPath() && operand) {
+ if (keep_paths) {
+ if (operand->isHidden()) {
+ operand->deleteObject(true);
+ }
+ } else {
+ if (operand->isHidden()) {
+ operand->setHidden(false);
+ }
+ }
+ }
+}
+
+// TODO: Migrate the tree next function to effect.cpp/h to avoid duplication
+void LPEBool::doOnVisibilityToggled(SPLPEItem const * /*lpeitem*/)
+{
+ SPItem *operand = dynamic_cast<SPItem *>(operand_path.getObject());
+ if (operand_path.linksToPath() && operand) {
+ if (!is_visible) {
+ operand->setHidden(false);
+ }
+ }
+}
+
} // namespace LivePathEffect
} /* namespace Inkscape */
diff --git a/src/live_effects/lpe-bool.h b/src/live_effects/lpe-bool.h
index 627d3194b..71933bfff 100644
--- a/src/live_effects/lpe-bool.h
+++ b/src/live_effects/lpe-bool.h
@@ -27,6 +27,8 @@ public:
void doEffect(SPCurve *curve) override;
void resetDefaults(SPItem const *item) override;
+ void doOnVisibilityToggled(SPLPEItem const * /*lpeitem*/) override;
+ void doOnRemove(SPLPEItem const * /*lpeitem*/) override;
enum bool_op_ex {
bool_op_ex_union = bool_op_union,
@@ -54,8 +56,10 @@ private:
EnumParam<bool_op_ex> bool_operation;
EnumParam<fill_typ> fill_type_this;
EnumParam<fill_typ> fill_type_operand;
+ BoolParam hide_linked;
BoolParam swap_operands;
BoolParam rmv_inner;
+ Geom::Affine prev;
};
}; //namespace LivePathEffect
diff --git a/src/live_effects/parameter/originalpath.cpp b/src/live_effects/parameter/originalpath.cpp
index dd292fee3..5430b67c1 100644
--- a/src/live_effects/parameter/originalpath.cpp
+++ b/src/live_effects/parameter/originalpath.cpp
@@ -30,11 +30,12 @@ namespace LivePathEffect {
OriginalPathParam::OriginalPathParam( const Glib::ustring& label, const Glib::ustring& tip,
const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
- Effect* effect)
+ Effect* effect, bool all)
: PathParam(label, tip, key, wr, effect, "")
{
oncanvas_editable = false;
_from_original_d = false;
+ _all = false;
}
OriginalPathParam::~OriginalPathParam()
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp
index 4fbf2af62..f96fa607e 100644
--- a/src/ui/clipboard.cpp
+++ b/src/ui/clipboard.cpp
@@ -637,6 +637,16 @@ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop)
if ( repr == nullptr ) {
repr = sp_repr_lookup_name(root, "svg:text", -1);
}
+ if (repr == nullptr) {
+ repr = sp_repr_lookup_name(root, "svg:ellipse", -1);
+ }
+ if (repr == nullptr) {
+ repr = sp_repr_lookup_name(root, "svg:rect", -1);
+ }
+ if (repr == nullptr) {
+ repr = sp_repr_lookup_name(root, "svg:circle", -1);
+ }
+
if ( repr == nullptr ) {
_userWarn(desktop, _("Clipboard does not contain a path."));