summaryrefslogtreecommitdiffstats
path: root/src/ui/tools/pen-tool.cpp
diff options
context:
space:
mode:
authorLiam P. White <inkscapebrony@gmail.com>2014-08-08 15:04:56 +0000
committerLiam P. White <inkscapebrony@gmail.com>2014-08-08 15:04:56 +0000
commitca8023872ae0d9f7b99688502b9bdba232ec5627 (patch)
tree73092b0aa6ea3e697da66d1d6316d3a2d78a4f3e /src/ui/tools/pen-tool.cpp
parentUpdate to experimental r13440 (diff)
parentSmall tweak to bbox calculation (diff)
downloadinkscape-ca8023872ae0d9f7b99688502b9bdba232ec5627.tar.gz
inkscape-ca8023872ae0d9f7b99688502b9bdba232ec5627.zip
Update to experimental r13464
(bzr r13341.5.14)
Diffstat (limited to 'src/ui/tools/pen-tool.cpp')
-rw-r--r--src/ui/tools/pen-tool.cpp44
1 files changed, 23 insertions, 21 deletions
diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp
index 56bcbef0d..9a73d497f 100644
--- a/src/ui/tools/pen-tool.cpp
+++ b/src/ui/tools/pen-tool.cpp
@@ -84,17 +84,17 @@ namespace Tools {
static Geom::Point pen_drag_origin_w(0, 0);
static bool pen_within_tolerance = false;
static int pen_last_paraxial_dir = 0; // last used direction in horizontal/vertical mode; 0 = horizontal, 1 = vertical
-
+const double handleCubicGap = 0.01;
namespace {
- ToolBase* createPenContext() {
- return new PenTool();
- }
+ ToolBase* createPenContext() {
+ return new PenTool();
+ }
- bool penContextRegistered = ToolFactory::instance().registerObject("/tools/freehand/pen", createPenContext);
+ bool penContextRegistered = ToolFactory::instance().registerObject("/tools/freehand/pen", createPenContext);
}
const std::string& PenTool::getPrefsPath() {
- return PenTool::prefsPath;
+ return PenTool::prefsPath;
}
const std::string PenTool::prefsPath = "/tools/freehand/pen";
@@ -321,7 +321,7 @@ bool PenTool::item_handler(SPItem* item, GdkEvent* event) {
}
if (!ret) {
- ret = FreehandBase::item_handler(item, event);
+ ret = FreehandBase::item_handler(item, event);
}
return ret;
@@ -359,7 +359,7 @@ bool PenTool::root_handler(GdkEvent* event) {
}
if (!ret) {
- ret = FreehandBase::root_handler(event);
+ ret = FreehandBase::root_handler(event);
}
return ret;
@@ -1268,15 +1268,15 @@ bool PenTool::_handleKeyPress(GdkEvent *event) {
}
// asign the value in a third of the distance of the last segment.
- if(this->bspline){
+ if (this->bspline){
this->p[1] = this->p[0] + (1./3)*(this->p[3] - this->p[0]);
}
Geom::Point const pt( (this->npoints < 4) ? crv->finalPoint() : this->p[3] );
-
+
this->npoints = 2;
// delete the last segment of the green curve
- if( this->green_curve->get_segment_count() == 1){
+ if (this->green_curve->get_segment_count() == 1) {
this->npoints = 5;
if (this->green_bpaths) {
if (this->green_bpaths->data) {
@@ -1285,11 +1285,12 @@ bool PenTool::_handleKeyPress(GdkEvent *event) {
this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data);
}
this->green_curve->reset();
- }else{
+ } else {
this->green_curve->backspace();
}
+
// assign the value of this->p[1] to the oposite of the green line last segment
- if(this->spiro){
+ if (this->spiro){
Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const *>(this->green_curve->last_segment());
if ( cubic ) {
this->p[1] = (*cubic)[3] + (*cubic)[3] - (*cubic)[2];
@@ -1298,6 +1299,7 @@ bool PenTool::_handleKeyPress(GdkEvent *event) {
this->p[1] = this->p[0];
}
}
+
sp_canvas_item_hide(this->c0);
sp_canvas_item_hide(this->c1);
sp_canvas_item_hide(this->cl0);
@@ -1452,7 +1454,7 @@ void PenTool::_bspline_spiro_on()
this->p[0] = this->red_curve->first_segment()->initialPoint();
this->p[3] = this->red_curve->first_segment()->finalPoint();
this->p[2] = this->p[3] + (1./3)*(this->p[0] - this->p[3]);
- this->p[2] = Geom::Point(this->p[2][X] + 0.005,this->p[2][Y] + 0.005);
+ this->p[2] = Geom::Point(this->p[2][X] + handleCubicGap,this->p[2][Y] + handleCubicGap);
}
}
@@ -1520,7 +1522,7 @@ void PenTool::_bspline_spiro_start_anchor_on()
Geom::Point A = tmpCurve->last_segment()->initialPoint();
Geom::Point D = tmpCurve->last_segment()->finalPoint();
Geom::Point C = D + (1./3)*(A - D);
- C = Geom::Point(C[X] + 0.005,C[Y] + 0.005);
+ C = Geom::Point(C[X] + handleCubicGap,C[Y] + handleCubicGap);
if(cubic){
lastSeg->moveto(A);
lastSeg->curveto((*cubic)[1],C,D);
@@ -1578,10 +1580,10 @@ void PenTool::_bspline_spiro_motion(bool shift){
this->npoints = 5;
SPCurve *tmpCurve = new SPCurve();
this->p[2] = this->p[3] + (1./3)*(this->p[0] - this->p[3]);
- this->p[2] = Geom::Point(this->p[2][X] + 0.005,this->p[2][Y] + 0.005);
+ this->p[2] = Geom::Point(this->p[2][X] + handleCubicGap,this->p[2][Y] + handleCubicGap);
if(this->green_curve->is_empty() && !this->sa){
this->p[1] = this->p[0] + (1./3)*(this->p[3] - this->p[0]);
- this->p[1] = Geom::Point(this->p[1][X] + 0.005,this->p[1][Y] + 0.005);
+ this->p[1] = Geom::Point(this->p[1][X] + handleCubicGap,this->p[1][Y] + handleCubicGap);
}else if(!this->green_curve->is_empty()){
tmpCurve = this->green_curve->copy();
}else{
@@ -1606,7 +1608,7 @@ void PenTool::_bspline_spiro_motion(bool shift){
WPower->reset();
this->p[1] = SBasisWPower.valueAt(WP);
if(!Geom::are_near(this->p[1],this->p[0]))
- this->p[1] = Geom::Point(this->p[1][X] + 0.005,this->p[1][Y] + 0.005);
+ this->p[1] = Geom::Point(this->p[1][X] + handleCubicGap,this->p[1][Y] + handleCubicGap);
if(shift)
this->p[2] = this->p[3];
}else{
@@ -1636,7 +1638,7 @@ void PenTool::_bspline_spiro_end_anchor_on()
using Geom::X;
using Geom::Y;
this->p[2] = this->p[3] + (1./3)*(this->p[0] - this->p[3]);
- this->p[2] = Geom::Point(this->p[2][X] + 0.005,this->p[2][Y] + 0.005);
+ this->p[2] = Geom::Point(this->p[2][X] + handleCubicGap,this->p[2][Y] + handleCubicGap);
SPCurve *tmpCurve = new SPCurve();
SPCurve *lastSeg = new SPCurve();
Geom::Point C(0,0);
@@ -1659,7 +1661,7 @@ void PenTool::_bspline_spiro_end_anchor_on()
Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*tmpCurve->last_segment());
if(this->bspline){
C = tmpCurve->last_segment()->finalPoint() + (1./3)*(tmpCurve->last_segment()->initialPoint() - tmpCurve->last_segment()->finalPoint());
- C = Geom::Point(C[X] + 0.005,C[Y] + 0.005);
+ C = Geom::Point(C[X] + handleCubicGap,C[Y] + handleCubicGap);
}else{
C = this->p[3] + this->p[3] - this->p[2];
}
@@ -2084,7 +2086,7 @@ void PenTool::_setSubsequentPoint(Geom::Point const p, bool statusbar, guint sta
// we are drawing horizontal/vertical lines and hit an anchor;
Geom::Point const origin = this->p[0];
// if the previous point and the anchor are not aligned either horizontally or vertically...
- if ((abs(p[Geom::X] - origin[Geom::X]) > 1e-9) && (abs(p[Geom::Y] - origin[Geom::Y]) > 1e-9)) {
+ if ((std::abs(p[Geom::X] - origin[Geom::X]) > 1e-9) && (std::abs(p[Geom::Y] - origin[Geom::Y]) > 1e-9)) {
// ...then we should draw an L-shaped path, consisting of two paraxial segments
Geom::Point intermed = p;
this->_setToNearestHorizVert(intermed, status, false);