From: johanengelen Date: Sun, 8 Jun 2008 18:31:38 +0000 (+0000) Subject: add method to retrieve first and last path of SPCurve, fix error. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=01e77bd6da7435e8d3719497b38790c73544bbaf;p=inkscape.git add method to retrieve first and last path of SPCurve, fix error. --- 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; diff --git a/src/display/curve.h b/src/display/curve.h index 4e94578ed..d46fa13b1 100644 --- a/src/display/curve.h +++ b/src/display/curve.h @@ -78,7 +78,9 @@ public: bool is_empty() const; bool is_closed() const; NArtBpath const * last_bpath() const; + Geom::Path const * last_path() const; NArtBpath const * first_bpath() const; + Geom::Path const * first_path() const; NR::Point first_point() const; NR::Point last_point() const; NR::Point second_point() const;