summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2016-12-30 18:14:55 +0000
committerjabiertxof <info@marker.es>2016-12-30 18:14:55 +0000
commit3c16d15761bac73cba9b81b49efe8e71306a5766 (patch)
tree0d0ddc17e7b0201cfdc6c6072445fc3ac69f37be /src
parentUpdate to trunk (diff)
downloadinkscape-3c16d15761bac73cba9b81b49efe8e71306a5766.tar.gz
inkscape-3c16d15761bac73cba9b81b49efe8e71306a5766.zip
Fixing clips and masks
(bzr r15356.1.6)
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/lpe-clone-original.cpp36
-rw-r--r--src/sp-lpe-item.cpp4
2 files changed, 27 insertions, 13 deletions
diff --git a/src/live_effects/lpe-clone-original.cpp b/src/live_effects/lpe-clone-original.cpp
index 8176f3811..81e6809f1 100644
--- a/src/live_effects/lpe-clone-original.cpp
+++ b/src/live_effects/lpe-clone-original.cpp
@@ -8,6 +8,8 @@
#include "display/curve.h"
#include "svg/path-string.h"
#include "svg/svg.h"
+#include "sp-clippath.h"
+#include "sp-mask.h"
#include "xml/sp-css-attr.h"
// TODO due to internal breakage in glibmm headers, this must be last:
@@ -36,9 +38,9 @@ LPECloneOriginal::LPECloneOriginal(LivePathEffectObject *lpeobject) :
scale.param_set_digits(2);
attributes.param_hide_canvas_text();
style_attributes.param_hide_canvas_text();
- apply_to_clippath_and_mask = true;
preserve_position_changed = !preserve_position;
preserve_affine = Geom::identity();
+ apply_to_clippath_and_mask = true;
}
void
@@ -60,6 +62,13 @@ LPECloneOriginal::cloneAttrbutes(SPObject *origin, SPObject *dest, bool live, co
SPShape * shape_dest = SP_SHAPE(dest);
gchar ** attarray = g_strsplit(attributes, ",", 0);
gchar ** iter = attarray;
+// if (SP_IS_CLIPPATH(SP_ITEM(origin)->parent) || SP_IS_MASK(SP_ITEM(origin)->parent)) {
+// Geom::Affine dest_affine = Geom::identity();
+// if (root && preserve_position) {
+// dest_affine *= Geom::Translate(preserve_affine.translation());
+// }
+// SP_ITEM(SP_ITEM(dest)->parent)->transform = dest_affine;
+// }
while (*iter != NULL) {
const char* attribute = (*iter);
if ( std::strcmp(attribute, "transform") == 0 ) {
@@ -69,11 +78,12 @@ LPECloneOriginal::cloneAttrbutes(SPObject *origin, SPObject *dest, bool live, co
if (preserve_position) {
Geom::Affine dest_affine = Geom::identity();
if (root) {
+ std::cout << "root" << preserve_affine.translation() << "\n";
dest_affine *= Geom::Translate(preserve_affine.translation());
- preserve_affine = Geom::identity();
+ //preserve_affine = Geom::identity();
+ dest_affine *= Geom::Translate(affine_dest.translation());
+ dest_affine *= Geom::Translate(affine_origin.translation()).inverse();
}
- dest_affine *= Geom::Translate(affine_dest.translation());
- dest_affine *= Geom::Translate(affine_origin.translation()).inverse();
dest_affine *= affine_origin;
SP_ITEM(dest)->transform = dest_affine;
} else {
@@ -89,7 +99,7 @@ LPECloneOriginal::cloneAttrbutes(SPObject *origin, SPObject *dest, bool live, co
if (c) {
Geom::PathVector c_pv = c->get_pathvector();
Geom::OptRect orig_bbox = SP_ITEM(origin)->geometricBounds();
- if (orig_bbox) {
+ if (orig_bbox && root) {
if (scale != 100.0) {
double scale_affine = scale/100.0;
Geom::Scale scale = Geom::Scale(scale_affine);
@@ -141,12 +151,6 @@ LPECloneOriginal::cloneAttrbutes(SPObject *origin, SPObject *dest, bool live, co
void
LPECloneOriginal::doBeforeEffect (SPLPEItem const* lpeitem){
original_bbox(lpeitem);
- if ( preserve_position_changed != preserve_position ) {
- if (!preserve_position) {
- preserve_affine = SP_ITEM(sp_lpe_item)->transform;
- }
- preserve_position_changed = preserve_position;
- }
if (linked_path.linksToPath()) { //Legacy staff
Glib::ustring attributes_value("d");
attributes.param_setValue(attributes_value);
@@ -158,6 +162,16 @@ LPECloneOriginal::doBeforeEffect (SPLPEItem const* lpeitem){
linked_path.param_readSVGValue("");
}
if (linked_item.linksToItem()) {
+ if (preserve_position) {
+ preserve_affine = SP_ITEM(sp_lpe_item)->transform;
+ }
+// if ( preserve_position_changed != preserve_position ) {
+// if (!preserve_position) {
+// preserve_affine = SP_ITEM(sp_lpe_item)->transform;
+// preserve_affine *= Geom::Translate(SP_ITEM(linked_item.getObject())->transform.translation()).inverse();
+// }
+// preserve_position_changed = preserve_position;
+// }
cloneAttrbutes(linked_item.getObject(), SP_OBJECT(sp_lpe_item), true, attributes.param_getSVGValue(), style_attributes.param_getSVGValue(), true);
}
}
diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp
index c7a800041..2dd7cec5a 100644
--- a/src/sp-lpe-item.cpp
+++ b/src/sp-lpe-item.cpp
@@ -241,7 +241,7 @@ bool SPLPEItem::performPathEffect(SPCurve *curve, SPShape *current, bool is_clip
}
if (!is_clip_or_mask || (is_clip_or_mask && lpe->apply_to_clippath_and_mask)) {
// Groups have their doBeforeEffect called elsewhere
- if (SP_IS_GROUP(this) && current) {
+ if (current) {
lpe->setCurrentShape(current);
}
if (!SP_IS_GROUP(this)) {
@@ -700,7 +700,7 @@ SPLPEItem::apply_to_clip_or_mask(SPItem *clip_mask, SPItem *item)
success = this->performPathEffect(c, SP_SHAPE(clip_mask), true);
c->transform(i2anc_affine(SP_GROUP(item), SP_GROUP(this)).inverse());
} else {
- success = this->performPathEffect(c, NULL, true);
+ success = this->performPathEffect(c, SP_SHAPE(clip_mask), true);
}
} catch (std::exception & e) {
g_warning("Exception during LPE execution. \n %s", e.what());