X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Feraser-context.cpp;h=68c0989bc945b1a80c8ad3e5b6764ad2df468ecf;hb=030609cb99174ea85e69635c494ccaaaa20b2ac5;hp=17e69c6aca8dcbecfad38eeca2132a337f4063cb;hpb=8b2786c73392c85abafbd29307f50a47c98d1409;p=inkscape.git diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp index 17e69c6ac..68c0989bc 100644 --- a/src/eraser-context.cpp +++ b/src/eraser-context.cpp @@ -7,6 +7,7 @@ * bulia byak * MenTaLguY * Jon A. Cruz + * Abhishek Sharma * * The original dynadraw code: * Paul Haeberli @@ -34,7 +35,7 @@ #include "svg/svg.h" #include "display/canvas-bpath.h" -#include "display/bezier-utils.h" +#include <2geom/bezier-utils.h> #include #include "macros.h" @@ -43,7 +44,6 @@ #include "desktop.h" #include "desktop-events.h" #include "desktop-handles.h" -#include "desktop-affine.h" #include "desktop-style.h" #include "message-context.h" #include "preferences.h" @@ -66,6 +66,8 @@ #include "eraser-context.h" +using Inkscape::DocumentUndo; + #define ERC_RED_RGBA 0xff0000ff #define TOLERANCE_ERASER 0.1 @@ -577,10 +579,13 @@ sp_eraser_context_root_handler(SPEventContext *event_context, dc->repr = NULL; } - Inkscape::Rubberband::get(desktop)->stop(); dc->_message_context->clear(); ret = TRUE; } + if (Inkscape::Rubberband::get(desktop)->is_started()) { + Inkscape::Rubberband::get(desktop)->stop(); + } + break; } @@ -714,7 +719,7 @@ set_to_accumulated(SPEraserContext *dc) if (!dc->accumulated->is_empty()) { if (!dc->repr) { /* Create object */ - Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); + Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); /* Set style */ @@ -724,10 +729,10 @@ set_to_accumulated(SPEraserContext *dc) SPItem *item=SP_ITEM(desktop->currentLayer()->appendChildRepr(dc->repr)); Inkscape::GC::release(dc->repr); - item->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse(); + item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); item->updateRepr(); } - Geom::PathVector pathv = dc->accumulated->get_pathvector() * sp_desktop_dt2doc_affine(desktop); + Geom::PathVector pathv = dc->accumulated->get_pathvector() * desktop->dt2doc(); gchar *str = sp_svg_write_path(pathv); g_assert( str != NULL ); dc->repr->setAttribute("d", str); @@ -739,7 +744,7 @@ set_to_accumulated(SPEraserContext *dc) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0; - Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); + Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); SPItem* acid = SP_ITEM(desktop->doc()->getObjectByRepr(dc->repr)); Geom::OptRect eraserBbox = acid->getBounds(Geom::identity()); @@ -748,10 +753,10 @@ set_to_accumulated(SPEraserContext *dc) GSList* toWorkOn = 0; if (selection->isEmpty()) { if ( eraserMode ) { - toWorkOn = sp_document_partial_items_in_box(sp_desktop_document(desktop), desktop->dkey, bounds); + toWorkOn = sp_desktop_document(desktop)->getItemsPartiallyInBox(desktop->dkey, bounds); } else { - Inkscape::Rubberband::Rubberband *r = Inkscape::Rubberband::get(desktop); - toWorkOn = sp_document_items_at_points(sp_desktop_document(desktop), desktop->dkey, r->getPoints()); + Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop); + toWorkOn = sp_desktop_document(desktop)->getItemsAtPoints(desktop->dkey, r->getPoints()); } toWorkOn = g_slist_remove( toWorkOn, acid ); } else { @@ -827,10 +832,10 @@ set_to_accumulated(SPEraserContext *dc) if ( workDone ) { - sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_ERASER, - _("Draw eraser stroke")); + DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_ERASER, + _("Draw eraser stroke")); } else { - sp_document_cancel(sp_desktop_document(desktop)); + DocumentUndo::cancel(sp_desktop_document(desktop)); } } @@ -943,12 +948,12 @@ fit_and_split(SPEraserContext *dc, gboolean release) } Geom::Point b1[BEZIER_MAX_LENGTH]; - gint const nb1 = sp_bezier_fit_cubic_r(b1, dc->point1, dc->npoints, + gint const nb1 = Geom::bezier_fit_cubic_r(b1, dc->point1, dc->npoints, tolerance_sq, BEZIER_MAX_BEZIERS); g_assert( nb1 * BEZIER_SIZE <= gint(G_N_ELEMENTS(b1)) ); Geom::Point b2[BEZIER_MAX_LENGTH]; - gint const nb2 = sp_bezier_fit_cubic_r(b2, dc->point2, dc->npoints, + gint const nb2 = Geom::bezier_fit_cubic_r(b2, dc->point2, dc->npoints, tolerance_sq, BEZIER_MAX_BEZIERS); g_assert( nb2 * BEZIER_SIZE <= gint(G_N_ELEMENTS(b2)) ); @@ -1072,4 +1077,4 @@ draw_temporary_box(SPEraserContext *dc) fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :