diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2008-05-05 19:00:20 +0000 |
|---|---|---|
| committer | johanengelen <johanengelen@users.sourceforge.net> | 2008-05-05 19:00:20 +0000 |
| commit | d955f60393f4f85b0269346f37b4481a1c70205a (patch) | |
| tree | 2dd9a11fe737c4a43c8aa88451acd3c8f766fff2 /src/eraser-context.cpp | |
| parent | Cmake: Moved helper macros to their own file and removed *-test.h from inksca... (diff) | |
| download | inkscape-d955f60393f4f85b0269346f37b4481a1c70205a.tar.gz inkscape-d955f60393f4f85b0269346f37b4481a1c70205a.zip | |
struct SPCurve => class SPCurve
change all sp_curve_methods functions to SPCurve::methods.
(bzr r5609)
Diffstat (limited to 'src/eraser-context.cpp')
| -rw-r--r-- | src/eraser-context.cpp | 97 |
1 files changed, 48 insertions, 49 deletions
diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp index 3ee75eb85..295e75e87 100644 --- a/src/eraser-context.cpp +++ b/src/eraser-context.cpp @@ -190,7 +190,7 @@ sp_eraser_context_dispose(GObject *object) SPEraserContext *erc = SP_ERASER_CONTEXT(object); if (erc->accumulated) { - erc->accumulated = sp_curve_unref(erc->accumulated); + erc->accumulated = erc->accumulated->unref(); } while (erc->segments) { @@ -198,9 +198,9 @@ sp_eraser_context_dispose(GObject *object) erc->segments = g_slist_remove(erc->segments, erc->segments->data); } - if (erc->currentcurve) erc->currentcurve = sp_curve_unref(erc->currentcurve); - if (erc->cal1) erc->cal1 = sp_curve_unref(erc->cal1); - if (erc->cal2) erc->cal2 = sp_curve_unref(erc->cal2); + if (erc->currentcurve) erc->currentcurve = erc->currentcurve->unref(); + if (erc->cal1) erc->cal1 = erc->cal1->unref(); + if (erc->cal2) erc->cal2 = erc->cal2->unref(); if (erc->currentshape) { gtk_object_destroy(GTK_OBJECT(erc->currentshape)); @@ -223,11 +223,11 @@ sp_eraser_context_setup(SPEventContext *ec) if (((SPEventContextClass *) parent_class)->setup) ((SPEventContextClass *) parent_class)->setup(ec); - erc->accumulated = sp_curve_new_sized(32); - erc->currentcurve = sp_curve_new_sized(4); + erc->accumulated = new SPCurve(32); + erc->currentcurve = new SPCurve(4); - erc->cal1 = sp_curve_new_sized(32); - erc->cal2 = sp_curve_new_sized(32); + erc->cal1 = new SPCurve(32); + erc->cal2 = new SPCurve(32); erc->currentshape = sp_canvas_item_new(sp_desktop_sketch(ec->desktop), SP_TYPE_CANVAS_BPATH, NULL); sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(erc->currentshape), ERC_RED_RGBA, SP_WIND_RULE_EVENODD); @@ -546,7 +546,7 @@ eraser_cancel(SPEraserContext *dc) dc->segments = g_slist_remove(dc->segments, dc->segments->data); } /* reset accumulated curve */ - sp_curve_reset(dc->accumulated); + dc->accumulated->reset(); clear_current(dc); if (dc->repr) { dc->repr = NULL; @@ -579,7 +579,7 @@ sp_eraser_context_root_handler(SPEventContext *event_context, sp_eraser_reset(dc, button_dt); sp_eraser_extinput(dc, event); sp_eraser_apply(dc, button_dt); - sp_curve_reset(dc->accumulated); + dc->accumulated->reset(); if (dc->repr) { dc->repr = NULL; } @@ -663,7 +663,7 @@ sp_eraser_context_root_handler(SPEventContext *event_context, set_to_accumulated(dc); // performs document_done /* reset accumulated curve */ - sp_curve_reset(dc->accumulated); + dc->accumulated->reset(); clear_current(dc); if (dc->repr) { @@ -790,9 +790,9 @@ clear_current(SPEraserContext *dc) sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(dc->currentshape), NULL); // reset curve - sp_curve_reset(dc->currentcurve); - sp_curve_reset(dc->cal1); - sp_curve_reset(dc->cal2); + dc->currentcurve->reset(); + dc->cal1->reset(); + dc->cal2->reset(); // reset points dc->npoints = 0; @@ -804,7 +804,7 @@ set_to_accumulated(SPEraserContext *dc) SPDesktop *desktop = SP_EVENT_CONTEXT(dc)->desktop; bool workDone = false; - if (!sp_curve_empty(dc->accumulated)) { + if (!dc->accumulated->is_empty()) { NArtBpath *abp; gchar *str; @@ -823,7 +823,7 @@ set_to_accumulated(SPEraserContext *dc) item->transform = SP_ITEM(desktop->currentRoot())->getRelativeTransform(desktop->currentLayer()); item->updateRepr(); } - abp = nr_artpath_affine(sp_curve_first_bpath(dc->accumulated), sp_desktop_dt2root_affine(desktop)); + abp = nr_artpath_affine(dc->accumulated->first_bpath(), sp_desktop_dt2root_affine(desktop)); str = sp_svg_write_path(abp); g_assert( str != NULL ); g_free(abp); @@ -955,16 +955,16 @@ add_cap(SPCurve *curve, } if ( NR::L2(v_in) > ERASER_EPSILON || NR::L2(v_out) > ERASER_EPSILON ) { - sp_curve_curveto(curve, from + v_in, to + v_out, to); + curve->curveto(from + v_in, to + v_out, to); } } static void accumulate_eraser(SPEraserContext *dc) { - if ( !sp_curve_empty(dc->cal1) && !sp_curve_empty(dc->cal2) ) { - sp_curve_reset(dc->accumulated); // Is this required ?? - SPCurve *rev_cal2 = sp_curve_reverse(dc->cal2); + if ( !dc->cal1->is_empty() && !dc->cal2->is_empty() ) { + dc->accumulated->reset(); /* Is this required ?? */ + SPCurve *rev_cal2 = dc->cal2->reverse(); g_assert(dc->cal1->end > 1); g_assert(rev_cal2->end > 1); @@ -975,20 +975,20 @@ accumulate_eraser(SPEraserContext *dc) g_assert(SP_CURVE_SEGMENT(dc->cal1, dc->cal1->end-1)->code == NR_CURVETO); g_assert(SP_CURVE_SEGMENT(rev_cal2, rev_cal2->end-1)->code == NR_CURVETO); - sp_curve_append(dc->accumulated, dc->cal1, FALSE); + dc->accumulated->append(dc->cal1, FALSE); add_cap(dc->accumulated, SP_CURVE_SEGMENT(dc->cal1, dc->cal1->end-1)->c(2), SP_CURVE_SEGMENT(dc->cal1, dc->cal1->end-1)->c(3), SP_CURVE_SEGMENT(rev_cal2, 0)->c(3), SP_CURVE_SEGMENT(rev_cal2, 1)->c(1), dc->cap_rounding); - sp_curve_append(dc->accumulated, rev_cal2, TRUE); + dc->accumulated->append(rev_cal2, TRUE); add_cap(dc->accumulated, SP_CURVE_SEGMENT(rev_cal2, rev_cal2->end-1)->c(2), SP_CURVE_SEGMENT(rev_cal2, rev_cal2->end-1)->c(3), SP_CURVE_SEGMENT(dc->cal1, 0)->c(3), SP_CURVE_SEGMENT(dc->cal1, 1)->c(1), dc->cap_rounding); - sp_curve_closepath(dc->accumulated); + dc->accumulated->closepath(); - sp_curve_unref(rev_cal2); + rev_cal2->unref(); - sp_curve_reset(dc->cal1); - sp_curve_reset(dc->cal2); + dc->cal1->reset(); + dc->cal2->reset(); } } @@ -1023,11 +1023,11 @@ fit_and_split(SPEraserContext *dc, gboolean release) if ( dc->cal1->end == 0 || dc->cal2->end == 0 ) { /* dc->npoints > 0 */ /* g_print("erasers(1|2) reset\n"); */ - sp_curve_reset(dc->cal1); - sp_curve_reset(dc->cal2); + dc->cal1->reset(); + dc->cal2->reset(); - sp_curve_moveto(dc->cal1, dc->point1[0]); - sp_curve_moveto(dc->cal2, dc->point2[0]); + dc->cal1->moveto(dc->point1[0]); + dc->cal2->moveto(dc->point2[0]); } NR::Point b1[BEZIER_MAX_LENGTH]; @@ -1047,31 +1047,30 @@ fit_and_split(SPEraserContext *dc, gboolean release) #endif /* CanvasShape */ if (! release) { - sp_curve_reset(dc->currentcurve); - sp_curve_moveto(dc->currentcurve, b1[0]); + dc->currentcurve->reset(); + dc->currentcurve->moveto(b1[0]); for (NR::Point *bp1 = b1; bp1 < b1 + BEZIER_SIZE * nb1; bp1 += BEZIER_SIZE) { - sp_curve_curveto(dc->currentcurve, bp1[1], + dc->currentcurve->curveto(bp1[1], bp1[2], bp1[3]); } - sp_curve_lineto(dc->currentcurve, - b2[BEZIER_SIZE*(nb2-1) + 3]); + dc->currentcurve->lineto(b2[BEZIER_SIZE*(nb2-1) + 3]); for (NR::Point *bp2 = b2 + BEZIER_SIZE * ( nb2 - 1 ); bp2 >= b2; bp2 -= BEZIER_SIZE) { - sp_curve_curveto(dc->currentcurve, bp2[2], bp2[1], bp2[0]); + dc->currentcurve->curveto(bp2[2], bp2[1], bp2[0]); } // FIXME: dc->segments is always NULL at this point?? if (!dc->segments) { // first segment add_cap(dc->currentcurve, b2[1], b2[0], b1[0], b1[1], dc->cap_rounding); } - sp_curve_closepath(dc->currentcurve); + dc->currentcurve->closepath(); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(dc->currentshape), dc->currentcurve); } /* Current eraser */ for (NR::Point *bp1 = b1; bp1 < b1 + BEZIER_SIZE * nb1; bp1 += BEZIER_SIZE) { - sp_curve_curveto(dc->cal1, bp1[1], bp1[2], bp1[3]); + dc->cal1->curveto(bp1[1], bp1[2], bp1[3]); } for (NR::Point *bp2 = b2; bp2 < b2 + BEZIER_SIZE * nb2; bp2 += BEZIER_SIZE) { - sp_curve_curveto(dc->cal2, bp2[1], bp2[2], bp2[3]); + dc->cal2->curveto(bp2[1], bp2[2], bp2[3]); } } else { /* fixme: ??? */ @@ -1081,10 +1080,10 @@ fit_and_split(SPEraserContext *dc, gboolean release) draw_temporary_box(dc); for (gint i = 1; i < dc->npoints; i++) { - sp_curve_lineto(dc->cal1, dc->point1[i]); + dc->cal1->lineto(dc->point1[i]); } for (gint i = 1; i < dc->npoints; i++) { - sp_curve_lineto(dc->cal2, dc->point2[i]); + dc->cal2->lineto(dc->point2[i]); } } @@ -1094,14 +1093,14 @@ fit_and_split(SPEraserContext *dc, gboolean release) #endif if (!release) { gint eraserMode = (prefs_get_int_attribute("tools.eraser", "mode", 0) != 0) ? 1 : 0; - g_assert(!sp_curve_empty(dc->currentcurve)); + g_assert(!dc->currentcurve->is_empty()); SPCanvasItem *cbp = sp_canvas_item_new(sp_desktop_sketch(SP_EVENT_CONTEXT(dc)->desktop), SP_TYPE_CANVAS_BPATH, NULL); - SPCurve *curve = sp_curve_copy(dc->currentcurve); + SPCurve *curve = dc->currentcurve->copy(); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH (cbp), curve); - sp_curve_unref(curve); + curve->unref(); guint32 fillColor = sp_desktop_get_color_tool (SP_ACTIVE_DESKTOP, "tools.eraser", true); //guint32 strokeColor = sp_desktop_get_color_tool (SP_ACTIVE_DESKTOP, "tools.eraser", false); @@ -1134,20 +1133,20 @@ fit_and_split(SPEraserContext *dc, gboolean release) static void draw_temporary_box(SPEraserContext *dc) { - sp_curve_reset(dc->currentcurve); + dc->currentcurve->reset(); - sp_curve_moveto(dc->currentcurve, dc->point1[dc->npoints-1]); + dc->currentcurve->moveto(dc->point1[dc->npoints-1]); for (gint i = dc->npoints-2; i >= 0; i--) { - sp_curve_lineto(dc->currentcurve, dc->point1[i]); + dc->currentcurve->lineto(dc->point1[i]); } for (gint i = 0; i < dc->npoints; i++) { - sp_curve_lineto(dc->currentcurve, dc->point2[i]); + dc->currentcurve->lineto(dc->point2[i]); } if (dc->npoints >= 2) { add_cap(dc->currentcurve, dc->point2[dc->npoints-2], dc->point2[dc->npoints-1], dc->point1[dc->npoints-1], dc->point1[dc->npoints-2], dc->cap_rounding); } - sp_curve_closepath(dc->currentcurve); + dc->currentcurve->closepath(); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(dc->currentshape), dc->currentcurve); } |
