From 710d4b83c310bd2fe9958aa22a9938b7ddb022a7 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 13 Feb 2016 02:41:52 +0100 Subject: Improved eraser tool, now working on documents not pixels and with 0 width (bzr r14648.1.1) --- src/ui/tools/eraser-tool.cpp | 159 ++++++++++++++++++++++--------------------- src/ui/tools/eraser-tool.h | 1 + 2 files changed, 81 insertions(+), 79 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 83ecf7a0a..51068a3ae 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -96,6 +96,7 @@ const std::string EraserTool::prefsPath = "/tools/eraser"; EraserTool::EraserTool() : DynamicBase(cursor_eraser_xpm, 4, 4) + , nowidth(false) { } @@ -145,6 +146,7 @@ static ProfileFloatElement f_profile[PROFILE_FLOAT_SIZE] = { sp_event_context_read(this, "cap_rounding"); this->is_drawing = false; + //TODO not sure why get 0.01 if slider width == 0, maybe a double/int problem Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/tools/eraser/selcue", 0) != 0) { @@ -339,7 +341,10 @@ void EraserTool::brush() { this->point1[this->npoints] = brush + del_left; this->point2[this->npoints] = brush - del_right; - + + if (this->nowidth) { + this->point1[this->npoints] = Geom::middle_point(this->point1[this->npoints],this->point2[this->npoints]); + } this->del = 0.5*(del_left + del_right); this->npoints++; @@ -489,33 +494,32 @@ bool EraserTool::root_handler(GdkEvent* event) { case GDK_KEY_PRESS: switch (get_group0_keyval (&event->key)) { - case GDK_KEY_Up: - case GDK_KEY_KP_Up: - if (!MOD__CTRL_ONLY(event)) { - this->angle += 5.0; - - if (this->angle > 90.0) { - this->angle = 90.0; - } - - sp_erc_update_toolbox (desktop, "eraser-angle", this->angle); - ret = TRUE; - } - break; - - case GDK_KEY_Down: - case GDK_KEY_KP_Down: - if (!MOD__CTRL_ONLY(event)) { - this->angle -= 5.0; - - if (this->angle < -90.0) { - this->angle = -90.0; - } - - sp_erc_update_toolbox (desktop, "eraser-angle", this->angle); - ret = TRUE; - } - break; +// case GDK_KEY_Up: +// case GDK_KEY_KP_Up: +// if (!MOD__CTRL_ONLY(event)) { +// this->angle += 5.0; + +// if (this->angle > 90.0) { +// this->angle = 90.0; +// } +// sp_erc_update_toolbox (desktop, "eraser-angle", this->angle); +// ret = TRUE; +// } +// break; + +// case GDK_KEY_Down: +// case GDK_KEY_KP_Down: +// if (!MOD__CTRL_ONLY(event)) { +// this->angle -= 5.0; + +// if (this->angle < -90.0) { +// this->angle = -90.0; +// } + +// sp_erc_update_toolbox (desktop, "eraser-angle", this->angle); +// ret = TRUE; +// } +// break; case GDK_KEY_Right: case GDK_KEY_KP_Right: @@ -640,20 +644,16 @@ void EraserTool::set_to_accumulated() { sp_desktop_apply_style_tool (desktop, repr, "/tools/eraser", false); this->repr = repr; - - SPItem *item=SP_ITEM(desktop->currentLayer()->appendChildRepr(this->repr)); - Inkscape::GC::release(this->repr); - - item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); - item->updateRepr(); } - + SPItem *item=SP_ITEM(desktop->currentLayer()->appendChildRepr(this->repr)); + Inkscape::GC::release(this->repr); + item->updateRepr(); Geom::PathVector pathv = this->accumulated->get_pathvector() * desktop->dt2doc(); + pathv *= item->i2doc_affine().inverse(); gchar *str = sp_svg_write_path(pathv); g_assert( str != NULL ); this->repr->setAttribute("d", str); g_free(str); - if ( this->repr ) { bool wasSelection = false; Inkscape::Selection *selection = desktop->getSelection(); @@ -663,13 +663,12 @@ void EraserTool::set_to_accumulated() { Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); SPItem* acid = SP_ITEM(desktop->doc()->getObjectByRepr(this->repr)); - Geom::OptRect eraserBbox = acid->visualBounds(); - Geom::Rect bounds = (*eraserBbox) * desktop->doc2dt(); + Geom::OptRect eraserBbox = acid->desktopVisualBounds(); std::vector remainingItems; std::vector toWorkOn; if (selection->isEmpty()) { if ( eraserMode ) { - toWorkOn = desktop->getDocument()->getItemsPartiallyInBox(desktop->dkey, bounds); + toWorkOn = desktop->getDocument()->getItemsPartiallyInBox(desktop->dkey, *eraserBbox); } else { Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop); toWorkOn = desktop->getDocument()->getItemsAtPoints(desktop->dkey, r->getPoints()); @@ -684,30 +683,30 @@ void EraserTool::set_to_accumulated() { if ( eraserMode ) { for (std::vector::const_iterator i = toWorkOn.begin(); i != toWorkOn.end(); ++i){ SPItem *item = *i; - - if ( eraserMode ) { - Geom::OptRect bbox = item->visualBounds(); - - if (bbox && bbox->intersects(*eraserBbox)) { - Inkscape::XML::Node* dup = this->repr->duplicate(xml_doc); - this->repr->parent()->appendChild(dup); - Inkscape::GC::release(dup); // parent takes over - - selection->set(item); - selection->add(dup); + Geom::OptRect bbox = item->desktopVisualBounds(); + if (bbox && bbox->intersects(*eraserBbox)) { + Inkscape::XML::Node* dup = this->repr->duplicate(xml_doc); + this->repr->parent()->appendChild(dup); + Inkscape::GC::release(dup); // parent takes over + + selection->set(item); + selection->add(dup); + if (this->nowidth) { + sp_selected_path_cut_skip_undo(selection, desktop); + } else { sp_selected_path_diff_skip_undo(selection, desktop); - workDone = true; // TODO set this only if something was cut. - - 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();i2!=nowSel.end();++i2) { - remainingItems.push_back(*i2); - } + } + workDone = true; // TODO set this only if something was cut. + + 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();i2!=nowSel.end();++i2) { + remainingItems.push_back(*i2); } - } else { - remainingItems.push_back(item); } + } else { + remainingItems.push_back(item); } } } else { @@ -811,24 +810,25 @@ void EraserTool::accumulate() { g_assert( rev_cal2_lastseg ); this->accumulated->append(this->cal1, FALSE); - - add_cap(this->accumulated, - dc_cal1_lastseg->finalPoint() - dc_cal1_lastseg->unitTangentAt(1), - dc_cal1_lastseg->finalPoint(), - rev_cal2_firstseg->initialPoint(), - rev_cal2_firstseg->initialPoint() + rev_cal2_firstseg->unitTangentAt(0), - this->cap_rounding); - - this->accumulated->append(rev_cal2, TRUE); - - add_cap(this->accumulated, - rev_cal2_lastseg->finalPoint() - rev_cal2_lastseg->unitTangentAt(1), - rev_cal2_lastseg->finalPoint(), - dc_cal1_firstseg->initialPoint(), - dc_cal1_firstseg->initialPoint() + dc_cal1_firstseg->unitTangentAt(0), - this->cap_rounding); - - this->accumulated->closepath(); + if(!this->nowidth) { + add_cap(this->accumulated, + dc_cal1_lastseg->finalPoint() - dc_cal1_lastseg->unitTangentAt(1), + dc_cal1_lastseg->finalPoint(), + rev_cal2_firstseg->initialPoint(), + rev_cal2_firstseg->initialPoint() + rev_cal2_firstseg->unitTangentAt(0), + this->cap_rounding); + + this->accumulated->append(rev_cal2, TRUE); + + add_cap(this->accumulated, + rev_cal2_lastseg->finalPoint() - rev_cal2_lastseg->unitTangentAt(1), + rev_cal2_lastseg->finalPoint(), + dc_cal1_firstseg->initialPoint(), + dc_cal1_firstseg->initialPoint() + dc_cal1_firstseg->unitTangentAt(0), + this->cap_rounding); + + this->accumulated->closepath(); + } rev_cal2->unref(); @@ -844,6 +844,8 @@ static double square(double const x) void EraserTool::fit_and_split(bool release) { double const tolerance_sq = square( desktop->w2d().descrim() * TOLERANCE_ERASER ); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + this->nowidth = prefs->getDouble( "/tools/eraser/width", 1) == 0; #ifdef ERASER_VERBOSE g_print("[F&S:R=%c]", release?'T':'F'); @@ -940,7 +942,6 @@ void EraserTool::fit_and_split(bool release) { g_print("[%d]Yup\n", this->npoints); #endif if (!release) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0; g_assert(!this->currentcurve->is_empty()); diff --git a/src/ui/tools/eraser-tool.h b/src/ui/tools/eraser-tool.h index 110f57ba3..50ce6b6e3 100644 --- a/src/ui/tools/eraser-tool.h +++ b/src/ui/tools/eraser-tool.h @@ -58,6 +58,7 @@ private: void accumulate(); void fit_and_split(bool release); void draw_temporary_box(); + bool nowidth; }; } -- cgit v1.2.3 From 5234acfed2a47dc2445475ec7a9e245f0f8dc729 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 1 Mar 2016 02:39:05 +0100 Subject: Improve fill rule and add mass option (bzr r14648.1.2) --- src/ui/tools/eraser-tool.cpp | 62 ++++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 19 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 51068a3ae..698415480 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -64,8 +64,11 @@ #include "livarot/Shape.h" #include "document-undo.h" #include "verbs.h" +#include "style.h" +#include "style-enums.h" #include <2geom/math-utils.h> #include <2geom/pathvector.h> +#include "path-chemistry.h" #include "display/curve.h" #include "ui/tools/eraser-tool.h" @@ -376,7 +379,8 @@ void EraserTool::cancel() { bool EraserTool::root_handler(GdkEvent* event) { gint ret = FALSE; - + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0; switch (event->type) { case GDK_BUTTON_PRESS: if (event->button.button == 1 && !this->space_panning) { @@ -396,10 +400,10 @@ bool EraserTool::root_handler(GdkEvent* event) { if (this->repr) { this->repr = NULL; } - - Inkscape::Rubberband::get(desktop)->start(desktop, button_dt); - Inkscape::Rubberband::get(desktop)->setMode(RUBBERBAND_MODE_TOUCHPATH); - + if ( ! eraserMode ) { + Inkscape::Rubberband::get(desktop)->start(desktop, button_dt); + Inkscape::Rubberband::get(desktop)->setMode(RUBBERBAND_MODE_TOUCHPATH); + } /* initialize first point */ this->npoints = 0; @@ -444,8 +448,9 @@ bool EraserTool::root_handler(GdkEvent* event) { ret = TRUE; } - - Inkscape::Rubberband::get(desktop)->move(motion_dt); + if ( !eraserMode ) { + Inkscape::Rubberband::get(desktop)->move(motion_dt); + } } break; @@ -485,7 +490,7 @@ bool EraserTool::root_handler(GdkEvent* event) { ret = TRUE; } - if (Inkscape::Rubberband::get(desktop)->is_started()) { + if (!eraserMode && Inkscape::Rubberband::get(desktop)->is_started()) { Inkscape::Rubberband::get(desktop)->stop(); } @@ -572,8 +577,9 @@ bool EraserTool::root_handler(GdkEvent* event) { break; case GDK_KEY_Escape: - Inkscape::Rubberband::get(desktop)->stop(); - + if ( !eraserMode ) { + Inkscape::Rubberband::get(desktop)->stop(); + } if (this->is_drawing) { // if drawing, cancel, otherwise pass it up for deselecting this->cancel(); @@ -645,7 +651,7 @@ void EraserTool::set_to_accumulated() { this->repr = repr; } - SPItem *item=SP_ITEM(desktop->currentLayer()->appendChildRepr(this->repr)); + SPItem *item = SP_ITEM(desktop->currentLayer()->appendChildRepr(this->repr)); Inkscape::GC::release(this->repr); item->updateRepr(); Geom::PathVector pathv = this->accumulated->get_pathvector() * desktop->dt2doc(); @@ -654,11 +660,11 @@ void EraserTool::set_to_accumulated() { g_assert( str != NULL ); this->repr->setAttribute("d", str); g_free(str); + if ( this->repr ) { bool wasSelection = false; Inkscape::Selection *selection = desktop->getSelection(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0; Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); @@ -675,32 +681,50 @@ void EraserTool::set_to_accumulated() { } toWorkOn.erase(std::remove(toWorkOn.begin(), toWorkOn.end(), acid), toWorkOn.end()); } else { - toWorkOn= selection->itemList(); + toWorkOn = selection->itemList(); wasSelection = true; } if ( !toWorkOn.empty() ) { if ( eraserMode ) { for (std::vector::const_iterator i = toWorkOn.begin(); i != toWorkOn.end(); ++i){ - SPItem *item = *i; + SPItem *item = *i; + SPUse *use = dynamic_cast(item); + if (SP_IS_GROUP(item) || use ) { + continue; + } Geom::OptRect bbox = item->desktopVisualBounds(); if (bbox && bbox->intersects(*eraserBbox)) { Inkscape::XML::Node* dup = this->repr->duplicate(xml_doc); this->repr->parent()->appendChild(dup); Inkscape::GC::release(dup); // parent takes over - - selection->set(item); - selection->add(dup); + selection->set(dup); + sp_selected_path_union(selection, desktop); + selection->add(item); + if(item->style->fill_rule.value == SP_WIND_RULE_EVENODD){ + SPCSSAttr *css = sp_repr_css_attr_new(); + sp_repr_css_set_property(css, "fill-rule", "evenodd"); + sp_desktop_set_style(desktop, css); + sp_repr_css_attr_unref(css); + css = 0; + } if (this->nowidth) { sp_selected_path_cut_skip_undo(selection, desktop); } else { sp_selected_path_diff_skip_undo(selection, desktop); } workDone = true; // TODO set this only if something was cut. - + bool break_apart = prefs->getBool("/tools/eraser/break_apart", false); + if(!break_apart){ + sp_selected_path_combine(desktop); + } else { + if(!this->nowidth){ + sp_selected_path_break_apart(desktop); + } + } if ( !selection->isEmpty() ) { // If the item was not completely erased, track the new remainder. - std::vector nowSel(selection->itemList()); + std::vector nowSel(selection->itemList()); for (std::vector::const_iterator i2 = nowSel.begin();i2!=nowSel.end();++i2) { remainingItems.push_back(*i2); } -- cgit v1.2.3 From fb08e5217a32dbfaf097cb26d67d9d7e0f5b718e Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 1 Mar 2016 12:03:12 +0100 Subject: Fix a bug with 0 width shapes (bzr r14648.1.4) --- src/ui/tools/eraser-tool.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 698415480..b34a2d3ce 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -699,7 +699,9 @@ void EraserTool::set_to_accumulated() { this->repr->parent()->appendChild(dup); Inkscape::GC::release(dup); // parent takes over selection->set(dup); - sp_selected_path_union(selection, desktop); + if (!this->nowidth) { + sp_selected_path_union(selection, desktop); + } selection->add(item); if(item->style->fill_rule.value == SP_WIND_RULE_EVENODD){ SPCSSAttr *css = sp_repr_css_attr_new(); -- cgit v1.2.3 From 32829581539b00c07f592c15cb62b69d71de9bb7 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 2 Mar 2016 20:44:36 +0100 Subject: Fix bug 1540155: Interactive simplify on pencit tool is hard to edit Fixed bugs: - https://launchpad.net/bugs/1540155 (bzr r14679) --- src/ui/tools/pencil-tool.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp index bfb1c67f0..b029ca613 100644 --- a/src/ui/tools/pencil-tool.cpp +++ b/src/ui/tools/pencil-tool.cpp @@ -634,12 +634,14 @@ void PencilTool::_interpolate() { using Geom::Y; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - double const tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0) * 0.4; - double tolerance_sq = 0.02 * square(this->desktop->w2d().descrim() * tol) * exp(0.2 * tol - 2); + double tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0) * 0.4; bool simplify = prefs->getInt("/tools/freehand/pencil/simplify", 0); if(simplify){ - tolerance_sq = 0; + double tol2 = prefs->getDoubleLimited("/tools/freehand/pencil/base-simplify", 25.0, 1.0, 100.0) * 0.4; + tol = std::min(tol,tol2); } + double tolerance_sq = 0.02 * square(this->desktop->w2d().descrim() * tol) * exp(0.2 * tol - 2); + g_assert(is_zero(this->req_tangent) || is_unit_vector(this->req_tangent)); this->green_curve->reset(); @@ -705,12 +707,14 @@ void PencilTool::_sketchInterpolate() { } Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - double const tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0) * 0.4; - double tolerance_sq = 0.02 * square(this->desktop->w2d().descrim() * tol) * exp(0.2 * tol - 2); + double tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0) * 0.4; bool simplify = prefs->getInt("/tools/freehand/pencil/simplify", 0); if(simplify){ - tolerance_sq = 0; + double tol2 = prefs->getDoubleLimited("/tools/freehand/pencil/base-simplify", 25.0, 1.0, 100.0) * 0.4; + tol = std::min(tol,tol2); } + double tolerance_sq = 0.02 * square(this->desktop->w2d().descrim() * tol) * exp(0.2 * tol - 2); + bool average_all_sketches = prefs->getBool("/tools/freehand/pencil/average_all_sketches", true); g_assert(is_zero(this->req_tangent) || is_unit_vector(this->req_tangent)); -- cgit v1.2.3 From c6cfbcf0dfd490c9ab46b21219881f78c0af8bf1 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 4 Mar 2016 10:51:55 +0100 Subject: Hide with widget in delete mode of eraser tool (bzr r14684) --- src/ui/tools/eraser-tool.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/ui/tools') diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index b34a2d3ce..edda211ca 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -449,6 +449,7 @@ bool EraserTool::root_handler(GdkEvent* event) { ret = TRUE; } if ( !eraserMode ) { + this->accumulated->reset(); Inkscape::Rubberband::get(desktop)->move(motion_dt); } } -- cgit v1.2.3 From 532e38d87f1465b0cce151bcc520f8f5b0b6bffc Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 4 Mar 2016 16:02:09 +0100 Subject: Fix bug: 230480 eraser tool always deletes selected objects Fixed bugs: - https://launchpad.net/bugs/230480 (bzr r14685) --- src/ui/tools/eraser-tool.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index edda211ca..8a3dbc66e 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -682,7 +682,18 @@ void EraserTool::set_to_accumulated() { } toWorkOn.erase(std::remove(toWorkOn.begin(), toWorkOn.end(), acid), toWorkOn.end()); } else { - toWorkOn = selection->itemList(); + if ( !eraserMode ) { + Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop); + std::vector touched; + touched = desktop->getDocument()->getItemsAtPoints(desktop->dkey, r->getPoints()); + for (std::vector::const_iterator i = touched.begin();i!=touched.end();++i) { + if(selection->includes(*i)){ + toWorkOn.push_back((*i)); + } + } + } else { + toWorkOn = selection->itemList(); + } wasSelection = true; } -- cgit v1.2.3 From 70f07d3a84ebcc213420c8028a2bc3d1dd4110d4 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 4 Mar 2016 20:19:00 +0100 Subject: Fix for bug 415471 and 1553182 related to undo with eraser tool Fixed bugs: - https://launchpad.net/bugs/1553182 (bzr r14688) --- src/ui/tools/eraser-tool.cpp | 89 ++++++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 41 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 8a3dbc66e..6b32b5901 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -702,49 +702,57 @@ void EraserTool::set_to_accumulated() { for (std::vector::const_iterator i = toWorkOn.begin(); i != toWorkOn.end(); ++i){ SPItem *item = *i; SPUse *use = dynamic_cast(item); - if (SP_IS_GROUP(item) || use ) { - continue; - } - Geom::OptRect bbox = item->desktopVisualBounds(); - if (bbox && bbox->intersects(*eraserBbox)) { - Inkscape::XML::Node* dup = this->repr->duplicate(xml_doc); - this->repr->parent()->appendChild(dup); - Inkscape::GC::release(dup); // parent takes over - selection->set(dup); - if (!this->nowidth) { - sp_selected_path_union(selection, desktop); - } - selection->add(item); - if(item->style->fill_rule.value == SP_WIND_RULE_EVENODD){ - SPCSSAttr *css = sp_repr_css_attr_new(); - sp_repr_css_set_property(css, "fill-rule", "evenodd"); - sp_desktop_set_style(desktop, css); - sp_repr_css_attr_unref(css); - css = 0; - } - if (this->nowidth) { - sp_selected_path_cut_skip_undo(selection, desktop); - } else { - sp_selected_path_diff_skip_undo(selection, desktop); - } - workDone = true; // TODO set this only if something was cut. - bool break_apart = prefs->getBool("/tools/eraser/break_apart", false); - if(!break_apart){ - sp_selected_path_combine(desktop); - } else { - if(!this->nowidth){ - sp_selected_path_break_apart(desktop); + if (SP_IS_PATH(item) && SP_PATH(item)->nodesInPath () == 2){ + sp_object_ref( *i, 0 ); + SPItem *item = *i; + item->deleteObject(true); + sp_object_unref(item); + workDone = true; + workDone = true; + } else if (SP_IS_GROUP(item) || use ) { + /*Do nothing*/ + } else { + Geom::OptRect bbox = item->desktopVisualBounds(); + if (bbox && bbox->intersects(*eraserBbox)) { + Inkscape::XML::Node* dup = this->repr->duplicate(xml_doc); + this->repr->parent()->appendChild(dup); + Inkscape::GC::release(dup); // parent takes over + selection->set(dup); + if (!this->nowidth) { + sp_selected_path_union_skip_undo(selection, desktop); } - } - 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();i2!=nowSel.end();++i2) { - remainingItems.push_back(*i2); + selection->add(item); + if(item->style->fill_rule.value == SP_WIND_RULE_EVENODD){ + SPCSSAttr *css = sp_repr_css_attr_new(); + sp_repr_css_set_property(css, "fill-rule", "evenodd"); + sp_desktop_set_style(desktop, css); + sp_repr_css_attr_unref(css); + css = 0; + } + if (this->nowidth) { + sp_selected_path_cut_skip_undo(selection, desktop); + } else { + sp_selected_path_diff_skip_undo(selection, desktop); + } + workDone = true; // TODO set this only if something was cut. + bool break_apart = prefs->getBool("/tools/eraser/break_apart", false); + if(!break_apart){ + sp_selected_path_combine(desktop, true); + } else { + if(!this->nowidth){ + sp_selected_path_break_apart(desktop, true); + } + } + 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();i2!=nowSel.end();++i2) { + remainingItems.push_back(*i2); + } } + } else { + remainingItems.push_back(item); } - } else { - remainingItems.push_back(item); } } } else { @@ -773,7 +781,6 @@ void EraserTool::set_to_accumulated() { } } } - // Remove the eraser stroke itself: sp_repr_unparent( this->repr ); this->repr = 0; -- cgit v1.2.3 From 0a0947876040165625941a4bccc1a788173121c0 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Mon, 7 Mar 2016 20:34:38 +0100 Subject: does not zoom in to selection box if holding shift to zoom out (bzr r14692) --- src/ui/tools/zoom-tool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/zoom-tool.cpp b/src/ui/tools/zoom-tool.cpp index 6a4d4dbbd..13e097c18 100644 --- a/src/ui/tools/zoom-tool.cpp +++ b/src/ui/tools/zoom-tool.cpp @@ -142,7 +142,7 @@ bool ZoomTool::root_handler(GdkEvent* event) { if ( event->button.button == 1 && !this->space_panning) { Geom::OptRect const b = Inkscape::Rubberband::get(desktop)->getRectangle(); - if (b && !within_tolerance) { + if (b && !within_tolerance && !(GDK_SHIFT_MASK & event->button.state) ) { desktop->set_display_area(*b, 10); } else if (!escaped) { double const zoom_rel( (event->button.state & GDK_SHIFT_MASK) -- cgit v1.2.3 From e798d5601af30bce49fa7288ea7a78fb7cd5bd70 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 14 Mar 2016 18:17:09 +0100 Subject: Fix a bug meassuring text in units diferent than PX (bzr r14704) --- src/ui/tools/measure-tool.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index a2a440ef4..07edf6039 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -1198,8 +1198,7 @@ void MeasureTool::showCanvasItems(bool to_guides, bool to_item, bool to_phantom, curve->unref(); continue; } - - curve->transform(item->i2doc_affine()); + curve->transform(item->transform); calculate_intersections(desktop, item, lineseg, curve, intersection_times); if (iter == te_get_layout(item)->end()) { -- cgit v1.2.3 From 2ab92c531add6a786d4a9cacf41ce33381c2ffe2 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Sat, 19 Mar 2016 22:42:23 -0400 Subject: Add Shift+Enter path complete and larger square node on mouse over. (bzr r14721) --- src/ui/tools/pen-tool.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 2ed366a7d..ff49417f4 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -1220,7 +1220,19 @@ bool PenTool::_handleKeyPress(GdkEvent *event) { case GDK_KEY_KP_Enter: if (this->npoints != 0) { this->ea = NULL; // unset end anchor if set (otherwise crashes) - this->_finish(false); + if(MOD__SHIFT_ONLY(event)) { + // All this is needed to stop the last control + // point dispeating and stop making an n-1 shape. + Geom::Point const event_w(0, 0); + Geom::Point event_dt(desktop->w2d(event_w)); + if(this->red_curve->is_empty()) { + this->red_curve->moveto(event_w); + } + this->_finishSegment(event_w, 0); + this->_finish(true); + } else { + this->_finish(false); + } ret = true; } break; -- cgit v1.2.3 From fd794a9d8bf0e82e62dfdb75a9f337b361f26b3e Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Sun, 20 Mar 2016 09:21:29 -0400 Subject: Update status bar text and remove spare Geom Point variable. (bzr r14725) --- src/ui/tools/pen-tool.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index ff49417f4..18af8e105 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -1223,12 +1223,11 @@ bool PenTool::_handleKeyPress(GdkEvent *event) { if(MOD__SHIFT_ONLY(event)) { // All this is needed to stop the last control // point dispeating and stop making an n-1 shape. - Geom::Point const event_w(0, 0); - Geom::Point event_dt(desktop->w2d(event_w)); + Geom::Point const p(0, 0); if(this->red_curve->is_empty()) { - this->red_curve->moveto(event_w); + this->red_curve->moveto(p); } - this->_finishSegment(event_w, 0); + this->_finishSegment(p, 0); this->_finish(true); } else { this->_finish(false); @@ -1795,12 +1794,12 @@ void PenTool::_setSubsequentPoint(Geom::Point const p, bool statusbar, guint sta if (statusbar) { gchar *message = is_curve ? - _("Curve segment: angle %3.2f°, distance %s; with Ctrl to snap angle, Enter to finish the path" ): - _("Line segment: angle %3.2f°, distance %s; with Ctrl to snap angle, Enter to finish the path"); + _("Curve segment: angle %3.2f°, distance %s; with Ctrl to snap angle, Enter or Shift+Enter to finish the path" ): + _("Line segment: angle %3.2f°, distance %s; with Ctrl to snap angle, Enter or Shift+Enter to finish the path"); if(this->spiro || this->bspline){ message = is_curve ? - _("Curve segment: angle %3.2f°, distance %s; with Shift+Click make a cusp node, Enter to finish the path" ): - _("Line segment: angle %3.2f°, distance %s; with Shift+Click make a cusp node, Enter to finish the path"); + _("Curve segment: angle %3.2f°, distance %s; with Shift+Click make a cusp node, Enter or Shift+Enter to finish the path" ): + _("Line segment: angle %3.2f°, distance %s; with Shift+Click make a cusp node, Enter or Shift+Enter to finish the path"); } this->_setAngleDistanceStatusMessage(p, 0, message); } -- cgit v1.2.3 From a907096a990015010ec1171cd8997d33951f28a2 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Tue, 12 Apr 2016 11:35:15 +0100 Subject: Hackfest 2016: un-obfuscate the SPCanvas widget. (bzr r14790) --- src/ui/tools/connector-tool.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index b84d16686..74f2664fe 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -247,7 +247,7 @@ void ConnectorTool::setup() { // Make sure we see all enter events for canvas items, // even if a mouse button is depressed. - this->desktop->canvas->gen_all_enter_events = true; + this->desktop->canvas->_gen_all_enter_events = true; } void ConnectorTool::set(const Inkscape::Preferences::Entry& val) { @@ -276,7 +276,7 @@ void ConnectorTool::finish() { this->cc_clear_active_conn(); // Restore the default event generating behaviour. - this->desktop->canvas->gen_all_enter_events = false; + this->desktop->canvas->_gen_all_enter_events = false; } //----------------------------------------------------------------------------- -- cgit v1.2.3 From e71c798f2fd8610baaddbb58d103b2ef44d65ccb Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Wed, 20 Apr 2016 23:14:10 -0700 Subject: minor warning cleanup. (bzr r14861) --- src/ui/tools/measure-tool.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index 07edf6039..287828d32 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -1287,9 +1287,9 @@ void MeasureTool::showCanvasItems(bool to_guides, bool to_item, bool to_phantom, if(to_guides) { gchar *cross_number; if (!prefs->getBool("/tools/measure/ignore_1st_and_last", true)) { - cross_number= g_strdup_printf(_("Crossing %u"), idx); + cross_number= g_strdup_printf(_("Crossing %lu"), static_cast(idx)); } else { - cross_number= g_strdup_printf(_("Crossing %u"), idx + 1); + cross_number= g_strdup_printf(_("Crossing %lu"), static_cast(idx + 1)); } if (!prefs->getBool("/tools/measure/ignore_1st_and_last", true) && idx == 0) { setGuide(desktop->doc2dt(intersections[idx]), angle + Geom::rad_from_deg(90), ""); -- cgit v1.2.3 From 7d03e020cb353dbc006a7f3020375dd7005aa760 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 10 May 2016 12:43:38 +0200 Subject: Fix a bug on Pen tool when use bend path as option and the clipboard has something diferent than shape, path or group (bzr r14882) --- src/ui/tools/freehand-base.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/ui/tools') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 613857626..c98ecb686 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -43,6 +43,7 @@ #include "snap.h" #include "sp-path.h" #include "sp-use.h" +#include "sp-item-group.h" #include "sp-namedview.h" #include "live_effects/lpe-powerstroke.h" #include "style.h" @@ -432,7 +433,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, if(cm->paste(SP_ACTIVE_DESKTOP,true) == true){ gchar const *svgd = item->getRepr()->attribute("d"); bend_item = dc->selection->singleItem(); - if(bend_item){ + if(bend_item && (SP_IS_SHAPE(bend_item) || SP_IS_GROUP(bend_item))){ bend_item->moveTo(item,false); bend_item->transform.setTranslation(Geom::Point()); spdc_apply_bend_shape(svgd, dc, bend_item); @@ -440,9 +441,11 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, shape = BEND_CLIPBOARD; } else { + bend_item = NULL; shape = NONE; } } else { + bend_item = NULL; shape = NONE; } break; -- cgit v1.2.3