diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2015-07-04 16:15:46 +0000 |
|---|---|---|
| committer | Krzysztof KosiĆski <tweenk.pl@gmail.com> | 2015-07-04 16:15:46 +0000 |
| commit | 1112ab0a12fc0cb5a6b00d1bbd5b100c55eedff8 (patch) | |
| tree | a91517f9165322b4e42c6cdeb4263beaedc4d02f /src/ui/tool/path-manipulator.cpp | |
| parent | Packaging. New Win32 installer Danish translation. (diff) | |
| parent | Upgrade to 2Geom r2413 (diff) | |
| download | inkscape-1112ab0a12fc0cb5a6b00d1bbd5b100c55eedff8.tar.gz inkscape-1112ab0a12fc0cb5a6b00d1bbd5b100c55eedff8.zip | |
Sync 2Geom to revision 2413.
May introduce regressions.
(bzr r14226)
Diffstat (limited to 'src/ui/tool/path-manipulator.cpp')
| -rw-r--r-- | src/ui/tool/path-manipulator.cpp | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index a772c07c2..848b10373 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1018,7 +1018,7 @@ NodeList::iterator PathManipulator::subdivideSegment(NodeList::iterator first, d Geom::CubicBezier temp(first->position(), first->front()->position(), second->back()->position(), second->position()); std::pair<Geom::CubicBezier, Geom::CubicBezier> div = temp.subdivide(t); - std::vector<Geom::Point> seg1 = div.first.points(), seg2 = div.second.points(); + std::vector<Geom::Point> seg1 = div.first.controlPoints(), seg2 = div.second.controlPoints(); // set new handle positions Node *n = new Node(_multi_path_manipulator._path_data.node_data, seg2[0]); @@ -1163,22 +1163,22 @@ void PathManipulator::_createControlPointsFromGeometry() pathv *= (_edit_transform * _i2d_transform); // in this loop, we know that there are no zero-segment subpaths - for (Geom::PathVector::const_iterator pit = pathv.begin(); pit != pathv.end(); ++pit) { + for (Geom::PathVector::iterator pit = pathv.begin(); pit != pathv.end(); ++pit) { // prepare new subpath SubpathPtr subpath(new NodeList(_subpaths)); _subpaths.push_back(subpath); Node *previous_node = new Node(_multi_path_manipulator._path_data.node_data, pit->initialPoint()); subpath->push_back(previous_node); - Geom::Curve const &cseg = pit->back_closed(); - bool fuse_ends = pit->closed() - && Geom::are_near(cseg.initialPoint(), cseg.finalPoint()); - for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_open(); ++cit) { + + bool closed = pit->closed(); + + for (Geom::Path::iterator cit = pit->begin(); cit != pit->end(); ++cit) { Geom::Point pos = cit->finalPoint(); Node *current_node; // if the closing segment is degenerate and the path is closed, we need to move // the handle of the first node instead of creating a new one - if (fuse_ends && cit == --(pit->end_open())) { + if (closed && cit == --(pit->end())) { current_node = subpath->begin().get_pointer(); } else { /* regardless of segment type, create a new node at the end @@ -1293,7 +1293,7 @@ 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_point(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){ @@ -1447,7 +1447,7 @@ void PathManipulator::_updateOutline() Geom::PathVector arrows; for (Geom::PathVector::iterator i = pv.begin(); i != pv.end(); ++i) { Geom::Path &path = *i; - for (Geom::Path::const_iterator j = path.begin(); j != path.end_default(); ++j) { + for (Geom::Path::iterator j = path.begin(); j != path.end_default(); ++j) { Geom::Point at = j->pointAt(0.5); Geom::Point ut = j->unitTangentAt(0.5); // rotate the point @@ -1667,21 +1667,22 @@ void PathManipulator::_commit(Glib::ustring const &annotation, gchar const *key) * point of the path. */ Geom::Coord PathManipulator::_updateDragPoint(Geom::Point const &evp) { - Geom::Coord dist = 1e23; + Geom::Coord dist = HUGE_VAL; Geom::Affine to_desktop = _edit_transform * _i2d_transform; Geom::PathVector pv = _spcurve->get_pathvector(); - boost::optional<Geom::PathVectorPosition> pvp - = Geom::nearestPoint(pv, _desktop->w2d(evp) * to_desktop.inverse()); + + boost::optional<Geom::PathVectorTime> pvp = + pv.nearestTime(_desktop->w2d(evp) * to_desktop.inverse()); if (!pvp) return dist; - Geom::Point nearest_point = _desktop->d2w(pv.at(pvp->path_nr).pointAt(pvp->t) * to_desktop); - - double fracpart; + Geom::Point nearest_pt = _desktop->d2w(pv.pointAt(*pvp) * to_desktop); + + double fracpart = pvp->t; std::list<SubpathPtr>::iterator spi = _subpaths.begin(); - for (unsigned i = 0; i < pvp->path_nr; ++i, ++spi) {} - NodeList::iterator first = (*spi)->before(pvp->t, &fracpart); + for (unsigned i = 0; i < pvp->path_index; ++i, ++spi) {} + NodeList::iterator first = (*spi)->before(pvp->asPathTime()); - dist = Geom::distance(evp, nearest_point); + dist = Geom::distance(evp, nearest_pt); double stroke_tolerance = _getStrokeTolerance(); if (first && first.next() && @@ -1689,7 +1690,7 @@ Geom::Coord PathManipulator::_updateDragPoint(Geom::Point const &evp) dist < stroke_tolerance) { _dragpoint->setVisible(true); - _dragpoint->setPosition(_desktop->w2d(nearest_point)); + _dragpoint->setPosition(_desktop->w2d(nearest_pt)); _dragpoint->setSize(2 * stroke_tolerance); _dragpoint->setTimeValue(fracpart); _dragpoint->setIterator(first); |
