diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2016-03-14 16:37:50 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2016-03-14 16:37:50 +0000 |
| commit | b8d22beef5345210ad27cdc2685083aeae6f8f3b (patch) | |
| tree | d69b8bfd19d3627a8425a1b265c2abf229b05354 /src/extension/implementation/script.cpp | |
| parent | fixes for update to trunk (diff) | |
| parent | "Relative to" option for node alignment. (diff) | |
| download | inkscape-b8d22beef5345210ad27cdc2685083aeae6f8f3b.tar.gz inkscape-b8d22beef5345210ad27cdc2685083aeae6f8f3b.zip | |
update to trunk
(bzr r13708.1.39)
Diffstat (limited to 'src/extension/implementation/script.cpp')
| -rw-r--r-- | src/extension/implementation/script.cpp | 59 |
1 files changed, 54 insertions, 5 deletions
diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index e07a3963c..4cb0c9b73 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -41,8 +41,12 @@ #include "ui/view/view.h" #include "xml/node.h" #include "xml/attribute-record.h" +#include "ui/tools/node-tool.h" +#include "ui/tool/multi-path-manipulator.h" +#include "ui/tool/path-manipulator.h" +#include "ui/tool/control-point-selection.h" + -#include "util/glib-list-iterators.h" #include "path-prefix.h" #ifdef WIN32 @@ -310,9 +314,9 @@ bool Script::load(Inkscape::Extension::Extension *module) const gchar *interpretstr = child_repr->attribute("interpreter"); if (interpretstr != NULL) { std::string interpString = resolveInterpreterExecutable(interpretstr); - command.insert(command.end(), interpString); + command.push_back(interpString); } - command.insert(command.end(), solve_reldir(child_repr)); + command.push_back(solve_reldir(child_repr)); } if (!strcmp(child_repr->name(), INKSCAPE_EXTENSION_NS "helper_extension")) { helper_extension = child_repr->firstChild()->content(); @@ -691,13 +695,56 @@ void Script::effect(Inkscape::Extension::Effect *module, std::vector<SPItem*> selected = desktop->getSelection()->itemList(); //desktop should not be NULL since doc was checked and desktop is a casted pointer - for(std::vector<SPItem*>::const_iterator x = selected.begin(); x != selected.end(); x++){ + for(std::vector<SPItem*>::const_iterator x = selected.begin(); x != selected.end(); ++x){ Glib::ustring selected_id; selected_id += "--id="; selected_id += (*x)->getId(); - params.insert(params.begin(), selected_id); + params.push_front(selected_id); } + {//add selected nodes + Inkscape::UI::Tools::NodeTool *tool = 0; + if (SP_ACTIVE_DESKTOP ) { + Inkscape::UI::Tools::ToolBase *ec = SP_ACTIVE_DESKTOP->event_context; + if (INK_IS_NODE_TOOL(ec)) { + tool = static_cast<Inkscape::UI::Tools::NodeTool*>(ec); + } + } + + if(tool){ + Inkscape::UI::ControlPointSelection *cps = tool->_selected_nodes; + for (Inkscape::UI::ControlPointSelection::iterator i = cps->begin(); i != cps->end(); ++i) { + Inkscape::UI::Node *node = dynamic_cast<Inkscape::UI::Node*>(*i); + if (node) { + std::string id = node->nodeList().subpathList().pm().item()->getId(); + + int sp = 0; + bool found_sp = false; + for(Inkscape::UI::SubpathList::iterator i = node->nodeList().subpathList().begin(); i != node->nodeList().subpathList().end(); ++i,++sp){ + if(&**i == &(node->nodeList())){ + found_sp = true; + break; + } + } + int nl=0; + bool found_nl = false; + for (Inkscape::UI::NodeList::iterator j = node->nodeList().begin(); j != node->nodeList().end(); ++j, ++nl){ + if(&*j==node){ + found_nl = true; + break; + } + } + std::ostringstream ss; + ss<< "--selected-nodes=" << id << ":" << sp << ":" << nl; + Glib::ustring selected = ss.str(); + + if(found_nl && found_sp)params.push_front(selected); + else g_warning("Something went wrong while trying to pass selected nodes to extension. Please report a bug."); + } + } + } + }//end add selected nodes + file_listener fileout; int data_read = execute(command, params, dc->_filename, fileout); fileout.toFile(tempfilename_out); @@ -1014,6 +1061,8 @@ int Script::execute (const std::list<std::string> &in_command, } } + //for(int i=0;i<argv.size(); ++i){printf("%s ",argv[i].c_str());}printf("\n"); + int stdout_pipe, stderr_pipe; try { |
