From 33fdcb19f2eda0c91a2c4371a3e1973b3d0c556f Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 8 Jun 2008 18:31:38 +0000 Subject: add method to retrieve first and last path of SPCurve, fix error. (bzr r5858) --- src/display/curve.cpp | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'src/display/curve.cpp') diff --git a/src/display/curve.cpp b/src/display/curve.cpp index 4144bb623..df1666d2e 100644 --- a/src/display/curve.cpp +++ b/src/display/curve.cpp @@ -1,7 +1,7 @@ #define __CURVE_C__ /** \file - * Routines for SPCurve and for NArtBpath arrays in general. + * Routines for SPCurve and for NArtBpath arrays / Geom::PathVector in general. */ /* @@ -894,6 +894,21 @@ SPCurve::last_bpath() const return _bpath + _end - 1; } +/** + * Return last path in PathVector or NULL. + */ +Geom::Path const * +SPCurve::last_path() const +{ + g_return_val_if_fail(this != NULL, NULL); + + if (is_empty()) { + return NULL; + } + + return &_pathv.back(); +} + /** * Return first subpath or NULL. */ @@ -909,6 +924,21 @@ SPCurve::first_bpath() const return _bpath; } +/** + * Return first path in PathVector or NULL. + */ +Geom::Path const * +SPCurve::first_path() const +{ + g_return_val_if_fail(this != NULL, NULL); + + if (is_empty()) { + return NULL; + } + + return &_pathv.front(); +} + /** * Return first point of first subpath or (0,0). TODO: shouldn't this be (NR_HUGE, NR_HUGE) to be able to tell it apart from normal (0,0) ? */ @@ -1080,9 +1110,9 @@ SPCurve::append(SPCurve const *curve2, case NR_MOVETO_OPEN: if (use_lineto && _hascpt) { lineto(bp->x3, bp->y3); - use_lineto = FALSE; + use_lineto = false; } else { - if (closed) closepath(); + if (closed && _hascpt) closepath(); moveto(bp->x3, bp->y3); } closed = false; @@ -1093,7 +1123,7 @@ SPCurve::append(SPCurve const *curve2, lineto(bp->x3, bp->y3); use_lineto = FALSE; } else { - if (closed) closepath(); + if (closed && _hascpt) closepath(); moveto(bp->x3, bp->y3); } closed = true; -- cgit v1.2.3