From e58cac52b258e64c2cc88b0044bf9cfbaecedce2 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 9 Apr 2013 00:23:07 +0200 Subject: Started conversion of SPEventContext tree; added virtual pads to all classes. (bzr r11608.1.89) --- src/eraser-context.cpp | 47 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 9 deletions(-) (limited to 'src/eraser-context.cpp') diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp index cd0b1dc3b..59cce31bd 100644 --- a/src/eraser-context.cpp +++ b/src/eraser-context.cpp @@ -116,9 +116,18 @@ sp_eraser_context_class_init(SPEraserContextClass *klass) event_context_class->root_handler = sp_eraser_context_root_handler; } +CEraserContext::CEraserContext(SPEraserContext* erasercontext) : CCommonContext(erasercontext) { + this->sperasercontext = erasercontext; +} + static void sp_eraser_context_init(SPEraserContext *erc) { + erc->cerasercontext = new CEraserContext(erc); + delete erc->ccommoncontext; + erc->ccommoncontext = erc->cerasercontext; + erc->ceventcontext = erc->cerasercontext; + erc->cursor_shape = cursor_eraser_xpm; erc->hot_x = 4; erc->hot_y = 4; @@ -133,11 +142,18 @@ sp_eraser_context_dispose(GObject *object) static void sp_eraser_context_setup(SPEventContext *ec) { + ec->ceventcontext->setup(); +} + +void CEraserContext::setup() { + SPEventContext* ec = this->sperasercontext; + SPEraserContext *erc = SP_ERASER_CONTEXT(ec); SPDesktop *desktop = ec->desktop; - if ((SP_EVENT_CONTEXT_CLASS(sp_eraser_context_parent_class))->setup) - (SP_EVENT_CONTEXT_CLASS(sp_eraser_context_parent_class))->setup(ec); +// if ((SP_EVENT_CONTEXT_CLASS(sp_eraser_context_parent_class))->setup) +// (SP_EVENT_CONTEXT_CLASS(sp_eraser_context_parent_class))->setup(ec); + CCommonContext::setup(); erc->accumulated = new SPCurve(); erc->currentcurve = new SPCurve(); @@ -192,10 +208,17 @@ static ProfileFloatElement f_profile[PROFILE_FLOAT_SIZE] = { static void sp_eraser_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val) { + ec->ceventcontext->set(val); +} + +void CEraserContext::set(Inkscape::Preferences::Entry* val) { + SPEventContext* ec = this->sperasercontext; + //pass on up to parent class to handle common attributes. - if (SP_EVENT_CONTEXT_CLASS(sp_eraser_context_parent_class)->set ) { - SP_EVENT_CONTEXT_CLASS(sp_eraser_context_parent_class)->set(ec, val); - } +// if (SP_EVENT_CONTEXT_CLASS(sp_eraser_context_parent_class)->set ) { +// SP_EVENT_CONTEXT_CLASS(sp_eraser_context_parent_class)->set(ec, val); +// } + CCommonContext::set(val); } static double @@ -445,6 +468,12 @@ gint sp_eraser_context_root_handler(SPEventContext *event_context, GdkEvent *event) { + return event_context->ceventcontext->root_handler(event); +} + +gint CEraserContext::root_handler(GdkEvent* event) { + SPEventContext* event_context = this->sperasercontext; + SPEraserContext *dc = SP_ERASER_CONTEXT(event_context); SPDesktop *desktop = event_context->desktop; @@ -660,15 +689,15 @@ sp_eraser_context_root_handler(SPEventContext *event_context, } if (!ret) { - if ((SP_EVENT_CONTEXT_CLASS(sp_eraser_context_parent_class))->root_handler) { - ret = (SP_EVENT_CONTEXT_CLASS(sp_eraser_context_parent_class))->root_handler(event_context, event); - } +// if ((SP_EVENT_CONTEXT_CLASS(sp_eraser_context_parent_class))->root_handler) { +// ret = (SP_EVENT_CONTEXT_CLASS(sp_eraser_context_parent_class))->root_handler(event_context, event); +// } + ret = CCommonContext::root_handler(event); } return ret; } - static void clear_current(SPEraserContext *dc) { -- cgit v1.2.3 From 1d8f1753cd8cab38d19fcc26a4ad70ba2e794ac8 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 9 Apr 2013 22:12:07 +0200 Subject: Added constructors to EventContext tree / some missing virtual pads. (bzr r11608.1.90) --- src/eraser-context.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/eraser-context.cpp') diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp index 59cce31bd..01d3adcf6 100644 --- a/src/eraser-context.cpp +++ b/src/eraser-context.cpp @@ -111,18 +111,18 @@ sp_eraser_context_class_init(SPEraserContextClass *klass) object_class->dispose = sp_eraser_context_dispose; - event_context_class->setup = sp_eraser_context_setup; - event_context_class->set = sp_eraser_context_set; - event_context_class->root_handler = sp_eraser_context_root_handler; +// event_context_class->setup = sp_eraser_context_setup; +// event_context_class->set = sp_eraser_context_set; +// event_context_class->root_handler = sp_eraser_context_root_handler; } CEraserContext::CEraserContext(SPEraserContext* erasercontext) : CCommonContext(erasercontext) { this->sperasercontext = erasercontext; } -static void -sp_eraser_context_init(SPEraserContext *erc) -{ +SPEraserContext::SPEraserContext() : SPCommonContext() { + SPEraserContext* erc = this; + erc->cerasercontext = new CEraserContext(erc); delete erc->ccommoncontext; erc->ccommoncontext = erc->cerasercontext; @@ -133,6 +133,12 @@ sp_eraser_context_init(SPEraserContext *erc) erc->hot_y = 4; } +static void +sp_eraser_context_init(SPEraserContext *erc) +{ + new (erc) SPEraserContext(); +} + static void sp_eraser_context_dispose(GObject *object) { -- cgit v1.2.3 From fbb85064cfaaf03cc09bacedb16a8561f61f2b3d Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 13 Apr 2013 00:37:18 +0200 Subject: Added prefPaths to contexts; modified SPFactory (bzr r11608.1.94) --- src/eraser-context.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/eraser-context.cpp') diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp index 01d3adcf6..00fb41004 100644 --- a/src/eraser-context.cpp +++ b/src/eraser-context.cpp @@ -101,6 +101,8 @@ static Geom::Point sp_eraser_get_npoint(SPEraserContext const *erc, Geom::Point static Geom::Point sp_eraser_get_vpoint(SPEraserContext const *erc, Geom::Point n); static void draw_temporary_box(SPEraserContext *dc); +const std::string SPEraserContext::prefsPath = "/tools/eraser"; + G_DEFINE_TYPE(SPEraserContext, sp_eraser_context, SP_TYPE_COMMON_CONTEXT); static void -- cgit v1.2.3 From fbdc8b84ff670c684dafc7d7d403ed01e7077e70 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 13 Apr 2013 18:13:17 +0200 Subject: Replaced casting macros for EventContext tree; added contructors. (bzr r11608.1.96) --- src/eraser-context.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/eraser-context.cpp') diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp index 00fb41004..cf6d8021d 100644 --- a/src/eraser-context.cpp +++ b/src/eraser-context.cpp @@ -101,6 +101,20 @@ static Geom::Point sp_eraser_get_npoint(SPEraserContext const *erc, Geom::Point static Geom::Point sp_eraser_get_vpoint(SPEraserContext const *erc, Geom::Point n); static void draw_temporary_box(SPEraserContext *dc); +#include "sp-factory.h" + +namespace { + SPEventContext* createEraserContext() { + return new SPEraserContext(); + } + + bool eraserContextRegistered = ToolFactory::instance().registerObject("/tools/eraser", createEraserContext); +} + +const std::string& CEraserContext::getPrefsPath() { + return SPEraserContext::prefsPath; +} + const std::string SPEraserContext::prefsPath = "/tools/eraser"; G_DEFINE_TYPE(SPEraserContext, sp_eraser_context, SP_TYPE_COMMON_CONTEXT); @@ -129,6 +143,7 @@ SPEraserContext::SPEraserContext() : SPCommonContext() { delete erc->ccommoncontext; erc->ccommoncontext = erc->cerasercontext; erc->ceventcontext = erc->cerasercontext; + types.insert(typeid(SPEraserContext)); erc->cursor_shape = cursor_eraser_xpm; erc->hot_x = 4; -- cgit v1.2.3 From 65ba6ad9a82f8f47974eb10665478fd783692bb5 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 20 Apr 2013 23:19:46 +0200 Subject: Merging of EventContext classes complete. (bzr r11608.1.98) --- src/eraser-context.cpp | 86 +++++--------------------------------------------- 1 file changed, 8 insertions(+), 78 deletions(-) (limited to 'src/eraser-context.cpp') diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp index cf6d8021d..7d2abc53f 100644 --- a/src/eraser-context.cpp +++ b/src/eraser-context.cpp @@ -83,12 +83,6 @@ using Inkscape::DocumentUndo; #define DRAG_DEFAULT 1.0 #define DRAG_MAX 1.0 -static void sp_eraser_context_dispose(GObject *object); - -static void sp_eraser_context_setup(SPEventContext *ec); -static void sp_eraser_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val); -static gint sp_eraser_context_root_handler(SPEventContext *ec, GdkEvent *event); - static void clear_current(SPEraserContext *dc); static void set_to_accumulated(SPEraserContext *dc); static void add_cap(SPCurve *curve, Geom::Point const &pre, Geom::Point const &from, Geom::Point const &to, Geom::Point const &post, double rounding); @@ -111,72 +105,32 @@ namespace { bool eraserContextRegistered = ToolFactory::instance().registerObject("/tools/eraser", createEraserContext); } -const std::string& CEraserContext::getPrefsPath() { +const std::string& SPEraserContext::getPrefsPath() { return SPEraserContext::prefsPath; } const std::string SPEraserContext::prefsPath = "/tools/eraser"; -G_DEFINE_TYPE(SPEraserContext, sp_eraser_context, SP_TYPE_COMMON_CONTEXT); - -static void -sp_eraser_context_class_init(SPEraserContextClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS(klass); - SPEventContextClass *event_context_class = SP_EVENT_CONTEXT_CLASS(klass); - - object_class->dispose = sp_eraser_context_dispose; - -// event_context_class->setup = sp_eraser_context_setup; -// event_context_class->set = sp_eraser_context_set; -// event_context_class->root_handler = sp_eraser_context_root_handler; -} - -CEraserContext::CEraserContext(SPEraserContext* erasercontext) : CCommonContext(erasercontext) { - this->sperasercontext = erasercontext; -} - SPEraserContext::SPEraserContext() : SPCommonContext() { SPEraserContext* erc = this; - erc->cerasercontext = new CEraserContext(erc); - delete erc->ccommoncontext; - erc->ccommoncontext = erc->cerasercontext; - erc->ceventcontext = erc->cerasercontext; - types.insert(typeid(SPEraserContext)); - erc->cursor_shape = cursor_eraser_xpm; erc->hot_x = 4; erc->hot_y = 4; } -static void -sp_eraser_context_init(SPEraserContext *erc) -{ - new (erc) SPEraserContext(); +SPEraserContext::~SPEraserContext() { } -static void -sp_eraser_context_dispose(GObject *object) -{ - G_OBJECT_CLASS(sp_eraser_context_parent_class)->dispose(object); -} - -static void -sp_eraser_context_setup(SPEventContext *ec) -{ - ec->ceventcontext->setup(); -} - -void CEraserContext::setup() { - SPEventContext* ec = this->sperasercontext; +void SPEraserContext::setup() { + SPEventContext* ec = this; SPEraserContext *erc = SP_ERASER_CONTEXT(ec); SPDesktop *desktop = ec->desktop; // if ((SP_EVENT_CONTEXT_CLASS(sp_eraser_context_parent_class))->setup) // (SP_EVENT_CONTEXT_CLASS(sp_eraser_context_parent_class))->setup(ec); - CCommonContext::setup(); + SPCommonContext::setup(); erc->accumulated = new SPCurve(); erc->currentcurve = new SPCurve(); @@ -228,22 +182,6 @@ static ProfileFloatElement f_profile[PROFILE_FLOAT_SIZE] = { } -static void -sp_eraser_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val) -{ - ec->ceventcontext->set(val); -} - -void CEraserContext::set(Inkscape::Preferences::Entry* val) { - SPEventContext* ec = this->sperasercontext; - - //pass on up to parent class to handle common attributes. -// if (SP_EVENT_CONTEXT_CLASS(sp_eraser_context_parent_class)->set ) { -// SP_EVENT_CONTEXT_CLASS(sp_eraser_context_parent_class)->set(ec, val); -// } - CCommonContext::set(val); -} - static double flerp(double f0, double f1, double p) { @@ -486,16 +424,8 @@ eraser_cancel(SPEraserContext *dc) } } - -gint -sp_eraser_context_root_handler(SPEventContext *event_context, - GdkEvent *event) -{ - return event_context->ceventcontext->root_handler(event); -} - -gint CEraserContext::root_handler(GdkEvent* event) { - SPEventContext* event_context = this->sperasercontext; +gint SPEraserContext::root_handler(GdkEvent* event) { + SPEventContext* event_context = this; SPEraserContext *dc = SP_ERASER_CONTEXT(event_context); SPDesktop *desktop = event_context->desktop; @@ -715,7 +645,7 @@ gint CEraserContext::root_handler(GdkEvent* event) { // if ((SP_EVENT_CONTEXT_CLASS(sp_eraser_context_parent_class))->root_handler) { // ret = (SP_EVENT_CONTEXT_CLASS(sp_eraser_context_parent_class))->root_handler(event_context, event); // } - ret = CCommonContext::root_handler(event); + ret = SPCommonContext::root_handler(event); } return ret; -- cgit v1.2.3 From 5512f857e2f33f1aa40124dc82b353e5f2e5a0b0 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 20 Apr 2013 23:58:53 +0200 Subject: Moved factories to different files. (bzr r11608.1.100) --- src/eraser-context.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/eraser-context.cpp') diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp index 7d2abc53f..f256dd8ef 100644 --- a/src/eraser-context.cpp +++ b/src/eraser-context.cpp @@ -95,7 +95,7 @@ static Geom::Point sp_eraser_get_npoint(SPEraserContext const *erc, Geom::Point static Geom::Point sp_eraser_get_vpoint(SPEraserContext const *erc, Geom::Point n); static void draw_temporary_box(SPEraserContext *dc); -#include "sp-factory.h" +#include "tool-factory.h" namespace { SPEventContext* createEraserContext() { -- cgit v1.2.3 From bdde74bbab299f2ee448f1c55469c56a66fb01f7 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sun, 21 Apr 2013 23:58:15 +0200 Subject: Removed some unused files; more refactoring in EventContext tree. (bzr r11608.1.104) --- src/eraser-context.cpp | 282 +++++++++++++++++++++++++++---------------------- 1 file changed, 156 insertions(+), 126 deletions(-) (limited to 'src/eraser-context.cpp') diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp index f256dd8ef..d84f6cfaa 100644 --- a/src/eraser-context.cpp +++ b/src/eraser-context.cpp @@ -112,37 +112,30 @@ const std::string& SPEraserContext::getPrefsPath() { const std::string SPEraserContext::prefsPath = "/tools/eraser"; SPEraserContext::SPEraserContext() : SPCommonContext() { - SPEraserContext* erc = this; - - erc->cursor_shape = cursor_eraser_xpm; - erc->hot_x = 4; - erc->hot_y = 4; + this->cursor_shape = cursor_eraser_xpm; + this->hot_x = 4; + this->hot_y = 4; } SPEraserContext::~SPEraserContext() { } void SPEraserContext::setup() { - SPEventContext* ec = this; + SPCommonContext::setup(); - SPEraserContext *erc = SP_ERASER_CONTEXT(ec); - SPDesktop *desktop = ec->desktop; + this->accumulated = new SPCurve(); + this->currentcurve = new SPCurve(); -// if ((SP_EVENT_CONTEXT_CLASS(sp_eraser_context_parent_class))->setup) -// (SP_EVENT_CONTEXT_CLASS(sp_eraser_context_parent_class))->setup(ec); - SPCommonContext::setup(); + this->cal1 = new SPCurve(); + this->cal2 = new SPCurve(); - erc->accumulated = new SPCurve(); - erc->currentcurve = new SPCurve(); + this->currentshape = sp_canvas_item_new(sp_desktop_sketch(desktop), SP_TYPE_CANVAS_BPATH, NULL); - erc->cal1 = new SPCurve(); - erc->cal2 = new SPCurve(); + sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(this->currentshape), ERC_RED_RGBA, SP_WIND_RULE_EVENODD); + sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(this->currentshape), 0x00000000, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); - erc->currentshape = sp_canvas_item_new(sp_desktop_sketch(desktop), SP_TYPE_CANVAS_BPATH, NULL); - sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(erc->currentshape), ERC_RED_RGBA, SP_WIND_RULE_EVENODD); - sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(erc->currentshape), 0x00000000, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); /* fixme: Cannot we cascade it to root more clearly? */ - g_signal_connect(G_OBJECT(erc->currentshape), "event", G_CALLBACK(sp_desktop_root_handler), desktop); + g_signal_connect(G_OBJECT(this->currentshape), "event", G_CALLBACK(sp_desktop_root_handler), desktop); /* static ProfileFloatElement f_profile[PROFILE_FLOAT_SIZE] = { @@ -156,30 +149,30 @@ static ProfileFloatElement f_profile[PROFILE_FLOAT_SIZE] = { }; */ - sp_event_context_read(ec, "mass"); - sp_event_context_read(ec, "wiggle"); - sp_event_context_read(ec, "angle"); - sp_event_context_read(ec, "width"); - sp_event_context_read(ec, "thinning"); - sp_event_context_read(ec, "tremor"); - sp_event_context_read(ec, "flatness"); - sp_event_context_read(ec, "tracebackground"); - sp_event_context_read(ec, "usepressure"); - sp_event_context_read(ec, "usetilt"); - sp_event_context_read(ec, "abs_width"); - sp_event_context_read(ec, "cap_rounding"); + sp_event_context_read(this, "mass"); + sp_event_context_read(this, "wiggle"); + sp_event_context_read(this, "angle"); + sp_event_context_read(this, "width"); + sp_event_context_read(this, "thinning"); + sp_event_context_read(this, "tremor"); + sp_event_context_read(this, "flatness"); + sp_event_context_read(this, "tracebackground"); + sp_event_context_read(this, "usepressure"); + sp_event_context_read(this, "usetilt"); + sp_event_context_read(this, "abs_width"); + sp_event_context_read(this, "cap_rounding"); - erc->is_drawing = false; + this->is_drawing = false; - erc->_message_context = new Inkscape::MessageContext(desktop->messageStack()); + this->_message_context = new Inkscape::MessageContext(desktop->messageStack()); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/tools/eraser/selcue", 0) != 0) { - ec->enableSelectionCue(); + this->enableSelectionCue(); } -// TODO temp force: - ec->enableSelectionCue(); + // TODO temp force: + this->enableSelectionCue(); } static double @@ -425,37 +418,33 @@ eraser_cancel(SPEraserContext *dc) } gint SPEraserContext::root_handler(GdkEvent* event) { - SPEventContext* event_context = this; - - SPEraserContext *dc = SP_ERASER_CONTEXT(event_context); - SPDesktop *desktop = event_context->desktop; - gint ret = FALSE; switch (event->type) { case GDK_BUTTON_PRESS: - if (event->button.button == 1 && !event_context->space_panning) { - - if (Inkscape::have_viable_layer(desktop, dc->_message_context) == false) { + if (event->button.button == 1 && !this->space_panning) { + if (Inkscape::have_viable_layer(desktop, this->_message_context) == false) { return TRUE; } - Geom::Point const button_w(event->button.x, - event->button.y); + Geom::Point const button_w(event->button.x, event->button.y); Geom::Point const button_dt(desktop->w2d(button_w)); - sp_eraser_reset(dc, button_dt); - sp_eraser_extinput(dc, event); - sp_eraser_apply(dc, button_dt); - dc->accumulated->reset(); - if (dc->repr) { - dc->repr = NULL; + + sp_eraser_reset(this, button_dt); + sp_eraser_extinput(this, event); + sp_eraser_apply(this, button_dt); + + this->accumulated->reset(); + + if (this->repr) { + this->repr = NULL; } Inkscape::Rubberband::get(desktop)->start(desktop, button_dt); Inkscape::Rubberband::get(desktop)->setMode(RUBBERBAND_MODE_TOUCHPATH); /* initialize first point */ - dc->npoints = 0; + this->npoints = 0; sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate), ( GDK_KEY_PRESS_MASK | @@ -468,76 +457,77 @@ gint SPEraserContext::root_handler(GdkEvent* event) { ret = TRUE; desktop->canvas->forceFullRedrawAfterInterruptions(3); - dc->is_drawing = true; + this->is_drawing = true; } break; - case GDK_MOTION_NOTIFY: - { - Geom::Point const motion_w(event->motion.x, - event->motion.y); - Geom::Point motion_dt(desktop->w2d(motion_w)); - sp_eraser_extinput(dc, event); - dc->_message_context->clear(); + case GDK_MOTION_NOTIFY: { + Geom::Point const motion_w(event->motion.x, event->motion.y); + Geom::Point motion_dt(desktop->w2d(motion_w) + ); + sp_eraser_extinput(this, event); - if ( dc->is_drawing && (event->motion.state & GDK_BUTTON1_MASK) && !event_context->space_panning) { - dc->dragging = TRUE; + this->_message_context->clear(); - dc->_message_context->set(Inkscape::NORMAL_MESSAGE, _("Drawing an eraser stroke")); + if ( this->is_drawing && (event->motion.state & GDK_BUTTON1_MASK) && !this->space_panning) { + this->dragging = TRUE; - if (!sp_eraser_apply(dc, motion_dt)) { + this->_message_context->set(Inkscape::NORMAL_MESSAGE, _("Drawing an eraser stroke")); + + if (!sp_eraser_apply(this, motion_dt)) { ret = TRUE; break; } - if ( dc->cur != dc->last ) { - sp_eraser_brush(dc); - g_assert( dc->npoints > 0 ); - fit_and_split(dc, FALSE); + if ( this->cur != this->last ) { + sp_eraser_brush(this); + g_assert( this->npoints > 0 ); + fit_and_split(this, FALSE); } + ret = TRUE; } + Inkscape::Rubberband::get(desktop)->move(motion_dt); } break; - - case GDK_BUTTON_RELEASE: - { + case GDK_BUTTON_RELEASE: { Geom::Point const motion_w(event->button.x, event->button.y); Geom::Point const motion_dt(desktop->w2d(motion_w)); sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time); desktop->canvas->endForcedFullRedraws(); - dc->is_drawing = false; + this->is_drawing = false; - if (dc->dragging && event->button.button == 1 && !event_context->space_panning) { - dc->dragging = FALSE; + if (this->dragging && event->button.button == 1 && !this->space_panning) { + this->dragging = FALSE; - sp_eraser_apply(dc, motion_dt); + sp_eraser_apply(this, motion_dt); /* Remove all temporary line segments */ - while (dc->segments) { - sp_canvas_item_destroy(SP_CANVAS_ITEM(dc->segments->data)); - dc->segments = g_slist_remove(dc->segments, dc->segments->data); + while (this->segments) { + sp_canvas_item_destroy(SP_CANVAS_ITEM(this->segments->data)); + this->segments = g_slist_remove(this->segments, this->segments->data); } /* Create object */ - fit_and_split(dc, TRUE); - accumulate_eraser(dc); - set_to_accumulated(dc); // performs document_done + fit_and_split(this, TRUE); + accumulate_eraser(this); + set_to_accumulated(this); // performs document_done /* reset accumulated curve */ - dc->accumulated->reset(); + this->accumulated->reset(); - clear_current(dc); - if (dc->repr) { - dc->repr = NULL; + clear_current(this); + if (this->repr) { + this->repr = NULL; } - dc->_message_context->clear(); + this->_message_context->clear(); ret = TRUE; } + if (Inkscape::Rubberband::get(desktop)->is_started()) { Inkscape::Rubberband::get(desktop)->stop(); } @@ -550,55 +540,73 @@ gint SPEraserContext::root_handler(GdkEvent* event) { case GDK_KEY_Up: case GDK_KEY_KP_Up: if (!MOD__CTRL_ONLY) { - dc->angle += 5.0; - if (dc->angle > 90.0) - dc->angle = 90.0; - sp_erc_update_toolbox (desktop, "eraser-angle", dc->angle); + 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) { - dc->angle -= 5.0; - if (dc->angle < -90.0) - dc->angle = -90.0; - sp_erc_update_toolbox (desktop, "eraser-angle", dc->angle); + 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: if (!MOD__CTRL_ONLY) { - dc->width += 0.01; - if (dc->width > 1.0) - dc->width = 1.0; - sp_erc_update_toolbox (desktop, "altx-eraser", dc->width * 100); // the same spinbutton is for alt+x + this->width += 0.01; + + if (this->width > 1.0) { + this->width = 1.0; + } + + sp_erc_update_toolbox (desktop, "altx-eraser", this->width * 100); // the same spinbutton is for alt+x ret = TRUE; } break; + case GDK_KEY_Left: case GDK_KEY_KP_Left: if (!MOD__CTRL_ONLY) { - dc->width -= 0.01; - if (dc->width < 0.01) - dc->width = 0.01; - sp_erc_update_toolbox (desktop, "altx-eraser", dc->width * 100); + this->width -= 0.01; + + if (this->width < 0.01) { + this->width = 0.01; + } + + sp_erc_update_toolbox (desktop, "altx-eraser", this->width * 100); ret = TRUE; } break; + case GDK_KEY_Home: case GDK_KEY_KP_Home: - dc->width = 0.01; - sp_erc_update_toolbox (desktop, "altx-eraser", dc->width * 100); + this->width = 0.01; + sp_erc_update_toolbox (desktop, "altx-eraser", this->width * 100); ret = TRUE; break; + case GDK_KEY_End: case GDK_KEY_KP_End: - dc->width = 1.0; - sp_erc_update_toolbox (desktop, "altx-eraser", dc->width * 100); + this->width = 1.0; + sp_erc_update_toolbox (desktop, "altx-eraser", this->width * 100); ret = TRUE; break; + case GDK_KEY_x: case GDK_KEY_X: if (MOD__ALT_ONLY) { @@ -606,22 +614,26 @@ gint SPEraserContext::root_handler(GdkEvent* event) { ret = TRUE; } break; + case GDK_KEY_Escape: Inkscape::Rubberband::get(desktop)->stop(); - if (dc->is_drawing) { + + if (this->is_drawing) { // if drawing, cancel, otherwise pass it up for deselecting - eraser_cancel (dc); + eraser_cancel (this); ret = TRUE; } break; + case GDK_KEY_z: case GDK_KEY_Z: - if (MOD__CTRL_ONLY && dc->is_drawing) { + if (MOD__CTRL_ONLY && this->is_drawing) { // if drawing, cancel, otherwise pass it up for undo - eraser_cancel (dc); + eraser_cancel (this); ret = TRUE; } break; + default: break; } @@ -631,20 +643,19 @@ gint SPEraserContext::root_handler(GdkEvent* event) { switch (get_group0_keyval(&event->key)) { case GDK_KEY_Control_L: case GDK_KEY_Control_R: - dc->_message_context->clear(); + this->_message_context->clear(); break; + default: break; } + break; default: break; } if (!ret) { -// if ((SP_EVENT_CONTEXT_CLASS(sp_eraser_context_parent_class))->root_handler) { -// ret = (SP_EVENT_CONTEXT_CLASS(sp_eraser_context_parent_class))->root_handler(event_context, event); -// } ret = SPCommonContext::root_handler(event); } @@ -685,9 +696,11 @@ set_to_accumulated(SPEraserContext *dc) SPItem *item=SP_ITEM(desktop->currentLayer()->appendChildRepr(dc->repr)); Inkscape::GC::release(dc->repr); + item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); item->updateRepr(); } + Geom::PathVector pathv = dc->accumulated->get_pathvector() * desktop->dt2doc(); gchar *str = sp_svg_write_path(pathv); g_assert( str != NULL ); @@ -707,6 +720,7 @@ set_to_accumulated(SPEraserContext *dc) Geom::Rect bounds = (*eraserBbox) * desktop->doc2dt(); std::vector remainingItems; GSList* toWorkOn = 0; + if (selection->isEmpty()) { if ( eraserMode ) { toWorkOn = sp_desktop_document(desktop)->getItemsPartiallyInBox(desktop->dkey, bounds); @@ -714,6 +728,7 @@ set_to_accumulated(SPEraserContext *dc) Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop); toWorkOn = sp_desktop_document(desktop)->getItemsAtPoints(desktop->dkey, r->getPoints()); } + toWorkOn = g_slist_remove( toWorkOn, acid ); } else { toWorkOn = g_slist_copy(const_cast(selection->itemList())); @@ -724,8 +739,10 @@ set_to_accumulated(SPEraserContext *dc) if ( eraserMode ) { for (GSList *i = toWorkOn ; i ; i = i->next ) { SPItem *item = SP_ITEM(i->data); + if ( eraserMode ) { Geom::OptRect bbox = item->visualBounds(); + if (bbox && bbox->intersects(*eraserBbox)) { Inkscape::XML::Node* dup = dc->repr->duplicate(xml_doc); dc->repr->parent()->appendChild(dup); @@ -735,12 +752,15 @@ set_to_accumulated(SPEraserContext *dc) selection->add(dup); sp_selected_path_diff_skip_undo(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. 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)); } + g_slist_free(nowSel); } } else { @@ -752,6 +772,7 @@ set_to_accumulated(SPEraserContext *dc) for (GSList *i = toWorkOn ; i ; i = i->next ) { sp_object_ref( SP_ITEM(i->data), 0 ); } + for (GSList *i = toWorkOn ; i ; i = i->next ) { SPItem *item = SP_ITEM(i->data); item->deleteObject(true); @@ -768,6 +789,7 @@ set_to_accumulated(SPEraserContext *dc) } selection->clear(); + if ( wasSelection ) { if ( !remainingItems.empty() ) { selection->add(remainingItems.begin(), remainingItems.end()); @@ -788,8 +810,7 @@ set_to_accumulated(SPEraserContext *dc) if ( workDone ) { - DocumentUndo::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 { DocumentUndo::cancel(sp_desktop_document(desktop)); } @@ -806,6 +827,7 @@ add_cap(SPCurve *curve, Geom::Point v_in = from - pre; double mag_in = Geom::L2(v_in); + if ( mag_in > ERASER_EPSILON ) { v_in = mag * v_in / mag_in; } else { @@ -814,6 +836,7 @@ add_cap(SPCurve *curve, Geom::Point v_out = to - post; double mag_out = Geom::L2(v_out); + if ( mag_out > ERASER_EPSILON ) { v_out = mag * v_out / mag_out; } else { @@ -841,6 +864,7 @@ accumulate_eraser(SPEraserContext *dc) Geom::CubicBezier const * rev_cal2_firstseg = dynamic_cast( rev_cal2->first_segment() ); Geom::CubicBezier const * dc_cal1_lastseg = dynamic_cast( dc->cal1->last_segment() ); Geom::CubicBezier const * rev_cal2_lastseg = dynamic_cast( rev_cal2->last_segment() ); + g_assert( dc_cal1_firstseg ); g_assert( rev_cal2_firstseg ); g_assert( dc_cal1_lastseg ); @@ -904,13 +928,11 @@ fit_and_split(SPEraserContext *dc, gboolean release) } Geom::Point b1[BEZIER_MAX_LENGTH]; - gint const nb1 = Geom::bezier_fit_cubic_r(b1, dc->point1, dc->npoints, - tolerance_sq, BEZIER_MAX_BEZIERS); + 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 = Geom::bezier_fit_cubic_r(b2, dc->point2, dc->npoints, - tolerance_sq, BEZIER_MAX_BEZIERS); + 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)) ); if ( nb1 != -1 && nb2 != -1 ) { @@ -918,22 +940,27 @@ fit_and_split(SPEraserContext *dc, gboolean release) #ifdef ERASER_VERBOSE g_print("nb1:%d nb2:%d\n", nb1, nb2); #endif + /* CanvasShape */ if (! release) { dc->currentcurve->reset(); dc->currentcurve->moveto(b1[0]); + for (Geom::Point *bp1 = b1; bp1 < b1 + BEZIER_SIZE * nb1; bp1 += BEZIER_SIZE) { - dc->currentcurve->curveto(bp1[1], - bp1[2], bp1[3]); + dc->currentcurve->curveto(bp1[1], bp1[2], bp1[3]); } + dc->currentcurve->lineto(b2[BEZIER_SIZE*(nb2-1) + 3]); + for (Geom::Point *bp2 = b2 + BEZIER_SIZE * ( nb2 - 1 ); bp2 >= b2; bp2 -= BEZIER_SIZE) { dc->currentcurve->curveto(bp2[2], bp2[1], bp2[0]); } + // FIXME: dc->segments is always NULL at this point?? if (!dc->segments) { // first segment add_cap(dc->currentcurve, b2[1], b2[0], b1[0], b1[1], dc->cap_rounding); } + dc->currentcurve->closepath(); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(dc->currentshape), dc->currentcurve); } @@ -942,6 +969,7 @@ fit_and_split(SPEraserContext *dc, gboolean release) for (Geom::Point *bp1 = b1; bp1 < b1 + BEZIER_SIZE * nb1; bp1 += BEZIER_SIZE) { dc->cal1->curveto(bp1[1], bp1[2], bp1[3]); } + for (Geom::Point *bp2 = b2; bp2 < b2 + BEZIER_SIZE * nb2; bp2 += BEZIER_SIZE) { dc->cal2->curveto(bp2[1], bp2[2], bp2[3]); } @@ -955,6 +983,7 @@ fit_and_split(SPEraserContext *dc, gboolean release) for (gint i = 1; i < dc->npoints; i++) { dc->cal1->lineto(dc->point1[i]); } + for (gint i = 1; i < dc->npoints; i++) { dc->cal2->lineto(dc->point2[i]); } @@ -969,9 +998,7 @@ fit_and_split(SPEraserContext *dc, gboolean release) gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0; g_assert(!dc->currentcurve->is_empty()); - SPCanvasItem *cbp = sp_canvas_item_new(sp_desktop_sketch(desktop), - SP_TYPE_CANVAS_BPATH, - NULL); + SPCanvasItem *cbp = sp_canvas_item_new(sp_desktop_sketch(desktop), SP_TYPE_CANVAS_BPATH, NULL); SPCurve *curve = dc->currentcurve->copy(); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH (cbp), curve); curve->unref(); @@ -1010,12 +1037,15 @@ draw_temporary_box(SPEraserContext *dc) dc->currentcurve->reset(); dc->currentcurve->moveto(dc->point1[dc->npoints-1]); + for (gint i = dc->npoints-2; i >= 0; i--) { dc->currentcurve->lineto(dc->point1[i]); } + for (gint i = 0; i < dc->npoints; i++) { dc->currentcurve->lineto(dc->point2[i]); } + if (dc->npoints >= 2) { add_cap(dc->currentcurve, dc->point2[dc->npoints-2], dc->point2[dc->npoints-1], dc->point1[dc->npoints-1], dc->point1[dc->npoints-2], dc->cap_rounding); } -- cgit v1.2.3 From b2dd3583e7372d23d18bbc6e861f4f645ec3dc37 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 30 Jul 2013 23:17:21 +0200 Subject: Further refactoring of EventContexts. (bzr r11608.1.109) --- src/eraser-context.cpp | 395 +++++++++++++++++++++---------------------------- 1 file changed, 171 insertions(+), 224 deletions(-) (limited to 'src/eraser-context.cpp') diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp index 63737da61..6391419eb 100644 --- a/src/eraser-context.cpp +++ b/src/eraser-context.cpp @@ -83,18 +83,6 @@ using Inkscape::DocumentUndo; #define DRAG_DEFAULT 1.0 #define DRAG_MAX 1.0 -static void clear_current(SPEraserContext *dc); -static void set_to_accumulated(SPEraserContext *dc); -static void add_cap(SPCurve *curve, Geom::Point const &pre, Geom::Point const &from, Geom::Point const &to, Geom::Point const &post, double rounding); -static void accumulate_eraser(SPEraserContext *dc); - -static void fit_and_split(SPEraserContext *erc, gboolean release); - -static void sp_eraser_reset(SPEraserContext *erc, Geom::Point p); -static Geom::Point sp_eraser_get_npoint(SPEraserContext const *erc, Geom::Point v); -static Geom::Point sp_eraser_get_vpoint(SPEraserContext const *erc, Geom::Point n); -static void draw_temporary_box(SPEraserContext *dc); - #include "tool-factory.h" namespace { @@ -181,66 +169,42 @@ flerp(double f0, double f1, double p) return f0 + ( f1 - f0 ) * p; } -/* Get normalized point */ -static Geom::Point -sp_eraser_get_npoint(SPEraserContext const *dc, Geom::Point v) -{ - Geom::Rect drect = SP_EVENT_CONTEXT(dc)->desktop->get_display_area(); - double const max = MAX ( drect.dimensions()[Geom::X], drect.dimensions()[Geom::Y] ); - return Geom::Point(( v[Geom::X] - drect.min()[Geom::X] ) / max, ( v[Geom::Y] - drect.min()[Geom::Y] ) / max); -} - -/* Get view point */ -static Geom::Point -sp_eraser_get_vpoint(SPEraserContext const *dc, Geom::Point n) -{ - Geom::Rect drect = SP_EVENT_CONTEXT(dc)->desktop->get_display_area(); - double const max = MAX ( drect.dimensions()[Geom::X], drect.dimensions()[Geom::Y] ); - return Geom::Point(n[Geom::X] * max + drect.min()[Geom::X], n[Geom::Y] * max + drect.min()[Geom::Y]); -} - -static void -sp_eraser_reset(SPEraserContext *dc, Geom::Point p) -{ - dc->last = dc->cur = sp_eraser_get_npoint(dc, p); - dc->vel = Geom::Point(0,0); - dc->vel_max = 0; - dc->acc = Geom::Point(0,0); - dc->ang = Geom::Point(0,0); - dc->del = Geom::Point(0,0); +void SPEraserContext::reset(Geom::Point p) { + this->last = this->cur = getNormalizedPoint(p); + this->vel = Geom::Point(0,0); + this->vel_max = 0; + this->acc = Geom::Point(0,0); + this->ang = Geom::Point(0,0); + this->del = Geom::Point(0,0); } -static void -sp_eraser_extinput(SPEraserContext *dc, GdkEvent *event) -{ - if (gdk_event_get_axis (event, GDK_AXIS_PRESSURE, &dc->pressure)) - dc->pressure = CLAMP (dc->pressure, ERC_MIN_PRESSURE, ERC_MAX_PRESSURE); +void SPEraserContext::extinput(GdkEvent *event) { + if (gdk_event_get_axis (event, GDK_AXIS_PRESSURE, &this->pressure)) + this->pressure = CLAMP (this->pressure, ERC_MIN_PRESSURE, ERC_MAX_PRESSURE); else - dc->pressure = ERC_DEFAULT_PRESSURE; + this->pressure = ERC_DEFAULT_PRESSURE; - if (gdk_event_get_axis (event, GDK_AXIS_XTILT, &dc->xtilt)) - dc->xtilt = CLAMP (dc->xtilt, ERC_MIN_TILT, ERC_MAX_TILT); + if (gdk_event_get_axis (event, GDK_AXIS_XTILT, &this->xtilt)) + this->xtilt = CLAMP (this->xtilt, ERC_MIN_TILT, ERC_MAX_TILT); else - dc->xtilt = ERC_DEFAULT_TILT; + this->xtilt = ERC_DEFAULT_TILT; - if (gdk_event_get_axis (event, GDK_AXIS_YTILT, &dc->ytilt)) - dc->ytilt = CLAMP (dc->ytilt, ERC_MIN_TILT, ERC_MAX_TILT); + if (gdk_event_get_axis (event, GDK_AXIS_YTILT, &this->ytilt)) + this->ytilt = CLAMP (this->ytilt, ERC_MIN_TILT, ERC_MAX_TILT); else - dc->ytilt = ERC_DEFAULT_TILT; + this->ytilt = ERC_DEFAULT_TILT; } -static gboolean -sp_eraser_apply(SPEraserContext *dc, Geom::Point p) -{ - Geom::Point n = sp_eraser_get_npoint(dc, p); +bool SPEraserContext::apply(Geom::Point p) { + Geom::Point n = getNormalizedPoint(p); /* Calculate mass and drag */ - double const mass = flerp(1.0, 160.0, dc->mass); - double const drag = flerp(0.0, 0.5, dc->drag * dc->drag); + double const mass = flerp(1.0, 160.0, this->mass); + double const drag = flerp(0.0, 0.5, this->drag * this->drag); /* Calculate force and acceleration */ - Geom::Point force = n - dc->cur; + Geom::Point force = n - this->cur; // If force is below the absolute threshold ERASER_EPSILON, // or we haven't yet reached ERASER_VEL_START (i.e. at the beginning of stroke) @@ -249,27 +213,27 @@ sp_eraser_apply(SPEraserContext *dc, Geom::Point p) // This prevents flips, blobs, and jerks caused by microscopic tremor of the tablet pen, // especially bothersome at the start of the stroke where we don't yet have the inertia to // smooth them out. - if ( Geom::L2(force) < ERASER_EPSILON || (dc->vel_max < ERASER_VEL_START && Geom::L2(force) < ERASER_EPSILON_START)) { + if ( Geom::L2(force) < ERASER_EPSILON || (this->vel_max < ERASER_VEL_START && Geom::L2(force) < ERASER_EPSILON_START)) { return FALSE; } - dc->acc = force / mass; + this->acc = force / mass; /* Calculate new velocity */ - dc->vel += dc->acc; + this->vel += this->acc; - if (Geom::L2(dc->vel) > dc->vel_max) - dc->vel_max = Geom::L2(dc->vel); + if (Geom::L2(this->vel) > this->vel_max) + this->vel_max = Geom::L2(this->vel); /* Calculate angle of drawing tool */ double a1; - if (dc->usetilt) { + if (this->usetilt) { // 1a. calculate nib angle from input device tilt: - gdouble length = std::sqrt(dc->xtilt*dc->xtilt + dc->ytilt*dc->ytilt);; + gdouble length = std::sqrt(this->xtilt*this->xtilt + this->ytilt*this->ytilt);; if (length > 0) { - Geom::Point ang1 = Geom::Point(dc->ytilt/length, dc->xtilt/length); + Geom::Point ang1 = Geom::Point(this->ytilt/length, this->xtilt/length); a1 = atan2(ang1); } else @@ -277,17 +241,17 @@ sp_eraser_apply(SPEraserContext *dc, Geom::Point p) } else { // 1b. fixed dc->angle (absolutely flat nib): - double const radians = ( (dc->angle - 90) / 180.0 ) * M_PI; + double const radians = ( (this->angle - 90) / 180.0 ) * M_PI; Geom::Point ang1 = Geom::Point(-sin(radians), cos(radians)); a1 = atan2(ang1); } // 2. perpendicular to dc->vel (absolutely non-flat nib): - gdouble const mag_vel = Geom::L2(dc->vel); + gdouble const mag_vel = Geom::L2(this->vel); if ( mag_vel < ERASER_EPSILON ) { return FALSE; } - Geom::Point ang2 = Geom::rot90(dc->vel) / mag_vel; + Geom::Point ang2 = Geom::rot90(this->vel) / mag_vel; // 3. Average them using flatness parameter: // calculate angles @@ -305,52 +269,50 @@ sp_eraser_apply(SPEraserContext *dc, Geom::Point p) a2 += 2*M_PI; // find the flatness-weighted bisector angle, unflip if a2 was flipped // FIXME: when dc->vel is oscillating around the fixed angle, the new_ang flips back and forth. How to avoid this? - double new_ang = a1 + (1 - dc->flatness) * (a2 - a1) - (flipped? M_PI : 0); + double new_ang = a1 + (1 - this->flatness) * (a2 - a1) - (flipped? M_PI : 0); // Try to detect a sudden flip when the new angle differs too much from the previous for the // current velocity; in that case discard this move - double angle_delta = Geom::L2(Geom::Point (cos (new_ang), sin (new_ang)) - dc->ang); - if ( angle_delta / Geom::L2(dc->vel) > 4000 ) { + double angle_delta = Geom::L2(Geom::Point (cos (new_ang), sin (new_ang)) - this->ang); + if ( angle_delta / Geom::L2(this->vel) > 4000 ) { return FALSE; } // convert to point - dc->ang = Geom::Point (cos (new_ang), sin (new_ang)); + this->ang = Geom::Point (cos (new_ang), sin (new_ang)); // g_print ("force %g acc %g vel_max %g vel %g a1 %g a2 %g new_ang %g\n", Geom::L2(force), Geom::L2(dc->acc), dc->vel_max, Geom::L2(dc->vel), a1, a2, new_ang); /* Apply drag */ - dc->vel *= 1.0 - drag; + this->vel *= 1.0 - drag; /* Update position */ - dc->last = dc->cur; - dc->cur += dc->vel; + this->last = this->cur; + this->cur += this->vel; return TRUE; } -static void -sp_eraser_brush(SPEraserContext *dc) -{ - g_assert( dc->npoints >= 0 && dc->npoints < SAMPLING_SIZE ); +void SPEraserContext::brush() { + g_assert( this->npoints >= 0 && this->npoints < SAMPLING_SIZE ); // How much velocity thins strokestyle - double vel_thin = flerp (0, 160, dc->vel_thin); + double vel_thin = flerp (0, 160, this->vel_thin); // Influence of pressure on thickness - double pressure_thick = (dc->usepressure ? dc->pressure : 1.0); + double pressure_thick = (this->usepressure ? this->pressure : 1.0); // get the real brush point, not the same as pointer (affected by hatch tracking and/or mass // drag) - Geom::Point brush = sp_eraser_get_vpoint(dc, dc->cur); + Geom::Point brush = getViewPoint(this->cur); //Geom::Point brush_w = SP_EVENT_CONTEXT(dc)->desktop->d2w(brush); double trace_thick = 1; - double width = (pressure_thick * trace_thick - vel_thin * Geom::L2(dc->vel)) * dc->width; + double width = (pressure_thick * trace_thick - vel_thin * Geom::L2(this->vel)) * this->width; double tremble_left = 0, tremble_right = 0; - if (dc->tremor > 0) { + if (this->tremor > 0) { // obtain two normally distributed random variables, using polar Box-Muller transform double x1, x2, w, y1, y2; do { @@ -367,28 +329,28 @@ sp_eraser_brush(SPEraserContext *dc) // (2) deflection depends on width, but is upped for small widths for better visual uniformity across widths; // (3) deflection somewhat depends on speed, to prevent fast strokes looking // comparatively smooth and slow ones excessively jittery - tremble_left = (y1)*dc->tremor * (0.15 + 0.8*width) * (0.35 + 14*Geom::L2(dc->vel)); - tremble_right = (y2)*dc->tremor * (0.15 + 0.8*width) * (0.35 + 14*Geom::L2(dc->vel)); + tremble_left = (y1)*this->tremor * (0.15 + 0.8*width) * (0.35 + 14*Geom::L2(this->vel)); + tremble_right = (y2)*this->tremor * (0.15 + 0.8*width) * (0.35 + 14*Geom::L2(this->vel)); } - if ( width < 0.02 * dc->width ) { - width = 0.02 * dc->width; + if ( width < 0.02 * this->width ) { + width = 0.02 * this->width; } double dezoomify_factor = 0.05 * 1000; - if (!dc->abs_width) { - dezoomify_factor /= SP_EVENT_CONTEXT(dc)->desktop->current_zoom(); + if (!this->abs_width) { + dezoomify_factor /= SP_EVENT_CONTEXT(this)->desktop->current_zoom(); } - Geom::Point del_left = dezoomify_factor * (width + tremble_left) * dc->ang; - Geom::Point del_right = dezoomify_factor * (width + tremble_right) * dc->ang; + Geom::Point del_left = dezoomify_factor * (width + tremble_left) * this->ang; + Geom::Point del_right = dezoomify_factor * (width + tremble_right) * this->ang; - dc->point1[dc->npoints] = brush + del_left; - dc->point2[dc->npoints] = brush - del_right; + this->point1[this->npoints] = brush + del_left; + this->point2[this->npoints] = brush - del_right; - dc->del = 0.5*(del_left + del_right); + this->del = 0.5*(del_left + del_right); - dc->npoints++; + this->npoints++; } static void @@ -397,27 +359,25 @@ sp_erc_update_toolbox (SPDesktop *desktop, const gchar *id, double value) desktop->setToolboxAdjustmentValue (id, value); } -static void -eraser_cancel(SPEraserContext *dc) -{ - SPDesktop *desktop = SP_EVENT_CONTEXT(dc)->desktop; - dc->dragging = FALSE; - dc->is_drawing = false; +void SPEraserContext::cancel() { + SPDesktop *desktop = SP_EVENT_CONTEXT(this)->desktop; + this->dragging = FALSE; + this->is_drawing = false; sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), 0); /* Remove all temporary line segments */ - while (dc->segments) { - sp_canvas_item_destroy(SP_CANVAS_ITEM(dc->segments->data)); - dc->segments = g_slist_remove(dc->segments, dc->segments->data); + while (this->segments) { + sp_canvas_item_destroy(SP_CANVAS_ITEM(this->segments->data)); + this->segments = g_slist_remove(this->segments, this->segments->data); } /* reset accumulated curve */ - dc->accumulated->reset(); - clear_current(dc); - if (dc->repr) { - dc->repr = NULL; + this->accumulated->reset(); + this->clear_current(); + if (this->repr) { + this->repr = NULL; } } -gint SPEraserContext::root_handler(GdkEvent* event) { +bool SPEraserContext::root_handler(GdkEvent* event) { gint ret = FALSE; switch (event->type) { @@ -430,9 +390,9 @@ gint SPEraserContext::root_handler(GdkEvent* event) { Geom::Point const button_w(event->button.x, event->button.y); Geom::Point const button_dt(desktop->w2d(button_w)); - sp_eraser_reset(this, button_dt); - sp_eraser_extinput(this, event); - sp_eraser_apply(this, button_dt); + this->reset(button_dt); + this->extinput(event); + this->apply(button_dt); this->accumulated->reset(); @@ -465,7 +425,7 @@ gint SPEraserContext::root_handler(GdkEvent* event) { Geom::Point const motion_w(event->motion.x, event->motion.y); Geom::Point motion_dt(desktop->w2d(motion_w) ); - sp_eraser_extinput(this, event); + this->extinput(event); this->_message_context->clear(); @@ -474,15 +434,15 @@ gint SPEraserContext::root_handler(GdkEvent* event) { this->_message_context->set(Inkscape::NORMAL_MESSAGE, _("Drawing an eraser stroke")); - if (!sp_eraser_apply(this, motion_dt)) { + if (!this->apply(motion_dt)) { ret = TRUE; break; } if ( this->cur != this->last ) { - sp_eraser_brush(this); + this->brush(); g_assert( this->npoints > 0 ); - fit_and_split(this, FALSE); + this->fit_and_split(false); } ret = TRUE; @@ -503,7 +463,7 @@ gint SPEraserContext::root_handler(GdkEvent* event) { if (this->dragging && event->button.button == 1 && !this->space_panning) { this->dragging = FALSE; - sp_eraser_apply(this, motion_dt); + this->apply(motion_dt); /* Remove all temporary line segments */ while (this->segments) { @@ -512,14 +472,14 @@ gint SPEraserContext::root_handler(GdkEvent* event) { } /* Create object */ - fit_and_split(this, TRUE); - accumulate_eraser(this); - set_to_accumulated(this); // performs document_done + this->fit_and_split(true); + this->accumulate(); + this->set_to_accumulated(); // performs document_done /* reset accumulated curve */ this->accumulated->reset(); - clear_current(this); + this->clear_current(); if (this->repr) { this->repr = NULL; } @@ -620,7 +580,7 @@ gint SPEraserContext::root_handler(GdkEvent* event) { if (this->is_drawing) { // if drawing, cancel, otherwise pass it up for deselecting - eraser_cancel (this); + this->cancel(); ret = TRUE; } break; @@ -629,7 +589,7 @@ gint SPEraserContext::root_handler(GdkEvent* event) { case GDK_KEY_Z: if (MOD__CTRL_ONLY(event) && this->is_drawing) { // if drawing, cancel, otherwise pass it up for undo - eraser_cancel (this); + this->cancel(); ret = TRUE; } break; @@ -662,29 +622,24 @@ gint SPEraserContext::root_handler(GdkEvent* event) { return ret; } -static void -clear_current(SPEraserContext *dc) -{ +void SPEraserContext::clear_current() { // reset bpath - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(dc->currentshape), NULL); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), NULL); // reset curve - dc->currentcurve->reset(); - dc->cal1->reset(); - dc->cal2->reset(); + this->currentcurve->reset(); + this->cal1->reset(); + this->cal2->reset(); // reset points - dc->npoints = 0; + this->npoints = 0; } -static void -set_to_accumulated(SPEraserContext *dc) -{ - SPDesktop *desktop = SP_EVENT_CONTEXT(dc)->desktop; +void SPEraserContext::set_to_accumulated() { bool workDone = false; - if (!dc->accumulated->is_empty()) { - if (!dc->repr) { + if (!this->accumulated->is_empty()) { + if (!this->repr) { /* Create object */ Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); @@ -692,22 +647,22 @@ set_to_accumulated(SPEraserContext *dc) /* Set style */ sp_desktop_apply_style_tool (desktop, repr, "/tools/eraser", false); - dc->repr = repr; + this->repr = repr; - SPItem *item=SP_ITEM(desktop->currentLayer()->appendChildRepr(dc->repr)); - Inkscape::GC::release(dc->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(); } - Geom::PathVector pathv = dc->accumulated->get_pathvector() * desktop->dt2doc(); + Geom::PathVector pathv = this->accumulated->get_pathvector() * desktop->dt2doc(); gchar *str = sp_svg_write_path(pathv); g_assert( str != NULL ); - dc->repr->setAttribute("d", str); + this->repr->setAttribute("d", str); g_free(str); - if ( dc->repr ) { + if ( this->repr ) { bool wasSelection = false; Inkscape::Selection *selection = sp_desktop_selection(desktop); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -715,7 +670,7 @@ set_to_accumulated(SPEraserContext *dc) gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0; Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); - SPItem* acid = SP_ITEM(desktop->doc()->getObjectByRepr(dc->repr)); + SPItem* acid = SP_ITEM(desktop->doc()->getObjectByRepr(this->repr)); Geom::OptRect eraserBbox = acid->visualBounds(); Geom::Rect bounds = (*eraserBbox) * desktop->doc2dt(); std::vector remainingItems; @@ -744,8 +699,8 @@ set_to_accumulated(SPEraserContext *dc) Geom::OptRect bbox = item->visualBounds(); if (bbox && bbox->intersects(*eraserBbox)) { - Inkscape::XML::Node* dup = dc->repr->duplicate(xml_doc); - dc->repr->parent()->appendChild(dup); + Inkscape::XML::Node* dup = this->repr->duplicate(xml_doc); + this->repr->parent()->appendChild(dup); Inkscape::GC::release(dup); // parent takes over selection->set(item); @@ -798,13 +753,13 @@ set_to_accumulated(SPEraserContext *dc) } // Remove the eraser stroke itself: - sp_repr_unparent( dc->repr ); - dc->repr = 0; + sp_repr_unparent( this->repr ); + this->repr = 0; } } else { - if (dc->repr) { - sp_repr_unparent(dc->repr); - dc->repr = 0; + if (this->repr) { + sp_repr_unparent(this->repr); + this->repr = 0; } } @@ -848,21 +803,19 @@ add_cap(SPCurve *curve, } } -static void -accumulate_eraser(SPEraserContext *dc) -{ - if ( !dc->cal1->is_empty() && !dc->cal2->is_empty() ) { - dc->accumulated->reset(); /* Is this required ?? */ - SPCurve *rev_cal2 = dc->cal2->create_reverse(); +void SPEraserContext::accumulate() { + if ( !this->cal1->is_empty() && !this->cal2->is_empty() ) { + this->accumulated->reset(); /* Is this required ?? */ + SPCurve *rev_cal2 = this->cal2->create_reverse(); - g_assert(dc->cal1->get_segment_count() > 0); + g_assert(this->cal1->get_segment_count() > 0); g_assert(rev_cal2->get_segment_count() > 0); - g_assert( ! dc->cal1->first_path()->closed() ); + g_assert( ! this->cal1->first_path()->closed() ); g_assert( ! rev_cal2->first_path()->closed() ); - Geom::CubicBezier const * dc_cal1_firstseg = dynamic_cast( dc->cal1->first_segment() ); + Geom::CubicBezier const * dc_cal1_firstseg = dynamic_cast( this->cal1->first_segment() ); Geom::CubicBezier const * rev_cal2_firstseg = dynamic_cast( rev_cal2->first_segment() ); - Geom::CubicBezier const * dc_cal1_lastseg = dynamic_cast( dc->cal1->last_segment() ); + Geom::CubicBezier const * dc_cal1_lastseg = dynamic_cast( this->cal1->last_segment() ); Geom::CubicBezier const * rev_cal2_lastseg = dynamic_cast( rev_cal2->last_segment() ); g_assert( dc_cal1_firstseg ); @@ -870,20 +823,20 @@ accumulate_eraser(SPEraserContext *dc) g_assert( dc_cal1_lastseg ); g_assert( rev_cal2_lastseg ); - dc->accumulated->append(dc->cal1, FALSE); + this->accumulated->append(this->cal1, FALSE); - add_cap(dc->accumulated, (*dc_cal1_lastseg)[2], (*dc_cal1_lastseg)[3], (*rev_cal2_firstseg)[0], (*rev_cal2_firstseg)[1], dc->cap_rounding); + add_cap(this->accumulated, (*dc_cal1_lastseg)[2], (*dc_cal1_lastseg)[3], (*rev_cal2_firstseg)[0], (*rev_cal2_firstseg)[1], this->cap_rounding); - dc->accumulated->append(rev_cal2, TRUE); + this->accumulated->append(rev_cal2, TRUE); - add_cap(dc->accumulated, (*rev_cal2_lastseg)[2], (*rev_cal2_lastseg)[3], (*dc_cal1_firstseg)[0], (*dc_cal1_firstseg)[1], dc->cap_rounding); + add_cap(this->accumulated, (*rev_cal2_lastseg)[2], (*rev_cal2_lastseg)[3], (*dc_cal1_firstseg)[0], (*dc_cal1_firstseg)[1], this->cap_rounding); - dc->accumulated->closepath(); + this->accumulated->closepath(); rev_cal2->unref(); - dc->cal1->reset(); - dc->cal2->reset(); + this->cal1->reset(); + this->cal2->reset(); } } @@ -892,47 +845,43 @@ static double square(double const x) return x * x; } -static void -fit_and_split(SPEraserContext *dc, gboolean release) -{ - SPDesktop *desktop = SP_EVENT_CONTEXT(dc)->desktop; - +void SPEraserContext::fit_and_split(bool release) { double const tolerance_sq = square( desktop->w2d().descrim() * TOLERANCE_ERASER ); #ifdef ERASER_VERBOSE g_print("[F&S:R=%c]", release?'T':'F'); #endif - if (!( dc->npoints > 0 && dc->npoints < SAMPLING_SIZE )) + if (!( this->npoints > 0 && this->npoints < SAMPLING_SIZE )) return; // just clicked - if ( dc->npoints == SAMPLING_SIZE - 1 || release ) { + if ( this->npoints == SAMPLING_SIZE - 1 || release ) { #define BEZIER_SIZE 4 #define BEZIER_MAX_BEZIERS 8 #define BEZIER_MAX_LENGTH ( BEZIER_SIZE * BEZIER_MAX_BEZIERS ) #ifdef ERASER_VERBOSE - g_print("[F&S:#] dc->npoints:%d, release:%s\n", + g_print("[F&S:#] this->npoints:%d, release:%s\n", dc->npoints, release ? "TRUE" : "FALSE"); #endif /* Current eraser */ - if ( dc->cal1->is_empty() || dc->cal2->is_empty() ) { + if ( this->cal1->is_empty() || this->cal2->is_empty() ) { /* dc->npoints > 0 */ /* g_print("erasers(1|2) reset\n"); */ - dc->cal1->reset(); - dc->cal2->reset(); + this->cal1->reset(); + this->cal2->reset(); - dc->cal1->moveto(dc->point1[0]); - dc->cal2->moveto(dc->point2[0]); + this->cal1->moveto(this->point1[0]); + this->cal2->moveto(this->point2[0]); } Geom::Point b1[BEZIER_MAX_LENGTH]; - gint const nb1 = Geom::bezier_fit_cubic_r(b1, dc->point1, dc->npoints, tolerance_sq, BEZIER_MAX_BEZIERS); + gint const nb1 = Geom::bezier_fit_cubic_r(b1, this->point1, this->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 = Geom::bezier_fit_cubic_r(b2, dc->point2, dc->npoints, tolerance_sq, BEZIER_MAX_BEZIERS); + gint const nb2 = Geom::bezier_fit_cubic_r(b2, this->point2, this->npoints, tolerance_sq, BEZIER_MAX_BEZIERS); g_assert( nb2 * BEZIER_SIZE <= gint(G_N_ELEMENTS(b2)) ); if ( nb1 != -1 && nb2 != -1 ) { @@ -943,63 +892,63 @@ fit_and_split(SPEraserContext *dc, gboolean release) /* CanvasShape */ if (! release) { - dc->currentcurve->reset(); - dc->currentcurve->moveto(b1[0]); + this->currentcurve->reset(); + this->currentcurve->moveto(b1[0]); for (Geom::Point *bp1 = b1; bp1 < b1 + BEZIER_SIZE * nb1; bp1 += BEZIER_SIZE) { - dc->currentcurve->curveto(bp1[1], bp1[2], bp1[3]); + this->currentcurve->curveto(bp1[1], bp1[2], bp1[3]); } - dc->currentcurve->lineto(b2[BEZIER_SIZE*(nb2-1) + 3]); + this->currentcurve->lineto(b2[BEZIER_SIZE*(nb2-1) + 3]); for (Geom::Point *bp2 = b2 + BEZIER_SIZE * ( nb2 - 1 ); bp2 >= b2; bp2 -= BEZIER_SIZE) { - dc->currentcurve->curveto(bp2[2], bp2[1], bp2[0]); + this->currentcurve->curveto(bp2[2], bp2[1], bp2[0]); } - // FIXME: dc->segments is always NULL at this point?? - if (!dc->segments) { // first segment - add_cap(dc->currentcurve, b2[1], b2[0], b1[0], b1[1], dc->cap_rounding); + // FIXME: this->segments is always NULL at this point?? + if (!this->segments) { // first segment + add_cap(this->currentcurve, b2[1], b2[0], b1[0], b1[1], this->cap_rounding); } - dc->currentcurve->closepath(); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(dc->currentshape), dc->currentcurve); + this->currentcurve->closepath(); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), this->currentcurve); } /* Current eraser */ for (Geom::Point *bp1 = b1; bp1 < b1 + BEZIER_SIZE * nb1; bp1 += BEZIER_SIZE) { - dc->cal1->curveto(bp1[1], bp1[2], bp1[3]); + this->cal1->curveto(bp1[1], bp1[2], bp1[3]); } for (Geom::Point *bp2 = b2; bp2 < b2 + BEZIER_SIZE * nb2; bp2 += BEZIER_SIZE) { - dc->cal2->curveto(bp2[1], bp2[2], bp2[3]); + this->cal2->curveto(bp2[1], bp2[2], bp2[3]); } } else { /* fixme: ??? */ #ifdef ERASER_VERBOSE g_print("[fit_and_split] failed to fit-cubic.\n"); #endif - draw_temporary_box(dc); + this->draw_temporary_box(); - for (gint i = 1; i < dc->npoints; i++) { - dc->cal1->lineto(dc->point1[i]); + for (gint i = 1; i < this->npoints; i++) { + this->cal1->lineto(this->point1[i]); } - for (gint i = 1; i < dc->npoints; i++) { - dc->cal2->lineto(dc->point2[i]); + for (gint i = 1; i < this->npoints; i++) { + this->cal2->lineto(this->point2[i]); } } /* Fit and draw and copy last point */ #ifdef ERASER_VERBOSE - g_print("[%d]Yup\n", dc->npoints); + 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(!dc->currentcurve->is_empty()); + g_assert(!this->currentcurve->is_empty()); SPCanvasItem *cbp = sp_canvas_item_new(sp_desktop_sketch(desktop), SP_TYPE_CANVAS_BPATH, NULL); - SPCurve *curve = dc->currentcurve->copy(); + SPCurve *curve = this->currentcurve->copy(); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH (cbp), curve); curve->unref(); @@ -1015,43 +964,41 @@ fit_and_split(SPEraserContext *dc, gboolean release) /* fixme: Cannot we cascade it to root more clearly? */ g_signal_connect(G_OBJECT(cbp), "event", G_CALLBACK(sp_desktop_root_handler), desktop); - dc->segments = g_slist_prepend(dc->segments, cbp); + this->segments = g_slist_prepend(this->segments, cbp); if ( !eraserMode ) { sp_canvas_item_hide(cbp); - sp_canvas_item_hide(dc->currentshape); + sp_canvas_item_hide(this->currentshape); } } - dc->point1[0] = dc->point1[dc->npoints - 1]; - dc->point2[0] = dc->point2[dc->npoints - 1]; - dc->npoints = 1; + this->point1[0] = this->point1[this->npoints - 1]; + this->point2[0] = this->point2[this->npoints - 1]; + this->npoints = 1; } else { - draw_temporary_box(dc); + this->draw_temporary_box(); } } -static void -draw_temporary_box(SPEraserContext *dc) -{ - dc->currentcurve->reset(); +void SPEraserContext::draw_temporary_box() { + this->currentcurve->reset(); - dc->currentcurve->moveto(dc->point1[dc->npoints-1]); + this->currentcurve->moveto(this->point1[this->npoints-1]); - for (gint i = dc->npoints-2; i >= 0; i--) { - dc->currentcurve->lineto(dc->point1[i]); + for (gint i = this->npoints-2; i >= 0; i--) { + this->currentcurve->lineto(this->point1[i]); } - for (gint i = 0; i < dc->npoints; i++) { - dc->currentcurve->lineto(dc->point2[i]); + for (gint i = 0; i < this->npoints; i++) { + this->currentcurve->lineto(this->point2[i]); } - if (dc->npoints >= 2) { - add_cap(dc->currentcurve, dc->point2[dc->npoints-2], dc->point2[dc->npoints-1], dc->point1[dc->npoints-1], dc->point1[dc->npoints-2], dc->cap_rounding); + if (this->npoints >= 2) { + add_cap(this->currentcurve, this->point2[this->npoints-2], this->point2[this->npoints-1], this->point1[this->npoints-1], this->point1[this->npoints-2], this->cap_rounding); } - dc->currentcurve->closepath(); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(dc->currentshape), dc->currentcurve); + this->currentcurve->closepath(); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), this->currentcurve); } /* -- cgit v1.2.3 From 989abbac025a8b3349748d19a613a08586c5fdcd Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Wed, 31 Jul 2013 21:11:20 +0200 Subject: Fixed SPObject ctor and dtor; removed singleton.h; some smaller changes. (bzr r11608.1.110) --- src/eraser-context.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/eraser-context.cpp') diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp index 6391419eb..b2df86434 100644 --- a/src/eraser-context.cpp +++ b/src/eraser-context.cpp @@ -152,8 +152,6 @@ static ProfileFloatElement f_profile[PROFILE_FLOAT_SIZE] = { this->is_drawing = false; - this->_message_context = new Inkscape::MessageContext(desktop->messageStack()); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/tools/eraser/selcue", 0) != 0) { this->enableSelectionCue(); @@ -383,7 +381,7 @@ bool SPEraserContext::root_handler(GdkEvent* event) { switch (event->type) { case GDK_BUTTON_PRESS: if (event->button.button == 1 && !this->space_panning) { - if (Inkscape::have_viable_layer(desktop, this->_message_context) == false) { + if (Inkscape::have_viable_layer(desktop, this->message_context) == false) { return TRUE; } @@ -427,12 +425,12 @@ bool SPEraserContext::root_handler(GdkEvent* event) { ); this->extinput(event); - this->_message_context->clear(); + this->message_context->clear(); if ( this->is_drawing && (event->motion.state & GDK_BUTTON1_MASK) && !this->space_panning) { this->dragging = TRUE; - this->_message_context->set(Inkscape::NORMAL_MESSAGE, _("Drawing an eraser stroke")); + this->message_context->set(Inkscape::NORMAL_MESSAGE, _("Drawing an eraser stroke")); if (!this->apply(motion_dt)) { ret = TRUE; @@ -484,7 +482,7 @@ bool SPEraserContext::root_handler(GdkEvent* event) { this->repr = NULL; } - this->_message_context->clear(); + this->message_context->clear(); ret = TRUE; } @@ -603,7 +601,7 @@ bool SPEraserContext::root_handler(GdkEvent* event) { switch (get_group0_keyval(&event->key)) { case GDK_KEY_Control_L: case GDK_KEY_Control_R: - this->_message_context->clear(); + this->message_context->clear(); break; default: -- cgit v1.2.3