From 1636c1dd1651780d01759676b194312529f211f7 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Sat, 25 Jun 2016 22:24:26 +0200 Subject: Moved next functions, added namespace, renamed range functions (bzr r14954.1.10) --- src/path-chemistry.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/path-chemistry.cpp') diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index 1a345b565..37d242b6b 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -57,7 +57,7 @@ sp_selected_path_combine(SPDesktop *desktop, bool skip_undo) Inkscape::Selection *selection = desktop->getSelection(); SPDocument *doc = desktop->getDocument(); - std::vector items(selection->itemList()); + std::vector items(selection->items()); if (items.size() < 1) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select object(s) to combine.")); @@ -203,7 +203,7 @@ sp_selected_path_break_apart(SPDesktop *desktop, bool skip_undo) bool did = false; - std::vector itemlist(selection->itemList()); + std::vector itemlist(selection->items()); for (std::vector::const_iterator i = itemlist.begin(); i != itemlist.end(); ++i){ SPItem *item = *i; @@ -303,7 +303,7 @@ sp_selected_path_to_curves(Inkscape::Selection *selection, SPDesktop *desktop, b desktop->setWaitingCursor(); } - std::vector selected(selection->itemList()); + std::vector selected(selection->items()); std::vector to_select; selection->clear(); std::vector items(selected); @@ -334,7 +334,7 @@ void sp_selected_to_lpeitems(SPDesktop *desktop) return; } - std::vector selected(selection->itemList()); + std::vector selected(selection->items()); std::vector to_select; selection->clear(); std::vector items(selected); @@ -603,7 +603,7 @@ void sp_selected_path_reverse(SPDesktop *desktop) { Inkscape::Selection *selection = desktop->getSelection(); - std::vector items = selection->itemList(); + std::vector items = selection->items(); if (items.empty()) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select path(s) to reverse.")); -- cgit v1.2.3 From 798cda4430354143e90fb7ce81c3593a6dc24bc5 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah <> Date: Wed, 13 Jul 2016 08:12:57 +0530 Subject: Propagate changes to object tree with changes in style element (bzr r14949.1.46) --- src/path-chemistry.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/path-chemistry.cpp') diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index 1a345b565..f66c8cbf5 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -493,7 +493,7 @@ sp_selected_item_to_curved_repr(SPItem *item, guint32 /*text_grouping_policy*/) /* Whole text's style */ Glib::ustring style_str = - item->style->write( SP_STYLE_FLAG_IFDIFF, item->parent ? item->parent->style : NULL); // TODO investigate posibility + item->style->write( SP_STYLE_FLAG_IFDIFF, SP_STYLE_SRC_UNSET, item->parent ? item->parent->style : NULL); // TODO investigate posibility g_repr->setAttribute("style", style_str.c_str()); Inkscape::Text::Layout::iterator iter = te_get_layout(item)->begin(); @@ -514,7 +514,7 @@ sp_selected_item_to_curved_repr(SPItem *item, guint32 /*text_grouping_policy*/) pos_obj = pos_obj->parent; // SPStrings don't have style } Glib::ustring style_str = - pos_obj->style->write( SP_STYLE_FLAG_IFDIFF, pos_obj->parent ? pos_obj->parent->style : NULL); // TODO investigate posibility + pos_obj->style->write( SP_STYLE_FLAG_IFDIFF, SP_STYLE_SRC_UNSET, pos_obj->parent ? pos_obj->parent->style : NULL); // TODO investigate posibility // get path from iter to iter_next: SPCurve *curve = te_get_layout(item)->convertToCurves(iter, iter_next); @@ -573,7 +573,7 @@ sp_selected_item_to_curved_repr(SPItem *item, guint32 /*text_grouping_policy*/) /* Style */ Glib::ustring style_str = - item->style->write( SP_STYLE_FLAG_IFDIFF, item->parent ? item->parent->style : NULL); // TODO investigate posibility + item->style->write( SP_STYLE_FLAG_IFDIFF, SP_STYLE_SRC_UNSET, item->parent ? item->parent->style : NULL); // TODO investigate posibility repr->setAttribute("style", style_str.c_str()); /* Mask */ -- cgit v1.2.3 From f35bb1f74a0ffeb5c6477a25e3c4cde87a97bcf1 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 28 Jul 2016 12:06:06 +0200 Subject: Removed unused includes, decrease compilation time (bzr r15025) --- src/path-chemistry.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/path-chemistry.cpp') diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index 1a345b565..9f98cb8a9 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -15,15 +15,12 @@ */ #ifdef HAVE_CONFIG_H -# include #endif #include #include #include "xml/repr.h" #include "svg/svg.h" #include "display/curve.h" -#include "color.h" -#include #include #include "sp-path.h" #include "sp-text.h" @@ -37,7 +34,6 @@ #include "selection.h" #include "box3d.h" -#include <2geom/pathvector.h> #include "selection-chemistry.h" #include "path-chemistry.h" #include "verbs.h" -- cgit v1.2.3 From 43b49e325db73cc19b1731db6c69545664ee8fbe Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 28 Jul 2016 13:26:17 +0200 Subject: Reverted changes to r15024 after many building problems (bzr r15027) --- src/path-chemistry.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/path-chemistry.cpp') diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index 9f98cb8a9..1a345b565 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -15,12 +15,15 @@ */ #ifdef HAVE_CONFIG_H +# include #endif #include #include #include "xml/repr.h" #include "svg/svg.h" #include "display/curve.h" +#include "color.h" +#include #include #include "sp-path.h" #include "sp-text.h" @@ -34,6 +37,7 @@ #include "selection.h" #include "box3d.h" +#include <2geom/pathvector.h> #include "selection-chemistry.h" #include "path-chemistry.h" #include "verbs.h" -- cgit v1.2.3 From 35830f456cadaecf8b8e3944e3031a1a93f6cb41 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 3 Aug 2016 15:29:38 +0200 Subject: Removed unused includes, decreased compilation time. Once again (bzr r15034) --- src/path-chemistry.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/path-chemistry.cpp') diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index 1a345b565..79a15f509 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -15,15 +15,13 @@ */ #ifdef HAVE_CONFIG_H -# include +#include #endif #include #include #include "xml/repr.h" #include "svg/svg.h" #include "display/curve.h" -#include "color.h" -#include #include #include "sp-path.h" #include "sp-text.h" @@ -37,7 +35,6 @@ #include "selection.h" #include "box3d.h" -#include <2geom/pathvector.h> #include "selection-chemistry.h" #include "path-chemistry.h" #include "verbs.h" -- cgit v1.2.3 From 532f77b14a76fc04e6bdeca3625f9a55b5f11bdf Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Tue, 25 Oct 2016 00:58:43 +0200 Subject: CPPification: almost all sp_object_set_whatever and sp_selection_whatever global functions are now methods of ObjectSet*, with these additional benefits: - They can now act on any SelectionSet, not just the current selection; - Whenever possible, they don't need a desktop anymore and can run if called from GUI. I hope I did not break too many things in the process. *: So instead of callink sp_selection_move(desktop,x,y), you call myobjectset->move(x,y) (bzr r15189) --- src/path-chemistry.cpp | 171 ++++++++++++++++++++++++++----------------------- 1 file changed, 90 insertions(+), 81 deletions(-) (limited to 'src/path-chemistry.cpp') diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index 5295b7a70..a19ca9524 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -38,8 +38,10 @@ #include "selection-chemistry.h" #include "path-chemistry.h" #include "verbs.h" +#include "object-set.h" using Inkscape::DocumentUndo; +using Inkscape::ObjectSet; inline bool less_than_items(SPItem const *first, SPItem const *second) @@ -49,39 +51,42 @@ inline bool less_than_items(SPItem const *first, SPItem const *second) } void -sp_selected_path_combine(SPDesktop *desktop, bool skip_undo) +ObjectSet::combine(bool skip_undo) { - Inkscape::Selection *selection = desktop->getSelection(); - SPDocument *doc = desktop->getDocument(); + //Inkscape::Selection *selection = desktop->getSelection(); + SPDocument *doc = document(); - std::vector items(selection->items().begin(), selection->items().end()); + std::vector items_copy(items().begin(), items().end()); - if (items.size() < 1) { - desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select object(s) to combine.")); + if (items_copy.size() < 1) { + if(desktop()) + desktop()->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select object(s) to combine.")); return; } - desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Combining paths...")); - // set "busy" cursor - desktop->setWaitingCursor(); + if(desktop()){ + desktop()->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Combining paths...")); + // set "busy" cursor + desktop()->setWaitingCursor(); + } - items = sp_degroup_list (items); // descend into any groups in selection + items_copy = sp_degroup_list (items_copy); // descend into any groups in selection std::vector to_paths; - for (std::vector::const_reverse_iterator i = items.rbegin(); i != items.rend(); ++i) { + for (std::vector::const_reverse_iterator i = items_copy.rbegin(); i != items_copy.rend(); ++i) { if (!dynamic_cast(*i) && !dynamic_cast(*i)) { to_paths.push_back(*i); } } std::vector converted; - bool did = sp_item_list_to_curves(to_paths, items, converted); + bool did = sp_item_list_to_curves(to_paths, items_copy, converted); for (std::vector::const_iterator i = converted.begin(); i != converted.end(); ++i) - items.push_back((SPItem*)doc->getObjectByRepr(*i)); + items_copy.push_back((SPItem*)doc->getObjectByRepr(*i)); - items = sp_degroup_list (items); // converting to path may have added more groups, descend again + items_copy = sp_degroup_list (items_copy); // converting to path may have added more groups, descend again - sort(items.begin(),items.end(),less_than_items); - assert(!items.empty()); // cannot be NULL because of list length check at top of function + sort(items_copy.begin(),items_copy.end(),less_than_items); + assert(!items_copy.empty()); // cannot be NULL because of list length check at top of function // remember the position, id, transform and style of the topmost path, they will be assigned to the combined one gint position = 0; @@ -95,10 +100,10 @@ sp_selected_path_combine(SPDesktop *desktop, bool skip_undo) Inkscape::XML::Node *parent = NULL; if (did) { - selection->clear(); + clear(); } - for (std::vector::const_reverse_iterator i = items.rbegin(); i != items.rend(); ++i){ + for (std::vector::const_reverse_iterator i = items_copy.rbegin(); i != items_copy.rend(); ++i){ SPItem *item = *i; SPPath *path = dynamic_cast(item); @@ -107,7 +112,7 @@ sp_selected_path_combine(SPDesktop *desktop, bool skip_undo) } if (!did) { - selection->clear(); + clear(); did = true; } @@ -142,7 +147,7 @@ sp_selected_path_combine(SPDesktop *desktop, bool skip_undo) first->deleteObject(false); // delete the topmost. - Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); + Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); // restore id, transform, path effect, and style @@ -170,37 +175,40 @@ sp_selected_path_combine(SPDesktop *desktop, bool skip_undo) // move to the position of the topmost, reduced by the number of deleted items repr->setPosition(position > 0 ? position : 0); if ( !skip_undo ) { - DocumentUndo::done(desktop->getDocument(), SP_VERB_SELECTION_COMBINE, + DocumentUndo::done(doc, SP_VERB_SELECTION_COMBINE, _("Combine")); } - selection->set(repr); + set(repr); Inkscape::GC::release(repr); } else { - desktop->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("No path(s) to combine in the selection.")); + if(desktop()) + desktop()->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("No path(s) to combine in the selection.")); } - desktop->clearWaitingCursor(); + if(desktop()) + desktop()->clearWaitingCursor(); } void -sp_selected_path_break_apart(SPDesktop *desktop, bool skip_undo) +ObjectSet::breakApart(bool skip_undo) { - Inkscape::Selection *selection = desktop->getSelection(); - - if (selection->isEmpty()) { - desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select path(s) to break apart.")); + if (isEmpty()) { + if(desktop()) + desktop()->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select path(s) to break apart.")); return; } - - desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Breaking apart paths...")); - // set "busy" cursor - desktop->setWaitingCursor(); + if(desktop()){ + desktop()->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Breaking apart paths...")); + // set "busy" cursor + desktop()->setWaitingCursor(); + + } bool did = false; - std::vector itemlist(selection->items().begin(), selection->items().end()); + std::vector itemlist(items().begin(), items().end()); for (std::vector::const_iterator i = itemlist.begin(); i != itemlist.end(); ++i){ SPItem *item = *i; @@ -264,83 +272,83 @@ sp_selected_path_break_apart(SPDesktop *desktop, bool skip_undo) Inkscape::GC::release(repr); } - selection->setReprList(reprs); + setReprList(reprs); g_slist_free(list); g_free(style); g_free(path_effect); } - - desktop->clearWaitingCursor(); + + if(desktop()) + desktop()->clearWaitingCursor(); if (did) { if ( !skip_undo ) { - DocumentUndo::done(desktop->getDocument(), SP_VERB_SELECTION_BREAK_APART, + DocumentUndo::done(document(), SP_VERB_SELECTION_BREAK_APART, _("Break apart")); } } else { - desktop->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("No path(s) to break apart in the selection.")); + if(desktop()) + desktop()->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("No path(s) to break apart in the selection.")); } } -/* This function is an entry point from GUI */ -void -sp_selected_path_to_curves(Inkscape::Selection *selection, SPDesktop *desktop, bool interactive) +void ObjectSet::toCurves(bool skip_undo) { - if (selection->isEmpty()) { - if (interactive && desktop) - desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select object(s) to convert to path.")); + if (isEmpty()) { + if (desktop()) + desktop()->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select object(s) to convert to path.")); return; } bool did = false; - if (interactive && desktop) { - desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Converting objects to paths...")); + if (desktop()) { + desktop()->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Converting objects to paths...")); // set "busy" cursor - desktop->setWaitingCursor(); + desktop()->setWaitingCursor(); } - std::vector selected(selection->items().begin(), selection->items().end()); + std::vector selected(items().begin(), items().end()); std::vector to_select; - selection->clear(); + clear(); std::vector items(selected); did = sp_item_list_to_curves(items, selected, to_select); - selection->setReprList(to_select); - selection->addList(selected); + setReprList(to_select); + addList(selected); - if (interactive && desktop) { - desktop->clearWaitingCursor(); - if (did) { - DocumentUndo::done(desktop->getDocument(), SP_VERB_OBJECT_TO_CURVE, + if (desktop()) { + desktop()->clearWaitingCursor(); + } + if (did&& !skip_undo) { + DocumentUndo::done(document(), SP_VERB_OBJECT_TO_CURVE, _("Object to path")); - } else { - desktop->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("No objects to convert to path in the selection.")); - return; - } + } else { + if(desktop()) + desktop()->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("No objects to convert to path in the selection.")); + return; } } /** Converts the selected items to LPEItems if they are not already so; e.g. SPRects) */ -void sp_selected_to_lpeitems(SPDesktop *desktop) +void ObjectSet::toLPEItems() { - Inkscape::Selection *selection = desktop->getSelection(); - if (selection->isEmpty()) { + if (isEmpty()) { return; } - std::vector selected(selection->items().begin(), selection->items().end()); + std::vector selected(items().begin(), items().end()); std::vector to_select; - selection->clear(); + clear(); std::vector items(selected); sp_item_list_to_curves(items, selected, to_select, true); - selection->setReprList(to_select); - selection->addList(selected); + setReprList(to_select); + addList(selected); } bool @@ -597,24 +605,24 @@ sp_selected_item_to_curved_repr(SPItem *item, guint32 /*text_grouping_policy*/) void -sp_selected_path_reverse(SPDesktop *desktop) +ObjectSet::pathReverse() { - Inkscape::Selection *selection = desktop->getSelection(); - auto items = selection->items(); - - if (items.empty()) { - desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select path(s) to reverse.")); + if (isEmpty()) { + if(desktop()) + desktop()->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select path(s) to reverse.")); return; } // set "busy" cursor - desktop->setWaitingCursor(); - + if(desktop()){ + desktop()->setWaitingCursor(); + desktop()->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Reversing paths...")); + } + bool did = false; - desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Reversing paths...")); - for (auto i = items.begin(); i != items.end(); ++i){ + for (auto i = items().begin(); i != items().end(); ++i){ SPPath *path = dynamic_cast(*i); if (!path) { @@ -642,14 +650,15 @@ sp_selected_path_reverse(SPDesktop *desktop) g_free(nodetypes); } } - - desktop->clearWaitingCursor(); + if(desktop()) + desktop()->clearWaitingCursor(); if (did) { - DocumentUndo::done(desktop->getDocument(), SP_VERB_SELECTION_REVERSE, + DocumentUndo::done(document(), SP_VERB_SELECTION_REVERSE, _("Reverse path")); } else { - desktop->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("No paths to reverse in the selection.")); + if(desktop()) + desktop()->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("No paths to reverse in the selection.")); } } -- cgit v1.2.3 From 69ba226147751a529c9561925b2737fa3071ecd2 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Sat, 3 Dec 2016 20:05:32 +0100 Subject: Improvements and fixes for buds pointed by suv on measure line LPE (bzr r15294) --- src/path-chemistry.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/path-chemistry.cpp') diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index a19ca9524..741f433f2 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -552,7 +552,8 @@ sp_selected_item_to_curved_repr(SPItem *item, guint32 /*text_grouping_policy*/) return g_repr; } - + + SP_LPE_ITEM(item)->removeAllPathEffects(true); SPCurve *curve = NULL; { SPShape *shape = dynamic_cast(item); -- cgit v1.2.3 From 6c05c1c14cb8d29fb06d6779ec9817615c518ab5 Mon Sep 17 00:00:00 2001 From: chr Date: Thu, 18 May 2017 19:58:59 +0200 Subject: fix a brunch of memory leaks (bzr r15698.1.2) --- src/path-chemistry.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/path-chemistry.cpp') diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index b66bcf368..7840c4ca8 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -255,8 +255,9 @@ ObjectSet::breakApart(bool skip_undo) repr->setAttribute("inkscape:original-d", str); else repr->setAttribute("d", str); + str = sp_svg_transform_write(transform); + repr->setAttribute("transform", str); g_free(str); - repr->setAttribute("transform", sp_svg_transform_write(transform)); // add the new repr to the parent parent->appendChild(repr); -- cgit v1.2.3