From 30faf29165b1bcd936e9e0ca3ecc8b4bad4c94d2 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 9 Sep 2017 03:54:39 +0200 Subject: This commit is based on a coment on bug #1670644. And allow to fill the fill between many LPE widget that allow attach all paths on the clipboard instead only one Also added to this widget the option visible, to allow work with multiples paths wigout getting full cracy --- src/selection-chemistry.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/selection-chemistry.cpp') diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index bac924980..f4e37d7e9 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -2942,6 +2942,7 @@ void ObjectSet::cloneOriginalPathLPE() { lpe_repr->setAttribute("effect", "fill_between_many"); lpe_repr->setAttribute("linkedpaths", os.str()); + lpe_repr->setAttribute("retain_original", "false"); document()->getDefs()->getRepr()->addChild(lpe_repr, NULL); // adds to and assigns the 'id' attribute } std::string lpe_id_href = std::string("#") + lpe_repr->attribute("id"); -- cgit v1.2.3 From 1c31310676b12bd4fd5e477192bf7bd9fffabf83 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 9 Sep 2017 06:28:03 +0200 Subject: Fix a bug when creating a cloned LPE with fill between many --- src/selection-chemistry.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/selection-chemistry.cpp') diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index f4e37d7e9..f23a49500 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -2917,7 +2917,7 @@ void ObjectSet::cloneOriginal() /** * This creates a new path, applies the Original Path LPE, and has it refer to the selection. */ -void ObjectSet::cloneOriginalPathLPE() +void ObjectSet::cloneOriginalPathLPE(bool allow_transforms) { Inkscape::SVGOStringStream os; @@ -2930,7 +2930,7 @@ void ObjectSet::cloneOriginalPathLPE() } else { firstItem = SP_ITEM(*i); } - os << '#' << SP_ITEM(*i)->getId() << ",0"; + os << '#' << SP_ITEM(*i)->getId() << ",0,1"; } } if (firstItem) { @@ -2942,7 +2942,9 @@ void ObjectSet::cloneOriginalPathLPE() { lpe_repr->setAttribute("effect", "fill_between_many"); lpe_repr->setAttribute("linkedpaths", os.str()); - lpe_repr->setAttribute("retain_original", "false"); + lpe_repr->setAttribute("original_visible", "false"); + gchar const *allow_transforms_str = allow_transforms ? "true" : "false"; + lpe_repr->setAttribute("allow_transforms", allow_transforms_str); document()->getDefs()->getRepr()->addChild(lpe_repr, NULL); // adds to and assigns the 'id' attribute } std::string lpe_id_href = std::string("#") + lpe_repr->attribute("id"); -- cgit v1.2.3 From b5d3bcd190a8b4c95613eeb82e2b768b08b693ce Mon Sep 17 00:00:00 2001 From: Jabiertxo Arraiza Cenoz Date: Wed, 13 Sep 2017 17:10:44 +0200 Subject: Fixes for clone original LPE --- src/selection-chemistry.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/selection-chemistry.cpp') diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index f23a49500..9764563f1 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -2915,7 +2915,7 @@ void ObjectSet::cloneOriginal() } /** -* This creates a new path, applies the Original Path LPE, and has it refer to the selection. +* This applies the Fill Between Many LPE, and has it refer to the selection. */ void ObjectSet::cloneOriginalPathLPE(bool allow_transforms) { @@ -2942,7 +2942,9 @@ void ObjectSet::cloneOriginalPathLPE(bool allow_transforms) { lpe_repr->setAttribute("effect", "fill_between_many"); lpe_repr->setAttribute("linkedpaths", os.str()); - lpe_repr->setAttribute("original_visible", "false"); + lpe_repr->setAttribute("applied", "true"); + gchar const *method_str = allow_transforms ? "all" : "partial"; + lpe_repr->setAttribute("method", method_str); gchar const *allow_transforms_str = allow_transforms ? "true" : "false"; lpe_repr->setAttribute("allow_transforms", allow_transforms_str); document()->getDefs()->getRepr()->addChild(lpe_repr, NULL); // adds to and assigns the 'id' attribute -- cgit v1.2.3 From f38f101c22e8afeceacc49bcd09b43bac47347e7 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 16 Sep 2017 16:00:54 +0200 Subject: Fix a bug on uninicialitated variable, that perform diferent results in debug and in release mode. Thanks Michael for help me finfing this bug. Also sused to remove some unnneded code in path chemistry and to better naming the variable uninicilitated --- src/selection-chemistry.cpp | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'src/selection-chemistry.cpp') diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 9764563f1..9e0298f6a 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -2849,18 +2849,6 @@ void ObjectSet::cloneOriginal() SPFlowtext *flowtext = dynamic_cast(item); if (flowtext) { original = flowtext->get_frame(NULL); // first frame only - } else { - SPLPEItem *lpeItem = dynamic_cast(item); - if (lpeItem) { - // check if the applied LPE is Clone original, if so, go to the refered path - Inkscape::LivePathEffect::Effect* lpe = lpeItem->getPathEffectOfType(Inkscape::LivePathEffect::CLONE_ORIGINAL); - if (lpe) { - Inkscape::LivePathEffect::Parameter *lpeparam = lpe->getParameter("linkedpath"); - if (Inkscape::LivePathEffect::OriginalPathParam *pathparam = dynamic_cast(lpeparam)) { - original = pathparam->getObject(); - } - } - } } } } -- cgit v1.2.3 From a474159bf7130e9b46a8da1efaf32e9eac4c55b7 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Thu, 21 Sep 2017 23:12:27 +0200 Subject: Fix for bug #1715433 Clone original LPE can no longer be used to fill a powerstroke path --- src/selection-chemistry.cpp | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'src/selection-chemistry.cpp') diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 9e0298f6a..807c8f7e1 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -2911,10 +2911,12 @@ void ObjectSet::cloneOriginalPathLPE(bool allow_transforms) Inkscape::SVGOStringStream os; SPObject * firstItem = NULL; auto items_= items(); + bool multiple = false; for (auto i=items_.begin();i!=items_.end();++i){ if (SP_IS_SHAPE(*i) || SP_IS_TEXT(*i)) { if (firstItem) { os << "|"; + multiple = true; } else { firstItem = SP_ITEM(*i); } @@ -2924,19 +2926,21 @@ void ObjectSet::cloneOriginalPathLPE(bool allow_transforms) if (firstItem) { Inkscape::XML::Document *xml_doc = document()->getReprDoc(); SPObject *parent = firstItem->parent; - // create the LPE Inkscape::XML::Node *lpe_repr = xml_doc->createElement("inkscape:path-effect"); - { + if (multiple) { lpe_repr->setAttribute("effect", "fill_between_many"); lpe_repr->setAttribute("linkedpaths", os.str()); lpe_repr->setAttribute("applied", "true"); - gchar const *method_str = allow_transforms ? "all" : "partial"; - lpe_repr->setAttribute("method", method_str); - gchar const *allow_transforms_str = allow_transforms ? "true" : "false"; - lpe_repr->setAttribute("allow_transforms", allow_transforms_str); - document()->getDefs()->getRepr()->addChild(lpe_repr, NULL); // adds to and assigns the 'id' attribute + } else { + lpe_repr->setAttribute("effect", "clone_original"); + lpe_repr->setAttribute("linkeditem", ((Glib::ustring)"#" + (Glib::ustring)firstItem->getId()).c_str()); } + gchar const *method_str = allow_transforms ? "d" : "bsplinespiro"; + lpe_repr->setAttribute("method", method_str); + gchar const *allow_transforms_str = allow_transforms ? "true" : "false"; + lpe_repr->setAttribute("allow_transforms", allow_transforms_str); + document()->getDefs()->getRepr()->addChild(lpe_repr, NULL); // adds to and assigns the 'id' attribute std::string lpe_id_href = std::string("#") + lpe_repr->attribute("id"); Inkscape::GC::release(lpe_repr); @@ -2946,18 +2950,21 @@ void ObjectSet::cloneOriginalPathLPE(bool allow_transforms) clone->setAttribute("d", "M 0 0", false); // add the new clone to the top of the original's parent parent->appendChildRepr(clone); + // select the new object: + set(clone); + Inkscape::GC::release(clone); SPObject *clone_obj = document()->getObjectById(clone->attribute("id")); SPLPEItem *clone_lpeitem = dynamic_cast(clone_obj); if (clone_lpeitem) { clone_lpeitem->addPathEffect(lpe_id_href, false); } } + if (multiple) { + DocumentUndo::done(document(), SP_VERB_EDIT_CLONE_ORIGINAL_PATH_LPE, _("Fill between many")); + } else { + DocumentUndo::done(document(), SP_VERB_EDIT_CLONE_ORIGINAL_PATH_LPE, _("Clone original")); + } - DocumentUndo::done(document(), SP_VERB_EDIT_CLONE_ORIGINAL_PATH_LPE, _("Fill between many")); - // select the new object: - set(clone); - - Inkscape::GC::release(clone); } else { if(desktop()) desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select path(s) to fill.")); -- cgit v1.2.3 From 6a03015b016c177e0657fc6274a571db16e48b64 Mon Sep 17 00:00:00 2001 From: Stefano Facchini Date: Sat, 23 Sep 2017 10:02:16 +0200 Subject: Remove unused parameter in SPItem::doWriteTransform --- src/selection-chemistry.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/selection-chemistry.cpp') diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 807c8f7e1..b13af6bac 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -1666,7 +1666,7 @@ void ObjectSet::applyAffine(Geom::Affine const &affine, bool set_i2d, bool compe for (auto& itm: region.children) { SPUse *use = dynamic_cast(&itm); if ( use ) { - use->doWriteTransform(use->getRepr(), item->transform.inverse(), NULL, compensate); + use->doWriteTransform(item->transform.inverse(), NULL, compensate); } } } @@ -1710,13 +1710,13 @@ void ObjectSet::applyAffine(Geom::Affine const &affine, bool set_i2d, bool compe if (prefs_parallel) { Geom::Affine move = result * clone_move * t_inv; - item->doWriteTransform(item->getRepr(), move, &move, compensate); + item->doWriteTransform(move, &move, compensate); } else if (prefs_unmoved) { //if (dynamic_cast(sp_use_get_original(dynamic_cast(item)))) // clone_move = Geom::identity(); Geom::Affine move = result * clone_move; - item->doWriteTransform(item->getRepr(), move, &t, compensate); + item->doWriteTransform(move, &t, compensate); } } else if (transform_offset_with_source && (prefs_parallel || prefs_unmoved) && affine.isTranslation()){ @@ -1725,23 +1725,23 @@ void ObjectSet::applyAffine(Geom::Affine const &affine, bool set_i2d, bool compe if (prefs_parallel) { Geom::Affine move = result * offset_move * t_inv; - item->doWriteTransform(item->getRepr(), move, &move, compensate); + item->doWriteTransform(move, &move, compensate); } else if (prefs_unmoved) { Geom::Affine move = result * offset_move; - item->doWriteTransform(item->getRepr(), move, &t, compensate); + item->doWriteTransform(move, &t, compensate); } } else { // just apply the result - item->doWriteTransform(item->getRepr(), result, &t, compensate); + item->doWriteTransform(result, &t, compensate); } } else { if (set_i2d) { item->set_i2d_affine(item->i2dt_affine() * (Geom::Affine)affine); } - item->doWriteTransform(item->getRepr(), item->transform, NULL, compensate); + item->doWriteTransform(item->transform, NULL, compensate); } if (adjust_transf_center) { // The transformation center should not be touched in case of pasting or importing, which is allowed by this if clause @@ -3171,7 +3171,7 @@ void ObjectSet::toSymbol() prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); // Remove transform on group, updating clones. - the_group->doWriteTransform(object->getRepr(), Geom::identity()); + the_group->doWriteTransform(Geom::identity()); // restore compensation setting prefs->setInt("/options/clonecompensation/value", saved_compensation); @@ -3483,7 +3483,7 @@ void ObjectSet::untile() if (i) { Geom::Affine transform( i->transform * pat_transform ); - i->doWriteTransform(i->getRepr(), transform); + i->doWriteTransform(transform); new_select.push_back(i); } else { @@ -3955,9 +3955,9 @@ void ObjectSet::setClipGroup() Geom::Affine oldtr=(*i)->transform; oldtr *= SP_ITEM((*i)->parent)->i2doc_affine().inverse(); - (*i)->doWriteTransform((*i)->getRepr(), (*i)->i2doc_affine()); + (*i)->doWriteTransform((*i)->i2doc_affine()); Inkscape::XML::Node *dup = (*i)->getRepr()->duplicate(xml_doc); - (*i)->doWriteTransform((*i)->getRepr(), oldtr); + (*i)->doWriteTransform(oldtr); mask_items.push_back(dup); if (remove_original) { @@ -4160,7 +4160,7 @@ void ObjectSet::unsetMask(const bool apply_clip_path, const bool skip_undo) { // transform mask, so it is moved the same spot where mask was applied Geom::Affine transform(mask_item->transform); transform *= (*it).second->transform; - mask_item->doWriteTransform(mask_item->getRepr(), transform); + mask_item->doWriteTransform(transform); } g_slist_free(items_to_move); -- cgit v1.2.3 From f81751abb770d0367d6c515cdcb56a7954714eab Mon Sep 17 00:00:00 2001 From: Stefano Facchini Date: Sat, 23 Sep 2017 10:23:47 +0200 Subject: Transform duplicate object only when clipping or masking --- src/selection-chemistry.cpp | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'src/selection-chemistry.cpp') diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index b13af6bac..7dfe74752 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -3871,11 +3871,10 @@ void ObjectSet::setClipGroup() clone->setAttribute("inkscape:transform-center-x", inner->attribute("inkscape:transform-center-x"), false); clone->setAttribute("inkscape:transform-center-y", inner->attribute("inkscape:transform-center-y"), false); - const Geom::Affine maskTransform(Geom::Affine::identity()); std::vector templist; templist.push_back(clone); // add the new clone to the top of the original's parent - gchar const *mask_id = SPClipPath::create(templist, doc, &maskTransform); + gchar const *mask_id = SPClipPath::create(templist, doc); outer->setAttribute("clip-path", g_strdup_printf("url(#%s)", mask_id)); @@ -3933,7 +3932,7 @@ void ObjectSet::setClipGroup() clear(); // create a list of duplicates - std::vector mask_items; + std::vector> mask_items; std::vector apply_to_items; std::vector items_to_delete; std::vector items_to_select; @@ -3953,12 +3952,8 @@ void ObjectSet::setClipGroup() || (topmost && !apply_to_layer && *i == items_.back()) || apply_to_layer){ - Geom::Affine oldtr=(*i)->transform; - oldtr *= SP_ITEM((*i)->parent)->i2doc_affine().inverse(); - (*i)->doWriteTransform((*i)->i2doc_affine()); Inkscape::XML::Node *dup = (*i)->getRepr()->duplicate(xml_doc); - (*i)->doWriteTransform(oldtr); - mask_items.push_back(dup); + mask_items.push_back(std::make_pair(dup, (*i)->i2doc_affine())); if (remove_original) { items_to_delete.push_back(*i); @@ -4003,11 +3998,15 @@ void ObjectSet::setClipGroup() gchar const *attributeName = apply_clip_path ? "clip-path" : "mask"; for (std::vector::const_reverse_iterator i = apply_to_items.rbegin(); i != apply_to_items.rend(); ++i) { SPItem *item = reinterpret_cast(*i); - // inverted object transform should be applied to a mask object, - // as mask is calculated in user space (after applying transform) + std::vector mask_items_dup; - for(std::vector::const_iterator it=mask_items.begin();it!=mask_items.end();++it) - mask_items_dup.push_back((*it)->duplicate(xml_doc)); + std::map dup_transf; + for (auto it = mask_items.begin(); it != mask_items.end(); ++it) { + Inkscape::XML::Node *dup = ((*it).first)->duplicate(xml_doc); + mask_items_dup.push_back(dup); + dup_transf[dup] = (*it).second; + } + Inkscape::XML::Node *current = SP_OBJECT(*i)->getRepr(); // Node to apply mask to Inkscape::XML::Node *apply_mask_to = current; @@ -4033,13 +4032,19 @@ void ObjectSet::setClipGroup() Inkscape::GC::release(group); } - Geom::Affine maskTransform(item->i2doc_affine().inverse()); - gchar const *mask_id = NULL; if (apply_clip_path) { - mask_id = SPClipPath::create(mask_items_dup, doc, &maskTransform); + mask_id = SPClipPath::create(mask_items_dup, doc); } else { - mask_id = sp_mask_create(mask_items_dup, doc, &maskTransform); + mask_id = sp_mask_create(mask_items_dup, doc); + } + + // inverted object transform should be applied to a mask object, + // as mask is calculated in user space (after applying transform) + for (auto it = mask_items_dup.begin(); it != mask_items_dup.end(); ++it) { + SPItem *clip_item = SP_ITEM(doc->getObjectByRepr(*it)); + clip_item->doWriteTransform(dup_transf[*it]); + clip_item->doWriteTransform(clip_item->transform * item->i2doc_affine().inverse()); } apply_mask_to->setAttribute(attributeName, Glib::ustring("url(#") + mask_id + ')'); -- cgit v1.2.3 From 8761f46f7b8c2a2df82203f5be89d60072998a82 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Mon, 2 Oct 2017 02:12:27 +0200 Subject: Second batch --- src/selection-chemistry.cpp | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) (limited to 'src/selection-chemistry.cpp') diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 7dfe74752..be0d7c7d8 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -768,18 +768,12 @@ Inkscape::XML::Node* ObjectSet::group() { } -static gint clone_depth_descending(gconstpointer a, gconstpointer b) { +static bool clone_depth_descending(gconstpointer a, gconstpointer b) { SPUse *use_a = static_cast(const_cast(a)); SPUse *use_b = static_cast(const_cast(b)); int depth_a = use_a->cloneDepth(); int depth_b = use_b->cloneDepth(); - if (depth_a < depth_b) { - return 1; - } else if (depth_a == depth_b) { - return 0; - } else { - return -1; - } + return (depth_a==depth_b)?(adepth_b); } void ObjectSet::popFromGroup(){ @@ -822,7 +816,7 @@ static void ungroup_impl(ObjectSet *set) // If any of the clones refer to the groups, unlink them and replace them with successors // in the items list. - GSList *clones_to_unlink = NULL; + std::vector clones_to_unlink; for (std::vector::const_iterator item = items.begin(); item != items.end(); ++item) { SPUse *use = dynamic_cast(*item); @@ -832,21 +826,19 @@ static void ungroup_impl(ObjectSet *set) } if (groups.find(original) != groups.end()) { - clones_to_unlink = g_slist_prepend(clones_to_unlink, *item); + clones_to_unlink.push_back(use); } } // Unlink clones beginning from those with highest clone depth. // This way we can be sure than no additional automatic unlinking happens, // and the items in the list remain valid - clones_to_unlink = g_slist_sort(clones_to_unlink, clone_depth_descending); + std::sort(clones_to_unlink.begin(),clones_to_unlink.end(),clone_depth_descending); - for (GSList *item = clones_to_unlink; item; item = item->next) { - SPUse *use = static_cast(item->data); - std::vector::iterator items_node = std::find(items.begin(),items.end(), item->data); + for (auto use:clones_to_unlink) { + std::vector::iterator items_node = std::find(items.begin(),items.end(), use); *items_node = use->unlink(); } - g_slist_free(clones_to_unlink); // do the actual work for (std::vector::iterator item = items.begin(); item != items.end(); ++item) { @@ -2380,7 +2372,7 @@ private: template -SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root, +SPItem *next_item(SPDesktop *desktop, std::vector &path, SPObject *root, bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive) { typename D::Iterator children; @@ -2388,11 +2380,12 @@ SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root, SPItem *found=NULL; - if (path) { - SPObject *object=reinterpret_cast(path->data); + if (!path.empty()) { + SPObject *object=path.back(); + path.pop_back(); g_assert(object->parent == root); if (desktop->isLayer(object)) { - found = next_item(desktop, path->next, object, only_in_viewport, inlayer, onlyvisible, onlysensitive); + found = next_item(desktop, path, object, only_in_viewport, inlayer, onlyvisible, onlysensitive); } iter = children = D::siblings_after(object); } else { @@ -2403,7 +2396,8 @@ SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root, SPObject *object=D::object(iter); if (desktop->isLayer(object)) { if (PREFS_SELECTION_LAYER != inlayer) { // recurse into sublayers - found = next_item(desktop, NULL, object, only_in_viewport, inlayer, onlyvisible, onlysensitive); + std::vector empt; + found = next_item(desktop, empt, object, only_in_viewport, inlayer, onlyvisible, onlysensitive); } } else { SPItem *item = dynamic_cast(object); @@ -2440,19 +2434,19 @@ SPItem *next_item_from_list(SPDesktop *desktop, std::vector const &item } } - GSList *path=NULL; + std::vector path; while ( current != root ) { - path = g_slist_prepend(path, current); + path.push_back(current); current = current->parent; } SPItem *next; // first, try from the current object next = next_item(desktop, path, root, only_in_viewport, inlayer, onlyvisible, onlysensitive); - g_slist_free(path); if (!next) { // if we ran out of objects, start over at the root - next = next_item(desktop, NULL, root, only_in_viewport, inlayer, onlyvisible, onlysensitive); + std::vector empt; + next = next_item(desktop, empt, root, only_in_viewport, inlayer, onlyvisible, onlysensitive); } return next; -- cgit v1.2.3 From 3e075e587aaa712efb1704478cd1a75131882889 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Mon, 2 Oct 2017 23:30:11 +0200 Subject: third batch --- src/selection-chemistry.cpp | 74 ++++++++++++--------------------------------- 1 file changed, 20 insertions(+), 54 deletions(-) (limited to 'src/selection-chemistry.cpp') diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index be0d7c7d8..863d8858a 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -2093,8 +2093,6 @@ std::vector sp_get_same_object_type(SPItem *sel, std::vector & return matches; } -GSList *sp_get_same_fill_or_stroke_color(SPItem *sel, GSList *src, SPSelectStrokeStyleType type); - /* * Find all items in src list that have the same stroke style as sel by type * Return the list of matching items @@ -2331,14 +2329,15 @@ typedef struct Forward { static Iterator children(SPObject *o) { return o->firstChild(); } static Iterator siblings_after(SPObject *o) { return o->getNext(); } - static void dispose(Iterator /*i*/) {} + static void dispose(Iterator i) {} static SPObject *object(Iterator i) { return i; } static Iterator next(Iterator i) { return i->getNext(); } + static bool isNull(Iterator i) {return (!i);} } Forward; typedef struct ListReverse { - typedef GSList *Iterator; + typedef std::list *Iterator; static Iterator children(SPObject *o) { return make_list(o, NULL); @@ -2347,23 +2346,24 @@ typedef struct ListReverse { return make_list(o->parent, o); } static void dispose(Iterator i) { - g_slist_free(i); + delete i; } static SPObject *object(Iterator i) { - return reinterpret_cast(i->data); + return *(i->begin()); } - static Iterator next(Iterator i) { return i->next; } + static Iterator next(Iterator i) { i->pop_front(); return i; } + + static bool isNull(Iterator i) {return i->empty();} private: - static GSList *make_list(SPObject *object, SPObject *limit) { - GSList *list = NULL; + static std::list *make_list(SPObject *object, SPObject *limit) { + auto list = new std::list; for (auto &child: object->children) { if (&child == limit) { break; } - list = g_slist_prepend(list, &child); - + list->push_front(&child); } return list; } @@ -2392,7 +2392,7 @@ SPItem *next_item(SPDesktop *desktop, std::vector &path, SPObject *r iter = children = D::children(root); } - while ( iter && !found ) { + while ( !D::isNull(iter) && !found ) { SPObject *object=D::object(iter); if (desktop->isLayer(object)) { if (PREFS_SELECTION_LAYER != inlayer) { // recurse into sublayers @@ -2546,41 +2546,11 @@ void sp_selection_next_patheffect_param(SPDesktop * dt) void ObjectSet::editMask(bool /*clip*/) { return; - /*if (!dt) return; - using namespace Inkscape::UI; - - Inkscape::Selection *selection = dt->getSelection(); - if (!selection || selection->isEmpty()) return; - - GSList const *items = selection->itemList(); - bool has_path = false; - for (GSList *i = const_cast(items); i; i= i->next) { - SPItem *item = SP_ITEM(i->data); - SPObject *search = clip - ? (item->clip_ref ? item->clip_ref->getObject() : NULL) - : item->mask_ref ? item->mask_ref->getObject() : NULL; - has_path |= has_path_recursive(search); - if (has_path) break; - } - if (has_path) { - if (!tools_isactive(dt, TOOLS_NODES)) { - tools_switch(dt, TOOLS_NODES); - } - ink_node_tool_set_mode(INK_NODE_TOOL(dt->event_context), - clip ? NODE_TOOL_EDIT_CLIPPING_PATHS : NODE_TOOL_EDIT_MASKS); - } else if (clip) { - dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, - _("The selection has no applied clip path.")); - } else { - dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, - _("The selection has no applied mask.")); - }*/ } - /** * If \a item is not entirely visible then adjust visible area to centre on the centre on of * \a item. @@ -4083,7 +4053,7 @@ void ObjectSet::unsetMask(const bool apply_clip_path, const bool skip_undo) { std::vector items_(items().begin(), items().end()); clear(); - GSList *items_to_ungroup = NULL; + std::vector items_to_ungroup; std::vector items_to_select(items_); @@ -4116,7 +4086,7 @@ void ObjectSet::unsetMask(const bool apply_clip_path, const bool skip_undo) { // ungroup only groups we created when setting clip/mask if (group->layerMode() == SPGroup::MASK_HELPER) { - items_to_ungroup = g_slist_prepend(items_to_ungroup, group); + items_to_ungroup.push_back(group); } } @@ -4125,7 +4095,7 @@ void ObjectSet::unsetMask(const bool apply_clip_path, const bool skip_undo) { // restore mask objects into a document for ( std::map::iterator it = referenced_objects.begin() ; it != referenced_objects.end() ; ++it) { SPObject *obj = (*it).first; // Group containing the clipped paths or masks - GSList *items_to_move = NULL; + std::vector items_to_move; for (auto& child: obj->children) { // Collect all clipped paths and masks within a single group Inkscape::XML::Node *copy = child.getRepr()->duplicate(xml_doc); @@ -4133,7 +4103,7 @@ void ObjectSet::unsetMask(const bool apply_clip_path, const bool skip_undo) { { copy->setAttribute("d", copy->attribute("inkscape:original-d")); } - items_to_move = g_slist_prepend(items_to_move, copy); + items_to_move.push_back(copy); } if (!obj->isReferenced()) { @@ -4146,8 +4116,8 @@ void ObjectSet::unsetMask(const bool apply_clip_path, const bool skip_undo) { gint pos = ((*it).second)->getRepr()->position(); // Iterate through all clipped paths / masks - for (GSList *i = items_to_move; NULL != i; i = i->next) { - Inkscape::XML::Node *repr = static_cast(i->data); + for (auto i=items_to_move.rbegin();i!=items_to_move.rend();++i) { + Inkscape::XML::Node *repr = *i; // insert into parent, restore pos parent->appendChild(repr); @@ -4161,13 +4131,11 @@ void ObjectSet::unsetMask(const bool apply_clip_path, const bool skip_undo) { transform *= (*it).second->transform; mask_item->doWriteTransform(transform); } - - g_slist_free(items_to_move); } // ungroup marked groups added when setting mask - for (GSList *i = items_to_ungroup ; NULL != i ; i = i->next) { - SPGroup *group = dynamic_cast(static_cast(i->data)); + for (auto i=items_to_ungroup.rbegin();i!=items_to_ungroup.rend();++i) { + SPGroup *group = *i; if (group) { items_to_select.erase(std::remove(items_to_select.begin(), items_to_select.end(), group), items_to_select.end()); std::vector children; @@ -4178,8 +4146,6 @@ void ObjectSet::unsetMask(const bool apply_clip_path, const bool skip_undo) { } } - g_slist_free(items_to_ungroup); - // rebuild selection addList(items_to_select); -- cgit v1.2.3 From ee527cbb228c6fba9c83bba5058d1a68ac647060 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 14 Oct 2017 21:29:10 +0200 Subject: Fixing problems with nested LPE and convert to paths --- src/selection-chemistry.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/selection-chemistry.cpp') diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 863d8858a..0bd611163 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -761,6 +761,10 @@ Inkscape::XML::Node* ObjectSet::group() { group->setPosition(topmost + 1); set(doc->getObjectByRepr(group)); + SPLPEItem *lpeitem = dynamic_cast(*(items().begin())); + if (lpeitem) { + sp_lpe_item_update_patheffect(lpeitem, true, true); + } DocumentUndo::done(doc, SP_VERB_SELECTION_GROUP, C_("Verb", "Group")); -- cgit v1.2.3