summaryrefslogtreecommitdiffstats
path: root/src/ui/tools/eraser-tool.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2013-11-13 00:00:04 +0000
committerJabiertxof <jtx@jtx.marker.es>2013-11-13 00:00:04 +0000
commit152a0caf7e216e7ceafeed20822500c385e3e2df (patch)
treea3b5d60e08f3bd8221ba2e50eea80b087e5d541a /src/ui/tools/eraser-tool.cpp
parentUpdate to trunk (diff)
parentfix C++11 compilation. There A LOT of const_casts in this file... :-( (diff)
downloadinkscape-152a0caf7e216e7ceafeed20822500c385e3e2df.tar.gz
inkscape-152a0caf7e216e7ceafeed20822500c385e3e2df.zip
Update to trunk
(bzr r12588.1.26)
Diffstat (limited to '')
-rw-r--r--src/ui/tools/eraser-tool.cpp (renamed from src/eraser-context.cpp)52
1 files changed, 30 insertions, 22 deletions
diff --git a/src/eraser-context.cpp b/src/ui/tools/eraser-tool.cpp
index b2df86434..270987d27 100644
--- a/src/eraser-context.cpp
+++ b/src/ui/tools/eraser-tool.cpp
@@ -67,7 +67,7 @@
#include <2geom/math-utils.h>
#include <2geom/pathvector.h>
-#include "eraser-context.h"
+#include "ui/tools/eraser-tool.h"
using Inkscape::DocumentUndo;
@@ -85,31 +85,35 @@ using Inkscape::DocumentUndo;
#include "tool-factory.h"
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
namespace {
- SPEventContext* createEraserContext() {
- return new SPEraserContext();
+ ToolBase* createEraserContext() {
+ return new EraserTool();
}
bool eraserContextRegistered = ToolFactory::instance().registerObject("/tools/eraser", createEraserContext);
}
-const std::string& SPEraserContext::getPrefsPath() {
- return SPEraserContext::prefsPath;
+const std::string& EraserTool::getPrefsPath() {
+ return EraserTool::prefsPath;
}
-const std::string SPEraserContext::prefsPath = "/tools/eraser";
+const std::string EraserTool::prefsPath = "/tools/eraser";
-SPEraserContext::SPEraserContext() : SPCommonContext() {
+EraserTool::EraserTool() : DynamicBase() {
this->cursor_shape = cursor_eraser_xpm;
this->hot_x = 4;
this->hot_y = 4;
}
-SPEraserContext::~SPEraserContext() {
+EraserTool::~EraserTool() {
}
-void SPEraserContext::setup() {
- SPCommonContext::setup();
+void EraserTool::setup() {
+ DynamicBase::setup();
this->accumulated = new SPCurve();
this->currentcurve = new SPCurve();
@@ -167,7 +171,7 @@ flerp(double f0, double f1, double p)
return f0 + ( f1 - f0 ) * p;
}
-void SPEraserContext::reset(Geom::Point p) {
+void EraserTool::reset(Geom::Point p) {
this->last = this->cur = getNormalizedPoint(p);
this->vel = Geom::Point(0,0);
this->vel_max = 0;
@@ -176,7 +180,7 @@ void SPEraserContext::reset(Geom::Point p) {
this->del = Geom::Point(0,0);
}
-void SPEraserContext::extinput(GdkEvent *event) {
+void EraserTool::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
@@ -194,7 +198,7 @@ void SPEraserContext::extinput(GdkEvent *event) {
}
-bool SPEraserContext::apply(Geom::Point p) {
+bool EraserTool::apply(Geom::Point p) {
Geom::Point n = getNormalizedPoint(p);
/* Calculate mass and drag */
@@ -291,7 +295,7 @@ bool SPEraserContext::apply(Geom::Point p) {
return TRUE;
}
-void SPEraserContext::brush() {
+void EraserTool::brush() {
g_assert( this->npoints >= 0 && this->npoints < SAMPLING_SIZE );
// How much velocity thins strokestyle
@@ -357,7 +361,7 @@ sp_erc_update_toolbox (SPDesktop *desktop, const gchar *id, double value)
desktop->setToolboxAdjustmentValue (id, value);
}
-void SPEraserContext::cancel() {
+void EraserTool::cancel() {
SPDesktop *desktop = SP_EVENT_CONTEXT(this)->desktop;
this->dragging = FALSE;
this->is_drawing = false;
@@ -375,7 +379,7 @@ void SPEraserContext::cancel() {
}
}
-bool SPEraserContext::root_handler(GdkEvent* event) {
+bool EraserTool::root_handler(GdkEvent* event) {
gint ret = FALSE;
switch (event->type) {
@@ -614,13 +618,13 @@ bool SPEraserContext::root_handler(GdkEvent* event) {
}
if (!ret) {
- ret = SPCommonContext::root_handler(event);
+ ret = DynamicBase::root_handler(event);
}
return ret;
}
-void SPEraserContext::clear_current() {
+void EraserTool::clear_current() {
// reset bpath
sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), NULL);
@@ -633,7 +637,7 @@ void SPEraserContext::clear_current() {
this->npoints = 0;
}
-void SPEraserContext::set_to_accumulated() {
+void EraserTool::set_to_accumulated() {
bool workDone = false;
if (!this->accumulated->is_empty()) {
@@ -801,7 +805,7 @@ add_cap(SPCurve *curve,
}
}
-void SPEraserContext::accumulate() {
+void EraserTool::accumulate() {
if ( !this->cal1->is_empty() && !this->cal2->is_empty() ) {
this->accumulated->reset(); /* Is this required ?? */
SPCurve *rev_cal2 = this->cal2->create_reverse();
@@ -843,7 +847,7 @@ static double square(double const x)
return x * x;
}
-void SPEraserContext::fit_and_split(bool release) {
+void EraserTool::fit_and_split(bool release) {
double const tolerance_sq = square( desktop->w2d().descrim() * TOLERANCE_ERASER );
#ifdef ERASER_VERBOSE
@@ -978,7 +982,7 @@ void SPEraserContext::fit_and_split(bool release) {
}
}
-void SPEraserContext::draw_temporary_box() {
+void EraserTool::draw_temporary_box() {
this->currentcurve->reset();
this->currentcurve->moveto(this->point1[this->npoints-1]);
@@ -999,6 +1003,10 @@ void SPEraserContext::draw_temporary_box() {
sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), this->currentcurve);
}
+}
+}
+}
+
/*
Local Variables:
mode:c++