diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2014-09-23 21:43:31 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2014-09-23 21:43:31 +0000 |
| commit | 86cf2d0a97e0412629102ae51df0a4797f9179db (patch) | |
| tree | d4ba8704b993eefd6b7410fd2d51d104a166096f /src/ui/tool/path-manipulator.cpp | |
| parent | fix bug -bad power- inserting nodes near cusp nodes in bspline (diff) | |
| download | inkscape-86cf2d0a97e0412629102ae51df0a4797f9179db.tar.gz inkscape-86cf2d0a97e0412629102ae51df0a4797f9179db.zip | |
remove magic numbers from bspline
(bzr r13341.1.219)
Diffstat (limited to 'src/ui/tool/path-manipulator.cpp')
| -rw-r--r-- | src/ui/tool/path-manipulator.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 48b19ef7a..52ff5d42c 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -56,6 +56,10 @@ enum PathChange { }; } // anonymous namespace +const double handleCubicGap = 0.01; +const double noPower = 0.0; +const double defaultStartPower = 0.3334; +const double defaultEndPower = 0.6667; /** * Notifies the path manipulator when something changes the path being edited @@ -1003,7 +1007,7 @@ NodeList::iterator PathManipulator::subdivideSegment(NodeList::iterator first, d lineInsideNodes->moveto(n->position()); lineInsideNodes->lineto(second->position()); SBasisInsideNodes = lineInsideNodes->first_segment()->toSBasis(); - Geom::Point next = SBasisInsideNodes.valueAt(0.3334); + Geom::Point next = SBasisInsideNodes.valueAt(defaultStartPower); next = Geom::Point(next[Geom::X] + handleCubicGap,next[Geom::Y] + handleCubicGap); lineInsideNodes->reset(); n->front()->setPosition(next); @@ -1014,7 +1018,7 @@ NodeList::iterator PathManipulator::subdivideSegment(NodeList::iterator first, d lineInsideNodes->moveto(n->position()); lineInsideNodes->lineto(first->position()); SBasisInsideNodes = lineInsideNodes->first_segment()->toSBasis(); - Geom::Point previous = SBasisInsideNodes.valueAt(0.3334); + Geom::Point previous = SBasisInsideNodes.valueAt(defaultStartPower); previous = Geom::Point(previous[Geom::X] + handleCubicGap,previous[Geom::Y] + handleCubicGap); n->back()->setPosition(previous); }else{ @@ -1246,7 +1250,7 @@ double PathManipulator::BSplineHandlePosition(Handle *h, Handle *h2){ if(h2){ h = h2; } - double pos = 0.0000; + double pos = noPower; const double handleCubicGap = 0.01; Node *n = h->parent(); Node * nextNode = NULL; @@ -1259,7 +1263,7 @@ double PathManipulator::BSplineHandlePosition(Handle *h, Handle *h2){ pos = Geom::nearest_point(Geom::Point(h->position()[X] - handleCubicGap, h->position()[Y] - handleCubicGap), *lineInsideNodes->first_segment()); } } - if (pos == 0.0000 && !h2){ + if (pos == noPower && !h2){ return BSplineHandlePosition(h, h->other()); } return pos; @@ -1282,14 +1286,14 @@ Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){ SPCurve *lineInsideNodes = new SPCurve(); Node * nextNode = NULL; nextNode = n->nodeToward(h); - if(nextNode && pos != 0.0000){ + if(nextNode && pos != noPower){ lineInsideNodes->moveto(n->position()); lineInsideNodes->lineto(nextNode->position()); SBasisInsideNodes = lineInsideNodes->first_segment()->toSBasis(); ret = SBasisInsideNodes.valueAt(pos); ret = Geom::Point(ret[X] + handleCubicGap,ret[Y] + handleCubicGap); }else{ - if(pos == 0.0000){ + if(pos == noPower){ ret = n->position(); } } |
