summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlexander Valavanis <valavanisalex@gmail.com>2019-05-27 10:49:08 +0000
committerAlexander Valavanis <valavanisalex@gmail.com>2019-05-27 10:49:08 +0000
commit2998240db89caabd4c5766f7f57b9a13241f7dc9 (patch)
treef7dc546316eaa36a36a795bc073d955d77762ed7 /src
parentHackfest2019: Rm tautological tests (diff)
parentmerged in master (diff)
downloadinkscape-2998240db89caabd4c5766f7f57b9a13241f7dc9.tar.gz
inkscape-2998240db89caabd4c5766f7f57b9a13241f7dc9.zip
Hackfest2019: Rm tautological tests
Diffstat (limited to 'src')
-rw-r--r--src/inkscape-application.cpp18
-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/ui/clipboard.cpp10
5 files changed, 96 insertions, 24 deletions
diff --git a/src/inkscape-application.cpp b/src/inkscape-application.cpp
index 77734ecd4..3b034b06b 100644
--- a/src/inkscape-application.cpp
+++ b/src/inkscape-application.cpp
@@ -434,15 +434,21 @@ ConcreteInkscapeApplication<T>::get_instance()
return instance;
}
+// Note: We tried using Gio::APPLICATION_CAN_OVERRIDE_APP_ID instead of
+// Gio::APPLICATION_NON_UNIQUE. The advantages of this is that copy/paste between windows would be
+// more reliable and that we wouldn't have multiple Inkscape instance writing to the preferences
+// file at the same time (if started as separate processes). This caused problems with batch
+// processing files and with extensions as they rely on having multiple instances of Inkscape
+// running independently. In principle one can use --gapplication-app-id to run a new instance of
+// Inkscape but this with our current structure fails with the error message:
+// "g_application_set_application_id: assertion '!application->priv->is_registered' failed".
+// It also require generating new id's for each separate Inkscape instance required.
+
template<class T>
ConcreteInkscapeApplication<T>::ConcreteInkscapeApplication()
: T("org.inkscape.application.with_gui",
Gio::APPLICATION_HANDLES_OPEN | // Use default file opening.
- Gio::APPLICATION_CAN_OVERRIDE_APP_ID ) // Allows different instances of
- // Inkscape to run at same time using
- // --gapplication-app-id (useful for
- // debugging different versions of
- // Inkscape).
+ Gio::APPLICATION_NON_UNIQUE )
, InkscapeApplication()
{
@@ -590,7 +596,7 @@ ConcreteInkscapeApplication<Gtk::Application>::on_startup2()
// removed after confirming this code isn't required.
_builder = Gtk::Builder::create();
- Glib::ustring app_builder_file = get_filename(UIS, "inkscape-application.xml");
+ Glib::ustring app_builder_file = get_filename(UIS, "inkscape-application.glade");
try
{
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/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."));