diff options
| author | Jabiertxo Arraiza Cenoz <jtx@jtx.markerlab.es> | 2018-04-26 09:08:06 +0000 |
|---|---|---|
| committer | Jabiertxo Arraiza Cenoz <jtx@jtx.markerlab.es> | 2018-04-26 09:28:58 +0000 |
| commit | 5bfbeb4a8dc322fcac11ed23fc2665a35c2b957a (patch) | |
| tree | e00191e553fa1c10319dd37490df0c462fb050b0 /src | |
| parent | Add start of 'font-variations' widget. (diff) | |
| download | inkscape-5bfbeb4a8dc322fcac11ed23fc2665a35c2b957a.tar.gz inkscape-5bfbeb4a8dc322fcac11ed23fc2665a35c2b957a.zip | |
Fix bug when converting to paths cliped and masked LPE elemets
Diffstat (limited to 'src')
| -rw-r--r-- | src/object/sp-lpe-item.cpp | 83 | ||||
| -rw-r--r-- | src/path-chemistry.cpp | 26 | ||||
| -rw-r--r-- | src/selection-chemistry.cpp | 18 |
3 files changed, 65 insertions, 62 deletions
diff --git a/src/object/sp-lpe-item.cpp b/src/object/sp-lpe-item.cpp index 27ea45ca6..c7c925c55 100644 --- a/src/object/sp-lpe-item.cpp +++ b/src/object/sp-lpe-item.cpp @@ -50,7 +50,7 @@ static void sp_lpe_item_enable_path_effects(SPLPEItem *lpeitem, bool enable); static void lpeobject_ref_modified(SPObject *href, guint flags, SPLPEItem *lpeitem); static void sp_lpe_item_create_original_path_recursive(SPLPEItem *lpeitem); -static void sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem, bool keep_paths, bool force = false); +static void sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem, bool keep_paths, bool force = false, bool is_clip_mask = false); typedef std::list<std::string> HRefList; static std::string patheffectlist_svg_string(PathEffectList const & list); @@ -376,7 +376,7 @@ sp_lpe_item_create_original_path_recursive(SPLPEItem *lpeitem) } static void -sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem, bool keep_paths, bool force) +sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem, bool keep_paths, bool force, bool is_clip_mask) { g_return_if_fail(lpeitem != NULL); SPItem *item = dynamic_cast<SPItem *>(lpeitem); @@ -391,7 +391,7 @@ sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem, bool keep_paths, 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) { SPLPEItem* clip_data = dynamic_cast<SPLPEItem*>(*iter); - sp_lpe_item_cleanup_original_path_recursive(clip_data, keep_paths, shape && !shape->hasPathEffectRecursive()); + sp_lpe_item_cleanup_original_path_recursive(clip_data, keep_paths, lpeitem && !lpeitem->hasPathEffectRecursive(), true); } } @@ -400,7 +400,7 @@ sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem, bool keep_paths, std::vector<SPObject*> mask_path_list = mask_path->childList(true); for ( std::vector<SPObject*>::const_iterator iter = mask_path_list.begin(); iter != mask_path_list.end();++iter) { SPLPEItem* mask_data = dynamic_cast<SPLPEItem*>(*iter); - sp_lpe_item_cleanup_original_path_recursive(mask_data, keep_paths, shape && !shape->hasPathEffectRecursive()); + sp_lpe_item_cleanup_original_path_recursive(mask_data, keep_paths, lpeitem && !lpeitem->hasPathEffectRecursive(), true); } } @@ -408,11 +408,15 @@ sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem, bool keep_paths, std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { SPLPEItem* subitem = dynamic_cast<SPLPEItem*>(*iter); - sp_lpe_item_cleanup_original_path_recursive(subitem, keep_paths, false); + sp_lpe_item_cleanup_original_path_recursive(subitem, keep_paths); + } } else if (path) { Inkscape::XML::Node *repr = lpeitem->getRepr(); - if ((!lpeitem->hasPathEffectRecursive() || force) && repr->attribute("inkscape:original-d")) + if (repr->attribute("inkscape:original-d") && + !lpeitem->hasPathEffectRecursive() && + (!is_clip_mask || + ( is_clip_mask && force))) { if (!keep_paths) { repr->setAttribute("d", repr->attribute("inkscape:original-d")); @@ -429,27 +433,34 @@ sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem, bool keep_paths, } } else if (shape) { Inkscape::XML::Node *repr = lpeitem->getRepr(); - if ((!lpeitem->hasPathEffectRecursive() || force) && repr->attribute("d")) - { - if (!keep_paths) { - repr->setAttribute("d", NULL); - } else { - SPDesktop * desktop = SP_ACTIVE_DESKTOP; - if (desktop) { - std::vector<SPItem*> items; - items.push_back(SP_ITEM(lpeitem)); - std::vector<SPItem*> selected = items; - std::vector<Inkscape::XML::Node*> to_select; - sp_item_list_to_curves(items, selected, to_select, true); + SPCurve * c_lpe = shape->getCurve(); + if (c_lpe) { + gchar *d_str = sp_svg_write_path(c_lpe->get_pathvector()); + if (d_str) { + if (!lpeitem->hasPathEffectRecursive() && + (!is_clip_mask || + ( is_clip_mask && force))) + { + if (!keep_paths) { + repr->setAttribute("d", NULL); + shape->setCurveBeforeLPE(NULL); + } else { + repr->setAttribute("d", NULL); + Inkscape::XML::Node *parent = repr->parent(); + Inkscape::XML::Node *spnew = sp_selected_item_to_curved_repr(lpeitem, 0); + sp_repr_unparent(repr); + parent->appendChild(spnew); + Inkscape::GC::release(spnew); + spnew->setAttribute("d", d_str); + } + } else { + if (!keep_paths) { + sp_lpe_item_update_patheffect(lpeitem, true, true); + } } - } - shape->setCurveBeforeLPE(NULL); - } else { - if (!keep_paths) { - sp_lpe_item_update_patheffect(lpeitem, true, true); + c_lpe->unref(); } } - } } @@ -693,7 +704,7 @@ bool SPLPEItem::hasPathEffectOnClipOrMask(SPLPEItem * shape) const } /** - * returns true when any LPE apply to clip or mask. + * returns true when any LPE apply to clip or mask. recursive mode */ bool SPLPEItem::hasPathEffectOnClipOrMaskRecursive(SPLPEItem * shape) const { @@ -880,28 +891,14 @@ SPLPEItem::applyToClipPathOrMask(SPItem *clip_mask, SPItem* to, Inkscape::LivePa } } } - if (lpe) { //group - c = shape->getCurve(); - } else { - c = shape->getCurveForEdit(); - } + c = shape->getCurve(); if (c) { bool success = false; try { - if(SP_IS_GROUP(this)){ - c->transform(i2anc_affine(SP_GROUP(to), SP_GROUP(this))); - if (lpe) { - success = this->performOnePathEffect(c, shape, lpe, true); - } else { - success = this->performPathEffect(c, shape, true); - } - c->transform(i2anc_affine(SP_GROUP(to), SP_GROUP(this)).inverse()); + if (lpe) { + success = this->performOnePathEffect(c, shape, lpe, true); } else { - if (lpe) { - success = this->performOnePathEffect(c, shape, lpe, true); - } else { - success = this->performPathEffect(c, SP_SHAPE(clip_mask), true); - } + success = this->performPathEffect(c, shape, true); } } catch (std::exception & e) { g_warning("Exception during LPE execution. \n %s", e.what()); diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index 7ee811dc9..95b55a829 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -380,19 +380,6 @@ sp_item_list_to_curves(const std::vector<SPItem*> &items, std::vector<SPItem*>& continue; } - SPPath *path = dynamic_cast<SPPath *>(item); - if (path && !path->hasPathEffect()) { - // remove connector attributes - if (item->getAttribute("inkscape:connector-type") != NULL) { - item->removeAttribute("inkscape:connection-start"); - item->removeAttribute("inkscape:connection-end"); - item->removeAttribute("inkscape:connector-type"); - item->removeAttribute("inkscape:connector-curvature"); - did = true; - } - continue; // already a path, and no path effect - } - SPBox3D *box = dynamic_cast<SPBox3D *>(item); if (box) { // convert 3D box to ordinary group of paths; replace the old element in 'selected' with the new group @@ -412,6 +399,19 @@ sp_item_list_to_curves(const std::vector<SPItem*> &items, std::vector<SPItem*>& lpeitem->removeAllPathEffects(true); } + SPPath *path = dynamic_cast<SPPath *>(item); + if (path) { + // remove connector attributes + if (item->getAttribute("inkscape:connector-type") != NULL) { + item->removeAttribute("inkscape:connection-start"); + item->removeAttribute("inkscape:connection-end"); + item->removeAttribute("inkscape:connector-type"); + item->removeAttribute("inkscape:connector-curvature"); + did = true; + } + continue; // already a path, and no path effect + } + if (group) { std::vector<SPItem*> item_list = sp_item_group_item_list(group); diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 622a843e4..128a4712f 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -2694,15 +2694,21 @@ bool ObjectSet::unlink(const bool skip_undo) Inkscape::URIReference *clip = item->clip_ref; Inkscape::URIReference *mask = item->mask_ref; if ((NULL != clip) && (NULL != clip->getObject())) { - tmp_set.unsetMask(true,true); - unlinked = tmp_set.unlink(true) || unlinked; - tmp_set.setMask(true,false,true); + SPUse * clipuse = dynamic_cast<SPUse *>(clip->getObject()); + if (clipuse) { + tmp_set.unsetMask(true,true); + unlinked = tmp_set.unlink(true) || unlinked; + tmp_set.setMask(true,false,true); + } new_select.push_back(tmp_set.singleItem()); } else if ((NULL != mask) && (NULL != mask->getObject())) { - tmp_set.unsetMask(false,true); - unlinked = tmp_set.unlink(true) || unlinked; - tmp_set.setMask(false,false,true); + SPUse * maskuse = dynamic_cast<SPUse *>(mask->getObject()); + if (maskuse) { + tmp_set.unsetMask(false,true); + unlinked = tmp_set.unlink(true) || unlinked; + tmp_set.setMask(false,false,true); + } new_select.push_back(tmp_set.singleItem()); } else { |
