diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2016-03-14 16:37:50 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2016-03-14 16:37:50 +0000 |
| commit | b8d22beef5345210ad27cdc2685083aeae6f8f3b (patch) | |
| tree | d69b8bfd19d3627a8425a1b265c2abf229b05354 /src/ui/tool/path-manipulator.cpp | |
| parent | fixes for update to trunk (diff) | |
| parent | "Relative to" option for node alignment. (diff) | |
| download | inkscape-b8d22beef5345210ad27cdc2685083aeae6f8f3b.tar.gz inkscape-b8d22beef5345210ad27cdc2685083aeae6f8f3b.zip | |
update to trunk
(bzr r13708.1.39)
Diffstat (limited to 'src/ui/tool/path-manipulator.cpp')
| -rw-r--r-- | src/ui/tool/path-manipulator.cpp | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 848b10373..f4790c317 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -56,9 +56,9 @@ enum PathChange { }; } // anonymous namespace -const double HANDLE_CUBIC_GAP = 0.01; +const double HANDLE_CUBIC_GAP = 0.001; const double NO_POWER = 0.0; -const double defaultStartPower = 0.3334; +const double DEFAULT_START_POWER = 1.0/3.0; /** @@ -695,10 +695,12 @@ unsigned PathManipulator::_deleteStretch(NodeList::iterator start, NodeList::ite // if we are removing, we readjust the handlers if(_isBSpline()){ if(start.prev()){ - start.prev()->front()->setPosition(_bsplineHandleReposition(start.prev()->front(),start.prev()->back())); + double bspline_weight = _bsplineHandlePosition(start.prev()->back(), false); + start.prev()->front()->setPosition(_bsplineHandleReposition(start.prev()->front(), bspline_weight)); } if(end){ - end->back()->setPosition(_bsplineHandleReposition(end->back(),end->front())); + double bspline_weight = _bsplineHandlePosition(end->front(), false); + end->back()->setPosition(_bsplineHandleReposition(end->back(),bspline_weight)); } } @@ -1033,7 +1035,7 @@ NodeList::iterator PathManipulator::subdivideSegment(NodeList::iterator first, d line_inside_nodes->moveto(n->position()); line_inside_nodes->lineto(second->position()); sbasis_inside_nodes = line_inside_nodes->first_segment()->toSBasis(); - Geom::Point next = sbasis_inside_nodes.valueAt(defaultStartPower); + Geom::Point next = sbasis_inside_nodes.valueAt(DEFAULT_START_POWER); next = Geom::Point(next[Geom::X] + HANDLE_CUBIC_GAP,next[Geom::Y] + HANDLE_CUBIC_GAP); line_inside_nodes->reset(); n->front()->setPosition(next); @@ -1044,7 +1046,7 @@ NodeList::iterator PathManipulator::subdivideSegment(NodeList::iterator first, d line_inside_nodes->moveto(n->position()); line_inside_nodes->lineto(first->position()); sbasis_inside_nodes = line_inside_nodes->first_segment()->toSBasis(); - Geom::Point previous = sbasis_inside_nodes.valueAt(defaultStartPower); + Geom::Point previous = sbasis_inside_nodes.valueAt(DEFAULT_START_POWER); previous = Geom::Point(previous[Geom::X] + HANDLE_CUBIC_GAP,previous[Geom::Y] + HANDLE_CUBIC_GAP); n->back()->setPosition(previous); }else{ @@ -1277,13 +1279,10 @@ bool PathManipulator::_isBSpline() const { } // returns the corresponding strength to the position of the handlers -double PathManipulator::_bsplineHandlePosition(Handle *h, Handle *h2) +double PathManipulator::_bsplineHandlePosition(Handle *h, bool check_other) { using Geom::X; using Geom::Y; - if(h2){ - h = h2; - } double pos = NO_POWER; Node *n = h->parent(); Node * next_node = NULL; @@ -1293,19 +1292,19 @@ double PathManipulator::_bsplineHandlePosition(Handle *h, Handle *h2) line_inside_nodes->moveto(n->position()); line_inside_nodes->lineto(next_node->position()); if(!are_near(h->position(), n->position())){ - pos = Geom::nearest_time(Geom::Point(h->position()[X] - HANDLE_CUBIC_GAP, h->position()[Y] - HANDLE_CUBIC_GAP), *line_inside_nodes->first_segment()); + pos = Geom::nearest_time(Geom::Point(h->position()[X] - HANDLE_CUBIC_GAP, h->position()[Y] + HANDLE_CUBIC_GAP), *line_inside_nodes->first_segment()); } } - if (pos == NO_POWER && !h2){ - return _bsplineHandlePosition(h, h->other()); + if (pos == NO_POWER && check_other){ + return _bsplineHandlePosition(h->other(), false); } return pos; } // give the location for the handler in the corresponding position -Geom::Point PathManipulator::_bsplineHandleReposition(Handle *h, Handle *h2) +Geom::Point PathManipulator::_bsplineHandleReposition(Handle *h, bool check_other) { - double pos = this->_bsplineHandlePosition(h, h2); + double pos = this->_bsplineHandlePosition(h, check_other); return _bsplineHandleReposition(h,pos); } |
