summaryrefslogtreecommitdiffstats
path: root/src/selection.cpp
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2018-02-26 21:29:38 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2018-05-09 19:42:10 +0000
commitae4c0eb49fe82e38ed782430e69190ff374389c7 (patch)
tree2e2642d9f9a90ecde15d7952ecd823150fd5886f /src/selection.cpp
parentfix compiling problems on selection (diff)
downloadinkscape-ae4c0eb49fe82e38ed782430e69190ff374389c7.tar.gz
inkscape-ae4c0eb49fe82e38ed782430e69190ff374389c7.zip
Add patch to branch https://inkscape.org/en/paste/10993/
Diffstat (limited to 'src/selection.cpp')
-rw-r--r--src/selection.cpp153
1 files changed, 77 insertions, 76 deletions
diff --git a/src/selection.cpp b/src/selection.cpp
index f4a76365e..230073bcd 100644
--- a/src/selection.cpp
+++ b/src/selection.cpp
@@ -189,60 +189,60 @@ void
Selection::setBackup ()
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ SPDocument *document = SP_ACTIVE_DOCUMENT;
+ Inkscape::UI::Tools::NodeTool *tool = 0;
if (desktop) {
- _selected_ids.clear();
- _seldata.clear();
- params.clear();
- auto items = const_cast<Selection *>(this)->items();
- for (auto iter = items.begin(); iter != items.end(); ++iter) {
- SPItem *item = *iter;
- std::string selected_id;
- selected_id += "--id=";
- selected_id += item->getId();
- params.push_front(selected_id);
- _selected_ids.push_back(item->getId());
- }
- Inkscape::UI::Tools::NodeTool *tool = 0;
-
Inkscape::UI::Tools::ToolBase *ec = 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;
- std::list<Inkscape::UI::SelectableControlPoint *> points_list = cps->_points_list;
- for (std::list<Inkscape::UI::SelectableControlPoint *>::iterator i = points_list.begin(); i != points_list.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;
- }
+ }
+ _selected_ids.clear();
+ _seldata.clear();
+ params.clear();
+ auto items = const_cast<Selection *>(this)->items();
+ for (auto iter = items.begin(); iter != items.end(); ++iter) {
+ SPItem *item = *iter;
+ std::string selected_id;
+ selected_id += "--id=";
+ selected_id += item->getId();
+ params.push_back(selected_id);
+ _selected_ids.push_back(item->getId());
+ }
+ if(tool){
+ Inkscape::UI::ControlPointSelection *cps = tool->_selected_nodes;
+ std::list<Inkscape::UI::SelectableControlPoint *> points_list = cps->_points_list;
+ for (std::list<Inkscape::UI::SelectableControlPoint *>::iterator i = points_list.begin(); i != points_list.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;
}
- std::ostringstream ss;
- ss<< "--selected-nodes=" << id << ":" << sp << ":" << nl;
- Glib::ustring selected_nodes = ss.str();
-
- if(found_nl && found_sp) {
- _seldata.push_back(std::make_pair(id,std::make_pair(sp,nl)));
- params.push_back(selected_nodes);
- } else {
- g_warning("Something went wrong while trying to pass selected nodes to extension. Please report a bug.");
+ }
+ 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_nodes = ss.str();
+
+ if(found_nl && found_sp) {
+ _seldata.push_back(std::make_pair(id,std::make_pair(sp,nl)));
+ params.push_back(selected_nodes);
+ } else {
+ g_warning("Something went wrong while trying to pass selected nodes to extension. Please report a bug.");
+ }
}
}
}//end add selected nodes
@@ -252,48 +252,49 @@ void
Selection::restoreBackup()
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ SPDocument *document = SP_ACTIVE_DOCUMENT;
+ Inkscape::UI::Tools::NodeTool *tool = 0;
if (desktop) {
- Inkscape::UI::Tools::NodeTool *tool = 0;
Inkscape::UI::Tools::ToolBase *ec = desktop->event_context;
if (INK_IS_NODE_TOOL(ec)) {
tool = static_cast<Inkscape::UI::Tools::NodeTool*>(ec);
}
- clear();
- std::vector<std::string>::reverse_iterator rit = _selected_ids.rbegin();
- for (; rit!= _selected_ids.rend(); ++rit){
- SPObject * obj = desktop->doc()->getObjectById(rit->c_str());
- SPDefs * defs = desktop->getDocument()->getDefs();
- if (obj && !defs->isAncestorOf(obj)) {
- add(obj);
- }
+ }
+ clear();
+ std::vector<std::string>::iterator it = _selected_ids.begin();
+ for (; it!= _selected_ids.end(); ++it){
+ SPItem * item = dynamic_cast<SPItem *>(document->getObjectById(it->c_str()));
+ SPDefs * defs = document->getDefs();
+ if (item && !defs->isAncestorOf(item)) {
+ add(item);
}
- if (tool) {
- Inkscape::UI::ControlPointSelection *cps = tool->_selected_nodes;
- cps->selectAll();
- std::list<Inkscape::UI::SelectableControlPoint *> points_list = cps->_points_list;
- cps->clear();
- Inkscape::UI::Node * node = dynamic_cast<Inkscape::UI::Node*>(*points_list.begin());
- if (node) {
- Inkscape::UI::SubpathList sp = node->nodeList().subpathList();
- for (std::vector<std::pair<std::string, std::pair<int, int> > >::iterator l = _seldata.begin(); l != _seldata.end(); ++l) {
- SPPath * path = dynamic_cast<SPPath *>(desktop->doc()->getObjectById(l->first));
- gint sp_count = 0;
- for (Inkscape::UI::SubpathList::iterator j = sp.begin(); j != sp.end(); ++j, ++sp_count) {
- if(sp_count == l->second.first) {
- gint nt_count = 0;
- for (Inkscape::UI::NodeList::iterator k = (*j)->begin(); k != (*j)->end(); ++k, ++nt_count) {
- if(nt_count == l->second.second) {
- k->select(true);
- break;
- }
+ }
+ if (tool) {
+ Inkscape::UI::ControlPointSelection *cps = tool->_selected_nodes;
+ cps->selectAll();
+ std::list<Inkscape::UI::SelectableControlPoint *> points_list = cps->_points_list;
+ cps->clear();
+ Inkscape::UI::Node * node = dynamic_cast<Inkscape::UI::Node*>(*points_list.begin());
+ if (node) {
+ Inkscape::UI::SubpathList sp = node->nodeList().subpathList();
+ for (std::vector<std::pair<std::string, std::pair<int, int> > >::iterator l = _seldata.begin(); l != _seldata.end(); ++l) {
+ SPPath * path = dynamic_cast<SPPath *>(document->getObjectById(l->first));
+ gint sp_count = 0;
+ for (Inkscape::UI::SubpathList::iterator j = sp.begin(); j != sp.end(); ++j, ++sp_count) {
+ if(sp_count == l->second.first) {
+ gint nt_count = 0;
+ for (Inkscape::UI::NodeList::iterator k = (*j)->begin(); k != (*j)->end(); ++k, ++nt_count) {
+ if(nt_count == l->second.second) {
+ cps->insert(k.ptr());
+ break;
}
- break;
}
+ break;
}
}
}
- points_list.clear();
}
+ points_list.clear();
}
}