summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLiam P. White <inkscapebrony@gmail.com>2014-08-14 22:10:29 +0000
committerLiam P. White <inkscapebrony@gmail.com>2014-08-14 22:10:29 +0000
commit527aea8e906f12c1b5e6072321fa48f09d60bab5 (patch)
tree64b86a36ff46e5364cc168c7afa350783323c557 /src
parentUpdate to experimental r13479 (diff)
downloadinkscape-527aea8e906f12c1b5e6072321fa48f09d60bab5.tar.gz
inkscape-527aea8e906f12c1b5e6072321fa48f09d60bab5.zip
Clone Original -> Fill Between Many
(bzr r13090.1.104)
Diffstat (limited to 'src')
-rw-r--r--src/selection-chemistry.cpp85
1 files changed, 42 insertions, 43 deletions
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index 1d7d76609..33279c0e7 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -2793,54 +2793,53 @@ void sp_selection_clone_original_path_lpe(SPDesktop *desktop)
if (desktop == NULL) {
return;
}
-
- Inkscape::Selection *selection = sp_desktop_selection(desktop);
- SPItem *item = selection->singleItem();
- if (g_slist_length(const_cast<GSList *>(selection->itemList())) != 1 || !item) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>one</b> path to clone."));
- return;
- }
- if ( !(SP_IS_SHAPE(item) || SP_IS_TEXT(item)) ) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select one <b>path</b> to clone."));
- return;
- }
-
- Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
- Inkscape::XML::Node *parent = item->getRepr()->parent();
-
- // create the LPE
- Inkscape::XML::Node *lpe_repr = xml_doc->createElement("inkscape:path-effect");
- {
- lpe_repr->setAttribute("effect", "clone_original");
- gchar *href = g_strdup_printf("#%s", item->getRepr()->attribute("id"));
- lpe_repr->setAttribute("linkedpath", href);
- g_free(href);
- desktop->doc()->getDefs()->getRepr()->addChild(lpe_repr, NULL); // adds to <defs> and assigns the 'id' attribute
- }
- const gchar * lpe_id = lpe_repr->attribute("id");
- Inkscape::GC::release(lpe_repr);
-
- // create the new path
- Inkscape::XML::Node *clone = xml_doc->createElement("svg:path");
- {
- clone->setAttribute("d", "M 0 0", false);
- // add the new clone to the top of the original's parent
- parent->appendChild(clone);
- SPObject *clone_obj = desktop->doc()->getObjectById(clone->attribute("id"));
- if (SP_IS_LPE_ITEM(clone_obj)) {
- gchar *href = g_strdup_printf("#%s", lpe_id);
- SP_LPE_ITEM(clone_obj)->addPathEffect( href, false );
- g_free(href);
+
+ Inkscape::SVGOStringStream os;
+ SPObject * firstItem = NULL;
+ for (const GSList * item = desktop->selection->itemList(); item != NULL; item = item->next) {
+ if (SP_IS_SHAPE(item->data) || SP_IS_TEXT(item->data)) {
+ if (firstItem) {
+ os << "|";
+ } else {
+ firstItem = SP_ITEM(item->data);
+ }
+ os << "#" << SP_ITEM(item->data)->getId() << ",0";
}
}
+ if (firstItem) {
+ Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
+ SPObject *parent = firstItem->parent;
- DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_CLONE_ORIGINAL_PATH_LPE,
- _("Clone original path"));
+ // create the LPE
+ Inkscape::XML::Node *lpe_repr = xml_doc->createElement("inkscape:path-effect");
+ {
+ lpe_repr->setAttribute("effect", "fill_between_many");
+ lpe_repr->setAttribute("linkedpaths", os.str().c_str());
+ desktop->doc()->getDefs()->getRepr()->addChild(lpe_repr, NULL); // adds to <defs> and assigns the 'id' attribute
+ }
+ const gchar * lpe_id = lpe_repr->attribute("id");
+ Inkscape::GC::release(lpe_repr);
- // select the new object:
- selection->set(clone);
+ // create the new path
+ Inkscape::XML::Node *clone = xml_doc->createElement("svg:path");
+ {
+ clone->setAttribute("d", "M 0 0", false);
+ // add the new clone to the top of the original's parent
+ parent->appendChildRepr(clone);
+ SPObject *clone_obj = desktop->doc()->getObjectById(clone->attribute("id"));
+ if (SP_IS_LPE_ITEM(clone_obj)) {
+ gchar *href = g_strdup_printf("#%s", lpe_id);
+ //sp_lpe_item_add_path_effect( SP_LPE_ITEM(clone_obj), href, false );
+ SP_LPE_ITEM(clone_obj)->addPathEffect(href, false);
+ g_free(href);
+ }
+ }
- Inkscape::GC::release(clone);
+ DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_EDIT_CLONE_ORIGINAL_PATH_LPE,
+ _("Fill between strokes"));
+ } else {
+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select path(s) to fill."));
+ }
}
void sp_selection_to_marker(SPDesktop *desktop, bool apply)