summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2009-04-07 22:58:28 +0000
committerjohanengelen <johanengelen@users.sourceforge.net>2009-04-07 22:58:28 +0000
commitad0a7318b9f7fb9679677ba0c0a4f6b7edb55e25 (patch)
treeec2699e72297444640bfe2f406022ee9a91a5c1d /src
parentFix bug #356743 (diff)
downloadinkscape-ad0a7318b9f7fb9679677ba0c0a4f6b7edb55e25.tar.gz
inkscape-ad0a7318b9f7fb9679677ba0c0a4f6b7edb55e25.zip
is_straight_curve now also returns true for straight line quadratic and cubic curves. this fixes spiro LPE behavior
(bzr r7663)
Diffstat (limited to 'src')
-rw-r--r--src/helper/geom-curves.h22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/helper/geom-curves.h b/src/helper/geom-curves.h
index f3dc364f2..bc5a8213a 100644
--- a/src/helper/geom-curves.h
+++ b/src/helper/geom-curves.h
@@ -7,12 +7,14 @@
* Author:
* Johan Engelen <goejendaagh@zonnet.nl>
*
- * Copyright (C) 2008 Johan Engelen
+ * Copyright (C) 2008-2009 Johan Engelen
*
* Released under GNU GPL
*/
#include <2geom/hvlinesegment.h>
+#include <2geom/line.h>
+#include <2geom/bezier-curve.h>
inline bool is_straight_curve(Geom::Curve const & c) {
if( dynamic_cast<Geom::LineSegment const*>(&c) ||
@@ -20,9 +22,23 @@ inline bool is_straight_curve(Geom::Curve const & c) {
dynamic_cast<Geom::VLineSegment const*>(&c) )
{
return true;
- } else {
- return false;
}
+ // 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;
+ }
+ }
+
+ return false;
}
#endif // INKSCAPE_HELPER_GEOM_CURVES_H