summaryrefslogtreecommitdiffstats
path: root/src/object
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/object
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/object')
-rw-r--r--src/object/sp-clippath.cpp9
-rw-r--r--src/object/sp-clippath.h18
-rw-r--r--src/object/sp-ellipse.cpp1
-rw-r--r--src/object/sp-item.cpp2
-rw-r--r--src/object/sp-item.h2
-rw-r--r--src/object/sp-lpe-item.cpp45
-rw-r--r--src/object/sp-mask.cpp7
-rw-r--r--src/object/sp-mask.h9
-rw-r--r--src/object/sp-path.cpp1
-rw-r--r--src/object/sp-spiral.cpp1
-rw-r--r--src/object/sp-star.cpp1
11 files changed, 61 insertions, 35 deletions
diff --git a/src/object/sp-clippath.cpp b/src/object/sp-clippath.cpp
index 321f6a80f..f06ac2c11 100644
--- a/src/object/sp-clippath.cpp
+++ b/src/object/sp-clippath.cpp
@@ -15,8 +15,6 @@
#include <cstring>
#include <string>
-#include "display/drawing.h"
-#include "display/drawing-group.h"
#include "xml/repr.h"
#include "enums.h"
@@ -31,13 +29,6 @@
#include "sp-item.h"
#include "sp-defs.h"
-struct SPClipPathView {
- SPClipPathView *next;
- unsigned int key;
- Inkscape::DrawingItem *arenaitem;
- Geom::OptRect bbox;
-};
-
static SPClipPathView* sp_clippath_view_new_prepend(SPClipPathView *list, unsigned int key, Inkscape::DrawingItem *arenaitem);
static SPClipPathView* sp_clippath_view_list_remove(SPClipPathView *list, SPClipPathView *view);
diff --git a/src/object/sp-clippath.h b/src/object/sp-clippath.h
index 57c3cf855..2c07fe5d1 100644
--- a/src/object/sp-clippath.h
+++ b/src/object/sp-clippath.h
@@ -15,16 +15,16 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#define SP_CLIPPATH(obj) (dynamic_cast<SPClipPath*>((SPObject*)obj))
-#define SP_IS_CLIPPATH(obj) (dynamic_cast<const SPClipPath*>((SPObject*)obj) != NULL)
-
-struct SPClipPathView;
-
#include <cstdio>
#include "sp-object-group.h"
+#include "display/drawing.h"
+#include "display/drawing-group.h"
#include "uri-references.h"
#include "xml/node.h"
+#define SP_CLIPPATH(obj) (dynamic_cast<SPClipPath*>((SPObject*)obj))
+#define SP_IS_CLIPPATH(obj) (dynamic_cast<const SPClipPath*>((SPObject*)obj) != NULL)
+
namespace Inkscape {
class Drawing;
@@ -32,6 +32,14 @@ class DrawingItem;
} // namespace Inkscape
+
+struct SPClipPathView {
+ SPClipPathView *next;
+ unsigned int key;
+ Inkscape::DrawingItem *arenaitem;
+ Geom::OptRect bbox;
+};
+
class SPClipPath : public SPObjectGroup {
public:
SPClipPath();
diff --git a/src/object/sp-ellipse.cpp b/src/object/sp-ellipse.cpp
index 97ad7f74c..723c28625 100644
--- a/src/object/sp-ellipse.cpp
+++ b/src/object/sp-ellipse.cpp
@@ -501,6 +501,7 @@ Geom::Affine SPGenericEllipse::set_transform(Geom::Affine const &xform)
if (hasPathEffect() && pathEffectsEnabled() &&
(this->hasPathEffectOfType(Inkscape::LivePathEffect::CLONE_ORIGINAL) ||
this->hasPathEffectOfType(Inkscape::LivePathEffect::BEND_PATH) ||
+ this->hasPathEffectOfType(Inkscape::LivePathEffect::POWERCLIP) ||
this->hasPathEffectOfType(Inkscape::LivePathEffect::FILL_BETWEEN_MANY) ||
this->hasPathEffectOfType(Inkscape::LivePathEffect::FILL_BETWEEN_STROKES) ) )
{
diff --git a/src/object/sp-item.cpp b/src/object/sp-item.cpp
index e6f4c4239..0a8af14dc 100644
--- a/src/object/sp-item.cpp
+++ b/src/object/sp-item.cpp
@@ -1321,7 +1321,7 @@ void SPItem::adjust_stroke( gdouble ex )
/**
* Find out the inverse of previous transform of an item (from its repr)
*/
-static Geom::Affine sp_item_transform_repr (SPItem *item)
+Geom::Affine sp_item_transform_repr (SPItem *item)
{
Geom::Affine t_old(Geom::identity());
gchar const *t_attr = item->getRepr()->attribute("transform");
diff --git a/src/object/sp-item.h b/src/object/sp-item.h
index f6a6781e9..acdde5d56 100644
--- a/src/object/sp-item.h
+++ b/src/object/sp-item.h
@@ -418,6 +418,8 @@ Geom::Affine i2anc_affine(SPObject const *item, SPObject const *ancestor);
Geom::Affine i2i_affine(SPObject const *src, SPObject const *dest);
+Geom::Affine sp_item_transform_repr (SPItem *item);
+
/* fixme: - these are evil, but OK */
int sp_item_repr_compare_position(SPItem const *first, SPItem const *second);
diff --git a/src/object/sp-lpe-item.cpp b/src/object/sp-lpe-item.cpp
index 37b2c11e8..d6eaf7b6e 100644
--- a/src/object/sp-lpe-item.cpp
+++ b/src/object/sp-lpe-item.cpp
@@ -201,6 +201,7 @@ bool SPLPEItem::performPathEffect(SPCurve *curve, SPShape *current, bool is_clip
}
if (this->hasPathEffect() && this->pathEffectsEnabled()) {
+ size_t path_effect_list_size = this->path_effect_list->size();
for (PathEffectList::iterator it = this->path_effect_list->begin(); it != this->path_effect_list->end(); ++it)
{
LivePathEffectObject *lpeobj = (*it)->lpeobject;
@@ -211,10 +212,14 @@ bool SPLPEItem::performPathEffect(SPCurve *curve, SPShape *current, bool is_clip
g_warning("SPLPEItem::performPathEffect - NULL lpeobj in list!");
return false;
}
+
Inkscape::LivePathEffect::Effect *lpe = lpeobj->get_lpe();
- if(!performOnePathEffect(curve, current, lpe, is_clip_or_mask)) {
+ if (!performOnePathEffect(curve, current, lpe, is_clip_or_mask)) {
return false;
}
+ if (path_effect_list_size != this->path_effect_list->size()) {
+ break;
+ }
}
}
return true;
@@ -462,6 +467,17 @@ sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem, bool keep_paths,
gchar *title = shape->title();
// remember description
gchar *desc = shape->desc();
+ // remember transformation
+ gchar const *transform_str = shape->getRepr()->attribute("transform");
+ // Mask
+ gchar const *mask_str = (gchar *) shape->getRepr()->attribute("mask");
+ // Clip path
+ gchar const *clip_str = (gchar *) shape->getRepr()->attribute("clip-path");
+
+ /* Rotation center */
+ gchar const *transform_center_x = shape->getRepr()->attribute("inkscape:transform-center-x");
+ gchar const *transform_center_y = shape->getRepr()->attribute("inkscape:transform-center-y");
+
// remember highlight color
guint32 highlight_color = 0;
if (shape->isHighlightSet())
@@ -476,6 +492,16 @@ sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem, bool keep_paths,
repr->setAttribute("id", id);
// restore class
repr->setAttribute("class", class_attr);
+ // restore transform
+ repr->setAttribute("transform", transform_str);
+ // restore clip
+ repr->setAttribute("clip-path", clip_str);
+ // restore mask
+ repr->setAttribute("mask", mask_str);
+ // restore transform_center_x
+ repr->setAttribute("inkscape:transform-center-x", transform_center_x);
+ // restore transform_center_y
+ repr->setAttribute("inkscape:transform-center-y", transform_center_y);
//restore d
repr->setAttribute("d", d_str);
//restore style
@@ -589,9 +615,9 @@ void SPLPEItem::removeCurrentPathEffect(bool keep_paths)
if (Inkscape::LivePathEffect::Effect* effect_ = this->getCurrentLPE()) {
effect_->keep_paths = keep_paths;
effect_->doOnRemove(this);
- PathEffectList new_list = *this->path_effect_list;
- new_list.remove(lperef); //current lpe ref is always our 'own' pointer from the path_effect_list
- this->getRepr()->setAttribute("inkscape:path-effect", patheffectlist_svg_string(new_list));
+ this->path_effect_list->remove(lperef); //current lpe ref is always our 'own' pointer from the path_effect_list
+ std::cout << this->path_effect_list->size() << "this->path_effect_list11111" << std::endl;
+ this->getRepr()->setAttribute("inkscape:path-effect", patheffectlist_svg_string(*this->path_effect_list));
if (!keep_paths) {
// Make sure that ellipse is stored as <svg:circle> or <svg:ellipse> if possible.
if( SP_IS_GENERICELLIPSE(this)) {
@@ -612,9 +638,8 @@ void SPLPEItem::removeAllPathEffects(bool keep_paths)
return;
}
}
- PathEffectList new_list = *this->path_effect_list;
std::list<Inkscape::LivePathEffect::LPEObjectReference *>::iterator i;
- for (i = new_list.begin(); i != new_list.end(); ++i) {
+ for (i = this->path_effect_list->begin(); i != this->path_effect_list->end(); ++i) {
Inkscape::LivePathEffect::LPEObjectReference *lperef = (*i);
if (!lperef) {
continue;
@@ -628,9 +653,8 @@ void SPLPEItem::removeAllPathEffects(bool keep_paths)
}
}
}
- new_list.clear();
+ this->path_effect_list->clear();
this->getRepr()->setAttribute("inkscape:path-effect", nullptr);
-
if (!keep_paths) {
// Make sure that ellipse is stored as <svg:circle> or <svg:ellipse> if possible.
if (SP_IS_GENERICELLIPSE(this)) {
@@ -959,15 +983,14 @@ SPLPEItem::applyToClipPathOrMask(SPItem *clip_mask, SPItem* to, Inkscape::LivePa
}
success = false;
}
- Inkscape::XML::Node *repr = clip_mask->getRepr();
if (success && c) {
shape->setCurveInsync(c);
gchar *str = sp_svg_write_path(c->get_pathvector());
- repr->setAttribute("d", str);
+ shape->setAttribute("d", str);
g_free(str);
} else {
// LPE was unsuccessful or doeffect stack return null.. Read the old 'd'-attribute.
- if (gchar const * value = repr->attribute("d")) {
+ if (gchar const * value = shape->getAttribute("d")) {
Geom::PathVector pv = sp_svg_read_pathv(value);
SPCurve *oldcurve = new (std::nothrow) SPCurve(pv);
if (oldcurve) {
diff --git a/src/object/sp-mask.cpp b/src/object/sp-mask.cpp
index 0d225d80a..277e35140 100644
--- a/src/object/sp-mask.cpp
+++ b/src/object/sp-mask.cpp
@@ -30,13 +30,6 @@
#include "sp-item.h"
#include "sp-mask.h"
-struct SPMaskView {
- SPMaskView *next;
- unsigned int key;
- Inkscape::DrawingItem *arenaitem;
- Geom::OptRect bbox;
-};
-
SPMaskView *sp_mask_view_new_prepend (SPMaskView *list, unsigned int key, Inkscape::DrawingItem *arenaitem);
SPMaskView *sp_mask_view_list_remove (SPMaskView *list, SPMaskView *view);
diff --git a/src/object/sp-mask.h b/src/object/sp-mask.h
index 5707e27d3..b1a1d1d3c 100644
--- a/src/object/sp-mask.h
+++ b/src/object/sp-mask.h
@@ -21,15 +21,20 @@
#define SP_MASK(obj) (dynamic_cast<SPMask*>((SPObject*)obj))
#define SP_IS_MASK(obj) (dynamic_cast<const SPMask*>((SPObject*)obj) != NULL)
-struct SPMaskView;
-
namespace Inkscape {
class Drawing;
class DrawingItem;
+
} // namespace Inkscape
+struct SPMaskView {
+ SPMaskView *next;
+ unsigned int key;
+ Inkscape::DrawingItem *arenaitem;
+ Geom::OptRect bbox;
+};
class SPMask : public SPObjectGroup {
public:
diff --git a/src/object/sp-path.cpp b/src/object/sp-path.cpp
index e2f6e6c99..f0e961d8c 100644
--- a/src/object/sp-path.cpp
+++ b/src/object/sp-path.cpp
@@ -325,6 +325,7 @@ Geom::Affine SPPath::set_transform(Geom::Affine const &transform) {
if (_curve_before_lpe && hasPathEffectRecursive()) {
if (this->hasPathEffectOfType(Inkscape::LivePathEffect::CLONE_ORIGINAL) ||
this->hasPathEffectOfType(Inkscape::LivePathEffect::BEND_PATH) ||
+ this->hasPathEffectOfType(Inkscape::LivePathEffect::POWERCLIP) ||
this->hasPathEffectOfType(Inkscape::LivePathEffect::FILL_BETWEEN_MANY) ||
this->hasPathEffectOfType(Inkscape::LivePathEffect::FILL_BETWEEN_STROKES) )
{
diff --git a/src/object/sp-spiral.cpp b/src/object/sp-spiral.cpp
index e8109be0f..da4f18923 100644
--- a/src/object/sp-spiral.cpp
+++ b/src/object/sp-spiral.cpp
@@ -407,6 +407,7 @@ Geom::Affine SPSpiral::set_transform(Geom::Affine const &xform)
if (hasPathEffect() && pathEffectsEnabled() &&
(this->hasPathEffectOfType(Inkscape::LivePathEffect::CLONE_ORIGINAL) ||
this->hasPathEffectOfType(Inkscape::LivePathEffect::BEND_PATH) ||
+ this->hasPathEffectOfType(Inkscape::LivePathEffect::POWERCLIP) ||
this->hasPathEffectOfType(Inkscape::LivePathEffect::FILL_BETWEEN_MANY) ||
this->hasPathEffectOfType(Inkscape::LivePathEffect::FILL_BETWEEN_STROKES) ) )
{
diff --git a/src/object/sp-star.cpp b/src/object/sp-star.cpp
index dc8ce4d91..fda39f4af 100644
--- a/src/object/sp-star.cpp
+++ b/src/object/sp-star.cpp
@@ -493,6 +493,7 @@ Geom::Affine SPStar::set_transform(Geom::Affine const &xform)
if (hasPathEffect() && pathEffectsEnabled() &&
(this->hasPathEffectOfType(Inkscape::LivePathEffect::CLONE_ORIGINAL) ||
this->hasPathEffectOfType(Inkscape::LivePathEffect::BEND_PATH) ||
+ this->hasPathEffectOfType(Inkscape::LivePathEffect::POWERCLIP) ||
this->hasPathEffectOfType(Inkscape::LivePathEffect::FILL_BETWEEN_MANY) ||
this->hasPathEffectOfType(Inkscape::LivePathEffect::FILL_BETWEEN_STROKES) ) )
{