From fdc44da6a01ea7605271feed15df61005ddd0219 Mon Sep 17 00:00:00 2001 From: mental Date: Tue, 9 May 2006 03:52:58 +0000 Subject: [PATCH] eliminate direct accesses to SPCurve::bpath --- ChangeLog | 12 +++ src/display/canvas-bpath.cpp | 2 +- src/display/curve.cpp | 128 ++++++++++++++--------------- src/display/curve.h | 6 +- src/display/nr-arena-shape.cpp | 12 +-- src/draw-context.cpp | 2 +- src/extension/internal/odf.cpp | 2 +- src/extension/internal/pov-out.cpp | 6 +- src/nodepath.cpp | 4 +- src/object-snapper.cpp | 4 +- src/path-chemistry.cpp | 10 +-- src/sp-flowregion.cpp | 2 +- src/sp-offset.cpp | 8 +- src/sp-path.cpp | 4 +- src/sp-shape.cpp | 20 ++--- src/sp-spiral.cpp | 2 +- src/sp-star.cpp | 2 +- src/sp-use-reference.cpp | 2 +- src/splivarot.cpp | 8 +- 19 files changed, 124 insertions(+), 112 deletions(-) diff --git a/ChangeLog b/ChangeLog index d267a6fa4..fc04c8467 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2006-05-08 MenTaLguY + + * src/display/canvas-bpath.cpp, src/display/curve.cpp, src/display/curve.h, + src/display/nr-arena-shape.cpp, src/draw-context.cpp, + src/extension/internal/odf.cpp, src/extension/internal/pov-out.cpp, + src/nodepath.cpp, src/object-snapper.cpp, src/path-chemistry.cpp, + src/sp-flowregion.cpp, src/splivarot.cpp, src/sp-offset.cpp, + src/sp-path.cpp, src/sp-shape.cpp, src/sp-spiral.cpp, src/sp-star.cpp, + src/sp-use-reference.cpp: + + eliminate direct accesses to SPCurve::bpath + 2006-05-08 MenTaLguY * src/streams-zlib.cpp, src/streams-jar.cpp, src/splivarot.cpp, diff --git a/src/display/canvas-bpath.cpp b/src/display/canvas-bpath.cpp index d85f77785..a9285f952 100644 --- a/src/display/canvas-bpath.cpp +++ b/src/display/canvas-bpath.cpp @@ -140,7 +140,7 @@ sp_canvas_bpath_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned i if ((cbp->fill_rgba & 0xff) || (cbp->stroke_rgba & 0xff)) { Path* thePath=new Path; - thePath->LoadArtBPath(cbp->curve->bpath, affine, true); + thePath->LoadArtBPath(SP_CANVAS_BPATH(cbp->curve), affine, true); thePath->Convert(0.25); if ((cbp->fill_rgba & 0xff) && (cbp->curve->end > 2)) { Shape* theShape=new Shape; diff --git a/src/display/curve.cpp b/src/display/curve.cpp index a8a6e354e..3ea4e60df 100644 --- a/src/display/curve.cpp +++ b/src/display/curve.cpp @@ -56,8 +56,8 @@ sp_curve_new_sized(gint length) SPCurve *curve = g_new(SPCurve, 1); curve->refcount = 1; - curve->bpath = nr_new(NArtBpath, length); - curve->bpath->code = NR_END; + curve->_bpath = nr_new(NArtBpath, length); + curve->_bpath->code = NR_END; curve->end = 0; curve->length = length; curve->substart = 0; @@ -92,13 +92,13 @@ sp_curve_new_from_bpath(NArtBpath *bpath) SPCurve *curve = g_new(SPCurve, 1); curve->refcount = 1; - curve->bpath = bpath; + curve->_bpath = bpath; curve->length = sp_bpath_length(bpath); curve->end = curve->length - 1; gint i = curve->end; for (; i > 0; i--) - if ((curve->bpath[i].code == NR_MOVETO) || - (curve->bpath[i].code == NR_MOVETO_OPEN)) + if ((curve->_bpath[i].code == NR_MOVETO) || + (curve->_bpath[i].code == NR_MOVETO_OPEN)) break; curve->substart = i; curve->sbpath = false; @@ -134,13 +134,13 @@ sp_curve_new_from_static_bpath(NArtBpath const *bpath) SPCurve *curve = g_new(SPCurve, 1); curve->refcount = 1; - curve->bpath = const_cast(bpath); + curve->_bpath = const_cast(bpath); curve->length = sp_bpath_length(bpath); curve->end = curve->length - 1; gint i = curve->end; for (; i > 0; i--) - if ((curve->bpath[i].code == NR_MOVETO) || - (curve->bpath[i].code == NR_MOVETO_OPEN)) + if ((curve->_bpath[i].code == NR_MOVETO) || + (curve->_bpath[i].code == NR_MOVETO_OPEN)) break; curve->substart = i; curve->sbpath = sbpath; @@ -207,8 +207,8 @@ sp_curve_unref(SPCurve *curve) curve->refcount -= 1; if (curve->refcount < 1) { - if ((!curve->sbpath) && (curve->bpath)) { - nr_free(curve->bpath); + if ((!curve->sbpath) && (curve->_bpath)) { + nr_free(curve->_bpath); } g_free(curve); } @@ -231,7 +231,7 @@ sp_curve_ensure_space(SPCurve *curve, gint space) if (space < SP_CURVE_LENSTEP) space = SP_CURVE_LENSTEP; - curve->bpath = nr_renew(curve->bpath, NArtBpath, curve->length + space); + curve->_bpath = nr_renew(curve->_bpath, NArtBpath, curve->length + space); curve->length += space; } @@ -244,7 +244,7 @@ sp_curve_copy(SPCurve *curve) { g_return_val_if_fail(curve != NULL, NULL); - return sp_curve_new_from_foreign_bpath(curve->bpath); + return sp_curve_new_from_foreign_bpath(curve->_bpath); } /** @@ -264,11 +264,11 @@ sp_curve_concat(GSList const *list) SPCurve *new_curve = sp_curve_new_sized(length + 1); - NArtBpath *bp = new_curve->bpath; + NArtBpath *bp = new_curve->_bpath; for (GSList const *l = list; l != NULL; l = l->next) { SPCurve *c = (SPCurve *) l->data; - memcpy(bp, c->bpath, c->end * sizeof(NArtBpath)); + memcpy(bp, c->_bpath, c->end * sizeof(NArtBpath)); bp += c->end; } @@ -277,8 +277,8 @@ sp_curve_concat(GSList const *list) new_curve->end = length; gint i; for (i = new_curve->end; i > 0; i--) { - if ((new_curve->bpath[i].code == NR_MOVETO) || - (new_curve->bpath[i].code == NR_MOVETO_OPEN) ) + if ((new_curve->_bpath[i].code == NR_MOVETO) || + (new_curve->_bpath[i].code == NR_MOVETO_OPEN) ) break; } @@ -300,16 +300,16 @@ sp_curve_split(SPCurve const *curve) while (p < curve->end) { gint i = 1; - while ((curve->bpath[p + i].code == NR_LINETO) || - (curve->bpath[p + i].code == NR_CURVETO)) + while ((curve->_bpath[p + i].code == NR_LINETO) || + (curve->_bpath[p + i].code == NR_CURVETO)) i++; SPCurve *new_curve = sp_curve_new_sized(i + 1); - memcpy(new_curve->bpath, curve->bpath + p, i * sizeof(NArtBpath)); + memcpy(new_curve->_bpath, curve->_bpath + p, i * sizeof(NArtBpath)); new_curve->end = i; - new_curve->bpath[i].code = NR_END; + new_curve->_bpath[i].code = NR_END; new_curve->substart = 0; - new_curve->closed = (new_curve->bpath->code == NR_MOVETO); - new_curve->hascpt = (new_curve->bpath->code == NR_MOVETO_OPEN); + new_curve->closed = (new_curve->_bpath->code == NR_MOVETO); + new_curve->hascpt = (new_curve->_bpath->code == NR_MOVETO_OPEN); l = g_slist_append(l, new_curve); /** \todo * effic: Use g_slist_prepend instead. Either work backwards from @@ -333,7 +333,7 @@ tmpl_curve_transform(SPCurve *const curve, M const &m) g_return_if_fail(!curve->sbpath); for (gint i = 0; i < curve->end; i++) { - NArtBpath *p = curve->bpath + i; + NArtBpath *p = curve->_bpath + i; switch (p->code) { case NR_MOVETO: case NR_MOVETO_OPEN: @@ -383,7 +383,7 @@ sp_curve_reset(SPCurve *curve) g_return_if_fail(curve != NULL); g_return_if_fail(!curve->sbpath); - curve->bpath->code = NR_END; + curve->_bpath->code = NR_END; curve->end = 0; curve->substart = 0; curve->hascpt = false; @@ -442,7 +442,7 @@ sp_curve_lineto(SPCurve *curve, gdouble x, gdouble y) /* fix endpoint */ g_return_if_fail(!curve->posSet); g_return_if_fail(curve->end > 1); - NArtBpath *bp = curve->bpath + curve->end - 1; + NArtBpath *bp = curve->_bpath + curve->end - 1; g_return_if_fail(bp->code == NR_LINETO); bp->x3 = x; bp->y3 = y; @@ -453,7 +453,7 @@ sp_curve_lineto(SPCurve *curve, gdouble x, gdouble y) if (curve->posSet) { /* start a new segment */ sp_curve_ensure_space(curve, 2); - NArtBpath *bp = curve->bpath + curve->end; + NArtBpath *bp = curve->_bpath + curve->end; bp->code = NR_MOVETO_OPEN; bp->setC(3, curve->movePos); bp++; @@ -472,7 +472,7 @@ sp_curve_lineto(SPCurve *curve, gdouble x, gdouble y) g_return_if_fail(curve->end > 1); sp_curve_ensure_space(curve, 1); - NArtBpath *bp = curve->bpath + curve->end; + NArtBpath *bp = curve->_bpath + curve->end; bp->code = NR_LINETO; bp->x3 = x; bp->y3 = y; @@ -493,7 +493,7 @@ sp_curve_lineto_moving(SPCurve *curve, gdouble x, gdouble y) /* change endpoint */ g_return_if_fail(!curve->posSet); g_return_if_fail(curve->end > 1); - NArtBpath *bp = curve->bpath + curve->end - 1; + NArtBpath *bp = curve->_bpath + curve->end - 1; g_return_if_fail(bp->code == NR_LINETO); bp->x3 = x; bp->y3 = y; @@ -503,7 +503,7 @@ sp_curve_lineto_moving(SPCurve *curve, gdouble x, gdouble y) if (curve->posSet) { /* start a new segment */ sp_curve_ensure_space(curve, 2); - NArtBpath *bp = curve->bpath + curve->end; + NArtBpath *bp = curve->_bpath + curve->end; bp->code = NR_MOVETO_OPEN; bp->setC(3, curve->movePos); bp++; @@ -523,7 +523,7 @@ sp_curve_lineto_moving(SPCurve *curve, gdouble x, gdouble y) g_return_if_fail(curve->end > 1); sp_curve_ensure_space(curve, 1); - NArtBpath *bp = curve->bpath + curve->end; + NArtBpath *bp = curve->_bpath + curve->end; bp->code = NR_LINETO; bp->x3 = x; bp->y3 = y; @@ -561,7 +561,7 @@ sp_curve_curveto(SPCurve *curve, gdouble x0, gdouble y0, gdouble x1, gdouble y1, if (curve->posSet) { /* start a new segment */ sp_curve_ensure_space(curve, 2); - NArtBpath *bp = curve->bpath + curve->end; + NArtBpath *bp = curve->_bpath + curve->end; bp->code = NR_MOVETO_OPEN; bp->setC(3, curve->movePos); bp++; @@ -584,7 +584,7 @@ sp_curve_curveto(SPCurve *curve, gdouble x0, gdouble y0, gdouble x1, gdouble y1, g_return_if_fail(curve->end > 1); sp_curve_ensure_space(curve, 1); - NArtBpath *bp = curve->bpath + curve->end; + NArtBpath *bp = curve->_bpath + curve->end; bp->code = NR_CURVETO; bp->x1 = x0; bp->y1 = y0; @@ -613,19 +613,19 @@ sp_curve_closepath(SPCurve *curve) g_return_if_fail(curve->end - curve->substart > 1); { - NArtBpath *bs = curve->bpath + curve->substart; - NArtBpath *be = curve->bpath + curve->end - 1; + NArtBpath *bs = curve->_bpath + curve->substart; + NArtBpath *be = curve->_bpath + curve->end - 1; if (bs->c(3) != be->c(3)) { sp_curve_lineto(curve, bs->c(3)); - bs = curve->bpath + curve->substart; + bs = curve->_bpath + curve->substart; } bs->code = NR_MOVETO; } curve->closed = true; - for (NArtBpath const *bp = curve->bpath; bp->code != NR_END; bp++) { + for (NArtBpath const *bp = curve->_bpath; bp->code != NR_END; bp++) { /** \todo * effic: Maintain a count of NR_MOVETO_OPEN's (e.g. instead of * the closed boolean). @@ -656,8 +656,8 @@ sp_curve_closepath_current(SPCurve *curve) g_return_if_fail(curve->end - curve->substart > 1); { - NArtBpath *bs = curve->bpath + curve->substart; - NArtBpath *be = curve->bpath + curve->end - 1; + NArtBpath *bs = curve->_bpath + curve->substart; + NArtBpath *be = curve->_bpath + curve->end - 1; be->x3 = bs->x3; be->y3 = bs->y3; @@ -666,7 +666,7 @@ sp_curve_closepath_current(SPCurve *curve) } curve->closed = true; - for (NArtBpath const *bp = curve->bpath; bp->code != NR_END; bp++) { + for (NArtBpath const *bp = curve->_bpath; bp->code != NR_END; bp++) { /** \todo * effic: Maintain a count of NR_MOVETO_OPEN's (e.g. instead of * the closed boolean). @@ -689,7 +689,7 @@ sp_curve_empty(SPCurve *curve) { g_return_val_if_fail(curve != NULL, TRUE); - return (curve->bpath->code == NR_END); + return (curve->_bpath->code == NR_END); } /** @@ -704,7 +704,7 @@ sp_curve_last_bpath(SPCurve const *curve) return NULL; } - return curve->bpath + curve->end - 1; + return curve->_bpath + curve->end - 1; } /** @@ -719,7 +719,7 @@ sp_curve_first_bpath(SPCurve const *curve) return NULL; } - return curve->bpath; + return curve->_bpath; } /** @@ -747,9 +747,9 @@ sp_curve_second_point(SPCurve const *const curve) NArtBpath *bpath = NULL; if (curve->end < 2) { - bpath = curve->bpath; + bpath = curve->_bpath; } else { - bpath = curve->bpath + 1; + bpath = curve->_bpath + 1; } g_return_val_if_fail(bpath != NULL, NR::Point(0, 0)); return bpath->c(3); @@ -767,7 +767,7 @@ sp_curve_penultimate_point(SPCurve const *const curve) return curve->movePos; } - NArtBpath *const bpath = curve->bpath + curve->end - 2; + NArtBpath *const bpath = curve->_bpath + curve->end - 2; g_return_val_if_fail(bpath != NULL, NR::Point(0, 0)); return bpath->c(3); } @@ -800,10 +800,10 @@ sp_curve_reverse(SPCurve const *curve) /* We need at least moveto, curveto, end. */ g_return_val_if_fail(curve->end - curve->substart > 1, NULL); - NArtBpath const *be = curve->bpath + curve->end - 1; + NArtBpath const *be = curve->_bpath + curve->end - 1; - g_assert(is_moveto(curve->bpath[curve->substart].code)); - g_assert(is_moveto(curve->bpath[0].code)); + g_assert(is_moveto(curve->_bpath[curve->substart].code)); + g_assert(is_moveto(curve->_bpath[0].code)); g_assert((be+1)->code == NR_END); SPCurve *new_curve = sp_curve_new_sized(curve->length); @@ -812,11 +812,11 @@ sp_curve_reverse(SPCurve const *curve) for (NArtBpath const *bp = be; ; --bp) { switch (bp->code) { case NR_MOVETO: - g_assert(new_curve->bpath[new_curve->substart].code == NR_MOVETO_OPEN); - new_curve->bpath[new_curve->substart].code = NR_MOVETO; + g_assert(new_curve->_bpath[new_curve->substart].code == NR_MOVETO_OPEN); + new_curve->_bpath[new_curve->substart].code = NR_MOVETO; /* FALL-THROUGH */ case NR_MOVETO_OPEN: - if (bp == curve->bpath) { + if (bp == curve->_bpath) { return new_curve; } sp_curve_moveto(new_curve, (bp-1)->c(3)); @@ -850,7 +850,7 @@ sp_curve_append(SPCurve *curve, if (curve2->end < 1) return; - NArtBpath const *bs = curve2->bpath; + NArtBpath const *bs = curve2->_bpath; bool closed = curve->closed; @@ -966,7 +966,7 @@ sp_curve_backspace(SPCurve *curve) if (curve->end > 0) { curve->end -= 1; if (curve->end > 0) { - NArtBpath *bp = curve->bpath + curve->end - 1; + NArtBpath *bp = curve->_bpath + curve->end - 1; if ((bp->code == NR_MOVETO) || (bp->code == NR_MOVETO_OPEN) ) { @@ -977,7 +977,7 @@ sp_curve_backspace(SPCurve *curve) curve->end -= 1; } } - curve->bpath[curve->end].code = NR_END; + curve->_bpath[curve->end].code = NR_END; } } @@ -1170,13 +1170,13 @@ sp_curve_distance_including_space(SPCurve const *const curve, double seg2len[]) double ret = 0.0; - if ( curve->bpath->code == NR_END ) { + if ( curve->_bpath->code == NR_END ) { return ret; } - NR::Point prev(curve->bpath->c(3)); + NR::Point prev(curve->_bpath->c(3)); for (gint i = 1; i < curve->end; ++i) { - NArtBpath &p = curve->bpath[i]; + NArtBpath &p = curve->_bpath[i]; double seg_len = 0; switch (p.code) { case NR_MOVETO_OPEN: @@ -1225,18 +1225,18 @@ sp_curve_stretch_endpoints(SPCurve *curve, NR::Point const &new_p0, NR::Point co if (sp_curve_empty(curve)) { return; } - g_assert(unsigned(SP_CURVE_LENGTH(curve)) + 1 == sp_bpath_length(curve->bpath)); + g_assert(unsigned(SP_CURVE_LENGTH(curve)) + 1 == sp_bpath_length(curve->_bpath)); unsigned const nSegs = SP_CURVE_LENGTH(curve) - 1; g_assert(nSegs != 0); double *const seg2len = new double[nSegs]; double const tot_len = sp_curve_nonzero_distance_including_space(curve, seg2len); NR::Point const offset0( new_p0 - sp_curve_first_point(curve) ); NR::Point const offset1( new_p1 - sp_curve_last_point(curve) ); - curve->bpath->setC(3, new_p0); + curve->_bpath->setC(3, new_p0); double begin_dist = 0.; for (unsigned si = 0; si < nSegs; ++si) { double const end_dist = begin_dist + seg2len[si]; - NArtBpath &p = curve->bpath[1 + si]; + NArtBpath &p = curve->_bpath[1 + si]; switch (p.code) { case NR_LINETO: case NR_MOVETO: @@ -1256,9 +1256,9 @@ sp_curve_stretch_endpoints(SPCurve *curve, NR::Point const &new_p0, NR::Point co begin_dist = end_dist; } - g_assert(L1(curve->bpath[nSegs].c(3) - new_p1) < 1.); + g_assert(L1(curve->_bpath[nSegs].c(3) - new_p1) < 1.); /* Explicit set for better numerical properties. */ - curve->bpath[nSegs].setC(3, new_p1); + curve->_bpath[nSegs].setC(3, new_p1); delete [] seg2len; } @@ -1272,8 +1272,8 @@ sp_curve_move_endpoints(SPCurve *curve, NR::Point const &new_p0, unsigned const nSegs = SP_CURVE_LENGTH(curve) - 1; g_assert(nSegs != 0); - curve->bpath->setC(3, new_p0); - curve->bpath[nSegs].setC(3, new_p1); + curve->_bpath->setC(3, new_p0); + curve->_bpath[nSegs].setC(3, new_p1); } diff --git a/src/display/curve.h b/src/display/curve.h index d63796140..07d951b63 100644 --- a/src/display/curve.h +++ b/src/display/curve.h @@ -23,7 +23,7 @@ /// Wrapper around NArtBpath. struct SPCurve { gint refcount; - NArtBpath *bpath; + NArtBpath *_bpath; /// Index in bpath[] of NR_END element. gint end; @@ -66,8 +66,8 @@ struct SPCurve { }; #define SP_CURVE_LENGTH(c) (((SPCurve const *)(c))->end) -#define SP_CURVE_BPATH(c) (((SPCurve const *)(c))->bpath) -#define SP_CURVE_SEGMENT(c,i) (((SPCurve const *)(c))->bpath + (i)) +#define SP_CURVE_BPATH(c) (((SPCurve const *)(c))->_bpath) +#define SP_CURVE_SEGMENT(c,i) (((SPCurve const *)(c))->_bpath + (i)) /* Constructors */ diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index e1e0ea540..8d5a48be8 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -214,7 +214,7 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g /* fixme: */ bbox.x0 = bbox.y0 = NR_HUGE; bbox.x1 = bbox.y1 = -NR_HUGE; - bp.path = shape->curve->bpath; + bp.path = SP_CURVE_BPATH(shape->curve); nr_path_matrix_bbox_union(&bp, gc->transform, &bbox); item->bbox.x0 = (gint32)(bbox.x0 - 1.0F); item->bbox.y0 = (gint32)(bbox.y0 - 1.0F); @@ -240,7 +240,7 @@ nr_arena_shape_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state, g /* fixme: */ bbox.x0 = bbox.y0 = NR_HUGE; bbox.x1 = bbox.y1 = -NR_HUGE; - bp.path = shape->curve->bpath; + bp.path = SP_CURVE_BPATH(shape->curve); nr_path_matrix_bbox_union(&bp, gc->transform, &bbox); if (shape->_stroke.paint.type() != NRArenaShape::Paint::NONE) { float width, scale; @@ -388,7 +388,7 @@ void nr_arena_shape_update_fill(NRArenaShape *shape, NRGC *gc, NRRectL *area, bool force_shape) { if ((shape->_fill.paint.type() != NRArenaShape::Paint::NONE || force_shape) && - ((shape->curve->end > 2) || (shape->curve->bpath[1].code == NR_CURVETO)) ) { + ((shape->curve->end > 2) || (SP_CURVE_BPATH(shape->curve)[1].code == NR_CURVETO)) ) { if (TRUE || !shape->fill_shp) { NR::Matrix cached_to_new; int isometry = 0; @@ -410,7 +410,7 @@ nr_arena_shape_update_fill(NRArenaShape *shape, NRGC *gc, NRRectL *area, bool fo Shape* theShape=new Shape; { NR::Matrix tempMat(gc->transform); - thePath->LoadArtBPath(shape->curve->bpath,tempMat,true); + thePath->LoadArtBPath(SP_CURVE_BPATH(shape->curve),tempMat,true); } if (is_inner_area(*area, NR_ARENA_ITEM(shape)->bbox)) { @@ -507,7 +507,7 @@ nr_arena_shape_update_stroke(NRArenaShape *shape,NRGC* gc, NRRectL *area) Shape* theShape = new Shape; { NR::Matrix tempMat(gc->transform); - thePath->LoadArtBPath(shape->curve->bpath, tempMat, true); + thePath->LoadArtBPath(SP_CURVE_BPATH(shape->curve), tempMat, true); } // add some padding to the rendering area, so clipped path does not go into a render area @@ -888,7 +888,7 @@ nr_arena_shape_pick(NRArenaItem *item, NR::Point p, double delta, unsigned int / } } else { NRBPath bp; - bp.path = shape->curve->bpath; + bp.path = SP_CURVE_BPATH(shape->curve); double dist = NR_HUGE; int wind = 0; nr_path_matrix_point_bbox_wind_distance(&bp, shape->ctm, p, NULL, &wind, &dist, NR_EPSILON); diff --git a/src/draw-context.cpp b/src/draw-context.cpp index 75ded20f5..6263880a4 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -308,7 +308,7 @@ spdc_attach_selection(SPDrawContext *dc, Inkscape::Selection *sel) SPCurve *c; c = (SPCurve*)l->data; g_return_if_fail( c->end > 1 ); - if ( c->bpath->code == NR_MOVETO_OPEN ) { + if ( SP_CURVE_BPATH(c)->code == NR_MOVETO_OPEN ) { NArtBpath *s, *e; SPDrawAnchor *a; s = sp_curve_first_bpath(c); diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp index 11cf842d3..16ff0f18f 100644 --- a/src/extension/internal/odf.cpp +++ b/src/extension/internal/odf.cpp @@ -1674,7 +1674,7 @@ bool OdfOutput::writeTree(Writer &outs, Inkscape::XML::Node *node) bbox_width * 1000.0, bbox_height * 1000.0); outs.printf(" svg:d=\""); - writePath(outs, curve->bpath, tf, bbox_x, bbox_y); + writePath(outs, SP_CURVE_BPATH(curve), tf, bbox_x, bbox_y); outs.printf("\""); outs.printf(">\n"); diff --git a/src/extension/internal/pov-out.cpp b/src/extension/internal/pov-out.cpp index fbe64bd81..8450b1040 100644 --- a/src/extension/internal/pov-out.cpp +++ b/src/extension/internal/pov-out.cpp @@ -217,12 +217,12 @@ PovOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const * //Count the NR_CURVETOs/LINETOs int segmentCount=0; - NArtBpath *bp = curve->bpath; + NArtBpath *bp = SP_CURVE_BPATH(curve); for (curveNr=0 ; curveNrlength ; curveNr++, bp++) if (bp->code == NR_CURVETO || bp->code == NR_LINETO) segmentCount++; - bp = curve->bpath; + bp = SP_CURVE_BPATH(curve); double cminx = bignum; double cmaxx = -bignum; double cminy = bignum; @@ -240,7 +240,7 @@ PovOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const * fprintf(f, " 0.0, //bottom\n"); fprintf(f, " %d, //nr points\n", segmentCount * 4); int segmentNr = 0; - for (bp = curve->bpath, curveNr=0 ; curveNrlength ; curveNr++, bp++) { + for (bp = SP_CURVE_BPATH(curve), curveNr=0 ; curveNrlength ; curveNr++, bp++) { using NR::X; using NR::Y; NR::Point const p1(bp->c(1) * tf); diff --git a/src/nodepath.cpp b/src/nodepath.cpp index e81abdacb..18da75111 100644 --- a/src/nodepath.cpp +++ b/src/nodepath.cpp @@ -411,7 +411,7 @@ static void update_repr_internal(Inkscape::NodePath::Path *np) SPCurve *curve = create_curve(np); gchar *typestr = create_typestr(np); - gchar *svgpath = sp_svg_write_path(curve->bpath); + gchar *svgpath = sp_svg_write_path(SP_CURVE_BPATH(curve)); if (repr->attribute("d") == NULL || strcmp(svgpath, repr->attribute("d"))) { // d changed np->local_change++; @@ -486,7 +486,7 @@ static void stamp_repr(Inkscape::NodePath::Path *np) SPCurve *curve = create_curve(np); gchar *typestr = create_typestr(np); - gchar *svgpath = sp_svg_write_path(curve->bpath); + gchar *svgpath = sp_svg_write_path(SP_CURVE_BPATH(curve)); new_repr->setAttribute("d", svgpath); new_repr->setAttribute("sodipodi:nodetypes", typestr); diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index e7a975d01..9439fea8b 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -78,10 +78,10 @@ void Inkscape::ObjectSnapper::_snapNodes(Inkscape::SnappedPoint &s, int j = 0; NR::Matrix const i2doc = sp_item_i2doc_affine(*i); - while (sh->curve->bpath[j].code != NR_END) { + while (SP_CURVE_BPATH(sh->curve)[j].code != NR_END) { /* Get this node in desktop coordinates */ - NArtBpath const &bp = sh->curve->bpath[j]; + NArtBpath const &bp = SP_CURVE_BPATH(sh->curve)[j]; NR::Point const n = desktop->doc2dt(bp.c(3) * i2doc); /* Try to snap to this node of the path */ diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index de775ac19..1cd7480aa 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -95,7 +95,7 @@ sp_selected_path_combine(void) SPPath *path = (SPPath *) i->data; SPCurve *c = sp_shape_get_curve(SP_SHAPE(path)); - NArtBpath *abp = nr_artpath_affine(c->bpath, SP_ITEM(path)->transform); + NArtBpath *abp = nr_artpath_affine(SP_CURVE_BPATH(c), SP_ITEM(path)->transform); sp_curve_unref(c); gchar *str = sp_svg_write_path(abp); nr_free(abp); @@ -178,7 +178,7 @@ sp_selected_path_break_apart(void) gchar *style = g_strdup(SP_OBJECT(item)->repr->attribute("style")); - NArtBpath *abp = nr_artpath_affine(curve->bpath, (SP_ITEM(path))->transform); + NArtBpath *abp = nr_artpath_affine(SP_CURVE_BPATH(curve), (SP_ITEM(path))->transform); sp_curve_unref(curve); @@ -198,7 +198,7 @@ sp_selected_path_break_apart(void) Inkscape::XML::Node *repr = sp_repr_new("svg:path"); repr->setAttribute("style", style); - gchar *str = sp_svg_write_path(curve->bpath); + gchar *str = sp_svg_write_path(SP_CURVE_BPATH(curve)); repr->setAttribute("d", str); g_free(str); @@ -326,7 +326,7 @@ sp_selected_item_to_curved_repr(SPItem *item, guint32 text_grouping_policy) sp_repr_set_attr(repr, "inkscape:transform-center-y", SP_OBJECT_REPR(item)->attribute("inkscape:transform-center-y")); /* Definition */ - gchar *def_str = sp_svg_write_path(curve->bpath); + gchar *def_str = sp_svg_write_path(SP_CURVE_BPATH(curve)); repr->setAttribute("d", def_str); g_free(def_str); sp_curve_unref(curve); @@ -358,7 +358,7 @@ sp_selected_path_reverse() SPCurve *rcurve = sp_curve_reverse(shape->curve); - gchar *str = sp_svg_write_path(rcurve->bpath); + gchar *str = sp_svg_write_path(SP_CURVE_BPATH(rcurve)); SP_OBJECT_REPR(shape)->setAttribute("d", str); g_free(str); diff --git a/src/sp-flowregion.cpp b/src/sp-flowregion.cpp index 95695768e..51bc4c511 100644 --- a/src/sp-flowregion.cpp +++ b/src/sp-flowregion.cpp @@ -521,7 +521,7 @@ static void GetDest(SPObject* child,Shape **computed,NR::Matrix itr_mat) Path* temp=new Path; NR::Matrix tr_mat=sp_item_i2root_affine (SP_ITEM(u_child)); tr_mat=itr_mat*tr_mat; - temp->LoadArtBPath(curve->bpath,tr_mat,true); + temp->LoadArtBPath(SP_CURVE_BPATH(curve),tr_mat,true); Shape* n_shp=new Shape; temp->Convert(0.25); temp->Fill(n_shp,0); diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp index fc9115f24..6aead7a54 100644 --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@ -277,7 +277,7 @@ sp_offset_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) } // write that curve to "d" - char *d = sp_svg_write_path (((SPShape *) offset)->curve->bpath); + char *d = sp_svg_write_path (SP_CURVE_BPATH(((SPShape *) offset)->curve)); repr->setAttribute("d", d); g_free (d); @@ -346,7 +346,7 @@ sp_offset_set(SPObject *object, unsigned key, gchar const *value) bpath = sp_svg_read_path (offset->original); curve = sp_curve_new_from_bpath (bpath); // curve se chargera de detruire bpath g_assert (curve != NULL); - offset->originalPath = bpath_to_liv_path (curve->bpath); + offset->originalPath = bpath_to_liv_path (SP_CURVE_BPATH(curve)); sp_curve_unref (curve); offset->knotSet = false; @@ -1023,7 +1023,7 @@ sp_offset_top_point (SPOffset * offset, NR::Point *px) return; } - Path *finalPath = bpath_to_liv_path (curve->bpath); + Path *finalPath = bpath_to_liv_path (SP_CURVE_BPATH(curve)); if (finalPath == NULL) { sp_curve_unref (curve); @@ -1167,7 +1167,7 @@ refresh_offset_source(SPOffset* offset) if (curve == NULL) return; } - orig = bpath_to_liv_path (curve->bpath); + orig = bpath_to_liv_path (SP_CURVE_BPATH(curve)); sp_curve_unref (curve); diff --git a/src/sp-path.cpp b/src/sp-path.cpp index 9fe2f54c5..ee98cc150 100644 --- a/src/sp-path.cpp +++ b/src/sp-path.cpp @@ -111,7 +111,7 @@ sp_nodes_in_path(SPPath *path) gint i = curve->length - 1; if (i > r) i = r; // sometimes after switching from node editor length is wrong, e.g. f6 - draw - f2 - tab - f1, this fixes it for (; i >= 0; i --) - if ((curve->bpath + i) -> code == NR_MOVETO) + if (SP_CURVE_BPATH(curve)[i].code == NR_MOVETO) r --; return r; } @@ -289,7 +289,7 @@ sp_path_set_transform(SPItem *item, NR::Matrix const &xform) /* Transform the path */ NRBPath dpath, spath; - spath.path = shape->curve->bpath; + spath.path = SP_CURVE_BPATH(shape->curve); nr_path_duplicate_transform(&dpath, &spath, xform); SPCurve *curve = sp_curve_new_from_bpath(dpath.path); if (curve) { diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 7366e533f..172339095 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -240,7 +240,7 @@ sp_shape_marker_required(SPShape const *shape, int const m, NArtBpath *bp) return false; } - if (bp == shape->curve->bpath) + if (bp == SP_CURVE_BPATH(shape->curve)) return m == SP_MARKER_LOC_START; else if (bp[1].code == NR_END) return m == SP_MARKER_LOC_END; @@ -438,9 +438,9 @@ found: static NR::Matrix sp_shape_marker_get_transform(SPShape const *shape, NArtBpath const *bp) { - g_return_val_if_fail(( is_moveto(shape->curve->bpath[0].code) + g_return_val_if_fail(( is_moveto(SP_CURVE_BPATH(shape->curve)[0].code) && ( 0 < shape->curve->end ) - && ( shape->curve->bpath[shape->curve->end].code == NR_END ) ), + && ( SP_CURVE_BPATH(shape->curve)[shape->curve->end].code == NR_END ) ), NR::Matrix(NR::translate(bp->c(3)))); double const angle1 = incoming_tangent(bp); double const angle2 = outgoing_tangent(bp); @@ -492,7 +492,7 @@ sp_shape_update_marker_view (SPShape *shape, NRArenaItem *ai) int n = 0; - for (NArtBpath *bp = shape->curve->bpath; bp->code != NR_END; bp++) { + for (NArtBpath *bp = SP_CURVE_BPATH(shape->curve); bp->code != NR_END; bp++) { if (sp_shape_marker_required (shape, i, bp)) { NR::Matrix const m(sp_shape_marker_get_transform(shape, bp)); sp_marker_show_instance ((SPMarker* ) shape->marker[i], ai, @@ -552,7 +552,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &tr // Union with bboxes of the markers, if any if (sp_shape_has_markers (shape)) { - for (NArtBpath* bp = shape->curve->bpath; bp->code != NR_END; bp++) { + for (NArtBpath* bp = SP_CURVE_BPATH(shape->curve); bp->code != NR_END; bp++) { for (int m = SP_MARKER_LOC_START; m < SP_MARKER_LOC_QTY; m++) { if (sp_shape_marker_required (shape, m, bp)) { @@ -613,17 +613,17 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx) if (style->fill.type != SP_PAINT_TYPE_NONE) { NRBPath bp; - bp.path = shape->curve->bpath; + bp.path = SP_CURVE_BPATH(shape->curve); sp_print_fill (ctx, &bp, i2d, style, &pbox, &dbox, &bbox); } if (style->stroke.type != SP_PAINT_TYPE_NONE) { NRBPath bp; - bp.path = shape->curve->bpath; + bp.path = SP_CURVE_BPATH(shape->curve); sp_print_stroke (ctx, &bp, i2d, style, &pbox, &dbox, &bbox); } - for (NArtBpath* bp = shape->curve->bpath; bp->code != NR_END; bp++) { + for (NArtBpath* bp = SP_CURVE_BPATH(shape->curve); bp->code != NR_END; bp++) { for (int m = SP_MARKER_LOC_START; m < SP_MARKER_LOC_QTY; m++) { if (sp_shape_marker_required (shape, m, bp)) { @@ -746,7 +746,7 @@ static int sp_shape_number_of_markers (SPShape *shape, int type) { int n = 0; - for (NArtBpath* bp = shape->curve->bpath; bp->code != NR_END; bp++) { + for (NArtBpath* bp = SP_CURVE_BPATH(shape->curve); bp->code != NR_END; bp++) { if (sp_shape_marker_required (shape, type, bp)) { n++; } @@ -897,7 +897,7 @@ static void sp_shape_snappoints(SPItem const *item, SnapPointsIter p) NR::Matrix const i2d (sp_item_i2d_affine (item)); /* Use the end points of each segment of the path */ - NArtBpath const *bp = shape->curve->bpath; + NArtBpath const *bp = SP_CURVE_BPATH(shape->curve); while (bp->code != NR_END) { *p = bp->c(3) * i2d; bp++; diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp index 9c04120e1..ab65ba4dd 100644 --- a/src/sp-spiral.cpp +++ b/src/sp-spiral.cpp @@ -166,7 +166,7 @@ sp_spiral_write (SPObject *object, Inkscape::XML::Node *repr, guint flags) //g_warning("sp_spiral_write(): No path to copy\n"); return NULL; } - NArtBpath *bpath = curve->bpath; + NArtBpath *bpath = SP_CURVE_BPATH(curve); if ( !bpath ) { //g_warning("sp_spiral_write(): No path to copy\n"); return NULL; diff --git a/src/sp-star.cpp b/src/sp-star.cpp index eea11791f..04efd8e93 100644 --- a/src/sp-star.cpp +++ b/src/sp-star.cpp @@ -146,7 +146,7 @@ sp_star_write (SPObject *object, Inkscape::XML::Node *repr, guint flags) } sp_star_set_shape ((SPShape *) star); - char *d = sp_svg_write_path (((SPShape *) star)->curve->bpath); + char *d = sp_svg_write_path (SP_CURVE_BPATH(((SPShape *) star)->curve)); repr->setAttribute("d", d); g_free (d); diff --git a/src/sp-use-reference.cpp b/src/sp-use-reference.cpp index c6619dbf5..9e3047998 100644 --- a/src/sp-use-reference.cpp +++ b/src/sp-use-reference.cpp @@ -231,7 +231,7 @@ void SPUsePath::refresh_source() } } originalPath = new Path; - originalPath->LoadArtBPath(curve->bpath, NR::Matrix(item->transform), true); + originalPath->LoadArtBPath(SP_CURVE_BPATH(curve), NR::Matrix(item->transform), true); sp_curve_unref(curve); } diff --git a/src/splivarot.cpp b/src/splivarot.cpp index c5969576e..eeb82970b 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -1491,19 +1491,19 @@ Path_for_item(SPItem *item, bool doTransformation, bool transformFull) if (!curve) return NULL; - NArtBpath *bpath = curve->bpath; + NArtBpath *bpath = SP_CURVE_BPATH(curve); if (bpath == NULL) return NULL; if ( doTransformation ) { if (transformFull) - bpath = nr_artpath_affine(curve->bpath, sp_item_i2doc_affine(item)); + bpath = nr_artpath_affine(SP_CURVE_BPATH(curve), sp_item_i2doc_affine(item)); else - bpath = nr_artpath_affine(curve->bpath, item->transform); + bpath = nr_artpath_affine(SP_CURVE_BPATH(curve), item->transform); sp_curve_unref(curve); curve=NULL; } else { - bpath=curve->bpath; + bpath=SP_CURVE_BPATH(curve); } Path *dest = new Path; -- 2.30.2