From 193b25a53c51a36fe9538e03203b0054c8cfc355 Mon Sep 17 00:00:00 2001 From: mc <> Date: Wed, 18 Feb 2015 02:02:37 +0100 Subject: Just... some... more... lines... (bzr r13922.1.2) --- src/ui/tools/eraser-tool.cpp | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) (limited to 'src/ui/tools/eraser-tool.cpp') diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 1b4dcfe25..3526e015a 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -676,7 +676,7 @@ void EraserTool::set_to_accumulated() { Geom::OptRect eraserBbox = acid->visualBounds(); Geom::Rect bounds = (*eraserBbox) * desktop->doc2dt(); std::vector remainingItems; - GSList* toWorkOn = 0; + SelContainer toWorkOn; if (selection->isEmpty()) { if ( eraserMode ) { @@ -686,16 +686,16 @@ void EraserTool::set_to_accumulated() { toWorkOn = desktop->getDocument()->getItemsAtPoints(desktop->dkey, r->getPoints()); } - toWorkOn = g_slist_remove( toWorkOn, acid ); + toWorkOn.remove(static_cast(acid) ); } else { - toWorkOn = g_slist_copy(const_cast(selection->itemList())); + toWorkOn = selection->itemList(); wasSelection = true; } - if ( g_slist_length(toWorkOn) > 0 ) { + if ( !toWorkOn.empty() ) { if ( eraserMode ) { - for (GSList *i = toWorkOn ; i ; i = i->next ) { - SPItem *item = SP_ITEM(i->data); + for (SelContainer::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { + SPItem *item = SP_ITEM(*i); if ( eraserMode ) { Geom::OptRect bbox = item->visualBounds(); @@ -712,13 +712,10 @@ void EraserTool::set_to_accumulated() { if ( !selection->isEmpty() ) { // If the item was not completely erased, track the new remainder. - GSList *nowSel = g_slist_copy(const_cast(selection->itemList())); - - for (GSList const *i2 = nowSel ; i2 ; i2 = i2->next ) { - remainingItems.push_back(SP_ITEM(i2->data)); + SelContainer nowSel(selection->itemList()); + for (SelContainer::const_iterator i2 = nowSel.begin();i!=nowSel.end();i++) { + remainingItems.push_back(SP_ITEM(*i2)); } - - g_slist_free(nowSel); } } else { remainingItems.push_back(item); @@ -726,20 +723,18 @@ void EraserTool::set_to_accumulated() { } } } else { - for (GSList *i = toWorkOn ; i ; i = i->next ) { - sp_object_ref( SP_ITEM(i->data), 0 ); + for (SelContainer::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { + sp_object_ref( SP_ITEM(*i), 0 ); } - for (GSList *i = toWorkOn ; i ; i = i->next ) { - SPItem *item = SP_ITEM(i->data); + for (SelContainer::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { + SPItem *item = SP_ITEM(*i); item->deleteObject(true); sp_object_unref(item); workDone = true; } } - g_slist_free(toWorkOn); - if ( !eraserMode ) { //sp_selection_delete(desktop); remainingItems.clear(); -- cgit v1.2.3 From 5fd00cab14d48beaf2279a2b8f3ad5b02b76c87b Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Thu, 19 Feb 2015 04:25:21 +0100 Subject: Put a few std::vector (bzr r13922.1.5) --- src/ui/tools/eraser-tool.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/ui/tools/eraser-tool.cpp') diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 3526e015a..520b93e72 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -676,8 +676,7 @@ void EraserTool::set_to_accumulated() { Geom::OptRect eraserBbox = acid->visualBounds(); Geom::Rect bounds = (*eraserBbox) * desktop->doc2dt(); std::vector remainingItems; - SelContainer toWorkOn; - + std::vector toWorkOn; if (selection->isEmpty()) { if ( eraserMode ) { toWorkOn = desktop->getDocument()->getItemsPartiallyInBox(desktop->dkey, bounds); @@ -685,16 +684,15 @@ void EraserTool::set_to_accumulated() { Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop); toWorkOn = desktop->getDocument()->getItemsAtPoints(desktop->dkey, r->getPoints()); } - - toWorkOn.remove(static_cast(acid) ); + toWorkOn.erase(find(toWorkOn.begin(),toWorkOn.end(),acid)); } else { - toWorkOn = selection->itemList(); + toWorkOn= selection->itemList(); wasSelection = true; } if ( !toWorkOn.empty() ) { if ( eraserMode ) { - for (SelContainer::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { + for (std::vector::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { SPItem *item = SP_ITEM(*i); if ( eraserMode ) { @@ -712,8 +710,8 @@ void EraserTool::set_to_accumulated() { if ( !selection->isEmpty() ) { // If the item was not completely erased, track the new remainder. - SelContainer nowSel(selection->itemList()); - for (SelContainer::const_iterator i2 = nowSel.begin();i!=nowSel.end();i++) { + std::vector nowSel(selection->itemList()); + for (std::vector::const_iterator i2 = nowSel.begin();i!=nowSel.end();i2++) { remainingItems.push_back(SP_ITEM(*i2)); } } @@ -723,11 +721,11 @@ void EraserTool::set_to_accumulated() { } } } else { - for (SelContainer::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { + for (std::vector ::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { sp_object_ref( SP_ITEM(*i), 0 ); } - for (SelContainer::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { + for (std::vector::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { SPItem *item = SP_ITEM(*i); item->deleteObject(true); sp_object_unref(item); -- cgit v1.2.3 From 7e4b6f793d31d3245bd8afbf6f10aa255ac3e7ae Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Thu, 19 Feb 2015 20:20:09 +0100 Subject: added a set to the Selection (bzr r13922.1.6) --- src/ui/tools/eraser-tool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/tools/eraser-tool.cpp') diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 520b93e72..b61a108f0 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -711,7 +711,7 @@ void EraserTool::set_to_accumulated() { if ( !selection->isEmpty() ) { // If the item was not completely erased, track the new remainder. std::vector nowSel(selection->itemList()); - for (std::vector::const_iterator i2 = nowSel.begin();i!=nowSel.end();i2++) { + for (std::vector::const_iterator i2 = nowSel.begin();i2!=nowSel.end();i2++) { remainingItems.push_back(SP_ITEM(*i2)); } } -- cgit v1.2.3 From 9a7fa4d1899d30ec745107823f307b2a0bf3172f Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Fri, 27 Feb 2015 03:10:36 +0100 Subject: corrected the casts (hopefully) (bzr r13922.1.10) --- src/ui/tools/eraser-tool.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/ui/tools/eraser-tool.cpp') diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index b61a108f0..adbbb2bd3 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -692,8 +692,8 @@ void EraserTool::set_to_accumulated() { if ( !toWorkOn.empty() ) { if ( eraserMode ) { - for (std::vector::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { - SPItem *item = SP_ITEM(*i); + for (std::vector::const_iterator i = toWorkOn.begin(); i != toWorkOn.end(); i++){ + SPItem *item = *i; if ( eraserMode ) { Geom::OptRect bbox = item->visualBounds(); @@ -712,7 +712,7 @@ void EraserTool::set_to_accumulated() { // If the item was not completely erased, track the new remainder. std::vector nowSel(selection->itemList()); for (std::vector::const_iterator i2 = nowSel.begin();i2!=nowSel.end();i2++) { - remainingItems.push_back(SP_ITEM(*i2)); + remainingItems.push_back(*i2); } } } else { @@ -722,11 +722,11 @@ void EraserTool::set_to_accumulated() { } } else { for (std::vector ::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { - sp_object_ref( SP_ITEM(*i), 0 ); + sp_object_ref( *i, 0 ); } for (std::vector::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; item->deleteObject(true); sp_object_unref(item); workDone = true; -- cgit v1.2.3