diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2011-02-05 02:04:47 +0000 |
|---|---|---|
| committer | Krzysztof KosiĆski <tweenk.pl@gmail.com> | 2011-02-05 02:04:47 +0000 |
| commit | fb749ad5edae38b062e00d1593ec0d306bac4ada (patch) | |
| tree | 00b1bf94cf1ebf0f81980909d5d9f5e427aed560 /src | |
| parent | Properly fix seltrans brokenness in 2Geom and pull updated files (diff) | |
| download | inkscape-fb749ad5edae38b062e00d1593ec0d306bac4ada.tar.gz inkscape-fb749ad5edae38b062e00d1593ec0d306bac4ada.zip | |
Fix node tool brokenness resulting from a switch to runtime order
in 2Geom's BezierCurve
(bzr r10035)
Diffstat (limited to 'src')
| -rw-r--r-- | src/helper/geom-curves.h | 18 | ||||
| -rw-r--r-- | src/helper/geom.cpp | 22 | ||||
| -rw-r--r-- | src/ui/tool/path-manipulator.cpp | 13 |
3 files changed, 28 insertions, 25 deletions
diff --git a/src/helper/geom-curves.h b/src/helper/geom-curves.h index f927634d8..5b921e572 100644 --- a/src/helper/geom-curves.h +++ b/src/helper/geom-curves.h @@ -26,17 +26,15 @@ inline bool is_straight_curve(Geom::Curve const & c) { } // the curve can be a quad/cubic bezier, but could still be a perfect straight line // if the control points are exactly on the line connecting the initial and final points. - else if ( Geom::QuadraticBezier const *quad = dynamic_cast<Geom::QuadraticBezier const*>(&c) ) { - Geom::Line line( quad->initialPoint(), quad->finalPoint() ); - if ( are_near((*quad)[1], line) ) { - return true; - } - } - else if ( Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const*>(&c) ) { - Geom::Line line( cubic->initialPoint(), cubic->finalPoint() ); - if ( are_near((*cubic)[1], line) && are_near((*cubic)[2], line) ) { - return true; + Geom::BezierCurve const *curve = dynamic_cast<Geom::BezierCurve const *>(&c); + if (curve) { + Geom::Line line(curve->initialPoint(), curve->finalPoint()); + std::vector<Geom::Point> pts = curve->points(); + for (unsigned i = 1; i < pts.size() - 1; ++i) { + if (!are_near(pts[i], line)) + return false; } + return true; } return false; diff --git a/src/helper/geom.cpp b/src/helper/geom.cpp index 4bf56f6c1..2420b43b4 100644 --- a/src/helper/geom.cpp +++ b/src/helper/geom.cpp @@ -476,15 +476,19 @@ pathv_to_linear_and_cubic_beziers( Geom::PathVector const &pathv ) output.back().close( pit->closed() ); for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_open(); ++cit) { - if( dynamic_cast<Geom::CubicBezier const*>(&*cit) || - is_straight_curve(*cit) ) - { - output.back().append(*cit); - } - else { - // convert all other curve types to cubicbeziers - Geom::Path cubicbezier_path = Geom::cubicbezierpath_from_sbasis(cit->toSBasis(), 0.1); - output.back().append(cubicbezier_path); + if (is_straight_curve(*cit)) { + Geom::LineSegment l(cit->initialPoint(), cit->finalPoint()); + output.back().append(l); + } else { + Geom::BezierCurve const *curve = dynamic_cast<Geom::BezierCurve const *>(&*cit); + if (curve && curve->order() == 3) { + Geom::CubicBezier b((*curve)[0], (*curve)[1], (*curve)[2], (*curve)[3]); + output.back().append(b); + } else { + // convert all other curve types to cubicbeziers + Geom::Path cubicbezier_path = Geom::cubicbezierpath_from_sbasis(cit->toSBasis(), 0.1); + output.back().append(cubicbezier_path); + } } } } diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 47e28a788..0e5705ee4 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1039,13 +1039,14 @@ void PathManipulator::_createControlPointsFromGeometry() subpath->push_back(current_node); } // if this is a bezier segment, move handles appropriately - if (Geom::CubicBezier const *cubic_bezier = - dynamic_cast<Geom::CubicBezier const*>(&*cit)) + // TODO: I don't know why the dynamic cast below doesn't want to work + // when I replace BezierCurve with CubicBezier. Might be a bug + // somewhere in pathv_to_linear_and_cubic_beziers + Geom::BezierCurve const *bezier = dynamic_cast<Geom::BezierCurve const*>(&*cit); + if (bezier && bezier->order() == 3) { - std::vector<Geom::Point> points = cubic_bezier->points(); - - previous_node->front()->setPosition(points[1]); - current_node ->back() ->setPosition(points[2]); + previous_node->front()->setPosition((*bezier)[1]); + current_node ->back() ->setPosition((*bezier)[2]); } previous_node = current_node; } |
