From afcec343e905389d2645115d60f14dfd45f5f2d0 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 14 Dec 2012 01:01:57 +0100 Subject: bzr history lost by a killed merge (bzr r11950.1.1) --- src/draw-context.cpp | 5 + src/live_effects/CMakeLists.txt | 2 + src/live_effects/Makefile_insert | 2 + src/live_effects/effect-enum.h | 3 + src/live_effects/effect.cpp | 13 +- src/pen-context.cpp | 988 +++++++++++++++++++++++++++++++++++++-- src/pen-context.h | 5 + src/widgets/pencil-toolbar.cpp | 9 +- 8 files changed, 989 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/draw-context.cpp b/src/draw-context.cpp index 5996d600b..21e2a6883 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -314,6 +314,11 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1) { Effect::createAndApply(SPIRO, dc->desktop->doc(), item); } + //BSpline + if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2) { + Effect::createAndApply(BSPLINE, dc->desktop->doc(), item); + } + //BSPline End int shape = prefs->getInt(tool_name(dc) + "/shape", 0); bool shape_applied = false; diff --git a/src/live_effects/CMakeLists.txt b/src/live_effects/CMakeLists.txt index a5f50a69d..7aeb911b0 100644 --- a/src/live_effects/CMakeLists.txt +++ b/src/live_effects/CMakeLists.txt @@ -34,6 +34,7 @@ set(live_effects_SRC lpe-spiro.cpp lpe-tangent_to_curve.cpp lpe-test-doEffect-stack.cpp + lpe-bspline.cpp lpe-text_label.cpp lpe-vonkoch.cpp lpegroupbbox.cpp @@ -94,6 +95,7 @@ set(live_effects_SRC lpe-spiro.h lpe-tangent_to_curve.h lpe-test-doEffect-stack.h + lpe-bspline.h lpe-text_label.h lpe-vonkoch.h lpegroupbbox.h diff --git a/src/live_effects/Makefile_insert b/src/live_effects/Makefile_insert index 9c3c171f2..248030e8c 100644 --- a/src/live_effects/Makefile_insert +++ b/src/live_effects/Makefile_insert @@ -38,6 +38,8 @@ ink_common_sources += \ live_effects/lpe-interpolate.h \ live_effects/lpe-test-doEffect-stack.cpp \ live_effects/lpe-test-doEffect-stack.h \ + live_effects/lpe-bspline.cpp \ + live_effects/lpe-bspline.h \ live_effects/lpe-lattice.cpp \ live_effects/lpe-lattice.h \ live_effects/lpe-envelope.cpp \ diff --git a/src/live_effects/effect-enum.h b/src/live_effects/effect-enum.h index 43af33b53..cf97dd87f 100644 --- a/src/live_effects/effect-enum.h +++ b/src/live_effects/effect-enum.h @@ -45,6 +45,9 @@ enum EffectType { PATH_LENGTH, LINE_SEGMENT, DOEFFECTSTACK_TEST, + //BSpline + BSPLINE, + //BSpline End DYNASTROKE, RECURSIVE_SKELETON, EXTRUDE, diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 3b57de25c..e9ec2076f 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -10,7 +10,7 @@ #include "live_effects/effect.h" #ifdef HAVE_CONFIG_H -# include "config.h" +#include "config.h" #endif // include effects: @@ -22,6 +22,9 @@ #include "live_effects/lpe-rough-hatches.h" #include "live_effects/lpe-dynastroke.h" #include "live_effects/lpe-test-doEffect-stack.h" +//BSpline +#include "live_effects/lpe-bspline.h" +//BSpline End #include "live_effects/lpe-gears.h" #include "live_effects/lpe-curvestitch.h" #include "live_effects/lpe-circle_with_radius.h" @@ -123,6 +126,9 @@ const Util::EnumData LPETypeData[] = { /* 0.49 */ {POWERSTROKE, N_("Power stroke"), "powerstroke"}, {CLONE_ORIGINAL, N_("Clone original path"), "clone_original"}, + //BSpline + {BSPLINE, N_("BSpline"), "bspline"}, + //BSpline End }; const Util::EnumDataConverter LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData)); @@ -231,6 +237,11 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj) case DOEFFECTSTACK_TEST: neweffect = static_cast ( new LPEdoEffectStackTest(lpeobj) ); break; + //BSpline + case BSPLINE: + neweffect = static_cast ( new LPEBSpline(lpeobj) ); + break; + //BSpline End case DYNASTROKE: neweffect = static_cast ( new LPEDynastroke(lpeobj) ); break; diff --git a/src/pen-context.cpp b/src/pen-context.cpp index cb20eb3eb..be25b6a7f 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -44,7 +44,26 @@ #include "context-fns.h" #include "tools-switch.h" #include "ui/control-manager.h" +//BSpline +//Incluimos +#define INKSCAPE_LPE_SPIRO_C +#include "live_effects/lpe-spiro.h" +#include "display/curve.h" +#include +#include <2geom/pathvector.h> +#include <2geom/affine.h> +#include <2geom/bezier-curve.h> +#include <2geom/hvlinesegment.h> +#include "helper/geom-nodetype.h" +#include "helper/geom-curves.h" + +#include "live_effects/spiro.h" + +#define INKSCAPE_LPE_BSPLINE_C +#include "live_effects/lpe-bspline.h" + +//BSpline End using Inkscape::ControlManager; @@ -59,6 +78,34 @@ static gint sp_pen_context_root_handler(SPEventContext *ec, GdkEvent *event); static gint sp_pen_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event); static void spdc_pen_set_initial_point(SPPenContext *pc, Geom::Point const p); + +//BSpline +//Added functions +//Sobrecarga la función "sp_pen_context_set_polyline_mode" +//Le da valor a la nueva propiedad "pc->spiro" que como se auto define indica si estamos en modo spiro +//En el futuro se la dará a "pc->bspline" +static void sp_pen_context_set_mode(SPPenContext *const pc, guint mode); +//Esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro +static void spiro_color(SPPenContext *const pc); +//Combierte el el último nodo a CUSP +static void spiro_node_cusp (SPPenContext *const pc); +//Combierte el el último nodo a SYMM +static void spiro_node_symm (SPPenContext *const pc); +//preparates the curves for its trasformation into spiro curves. +static void spiro_build(SPPenContext *const pc, bool Shift); +//function spiro cloned from lpe-spiro.cpp +static void spiro_doEffect(SPCurve * curve); +//Combierte el el último nodo a CUSP +static void bspline_node_cusp (SPPenContext *const pc); +//Combierte el el último nodo a BSpline +static void bspline_node (SPPenContext *const pc); +//preparates the curves for its trasformation into bspline curves. +static void bspline_build(SPPenContext *const pc, bool Shift); +//function bspline cloned from lpe-bspline.cpp +static void bspline_doEffect(SPCurve * curve); +//BSpline end + + static void spdc_pen_set_subsequent_point(SPPenContext *const pc, Geom::Point const p, bool statusbar, guint status = 0); static void spdc_pen_set_ctrl(SPPenContext *pc, Geom::Point const p, guint state); static void spdc_pen_finish_segment(SPPenContext *pc, Geom::Point p, guint state); @@ -192,10 +239,21 @@ static void sp_pen_context_dispose(GObject *object) void sp_pen_context_set_polyline_mode(SPPenContext *const pc) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); guint mode = prefs->getInt("/tools/freehand/pen/freehand-mode", 0); - pc->polylines_only = (mode == 2 || mode == 3); - pc->polylines_paraxial = (mode == 3); + pc->polylines_only = (mode == 3 || mode == 4); + pc->polylines_paraxial = (mode == 4); + //BSpline + //we call the function which defines the Spiro modes and the B-spline in the future + //todo: merge to one function only + sp_pen_context_set_mode(pc, mode); + //BSpline End } - +//BSpline +//Set the mode of draw now spiro, and later b-splines +void sp_pen_context_set_mode(SPPenContext *const pc, guint mode) { + pc->spiro = (mode == 1); + pc->bspline = (mode == 2); +} +//BSpline End /** * Callback to initialize SPPenContext object. */ @@ -414,11 +472,18 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const Geom::Point const event_w(bevent.x, bevent.y); Geom::Point event_dt(desktop->w2d(event_w)); SPEventContext *event_context = SP_EVENT_CONTEXT(pc); - + //Test whether we hit any anchor. + SPDrawAnchor * const anchor = spdc_test_inside(pc, event_w); + //BSpline + //with this we avoid creating a new point over the existing one + if((pc->spiro || pc->bspline) && (!anchor || pc->p[0] == pc->p[3]) && pc->p[0] == pc->desktop->w2d(event_w)){ + return FALSE; + } + //BSpline end gint ret = FALSE; if (bevent.button == 1 && !event_context->space_panning // make sure this is not the last click for a waiting LPE (otherwise we want to finish the path) - && pc->expecting_clicks_for_LPE != 1) { + && (pc->expecting_clicks_for_LPE != 1)) { if (Inkscape::have_viable_layer(desktop, dc->_message_context) == false) { return TRUE; @@ -436,9 +501,6 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const pen_drag_origin_w = event_w; pen_within_tolerance = true; - // Test whether we hit any anchor. - SPDrawAnchor * const anchor = spdc_test_inside(pc, event_w); - switch (pc->mode) { case SP_PEN_CONTEXT_MODE_CLICK: // In click mode we add point on release @@ -460,7 +522,7 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const case SP_PEN_CONTEXT_STOP: // This is allowed, if we just canceled curve case SP_PEN_CONTEXT_POINT: - if (pc->npoints == 0) { + if (pc->npoints == 0 ) { Geom::Point p; if ((bevent.state & GDK_CONTROL_MASK) && (pc->polylines_only || pc->polylines_paraxial)) { @@ -533,6 +595,11 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const } pc->state = pc->polylines_only ? SP_PEN_CONTEXT_POINT : SP_PEN_CONTEXT_CONTROL; + //BSpline + //Esto evita arrastrar los manejadores ya que el punto se crea + //al soltar el botón del ratón. + if((pc->spiro || pc->bspline) && pc->state != SP_PEN_CONTEXT_CLOSE ) pc->state = SP_PEN_CONTEXT_POINT; + //BSpline End ret = TRUE; break; case SP_PEN_CONTEXT_CONTROL: @@ -594,14 +661,19 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons } Geom::Point const event_w(mevent.x, - mevent.y); + mevent.y); + //BSpline + //we take out the function the const "tolerance" because we need it later + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + gint const tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); + //"spiro_color" lo ejecutamos siempre sea o no spiro + spiro_color(pc); if (pen_within_tolerance) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - gint const tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); - if ( Geom::LInfty( event_w - pen_drag_origin_w ) < tolerance ) { + if ( Geom::LInfty( event_w - pen_drag_origin_w ) < tolerance && mevent.time != 0) { return FALSE; // Do not drag if we're within tolerance from origin. } } + //BSpline END // Once the user has moved farther than tolerance from the original location // (indicating they intend to move the object, not click), then always process the // motion notify coordinates as given (no snapping back to origin) @@ -612,7 +684,6 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons // Test, whether we hit any anchor SPDrawAnchor *anchor = spdc_test_inside(pc, event_w); - switch (pc->mode) { case SP_PEN_CONTEXT_MODE_CLICK: switch (pc->state) { @@ -657,7 +728,11 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons } if (anchor && !pc->anchor_statusbar) { - pc->_message_context->set(Inkscape::NORMAL_MESSAGE, _("Click or click and drag to close and finish the path.")); + if(!pc->spiro && !pc->bspline){ + pc->_message_context->set(Inkscape::NORMAL_MESSAGE, _("Click or click and drag to close and finish the path.")); + }else{ + pc->_message_context->set(Inkscape::NORMAL_MESSAGE, _("Click or click and drag to close and finish the path. Shift to cusp node")); + } pc->anchor_statusbar = true; } else if (!anchor && pc->anchor_statusbar) { pc->_message_context->clear(); @@ -667,7 +742,11 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons ret = TRUE; } else { if (anchor && !pc->anchor_statusbar) { - pc->_message_context->set(Inkscape::NORMAL_MESSAGE, _("Click or click and drag to continue the path from this point.")); + if(!pc->spiro && !pc->bspline){ + pc->_message_context->set(Inkscape::NORMAL_MESSAGE, _("Click or click and drag to continue the path from this point.")); + }else{ + pc->_message_context->set(Inkscape::NORMAL_MESSAGE, _("Click or click and drag to continue the path from this point. Shift to cusp node")); + } pc->anchor_statusbar = true; } else if (!anchor && pc->anchor_statusbar) { pc->_message_context->clear(); @@ -712,6 +791,42 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons default: break; } + //BSpline + if(pc->spiro){ + //Here we redraw the Spiro curve when the cursor is moved + //and the tolerance distance is exceeded. + //the tolerance value can be multiplied to improve the performance + //but it would lost fluency. + //If the cursor stops the curve is also redrawed. + if ( Geom::LInfty( event_w - pen_drag_origin_w ) > tolerance || mevent.time == 0) { + //and we redraw the spiro + if ((mevent.state & GDK_SHIFT_MASK)){ + spiro_build(pc,true); + }else{ + spiro_build(pc,false); + } + //we update the distance and the tolerance + pen_drag_origin_w = event_w; + } + } + if(pc->bspline){ + //Here we redraw the Bspline curve when the cursor is moved + //and the tolerance distance is exceeded. + //the tolerance value can be multiplied to improve the performance + //but it would lost fluency. + //If the cursor stops the curve is also redrawed. + if ( Geom::LInfty( event_w - pen_drag_origin_w ) > tolerance || mevent.time == 0) { + //and we redraw the spiro + if ((mevent.state & GDK_SHIFT_MASK)){ + bspline_build(pc,true); + }else{ + bspline_build(pc,false); + } + //we update the distance and the tolerance + pen_drag_origin_w = event_w; + } + } + //BSpline End return ret; } @@ -724,11 +839,11 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con // skip event processing if events are disabled return FALSE; } - + gint ret = FALSE; + SPEventContext *event_context = SP_EVENT_CONTEXT(pc); - if ( revent.button == 1 && !event_context->space_panning) { - + if ( revent.button == 1 && !event_context->space_panning ) { SPDrawContext *dc = SP_DRAW_CONTEXT (pc); Geom::Point const event_w(revent.x, @@ -738,7 +853,14 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con // Test whether we hit any anchor. SPDrawAnchor *anchor = spdc_test_inside(pc, event_w); - + //BSpline + if(pc->spiro || pc->bspline){ + //Si intentamos crear un nodo en el mismo sitio que el origen, paramos. + if((!anchor || pc->p[0] == pc->p[3]) && pc->p[0] == p){ + return FALSE; + } + } + //BSpline End switch (pc->mode) { case SP_PEN_CONTEXT_MODE_CLICK: switch (pc->state) { @@ -774,6 +896,12 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con } spdc_pen_finish_segment(pc, p, revent.state); spdc_pen_finish(pc, TRUE); + //BSpline + //Ocultamos la guia del penultimo nodo al cerrar la curva + if(pc->spiro){ + sp_canvas_item_hide(pc->c1); + } + //BSpline End pc->state = SP_PEN_CONTEXT_POINT; ret = TRUE; break; @@ -803,6 +931,12 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con // finishing at some other anchor, finish curve but not close spdc_pen_finish(pc, FALSE); } + //BSpline + if(pc->spiro){ + //Ocultamos la guia del penultimo nodo al cerrar la curva + sp_canvas_item_hide(pc->c1); + } + //BSpline End break; case SP_PEN_CONTEXT_STOP: // This is allowed, if we just cancelled curve @@ -816,7 +950,6 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con default: break; } - if (pc->grab) { // Release grab now sp_canvas_item_ungrab(pc->grab, revent.time); @@ -827,6 +960,28 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con dc->green_closed = FALSE; } + //BSpline + if(pc->spiro){ + //Ejecutamos la función tipo de nodo segun tengamos la mayuscula presionada + if ((revent.state & GDK_SHIFT_MASK)){ + spiro_node_cusp(pc); + spiro_build(pc,true); + }else{ + spiro_node_symm(pc); + spiro_build(pc,false); + } + } + if(pc->bspline){ + //Ejecutamos la función tipo de nodo segun tengamos la mayuscula presionada + if ((revent.state & GDK_SHIFT_MASK)){ + bspline_node_cusp(pc); + bspline_build(pc, true); + }else{ + bspline_node(pc); + bspline_build(pc, false); + } + } + //BSpline End // TODO: can we be sure that the path was created correctly? // TODO: should we offer an option to collect the clicks in a list? @@ -846,7 +1001,6 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con // handled in spdc_check_for_and_apply_waiting_LPE() in draw-context.cpp } } - return ret; } @@ -874,13 +1028,10 @@ static void pen_redraw_all (SPPenContext *const pc) SPCanvasItem *cshape = sp_canvas_bpath_new(sp_desktop_sketch(pc->desktop), pc->green_curve); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cshape), pc->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(cshape), 0, SP_WIND_RULE_NONZERO); - pc->green_bpaths = g_slist_prepend(pc->green_bpaths, cshape); } - if (pc->green_anchor) SP_CTRL(pc->green_anchor->ctrl)->moveto(pc->green_anchor->dp); - pc->red_curve->reset(); pc->red_curve->moveto(pc->p[0]); pc->red_curve->curveto(pc->p[1], pc->p[2], pc->p[3]); @@ -913,6 +1064,19 @@ static void pen_redraw_all (SPPenContext *const pc) sp_canvas_item_hide(pc->cl0); } } + //BSpline + //Simplemente redibujamos la spiro teniendo en cuenta si el nodo es cusp o symm. + //como es un redibujo simplemente no llamamos a la función global + //sino al final de esta + if(pc->spiro){ + //we redraw spiro + spiro_build(pc, true); + } + if(pc->bspline){ + //we redraw bspline + bspline_build(pc, false); + } + //BSpline End } static void pen_lastpoint_move (SPPenContext *const pc, gdouble x, gdouble y) @@ -943,8 +1107,11 @@ static void pen_lastpoint_move_screen (SPPenContext *const pc, gdouble x, gdoubl static void pen_lastpoint_tocurve (SPPenContext *const pc) { - if (pc->npoints != 5) + //BSpline + //Evitamos que si la "red_curve" tiene solo dos puntos -recta- no se pare aqui. + if (pc->npoints != 5 && !pc->spiro && !pc->bspline) return; + //BSpline Geom::CubicBezier const * cubic = dynamic_cast( pc->green_curve->last_segment() ); if ( cubic ) { @@ -953,16 +1120,86 @@ static void pen_lastpoint_tocurve (SPPenContext *const pc) pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]); } + //BSpline + //Para formar una curva necesitamos un nodo symm en el "lastpoint" + //de esta manera modificamos el final de la "curva_verde" para que sea symm con el pricipio de la "red_curve" + if(pc->spiro){ + Geom::Point A(0,0); + Geom::Point B(0,0); + Geom::Point C(0,0); + Geom::Point D(0,0); + SPCurve * previous = new SPCurve(); + //We obtain the last segment 4 points in the previous curve + if ( cubic ){ + A = (*cubic)[0]; + B = (*cubic)[1]; + C = pc->p[0] + (Geom::Point)(pc->p[0] - pc->p[1]); + D = (*cubic)[3]; + }else{ + A = pc->green_curve->last_segment()->initialPoint(); + B = pc->green_curve->last_segment()->initialPoint(); + C = pc->p[0] + (Geom::Point)(pc->p[0] - pc->p[1]); + D = pc->green_curve->last_segment()->finalPoint(); + } + previous->moveto(A); + previous->curveto(B, C, D); + //we eliminate the last segment + pc->green_curve->backspace(); + //and we add it again with the recreation + pc->green_curve->append_continuous(previous, 0.0625); + } + //Para formar una curva bspline necesitamos un nodo cusp en el "lastpoint" + //de esta manera modificamos el final de la "curva_verde" para que sea cusp con el pricipio de la "red_curve" + //Que se quedará recta + if(pc->bspline){ + Geom::Point A(0,0); + Geom::Point B(0,0); + SPCurve * previous = new SPCurve(); + //We obtain the last segment 2 points in the previous curve + A = pc->green_curve->last_segment()->initialPoint(); + B = pc->green_curve->last_segment()->finalPoint(); + previous->moveto(A); + previous->lineto(B); + //we eliminate the last segment + pc->green_curve->backspace(); + //and we add it again with the recreation + pc->green_curve->append_continuous(previous, 0.0625); + } + //Spiro Live pen_redraw_all(pc); } static void pen_lastpoint_toline (SPPenContext *const pc) { - if (pc->npoints != 5) + //BSpline + //Si no es bspline + if (pc->npoints != 5 && !pc->bspline) return; - + //BSpline End pc->p[1] = pc->p[0]; + //BSpline + //Para formar una recta necesitamos un nodo con manejador en el "lastpoint" + //de esta manera modificamos el final de la "curva_verde" para que tenga manejador + if(pc->bspline){ + Geom::Point A(0,0); + Geom::Point B(0,0); + Geom::Point C(0,0); + Geom::Point D(0,0); + SPCurve * previous = new SPCurve(); + //We obtain the last segment 4 points in the previous curve + A = pc->green_curve->last_segment()->initialPoint(); + B = pc->green_curve->last_segment()->initialPoint(); + C = pc->p[0] + (Geom::Point)(pc->p[0] - pc->p[1]); + D = pc->green_curve->last_segment()->finalPoint(); + previous->moveto(A); + previous->curveto(B, C, D); + //we eliminate the last segment + pc->green_curve->backspace(); + //and we add it again with the recreation + pc->green_curve->append_continuous(previous, 0.0625); + } + pen_redraw_all(pc); } @@ -1148,8 +1385,6 @@ static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) : pc->p[3] )); pc->npoints = 2; pc->green_curve->backspace(); - sp_canvas_item_hide(pc->c0); - sp_canvas_item_hide(pc->c1); sp_canvas_item_hide(pc->cl0); sp_canvas_item_hide(pc->cl1); pc->state = SP_PEN_CONTEXT_POINT; @@ -1168,6 +1403,7 @@ static void spdc_reset_colors(SPPenContext *pc) { // Red pc->red_curve->reset(); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), NULL); // Blue pc->blue_curve->reset(); @@ -1223,6 +1459,677 @@ static void spdc_pen_set_angle_distance_status_message(SPPenContext *const pc, G g_string_free(dist, FALSE); } + +//BSpline Set Functions +//Creates a new curve resetting the original +static SPCurve * reverse_then_reset(SPCurve *orig) +{ + SPCurve *ret = orig->create_reverse(); + orig->reset(); + return ret; +} + +//Esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro +static void spiro_color(SPPenContext *const pc) +{ + bool remake_green_bpaths = false; + if(pc->spiro){ + //If the colour is not defined as trasparent, por example when changing + //from drawing to spiro mode or when selecting the pen tool + if(pc->green_color != 0x00ff000){ + //We change the green and red colours to transparent, so this lines are not necessary + //to the drawing with spiro + pc->red_color = 0xff00000; + pc->green_color = 0x00ff000; + remake_green_bpaths = true; + } + }else{ + //If we come from working with the spiro curve and change the mode the "green_curve" colour is transparent + if(pc->green_color != 0x00ff007f){ + //since we are not im spiro mode, we assign the original colours + //to the red and the green curve, removing their transparency + pc->red_color = 0xff00007f; + pc->green_color = 0x00ff007f; + remake_green_bpaths = true; + } + //we hide the spiro/bspline rests + if(!pc->bspline){ + sp_canvas_item_hide(pc->blue_bpath); + } + } + //We erase all the "green_bpaths" to recreate them after with the colour + //transparency recently modified + if (pc->green_bpaths && remake_green_bpaths) { + // remove old piecewise green canvasitems + while (pc->green_bpaths) { + sp_canvas_item_destroy(SP_CANVAS_ITEM(pc->green_bpaths->data)); + pc->green_bpaths = g_slist_remove(pc->green_bpaths, pc->green_bpaths->data); + } + // one canvas bpath for all of green_curve + SPCanvasItem *cshape = sp_canvas_bpath_new(sp_desktop_sketch(pc->desktop), pc->green_curve); + sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cshape), pc->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); + sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(cshape), 0, SP_WIND_RULE_NONZERO); + pc->green_bpaths = g_slist_prepend(pc->green_bpaths, cshape); + } + sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(pc->red_bpath), pc->red_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); +} + +//Combierte el el último nodo a CUSP +static void spiro_node_cusp (SPPenContext *const pc) +{ + if(pc->green_curve->is_empty()) + return; + Geom::Point P0(0,0); + Geom::Point P1(0,0); + Geom::Point P2(0,0); + Geom::Point P3(0,0); + Geom::CubicBezier const * cubic = dynamic_cast( pc->green_curve->last_segment()); + if(cubic){ + P0 = (*cubic)[0]; + P1 = (*cubic)[1]; + P2 = (*cubic)[3]; + P3 = (*cubic)[3]; + } + pc->p[0] + P3; + pc->p[1] = P3 - (1./3)*(Geom::Point)( P0 - P3 ); + SPCurve * last = new SPCurve(); + last->moveto(P0); + last->curveto(P1,P2,P3); + if( pc->green_curve->get_segment_count() == 1){ + pc->green_curve = last; + }else{ + pc->green_curve->backspace(); + pc->green_curve->append_continuous(last, 0.0625); + } +} + +//Combierte el el último nodo a SYMM +//Solo se ejecuta al final de el evento release button +static void spiro_node_symm(SPPenContext *const pc) +{ + //Si empezamos sobre una curva ya existente + if(pc->green_curve->is_empty() && pc->sa && !pc->sa->curve->is_empty()){ + Geom::CubicBezier const * cubic; + if (pc->sa->start) { + cubic = dynamic_cast( pc->sa->curve->first_segment() ); + if ( cubic ) { + pc->p[1] = (pc->p[0]-(*cubic)[1]) + pc->p[0]; + } + }else{ + cubic = dynamic_cast( pc->sa->curve->last_segment() ); + if ( cubic ) { + pc->p[1] = (pc->p[0]-(*cubic)[2]) + pc->p[0]; + } + } + } + //Cuando cerramos el segmento + if (!pc->green_curve->is_empty()){ + Geom::Point P0(0,0); + Geom::Point P1(0,0); + Geom::Point P2(0,0); + Geom::Point P3(0,0); + Geom::CubicBezier const * cubic = dynamic_cast( pc->green_curve->last_segment()); + if(cubic){ + P0 = (*cubic)[0]; + P1 = (*cubic)[1]; + P2 = (*cubic)[3] + (1./3)*((*cubic)[0] - (*cubic)[3]); + P3 = (*cubic)[3]; + }else{ + P0 = pc->green_curve->last_segment()->initialPoint(); + P1 = P0; + P3 = pc->green_curve->last_segment()->finalPoint(); + P2 = P3 + (1./3)*(P0 - P3); + } + pc->p[1] = pc->p[0] + (Geom::Point)( pc->p[0] - P2 ); + SPCurve * last = new SPCurve(); + last->moveto(P0); + last->curveto(P1,P2,P3); + if( pc->green_curve->get_segment_count() == 1){ + pc->green_curve = last; + }else{ + pc->green_curve->backspace(); + pc->green_curve->append_continuous(last, 0.0625); + } + } + //por si cerramos la curva + if(pc->ea && !pc->ea->curve->is_empty()){ + Geom::CubicBezier const * cubic; + if(pc->ea->start){ + cubic = dynamic_cast( pc->ea->curve->first_segment()); + if(cubic){ + pc->p[2] = pc->p[3] + (Geom::Point)( pc->p[3] - (*cubic)[1] ); + } + }else{ + cubic = dynamic_cast( pc->ea->curve->last_segment()); + if(cubic){ + pc->p[2] = pc->p[3] + (Geom::Point)( pc->p[3] - (*cubic)[2] ); + } + } + } +} + +//preparates the curves for its trasformation into spiro curves. +//Parámetro opcional que indica si la curva se cierra en que modo lo hace Cusp o Symm +static void spiro_build(SPPenContext *const pc, bool Shift) +{ + //We create the base curve + SPCurve *curve = new SPCurve(); + //If we continuate the existing curve we add it at the start + if(pc->sa && !pc->sa->curve->is_empty()){ + curve = pc->sa->curve->copy(); + if (pc->sa->start) { + curve = curve->create_reverse(); + } + } + //We add also the green curve + if (!pc->green_curve->is_empty()) { + curve->append_continuous(pc->green_curve, 0.0625); + } + //and the red one + if (!pc->red_curve->is_empty()) { + //we add the curve to the modified values + if(!Shift){ + if(pc->ea && !pc->ea->curve->is_empty()){ + Geom::CubicBezier const * cubic; + if(pc->ea->start){ + cubic = dynamic_cast( pc->ea->curve->first_segment()); + if(cubic){ + pc->p[2] = pc->p[3] + (Geom::Point)( pc->p[3] - (*cubic)[1] ); + } + }else{ + cubic = dynamic_cast( pc->ea->curve->last_segment()); + if(cubic){ + pc->p[2] = pc->p[3] + (Geom::Point)( pc->p[3] - (*cubic)[2] ); + } + } + } else if(pc->green_anchor && pc->green_anchor->active){ + Geom::CubicBezier const * cubic; + cubic = dynamic_cast( pc->green_curve->first_segment()); + if(cubic){ + pc->p[2] = pc->p[3] + (Geom::Point)( pc->p[3] - (*cubic)[1] ); + } + } + if(pc->p[2] != pc->p[3]){ + pc->red_curve->reset(); + pc->npoints = 5; + pc->red_curve->moveto(pc->p[0]); + pc->red_curve->curveto(pc->p[1],pc->p[2],pc->p[3]); + } + }else{ + if((pc->ea && !pc->ea->curve->is_empty()) || (pc->green_anchor && pc->green_anchor->active)){ + pc->p[2] == pc->p[3]; + pc->red_curve->reset(); + pc->npoints = 5; + pc->red_curve->moveto(pc->p[0]); + pc->red_curve->curveto(pc->p[1],pc->p[2],pc->p[3]); + } + } + curve->append_continuous(pc->red_curve, 0.0625); + } + if(!curve->is_empty()){ + //cerramos la curva si estan cerca los puntos finales de la curva spiro + if(Geom::are_near(curve->first_path()->initialPoint(), curve->last_path()->finalPoint())){ + curve->closepath_current(); + } + //TODO: CALL TO CLONED FUNCTION SPIRO::doEffect IN lpe-spiro.cpp + //For example + //using namespace Inkscape::LivePathEffect; + //LivePathEffectObject *lpeobj = static_cast (curve); + //Effect *spr = static_cast ( new LPESpiro(lpeobj) ); + //spr->doEffect(curve); + spiro_doEffect(curve); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->blue_bpath), curve); + sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(pc->blue_bpath), pc->blue_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); + sp_canvas_item_show(pc->blue_bpath); + curve->unref(); + sp_canvas_item_show(pc->c1); + pc->blue_curve->reset(); + SP_CTRL(pc->c1)->moveto(pc->p[0]); + //We hide the holders that doesn't contribute anything + sp_canvas_item_hide(pc->cl1); + sp_canvas_item_hide(pc->c0); + sp_canvas_item_hide(pc->cl0); + }else{ + //if the curve is empty + sp_canvas_item_hide(pc->blue_bpath); + } +} +//Spiro function cloned from lpe-spiro.cpp +static void spiro_doEffect(SPCurve * curve) +{ + using Geom::X; + using Geom::Y; + + // Make copy of old path as it is changed during processing + Geom::PathVector const original_pathv = curve->get_pathvector(); + guint len = curve->get_segment_count() + 2; + + curve->reset(); + Spiro::spiro_cp *path = g_new (Spiro::spiro_cp, len); + int ip = 0; + + for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { + if (path_it->empty()) + continue; + + // start of path + { + Geom::Point p = path_it->front().pointAt(0); + path[ip].x = p[X]; + path[ip].y = p[Y]; + path[ip].ty = '{' ; // for closed paths, this is overwritten + ip++; + } + + // midpoints + Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve + Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve + + Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop + if (path_it->closed()) { + // if the path is closed, maybe we have to stop a bit earlier because the closing line segment has zerolength. + const Geom::Curve &closingline = path_it->back_closed(); // the closing line segment is always of type Geom::LineSegment. + if (are_near(closingline.initialPoint(), closingline.finalPoint())) { + // closingline.isDegenerate() did not work, because it only checks for *exact* zero length, which goes wrong for relative coordinates and rounding errors... + // the closing line segment has zero-length. So stop before that one! + curve_endit = path_it->end_open(); + } + } + + while ( curve_it2 != curve_endit ) + { + /* This deals with the node between curve_it1 and curve_it2. + * Loop to end_default (so without last segment), loop ends when curve_it2 hits the end + * and then curve_it1 points to end or closing segment */ + Geom::Point p = curve_it1->finalPoint(); + path[ip].x = p[X]; + path[ip].y = p[Y]; + + // Determine type of spiro node this is, determined by the tangents (angles) of the curves + // TODO: see if this can be simplified by using /helpers/geom-nodetype.cpp:get_nodetype + bool this_is_line = is_straight_curve(*curve_it1); + bool next_is_line = is_straight_curve(*curve_it2); + + Geom::NodeType nodetype = Geom::get_nodetype(*curve_it1, *curve_it2); + + if ( nodetype == Geom::NODE_SMOOTH || nodetype == Geom::NODE_SYMM ) + { + if (this_is_line && !next_is_line) { + path[ip].ty = ']'; + } else if (next_is_line && !this_is_line) { + path[ip].ty = '['; + } else { + path[ip].ty = 'c'; + } + } else { + path[ip].ty = 'v'; + } + + ++curve_it1; + ++curve_it2; + ip++; + } + + // add last point to the spiropath + Geom::Point p = curve_it1->finalPoint(); + path[ip].x = p[X]; + path[ip].y = p[Y]; + if (path_it->closed()) { + // curve_it1 points to the (visually) closing segment. determine the match between first and this last segment (the closing node) + Geom::NodeType nodetype = Geom::get_nodetype(*curve_it1, path_it->front()); + switch (nodetype) { + case Geom::NODE_NONE: // can't happen! but if it does, it means the path isn't closed :-) + path[ip].ty = '}'; + ip++; + break; + case Geom::NODE_CUSP: + path[0].ty = path[ip].ty = 'v'; + break; + case Geom::NODE_SMOOTH: + case Geom::NODE_SYMM: + path[0].ty = path[ip].ty = 'c'; + break; + } + } else { + // set type to path closer + path[ip].ty = '}'; + ip++; + } + + // run subpath through spiro + int sp_len = ip; + Spiro::spiro_run(path, sp_len, *curve); + ip = 0; + } + + g_free (path); +} + +//Combierte el el último nodo a CUSP +//Crea una curva en el punto final de la green_curve +static void bspline_node_cusp(SPPenContext *const pc) +{ + + if (!pc->green_curve->is_empty()){ + using Geom::X; + using Geom::Y; + Geom::Point P0(0,0); + Geom::Point P1(0,0); + Geom::Point P2(0,0); + Geom::Point P3(0,0); + P0 = pc->green_curve->last_segment()->initialPoint(); + P1 = P0; + P3 = pc->green_curve->last_segment()->finalPoint(); + P2 = P3 + (1./3)*(P0 - P3); + P2 = Geom::Point(P2[X]+1,P2[Y]+1); + pc->p[0] = P3; + pc->p[1] = P3; + SPCurve * last = new SPCurve(); + last->moveto(P0); + last->curveto(P1, P2,P3); + if( pc->green_curve->get_segment_count() == 1){ + pc->green_curve = last; + }else{ + pc->green_curve->backspace(); + pc->green_curve->append_continuous(last, 0.0625); + } + } + if (pc->sa && !pc->sa->curve->is_empty() && pc->green_curve->get_segment_count() == 1){ + using Geom::X; + using Geom::Y; + if(pc->sa->start){ + pc->sa->curve = reverse_then_reset(pc->sa->curve); + } + Geom::Point P0(0,0); + Geom::Point P1(0,0); + Geom::Point P2(0,0); + Geom::Point P3(0,0); + P0 = pc->sa->curve->last_segment()->initialPoint(); + P1 = P0; + P3 = pc->sa->curve->last_segment()->finalPoint(); + P2 = P3 + (1./3)*(P0 - P3); + P2 = Geom::Point(P2[X]+1,P2[Y]+1); + pc->p[0] = P3; + pc->p[1] = P3; + SPCurve * last = new SPCurve(); + last->moveto(P0); + last->curveto(P1,P2,P3); + if( pc->sa->curve->get_segment_count() == 1){ + pc->sa->curve = last; + }else{ + pc->sa->curve->backspace(); + pc->sa->curve->append_continuous(last, 0.0625); + } + } + //Lo ejacutamos para que se actualize tosa la curva por un fallo de redibujo + bspline_build(pc,true); +} + +//Combierte el el último nodo a SYMM +//crea lineas rectas +static void bspline_node(SPPenContext *const pc) +{ + + if (!pc->green_curve->is_empty()){ + Geom::Point P0(0,0); + Geom::Point P1(0,0); + P0 = pc->green_curve->last_segment()->initialPoint(); + P1 = pc->green_curve->last_segment()->finalPoint(); + pc->p[1] = P1; + pc->p[0] = P1; + SPCurve * last = new SPCurve(); + last->moveto(P0); + last->lineto(P1); + if( pc->green_curve->get_segment_count() == 1){ + pc->green_curve = last; + }else{ + pc->green_curve->backspace(); + pc->green_curve->append_continuous(last, 0.0625); + } + } +} + +//preparates the curves for its trasformation into BSline curves. +static void bspline_build(SPPenContext *const pc, bool Shift) +{ + if (pc->green_curve->is_empty() && !pc->sa) + return; + //We create the base curve + SPCurve *curve = new SPCurve(); + //If we continuate the existing curve we add it at the start + if(pc->sa && !pc->sa->curve->is_empty()){ + curve = pc->sa->curve->copy(); + if (pc->sa->start) { + curve = curve->create_reverse(); + } + } + //We add also the green curve + if (!pc->green_curve->is_empty()) { + curve->append_continuous(pc->green_curve, 0.0625); + } + //and the red one + if (!pc->red_curve->is_empty()) { + //we add the curve to the modified values + if((pc->ea && !pc->ea->curve->is_empty()) || (pc->green_anchor && pc->green_anchor->active)){ + if(Shift){ + using Geom::X; + using Geom::Y; + pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); + pc->p[2] = Geom::Point(pc->p[2][X]+1,pc->p[2][Y]+1); + pc->red_curve->reset(); + pc->npoints = 5; + pc->red_curve->moveto(pc->p[0]); + pc->red_curve->curveto(pc->p[1],pc->p[2],pc->p[3]); + }else{ + pc->red_curve->reset(); + pc->npoints = 2; + pc->red_curve->moveto(pc->p[0]); + pc->red_curve->lineto(pc->red_curve->first_segment()->finalPoint()); + } + } + curve->append_continuous(pc->red_curve, 0.0625); + } + if(curve->get_segment_count() > 1 ){ + //cerramos la curva si estan cerca los puntos finales de la curva spiro + if(Geom::are_near(curve->first_path()->initialPoint(), curve->last_path()->finalPoint())){ + curve->closepath_current(); + } + //TODO: CALL TO CLONED FUNCTION SPIRO::doEffect IN lpe-spiro.cpp + //For example + //using namespace Inkscape::LivePathEffect; + //LivePathEffectObject *lpeobj = static_cast (curve); + //Effect *spr = static_cast ( new LPEBspline(lpeobj) ); + //spr->doEffect(curve); + bspline_doEffect(curve); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->blue_bpath), curve); + sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(pc->blue_bpath), pc->blue_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); + sp_canvas_item_show(pc->blue_bpath); + curve->unref(); + pc->blue_curve->reset(); + //We hide the holders that doesn't contribute anything + sp_canvas_item_hide(pc->c1); + sp_canvas_item_hide(pc->cl1); + sp_canvas_item_hide(pc->c0); + sp_canvas_item_hide(pc->cl0); + }else { + //if the curve is empty + sp_canvas_item_hide(pc->blue_bpath); + } +} + +static void bspline_doEffect(SPCurve * curve) +{ + using Geom::X; + using Geom::Y; + + // Make copy of old path as it is changed during processing + Geom::PathVector const original_pathv = curve->get_pathvector(); + curve->reset(); + int ip = 0; + //Sbasis + Geom::D2< Geom::SBasis > curveIn; + Geom::D2< Geom::SBasis > curveOut; + Geom::D2< Geom::SBasis > rectCurve; + Geom::D2< Geom::SBasis > rectCurveExtra; + //Puntos a usar. Ponemos todos los posibles para hacer más inteligible el código + Geom::Point startAnchor(0,0); + Geom::Point previousAnchor(0,0); + Geom::Point anchor(0,0); + Geom::Point previousSBasis0(0,0); + Geom::Point previousSBasis1(0,0); + Geom::Point previousSBasis2(0,0); + //Geom::Point previousSBasis3(0,0); + Geom::Point SBasis0(0,0); + Geom::Point SBasis1(0,0); + Geom::Point SBasis2(0,0); + Geom::Point SBasis3(0,0); + //Geom::Point nextSBasis0(0,0); + Geom::Point nextSBasis1(0,0); + Geom::Point nextSBasis2(0,0); + Geom::Point nextSBasis3(0,0); + //Curvas temporales + SPCurve *BSplineRectTemp = new SPCurve(); + SPCurve *BSplineCurveTemp = new SPCurve(); + SPCurve *BSplinePreviousCurveTemp = new SPCurve(); + //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo + for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { + //Si está vacío... + if (path_it->empty()) + continue; + //Declaramos las variables + //Itreador + Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve + Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve + Geom::Path::const_iterator curve_end = path_it->end(); // last curve + Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop + //por defecto la linea es recta. + //Para formar las bsplines contamos que si el nodo es cusp -sin manejadores + //se calcula el nodo resultante como BSpline. Si por el contrario tiene un manejador + //en el últimp punto de la cuva (pc->p[2]) calculamos la curva resultante para que forme un nodo cusp + bool is_line = true; + bool previous_is_line = true; + if (path_it->closed()) { + SBasis2 = curve_it1->toSBasis().valueAt(0.3334); + nextSBasis1 = curve_end->toSBasis().valueAt(0.6664); + BSplineRectTemp->moveto(nextSBasis1); + BSplineRectTemp->lineto(SBasis2); + startAnchor = BSplineRectTemp->first_segment()->toSBasis().valueAt(0.5); + anchor = startAnchor; + BSplineRectTemp->reset(); + } + while ( curve_it2 != curve_endit ) + { + //Calculamos los dos puntos para seleccional el punto central de la línea que los une + curveIn = curve_it1->toSBasis(); + curveOut = curve_it2->toSBasis(); + previousSBasis0 = SBasis0; + previousSBasis1 = SBasis1; + previousSBasis2 = SBasis2; + //previousSBasis3 = SBasis3; + SBasis0 = curveIn.valueAt(0); + SBasis1 = curveIn.valueAt(0.3334); + SBasis2 = curveIn.valueAt(0.6667); + SBasis3 = curveIn.valueAt(1); + //nextSBasis0 = curveOut.valueAt(0); + nextSBasis1 = curveOut.valueAt(0.3334); + nextSBasis2 = curveOut.valueAt(0.6667);; + nextSBasis3 = curveOut.valueAt(1); + //Se forma con la union de dos puntos, el primero está en la curva entrante + // y se conoce dividiendo por tres la curva y seleccionado el + //punto mas cercano de los dos al nodo de union con la curva saliente. + //El otro punto es el puntio más cercano al nodo de union + //de la curva saliente dividida por tres. + BSplineRectTemp->moveto(SBasis2); + BSplineRectTemp->lineto(nextSBasis1); + previousAnchor = anchor; + anchor = BSplineRectTemp->first_segment()->toSBasis().valueAt(0.5); + BSplineRectTemp->reset(); + //Vemos si el nodo es curva + previous_is_line = is_line; + is_line = is_straight_curve(*curve_it1); + if(!is_line && curve->get_segment_count() > 1){ + //Si no es curva convertimos la curva resultante a un nodo cusp + //aberiguamos el punto en donde deveria estar de manera fija + //independientemente de el manejador y movemos + BSplineRectTemp->moveto(SBasis0); + BSplineRectTemp->lineto(SBasis3); + SBasis1 = BSplineRectTemp->first_segment()->toSBasis().valueAt(0.3334); + SBasis2 = BSplineRectTemp->first_segment()->toSBasis().valueAt(0.6667); + BSplineRectTemp->reset(); + BSplineRectTemp->moveto(SBasis1); + BSplineRectTemp->lineto(previousSBasis2); + previousAnchor = BSplineRectTemp->first_segment()->toSBasis().valueAt(0.5); + anchor = SBasis3; + BSplineRectTemp->reset(); + //averiguamos el nuevo vinal de curva entrante recreando de nuevo + //una linea y seleccionando su centro como origen + if(previous_is_line){ + BSplineCurveTemp->moveto(previousAnchor); + BSplineCurveTemp->curveto(SBasis1, SBasis2, anchor); + }else{ + BSplineCurveTemp->moveto(SBasis0); + BSplineCurveTemp->lineto(anchor); + } + BSplineRectTemp->reset(); + + //Como el origen ha cambiado, seleccionamos el ultimo punto + //de la curva ya creada y lo movemos al nuevo origen/final + Geom::CubicBezier const * cubic = dynamic_cast( curve->last_segment()); + if(cubic){ + BSplinePreviousCurveTemp->moveto((*cubic)[0]); + if(previous_is_line){ + BSplinePreviousCurveTemp->curveto((*cubic)[1],(*cubic)[2],previousAnchor); + } else { + BSplinePreviousCurveTemp->curveto((*cubic)[1],(*cubic)[2],curve->last_segment()->finalPoint()); + } + }else{ + BSplinePreviousCurveTemp->moveto(curve->last_segment()->initialPoint()); + BSplinePreviousCurveTemp->lineto(curve->last_segment()->finalPoint()); + } + if( curve->get_segment_count() == 1){ + curve = BSplinePreviousCurveTemp; + }else{ + curve->backspace(); + curve->append_continuous(BSplinePreviousCurveTemp, 0.0625); + } + BSplinePreviousCurveTemp->reset(); + }else{ + //Creamos la curva correspondiente a la posición actual del + //Iterador, para anexarla a la curva de salida + //almacena la SPCurve de un solo segmento que se va añadir al resiultado final + //en la itineración + if (ip == 0 && !path_it->closed()){ + BSplineCurveTemp->moveto(SBasis0); + }else{ + //Empezamos la curva el el final de la anterior curva + BSplineCurveTemp->moveto(previousAnchor); + } + BSplineCurveTemp->curveto(SBasis1, SBasis2, anchor); + } + curve->append_continuous(BSplineCurveTemp, 0.0625); + BSplineCurveTemp->reset(); + ++curve_it1; + ++curve_it2; + ip++; + } + //terminamos el trazado + BSplineCurveTemp->moveto(anchor); + is_line = is_straight_curve(*curve_it1); + if (path_it->closed() && is_line) { + BSplineCurveTemp->curveto(nextSBasis1, nextSBasis2, startAnchor); + }else{ + BSplineCurveTemp->curveto(nextSBasis1, nextSBasis2, nextSBasis3); + } + curve->append_continuous(BSplineCurveTemp, 0.0625); + BSplineCurveTemp->reset(); + if (path_it->closed()) { + curve->closepath_current(); + } + } +} + +//BSpline end + static void spdc_pen_set_subsequent_point(SPPenContext *const pc, Geom::Point const p, bool statusbar, guint status) { g_assert( pc->npoints != 0 ); @@ -1249,7 +2156,9 @@ static void spdc_pen_set_subsequent_point(SPPenContext *const pc, Geom::Point co is_curve = false; } else { // one of the 'regular' modes - if (pc->p[1] != pc->p[0]) { + //SpiroLive + if (pc->p[1] != pc->p[0] || pc->spiro) { + //SpiroLive End pc->red_curve->curveto(pc->p[1], p, p); is_curve = true; } else { @@ -1257,13 +2166,18 @@ static void spdc_pen_set_subsequent_point(SPPenContext *const pc, Geom::Point co is_curve = false; } } - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), pc->red_curve); - if (statusbar) { gchar *message = is_curve ? _("Curve segment: angle %3.2f°, distance %s; with Ctrl to snap angle, Enter to finish the path" ): _("Line segment: angle %3.2f°, distance %s; with Ctrl to snap angle, Enter to finish the path"); + //BSpline + if(pc->spiro || pc->bspline){ + message = is_curve ? + _("Curve segment: angle %3.2f°, distance %s; with Shift to cusp node, Enter to finish the path" ): + _("Line segment: angle %3.2f°, distance %s; with Shift to cusp node, Enter to finish the path"); + } + //BSpline End spdc_pen_set_angle_distance_status_message(pc, p, 0, message); } } @@ -1277,9 +2191,12 @@ static void spdc_pen_set_ctrl(SPPenContext *const pc, Geom::Point const p, guint pc->p[1] = p; sp_canvas_item_hide(pc->c0); sp_canvas_item_hide(pc->cl0); - SP_CTRL(pc->c1)->moveto(pc->p[1]); + if(pc->spiro){ + SP_CTRL(pc->c1)->moveto(pc->p[1]); + }else{ + SP_CTRL(pc->c1)->moveto(pc->p[1]); + } pc->cl1->setCoords(pc->p[0], pc->p[1]); - spdc_pen_set_angle_distance_status_message(pc, p, 0, _("Curve handle: angle %3.2f°, length %s; with Ctrl to snap angle")); } else if ( pc->npoints == 5 ) { pc->p[4] = p; @@ -1300,7 +2217,6 @@ static void spdc_pen_set_ctrl(SPPenContext *const pc, Geom::Point const p, guint pc->cl0 ->setCoords(pc->p[3], pc->p[2]); SP_CTRL(pc->c1)->moveto(pc->p[4]); pc->cl1->setCoords(pc->p[3], pc->p[4]); - gchar *message = is_symm ? _("Curve handle, symmetric: angle %3.2f°, length %s; with Ctrl to snap angle, with Shift to move this handle only") : _("Curve handle: angle %3.2f°, length %s; with Ctrl to snap angle, with Shift to move this handle only"); diff --git a/src/pen-context.h b/src/pen-context.h index a68b76ff5..4485539cd 100644 --- a/src/pen-context.h +++ b/src/pen-context.h @@ -43,6 +43,11 @@ struct SPPenContext : public SPDrawContext { bool polylines_only; bool polylines_paraxial; + //SpiroLive + //Propiedad que guarda si el modo Spiro está activo o no + bool spiro; + bool bspline; + //SpiroLIve End int num_clicks; unsigned int expecting_clicks_for_LPE; // if positive, finish the path after this many clicks diff --git a/src/widgets/pencil-toolbar.cpp b/src/widgets/pencil-toolbar.cpp index d0e71d2b0..7e28f7c8c 100644 --- a/src/widgets/pencil-toolbar.cpp +++ b/src/widgets/pencil-toolbar.cpp @@ -139,7 +139,14 @@ static void sp_add_freehand_mode_toggle(GtkActionGroup* mainActions, GObject* ho 1, _("Create Spiro path"), 2, INKSCAPE_ICON("path-mode-spiro"), -1 ); - + //BSpline + gtk_list_store_append( model, &iter ); + gtk_list_store_set( model, &iter, + 0, _("BSpline"), + 1, _("Create BSpline path"), + 2, INKSCAPE_ICON("path-mode-bspline"), + -1 ); + //BSpline if (!tool_is_pencil) { gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, -- cgit v1.2.3 From e6d37f6e87aad1a48740c7096408e2457d3527a1 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 21 Dec 2012 09:33:52 +0100 Subject: not working (bzr r11950.1.3) --- src/pen-context.cpp | 844 +++++++++++++++++++++++-------------------------- src/pencil-context.cpp | 19 +- 2 files changed, 411 insertions(+), 452 deletions(-) (limited to 'src') diff --git a/src/pen-context.cpp b/src/pen-context.cpp index be25b6a7f..6d35d0897 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -58,6 +58,11 @@ #include "helper/geom-nodetype.h" #include "helper/geom-curves.h" +// For handling un-continuous paths: +#include "message-stack.h" +#include "inkscape.h" +#include "desktop.h" + #include "live_effects/spiro.h" #define INKSCAPE_LPE_BSPLINE_C @@ -87,20 +92,16 @@ static void spdc_pen_set_initial_point(SPPenContext *pc, Geom::Point const p); static void sp_pen_context_set_mode(SPPenContext *const pc, guint mode); //Esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro static void spiro_color(SPPenContext *const pc); -//Combierte el el último nodo a CUSP -static void spiro_node_cusp (SPPenContext *const pc); -//Combierte el el último nodo a SYMM -static void spiro_node_symm (SPPenContext *const pc); -//preparates the curves for its trasformation into spiro curves. -static void spiro_build(SPPenContext *const pc, bool Shift); +//Preparamos la curva roja para que se muestre según esté pulsada la tecla SHIFT +static void spiro_prepare(SPPenContext *const pc, bool Shift); +//Unimos todas las curvas en juego y llamamos a la función doEffect. +static void spiro_build(SPPenContext *const pc); //function spiro cloned from lpe-spiro.cpp static void spiro_doEffect(SPCurve * curve); -//Combierte el el último nodo a CUSP -static void bspline_node_cusp (SPPenContext *const pc); -//Combierte el el último nodo a BSpline -static void bspline_node (SPPenContext *const pc); -//preparates the curves for its trasformation into bspline curves. -static void bspline_build(SPPenContext *const pc, bool Shift); +//Preparamos la curva roja para que se muestre según esté pulsada la tecla SHIFT +static void bspline_prepare(SPPenContext *const pc,bool Shift); +//Unimos todas las curvas en juego y llamamos a la función doEffect. +static void bspline_build(SPPenContext *const pc); //function bspline cloned from lpe-bspline.cpp static void bspline_doEffect(SPCurve * curve); //BSpline end @@ -476,7 +477,7 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const SPDrawAnchor * const anchor = spdc_test_inside(pc, event_w); //BSpline //with this we avoid creating a new point over the existing one - if((pc->spiro || pc->bspline) && (!anchor || pc->p[0] == pc->p[3]) && pc->p[0] == pc->desktop->w2d(event_w)){ + if((pc->spiro || pc->bspline) && pc->npoints > 0 && pc->p[0] == pc->p[3]){ return FALSE; } //BSpline end @@ -669,7 +670,7 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons //"spiro_color" lo ejecutamos siempre sea o no spiro spiro_color(pc); if (pen_within_tolerance) { - if ( Geom::LInfty( event_w - pen_drag_origin_w ) < tolerance && mevent.time != 0) { + if ( Geom::LInfty( event_w - pen_drag_origin_w ) < tolerance) { return FALSE; // Do not drag if we're within tolerance from origin. } } @@ -766,8 +767,9 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons // snap the handle spdc_endpoint_snap_handle(pc, p, mevent.state); - - if (!pc->polylines_only) { + //BSpline + if (!pc->polylines_only && !pc->bspline && !pc->spiro) { + //BSpline End spdc_pen_set_ctrl(pc, p, mevent.state); } else { spdc_pen_set_ctrl(pc, pc->p[1], mevent.state); @@ -792,39 +794,14 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons break; } //BSpline - if(pc->spiro){ - //Here we redraw the Spiro curve when the cursor is moved - //and the tolerance distance is exceeded. - //the tolerance value can be multiplied to improve the performance - //but it would lost fluency. - //If the cursor stops the curve is also redrawed. - if ( Geom::LInfty( event_w - pen_drag_origin_w ) > tolerance || mevent.time == 0) { - //and we redraw the spiro - if ((mevent.state & GDK_SHIFT_MASK)){ - spiro_build(pc,true); - }else{ - spiro_build(pc,false); - } - //we update the distance and the tolerance - pen_drag_origin_w = event_w; + if ( Geom::LInfty( event_w - pen_drag_origin_w ) > tolerance || mevent.time == 0) { + if(pc->spiro){ + spiro_prepare(pc,(mevent.state & GDK_SHIFT_MASK)); } - } - if(pc->bspline){ - //Here we redraw the Bspline curve when the cursor is moved - //and the tolerance distance is exceeded. - //the tolerance value can be multiplied to improve the performance - //but it would lost fluency. - //If the cursor stops the curve is also redrawed. - if ( Geom::LInfty( event_w - pen_drag_origin_w ) > tolerance || mevent.time == 0) { - //and we redraw the spiro - if ((mevent.state & GDK_SHIFT_MASK)){ - bspline_build(pc,true); - }else{ - bspline_build(pc,false); - } - //we update the distance and the tolerance - pen_drag_origin_w = event_w; + if(pc->bspline){ + bspline_prepare(pc,(mevent.state & GDK_SHIFT_MASK)); } + pen_drag_origin_w = event_w; } //BSpline End return ret; @@ -841,7 +818,6 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con } gint ret = FALSE; - SPEventContext *event_context = SP_EVENT_CONTEXT(pc); if ( revent.button == 1 && !event_context->space_panning ) { SPDrawContext *dc = SP_DRAW_CONTEXT (pc); @@ -856,7 +832,7 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con //BSpline if(pc->spiro || pc->bspline){ //Si intentamos crear un nodo en el mismo sitio que el origen, paramos. - if((!anchor || pc->p[0] == pc->p[3]) && pc->p[0] == p){ + if(pc->npoints > 0 && pc->p[0] == pc->p[3]){ return FALSE; } } @@ -879,6 +855,14 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con p = anchor->dp; } } + //BSpline + if(pc->spiro){ + spiro_prepare(pc,(revent.state & GDK_SHIFT_MASK)); + } + if(pc->bspline){ + bspline_prepare(pc,(revent.state & GDK_SHIFT_MASK)); + } + //BSpline End pc->state = SP_PEN_CONTEXT_CONTROL; ret = TRUE; break; @@ -895,13 +879,13 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con spdc_endpoint_snap(pc, p, revent.state); } spdc_pen_finish_segment(pc, p, revent.state); - spdc_pen_finish(pc, TRUE); //BSpline //Ocultamos la guia del penultimo nodo al cerrar la curva if(pc->spiro){ sp_canvas_item_hide(pc->c1); } //BSpline End + spdc_pen_finish(pc, TRUE); pc->state = SP_PEN_CONTEXT_POINT; ret = TRUE; break; @@ -924,6 +908,12 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con case SP_PEN_CONTEXT_CLOSE: spdc_endpoint_snap(pc, p, revent.state); spdc_pen_finish_segment(pc, p, revent.state); + //BSpline + //Ocultamos la guia del penultimo nodo al cerrar la curva + if(pc->spiro){ + sp_canvas_item_hide(pc->c1); + } + //BSpline End if (pc->green_closed) { // finishing at the start anchor, close curve spdc_pen_finish(pc, TRUE); @@ -931,12 +921,6 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con // finishing at some other anchor, finish curve but not close spdc_pen_finish(pc, FALSE); } - //BSpline - if(pc->spiro){ - //Ocultamos la guia del penultimo nodo al cerrar la curva - sp_canvas_item_hide(pc->c1); - } - //BSpline End break; case SP_PEN_CONTEXT_STOP: // This is allowed, if we just cancelled curve @@ -960,28 +944,6 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con dc->green_closed = FALSE; } - //BSpline - if(pc->spiro){ - //Ejecutamos la función tipo de nodo segun tengamos la mayuscula presionada - if ((revent.state & GDK_SHIFT_MASK)){ - spiro_node_cusp(pc); - spiro_build(pc,true); - }else{ - spiro_node_symm(pc); - spiro_build(pc,false); - } - } - if(pc->bspline){ - //Ejecutamos la función tipo de nodo segun tengamos la mayuscula presionada - if ((revent.state & GDK_SHIFT_MASK)){ - bspline_node_cusp(pc); - bspline_build(pc, true); - }else{ - bspline_node(pc); - bspline_build(pc, false); - } - } - //BSpline End // TODO: can we be sure that the path was created correctly? // TODO: should we offer an option to collect the clicks in a list? @@ -1070,11 +1032,11 @@ static void pen_redraw_all (SPPenContext *const pc) //sino al final de esta if(pc->spiro){ //we redraw spiro - spiro_build(pc, true); + spiro_build(pc); } if(pc->bspline){ //we redraw bspline - bspline_build(pc, false); + bspline_build(pc); } //BSpline End } @@ -1160,10 +1122,15 @@ static void pen_lastpoint_tocurve (SPPenContext *const pc) B = pc->green_curve->last_segment()->finalPoint(); previous->moveto(A); previous->lineto(B); - //we eliminate the last segment - pc->green_curve->backspace(); - //and we add it again with the recreation - pc->green_curve->append_continuous(previous, 0.0625); + if( pc->green_curve->get_segment_count() == 1){ + pc->green_curve = previous; + }else{ + //we eliminate the last segment + pc->green_curve->backspace(); + //and we add it again with the recreation + pc->green_curve->append_continuous(previous, 0.0625); + } + } //Spiro Live pen_redraw_all(pc); @@ -1181,7 +1148,7 @@ static void pen_lastpoint_toline (SPPenContext *const pc) //BSpline //Para formar una recta necesitamos un nodo con manejador en el "lastpoint" //de esta manera modificamos el final de la "curva_verde" para que tenga manejador - if(pc->bspline){ + if(pc->bspline && !pc->green_curve->is_empty()){ Geom::Point A(0,0); Geom::Point B(0,0); Geom::Point C(0,0); @@ -1190,14 +1157,19 @@ static void pen_lastpoint_toline (SPPenContext *const pc) //We obtain the last segment 4 points in the previous curve A = pc->green_curve->last_segment()->initialPoint(); B = pc->green_curve->last_segment()->initialPoint(); - C = pc->p[0] + (Geom::Point)(pc->p[0] - pc->p[1]); + C = pc->green_curve->last_segment()->finalPoint() + (1./3)* (Geom::Point)(pc->green_curve->last_segment()->initialPoint() - pc->green_curve->last_segment()->finalPoint()); D = pc->green_curve->last_segment()->finalPoint(); previous->moveto(A); previous->curveto(B, C, D); - //we eliminate the last segment - pc->green_curve->backspace(); - //and we add it again with the recreation - pc->green_curve->append_continuous(previous, 0.0625); + + if( pc->green_curve->get_segment_count() == 1){ + pc->green_curve = previous; + }else{ + //we eliminate the last segment + pc->green_curve->backspace(); + //and we add it again with the recreation + pc->green_curve->append_continuous(previous, 0.0625); + } } pen_redraw_all(pc); @@ -1514,103 +1486,114 @@ static void spiro_color(SPPenContext *const pc) sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(pc->red_bpath), pc->red_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); } -//Combierte el el último nodo a CUSP -static void spiro_node_cusp (SPPenContext *const pc) -{ - if(pc->green_curve->is_empty()) - return; - Geom::Point P0(0,0); - Geom::Point P1(0,0); - Geom::Point P2(0,0); - Geom::Point P3(0,0); - Geom::CubicBezier const * cubic = dynamic_cast( pc->green_curve->last_segment()); - if(cubic){ - P0 = (*cubic)[0]; - P1 = (*cubic)[1]; - P2 = (*cubic)[3]; - P3 = (*cubic)[3]; - } - pc->p[0] + P3; - pc->p[1] = P3 - (1./3)*(Geom::Point)( P0 - P3 ); - SPCurve * last = new SPCurve(); - last->moveto(P0); - last->curveto(P1,P2,P3); - if( pc->green_curve->get_segment_count() == 1){ - pc->green_curve = last; - }else{ - pc->green_curve->backspace(); - pc->green_curve->append_continuous(last, 0.0625); - } -} -//Combierte el el último nodo a SYMM -//Solo se ejecuta al final de el evento release button -static void spiro_node_symm(SPPenContext *const pc) +//Preparamos la curva roja para que se muestre según esté pulsada la tecla SHIFT +static void spiro_prepare(SPPenContext *const pc, bool Shift) { - //Si empezamos sobre una curva ya existente - if(pc->green_curve->is_empty() && pc->sa && !pc->sa->curve->is_empty()){ - Geom::CubicBezier const * cubic; - if (pc->sa->start) { - cubic = dynamic_cast( pc->sa->curve->first_segment() ); - if ( cubic ) { - pc->p[1] = (pc->p[0]-(*cubic)[1]) + pc->p[0]; + if(Shift){ + //Creamos un nodo CUSP + pc->npoints = 5; + pc->p[2] = pc->p[3]; + //Si empezamos sobre otra curva en modo cusp la alteramos para que no tenga manejador final + //recreando la curva e igualando el punto del manejador al punto fiinal de la curva + if(pc->anchor_statusbar && pc->sa && !pc->sa->curve->is_empty() && !pc->ea && pc->green_curve->is_empty()){ + bool reverse = false; + Geom::CubicBezier const * cubic; + if(pc->sa->start){ + reverse = true; + pc->sa->curve = reverse_then_reset(pc->sa->curve); } - }else{ - cubic = dynamic_cast( pc->sa->curve->last_segment() ); - if ( cubic ) { - pc->p[1] = (pc->p[0]-(*cubic)[2]) + pc->p[0]; + Geom::Point P0(0,0); + Geom::Point P1(0,0); + Geom::Point P2(0,0); + Geom::Point P3(0,0); + Geom::Point P4(0,0); + cubic = dynamic_cast( pc->sa->curve->last_segment()); + if(cubic){ + P0 = pc->sa->curve->last_segment()->initialPoint(); + P1 = (*cubic)[1]; + P3 = pc->sa->curve->last_segment()->finalPoint(); + P2 = P3; + }else{ + P0 = pc->sa->curve->last_segment()->initialPoint(); + P1 = P0; + P3 = pc->sa->curve->last_segment()->finalPoint(); + P2 = P3; + } + SPCurve * last = new SPCurve(); + last->moveto(P0); + last->curveto(P1,P2,P3); + if( pc->sa->curve->get_segment_count() == 1){ + pc->sa->curve = last; + }else{ + pc->sa->curve->backspace(); + pc->sa->curve->append_continuous(last, 0.0625); + } + if(reverse){ + pc->sa->curve = reverse_then_reset(pc->sa->curve); } + delete last; } - } - //Cuando cerramos el segmento - if (!pc->green_curve->is_empty()){ - Geom::Point P0(0,0); - Geom::Point P1(0,0); - Geom::Point P2(0,0); - Geom::Point P3(0,0); - Geom::CubicBezier const * cubic = dynamic_cast( pc->green_curve->last_segment()); - if(cubic){ - P0 = (*cubic)[0]; - P1 = (*cubic)[1]; - P2 = (*cubic)[3] + (1./3)*((*cubic)[0] - (*cubic)[3]); - P3 = (*cubic)[3]; - }else{ - P0 = pc->green_curve->last_segment()->initialPoint(); - P1 = P0; - P3 = pc->green_curve->last_segment()->finalPoint(); - P2 = P3 + (1./3)*(P0 - P3); + + }else{ + //Symm nodo + using Geom::X; + using Geom::Y; + Geom::CubicBezier const * cubic; + + //Damos valores a los puntos de la curva roja para que generen un nodo SYMM + if(!pc->red_curve->is_empty()){ + pc->npoints = 5; + //Les damos valor + pc->p[0] = pc->red_curve->first_segment()->initialPoint(); + pc->p[3] = pc->red_curve->first_segment()->finalPoint(); + pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); + pc->p[4] = pc->p[3] + (Geom::Point)( pc->p[3] - pc->p[2] ); + pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]); } - pc->p[1] = pc->p[0] + (Geom::Point)( pc->p[0] - P2 ); - SPCurve * last = new SPCurve(); - last->moveto(P0); - last->curveto(P1,P2,P3); - if( pc->green_curve->get_segment_count() == 1){ - pc->green_curve = last; - }else{ - pc->green_curve->backspace(); - pc->green_curve->append_continuous(last, 0.0625); + //Continuamos la curva en modo SPIRO + if(pc->anchor_statusbar && pc->sa && !pc->sa->curve->is_empty() && !pc->ea && pc->green_curve->is_empty()){ + cubic = dynamic_cast( pc->sa->curve->last_segment()); + if (pc->sa->start) { + cubic = dynamic_cast( pc->sa->curve->create_reverse()->last_segment() ); + } + if(cubic){ + pc->p[1] = (pc->p[0] - (*cubic)[2]) + pc->p[0]; + } } - } - //por si cerramos la curva - if(pc->ea && !pc->ea->curve->is_empty()){ - Geom::CubicBezier const * cubic; - if(pc->ea->start){ - cubic = dynamic_cast( pc->ea->curve->first_segment()); + //Nos aseguramos que el primer nodo sea SYMM con el ultimo segmento de la curva verde + if(!pc->green_curve->is_empty()){ + cubic = dynamic_cast( pc->green_curve->last_segment()); + if(cubic && (*cubic)[2] != (*cubic)[3]){ + pc->p[1] = (pc->p[0] - (*cubic)[2]) + pc->p[0]; + } + } + + //Si cerramos sobre otra curva ponemos simetrico a esta el manejador del punto de cierre + if(pc->ea && !pc->ea->curve->is_empty()){ + cubic = dynamic_cast( pc->ea->curve->last_segment() ); + if (pc->ea->start) { + cubic = dynamic_cast( pc->ea->curve->create_reverse()->last_segment() ); + } if(cubic){ - pc->p[2] = pc->p[3] + (Geom::Point)( pc->p[3] - (*cubic)[1] ); + pc->p[2] = (pc->p[3]-(*cubic)[2]) + pc->p[3]; } - }else{ - cubic = dynamic_cast( pc->ea->curve->last_segment()); + } + //Lo mismpo pero cerrando sobre la curva inicial + if(pc->green_anchor && pc->green_anchor->active){ + cubic = dynamic_cast( pc->green_curve->first_segment() ); if(cubic){ - pc->p[2] = pc->p[3] + (Geom::Point)( pc->p[3] - (*cubic)[2] ); + pc->p[2] = (pc->p[3]-(*cubic)[1]) + pc->p[3]; } } + } + spiro_build(pc); } -//preparates the curves for its trasformation into spiro curves. -//Parámetro opcional que indica si la curva se cierra en que modo lo hace Cusp o Symm -static void spiro_build(SPPenContext *const pc, bool Shift) + +//Unimos todas las curvas en juego y llamamos a la función doEffect. +static void spiro_build(SPPenContext *const pc) { //We create the base curve SPCurve *curve = new SPCurve(); @@ -1622,49 +1605,23 @@ static void spiro_build(SPPenContext *const pc, bool Shift) } } //We add also the green curve - if (!pc->green_curve->is_empty()) { + if (!pc->green_curve->is_empty()) curve->append_continuous(pc->green_curve, 0.0625); - } + //and the red one - if (!pc->red_curve->is_empty()) { - //we add the curve to the modified values - if(!Shift){ - if(pc->ea && !pc->ea->curve->is_empty()){ - Geom::CubicBezier const * cubic; - if(pc->ea->start){ - cubic = dynamic_cast( pc->ea->curve->first_segment()); - if(cubic){ - pc->p[2] = pc->p[3] + (Geom::Point)( pc->p[3] - (*cubic)[1] ); - } - }else{ - cubic = dynamic_cast( pc->ea->curve->last_segment()); - if(cubic){ - pc->p[2] = pc->p[3] + (Geom::Point)( pc->p[3] - (*cubic)[2] ); - } - } - } else if(pc->green_anchor && pc->green_anchor->active){ - Geom::CubicBezier const * cubic; - cubic = dynamic_cast( pc->green_curve->first_segment()); - if(cubic){ - pc->p[2] = pc->p[3] + (Geom::Point)( pc->p[3] - (*cubic)[1] ); - } - } - if(pc->p[2] != pc->p[3]){ - pc->red_curve->reset(); - pc->npoints = 5; - pc->red_curve->moveto(pc->p[0]); - pc->red_curve->curveto(pc->p[1],pc->p[2],pc->p[3]); - } + if (!pc->red_curve->is_empty()){ + pc->red_curve->reset(); + pc->red_curve->moveto(pc->p[0]); + pc->red_curve->curveto(pc->p[1],pc->p[2],pc->p[3]); + curve->append_continuous(pc->red_curve, 0.0625); + } + + if(!pc->sa && pc->ea && !pc->ea->curve->is_empty()){ + if (pc->ea->start) { + curve->append_continuous(pc->ea->curve, 0.0625); }else{ - if((pc->ea && !pc->ea->curve->is_empty()) || (pc->green_anchor && pc->green_anchor->active)){ - pc->p[2] == pc->p[3]; - pc->red_curve->reset(); - pc->npoints = 5; - pc->red_curve->moveto(pc->p[0]); - pc->red_curve->curveto(pc->p[1],pc->p[2],pc->p[3]); - } + curve->append_continuous(pc->ea->curve->create_reverse(), 0.0625); } - curve->append_continuous(pc->red_curve, 0.0625); } if(!curve->is_empty()){ //cerramos la curva si estan cerca los puntos finales de la curva spiro @@ -1675,7 +1632,7 @@ static void spiro_build(SPPenContext *const pc, bool Shift) //For example //using namespace Inkscape::LivePathEffect; //LivePathEffectObject *lpeobj = static_cast (curve); - //Effect *spr = static_cast ( new LPESpiro(lpeobj) ); + //Effect *spr = static_cast ( new LPEspiro(lpeobj) ); //spr->doEffect(curve); spiro_doEffect(curve); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->blue_bpath), curve); @@ -1805,95 +1762,70 @@ static void spiro_doEffect(SPCurve * curve) g_free (path); } -//Combierte el el último nodo a CUSP -//Crea una curva en el punto final de la green_curve -static void bspline_node_cusp(SPPenContext *const pc) +//Unimos todas las curvas en juego y llamamos a la función doEffect. +static void bspline_prepare(SPPenContext *const pc, bool Shift) { - - if (!pc->green_curve->is_empty()){ - using Geom::X; - using Geom::Y; - Geom::Point P0(0,0); - Geom::Point P1(0,0); - Geom::Point P2(0,0); - Geom::Point P3(0,0); - P0 = pc->green_curve->last_segment()->initialPoint(); - P1 = P0; - P3 = pc->green_curve->last_segment()->finalPoint(); - P2 = P3 + (1./3)*(P0 - P3); - P2 = Geom::Point(P2[X]+1,P2[Y]+1); - pc->p[0] = P3; - pc->p[1] = P3; - SPCurve * last = new SPCurve(); - last->moveto(P0); - last->curveto(P1, P2,P3); - if( pc->green_curve->get_segment_count() == 1){ - pc->green_curve = last; - }else{ - pc->green_curve->backspace(); - pc->green_curve->append_continuous(last, 0.0625); + if(!Shift){ + //Modo Bspline formado por nodos CUSP + if (pc->npoints == 5){ + pc->npoints = 2; + pc->p[1]= pc->p[3]; } - } - if (pc->sa && !pc->sa->curve->is_empty() && pc->green_curve->get_segment_count() == 1){ + }else{ + //NODO CUSP formado por nodo SMOOTH + //solo mobemos el manejador del nodo final de cada segmento + //Es suficiente para mostrar el nodo como CUSP using Geom::X; using Geom::Y; - if(pc->sa->start){ - pc->sa->curve = reverse_then_reset(pc->sa->curve); + bool reverse = false; + //Usamos 5 puntos + if(pc->npoints == 2){ + pc->npoints = 5; } - Geom::Point P0(0,0); - Geom::Point P1(0,0); - Geom::Point P2(0,0); - Geom::Point P3(0,0); - P0 = pc->sa->curve->last_segment()->initialPoint(); - P1 = P0; - P3 = pc->sa->curve->last_segment()->finalPoint(); - P2 = P3 + (1./3)*(P0 - P3); - P2 = Geom::Point(P2[X]+1,P2[Y]+1); - pc->p[0] = P3; - pc->p[1] = P3; - SPCurve * last = new SPCurve(); - last->moveto(P0); - last->curveto(P1,P2,P3); - if( pc->sa->curve->get_segment_count() == 1){ - pc->sa->curve = last; - }else{ - pc->sa->curve->backspace(); - pc->sa->curve->append_continuous(last, 0.0625); + pc->p[1] = pc->p[0]; + //Les damos valor + pc->p[3] = pc->red_curve->first_segment()->finalPoint(); + pc->p[4] = pc->p[3]; + pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); + + //Si empezamos sobre otra curva hay que modificarla para que tenga manejador en el último nodo + if(pc->anchor_statusbar && pc->sa && !pc->sa->curve->is_empty() && !pc->ea && pc->green_curve->is_empty()){ + if(pc->sa->start){ + reverse = true; + pc->sa->curve = reverse_then_reset(pc->sa->curve); + } + Geom::Point P0(0,0); + Geom::Point P1(0,0); + Geom::Point P2(0,0); + Geom::Point P3(0,0); + Geom::Point P4(0,0); + P0 = pc->sa->curve->last_segment()->initialPoint(); + P1 = P0; + P3 = pc->sa->curve->last_segment()->finalPoint(); + P2 = P3 + (1./3)*(P0 - P3); + SPCurve * last = new SPCurve(); + last->moveto(P0); + last->curveto(P1,P2,P3); + if( pc->sa->curve->get_segment_count() == 1){ + pc->sa->curve = last; + }else{ + pc->sa->curve->backspace(); + pc->sa->curve->append_continuous(last, 0.0625); + } + if(reverse){ + pc->sa->curve = reverse_then_reset(pc->sa->curve); + } + delete last; } } - //Lo ejacutamos para que se actualize tosa la curva por un fallo de redibujo - bspline_build(pc,true); +bspline_build(pc); } -//Combierte el el último nodo a SYMM -//crea lineas rectas -static void bspline_node(SPPenContext *const pc) -{ - if (!pc->green_curve->is_empty()){ - Geom::Point P0(0,0); - Geom::Point P1(0,0); - P0 = pc->green_curve->last_segment()->initialPoint(); - P1 = pc->green_curve->last_segment()->finalPoint(); - pc->p[1] = P1; - pc->p[0] = P1; - SPCurve * last = new SPCurve(); - last->moveto(P0); - last->lineto(P1); - if( pc->green_curve->get_segment_count() == 1){ - pc->green_curve = last; - }else{ - pc->green_curve->backspace(); - pc->green_curve->append_continuous(last, 0.0625); - } - } -} //preparates the curves for its trasformation into BSline curves. -static void bspline_build(SPPenContext *const pc, bool Shift) +static void bspline_build(SPPenContext *const pc) { - if (pc->green_curve->is_empty() && !pc->sa) - return; //We create the base curve SPCurve *curve = new SPCurve(); //If we continuate the existing curve we add it at the start @@ -1904,31 +1836,28 @@ static void bspline_build(SPPenContext *const pc, bool Shift) } } //We add also the green curve - if (!pc->green_curve->is_empty()) { + if (!pc->green_curve->is_empty()) curve->append_continuous(pc->green_curve, 0.0625); - } + //and the red one - if (!pc->red_curve->is_empty()) { - //we add the curve to the modified values - if((pc->ea && !pc->ea->curve->is_empty()) || (pc->green_anchor && pc->green_anchor->active)){ - if(Shift){ - using Geom::X; - using Geom::Y; - pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); - pc->p[2] = Geom::Point(pc->p[2][X]+1,pc->p[2][Y]+1); - pc->red_curve->reset(); - pc->npoints = 5; - pc->red_curve->moveto(pc->p[0]); - pc->red_curve->curveto(pc->p[1],pc->p[2],pc->p[3]); - }else{ - pc->red_curve->reset(); - pc->npoints = 2; - pc->red_curve->moveto(pc->p[0]); - pc->red_curve->lineto(pc->red_curve->first_segment()->finalPoint()); - } + if (!pc->red_curve->is_empty()){ + pc->red_curve->reset(); + pc->red_curve->moveto(pc->p[0]); + if(pc->npoints == 2){ + pc->red_curve->lineto(pc->p[1]); + }else{ + pc->red_curve->curveto(pc->p[1],pc->p[2],pc->p[3]); } curve->append_continuous(pc->red_curve, 0.0625); } + + if(!pc->sa && pc->ea && !pc->ea->curve->is_empty()){ + if (pc->ea->start) { + curve->append_continuous(pc->ea->curve, 0.0625); + }else{ + curve->append_continuous(pc->ea->curve->create_reverse(), 0.0625); + } + } if(curve->get_segment_count() > 1 ){ //cerramos la curva si estan cerca los puntos finales de la curva spiro if(Geom::are_near(curve->first_path()->initialPoint(), curve->last_path()->finalPoint())){ @@ -1938,7 +1867,7 @@ static void bspline_build(SPPenContext *const pc, bool Shift) //For example //using namespace Inkscape::LivePathEffect; //LivePathEffectObject *lpeobj = static_cast (curve); - //Effect *spr = static_cast ( new LPEBspline(lpeobj) ); + //Effect *spr = static_cast ( new LPEbspline_prepare(lpeobj) ); //spr->doEffect(curve); bspline_doEffect(curve); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->blue_bpath), curve); @@ -1951,7 +1880,7 @@ static void bspline_build(SPPenContext *const pc, bool Shift) sp_canvas_item_hide(pc->cl1); sp_canvas_item_hide(pc->c0); sp_canvas_item_hide(pc->cl0); - }else { + }else{ //if the curve is empty sp_canvas_item_hide(pc->blue_bpath); } @@ -1965,167 +1894,174 @@ static void bspline_doEffect(SPCurve * curve) // Make copy of old path as it is changed during processing Geom::PathVector const original_pathv = curve->get_pathvector(); curve->reset(); - int ip = 0; //Sbasis - Geom::D2< Geom::SBasis > curveIn; - Geom::D2< Geom::SBasis > curveOut; - Geom::D2< Geom::SBasis > rectCurve; - Geom::D2< Geom::SBasis > rectCurveExtra; - //Puntos a usar. Ponemos todos los posibles para hacer más inteligible el código - Geom::Point startAnchor(0,0); - Geom::Point previousAnchor(0,0); - Geom::Point anchor(0,0); - Geom::Point previousSBasis0(0,0); - Geom::Point previousSBasis1(0,0); - Geom::Point previousSBasis2(0,0); - //Geom::Point previousSBasis3(0,0); - Geom::Point SBasis0(0,0); - Geom::Point SBasis1(0,0); - Geom::Point SBasis2(0,0); - Geom::Point SBasis3(0,0); - //Geom::Point nextSBasis0(0,0); - Geom::Point nextSBasis1(0,0); - Geom::Point nextSBasis2(0,0); - Geom::Point nextSBasis3(0,0); + Geom::D2< Geom::SBasis > SBasisIn; + Geom::D2< Geom::SBasis > SBasisOut; + Geom::D2< Geom::SBasis > SBasisEnd; + Geom::D2< Geom::SBasis > SBasisHelper; + //curves + SPCurve * in = new SPCurve(); + SPCurve * out = new SPCurve(); + SPCurve * end = new SPCurve(); //Curvas temporales - SPCurve *BSplineRectTemp = new SPCurve(); - SPCurve *BSplineCurveTemp = new SPCurve(); - SPCurve *BSplinePreviousCurveTemp = new SPCurve(); + SPCurve *lineHelper = new SPCurve(); + SPCurve *curveHelper = new SPCurve(); + SPCurve *nCurve = new SPCurve(); + //Puntos a usar. Ponemos todos los posibles para hacer más inteligible el código + Geom::Point startNode(0,0); + Geom::Point previousNode(0,0); + Geom::Point node(0,0); + Geom::Point previousPointAt0(0,0); + Geom::Point previousPointAt1(0,0); + Geom::Point previousPointAt2(0,0); + //Geom::Point previousPointAt3(0,0); + Geom::Point pointAt0(0,0); + Geom::Point pointAt1(0,0); + Geom::Point pointAt2(0,0); + Geom::Point pointAt3(0,0); + //Geom::Point nextPointAt0(0,0); + Geom::Point nextPointAt1(0,0); + Geom::Point nextPointAt2(0,0); + Geom::Point nextPointAt3(0,0); + //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { //Si está vacío... if (path_it->empty()) continue; - //Declaramos las variables - //Itreador + //Itreadores Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve - Geom::Path::const_iterator curve_end = path_it->end(); // last curve + Geom::Path::const_iterator curve_end = path_it->end(); // end curve Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop - //por defecto la linea es recta. - //Para formar las bsplines contamos que si el nodo es cusp -sin manejadores - //se calcula el nodo resultante como BSpline. Si por el contrario tiene un manejador - //en el últimp punto de la cuva (pc->p[2]) calculamos la curva resultante para que forme un nodo cusp - bool is_line = true; - bool previous_is_line = true; - if (path_it->closed()) { - SBasis2 = curve_it1->toSBasis().valueAt(0.3334); - nextSBasis1 = curve_end->toSBasis().valueAt(0.6664); - BSplineRectTemp->moveto(nextSBasis1); - BSplineRectTemp->lineto(SBasis2); - startAnchor = BSplineRectTemp->first_segment()->toSBasis().valueAt(0.5); - anchor = startAnchor; - BSplineRectTemp->reset(); + //Las lineas rectas forman nodos BSpline + //Las curvas forman nodos CUSP + bool isBSpline = true; + //Creamos las lineas rectas que unen todos los puntos del trazado y donde se calcularán + //los puntos clave para los manejadores. + //Esto hace que la curva BSpline no pierda su condición aunque se trasladen + //dichos manejadores + in->moveto(curve_it1->initialPoint()); + in->lineto(curve_it1->finalPoint()); + out->moveto(curve_it2->initialPoint()); + out->lineto(curve_it2->finalPoint()); + //este no cambia. + end->moveto(curve_end->initialPoint()); + end->lineto(curve_end->finalPoint()); + //Si la curva está cerrada calculamos el punto donde + //deveria estar el nodo BSpline de cierre/inicio de la curva + //en posible caso de que se cierre con una linea recta creando un nodo BSPline + if (path_it->closed() && is_straight_curve(*curve_end)) { + //Calculamos el nodo de inicio BSpline + SBasisIn = in->first_segment()->toSBasis(); + SBasisEnd = end->first_segment()->toSBasis(); + lineHelper->moveto(SBasisIn.valueAt(0.3334)); + lineHelper->lineto(SBasisEnd.valueAt(0.6664)); + SBasisHelper = lineHelper->first_segment()->toSBasis(); + lineHelper->reset(); + //Guardamos el principio de la curva + startNode = SBasisHelper.valueAt(0.5); + //Definimos el punto de inicio original de la curva resultante + node = startNode; + }else{ + //Guardamos el principio de la curva + startNode = in->first_segment()->initialPoint(); + //Definimos el punto de inicio original de la curva resultante + node = startNode; } + //Recorremos todos los segmentos menos el último while ( curve_it2 != curve_endit ) { - //Calculamos los dos puntos para seleccional el punto central de la línea que los une - curveIn = curve_it1->toSBasis(); - curveOut = curve_it2->toSBasis(); - previousSBasis0 = SBasis0; - previousSBasis1 = SBasis1; - previousSBasis2 = SBasis2; - //previousSBasis3 = SBasis3; - SBasis0 = curveIn.valueAt(0); - SBasis1 = curveIn.valueAt(0.3334); - SBasis2 = curveIn.valueAt(0.6667); - SBasis3 = curveIn.valueAt(1); - //nextSBasis0 = curveOut.valueAt(0); - nextSBasis1 = curveOut.valueAt(0.3334); - nextSBasis2 = curveOut.valueAt(0.6667);; - nextSBasis3 = curveOut.valueAt(1); - //Se forma con la union de dos puntos, el primero está en la curva entrante - // y se conoce dividiendo por tres la curva y seleccionado el - //punto mas cercano de los dos al nodo de union con la curva saliente. - //El otro punto es el puntio más cercano al nodo de union - //de la curva saliente dividida por tres. - BSplineRectTemp->moveto(SBasis2); - BSplineRectTemp->lineto(nextSBasis1); - previousAnchor = anchor; - anchor = BSplineRectTemp->first_segment()->toSBasis().valueAt(0.5); - BSplineRectTemp->reset(); - //Vemos si el nodo es curva - previous_is_line = is_line; - is_line = is_straight_curve(*curve_it1); - if(!is_line && curve->get_segment_count() > 1){ - //Si no es curva convertimos la curva resultante a un nodo cusp - //aberiguamos el punto en donde deveria estar de manera fija - //independientemente de el manejador y movemos - BSplineRectTemp->moveto(SBasis0); - BSplineRectTemp->lineto(SBasis3); - SBasis1 = BSplineRectTemp->first_segment()->toSBasis().valueAt(0.3334); - SBasis2 = BSplineRectTemp->first_segment()->toSBasis().valueAt(0.6667); - BSplineRectTemp->reset(); - BSplineRectTemp->moveto(SBasis1); - BSplineRectTemp->lineto(previousSBasis2); - previousAnchor = BSplineRectTemp->first_segment()->toSBasis().valueAt(0.5); - anchor = SBasis3; - BSplineRectTemp->reset(); - //averiguamos el nuevo vinal de curva entrante recreando de nuevo - //una linea y seleccionando su centro como origen - if(previous_is_line){ - BSplineCurveTemp->moveto(previousAnchor); - BSplineCurveTemp->curveto(SBasis1, SBasis2, anchor); - }else{ - BSplineCurveTemp->moveto(SBasis0); - BSplineCurveTemp->lineto(anchor); - } - BSplineRectTemp->reset(); - - //Como el origen ha cambiado, seleccionamos el ultimo punto - //de la curva ya creada y lo movemos al nuevo origen/final - Geom::CubicBezier const * cubic = dynamic_cast( curve->last_segment()); - if(cubic){ - BSplinePreviousCurveTemp->moveto((*cubic)[0]); - if(previous_is_line){ - BSplinePreviousCurveTemp->curveto((*cubic)[1],(*cubic)[2],previousAnchor); - } else { - BSplinePreviousCurveTemp->curveto((*cubic)[1],(*cubic)[2],curve->last_segment()->finalPoint()); - } - }else{ - BSplinePreviousCurveTemp->moveto(curve->last_segment()->initialPoint()); - BSplinePreviousCurveTemp->lineto(curve->last_segment()->finalPoint()); - } - if( curve->get_segment_count() == 1){ - curve = BSplinePreviousCurveTemp; - }else{ - curve->backspace(); - curve->append_continuous(BSplinePreviousCurveTemp, 0.0625); - } - BSplinePreviousCurveTemp->reset(); - }else{ - //Creamos la curva correspondiente a la posición actual del - //Iterador, para anexarla a la curva de salida - //almacena la SPCurve de un solo segmento que se va añadir al resiultado final - //en la itineración - if (ip == 0 && !path_it->closed()){ - BSplineCurveTemp->moveto(SBasis0); - }else{ - //Empezamos la curva el el final de la anterior curva - BSplineCurveTemp->moveto(previousAnchor); - } - BSplineCurveTemp->curveto(SBasis1, SBasis2, anchor); + //Damos valor a el objeto SBasis para el path de entrada y el de salida + SBasisIn = in->first_segment()->toSBasis(); + SBasisOut = out->first_segment()->toSBasis(); + //Damos valor a los puntos calculados en el anterior paso del bucle + previousPointAt0 = pointAt0; + previousPointAt1 = pointAt1; + previousPointAt2 = pointAt2; + //previousPointAt3 = pointAt3; + //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida + pointAt0 = SBasisIn.valueAt(0); + pointAt1 = SBasisIn.valueAt(0.3334); + pointAt2 = SBasisIn.valueAt(0.6667); + pointAt3 = SBasisIn.valueAt(1); + //Y hacemos lo propio con el path de salida + //nextPointAt0 = curveOut.valueAt(0); + nextPointAt1 = SBasisOut.valueAt(0.3334); + nextPointAt2 = SBasisOut.valueAt(0.6667);; + nextPointAt3 = SBasisOut.valueAt(1); + //La curva BSpline se forma calculando el centro del segmanto de unión + //de el punto situado en las 2/3 partes de el segmento de entrada + //con el punto situado en la posición 1/3 del segmento de salida + //Estos dos puntos ademas estan posicionados en el lugas correspondiente de + //los manejadores de la curva + lineHelper->moveto(pointAt2); + lineHelper->lineto(nextPointAt1); + SBasisHelper = lineHelper->first_segment()->toSBasis(); + lineHelper->reset(); + //almacenamos el punto del anterior bucle -o el de cierre- que nos hara de principio de curva + previousNode = node; + //Y este hará de final de curva + node = SBasisHelper.valueAt(0.5); + //Vemos si el nodo es BSpline o CUSP + //Averiguamos si el path de entrada es recto o tiene manejadores + isBSpline = is_straight_curve(*curve_it1); + //Si no es recto, tenemos que generar la curva con nodo final CUSP + if(!isBSpline ){ + //Definimos como nodo el final del segmento de entrada + node = pointAt3; } - curve->append_continuous(BSplineCurveTemp, 0.0625); - BSplineCurveTemp->reset(); + curveHelper->moveto(previousNode); + curveHelper->curveto(pointAt1, pointAt2, node); + //añadimos la curva generada a la curva pricipal + nCurve->append_continuous(curveHelper, 0.0625); + curveHelper->reset(); + //aumentamos los valores para el siguiente paso en el bucle ++curve_it1; ++curve_it2; - ip++; + in->reset(); + in->moveto(curve_it1->initialPoint()); + in->lineto(curve_it1->finalPoint()); + out->reset(); + if(curve_it1 != curve_end){ + out->moveto(curve_it2->initialPoint()); + out->lineto(curve_it2->finalPoint()); + } } - //terminamos el trazado - BSplineCurveTemp->moveto(anchor); - is_line = is_straight_curve(*curve_it1); - if (path_it->closed() && is_line) { - BSplineCurveTemp->curveto(nextSBasis1, nextSBasis2, startAnchor); + //Aberiguamos la ultima parte de la curva correspondiente al último segmento + curveHelper->moveto(node); + //Si está cerrada la curva, la cerramos sobre el valor guardado previamente + //Si no finalizamos en el punto final + if (path_it->closed()) { + curveHelper->curveto(nextPointAt1, nextPointAt2, startNode); }else{ - BSplineCurveTemp->curveto(nextSBasis1, nextSBasis2, nextSBasis3); + curveHelper->curveto(nextPointAt1, nextPointAt2, nextPointAt3); } - curve->append_continuous(BSplineCurveTemp, 0.0625); - BSplineCurveTemp->reset(); + //añadimos este último segmento + nCurve->append_continuous(curveHelper, 0.0625); + //y cerramos la curva if (path_it->closed()) { - curve->closepath_current(); + nCurve->closepath_current(); } - } + curve->append(nCurve,false); + nCurve->reset(); + //Limpiamos + in->reset(); + out->reset(); + end->reset(); + lineHelper->reset(); + curveHelper->reset(); + } + delete in; + delete out; + delete end; + delete lineHelper; + delete curveHelper; + //Todo: remove? + //delete SBasisIn; + //delete SBasisOut; + //delete SBasisEnd; + //delete SBasisHelper; } //BSpline end @@ -2235,6 +2171,14 @@ static void spdc_pen_finish_segment(SPPenContext *const pc, Geom::Point const p, ++pc->num_clicks; if (!pc->red_curve->is_empty()) { + //BSpline + if(pc->spiro){ + spiro_prepare(pc, (state & GDK_SHIFT_MASK)); + } + if(pc->bspline){ + bspline_prepare(pc, (state & GDK_SHIFT_MASK)); + } + //BSpline End pc->green_curve->append_continuous(pc->red_curve, 0.0625); SPCurve *curve = pc->red_curve->copy(); /// \todo fixme: diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp index 19a040b24..32248d9b6 100644 --- a/src/pencil-context.cpp +++ b/src/pencil-context.cpp @@ -780,7 +780,14 @@ interpolate(SPPencilContext *pc) /* Fit and draw and reset state */ pc->green_curve->moveto(b[0]); for (int c = 0; c < n_segs; c++) { - pc->green_curve->curveto(b[4*c+1], b[4*c+2], b[4*c+3]); + //BSpline + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + guint mode = prefs->getInt("/tools/freehand/pencil/freehand-mode", 0); + if(mode == 2){ + pc->green_curve->lineto(b[4*c+3]); + }else{ + pc->green_curve->curveto(b[4*c+1], b[4*c+2], b[4*c+3]); + } } sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), pc->green_curve); @@ -920,7 +927,15 @@ fit_and_split(SPPencilContext *pc) /* Fit and draw and reset state */ pc->red_curve->reset(); pc->red_curve->moveto(b[0]); - pc->red_curve->curveto(b[1], b[2], b[3]); + //BSpline + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + guint mode = prefs->getInt("/tools/freehand/pencil/freehand-mode", 0); + if(mode == 2){ + pc->red_curve->lineto(b[3]); + }else{ + pc->red_curve->curveto(b[1], b[2], b[3]); + } + //BSpline End sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), pc->red_curve); pc->red_curve_is_valid = true; } else { -- cgit v1.2.3 From d395af6ee332142c63355d008d49b1f4b3487dfe Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 24 Dec 2012 08:05:24 +0100 Subject: Going to merge (bzr r11950.1.5) --- src/live_effects/lpe-bspline.cpp | 226 ++++++++++++++++++++++++++ src/live_effects/lpe-bspline.h | 35 ++++ src/pen-context.cpp | 342 +++++++++++++++++++++------------------ 3 files changed, 444 insertions(+), 159 deletions(-) create mode 100644 src/live_effects/lpe-bspline.cpp create mode 100644 src/live_effects/lpe-bspline.h (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp new file mode 100644 index 000000000..e125cc4e0 --- /dev/null +++ b/src/live_effects/lpe-bspline.cpp @@ -0,0 +1,226 @@ +#define INKSCAPE_LPE_BSPLINE_C + +/* + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "live_effects/lpe-bspline.h" + +#include "display/curve.h" +#include +#include <2geom/pathvector.h> +#include <2geom/affine.h> +#include <2geom/bezier-curve.h> +#include "helper/geom-curves.h" + +// For handling un-continuous paths: +#include "message-stack.h" +#include "inkscape.h" +#include "desktop.h" + +namespace Inkscape { +namespace LivePathEffect { + +LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) : + Effect(lpeobject) +{ +} + +LPEBSpline::~LPEBSpline() +{ +} +//Crea una nueva curva reseteando la original +SPCurve * +LPEBSpline::reverse_then_reset(SPCurve * orig){ + SPCurve *ret = orig->create_reverse(); + orig->reset(); + return ret; +} + +void +LPEBSpline::doEffect(SPCurve * curve) +{ + using Geom::X; + using Geom::Y; + + // Make copy of old path as it is changed during processing + Geom::PathVector const original_pathv = curve->get_pathvector(); + curve->reset(); + //Sbasis + Geom::D2< Geom::SBasis > SBasisIn; + Geom::D2< Geom::SBasis > SBasisOut; + Geom::D2< Geom::SBasis > SBasisEnd; + Geom::D2< Geom::SBasis > SBasisHelper; + //curves + SPCurve * in = new SPCurve(); + SPCurve * out = new SPCurve(); + SPCurve * end = new SPCurve(); + //Curvas temporales + SPCurve *lineHelper = new SPCurve(); + SPCurve *curveHelper = new SPCurve(); + SPCurve *nCurve = new SPCurve(); + //Puntos a usar. Ponemos todos los posibles para hacer más inteligible el código + Geom::Point startNode(0,0); + Geom::Point previousNode(0,0); + Geom::Point node(0,0); + //Geom::Point previousPointAt3(0,0); + Geom::Point pointAt0(0,0); + Geom::Point pointAt1(0,0); + Geom::Point pointAt2(0,0); + Geom::Point pointAt3(0,0); + //Geom::Point nextPointAt0(0,0); + Geom::Point nextPointAt1(0,0); + Geom::Point nextPointAt2(0,0); + Geom::Point nextPointAt3(0,0); + + //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo + for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { + //Si está vacío... + if (path_it->empty()) + continue; + //Itreadores + Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve + Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve + Geom::Path::const_iterator curve_end = path_it->end(); // end curve + Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop + //Las lineas rectas forman nodos BSpline + //Las curvas forman nodos CUSP + bool isBSpline = true; + //Creamos las lineas rectas que unen todos los puntos del trazado y donde se calcularán + //los puntos clave para los manejadores. + //Esto hace que la curva BSpline no pierda su condición aunque se trasladen + //dichos manejadores + in->moveto(curve_it1->initialPoint()); + in->lineto(curve_it1->finalPoint()); + out->moveto(curve_it2->initialPoint()); + out->lineto(curve_it2->finalPoint()); + //este no cambia. + end->moveto(curve_end->initialPoint()); + end->lineto(curve_end->finalPoint()); + //Si la curva está cerrada calculamos el punto donde + //deveria estar el nodo BSpline de cierre/inicio de la curva + //en posible caso de que se cierre con una linea recta creando un nodo BSPline + if (path_it->closed() && is_straight_curve(*curve_end)) { + //Calculamos el nodo de inicio BSpline + SBasisIn = in->first_segment()->toSBasis(); + SBasisEnd = end->first_segment()->toSBasis(); + lineHelper->moveto(SBasisIn.valueAt(0.3334)); + lineHelper->lineto(SBasisEnd.valueAt(0.6664)); + SBasisHelper = lineHelper->first_segment()->toSBasis(); + lineHelper->reset(); + //Guardamos el principio de la curva + startNode = SBasisHelper.valueAt(0.5); + //Definimos el punto de inicio original de la curva resultante + node = startNode; + }else{ + //Guardamos el principio de la curva + startNode = in->first_segment()->initialPoint(); + //Definimos el punto de inicio original de la curva resultante + node = startNode; + } + //Recorremos todos los segmentos menos el último + while ( curve_it2 != curve_endit ) + { + //Damos valor a el objeto SBasis para el path de entrada y el de salida + SBasisIn = in->first_segment()->toSBasis(); + SBasisOut = out->first_segment()->toSBasis(); + //previousPointAt3 = pointAt3; + //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida + pointAt0 = SBasisIn.valueAt(0); + pointAt1 = SBasisIn.valueAt(0.3334); + pointAt2 = SBasisIn.valueAt(0.6667); + pointAt3 = SBasisIn.valueAt(1); + //Y hacemos lo propio con el path de salida + //nextPointAt0 = curveOut.valueAt(0); + nextPointAt1 = SBasisOut.valueAt(0.3334); + nextPointAt2 = SBasisOut.valueAt(0.6667);; + nextPointAt3 = SBasisOut.valueAt(1); + //La curva BSpline se forma calculando el centro del segmanto de unión + //de el punto situado en las 2/3 partes de el segmento de entrada + //con el punto situado en la posición 1/3 del segmento de salida + //Estos dos puntos ademas estan posicionados en el lugas correspondiente de + //los manejadores de la curva + lineHelper->moveto(pointAt2); + lineHelper->lineto(nextPointAt1); + SBasisHelper = lineHelper->first_segment()->toSBasis(); + lineHelper->reset(); + //almacenamos el punto del anterior bucle -o el de cierre- que nos hara de principio de curva + previousNode = node; + //Y este hará de final de curva + node = SBasisHelper.valueAt(0.5); + //Vemos si el nodo es BSpline o CUSP + //Averiguamos si el path de entrada es recto o tiene manejadores + isBSpline = is_straight_curve(*curve_it1); + //Si no es recto, tenemos que generar la curva con nodo final CUSP + if(!isBSpline ){ + //Definimos como nodo el final del segmento de entrada + node = pointAt3; + } + curveHelper->moveto(previousNode); + curveHelper->curveto(pointAt1, pointAt2, node); + //añadimos la curva generada a la curva pricipal + nCurve->append_continuous(curveHelper, 0.0625); + curveHelper->reset(); + //aumentamos los valores para el siguiente paso en el bucle + ++curve_it1; + ++curve_it2; + in->reset(); + in->moveto(curve_it1->initialPoint()); + in->lineto(curve_it1->finalPoint()); + out->reset(); + if(curve_it1 != curve_end){ + out->moveto(curve_it2->initialPoint()); + out->lineto(curve_it2->finalPoint()); + } + } + //Aberiguamos la ultima parte de la curva correspondiente al último segmento + curveHelper->moveto(node); + //Si está cerrada la curva, la cerramos sobre el valor guardado previamente + //Si no finalizamos en el punto final + if (path_it->closed()) { + curveHelper->curveto(nextPointAt1, nextPointAt2, startNode); + }else{ + curveHelper->curveto(nextPointAt1, nextPointAt2, nextPointAt3); + } + //añadimos este último segmento + nCurve->append_continuous(curveHelper, 0.0625); + //y cerramos la curva + if (path_it->closed()) { + nCurve->closepath_current(); + } + curve->append(nCurve,false); + nCurve->reset(); + //Limpiamos + in->reset(); + out->reset(); + end->reset(); + lineHelper->reset(); + curveHelper->reset(); + } + delete in; + delete out; + delete end; + delete lineHelper; + delete curveHelper; + //Todo: remove? + //delete SBasisIn; + //delete SBasisOut; + //delete SBasisEnd; + //delete SBasisHelper; +} + + + +}; //namespace LivePathEffect +}; /* namespace Inkscape */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h new file mode 100644 index 000000000..23ac495df --- /dev/null +++ b/src/live_effects/lpe-bspline.h @@ -0,0 +1,35 @@ +#ifndef INKSCAPE_LPE_BSPLINE_H +#define INKSCAPE_LPE_BSPLINE_H + +/* + * Inkscape::LPEBSpline + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "live_effects/effect.h" + + +namespace Inkscape { +namespace LivePathEffect { + +class LPEBSpline : public Effect { +public: + LPEBSpline(LivePathEffectObject *lpeobject); + virtual ~LPEBSpline(); + + virtual LPEPathFlashType pathFlashType() { return SUPPRESS_FLASH; } + + virtual SPCurve *reverse_then_reset(SPCurve * orig); + + virtual void doEffect(SPCurve * curve); + +private: + LPEBSpline(const LPEBSpline&); + LPEBSpline& operator=(const LPEBSpline&); +}; + +}; //namespace LivePathEffect +}; //namespace Inkscape + +#endif diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 6d35d0897..20c95c13f 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -83,23 +83,29 @@ static gint sp_pen_context_root_handler(SPEventContext *ec, GdkEvent *event); static gint sp_pen_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event); static void spdc_pen_set_initial_point(SPPenContext *pc, Geom::Point const p); +/* + *BSpline + *Added functions +*/ -//BSpline -//Added functions -//Sobrecarga la función "sp_pen_context_set_polyline_mode" -//Le da valor a la nueva propiedad "pc->spiro" que como se auto define indica si estamos en modo spiro -//En el futuro se la dará a "pc->bspline" +/* + *Sobrecarga la función "sp_pen_context_set_polyline_mode" + *Le da valor a la nueva propiedad "pc->spiro" que como se auto define indica si estamos en modo spiro + *En el futuro se la dará a "pc->bspline" +*/ static void sp_pen_context_set_mode(SPPenContext *const pc, guint mode); //Esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro static void spiro_color(SPPenContext *const pc); +//Guarda el valor si se ha pulsado la tecla SHIFT al continuar una curva +static bool saShift = false; //Preparamos la curva roja para que se muestre según esté pulsada la tecla SHIFT -static void spiro_prepare(SPPenContext *const pc, bool Shift); +static void spiro(SPPenContext *const pc, bool Shift); //Unimos todas las curvas en juego y llamamos a la función doEffect. static void spiro_build(SPPenContext *const pc); //function spiro cloned from lpe-spiro.cpp static void spiro_doEffect(SPCurve * curve); //Preparamos la curva roja para que se muestre según esté pulsada la tecla SHIFT -static void bspline_prepare(SPPenContext *const pc,bool Shift); +static void bspline(SPPenContext *const pc,bool Shift); //Unimos todas las curvas en juego y llamamos a la función doEffect. static void bspline_build(SPPenContext *const pc); //function bspline cloned from lpe-bspline.cpp @@ -248,13 +254,17 @@ void sp_pen_context_set_polyline_mode(SPPenContext *const pc) { sp_pen_context_set_mode(pc, mode); //BSpline End } + //BSpline -//Set the mode of draw now spiro, and later b-splines +/* +*.Set the mode of draw now spiro, and later b-splines +*/ void sp_pen_context_set_mode(SPPenContext *const pc, guint mode) { pc->spiro = (mode == 1); pc->bspline = (mode == 2); } //BSpline End + /** * Callback to initialize SPPenContext object. */ @@ -637,7 +647,6 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const if (pc->expecting_clicks_for_LPE > 0) { --pc->expecting_clicks_for_LPE; } - return ret; } @@ -768,7 +777,7 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons // snap the handle spdc_endpoint_snap_handle(pc, p, mevent.state); //BSpline - if (!pc->polylines_only && !pc->bspline && !pc->spiro) { + if (!pc->polylines_only && !pc->spiro && !pc->bspline) { //BSpline End spdc_pen_set_ctrl(pc, p, mevent.state); } else { @@ -796,10 +805,10 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons //BSpline if ( Geom::LInfty( event_w - pen_drag_origin_w ) > tolerance || mevent.time == 0) { if(pc->spiro){ - spiro_prepare(pc,(mevent.state & GDK_SHIFT_MASK)); + spiro(pc,(mevent.state & GDK_SHIFT_MASK)); } if(pc->bspline){ - bspline_prepare(pc,(mevent.state & GDK_SHIFT_MASK)); + bspline(pc,(mevent.state & GDK_SHIFT_MASK)); } pen_drag_origin_w = event_w; } @@ -857,10 +866,10 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con } //BSpline if(pc->spiro){ - spiro_prepare(pc,(revent.state & GDK_SHIFT_MASK)); + spiro(pc,(revent.state & GDK_SHIFT_MASK)); } if(pc->bspline){ - bspline_prepare(pc,(revent.state & GDK_SHIFT_MASK)); + bspline(pc,(revent.state & GDK_SHIFT_MASK)); } //BSpline End pc->state = SP_PEN_CONTEXT_CONTROL; @@ -1000,7 +1009,9 @@ static void pen_redraw_all (SPPenContext *const pc) sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), pc->red_curve); // handles - if (pc->p[0] != pc->p[1]) { + //BSpline + if (pc->p[0] != pc->p[1] && !pc->spiro && !pc->bspline) { + //BSpline End SP_CTRL(pc->c1)->moveto(pc->p[1]); pc->cl1->setCoords(pc->p[0], pc->p[1]); sp_canvas_item_show(pc->c1); @@ -1013,9 +1024,11 @@ static void pen_redraw_all (SPPenContext *const pc) Geom::Curve const * last_seg = pc->green_curve->last_segment(); if (last_seg) { Geom::CubicBezier const * cubic = dynamic_cast( last_seg ); + //BSpline if ( cubic && - (*cubic)[2] != pc->p[0] ) + (*cubic)[2] != pc->p[0]&& !pc->spiro && !pc->bspline ) { + //BSpline End Geom::Point p2 = (*cubic)[2]; SP_CTRL(pc->c0)->moveto(p2); pc->cl0->setCoords(p2, pc->p[0]); @@ -1074,15 +1087,16 @@ static void pen_lastpoint_tocurve (SPPenContext *const pc) if (pc->npoints != 5 && !pc->spiro && !pc->bspline) return; //BSpline - - Geom::CubicBezier const * cubic = dynamic_cast( pc->green_curve->last_segment() ); - if ( cubic ) { - pc->p[1] = pc->p[0] + (Geom::Point)( (*cubic)[3] - (*cubic)[2] ); - } else { - pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]); + Geom::CubicBezier const * cubic; + if(!pc->bspline){ + cubic = dynamic_cast( pc->green_curve->last_segment() ); + if ( cubic ) { + pc->p[1] = pc->p[0] + (Geom::Point)( (*cubic)[3] - (*cubic)[2] ); + } else { + pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]); + } } - //BSpline //Para formar una curva necesitamos un nodo symm en el "lastpoint" //de esta manera modificamos el final de la "curva_verde" para que sea symm con el pricipio de la "red_curve" if(pc->spiro){ @@ -1091,6 +1105,8 @@ static void pen_lastpoint_tocurve (SPPenContext *const pc) Geom::Point C(0,0); Geom::Point D(0,0); SPCurve * previous = new SPCurve(); + using Geom::X; + using Geom::Y; //We obtain the last segment 4 points in the previous curve if ( cubic ){ A = (*cubic)[0]; @@ -1103,12 +1119,17 @@ static void pen_lastpoint_tocurve (SPPenContext *const pc) C = pc->p[0] + (Geom::Point)(pc->p[0] - pc->p[1]); D = pc->green_curve->last_segment()->finalPoint(); } + C = Geom::Point(C[X]+1,C[Y]+1); previous->moveto(A); previous->curveto(B, C, D); - //we eliminate the last segment - pc->green_curve->backspace(); - //and we add it again with the recreation - pc->green_curve->append_continuous(previous, 0.0625); + if( pc->green_curve->get_segment_count() == 1){ + pc->green_curve = previous; + }else{ + //we eliminate the last segment + pc->green_curve->backspace(); + //and we add it again with the recreation + pc->green_curve->append_continuous(previous, 0.0625); + } } //Para formar una curva bspline necesitamos un nodo cusp en el "lastpoint" //de esta manera modificamos el final de la "curva_verde" para que sea cusp con el pricipio de la "red_curve" @@ -1142,9 +1163,39 @@ static void pen_lastpoint_toline (SPPenContext *const pc) //Si no es bspline if (pc->npoints != 5 && !pc->bspline) return; - //BSpline End - pc->p[1] = pc->p[0]; - + if(!pc->bspline) + pc->p[1] = pc->p[0]; + if(pc->spiro){ + Geom::Point A(0,0); + Geom::Point B(0,0); + Geom::Point C(0,0); + Geom::Point D(0,0); + SPCurve * previous = new SPCurve(); + Geom::CubicBezier const * cubic = dynamic_cast( pc->green_curve->last_segment() ); + if ( cubic ) { + A = pc->green_curve->last_segment()->initialPoint(); + B = (*cubic)[1]; + C = pc->green_curve->last_segment()->finalPoint(); + D = C; + pc->p[1] = pc->p[0] + (Geom::Point)( (*cubic)[3] - (*cubic)[2] ); + } else { + //We obtain the last segment 4 points in the previous curve + A = pc->green_curve->last_segment()->initialPoint(); + B = A; + C = pc->green_curve->last_segment()->finalPoint(); + D = C; + } + previous->moveto(A); + previous->curveto(B, C, D); + if( pc->green_curve->get_segment_count() == 1){ + pc->green_curve = previous; + }else{ + //we eliminate the last segment + pc->green_curve->backspace(); + //and we add it again with the recreation + pc->green_curve->append_continuous(previous, 0.0625); + } + } //BSpline //Para formar una recta necesitamos un nodo con manejador en el "lastpoint" //de esta manera modificamos el final de la "curva_verde" para que tenga manejador @@ -1153,15 +1204,17 @@ static void pen_lastpoint_toline (SPPenContext *const pc) Geom::Point B(0,0); Geom::Point C(0,0); Geom::Point D(0,0); + using Geom::X; + using Geom::Y; SPCurve * previous = new SPCurve(); //We obtain the last segment 4 points in the previous curve A = pc->green_curve->last_segment()->initialPoint(); B = pc->green_curve->last_segment()->initialPoint(); C = pc->green_curve->last_segment()->finalPoint() + (1./3)* (Geom::Point)(pc->green_curve->last_segment()->initialPoint() - pc->green_curve->last_segment()->finalPoint()); + C = Geom::Point(C[X]+1,C[Y]+1); D = pc->green_curve->last_segment()->finalPoint(); previous->moveto(A); previous->curveto(B, C, D); - if( pc->green_curve->get_segment_count() == 1){ pc->green_curve = previous; }else{ @@ -1332,6 +1385,12 @@ static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) } } else { // Reset red curve + //BSpline + if ((pc->spiro || pc->bspline) && pc->green_curve->get_segment_count()==1) { + pen_cancel (pc); + ret = TRUE; + } + //BSpline End pc->red_curve->reset(); // Destroy topmost green bpath if (pc->green_bpaths) { @@ -1362,6 +1421,15 @@ static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) pc->state = SP_PEN_CONTEXT_POINT; spdc_pen_set_subsequent_point(pc, pt, true); pen_last_paraxial_dir = !pen_last_paraxial_dir; + //BSpline + if(pc->spiro || pc->bspline){ + SPCanvasItem *cshape = sp_canvas_bpath_new(sp_desktop_sketch(pc->desktop), pc->green_curve); + sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cshape), pc->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); + sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(cshape), 0, SP_WIND_RULE_NONZERO); + pc->green_bpaths = g_slist_prepend(pc->green_bpaths, cshape); + pen_redraw_all(pc); + } + //BSpline End ret = TRUE; } break; @@ -1488,71 +1556,40 @@ static void spiro_color(SPPenContext *const pc) //Preparamos la curva roja para que se muestre según esté pulsada la tecla SHIFT -static void spiro_prepare(SPPenContext *const pc, bool Shift) +static void spiro(SPPenContext *const pc, bool Shift) { if(Shift){ - //Creamos un nodo CUSP - pc->npoints = 5; - pc->p[2] = pc->p[3]; - //Si empezamos sobre otra curva en modo cusp la alteramos para que no tenga manejador final - //recreando la curva e igualando el punto del manejador al punto fiinal de la curva - if(pc->anchor_statusbar && pc->sa && !pc->sa->curve->is_empty() && !pc->ea && pc->green_curve->is_empty()){ - bool reverse = false; - Geom::CubicBezier const * cubic; - if(pc->sa->start){ - reverse = true; - pc->sa->curve = reverse_then_reset(pc->sa->curve); - } - Geom::Point P0(0,0); - Geom::Point P1(0,0); - Geom::Point P2(0,0); - Geom::Point P3(0,0); - Geom::Point P4(0,0); - cubic = dynamic_cast( pc->sa->curve->last_segment()); - if(cubic){ - P0 = pc->sa->curve->last_segment()->initialPoint(); - P1 = (*cubic)[1]; - P3 = pc->sa->curve->last_segment()->finalPoint(); - P2 = P3; - }else{ - P0 = pc->sa->curve->last_segment()->initialPoint(); - P1 = P0; - P3 = pc->sa->curve->last_segment()->finalPoint(); - P2 = P3; - } - SPCurve * last = new SPCurve(); - last->moveto(P0); - last->curveto(P1,P2,P3); - if( pc->sa->curve->get_segment_count() == 1){ - pc->sa->curve = last; - }else{ - pc->sa->curve->backspace(); - pc->sa->curve->append_continuous(last, 0.0625); - } - if(reverse){ - pc->sa->curve = reverse_then_reset(pc->sa->curve); - } - delete last; + if(!pc->red_curve->is_empty()){ + //Creamos un nodo CUSP + pc->npoints = 5; + pc->p[2] = pc->p[3]; + } + //Continuamos la curva en modo CUSP + //Guardamos el valor de inicio en cusp para que no se redibuje como SYMM + if(pc->anchor_statusbar){ + saShift = true; } - }else{ //Symm nodo using Geom::X; using Geom::Y; Geom::CubicBezier const * cubic; - //Damos valores a los puntos de la curva roja para que generen un nodo SYMM if(!pc->red_curve->is_empty()){ + //Damos valores a los puntos de la curva roja para que generen un nodo SYMM pc->npoints = 5; //Les damos valor - pc->p[0] = pc->red_curve->first_segment()->initialPoint(); - pc->p[3] = pc->red_curve->first_segment()->finalPoint(); + pc->p[3] = pc->red_curve->first_segment()->finalPoint(); + pc->p[0] = pc->red_curve->first_segment()->initialPoint(); pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); - pc->p[4] = pc->p[3] + (Geom::Point)( pc->p[3] - pc->p[2] ); pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]); + pc->p[1] = Geom::Point(pc->p[1][X]+1,pc->p[1][Y]+1); + pc->p[2] = Geom::Point(pc->p[2][X]+1,pc->p[2][Y]+1); + pc->p[4] = pc->p[3] + (Geom::Point)( pc->p[3] - pc->p[2] ); } + //Continuamos la curva en modo SPIRO - if(pc->anchor_statusbar && pc->sa && !pc->sa->curve->is_empty() && !pc->ea && pc->green_curve->is_empty()){ + if( saShift == false && pc->sa && !pc->sa->curve->is_empty() && !pc->ea && pc->green_curve->is_empty()){ cubic = dynamic_cast( pc->sa->curve->last_segment()); if (pc->sa->start) { cubic = dynamic_cast( pc->sa->curve->create_reverse()->last_segment() ); @@ -1561,32 +1598,34 @@ static void spiro_prepare(SPPenContext *const pc, bool Shift) pc->p[1] = (pc->p[0] - (*cubic)[2]) + pc->p[0]; } } + //Nos aseguramos que el primer nodo sea SYMM con el ultimo segmento de la curva verde if(!pc->green_curve->is_empty()){ cubic = dynamic_cast( pc->green_curve->last_segment()); if(cubic && (*cubic)[2] != (*cubic)[3]){ pc->p[1] = (pc->p[0] - (*cubic)[2]) + pc->p[0]; } + //Damos valor original a la variable por si se necesita de nuevo + saShift = false; } //Si cerramos sobre otra curva ponemos simetrico a esta el manejador del punto de cierre - if(pc->ea && !pc->ea->curve->is_empty()){ - cubic = dynamic_cast( pc->ea->curve->last_segment() ); - if (pc->ea->start) { - cubic = dynamic_cast( pc->ea->curve->create_reverse()->last_segment() ); + if(pc->anchor_statusbar && pc->sa && !Geom::are_near(pc->sa->dp, pc->red_curve->first_segment()->finalPoint())){ + cubic = dynamic_cast( pc->sa->curve->last_segment() ); + if (!pc->sa->start) { + cubic = dynamic_cast( pc->sa->curve->create_reverse()->last_segment() ); } if(cubic){ pc->p[2] = (pc->p[3]-(*cubic)[2]) + pc->p[3]; } } //Lo mismpo pero cerrando sobre la curva inicial - if(pc->green_anchor && pc->green_anchor->active){ + if(pc->anchor_statusbar && pc->green_anchor && pc->green_anchor->active){ cubic = dynamic_cast( pc->green_curve->first_segment() ); if(cubic){ pc->p[2] = (pc->p[3]-(*cubic)[1]) + pc->p[3]; } } - } spiro_build(pc); } @@ -1613,16 +1652,10 @@ static void spiro_build(SPPenContext *const pc) pc->red_curve->reset(); pc->red_curve->moveto(pc->p[0]); pc->red_curve->curveto(pc->p[1],pc->p[2],pc->p[3]); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), pc->red_curve); curve->append_continuous(pc->red_curve, 0.0625); } - if(!pc->sa && pc->ea && !pc->ea->curve->is_empty()){ - if (pc->ea->start) { - curve->append_continuous(pc->ea->curve, 0.0625); - }else{ - curve->append_continuous(pc->ea->curve->create_reverse(), 0.0625); - } - } if(!curve->is_empty()){ //cerramos la curva si estan cerca los puntos finales de la curva spiro if(Geom::are_near(curve->first_path()->initialPoint(), curve->last_path()->finalPoint())){ @@ -1763,62 +1796,69 @@ static void spiro_doEffect(SPCurve * curve) } //Unimos todas las curvas en juego y llamamos a la función doEffect. -static void bspline_prepare(SPPenContext *const pc, bool Shift) +static void bspline(SPPenContext *const pc, bool Shift) { if(!Shift){ //Modo Bspline formado por nodos CUSP - if (pc->npoints == 5){ + if (pc->npoints == 5 || !pc->red_curve->is_empty()){ pc->npoints = 2; pc->p[1]= pc->p[3]; } }else{ - //NODO CUSP formado por nodo SMOOTH - //solo mobemos el manejador del nodo final de cada segmento - //Es suficiente para mostrar el nodo como CUSP using Geom::X; using Geom::Y; - bool reverse = false; - //Usamos 5 puntos - if(pc->npoints == 2){ + +/* +.* //TODO: No puedo conseguir que el siguoenmte codigo funcione +.* //Este trata de convertir el nodo de inicio de continuación de curva BSpline a CUSP +.* //modifiacandpo el segmento al que se trata de anexar la curva +.* //de manera que le obligue a tener manejador final +.* +.* if(pc->anchor_statusbar && pc->sa && !pc->sa->curve->is_empty() && pc->red_curve->is_empty()){ +.* bool reverse = false; +.* if(pc->sa->start){ +.* pc->sa->curve = reverse_then_reset(pc->sa->curve); +.* reverse = true; +.* } +.* Geom::Point P0(0,0); +.* Geom::Point P1(0,0); +.* Geom::Point P2(0,0); +.* Geom::Point P3(0,0); +.* Geom::Point P4(0,0); +.* P0 = pc->sa->curve->last_segment()->initialPoint(); +.* P1 = P0; +.* P3 = pc->sa->curve->last_segment()->finalPoint(); +.* P2 = P3 + (1./3)*(P0 - P3); +.* P2 = Geom::Point(P2[X]+1,P2[Y]+1); +.* SPCurve * last = new SPCurve(); +.* last->moveto(P0); +.* last->curveto(P1,P2,P3); +.* if( pc->sa->curve->get_segment_count() == 1){ +.* pc->sa->curve = last; +.* }else{ +.* pc->sa->curve->backspace(); +.* pc->sa->curve->append_continuous(last, 0.0625); +.* if(reverse) +.* pc->sa->curve = reverse_then_reset(pc->sa->curve); +.* } +.* delete last; +.* } +*/ + //NODO CUSP formado por nodo SMOOTH + //solo mobemos el manejador del nodo final de cada segmento + //Es suficiente para mostrar el nodo como CUSP + //Usamos 5 puntos + if(!pc->red_curve->is_empty()){ pc->npoints = 5; - } - pc->p[1] = pc->p[0]; - //Les damos valor - pc->p[3] = pc->red_curve->first_segment()->finalPoint(); - pc->p[4] = pc->p[3]; - pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); - - //Si empezamos sobre otra curva hay que modificarla para que tenga manejador en el último nodo - if(pc->anchor_statusbar && pc->sa && !pc->sa->curve->is_empty() && !pc->ea && pc->green_curve->is_empty()){ - if(pc->sa->start){ - reverse = true; - pc->sa->curve = reverse_then_reset(pc->sa->curve); - } - Geom::Point P0(0,0); - Geom::Point P1(0,0); - Geom::Point P2(0,0); - Geom::Point P3(0,0); - Geom::Point P4(0,0); - P0 = pc->sa->curve->last_segment()->initialPoint(); - P1 = P0; - P3 = pc->sa->curve->last_segment()->finalPoint(); - P2 = P3 + (1./3)*(P0 - P3); - SPCurve * last = new SPCurve(); - last->moveto(P0); - last->curveto(P1,P2,P3); - if( pc->sa->curve->get_segment_count() == 1){ - pc->sa->curve = last; - }else{ - pc->sa->curve->backspace(); - pc->sa->curve->append_continuous(last, 0.0625); - } - if(reverse){ - pc->sa->curve = reverse_then_reset(pc->sa->curve); - } - delete last; + pc->p[0] = pc->red_curve->first_segment()->initialPoint(); + pc->p[1] = pc->p[0]; + pc->p[3] = pc->red_curve->first_segment()->finalPoint(); + pc->p[4] = pc->p[3]; + pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); + pc->p[2] = Geom::Point(pc->p[2][X]+1,pc->p[2][Y]+1); } } -bspline_build(pc); + bspline_build(pc); } @@ -1848,16 +1888,10 @@ static void bspline_build(SPPenContext *const pc) }else{ pc->red_curve->curveto(pc->p[1],pc->p[2],pc->p[3]); } + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), pc->red_curve); curve->append_continuous(pc->red_curve, 0.0625); } - if(!pc->sa && pc->ea && !pc->ea->curve->is_empty()){ - if (pc->ea->start) { - curve->append_continuous(pc->ea->curve, 0.0625); - }else{ - curve->append_continuous(pc->ea->curve->create_reverse(), 0.0625); - } - } if(curve->get_segment_count() > 1 ){ //cerramos la curva si estan cerca los puntos finales de la curva spiro if(Geom::are_near(curve->first_path()->initialPoint(), curve->last_path()->finalPoint())){ @@ -1867,7 +1901,7 @@ static void bspline_build(SPPenContext *const pc) //For example //using namespace Inkscape::LivePathEffect; //LivePathEffectObject *lpeobj = static_cast (curve); - //Effect *spr = static_cast ( new LPEbspline_prepare(lpeobj) ); + //Effect *spr = static_cast ( new LPEbspline(lpeobj) ); //spr->doEffect(curve); bspline_doEffect(curve); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->blue_bpath), curve); @@ -1911,9 +1945,6 @@ static void bspline_doEffect(SPCurve * curve) Geom::Point startNode(0,0); Geom::Point previousNode(0,0); Geom::Point node(0,0); - Geom::Point previousPointAt0(0,0); - Geom::Point previousPointAt1(0,0); - Geom::Point previousPointAt2(0,0); //Geom::Point previousPointAt3(0,0); Geom::Point pointAt0(0,0); Geom::Point pointAt1(0,0); @@ -1975,10 +2006,6 @@ static void bspline_doEffect(SPCurve * curve) //Damos valor a el objeto SBasis para el path de entrada y el de salida SBasisIn = in->first_segment()->toSBasis(); SBasisOut = out->first_segment()->toSBasis(); - //Damos valor a los puntos calculados en el anterior paso del bucle - previousPointAt0 = pointAt0; - previousPointAt1 = pointAt1; - previousPointAt2 = pointAt2; //previousPointAt3 = pointAt3; //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida pointAt0 = SBasisIn.valueAt(0); @@ -2127,11 +2154,7 @@ static void spdc_pen_set_ctrl(SPPenContext *const pc, Geom::Point const p, guint pc->p[1] = p; sp_canvas_item_hide(pc->c0); sp_canvas_item_hide(pc->cl0); - if(pc->spiro){ - SP_CTRL(pc->c1)->moveto(pc->p[1]); - }else{ - SP_CTRL(pc->c1)->moveto(pc->p[1]); - } + SP_CTRL(pc->c1)->moveto(pc->p[1]); pc->cl1->setCoords(pc->p[0], pc->p[1]); spdc_pen_set_angle_distance_status_message(pc, p, 0, _("Curve handle: angle %3.2f°, length %s; with Ctrl to snap angle")); } else if ( pc->npoints == 5 ) { @@ -2173,10 +2196,10 @@ static void spdc_pen_finish_segment(SPPenContext *const pc, Geom::Point const p, if (!pc->red_curve->is_empty()) { //BSpline if(pc->spiro){ - spiro_prepare(pc, (state & GDK_SHIFT_MASK)); + spiro(pc, (state & GDK_SHIFT_MASK)); } if(pc->bspline){ - bspline_prepare(pc, (state & GDK_SHIFT_MASK)); + bspline(pc, (state & GDK_SHIFT_MASK)); } //BSpline End pc->green_curve->append_continuous(pc->red_curve, 0.0625); @@ -2328,3 +2351,4 @@ void pen_set_to_nearest_horiz_vert(const SPPenContext *const pc, Geom::Point &pt End: */ // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : + -- cgit v1.2.3 From 69282d367f74bd425ae11cab845208250d38ca24 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 24 Dec 2012 12:42:35 +0100 Subject: Fix shortcut Spiro to curve (bzr r11950.1.8) --- src/pen-context.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 20c95c13f..f6d07facc 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -1088,14 +1088,6 @@ static void pen_lastpoint_tocurve (SPPenContext *const pc) return; //BSpline Geom::CubicBezier const * cubic; - if(!pc->bspline){ - cubic = dynamic_cast( pc->green_curve->last_segment() ); - if ( cubic ) { - pc->p[1] = pc->p[0] + (Geom::Point)( (*cubic)[3] - (*cubic)[2] ); - } else { - pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]); - } - } //Para formar una curva necesitamos un nodo symm en el "lastpoint" //de esta manera modificamos el final de la "curva_verde" para que sea symm con el pricipio de la "red_curve" @@ -1105,8 +1097,7 @@ static void pen_lastpoint_tocurve (SPPenContext *const pc) Geom::Point C(0,0); Geom::Point D(0,0); SPCurve * previous = new SPCurve(); - using Geom::X; - using Geom::Y; + cubic = dynamic_cast( pc->green_curve->last_segment() ); //We obtain the last segment 4 points in the previous curve if ( cubic ){ A = (*cubic)[0]; @@ -1119,7 +1110,6 @@ static void pen_lastpoint_tocurve (SPPenContext *const pc) C = pc->p[0] + (Geom::Point)(pc->p[0] - pc->p[1]); D = pc->green_curve->last_segment()->finalPoint(); } - C = Geom::Point(C[X]+1,C[Y]+1); previous->moveto(A); previous->curveto(B, C, D); if( pc->green_curve->get_segment_count() == 1){ @@ -1131,6 +1121,16 @@ static void pen_lastpoint_tocurve (SPPenContext *const pc) pc->green_curve->append_continuous(previous, 0.0625); } } + + if(!pc->bspline){ + cubic = dynamic_cast( pc->green_curve->last_segment() ); + if ( cubic ) { + pc->p[1] = pc->p[0] + (Geom::Point)( pc->p[0] - (*cubic)[2] ); + } else { + pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]); + } + } + //Para formar una curva bspline necesitamos un nodo cusp en el "lastpoint" //de esta manera modificamos el final de la "curva_verde" para que sea cusp con el pricipio de la "red_curve" //Que se quedará recta -- cgit v1.2.3 From eac303cf672b1c09a0378ca8b34aafcfdf4ee08d Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 4 Jan 2013 22:30:00 +0100 Subject: Fixing StartAnchor problems in bspline (bzr r11950.1.10) --- src/live_effects/lpe-bspline.cpp | 19 ++++-- src/pen-context.cpp | 128 ++++++++++++++++++++++----------------- 2 files changed, 87 insertions(+), 60 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index e125cc4e0..24e7a5027 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -13,6 +13,7 @@ #include <2geom/bezier-curve.h> #include "helper/geom-curves.h" + // For handling un-continuous paths: #include "message-stack.h" #include "inkscape.h" @@ -72,6 +73,8 @@ LPEBSpline::doEffect(SPCurve * curve) Geom::Point nextPointAt1(0,0); Geom::Point nextPointAt2(0,0); Geom::Point nextPointAt3(0,0); + Geom::CubicBezier const * cubic; + Geom::PathVector newpathv; //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { @@ -79,6 +82,7 @@ LPEBSpline::doEffect(SPCurve * curve) if (path_it->empty()) continue; //Itreadores + Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve Geom::Path::const_iterator curve_end = path_it->end(); // end curve @@ -100,7 +104,12 @@ LPEBSpline::doEffect(SPCurve * curve) //Si la curva está cerrada calculamos el punto donde //deveria estar el nodo BSpline de cierre/inicio de la curva //en posible caso de que se cierre con una linea recta creando un nodo BSPline - if (path_it->closed() && is_straight_curve(*curve_end)) { + + cubic = dynamic_cast(&*curve_endit); + if((*cubic)[2] == (*cubic)[3]) + isBSpline = false; + if (path_it->closed() && !isBSpline) { + isBSpline = true; //Calculamos el nodo de inicio BSpline SBasisIn = in->first_segment()->toSBasis(); SBasisEnd = end->first_segment()->toSBasis(); @@ -149,9 +158,11 @@ LPEBSpline::doEffect(SPCurve * curve) //Y este hará de final de curva node = SBasisHelper.valueAt(0.5); //Vemos si el nodo es BSpline o CUSP - //Averiguamos si el path de entrada es recto o tiene manejadores - isBSpline = is_straight_curve(*curve_it1); - //Si no es recto, tenemos que generar la curva con nodo final CUSP + //Averiguamos si el punto de union tiene manejadores + cubic = dynamic_cast(&*curve_it1); + if((*cubic)[2] == (*cubic)[3]) + isBSpline = true; + //Si no tiene manejador, tenemos que generar la curva con nodo final CUSP if(!isBSpline ){ //Definimos como nodo el final del segmento de entrada node = pointAt3; diff --git a/src/pen-context.cpp b/src/pen-context.cpp index f6d07facc..ea14a5183 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -58,6 +58,7 @@ #include "helper/geom-nodetype.h" #include "helper/geom-curves.h" + // For handling un-continuous paths: #include "message-stack.h" #include "inkscape.h" @@ -1501,14 +1502,6 @@ static void spdc_pen_set_angle_distance_status_message(SPPenContext *const pc, G //BSpline Set Functions -//Creates a new curve resetting the original -static SPCurve * reverse_then_reset(SPCurve *orig) -{ - SPCurve *ret = orig->create_reverse(); - orig->reset(); - return ret; -} - //Esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro static void spiro_color(SPPenContext *const pc) { @@ -1794,6 +1787,14 @@ static void spiro_doEffect(SPCurve * curve) g_free (path); } +//BSpline Set Functions +//Creates a new curve resetting the original +static SPCurve * reverse_then_reset(SPCurve *orig) +{ + SPCurve *ret = orig->create_reverse(); + orig->reset(); + return ret; +} //Unimos todas las curvas en juego y llamamos a la función doEffect. static void bspline(SPPenContext *const pc, bool Shift) @@ -1801,61 +1802,62 @@ static void bspline(SPPenContext *const pc, bool Shift) if(!Shift){ //Modo Bspline formado por nodos CUSP if (pc->npoints == 5 || !pc->red_curve->is_empty()){ - pc->npoints = 2; - pc->p[1]= pc->p[3]; + pc->npoints = 5; + pc->p[2]= pc->p[3]; } }else{ using Geom::X; using Geom::Y; + Geom::CubicBezier const * cubic; + if(pc->green_curve->is_empty() && pc->red_curve->is_empty() && pc->sa && !pc->ea && !pc->sa->curve->is_empty()){ + bool reverse = false; + if (pc->sa->start) { + reverse = true; + pc->sa->curve = reverse_then_reset(pc->sa->curve); + } + Geom::Point P0(0,0); + Geom::Point P1(0,0); + Geom::Point P2(0,0); + Geom::Point P3(0,0); + Geom::Point P4(0,0); + P0 = pc->sa->curve->last_segment()->initialPoint(); + P1 = P0; + cubic = dynamic_cast( pc->sa->curve->last_segment() ); + if(cubic) + P1 = (*cubic)[2]; + P3 = pc->sa->curve->last_segment()->finalPoint(); + P2 = P3 + (1./3)*(P0 - P3); + P2 = Geom::Point(P2[X]+1,P2[Y]+1); + SPCurve * last = new SPCurve(); + last->moveto(P0); + last->curveto(P1,P2,P3); + if( pc->sa->curve->get_segment_count() == 1){ + pc->sa->curve = last; + }else{ + pc->sa->curve->backspace(); + pc->sa->curve->append_continuous(last, 0.0625); + } + if(reverse) + pc->sa->curve = reverse_then_reset(pc->sa->curve); + last->reset(); + last->unref(); + } -/* -.* //TODO: No puedo conseguir que el siguoenmte codigo funcione -.* //Este trata de convertir el nodo de inicio de continuación de curva BSpline a CUSP -.* //modifiacandpo el segmento al que se trata de anexar la curva -.* //de manera que le obligue a tener manejador final -.* -.* if(pc->anchor_statusbar && pc->sa && !pc->sa->curve->is_empty() && pc->red_curve->is_empty()){ -.* bool reverse = false; -.* if(pc->sa->start){ -.* pc->sa->curve = reverse_then_reset(pc->sa->curve); -.* reverse = true; -.* } -.* Geom::Point P0(0,0); -.* Geom::Point P1(0,0); -.* Geom::Point P2(0,0); -.* Geom::Point P3(0,0); -.* Geom::Point P4(0,0); -.* P0 = pc->sa->curve->last_segment()->initialPoint(); -.* P1 = P0; -.* P3 = pc->sa->curve->last_segment()->finalPoint(); -.* P2 = P3 + (1./3)*(P0 - P3); -.* P2 = Geom::Point(P2[X]+1,P2[Y]+1); -.* SPCurve * last = new SPCurve(); -.* last->moveto(P0); -.* last->curveto(P1,P2,P3); -.* if( pc->sa->curve->get_segment_count() == 1){ -.* pc->sa->curve = last; -.* }else{ -.* pc->sa->curve->backspace(); -.* pc->sa->curve->append_continuous(last, 0.0625); -.* if(reverse) -.* pc->sa->curve = reverse_then_reset(pc->sa->curve); -.* } -.* delete last; -.* } -*/ - //NODO CUSP formado por nodo SMOOTH - //solo mobemos el manejador del nodo final de cada segmento - //Es suficiente para mostrar el nodo como CUSP - //Usamos 5 puntos + //NODO CUSP formado por nodo SMOOTH + //solo mobemos el manejador del nodo final de cada segmento + //Es suficiente para mostrar el nodo como CUSP + //Usamos 5 puntos if(!pc->red_curve->is_empty()){ pc->npoints = 5; pc->p[0] = pc->red_curve->first_segment()->initialPoint(); pc->p[1] = pc->p[0]; + cubic = dynamic_cast( pc->red_curve->first_segment() ); + if(cubic) + pc->p[1] = (*cubic)[1]; pc->p[3] = pc->red_curve->first_segment()->finalPoint(); - pc->p[4] = pc->p[3]; - pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); + pc->p[2] = pc->p[0] + (1./3)*(pc->p[0] - pc->p[3]); pc->p[2] = Geom::Point(pc->p[2][X]+1,pc->p[2][Y]+1); + pc->p[4] = pc->p[3] + (1./3)*(pc->p[3] - pc->p[0]); } } bspline_build(pc); @@ -1954,6 +1956,8 @@ static void bspline_doEffect(SPCurve * curve) Geom::Point nextPointAt1(0,0); Geom::Point nextPointAt2(0,0); Geom::Point nextPointAt3(0,0); + Geom::CubicBezier const * cubic; + Geom::PathVector newpathv; //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { @@ -1961,6 +1965,7 @@ static void bspline_doEffect(SPCurve * curve) if (path_it->empty()) continue; //Itreadores + Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve Geom::Path::const_iterator curve_end = path_it->end(); // end curve @@ -1982,7 +1987,12 @@ static void bspline_doEffect(SPCurve * curve) //Si la curva está cerrada calculamos el punto donde //deveria estar el nodo BSpline de cierre/inicio de la curva //en posible caso de que se cierre con una linea recta creando un nodo BSPline - if (path_it->closed() && is_straight_curve(*curve_end)) { + + cubic = dynamic_cast(&*curve_endit); + if((*cubic)[2] == (*cubic)[3]) + isBSpline = false; + if (path_it->closed() && !isBSpline) { + isBSpline = true; //Calculamos el nodo de inicio BSpline SBasisIn = in->first_segment()->toSBasis(); SBasisEnd = end->first_segment()->toSBasis(); @@ -2031,9 +2041,11 @@ static void bspline_doEffect(SPCurve * curve) //Y este hará de final de curva node = SBasisHelper.valueAt(0.5); //Vemos si el nodo es BSpline o CUSP - //Averiguamos si el path de entrada es recto o tiene manejadores - isBSpline = is_straight_curve(*curve_it1); - //Si no es recto, tenemos que generar la curva con nodo final CUSP + //Averiguamos si el punto de union tiene manejadores + cubic = dynamic_cast(&*curve_it1); + if((*cubic)[2] == (*cubic)[3]) + isBSpline = true; + //Si no tiene manejador, tenemos que generar la curva con nodo final CUSP if(!isBSpline ){ //Definimos como nodo el final del segmento de entrada node = pointAt3; @@ -2225,7 +2237,11 @@ static void spdc_pen_finish(SPPenContext *const pc, gboolean const closed) // don't let the path be finished before we have collected the required number of mouse clicks return; } + //BSpline + if(pc->bspline && pc->green_curve->get_segment_count() < 2 && !pc->sa ) + return; + //BSpline End pc->num_clicks = 0; pen_disable_events(pc); -- cgit v1.2.3 From 32866e3ed73a2a8c41520e2538687b5701a2d347 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 5 Jan 2013 11:53:55 +0100 Subject: fix continue (bzr r11950.1.11) --- src/live_effects/lpe-bspline.cpp | 21 +++---- src/pen-context.cpp | 127 +++++++++++++++++++-------------------- 2 files changed, 71 insertions(+), 77 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 24e7a5027..c8263282e 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -1,5 +1,5 @@ +#define INKSCAPE_HELPER_GEOM_CURVES_H #define INKSCAPE_LPE_BSPLINE_C - /* * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -73,9 +73,6 @@ LPEBSpline::doEffect(SPCurve * curve) Geom::Point nextPointAt1(0,0); Geom::Point nextPointAt2(0,0); Geom::Point nextPointAt3(0,0); - Geom::CubicBezier const * cubic; - Geom::PathVector newpathv; - //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { //Si está vacío... @@ -104,10 +101,10 @@ LPEBSpline::doEffect(SPCurve * curve) //Si la curva está cerrada calculamos el punto donde //deveria estar el nodo BSpline de cierre/inicio de la curva //en posible caso de que se cierre con una linea recta creando un nodo BSPline - - cubic = dynamic_cast(&*curve_endit); - if((*cubic)[2] == (*cubic)[3]) - isBSpline = false; + if (Geom::CubicBezier const *cubic = dynamic_cast(&*curve_end)){ + if((*cubic)[2] == (*cubic)[3]) + isBSpline = false; + } if (path_it->closed() && !isBSpline) { isBSpline = true; //Calculamos el nodo de inicio BSpline @@ -159,9 +156,10 @@ LPEBSpline::doEffect(SPCurve * curve) node = SBasisHelper.valueAt(0.5); //Vemos si el nodo es BSpline o CUSP //Averiguamos si el punto de union tiene manejadores - cubic = dynamic_cast(&*curve_it1); - if((*cubic)[2] == (*cubic)[3]) - isBSpline = true; + if (Geom::CubicBezier const *cubic = dynamic_cast(&*curve_it1)){ + if((*cubic)[2] == (*cubic)[3]) + isBSpline = true; + } //Si no tiene manejador, tenemos que generar la curva con nodo final CUSP if(!isBSpline ){ //Definimos como nodo el final del segmento de entrada @@ -221,7 +219,6 @@ LPEBSpline::doEffect(SPCurve * curve) } - }; //namespace LivePathEffect }; /* namespace Inkscape */ diff --git a/src/pen-context.cpp b/src/pen-context.cpp index ea14a5183..92481ec68 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -58,7 +58,6 @@ #include "helper/geom-nodetype.h" #include "helper/geom-curves.h" - // For handling un-continuous paths: #include "message-stack.h" #include "inkscape.h" @@ -1502,6 +1501,14 @@ static void spdc_pen_set_angle_distance_status_message(SPPenContext *const pc, G //BSpline Set Functions +//Creates a new curve resetting the original +static SPCurve * reverse_then_reset(SPCurve *orig) +{ + SPCurve *ret = orig->create_reverse(); + orig->reset(); + return ret; +} + //Esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro static void spiro_color(SPPenContext *const pc) { @@ -1787,14 +1794,6 @@ static void spiro_doEffect(SPCurve * curve) g_free (path); } -//BSpline Set Functions -//Creates a new curve resetting the original -static SPCurve * reverse_then_reset(SPCurve *orig) -{ - SPCurve *ret = orig->create_reverse(); - orig->reset(); - return ret; -} //Unimos todas las curvas en juego y llamamos a la función doEffect. static void bspline(SPPenContext *const pc, bool Shift) @@ -1802,62 +1801,61 @@ static void bspline(SPPenContext *const pc, bool Shift) if(!Shift){ //Modo Bspline formado por nodos CUSP if (pc->npoints == 5 || !pc->red_curve->is_empty()){ - pc->npoints = 5; - pc->p[2]= pc->p[3]; + pc->npoints = 2; + pc->p[1]= pc->p[3]; } }else{ using Geom::X; using Geom::Y; - Geom::CubicBezier const * cubic; - if(pc->green_curve->is_empty() && pc->red_curve->is_empty() && pc->sa && !pc->ea && !pc->sa->curve->is_empty()){ - bool reverse = false; - if (pc->sa->start) { - reverse = true; - pc->sa->curve = reverse_then_reset(pc->sa->curve); - } - Geom::Point P0(0,0); - Geom::Point P1(0,0); - Geom::Point P2(0,0); - Geom::Point P3(0,0); - Geom::Point P4(0,0); - P0 = pc->sa->curve->last_segment()->initialPoint(); - P1 = P0; - cubic = dynamic_cast( pc->sa->curve->last_segment() ); - if(cubic) - P1 = (*cubic)[2]; - P3 = pc->sa->curve->last_segment()->finalPoint(); - P2 = P3 + (1./3)*(P0 - P3); - P2 = Geom::Point(P2[X]+1,P2[Y]+1); - SPCurve * last = new SPCurve(); - last->moveto(P0); - last->curveto(P1,P2,P3); - if( pc->sa->curve->get_segment_count() == 1){ - pc->sa->curve = last; - }else{ - pc->sa->curve->backspace(); - pc->sa->curve->append_continuous(last, 0.0625); - } - if(reverse) - pc->sa->curve = reverse_then_reset(pc->sa->curve); - last->reset(); - last->unref(); - } - //NODO CUSP formado por nodo SMOOTH - //solo mobemos el manejador del nodo final de cada segmento - //Es suficiente para mostrar el nodo como CUSP - //Usamos 5 puntos +/* +.* //TODO: No puedo conseguir que el siguoenmte codigo funcione +.* //Este trata de convertir el nodo de inicio de continuación de curva BSpline a CUSP +.* //modifiacandpo el segmento al que se trata de anexar la curva +.* //de manera que le obligue a tener manejador final +.* +.* if(pc->anchor_statusbar && pc->sa && !pc->sa->curve->is_empty() && pc->red_curve->is_empty()){ +.* bool reverse = false; +.* if(pc->sa->start){ +.* pc->sa->curve = reverse_then_reset(pc->sa->curve); +.* reverse = true; +.* } +.* Geom::Point P0(0,0); +.* Geom::Point P1(0,0); +.* Geom::Point P2(0,0); +.* Geom::Point P3(0,0); +.* Geom::Point P4(0,0); +.* P0 = pc->sa->curve->last_segment()->initialPoint(); +.* P1 = P0; +.* P3 = pc->sa->curve->last_segment()->finalPoint(); +.* P2 = P3 + (1./3)*(P0 - P3); +.* P2 = Geom::Point(P2[X]+1,P2[Y]+1); +.* SPCurve * last = new SPCurve(); +.* last->moveto(P0); +.* last->curveto(P1,P2,P3); +.* if( pc->sa->curve->get_segment_count() == 1){ +.* pc->sa->curve = last; +.* }else{ +.* pc->sa->curve->backspace(); +.* pc->sa->curve->append_continuous(last, 0.0625); +.* if(reverse) +.* pc->sa->curve = reverse_then_reset(pc->sa->curve); +.* } +.* delete last; +.* } +*/ + //NODO CUSP formado por nodo SMOOTH + //solo mobemos el manejador del nodo final de cada segmento + //Es suficiente para mostrar el nodo como CUSP + //Usamos 5 puntos if(!pc->red_curve->is_empty()){ pc->npoints = 5; pc->p[0] = pc->red_curve->first_segment()->initialPoint(); pc->p[1] = pc->p[0]; - cubic = dynamic_cast( pc->red_curve->first_segment() ); - if(cubic) - pc->p[1] = (*cubic)[1]; pc->p[3] = pc->red_curve->first_segment()->finalPoint(); - pc->p[2] = pc->p[0] + (1./3)*(pc->p[0] - pc->p[3]); + pc->p[4] = pc->p[3]; + pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); pc->p[2] = Geom::Point(pc->p[2][X]+1,pc->p[2][Y]+1); - pc->p[4] = pc->p[3] + (1./3)*(pc->p[3] - pc->p[0]); } } bspline_build(pc); @@ -1956,9 +1954,6 @@ static void bspline_doEffect(SPCurve * curve) Geom::Point nextPointAt1(0,0); Geom::Point nextPointAt2(0,0); Geom::Point nextPointAt3(0,0); - Geom::CubicBezier const * cubic; - Geom::PathVector newpathv; - //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { //Si está vacío... @@ -1987,10 +1982,10 @@ static void bspline_doEffect(SPCurve * curve) //Si la curva está cerrada calculamos el punto donde //deveria estar el nodo BSpline de cierre/inicio de la curva //en posible caso de que se cierre con una linea recta creando un nodo BSPline - - cubic = dynamic_cast(&*curve_endit); - if((*cubic)[2] == (*cubic)[3]) - isBSpline = false; + if (Geom::CubicBezier const *cubic = dynamic_cast(&*curve_end)){ + if((*cubic)[2] == (*cubic)[3]) + isBSpline = false; + } if (path_it->closed() && !isBSpline) { isBSpline = true; //Calculamos el nodo de inicio BSpline @@ -2042,9 +2037,10 @@ static void bspline_doEffect(SPCurve * curve) node = SBasisHelper.valueAt(0.5); //Vemos si el nodo es BSpline o CUSP //Averiguamos si el punto de union tiene manejadores - cubic = dynamic_cast(&*curve_it1); - if((*cubic)[2] == (*cubic)[3]) - isBSpline = true; + if (Geom::CubicBezier const *cubic = dynamic_cast(&*curve_it1)){ + if((*cubic)[2] == (*cubic)[3]) + isBSpline = true; + } //Si no tiene manejador, tenemos que generar la curva con nodo final CUSP if(!isBSpline ){ //Definimos como nodo el final del segmento de entrada @@ -2237,11 +2233,12 @@ static void spdc_pen_finish(SPPenContext *const pc, gboolean const closed) // don't let the path be finished before we have collected the required number of mouse clicks return; } + //BSpline if(pc->bspline && pc->green_curve->get_segment_count() < 2 && !pc->sa ) return; - //BSpline End + pc->num_clicks = 0; pen_disable_events(pc); -- cgit v1.2.3 From 74b658f45b5044ab5903ccc255c1ae0f8a750fce Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 6 Jan 2013 19:20:10 +0100 Subject: fix continue (bzr r11950.1.12) --- src/live_effects/lpe-bspline.cpp | 27 +++++----- src/pen-context.cpp | 111 +++++++++++++++++---------------------- 2 files changed, 64 insertions(+), 74 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index c8263282e..a57cc9a88 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -1,4 +1,3 @@ -#define INKSCAPE_HELPER_GEOM_CURVES_H #define INKSCAPE_LPE_BSPLINE_C /* * Released under GNU GPL, read the file 'COPYING' for more information @@ -73,6 +72,7 @@ LPEBSpline::doEffect(SPCurve * curve) Geom::Point nextPointAt1(0,0); Geom::Point nextPointAt2(0,0); Geom::Point nextPointAt3(0,0); + Geom::CubicBezier const *cubic; //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { //Si está vacío... @@ -101,17 +101,15 @@ LPEBSpline::doEffect(SPCurve * curve) //Si la curva está cerrada calculamos el punto donde //deveria estar el nodo BSpline de cierre/inicio de la curva //en posible caso de que se cierre con una linea recta creando un nodo BSPline - if (Geom::CubicBezier const *cubic = dynamic_cast(&*curve_end)){ - if((*cubic)[2] == (*cubic)[3]) - isBSpline = false; - } - if (path_it->closed() && !isBSpline) { - isBSpline = true; + cubic = dynamic_cast(&*curve_end); + if(cubic && (*cubic)[2] != (*cubic)[3]) + isBSpline = false; + if (path_it->closed() && isBSpline) { //Calculamos el nodo de inicio BSpline SBasisIn = in->first_segment()->toSBasis(); SBasisEnd = end->first_segment()->toSBasis(); lineHelper->moveto(SBasisIn.valueAt(0.3334)); - lineHelper->lineto(SBasisEnd.valueAt(0.6664)); + lineHelper->lineto(SBasisEnd.valueAt(0.6667)); SBasisHelper = lineHelper->first_segment()->toSBasis(); lineHelper->reset(); //Guardamos el principio de la curva @@ -119,6 +117,7 @@ LPEBSpline::doEffect(SPCurve * curve) //Definimos el punto de inicio original de la curva resultante node = startNode; }else{ + isBSpline = true; //Guardamos el principio de la curva startNode = in->first_segment()->initialPoint(); //Definimos el punto de inicio original de la curva resultante @@ -156,13 +155,16 @@ LPEBSpline::doEffect(SPCurve * curve) node = SBasisHelper.valueAt(0.5); //Vemos si el nodo es BSpline o CUSP //Averiguamos si el punto de union tiene manejadores - if (Geom::CubicBezier const *cubic = dynamic_cast(&*curve_it1)){ - if((*cubic)[2] == (*cubic)[3]) - isBSpline = true; - } + cubic = dynamic_cast(&*curve_it1); + if(cubic && (*cubic)[2] != (*cubic)[3]) + isBSpline = false; + cubic = dynamic_cast(&*curve_it2); + if(cubic && (*cubic)[0] != (*cubic)[1]) + isBSpline = false; //Si no tiene manejador, tenemos que generar la curva con nodo final CUSP if(!isBSpline ){ //Definimos como nodo el final del segmento de entrada + isBSpline = true; node = pointAt3; } curveHelper->moveto(previousNode); @@ -190,6 +192,7 @@ LPEBSpline::doEffect(SPCurve * curve) curveHelper->curveto(nextPointAt1, nextPointAt2, startNode); }else{ curveHelper->curveto(nextPointAt1, nextPointAt2, nextPointAt3); + isBSpline = true; } //añadimos este último segmento nCurve->append_continuous(curveHelper, 0.0625); diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 92481ec68..eef82e379 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -1566,7 +1566,7 @@ static void spiro(SPPenContext *const pc, bool Shift) } //Continuamos la curva en modo CUSP //Guardamos el valor de inicio en cusp para que no se redibuje como SYMM - if(pc->anchor_statusbar){ + if(pc->anchor_statusbar && pc->red_curve->is_empty()){ saShift = true; } }else{ @@ -1574,7 +1574,9 @@ static void spiro(SPPenContext *const pc, bool Shift) using Geom::X; using Geom::Y; Geom::CubicBezier const * cubic; - + if(pc->anchor_statusbar && pc->red_curve->is_empty()){ + saShift = false; + } if(!pc->red_curve->is_empty()){ //Damos valores a los puntos de la curva roja para que generen un nodo SYMM pc->npoints = 5; @@ -1798,65 +1800,44 @@ static void spiro_doEffect(SPCurve * curve) //Unimos todas las curvas en juego y llamamos a la función doEffect. static void bspline(SPPenContext *const pc, bool Shift) { - if(!Shift){ - //Modo Bspline formado por nodos CUSP - if (pc->npoints == 5 || !pc->red_curve->is_empty()){ - pc->npoints = 2; - pc->p[1]= pc->p[3]; + if(Shift){ + //Continuamos la curva en modo CUSP + //Guardamos el valor de inicio en cusp para que no se redibuje como SYMM + if(pc->anchor_statusbar && pc->red_curve->is_empty()){ + saShift = true; } - }else{ using Geom::X; using Geom::Y; -/* -.* //TODO: No puedo conseguir que el siguoenmte codigo funcione -.* //Este trata de convertir el nodo de inicio de continuación de curva BSpline a CUSP -.* //modifiacandpo el segmento al que se trata de anexar la curva -.* //de manera que le obligue a tener manejador final -.* -.* if(pc->anchor_statusbar && pc->sa && !pc->sa->curve->is_empty() && pc->red_curve->is_empty()){ -.* bool reverse = false; -.* if(pc->sa->start){ -.* pc->sa->curve = reverse_then_reset(pc->sa->curve); -.* reverse = true; -.* } -.* Geom::Point P0(0,0); -.* Geom::Point P1(0,0); -.* Geom::Point P2(0,0); -.* Geom::Point P3(0,0); -.* Geom::Point P4(0,0); -.* P0 = pc->sa->curve->last_segment()->initialPoint(); -.* P1 = P0; -.* P3 = pc->sa->curve->last_segment()->finalPoint(); -.* P2 = P3 + (1./3)*(P0 - P3); -.* P2 = Geom::Point(P2[X]+1,P2[Y]+1); -.* SPCurve * last = new SPCurve(); -.* last->moveto(P0); -.* last->curveto(P1,P2,P3); -.* if( pc->sa->curve->get_segment_count() == 1){ -.* pc->sa->curve = last; -.* }else{ -.* pc->sa->curve->backspace(); -.* pc->sa->curve->append_continuous(last, 0.0625); -.* if(reverse) -.* pc->sa->curve = reverse_then_reset(pc->sa->curve); -.* } -.* delete last; -.* } -*/ - //NODO CUSP formado por nodo SMOOTH - //solo mobemos el manejador del nodo final de cada segmento - //Es suficiente para mostrar el nodo como CUSP - //Usamos 5 puntos + //NODO CUSP formado por nodo SMOOTH + //solo mobemos el manejador del nodo final de cada segmento + //Es suficiente para mostrar el nodo como CUSP + //Usamos 5 puntos + //Continuamos la curva en modo CUSP + //Guardamos el valor de inicio en cusp para que no se redibuje como SYMM + if(!pc->red_curve->is_empty()){ pc->npoints = 5; pc->p[0] = pc->red_curve->first_segment()->initialPoint(); - pc->p[1] = pc->p[0]; pc->p[3] = pc->red_curve->first_segment()->finalPoint(); pc->p[4] = pc->p[3]; pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); pc->p[2] = Geom::Point(pc->p[2][X]+1,pc->p[2][Y]+1); } + }else{ + if(pc->anchor_statusbar && pc->red_curve->is_empty()){ + saShift = false; + } + if(!pc->green_curve->is_empty()){ + //Damos valor original a la variable por si se necesita de nuevo + saShift = false; + } + //Modo Bspline formado por nodos CUSP + if (pc->npoints == 5 || !pc->red_curve->is_empty()){ + pc->p[2]= pc->p[3]; + if(pc->green_curve->is_empty() && saShift) + pc->p[1] = pc->p[0] + (1./3)*(pc->p[0] - pc->p[3]); + } } bspline_build(pc); } @@ -1866,6 +1847,7 @@ static void bspline(SPPenContext *const pc, bool Shift) //preparates the curves for its trasformation into BSline curves. static void bspline_build(SPPenContext *const pc) { + //We create the base curve SPCurve *curve = new SPCurve(); //If we continuate the existing curve we add it at the start @@ -1897,7 +1879,8 @@ static void bspline_build(SPPenContext *const pc) if(Geom::are_near(curve->first_path()->initialPoint(), curve->last_path()->finalPoint())){ curve->closepath_current(); } - //TODO: CALL TO CLONED FUNCTION SPIRO::doEffect IN lpe-spiro.cpp + + //TODO: CALL TO CLONED FUNCTION BSPLINE::doEffect IN lpe-bspline.cpp //For example //using namespace Inkscape::LivePathEffect; //LivePathEffectObject *lpeobj = static_cast (curve); @@ -1954,6 +1937,7 @@ static void bspline_doEffect(SPCurve * curve) Geom::Point nextPointAt1(0,0); Geom::Point nextPointAt2(0,0); Geom::Point nextPointAt3(0,0); + Geom::CubicBezier const *cubic; //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { //Si está vacío... @@ -1982,17 +1966,15 @@ static void bspline_doEffect(SPCurve * curve) //Si la curva está cerrada calculamos el punto donde //deveria estar el nodo BSpline de cierre/inicio de la curva //en posible caso de que se cierre con una linea recta creando un nodo BSPline - if (Geom::CubicBezier const *cubic = dynamic_cast(&*curve_end)){ - if((*cubic)[2] == (*cubic)[3]) - isBSpline = false; - } - if (path_it->closed() && !isBSpline) { - isBSpline = true; + cubic = dynamic_cast(&*curve_end); + if(cubic && (*cubic)[2] != (*cubic)[3]) + isBSpline = false; + if (path_it->closed() && isBSpline) { //Calculamos el nodo de inicio BSpline SBasisIn = in->first_segment()->toSBasis(); SBasisEnd = end->first_segment()->toSBasis(); lineHelper->moveto(SBasisIn.valueAt(0.3334)); - lineHelper->lineto(SBasisEnd.valueAt(0.6664)); + lineHelper->lineto(SBasisEnd.valueAt(0.6667)); SBasisHelper = lineHelper->first_segment()->toSBasis(); lineHelper->reset(); //Guardamos el principio de la curva @@ -2000,6 +1982,7 @@ static void bspline_doEffect(SPCurve * curve) //Definimos el punto de inicio original de la curva resultante node = startNode; }else{ + isBSpline = true; //Guardamos el principio de la curva startNode = in->first_segment()->initialPoint(); //Definimos el punto de inicio original de la curva resultante @@ -2037,13 +2020,16 @@ static void bspline_doEffect(SPCurve * curve) node = SBasisHelper.valueAt(0.5); //Vemos si el nodo es BSpline o CUSP //Averiguamos si el punto de union tiene manejadores - if (Geom::CubicBezier const *cubic = dynamic_cast(&*curve_it1)){ - if((*cubic)[2] == (*cubic)[3]) - isBSpline = true; - } + cubic = dynamic_cast(&*curve_it1); + if(cubic && (*cubic)[2] != (*cubic)[3]) + isBSpline = false; + cubic = dynamic_cast(&*curve_it2); + if(cubic && (*cubic)[0] != (*cubic)[1]) + isBSpline = false; //Si no tiene manejador, tenemos que generar la curva con nodo final CUSP if(!isBSpline ){ //Definimos como nodo el final del segmento de entrada + isBSpline = true; node = pointAt3; } curveHelper->moveto(previousNode); @@ -2071,6 +2057,7 @@ static void bspline_doEffect(SPCurve * curve) curveHelper->curveto(nextPointAt1, nextPointAt2, startNode); }else{ curveHelper->curveto(nextPointAt1, nextPointAt2, nextPointAt3); + isBSpline = true; } //añadimos este último segmento nCurve->append_continuous(curveHelper, 0.0625); @@ -2128,7 +2115,7 @@ static void spdc_pen_set_subsequent_point(SPPenContext *const pc, Geom::Point co } else { // one of the 'regular' modes //SpiroLive - if (pc->p[1] != pc->p[0] || pc->spiro) { + if (pc->p[1] != pc->p[0] || pc->spiro ) { //SpiroLive End pc->red_curve->curveto(pc->p[1], p, p); is_curve = true; -- cgit v1.2.3 From 1a2b144ddb576654cf6672db8528901db92f0e20 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 6 Jan 2013 20:52:24 +0100 Subject: Fixed StartAnchor continue errors with bspline (bzr r11950.1.13) --- src/pen-context.cpp | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/pen-context.cpp b/src/pen-context.cpp index eef82e379..936000c9c 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -1801,24 +1801,22 @@ static void spiro_doEffect(SPCurve * curve) static void bspline(SPPenContext *const pc, bool Shift) { if(Shift){ + + using Geom::X; + using Geom::Y; //Continuamos la curva en modo CUSP //Guardamos el valor de inicio en cusp para que no se redibuje como SYMM if(pc->anchor_statusbar && pc->red_curve->is_empty()){ saShift = true; } - using Geom::X; - using Geom::Y; - - //NODO CUSP formado por nodo SMOOTH - //solo mobemos el manejador del nodo final de cada segmento - //Es suficiente para mostrar el nodo como CUSP - //Usamos 5 puntos - //Continuamos la curva en modo CUSP - //Guardamos el valor de inicio en cusp para que no se redibuje como SYMM - + //NODO CUSP formado por nodo SMOOTH + //solo mobemos el manejador del nodo final de cada segmento + //Es suficiente para mostrar el nodo como CUSP + //Usamos 5 puntos if(!pc->red_curve->is_empty()){ pc->npoints = 5; pc->p[0] = pc->red_curve->first_segment()->initialPoint(); + pc->p[1] = pc->p[0]; pc->p[3] = pc->red_curve->first_segment()->finalPoint(); pc->p[4] = pc->p[3]; pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); @@ -1832,11 +1830,17 @@ static void bspline(SPPenContext *const pc, bool Shift) //Damos valor original a la variable por si se necesita de nuevo saShift = false; } - //Modo Bspline formado por nodos CUSP + + //Modo Bspline formado por nodos CUSP if (pc->npoints == 5 || !pc->red_curve->is_empty()){ - pc->p[2]= pc->p[3]; - if(pc->green_curve->is_empty() && saShift) - pc->p[1] = pc->p[0] + (1./3)*(pc->p[0] - pc->p[3]); + pc->npoints = 2; + pc->p[1]= pc->p[3]; + } + if(pc->green_curve->is_empty() && saShift){ + pc->npoints = 5; + pc->p[3] = pc->p[1]; + pc->p[2] = pc->p[3]; + pc->p[1] = pc->p[0] + (1./3)*(pc->p[0] - pc->p[3]); } } bspline_build(pc); @@ -1847,7 +1851,6 @@ static void bspline(SPPenContext *const pc, bool Shift) //preparates the curves for its trasformation into BSline curves. static void bspline_build(SPPenContext *const pc) { - //We create the base curve SPCurve *curve = new SPCurve(); //If we continuate the existing curve we add it at the start @@ -1879,8 +1882,7 @@ static void bspline_build(SPPenContext *const pc) if(Geom::are_near(curve->first_path()->initialPoint(), curve->last_path()->finalPoint())){ curve->closepath_current(); } - - //TODO: CALL TO CLONED FUNCTION BSPLINE::doEffect IN lpe-bspline.cpp + //TODO: CALL TO CLONED FUNCTION SPIRO::doEffect IN lpe-spiro.cpp //For example //using namespace Inkscape::LivePathEffect; //LivePathEffectObject *lpeobj = static_cast (curve); @@ -2115,7 +2117,7 @@ static void spdc_pen_set_subsequent_point(SPPenContext *const pc, Geom::Point co } else { // one of the 'regular' modes //SpiroLive - if (pc->p[1] != pc->p[0] || pc->spiro ) { + if (pc->p[1] != pc->p[0] || pc->spiro) { //SpiroLive End pc->red_curve->curveto(pc->p[1], p, p); is_curve = true; @@ -2225,7 +2227,7 @@ static void spdc_pen_finish(SPPenContext *const pc, gboolean const closed) if(pc->bspline && pc->green_curve->get_segment_count() < 2 && !pc->sa ) return; //BSpline End - + pc->num_clicks = 0; pen_disable_events(pc); -- cgit v1.2.3 From 209a1bb14d539824b0c45f5354b471e5596fcf70 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 7 Jan 2013 02:10:39 +0100 Subject: Update name (bzr r11950.1.15) --- src/pencil-context.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp index 32248d9b6..4ddeb6a4f 100644 --- a/src/pencil-context.cpp +++ b/src/pencil-context.cpp @@ -788,6 +788,7 @@ interpolate(SPPencilContext *pc) }else{ pc->green_curve->curveto(b[4*c+1], b[4*c+2], b[4*c+3]); } + //BSpline } sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), pc->green_curve); -- cgit v1.2.3 From eeb9410c8748a03536119dd01615cda3ca215cb1 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 8 Jan 2013 01:57:47 +0100 Subject: Fix BSplines whit 1 segment (bzr r11950.1.16) --- src/live_effects/lpe-bspline.cpp | 2 ++ src/pen-context.cpp | 8 ++------ src/pencil-context.cpp | 9 ++++++--- 3 files changed, 10 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index a57cc9a88..a1f51de0b 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -43,6 +43,8 @@ LPEBSpline::doEffect(SPCurve * curve) using Geom::X; using Geom::Y; + if(curve->get_segment_count() < 2) + return; // Make copy of old path as it is changed during processing Geom::PathVector const original_pathv = curve->get_pathvector(); curve->reset(); diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 936000c9c..bc57fc603 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -1909,7 +1909,8 @@ static void bspline_doEffect(SPCurve * curve) { using Geom::X; using Geom::Y; - + if(curve->get_segment_count() < 2) + return; // Make copy of old path as it is changed during processing Geom::PathVector const original_pathv = curve->get_pathvector(); curve->reset(); @@ -2223,11 +2224,6 @@ static void spdc_pen_finish(SPPenContext *const pc, gboolean const closed) return; } - //BSpline - if(pc->bspline && pc->green_curve->get_segment_count() < 2 && !pc->sa ) - return; - //BSpline End - pc->num_clicks = 0; pen_disable_events(pc); diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp index 4ddeb6a4f..cce04abb7 100644 --- a/src/pencil-context.cpp +++ b/src/pencil-context.cpp @@ -779,10 +779,12 @@ interpolate(SPPencilContext *pc) { /* Fit and draw and reset state */ pc->green_curve->moveto(b[0]); + //BSpline + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + guint mode = prefs->getInt("/tools/freehand/pencil/freehand-mode", 0); + //BSpline End for (int c = 0; c < n_segs; c++) { - //BSpline - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - guint mode = prefs->getInt("/tools/freehand/pencil/freehand-mode", 0); + //BSpline if(mode == 2){ pc->green_curve->lineto(b[4*c+3]); }else{ @@ -790,6 +792,7 @@ interpolate(SPPencilContext *pc) } //BSpline } + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), pc->green_curve); /* Fit and draw and copy last point */ -- cgit v1.2.3 From 45c35505428e178b32c8f32f85058e4d894bd62d Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 18 Jan 2013 23:32:27 +0100 Subject: Delete bspline node whith node tool and fix 1 segment continue shift error (bzr r11950.1.17) --- src/pen-context.cpp | 4 +++- src/ui/tool/multi-path-manipulator.cpp | 11 ++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/pen-context.cpp b/src/pen-context.cpp index bc57fc603..a5b79cf82 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -2225,7 +2225,9 @@ static void spdc_pen_finish(SPPenContext *const pc, gboolean const closed) } pc->num_clicks = 0; - + if(pc->spiro || pc->bspline){ + saShift = false; + } pen_disable_events(pc); SPDesktop *const desktop = pc->desktop; diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp index 1f074c8da..c9e35e5b2 100644 --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@ -671,7 +671,16 @@ bool MultiPathManipulator::event(SPEventContext *event_context, GdkEvent *event) // a) del preserves shape, and control is not pressed // b) ctrl+del preserves shape (del_preserves_shape is false), and control is pressed // Hence xor - deleteNodes(del_preserves_shape ^ held_control(event->key)); + guint mode = prefs->getInt("/tools/freehand/pen/freehand-mode", 0); + if(mode==2){ + if(del_preserves_shape ^ held_control(event->key)) + deleteNodes(false); + else + deleteNodes(true); + } + else + //BSpline end + deleteNodes(del_preserves_shape ^ held_control(event->key)); // Delete any selected gradient nodes as well event_context->deleteSelectedDrag(held_control(event->key)); -- cgit v1.2.3 From e7f30f2084fa4b7169f36012afe7230ac61d2628 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 10 Feb 2013 02:53:57 +0100 Subject: Fix a obsolete dep on src CMake List (bzr r11950.1.23) --- src/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3cc3df1bc..a8925e24f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -188,7 +188,6 @@ set(inkscape_SRC composite-undo-stack-observer.cpp conditions.cpp conn-avoid-ref.cpp - connection-points.cpp connector-context.cpp console-output-undo-observer.cpp context-fns.cpp @@ -332,7 +331,6 @@ set(inkscape_SRC composite-undo-stack-observer.h conditions.h conn-avoid-ref.h - connection-points.h connection-pool.h connector-context.h console-output-undo-observer.h -- cgit v1.2.3 From 91942b752107bb44bbc64af31d5912a8b04c815a Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 13 Feb 2013 00:07:12 +0100 Subject: First attempt for Adjustable Wheight (bzr r11950.1.28) --- src/live_effects/lpe-bspline.cpp | 82 +++++++++++--------------------- src/live_effects/lpe-bspline.h | 2 - src/pen-context.cpp | 100 ++++++++++++++++----------------------- 3 files changed, 69 insertions(+), 115 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index a1f51de0b..8a01beabd 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -53,14 +53,14 @@ LPEBSpline::doEffect(SPCurve * curve) Geom::D2< Geom::SBasis > SBasisOut; Geom::D2< Geom::SBasis > SBasisEnd; Geom::D2< Geom::SBasis > SBasisHelper; - //curves - SPCurve * in = new SPCurve(); - SPCurve * out = new SPCurve(); - SPCurve * end = new SPCurve(); //Curvas temporales SPCurve *lineHelper = new SPCurve(); SPCurve *curveHelper = new SPCurve(); SPCurve *nCurve = new SPCurve(); + //curves + SPCurve * in = new SPCurve(); + SPCurve * out = new SPCurve(); + SPCurve * end = new SPCurve(); //Puntos a usar. Ponemos todos los posibles para hacer más inteligible el código Geom::Point startNode(0,0); Geom::Point previousNode(0,0); @@ -74,7 +74,9 @@ LPEBSpline::doEffect(SPCurve * curve) Geom::Point nextPointAt1(0,0); Geom::Point nextPointAt2(0,0); Geom::Point nextPointAt3(0,0); - Geom::CubicBezier const *cubic; + Geom::CubicBezier const *cubicIn; + Geom::CubicBezier const *cubicOut; + Geom::CubicBezier const *cubicEnd; //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { //Si está vacío... @@ -86,9 +88,6 @@ LPEBSpline::doEffect(SPCurve * curve) Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve Geom::Path::const_iterator curve_end = path_it->end(); // end curve Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop - //Las lineas rectas forman nodos BSpline - //Las curvas forman nodos CUSP - bool isBSpline = true; //Creamos las lineas rectas que unen todos los puntos del trazado y donde se calcularán //los puntos clave para los manejadores. //Esto hace que la curva BSpline no pierda su condición aunque se trasladen @@ -100,31 +99,22 @@ LPEBSpline::doEffect(SPCurve * curve) //este no cambia. end->moveto(curve_end->initialPoint()); end->lineto(curve_end->finalPoint()); + //Si la curva está cerrada calculamos el punto donde //deveria estar el nodo BSpline de cierre/inicio de la curva //en posible caso de que se cierre con una linea recta creando un nodo BSPline - cubic = dynamic_cast(&*curve_end); - if(cubic && (*cubic)[2] != (*cubic)[3]) - isBSpline = false; - if (path_it->closed() && isBSpline) { - //Calculamos el nodo de inicio BSpline - SBasisIn = in->first_segment()->toSBasis(); - SBasisEnd = end->first_segment()->toSBasis(); - lineHelper->moveto(SBasisIn.valueAt(0.3334)); - lineHelper->lineto(SBasisEnd.valueAt(0.6667)); - SBasisHelper = lineHelper->first_segment()->toSBasis(); - lineHelper->reset(); - //Guardamos el principio de la curva - startNode = SBasisHelper.valueAt(0.5); - //Definimos el punto de inicio original de la curva resultante - node = startNode; - }else{ - isBSpline = true; - //Guardamos el principio de la curva - startNode = in->first_segment()->initialPoint(); - //Definimos el punto de inicio original de la curva resultante - node = startNode; - } + cubicIn = dynamic_cast(&*curve_it1); + cubicOut = dynamic_cast(&*curve_it2); + cubicEnd = dynamic_cast(&*curve_end); + //Calculamos el nodo de inicio BSpline + lineHelper->moveto(SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[1],*in->first_segment()))); + lineHelper->lineto(SBasisEnd.valueAt(Geom::nearest_point((*cubicEnd)[2],*end->first_segment()))); + SBasisHelper = lineHelper->first_segment()->toSBasis(); + lineHelper->reset(); + //Guardamos el principio de la curva + startNode = SBasisHelper.valueAt(0.5); + //Definimos el punto de inicio original de la curva resultante + node = startNode; //Recorremos todos los segmentos menos el último while ( curve_it2 != curve_endit ) { @@ -134,14 +124,15 @@ LPEBSpline::doEffect(SPCurve * curve) //previousPointAt3 = pointAt3; //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida pointAt0 = SBasisIn.valueAt(0); - pointAt1 = SBasisIn.valueAt(0.3334); - pointAt2 = SBasisIn.valueAt(0.6667); + pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[1],*in->first_segment())); + pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[2],*in->first_segment())); pointAt3 = SBasisIn.valueAt(1); //Y hacemos lo propio con el path de salida //nextPointAt0 = curveOut.valueAt(0); - nextPointAt1 = SBasisOut.valueAt(0.3334); - nextPointAt2 = SBasisOut.valueAt(0.6667);; + nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubicOut)[1],*in->first_segment())); + nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*cubicOut)[1],*out->first_segment())); nextPointAt3 = SBasisOut.valueAt(1); + //La curva BSpline se forma calculando el centro del segmanto de unión //de el punto situado en las 2/3 partes de el segmento de entrada //con el punto situado en la posición 1/3 del segmento de salida @@ -155,20 +146,6 @@ LPEBSpline::doEffect(SPCurve * curve) previousNode = node; //Y este hará de final de curva node = SBasisHelper.valueAt(0.5); - //Vemos si el nodo es BSpline o CUSP - //Averiguamos si el punto de union tiene manejadores - cubic = dynamic_cast(&*curve_it1); - if(cubic && (*cubic)[2] != (*cubic)[3]) - isBSpline = false; - cubic = dynamic_cast(&*curve_it2); - if(cubic && (*cubic)[0] != (*cubic)[1]) - isBSpline = false; - //Si no tiene manejador, tenemos que generar la curva con nodo final CUSP - if(!isBSpline ){ - //Definimos como nodo el final del segmento de entrada - isBSpline = true; - node = pointAt3; - } curveHelper->moveto(previousNode); curveHelper->curveto(pointAt1, pointAt2, node); //añadimos la curva generada a la curva pricipal @@ -177,6 +154,7 @@ LPEBSpline::doEffect(SPCurve * curve) //aumentamos los valores para el siguiente paso en el bucle ++curve_it1; ++curve_it2; + //Damos valor a el objeto para el path de entrada y el de salida in->reset(); in->moveto(curve_it1->initialPoint()); in->lineto(curve_it1->finalPoint()); @@ -185,6 +163,8 @@ LPEBSpline::doEffect(SPCurve * curve) out->moveto(curve_it2->initialPoint()); out->lineto(curve_it2->finalPoint()); } + cubicIn = dynamic_cast(&*curve_it1); + cubicOut = dynamic_cast(&*curve_it2); } //Aberiguamos la ultima parte de la curva correspondiente al último segmento curveHelper->moveto(node); @@ -194,7 +174,6 @@ LPEBSpline::doEffect(SPCurve * curve) curveHelper->curveto(nextPointAt1, nextPointAt2, startNode); }else{ curveHelper->curveto(nextPointAt1, nextPointAt2, nextPointAt3); - isBSpline = true; } //añadimos este último segmento nCurve->append_continuous(curveHelper, 0.0625); @@ -217,13 +196,8 @@ LPEBSpline::doEffect(SPCurve * curve) delete lineHelper; delete curveHelper; //Todo: remove? - //delete SBasisIn; - //delete SBasisOut; - //delete SBasisEnd; //delete SBasisHelper; } - - }; //namespace LivePathEffect }; /* namespace Inkscape */ diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index 23ac495df..898f638ed 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -18,8 +18,6 @@ public: LPEBSpline(LivePathEffectObject *lpeobject); virtual ~LPEBSpline(); - virtual LPEPathFlashType pathFlashType() { return SUPPRESS_FLASH; } - virtual SPCurve *reverse_then_reset(SPCurve * orig); virtual void doEffect(SPCurve * curve); diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 3055f8504..9e5bb836f 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -1772,10 +1772,11 @@ static void spiro_doEffect(SPCurve * curve) //Unimos todas las curvas en juego y llamamos a la función doEffect. static void bspline(SPPenContext *const pc, bool Shift) { - if(Shift){ + if(!Shift){ using Geom::X; using Geom::Y; + Geom::CubicBezier const *cubic; //Continuamos la curva en modo CUSP //Guardamos el valor de inicio en cusp para que no se redibuje como SYMM if(pc->anchor_statusbar && pc->red_curve->is_empty()){ @@ -1788,11 +1789,16 @@ static void bspline(SPPenContext *const pc, bool Shift) if(!pc->red_curve->is_empty()){ pc->npoints = 5; pc->p[0] = pc->red_curve->first_segment()->initialPoint(); - pc->p[1] = pc->p[0]; + if(pc->green_curve->is_empty()) + pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[1]); + else + cubic = dynamic_cast(&*pc->green_curve->last_segment() + if(cubic && (*cubic)[2] == (*cubicIn)[3]) + pc->p[1] = pc->p[0]; + else + pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[1]); pc->p[3] = pc->red_curve->first_segment()->finalPoint(); - pc->p[4] = pc->p[3]; pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); - pc->p[2] = Geom::Point(pc->p[2][X]+1,pc->p[2][Y]+1); } }else{ if(pc->anchor_statusbar && pc->red_curve->is_empty()){ @@ -1803,7 +1809,6 @@ static void bspline(SPPenContext *const pc, bool Shift) saShift = false; } - //Modo Bspline formado por nodos CUSP if (pc->npoints == 5 || !pc->red_curve->is_empty()){ pc->npoints = 2; pc->p[1]= pc->p[3]; @@ -1881,8 +1886,9 @@ static void bspline_doEffect(SPCurve * curve) { using Geom::X; using Geom::Y; + if(curve->get_segment_count() < 2) - return; + return; // Make copy of old path as it is changed during processing Geom::PathVector const original_pathv = curve->get_pathvector(); curve->reset(); @@ -1891,14 +1897,14 @@ static void bspline_doEffect(SPCurve * curve) Geom::D2< Geom::SBasis > SBasisOut; Geom::D2< Geom::SBasis > SBasisEnd; Geom::D2< Geom::SBasis > SBasisHelper; - //curves - SPCurve * in = new SPCurve(); - SPCurve * out = new SPCurve(); - SPCurve * end = new SPCurve(); //Curvas temporales SPCurve *lineHelper = new SPCurve(); SPCurve *curveHelper = new SPCurve(); SPCurve *nCurve = new SPCurve(); + //curves + SPCurve * in = new SPCurve(); + SPCurve * out = new SPCurve(); + SPCurve * end = new SPCurve(); //Puntos a usar. Ponemos todos los posibles para hacer más inteligible el código Geom::Point startNode(0,0); Geom::Point previousNode(0,0); @@ -1912,7 +1918,9 @@ static void bspline_doEffect(SPCurve * curve) Geom::Point nextPointAt1(0,0); Geom::Point nextPointAt2(0,0); Geom::Point nextPointAt3(0,0); - Geom::CubicBezier const *cubic; + Geom::CubicBezier const *cubicIn; + Geom::CubicBezier const *cubicOut; + Geom::CubicBezier const *cubicEnd; //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { //Si está vacío... @@ -1924,9 +1932,6 @@ static void bspline_doEffect(SPCurve * curve) Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve Geom::Path::const_iterator curve_end = path_it->end(); // end curve Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop - //Las lineas rectas forman nodos BSpline - //Las curvas forman nodos CUSP - bool isBSpline = true; //Creamos las lineas rectas que unen todos los puntos del trazado y donde se calcularán //los puntos clave para los manejadores. //Esto hace que la curva BSpline no pierda su condición aunque se trasladen @@ -1938,31 +1943,22 @@ static void bspline_doEffect(SPCurve * curve) //este no cambia. end->moveto(curve_end->initialPoint()); end->lineto(curve_end->finalPoint()); + //Si la curva está cerrada calculamos el punto donde //deveria estar el nodo BSpline de cierre/inicio de la curva //en posible caso de que se cierre con una linea recta creando un nodo BSPline - cubic = dynamic_cast(&*curve_end); - if(cubic && (*cubic)[2] != (*cubic)[3]) - isBSpline = false; - if (path_it->closed() && isBSpline) { - //Calculamos el nodo de inicio BSpline - SBasisIn = in->first_segment()->toSBasis(); - SBasisEnd = end->first_segment()->toSBasis(); - lineHelper->moveto(SBasisIn.valueAt(0.3334)); - lineHelper->lineto(SBasisEnd.valueAt(0.6667)); - SBasisHelper = lineHelper->first_segment()->toSBasis(); - lineHelper->reset(); - //Guardamos el principio de la curva - startNode = SBasisHelper.valueAt(0.5); - //Definimos el punto de inicio original de la curva resultante - node = startNode; - }else{ - isBSpline = true; - //Guardamos el principio de la curva - startNode = in->first_segment()->initialPoint(); - //Definimos el punto de inicio original de la curva resultante - node = startNode; - } + cubicIn = dynamic_cast(&*curve_it1); + cubicOut = dynamic_cast(&*curve_it2); + cubicEnd = dynamic_cast(&*curve_end); + //Calculamos el nodo de inicio BSpline + lineHelper->moveto(SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[1],*in->first_segment()))); + lineHelper->lineto(SBasisEnd.valueAt(Geom::nearest_point((*cubicEnd)[2],*end->first_segment()))); + SBasisHelper = lineHelper->first_segment()->toSBasis(); + lineHelper->reset(); + //Guardamos el principio de la curva + startNode = SBasisHelper.valueAt(0.5); + //Definimos el punto de inicio original de la curva resultante + node = startNode; //Recorremos todos los segmentos menos el último while ( curve_it2 != curve_endit ) { @@ -1972,14 +1968,15 @@ static void bspline_doEffect(SPCurve * curve) //previousPointAt3 = pointAt3; //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida pointAt0 = SBasisIn.valueAt(0); - pointAt1 = SBasisIn.valueAt(0.3334); - pointAt2 = SBasisIn.valueAt(0.6667); + pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[1],*in->first_segment())); + pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[2],*in->first_segment())); pointAt3 = SBasisIn.valueAt(1); //Y hacemos lo propio con el path de salida //nextPointAt0 = curveOut.valueAt(0); - nextPointAt1 = SBasisOut.valueAt(0.3334); - nextPointAt2 = SBasisOut.valueAt(0.6667);; + nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubicOut)[1],*in->first_segment())); + nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*cubicOut)[1],*out->first_segment())); nextPointAt3 = SBasisOut.valueAt(1); + //La curva BSpline se forma calculando el centro del segmanto de unión //de el punto situado en las 2/3 partes de el segmento de entrada //con el punto situado en la posición 1/3 del segmento de salida @@ -1993,20 +1990,6 @@ static void bspline_doEffect(SPCurve * curve) previousNode = node; //Y este hará de final de curva node = SBasisHelper.valueAt(0.5); - //Vemos si el nodo es BSpline o CUSP - //Averiguamos si el punto de union tiene manejadores - cubic = dynamic_cast(&*curve_it1); - if(cubic && (*cubic)[2] != (*cubic)[3]) - isBSpline = false; - cubic = dynamic_cast(&*curve_it2); - if(cubic && (*cubic)[0] != (*cubic)[1]) - isBSpline = false; - //Si no tiene manejador, tenemos que generar la curva con nodo final CUSP - if(!isBSpline ){ - //Definimos como nodo el final del segmento de entrada - isBSpline = true; - node = pointAt3; - } curveHelper->moveto(previousNode); curveHelper->curveto(pointAt1, pointAt2, node); //añadimos la curva generada a la curva pricipal @@ -2015,6 +1998,7 @@ static void bspline_doEffect(SPCurve * curve) //aumentamos los valores para el siguiente paso en el bucle ++curve_it1; ++curve_it2; + //Damos valor a el objeto para el path de entrada y el de salida in->reset(); in->moveto(curve_it1->initialPoint()); in->lineto(curve_it1->finalPoint()); @@ -2023,6 +2007,8 @@ static void bspline_doEffect(SPCurve * curve) out->moveto(curve_it2->initialPoint()); out->lineto(curve_it2->finalPoint()); } + cubicIn = dynamic_cast(&*curve_it1); + cubicOut = dynamic_cast(&*curve_it2); } //Aberiguamos la ultima parte de la curva correspondiente al último segmento curveHelper->moveto(node); @@ -2032,7 +2018,6 @@ static void bspline_doEffect(SPCurve * curve) curveHelper->curveto(nextPointAt1, nextPointAt2, startNode); }else{ curveHelper->curveto(nextPointAt1, nextPointAt2, nextPointAt3); - isBSpline = true; } //añadimos este último segmento nCurve->append_continuous(curveHelper, 0.0625); @@ -2055,12 +2040,9 @@ static void bspline_doEffect(SPCurve * curve) delete lineHelper; delete curveHelper; //Todo: remove? - //delete SBasisIn; - //delete SBasisOut; - //delete SBasisEnd; //delete SBasisHelper; } - + //BSpline end static void spdc_pen_set_subsequent_point(SPPenContext *const pc, Geom::Point const p, bool statusbar, guint status) -- cgit v1.2.3 From 8988dd2782f290d9b2e88290ce07384839560027 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 13 Feb 2013 01:00:39 +0100 Subject: Removed unused function (bzr r11950.2.2) --- src/live_effects/lpe-bspline.cpp | 8 +------- src/live_effects/lpe-bspline.h | 2 -- src/pen-context.cpp | 9 --------- 3 files changed, 1 insertion(+), 18 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index a1f51de0b..b8e6094f6 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -29,13 +29,7 @@ LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) : LPEBSpline::~LPEBSpline() { } -//Crea una nueva curva reseteando la original -SPCurve * -LPEBSpline::reverse_then_reset(SPCurve * orig){ - SPCurve *ret = orig->create_reverse(); - orig->reset(); - return ret; -} + void LPEBSpline::doEffect(SPCurve * curve) diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index 23ac495df..bb826eee8 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -20,8 +20,6 @@ public: virtual LPEPathFlashType pathFlashType() { return SUPPRESS_FLASH; } - virtual SPCurve *reverse_then_reset(SPCurve * orig); - virtual void doEffect(SPCurve * curve); private: diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 3055f8504..9056003e0 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -1472,15 +1472,6 @@ static void spdc_pen_set_angle_distance_status_message(SPPenContext *const pc, G } -//BSpline Set Functions -//Creates a new curve resetting the original -static SPCurve * reverse_then_reset(SPCurve *orig) -{ - SPCurve *ret = orig->create_reverse(); - orig->reset(); - return ret; -} - //Esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro static void spiro_color(SPPenContext *const pc) { -- cgit v1.2.3 From 23e56d5e362d55bb22edaf1070cbac0b604aee36 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 13 Feb 2013 03:55:29 +0100 Subject: First Steps, BSpline Live Path Ok, working Pen Context (bzr r11950.1.29) --- src/live_effects/lpe-bspline.cpp | 88 ++++++++++++-------- src/live_effects/lpe-bspline.h | 2 +- src/pen-context.cpp | 169 ++++++++++++++++++++++----------------- 3 files changed, 148 insertions(+), 111 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 8a01beabd..408f0f8a6 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -12,7 +12,6 @@ #include <2geom/bezier-curve.h> #include "helper/geom-curves.h" - // For handling un-continuous paths: #include "message-stack.h" #include "inkscape.h" @@ -29,13 +28,6 @@ LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) : LPEBSpline::~LPEBSpline() { } -//Crea una nueva curva reseteando la original -SPCurve * -LPEBSpline::reverse_then_reset(SPCurve * orig){ - SPCurve *ret = orig->create_reverse(); - orig->reset(); - return ret; -} void LPEBSpline::doEffect(SPCurve * curve) @@ -106,46 +98,70 @@ LPEBSpline::doEffect(SPCurve * curve) cubicIn = dynamic_cast(&*curve_it1); cubicOut = dynamic_cast(&*curve_it2); cubicEnd = dynamic_cast(&*curve_end); - //Calculamos el nodo de inicio BSpline - lineHelper->moveto(SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[1],*in->first_segment()))); - lineHelper->lineto(SBasisEnd.valueAt(Geom::nearest_point((*cubicEnd)[2],*end->first_segment()))); - SBasisHelper = lineHelper->first_segment()->toSBasis(); - lineHelper->reset(); - //Guardamos el principio de la curva - startNode = SBasisHelper.valueAt(0.5); - //Definimos el punto de inicio original de la curva resultante - node = startNode; + if (path_it->closed() && cubicIn && cubicEnd && (*cubicIn)[1] != (*cubicEnd)[2]){ + //Calculamos el nodo de inicio BSpline + SBasisIn = in->first_segment()->toSBasis(); + SBasisEnd = end->first_segment()->toSBasis(); + lineHelper->moveto(SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[1],*in->first_segment()))); + lineHelper->lineto(SBasisEnd.valueAt(Geom::nearest_point((*cubicEnd)[2],*end->first_segment()))); + SBasisHelper = lineHelper->first_segment()->toSBasis(); + lineHelper->reset(); + //Guardamos el principio de la curva + startNode = SBasisHelper.valueAt(0.5); + //Definimos el punto de inicio original de la curva resultante + node = startNode; + }else{ + startNode = in->first_segment()->initialPoint(); + node = startNode; + } //Recorremos todos los segmentos menos el último while ( curve_it2 != curve_endit ) { - //Damos valor a el objeto SBasis para el path de entrada y el de salida SBasisIn = in->first_segment()->toSBasis(); SBasisOut = out->first_segment()->toSBasis(); //previousPointAt3 = pointAt3; //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida - pointAt0 = SBasisIn.valueAt(0); - pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[1],*in->first_segment())); - pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[2],*in->first_segment())); - pointAt3 = SBasisIn.valueAt(1); + if(cubicIn){ + pointAt0 = SBasisIn.valueAt(0); + pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[1],*in->first_segment())); + pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[2],*in->first_segment())); + pointAt3 = SBasisIn.valueAt(1); + }else{ + pointAt0 = SBasisIn.valueAt(0); + pointAt1 = SBasisIn.valueAt(0); + pointAt2 = SBasisIn.valueAt(1); + pointAt3 = SBasisIn.valueAt(1); + } //Y hacemos lo propio con el path de salida //nextPointAt0 = curveOut.valueAt(0); - nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubicOut)[1],*in->first_segment())); - nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*cubicOut)[1],*out->first_segment())); - nextPointAt3 = SBasisOut.valueAt(1); - + if(cubicOut){ + nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubicOut)[1],*out->first_segment())); + nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*cubicOut)[2],*out->first_segment())); + nextPointAt3 = SBasisOut.valueAt(1); + }else{ + nextPointAt1 = SBasisOut.valueAt(0); + nextPointAt2 = SBasisOut.valueAt(1); + nextPointAt3 = SBasisOut.valueAt(1); + } //La curva BSpline se forma calculando el centro del segmanto de unión //de el punto situado en las 2/3 partes de el segmento de entrada //con el punto situado en la posición 1/3 del segmento de salida //Estos dos puntos ademas estan posicionados en el lugas correspondiente de //los manejadores de la curva - lineHelper->moveto(pointAt2); - lineHelper->lineto(nextPointAt1); - SBasisHelper = lineHelper->first_segment()->toSBasis(); - lineHelper->reset(); - //almacenamos el punto del anterior bucle -o el de cierre- que nos hara de principio de curva - previousNode = node; - //Y este hará de final de curva - node = SBasisHelper.valueAt(0.5); + if(nextPointAt1 != pointAt2){ + lineHelper->moveto(pointAt2); + lineHelper->lineto(nextPointAt1); + SBasisHelper = lineHelper->first_segment()->toSBasis(); + lineHelper->reset(); + //almacenamos el punto del anterior bucle -o el de cierre- que nos hara de principio de curva + previousNode = node; + //Y este hará de final de curva + node = SBasisHelper.valueAt(0.5); + }else{ + previousNode = node; + //Y este hará de final de curva + node = nextPointAt1; + } curveHelper->moveto(previousNode); curveHelper->curveto(pointAt1, pointAt2, node); //añadimos la curva generada a la curva pricipal @@ -162,9 +178,10 @@ LPEBSpline::doEffect(SPCurve * curve) if(curve_it1 != curve_end){ out->moveto(curve_it2->initialPoint()); out->lineto(curve_it2->finalPoint()); + cubicOut = dynamic_cast(&*curve_it2); } cubicIn = dynamic_cast(&*curve_it1); - cubicOut = dynamic_cast(&*curve_it2); + } //Aberiguamos la ultima parte de la curva correspondiente al último segmento curveHelper->moveto(node); @@ -198,6 +215,7 @@ LPEBSpline::doEffect(SPCurve * curve) //Todo: remove? //delete SBasisHelper; } + }; //namespace LivePathEffect }; /* namespace Inkscape */ diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index 898f638ed..d983a7654 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -18,7 +18,7 @@ public: LPEBSpline(LivePathEffectObject *lpeobject); virtual ~LPEBSpline(); - virtual SPCurve *reverse_then_reset(SPCurve * orig); + virtual LPEPathFlashType pathFlashType() const { return SUPPRESS_FLASH; } virtual void doEffect(SPCurve * curve); diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 9e5bb836f..3c8e46a54 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -65,8 +65,10 @@ #include "live_effects/spiro.h" + #define INKSCAPE_LPE_BSPLINE_C #include "live_effects/lpe-bspline.h" +#include <2geom/nearest-point.h> //BSpline End using Inkscape::ControlManager; @@ -1060,7 +1062,8 @@ static void pen_lastpoint_tocurve (SPPenContext *const pc) return; //BSpline Geom::CubicBezier const * cubic; - + if(!pc->bspline) + pc->p[1] = pc->p[0]; //Para formar una curva necesitamos un nodo symm en el "lastpoint" //de esta manera modificamos el final de la "curva_verde" para que sea symm con el pricipio de la "red_curve" if(pc->spiro){ @@ -1094,27 +1097,25 @@ static void pen_lastpoint_tocurve (SPPenContext *const pc) } } - if(!pc->bspline){ - cubic = dynamic_cast( pc->green_curve->last_segment() ); - if ( cubic ) { - pc->p[1] = pc->p[0] + (Geom::Point)( pc->p[0] - (*cubic)[2] ); - } else { - pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]); - } - } - - //Para formar una curva bspline necesitamos un nodo cusp en el "lastpoint" - //de esta manera modificamos el final de la "curva_verde" para que sea cusp con el pricipio de la "red_curve" - //Que se quedará recta - if(pc->bspline){ +//BSpline + //Para formar una recta necesitamos un nodo con manejador en el "lastpoint" + //de esta manera modificamos el final de la "curva_verde" para que tenga manejador + if(pc->bspline && !pc->green_curve->is_empty()){ Geom::Point A(0,0); Geom::Point B(0,0); + Geom::Point C(0,0); + Geom::Point D(0,0); + using Geom::X; + using Geom::Y; SPCurve * previous = new SPCurve(); - //We obtain the last segment 2 points in the previous curve + //We obtain the last segment 4 points in the previous curve A = pc->green_curve->last_segment()->initialPoint(); - B = pc->green_curve->last_segment()->finalPoint(); + B = pc->green_curve->last_segment()->initialPoint(); + C = pc->green_curve->last_segment()->finalPoint() + (1./3)* (Geom::Point)(pc->green_curve->last_segment()->initialPoint() - pc->green_curve->last_segment()->finalPoint()); + pc->p[1] = pc->p[0] + (1./3)*(C - pc->p[0]); + D = pc->green_curve->last_segment()->finalPoint(); previous->moveto(A); - previous->lineto(B); + previous->curveto(B, C, D); if( pc->green_curve->get_segment_count() == 1){ pc->green_curve = previous; }else{ @@ -1123,7 +1124,6 @@ static void pen_lastpoint_tocurve (SPPenContext *const pc) //and we add it again with the recreation pc->green_curve->append_continuous(previous, 0.0625); } - } //Spiro Live pen_redraw_all(pc); @@ -1135,8 +1135,7 @@ static void pen_lastpoint_toline (SPPenContext *const pc) //Si no es bspline if (pc->npoints != 5 && !pc->bspline) return; - if(!pc->bspline) - pc->p[1] = pc->p[0]; + Geom::CubicBezier const * cubic; if(pc->spiro){ Geom::Point A(0,0); Geom::Point B(0,0); @@ -1168,25 +1167,28 @@ static void pen_lastpoint_toline (SPPenContext *const pc) pc->green_curve->append_continuous(previous, 0.0625); } } - //BSpline - //Para formar una recta necesitamos un nodo con manejador en el "lastpoint" - //de esta manera modificamos el final de la "curva_verde" para que tenga manejador - if(pc->bspline && !pc->green_curve->is_empty()){ + + if(!pc->bspline){ + cubic = dynamic_cast( pc->green_curve->last_segment() ); + if ( cubic ) { + pc->p[1] = pc->p[0] + (Geom::Point)( pc->p[0] - (*cubic)[2] ); + } else { + pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]); + } + } + + //Para formar una curva bspline necesitamos un nodo cusp en el "lastpoint" + //de esta manera modificamos el final de la "curva_verde" para que sea cusp con el pricipio de la "red_curve" + //Que se quedará recta + if(pc->bspline){ Geom::Point A(0,0); Geom::Point B(0,0); - Geom::Point C(0,0); - Geom::Point D(0,0); - using Geom::X; - using Geom::Y; SPCurve * previous = new SPCurve(); - //We obtain the last segment 4 points in the previous curve + //We obtain the last segment 2 points in the previous curve A = pc->green_curve->last_segment()->initialPoint(); - B = pc->green_curve->last_segment()->initialPoint(); - C = pc->green_curve->last_segment()->finalPoint() + (1./3)* (Geom::Point)(pc->green_curve->last_segment()->initialPoint() - pc->green_curve->last_segment()->finalPoint()); - C = Geom::Point(C[X]+1,C[Y]+1); - D = pc->green_curve->last_segment()->finalPoint(); + B = pc->green_curve->last_segment()->finalPoint(); previous->moveto(A); - previous->curveto(B, C, D); + previous->lineto(B); if( pc->green_curve->get_segment_count() == 1){ pc->green_curve = previous; }else{ @@ -1195,8 +1197,8 @@ static void pen_lastpoint_toline (SPPenContext *const pc) //and we add it again with the recreation pc->green_curve->append_continuous(previous, 0.0625); } + } - pen_redraw_all(pc); } @@ -1472,14 +1474,6 @@ static void spdc_pen_set_angle_distance_status_message(SPPenContext *const pc, G } -//BSpline Set Functions -//Creates a new curve resetting the original -static SPCurve * reverse_then_reset(SPCurve *orig) -{ - SPCurve *ret = orig->create_reverse(); - orig->reset(); - return ret; -} //Esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro static void spiro_color(SPPenContext *const pc) @@ -1789,15 +1783,15 @@ static void bspline(SPPenContext *const pc, bool Shift) if(!pc->red_curve->is_empty()){ pc->npoints = 5; pc->p[0] = pc->red_curve->first_segment()->initialPoint(); + pc->p[3] = pc->red_curve->first_segment()->finalPoint(); if(pc->green_curve->is_empty()) - pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[1]); + pc->p[1] = pc->p[0] + (1./3)*(pc->p[0] - pc->p[3]); else - cubic = dynamic_cast(&*pc->green_curve->last_segment() - if(cubic && (*cubic)[2] == (*cubicIn)[3]) + cubic = dynamic_cast(&*pc->green_curve->last_segment()); + if(cubic && ((*cubic)[2] == (*cubic)[3])) pc->p[1] = pc->p[0]; else - pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[1]); - pc->p[3] = pc->red_curve->first_segment()->finalPoint(); + pc->p[1] = pc->p[0] + (1./3)*(pc->p[0] - pc->p[3]); pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); } }else{ @@ -1950,46 +1944,70 @@ static void bspline_doEffect(SPCurve * curve) cubicIn = dynamic_cast(&*curve_it1); cubicOut = dynamic_cast(&*curve_it2); cubicEnd = dynamic_cast(&*curve_end); - //Calculamos el nodo de inicio BSpline - lineHelper->moveto(SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[1],*in->first_segment()))); - lineHelper->lineto(SBasisEnd.valueAt(Geom::nearest_point((*cubicEnd)[2],*end->first_segment()))); - SBasisHelper = lineHelper->first_segment()->toSBasis(); - lineHelper->reset(); - //Guardamos el principio de la curva - startNode = SBasisHelper.valueAt(0.5); - //Definimos el punto de inicio original de la curva resultante - node = startNode; + if (path_it->closed() && cubicIn && cubicEnd && (*cubicIn)[1] != (*cubicEnd)[2]){ + //Calculamos el nodo de inicio BSpline + SBasisIn = in->first_segment()->toSBasis(); + SBasisEnd = end->first_segment()->toSBasis(); + lineHelper->moveto(SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[1],*in->first_segment()))); + lineHelper->lineto(SBasisEnd.valueAt(Geom::nearest_point((*cubicEnd)[2],*end->first_segment()))); + SBasisHelper = lineHelper->first_segment()->toSBasis(); + lineHelper->reset(); + //Guardamos el principio de la curva + startNode = SBasisHelper.valueAt(0.5); + //Definimos el punto de inicio original de la curva resultante + node = startNode; + }else{ + startNode = in->first_segment()->initialPoint(); + node = startNode; + } //Recorremos todos los segmentos menos el último while ( curve_it2 != curve_endit ) { - //Damos valor a el objeto SBasis para el path de entrada y el de salida SBasisIn = in->first_segment()->toSBasis(); SBasisOut = out->first_segment()->toSBasis(); //previousPointAt3 = pointAt3; //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida - pointAt0 = SBasisIn.valueAt(0); - pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[1],*in->first_segment())); - pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[2],*in->first_segment())); - pointAt3 = SBasisIn.valueAt(1); + if(cubicIn){ + pointAt0 = SBasisIn.valueAt(0); + pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[1],*in->first_segment())); + pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[2],*in->first_segment())); + pointAt3 = SBasisIn.valueAt(1); + }else{ + pointAt0 = SBasisIn.valueAt(0); + pointAt1 = SBasisIn.valueAt(0); + pointAt2 = SBasisIn.valueAt(1); + pointAt3 = SBasisIn.valueAt(1); + } //Y hacemos lo propio con el path de salida //nextPointAt0 = curveOut.valueAt(0); - nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubicOut)[1],*in->first_segment())); - nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*cubicOut)[1],*out->first_segment())); - nextPointAt3 = SBasisOut.valueAt(1); - + if(cubicOut){ + nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubicOut)[1],*out->first_segment())); + nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*cubicOut)[2],*out->first_segment())); + nextPointAt3 = SBasisOut.valueAt(1); + }else{ + nextPointAt1 = SBasisOut.valueAt(0); + nextPointAt2 = SBasisOut.valueAt(1); + nextPointAt3 = SBasisOut.valueAt(1); + } //La curva BSpline se forma calculando el centro del segmanto de unión //de el punto situado en las 2/3 partes de el segmento de entrada //con el punto situado en la posición 1/3 del segmento de salida //Estos dos puntos ademas estan posicionados en el lugas correspondiente de //los manejadores de la curva - lineHelper->moveto(pointAt2); - lineHelper->lineto(nextPointAt1); - SBasisHelper = lineHelper->first_segment()->toSBasis(); - lineHelper->reset(); - //almacenamos el punto del anterior bucle -o el de cierre- que nos hara de principio de curva - previousNode = node; - //Y este hará de final de curva - node = SBasisHelper.valueAt(0.5); + if(nextPointAt1 != pointAt2){ + lineHelper->moveto(pointAt2); + lineHelper->lineto(nextPointAt1); + SBasisHelper = lineHelper->first_segment()->toSBasis(); + lineHelper->reset(); + //almacenamos el punto del anterior bucle -o el de cierre- que nos hara de principio de curva + previousNode = node; + //Y este hará de final de curva + node = SBasisHelper.valueAt(0.5); + }else{ + previousNode = node; + //Y este hará de final de curva + node = nextPointAt1; + } curveHelper->moveto(previousNode); curveHelper->curveto(pointAt1, pointAt2, node); //añadimos la curva generada a la curva pricipal @@ -2006,9 +2024,10 @@ static void bspline_doEffect(SPCurve * curve) if(curve_it1 != curve_end){ out->moveto(curve_it2->initialPoint()); out->lineto(curve_it2->finalPoint()); + cubicOut = dynamic_cast(&*curve_it2); } cubicIn = dynamic_cast(&*curve_it1); - cubicOut = dynamic_cast(&*curve_it2); + } //Aberiguamos la ultima parte de la curva correspondiente al último segmento curveHelper->moveto(node); -- cgit v1.2.3 From 0905e866b43bc83405adc3b03a8db47956779c19 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 14 Feb 2013 03:18:29 +0100 Subject: Pen Context working in mode BSpline,Cusp mode to fix (bzr r11950.1.30) --- src/pen-context.cpp | 67 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 54 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 3c8e46a54..8d5887223 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -583,7 +583,7 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const //BSpline //Esto evita arrastrar los manejadores ya que el punto se crea //al soltar el botón del ratón. - if((pc->spiro || pc->bspline) && pc->state != SP_PEN_CONTEXT_CLOSE ) pc->state = SP_PEN_CONTEXT_POINT; + if(((pc->spiro || pc->bspline) && pc->state != SP_PEN_CONTEXT_CLOSE)&&!(pc->bspline && bevent.state & GDK_SHIFT_MASK) ) pc->state = SP_PEN_CONTEXT_POINT; //BSpline End ret = TRUE; break; @@ -984,8 +984,20 @@ static void pen_redraw_all (SPPenContext *const pc) // handles //BSpline - if (pc->p[0] != pc->p[1] && !pc->spiro && !pc->bspline) { + SPCurve * WPower = new SPCurve(); + Geom::D2< Geom::SBasis > SBasisWPower; + float WP = 0; + if (pc->p[0] != pc->p[1] && !pc->spiro /*&& !pc->bspline*/) { //BSpline End + if(pc->bspline){ + WPower->moveto(pc->red_curve->first_segment()->initialPoint()); + WPower->lineto(pc->red_curve->first_segment()->finalPoint()); + SBasisWPower = WPower->first_segment()->toSBasis(); + + WPower->reset(); + pc->p[1] = SBasisWPower.valueAt(WP); + } + SP_CTRL(pc->c1)->moveto(pc->p[1]); pc->cl1->setCoords(pc->p[0], pc->p[1]); sp_canvas_item_show(pc->c1); @@ -994,16 +1006,23 @@ static void pen_redraw_all (SPPenContext *const pc) sp_canvas_item_hide(pc->c1); sp_canvas_item_hide(pc->cl1); } - + Geom::Point p2; Geom::Curve const * last_seg = pc->green_curve->last_segment(); if (last_seg) { Geom::CubicBezier const * cubic = dynamic_cast( last_seg ); //BSpline if ( cubic && - (*cubic)[2] != pc->p[0]&& !pc->spiro && !pc->bspline ) + (*cubic)[2] != pc->p[0]&& !pc->spiro /*&& !pc->bspline*/ ) { //BSpline End - Geom::Point p2 = (*cubic)[2]; + if(pc->bspline){ + WPower->moveto(last_seg->finalPoint()); + WPower->lineto(last_seg->initialPoint()); + SBasisWPower = WPower->first_segment()->toSBasis(); + p2 = SBasisWPower.valueAt(WP); + }else{ + p2 = (*cubic)[2]; + } SP_CTRL(pc->c0)->moveto(p2); pc->cl0->setCoords(p2, pc->p[0]); sp_canvas_item_show(pc->c0); @@ -1784,15 +1803,35 @@ static void bspline(SPPenContext *const pc, bool Shift) pc->npoints = 5; pc->p[0] = pc->red_curve->first_segment()->initialPoint(); pc->p[3] = pc->red_curve->first_segment()->finalPoint(); - if(pc->green_curve->is_empty()) + if(pc->green_curve->is_empty()){ pc->p[1] = pc->p[0] + (1./3)*(pc->p[0] - pc->p[3]); - else + pc->p[1] = Geom::Point(pc->p[1][X]+1,pc->p[1][Y]+1); + }else{ cubic = dynamic_cast(&*pc->green_curve->last_segment()); - if(cubic && ((*cubic)[2] == (*cubic)[3])) + if(!cubic || ((*cubic)[2] == (*cubic)[3])) pc->p[1] = pc->p[0]; - else - pc->p[1] = pc->p[0] + (1./3)*(pc->p[0] - pc->p[3]); + else{ + if(cubic){ + SPCurve * WPower = new SPCurve(); + Geom::D2< Geom::SBasis > SBasisWPower; + WPower->moveto(pc->green_curve->last_segment()->finalPoint()); + WPower->lineto(pc->green_curve->last_segment()->initialPoint()); + float WP = Geom::nearest_point((*cubic)[2],*WPower->first_segment()); + WPower->reset(); + WPower->moveto(pc->red_curve->last_segment()->initialPoint()); + WPower->lineto(pc->red_curve->last_segment()->finalPoint()); + SBasisWPower = WPower->first_segment()->toSBasis(); + WPower->reset(); + pc->p[1] = SBasisWPower.valueAt(WP); + pc->p[1] = Geom::Point(pc->p[1][X]+1,pc->p[1][Y]+1); + }else{ + pc->p[1] = pc->p[0] + (1./3)*(pc->p[0] - pc->p[3]); + pc->p[1] = Geom::Point(pc->p[1][X]+1,pc->p[1][Y]+1); + } + } + } pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); + pc->p[2] = Geom::Point(pc->p[2][X]+1,pc->p[2][Y]+1); } }else{ if(pc->anchor_statusbar && pc->red_curve->is_empty()){ @@ -1803,9 +1842,11 @@ static void bspline(SPPenContext *const pc, bool Shift) saShift = false; } - if (pc->npoints == 5 || !pc->red_curve->is_empty()){ - pc->npoints = 2; - pc->p[1]= pc->p[3]; + if (!pc->red_curve->is_empty()){ + pc->npoints = 5; + pc->p[0] = pc->red_curve->first_segment()->finalPoint(); + pc->p[3] = pc->red_curve->first_segment()->initialPoint(); + pc->p[2] = pc->p[3]; } if(pc->green_curve->is_empty() && saShift){ pc->npoints = 5; -- cgit v1.2.3 From 28b44133e0d9df8054e17ed9724ea645220e1530 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 14 Feb 2013 06:01:26 +0100 Subject: All done except cusp continuous and close bspline (bzr r11950.1.32) --- src/live_effects/lpe-bspline.cpp | 2 +- src/pen-context.cpp | 78 +++++++++++++++++++++------------------- src/ui/tool/path-manipulator.cpp | 23 ++++++++++-- 3 files changed, 63 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 408f0f8a6..0ce18dcea 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -98,7 +98,7 @@ LPEBSpline::doEffect(SPCurve * curve) cubicIn = dynamic_cast(&*curve_it1); cubicOut = dynamic_cast(&*curve_it2); cubicEnd = dynamic_cast(&*curve_end); - if (path_it->closed() && cubicIn && cubicEnd && (*cubicIn)[1] != (*cubicEnd)[2]){ + if (path_it->closed() && cubicEnd && (*cubicEnd)[3] != (*cubicEnd)[2]){ //Calculamos el nodo de inicio BSpline SBasisIn = in->first_segment()->toSBasis(); SBasisEnd = end->first_segment()->toSBasis(); diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 8d5887223..5c3c49250 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -583,7 +583,7 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const //BSpline //Esto evita arrastrar los manejadores ya que el punto se crea //al soltar el botón del ratón. - if(((pc->spiro || pc->bspline) && pc->state != SP_PEN_CONTEXT_CLOSE)&&!(pc->bspline && bevent.state & GDK_SHIFT_MASK) ) pc->state = SP_PEN_CONTEXT_POINT; + if((pc->spiro || pc->bspline) && pc->state != SP_PEN_CONTEXT_CLOSE) pc->state = SP_PEN_CONTEXT_POINT; //BSpline End ret = TRUE; break; @@ -1785,15 +1785,12 @@ static void spiro_doEffect(SPCurve * curve) //Unimos todas las curvas en juego y llamamos a la función doEffect. static void bspline(SPPenContext *const pc, bool Shift) { + using Geom::X; + using Geom::Y; + Geom::CubicBezier const *cubic; if(!Shift){ - - using Geom::X; - using Geom::Y; - Geom::CubicBezier const *cubic; - //Continuamos la curva en modo CUSP - //Guardamos el valor de inicio en cusp para que no se redibuje como SYMM if(pc->anchor_statusbar && pc->red_curve->is_empty()){ - saShift = true; + saShift = false; } //NODO CUSP formado por nodo SMOOTH //solo mobemos el manejador del nodo final de cada segmento @@ -1804,39 +1801,39 @@ static void bspline(SPPenContext *const pc, bool Shift) pc->p[0] = pc->red_curve->first_segment()->initialPoint(); pc->p[3] = pc->red_curve->first_segment()->finalPoint(); if(pc->green_curve->is_empty()){ - pc->p[1] = pc->p[0] + (1./3)*(pc->p[0] - pc->p[3]); + pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]); pc->p[1] = Geom::Point(pc->p[1][X]+1,pc->p[1][Y]+1); }else{ cubic = dynamic_cast(&*pc->green_curve->last_segment()); if(!cubic || ((*cubic)[2] == (*cubic)[3])) pc->p[1] = pc->p[0]; else{ - if(cubic){ - SPCurve * WPower = new SPCurve(); - Geom::D2< Geom::SBasis > SBasisWPower; - WPower->moveto(pc->green_curve->last_segment()->finalPoint()); - WPower->lineto(pc->green_curve->last_segment()->initialPoint()); - float WP = Geom::nearest_point((*cubic)[2],*WPower->first_segment()); - WPower->reset(); - WPower->moveto(pc->red_curve->last_segment()->initialPoint()); - WPower->lineto(pc->red_curve->last_segment()->finalPoint()); - SBasisWPower = WPower->first_segment()->toSBasis(); - WPower->reset(); - pc->p[1] = SBasisWPower.valueAt(WP); - pc->p[1] = Geom::Point(pc->p[1][X]+1,pc->p[1][Y]+1); - }else{ - pc->p[1] = pc->p[0] + (1./3)*(pc->p[0] - pc->p[3]); - pc->p[1] = Geom::Point(pc->p[1][X]+1,pc->p[1][Y]+1); - } + SPCurve * WPower = new SPCurve(); + Geom::D2< Geom::SBasis > SBasisWPower; + WPower->moveto(pc->green_curve->last_segment()->finalPoint()); + WPower->lineto(pc->green_curve->last_segment()->initialPoint()); + float WP = Geom::nearest_point((*cubic)[2],*WPower->first_segment()); + WPower->reset(); + WPower->moveto(pc->red_curve->last_segment()->initialPoint()); + WPower->lineto(pc->red_curve->last_segment()->finalPoint()); + SBasisWPower = WPower->first_segment()->toSBasis(); + WPower->reset(); + pc->p[1] = SBasisWPower.valueAt(WP); + pc->p[1] = Geom::Point(pc->p[1][X]+1,pc->p[1][Y]+1); } } pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); pc->p[2] = Geom::Point(pc->p[2][X]+1,pc->p[2][Y]+1); } + if(pc->green_curve->is_empty() && saShift) + pc->p[1] = pc->p[0]; }else{ + //Continuamos la curva en modo CUSP + //Guardamos el valor de inicio en cusp para que no se redibuje como SYMM if(pc->anchor_statusbar && pc->red_curve->is_empty()){ - saShift = false; + saShift = true; } + if(!pc->green_curve->is_empty()){ //Damos valor original a la variable por si se necesita de nuevo saShift = false; @@ -1844,15 +1841,22 @@ static void bspline(SPPenContext *const pc, bool Shift) if (!pc->red_curve->is_empty()){ pc->npoints = 5; - pc->p[0] = pc->red_curve->first_segment()->finalPoint(); - pc->p[3] = pc->red_curve->first_segment()->initialPoint(); - pc->p[2] = pc->p[3]; - } - if(pc->green_curve->is_empty() && saShift){ - pc->npoints = 5; - pc->p[3] = pc->p[1]; - pc->p[2] = pc->p[3]; - pc->p[1] = pc->p[0] + (1./3)*(pc->p[0] - pc->p[3]); + pc->p[0] = pc->red_curve->first_segment()->initialPoint(); + pc->p[3] = pc->red_curve->first_segment()->finalPoint(); + if(pc->green_curve->is_empty()){ + pc->p[1] = pc->p[0]; + }else{ + cubic = dynamic_cast(&*pc->green_curve->last_segment()); + if(!cubic || ((*cubic)[2] == (*cubic)[3])){ + pc->p[1] = pc->p[0]; + pc->p[2] = pc->p[3]; + }else{ + pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]); + pc->p[1] = Geom::Point(pc->p[1][X]+1,pc->p[1][Y]+1); + pc->p[2] = pc->p[3]; + } + + } } } bspline_build(pc); @@ -1985,7 +1989,7 @@ static void bspline_doEffect(SPCurve * curve) cubicIn = dynamic_cast(&*curve_it1); cubicOut = dynamic_cast(&*curve_it2); cubicEnd = dynamic_cast(&*curve_end); - if (path_it->closed() && cubicIn && cubicEnd && (*cubicIn)[1] != (*cubicEnd)[2]){ + if (path_it->closed() && cubicEnd && (*cubicEnd)[3] != (*cubicEnd)[2]){ //Calculamos el nodo de inicio BSpline SBasisIn = in->first_segment()->toSBasis(); SBasisEnd = end->first_segment()->toSBasis(); diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 35eb23f42..f1b2e12be 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -9,7 +9,9 @@ * Copyright (C) 2009 Authors * Released under GNU GPL, read the file 'COPYING' for more information */ - +//BSpline +#include "live_effects/lpe-bspline.h" +//BSpline end #include "live_effects/lpe-powerstroke.h" #include #include @@ -1257,9 +1259,26 @@ void PathManipulator::_updateOutline() sp_canvas_item_hide(_outline); return; } - Geom::PathVector pv = _spcurve->get_pathvector(); pv *= (_edit_transform * _i2d_transform); + //BSpline + if (SP_IS_LPE_ITEM(_path) && sp_lpe_item_has_path_effect(SP_LPE_ITEM(_path))) { + PathEffectList effect_list = sp_lpe_item_get_effect_list(SP_LPE_ITEM(_path)); + LivePathEffect::LPEBSpline *lpe_bsp = dynamic_cast( effect_list.front()->lpeobject->get_lpe()); + if (lpe_bsp) { + Geom::PathVector pv2; + for (Geom::PathVector::iterator i = pv.begin(); i != pv.end(); ++i) { + Geom::Path &path = *i; + for (Geom::Path::const_iterator j = path.begin(); j != path.end_default(); ++j) { + Geom::Path pv2j(j->pointAt(0)); + pv2j.appendNew(j->pointAt(1)); + pv2.push_back(pv2j); + } + } + pv = pv2; + } + } + //BSpline End // This SPCurve thing has to be killed with extreme prejudice SPCurve *_hc = new SPCurve(); if (_show_path_direction) { -- cgit v1.2.3 From 4a0858ff965d54fc08f721fbbc2503f9ab3d9d3c Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 18 Feb 2013 11:23:51 +0100 Subject: refactor (bzr r11950.1.35) --- src/live_effects/lpe-bspline.cpp | 46 +++++++++--------- src/pen-context.cpp | 88 +++++++++++++++++++++++---------- src/ui/tool/node.cpp | 26 ++++++++-- src/ui/tool/path-manipulator.cpp | 102 +++++++++++++++++++++++++++++++-------- src/ui/tool/path-manipulator.h | 6 +++ 5 files changed, 196 insertions(+), 72 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 0ce18dcea..858a09159 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -45,14 +45,14 @@ LPEBSpline::doEffect(SPCurve * curve) Geom::D2< Geom::SBasis > SBasisOut; Geom::D2< Geom::SBasis > SBasisEnd; Geom::D2< Geom::SBasis > SBasisHelper; - //Curvas temporales - SPCurve *lineHelper = new SPCurve(); - SPCurve *curveHelper = new SPCurve(); - SPCurve *nCurve = new SPCurve(); //curves SPCurve * in = new SPCurve(); SPCurve * out = new SPCurve(); SPCurve * end = new SPCurve(); + //Curvas temporales + SPCurve *lineHelper = new SPCurve(); + SPCurve *curveHelper = new SPCurve(); + SPCurve *nCurve = new SPCurve(); //Puntos a usar. Ponemos todos los posibles para hacer más inteligible el código Geom::Point startNode(0,0); Geom::Point previousNode(0,0); @@ -66,9 +66,7 @@ LPEBSpline::doEffect(SPCurve * curve) Geom::Point nextPointAt1(0,0); Geom::Point nextPointAt2(0,0); Geom::Point nextPointAt3(0,0); - Geom::CubicBezier const *cubicIn; - Geom::CubicBezier const *cubicOut; - Geom::CubicBezier const *cubicEnd; + Geom::BezierCurve const *bezier; //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { //Si está vacío... @@ -80,6 +78,7 @@ LPEBSpline::doEffect(SPCurve * curve) Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve Geom::Path::const_iterator curve_end = path_it->end(); // end curve Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop + //Creamos las lineas rectas que unen todos los puntos del trazado y donde se calcularán //los puntos clave para los manejadores. //Esto hace que la curva BSpline no pierda su condición aunque se trasladen @@ -91,19 +90,18 @@ LPEBSpline::doEffect(SPCurve * curve) //este no cambia. end->moveto(curve_end->initialPoint()); end->lineto(curve_end->finalPoint()); - //Si la curva está cerrada calculamos el punto donde //deveria estar el nodo BSpline de cierre/inicio de la curva //en posible caso de que se cierre con una linea recta creando un nodo BSPline - cubicIn = dynamic_cast(&*curve_it1); - cubicOut = dynamic_cast(&*curve_it2); - cubicEnd = dynamic_cast(&*curve_end); - if (path_it->closed() && cubicEnd && (*cubicEnd)[3] != (*cubicEnd)[2]){ + bezier = dynamic_cast(&*curve_end); + if (path_it->closed() && bezier && (*bezier)[2] != (*bezier)[3]) { //Calculamos el nodo de inicio BSpline SBasisIn = in->first_segment()->toSBasis(); SBasisEnd = end->first_segment()->toSBasis(); - lineHelper->moveto(SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[1],*in->first_segment()))); - lineHelper->lineto(SBasisEnd.valueAt(Geom::nearest_point((*cubicEnd)[2],*end->first_segment()))); + bezier = dynamic_cast(&*curve_it1); + lineHelper->moveto(SBasisIn.valueAt(Geom::nearest_point((*bezier)[1],*in->first_segment()))); + bezier = dynamic_cast(&*curve_end); + lineHelper->lineto(SBasisEnd.valueAt(Geom::nearest_point((*bezier)[2],*end->first_segment()))); SBasisHelper = lineHelper->first_segment()->toSBasis(); lineHelper->reset(); //Guardamos el principio de la curva @@ -111,9 +109,12 @@ LPEBSpline::doEffect(SPCurve * curve) //Definimos el punto de inicio original de la curva resultante node = startNode; }else{ + //Guardamos el principio de la curva startNode = in->first_segment()->initialPoint(); + //Definimos el punto de inicio original de la curva resultante node = startNode; } + //Recorremos todos los segmentos menos el último while ( curve_it2 != curve_endit ) { @@ -121,10 +122,11 @@ LPEBSpline::doEffect(SPCurve * curve) SBasisOut = out->first_segment()->toSBasis(); //previousPointAt3 = pointAt3; //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida - if(cubicIn){ + bezier = dynamic_cast(&*curve_it1); + if(bezier){ pointAt0 = SBasisIn.valueAt(0); - pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[1],*in->first_segment())); - pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[2],*in->first_segment())); + pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*bezier)[1],*in->first_segment())); + pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*bezier)[2],*in->first_segment())); pointAt3 = SBasisIn.valueAt(1); }else{ pointAt0 = SBasisIn.valueAt(0); @@ -134,9 +136,10 @@ LPEBSpline::doEffect(SPCurve * curve) } //Y hacemos lo propio con el path de salida //nextPointAt0 = curveOut.valueAt(0); - if(cubicOut){ - nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubicOut)[1],*out->first_segment())); - nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*cubicOut)[2],*out->first_segment())); + bezier = dynamic_cast(&*curve_it2); + if(bezier){ + nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*bezier)[1],*out->first_segment())); + nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*bezier)[2],*out->first_segment())); nextPointAt3 = SBasisOut.valueAt(1); }else{ nextPointAt1 = SBasisOut.valueAt(0); @@ -178,10 +181,7 @@ LPEBSpline::doEffect(SPCurve * curve) if(curve_it1 != curve_end){ out->moveto(curve_it2->initialPoint()); out->lineto(curve_it2->finalPoint()); - cubicOut = dynamic_cast(&*curve_it2); } - cubicIn = dynamic_cast(&*curve_it1); - } //Aberiguamos la ultima parte de la curva correspondiente al último segmento curveHelper->moveto(node); diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 9577ecbf9..26eb77b06 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -1844,7 +1844,45 @@ static void bspline(SPPenContext *const pc, bool Shift) lastSeg->curveto((*cubic)[1],(*cubic)[3],(*cubic)[3]); previousCurve->backspace(); previousCurve->append_continuous(lastSeg, 0.0625); - pc->sa = previousCurve; + pc->sa->curve = previousCurve; + } + } + } + if(pc->anchor_statusbar && !pc->red_curve->is_empty()){ + // Step B - both start and end anchored to same curve + if ( pc->sa && pc->ea + && ( pc->sa->curve == pc->ea->curve ) + && ( ( pc->sa != pc->ea ) + || pc->sa->curve->is_closed() ) ) + { + SPCurve * same = pc->sa->curve->copy(); + if (pc->sa->start) { + same = same->create_reverse(); + } + cubic = dynamic_cast(&*same->last_segment()); + if(cubic){ + SPCurve *lastSeg = new SPCurve(); + lastSeg->moveto((*cubic)[0]); + lastSeg->curveto((*cubic)[1],(*cubic)[3],(*cubic)[3]); + same->backspace(); + same->append_continuous(lastSeg, 0.0625); + same = same->create_reverse(); + pc->sa->curve = same; + } + } + // Step A - test, whether we ended on green anchor + if ( pc->green_anchor && pc->green_anchor->active ) { + // We hit green anchor, closing Green-Blue-Red + SPCurve * green = pc->green_curve->copy()->create_reverse(); + cubic = dynamic_cast(&*green->last_segment()); + if(cubic){ + SPCurve *lastSeg = new SPCurve(); + lastSeg->moveto((*cubic)[0]); + lastSeg->curveto((*cubic)[1],(*cubic)[3],(*cubic)[3]); + green->backspace(); + green->append_continuous(lastSeg, 0.0625); + green = green->create_reverse(); + pc->green_curve = green; } } } @@ -1936,7 +1974,7 @@ static void bspline_build(SPPenContext *const pc) } } -static void bspline_doEffect(SPCurve * curve) +static void __attribute__((optimize(0))) bspline_doEffect(SPCurve * curve) { using Geom::X; using Geom::Y; @@ -1951,14 +1989,14 @@ static void bspline_doEffect(SPCurve * curve) Geom::D2< Geom::SBasis > SBasisOut; Geom::D2< Geom::SBasis > SBasisEnd; Geom::D2< Geom::SBasis > SBasisHelper; - //Curvas temporales - SPCurve *lineHelper = new SPCurve(); - SPCurve *curveHelper = new SPCurve(); - SPCurve *nCurve = new SPCurve(); //curves SPCurve * in = new SPCurve(); SPCurve * out = new SPCurve(); SPCurve * end = new SPCurve(); + //Curvas temporales + SPCurve *lineHelper = new SPCurve(); + SPCurve *curveHelper = new SPCurve(); + SPCurve *nCurve = new SPCurve(); //Puntos a usar. Ponemos todos los posibles para hacer más inteligible el código Geom::Point startNode(0,0); Geom::Point previousNode(0,0); @@ -1972,9 +2010,7 @@ static void bspline_doEffect(SPCurve * curve) Geom::Point nextPointAt1(0,0); Geom::Point nextPointAt2(0,0); Geom::Point nextPointAt3(0,0); - Geom::CubicBezier const *cubicIn; - Geom::CubicBezier const *cubicOut; - Geom::CubicBezier const *cubicEnd; + Geom::BezierCurve const *bezier; //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { //Si está vacío... @@ -1986,6 +2022,7 @@ static void bspline_doEffect(SPCurve * curve) Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve Geom::Path::const_iterator curve_end = path_it->end(); // end curve Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop + //Creamos las lineas rectas que unen todos los puntos del trazado y donde se calcularán //los puntos clave para los manejadores. //Esto hace que la curva BSpline no pierda su condición aunque se trasladen @@ -1997,19 +2034,18 @@ static void bspline_doEffect(SPCurve * curve) //este no cambia. end->moveto(curve_end->initialPoint()); end->lineto(curve_end->finalPoint()); - //Si la curva está cerrada calculamos el punto donde //deveria estar el nodo BSpline de cierre/inicio de la curva //en posible caso de que se cierre con una linea recta creando un nodo BSPline - cubicIn = dynamic_cast(&*curve_it1); - cubicOut = dynamic_cast(&*curve_it2); - cubicEnd = dynamic_cast(&*curve_end); - if (path_it->closed()){ + bezier = dynamic_cast(&*curve_end); + if (path_it->closed() && bezier && (*bezier)[2] != (*bezier)[3]) { //Calculamos el nodo de inicio BSpline SBasisIn = in->first_segment()->toSBasis(); SBasisEnd = end->first_segment()->toSBasis(); - lineHelper->moveto(SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[1],*in->first_segment()))); - lineHelper->lineto(SBasisEnd.valueAt(Geom::nearest_point((*cubicEnd)[2],*end->first_segment()))); + bezier = dynamic_cast(&*curve_it1); + lineHelper->moveto(SBasisIn.valueAt(Geom::nearest_point((*bezier)[1],*in->first_segment()))); + bezier = dynamic_cast(&*curve_end); + lineHelper->lineto(SBasisEnd.valueAt(Geom::nearest_point((*bezier)[2],*end->first_segment()))); SBasisHelper = lineHelper->first_segment()->toSBasis(); lineHelper->reset(); //Guardamos el principio de la curva @@ -2017,9 +2053,12 @@ static void bspline_doEffect(SPCurve * curve) //Definimos el punto de inicio original de la curva resultante node = startNode; }else{ + //Guardamos el principio de la curva startNode = in->first_segment()->initialPoint(); + //Definimos el punto de inicio original de la curva resultante node = startNode; } + //Recorremos todos los segmentos menos el último while ( curve_it2 != curve_endit ) { @@ -2027,10 +2066,11 @@ static void bspline_doEffect(SPCurve * curve) SBasisOut = out->first_segment()->toSBasis(); //previousPointAt3 = pointAt3; //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida - if(cubicIn){ + bezier = dynamic_cast(&*curve_it1); + if(bezier){ pointAt0 = SBasisIn.valueAt(0); - pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[1],*in->first_segment())); - pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[2],*in->first_segment())); + pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*bezier)[1],*in->first_segment())); + pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*bezier)[2],*in->first_segment())); pointAt3 = SBasisIn.valueAt(1); }else{ pointAt0 = SBasisIn.valueAt(0); @@ -2040,9 +2080,10 @@ static void bspline_doEffect(SPCurve * curve) } //Y hacemos lo propio con el path de salida //nextPointAt0 = curveOut.valueAt(0); - if(cubicOut){ - nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubicOut)[1],*out->first_segment())); - nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*cubicOut)[2],*out->first_segment())); + bezier = dynamic_cast(&*curve_it2); + if(bezier){ + nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*bezier)[1],*out->first_segment())); + nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*bezier)[2],*out->first_segment())); nextPointAt3 = SBasisOut.valueAt(1); }else{ nextPointAt1 = SBasisOut.valueAt(0); @@ -2084,10 +2125,7 @@ static void bspline_doEffect(SPCurve * curve) if(curve_it1 != curve_end){ out->moveto(curve_it2->initialPoint()); out->lineto(curve_it2->finalPoint()); - cubicOut = dynamic_cast(&*curve_it2); } - cubicIn = dynamic_cast(&*curve_it1); - } //Aberiguamos la ultima parte de la curva correspondiente al último segmento curveHelper->moveto(node); diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index dc6e0fbae..dff8d3dd9 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -13,7 +13,6 @@ #include #include <2geom/bezier-utils.h> #include <2geom/transforms.h> - #include "display/sp-ctrlline.h" #include "display/sp-canvas.h" #include "display/sp-canvas-util.h" @@ -196,8 +195,13 @@ void Handle::move(Geom::Point const &new_pos) break; default: break; } - - setPosition(new_pos); + //BSpline + if(_pm().isBSpline()){ + Handle *h = this; + setPosition(_pm().BSplineHandleReposition(h)); + }else + setPosition(new_pos); + //BSpline End } void Handle::setPosition(Geom::Point const &p) @@ -550,10 +554,24 @@ void Node::move(Geom::Point const &new_pos) // move handles when the node moves. Geom::Point old_pos = position(); Geom::Point delta = new_pos - position(); + //BSpline + float pos = 0; + if(_pm().isBSpline()){ + Node *n = this; + pos = _pm().BSplineMaxPosition(n); + } + //BSpline End setPosition(new_pos); _front.setPosition(_front.position() + delta); _back.setPosition(_back.position() + delta); - + //BSpline + if(_pm().isBSpline()){ + Handle* front = &_front; + Handle* back = &_back; + _front.setPosition(_pm().BSplineHandleRepositionFixed(front,pos)); + _back.setPosition(_pm().BSplineHandleRepositionFixed(back,pos)); + } + //BSpline End // if the node has a smooth handle after a line segment, it should be kept colinear // with the segment _fixNeighbors(old_pos, new_pos); diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index f1b2e12be..b650987bc 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1102,7 +1102,6 @@ void PathManipulator::_createControlPointsFromGeometry() Geom::Curve const &cseg = pit->back_closed(); bool fuse_ends = pit->closed() && Geom::are_near(cseg.initialPoint(), cseg.finalPoint()); - for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_open(); ++cit) { Geom::Point pos = cit->finalPoint(); Node *current_node; @@ -1169,6 +1168,75 @@ void PathManipulator::_createControlPointsFromGeometry() } } + +bool PathManipulator::isBSpline(){ + LivePathEffect::LPEBSpline *lpe_bsp = NULL; + if (SP_IS_LPE_ITEM(_path) && sp_lpe_item_has_path_effect(SP_LPE_ITEM(_path))) { + PathEffectList effect_list = sp_lpe_item_get_effect_list(SP_LPE_ITEM(_path)); + lpe_bsp = dynamic_cast( effect_list.front()->lpeobject->get_lpe()); + }else{ + lpe_bsp = NULL; + } + if(lpe_bsp){ + return true; + } + return false; +} +double PathManipulator::BSplineMaxPosition(Node *n){ + double nearestPointAt = 0; + Geom::D2< Geom::SBasis > SBasisInsideNodes; + SPCurve *lineInsideNodes = new SPCurve(); + Node * frontNode = n->nodeToward(n->front()); + if(frontNode){ + lineInsideNodes->moveto(n->position()); + lineInsideNodes->lineto(frontNode->position()); + SBasisInsideNodes = lineInsideNodes->first_segment()->toSBasis(); + nearestPointAt = Geom::nearest_point(n->front()->position(),*lineInsideNodes->first_segment()); + } + Node * backNode = n->nodeToward(n->back()); + if(backNode){ + lineInsideNodes->reset(); + lineInsideNodes->moveto(n->position()); + lineInsideNodes->lineto(backNode->position()); + SBasisInsideNodes = lineInsideNodes->first_segment()->toSBasis(); + using std::max; + nearestPointAt = max(nearestPointAt,1-Geom::nearest_point(n->back()->position(),*lineInsideNodes->first_segment())); + } + return nearestPointAt; +} + +Geom::Point PathManipulator::BSplineHandleReposition(Handle *h){ + double nearestPointAt = 0; + Node *n = h->parent(); + Geom::D2< Geom::SBasis > SBasisInsideNodes; + SPCurve *lineInsideNodes = new SPCurve(); + Node * nextNode = n->nodeToward(h); + if(nextNode){ + lineInsideNodes->moveto(n->position()); + lineInsideNodes->lineto(nextNode->position()); + SBasisInsideNodes = lineInsideNodes->first_segment()->toSBasis(); + nearestPointAt = Geom::nearest_point(n->front()->position(),*lineInsideNodes->first_segment()); + } + return SBasisInsideNodes.valueAt(nearestPointAt); +} + +Geom::Point PathManipulator::BSplineHandleRepositionFixed(Handle *h,double pos){ + Node *n = h->parent(); + if(n->back()->position() == h->position()) + pos = 1-pos; + Geom::D2< Geom::SBasis > SBasisInsideNodes; + SPCurve *lineInsideNodes = new SPCurve(); + Node * nextNode = n->nodeToward(h); + if(nextNode){ + lineInsideNodes->moveto(n->position()); + lineInsideNodes->lineto(nextNode->position()); + SBasisInsideNodes = lineInsideNodes->first_segment()->toSBasis(); + }else{ + return n->position(); + } + return SBasisInsideNodes.valueAt(pos); +} + /** Construct the geometric representation of nodes and handles, update the outline * and display * \param alert_LPE if true, first the LPE is warned what the new path is going to be before updating it @@ -1184,14 +1252,25 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) } NodeList::iterator prev = subpath->begin(); builder.moveTo(prev->position()); - for (NodeList::iterator i = ++subpath->begin(); i != subpath->end(); ++i) { + if (this->isBSpline()) { + float pos = BSplineMaxPosition(i.ptr()); + i.ptr()->front()->setPosition(BSplineHandleRepositionFixed(i.ptr()->front(),pos)); + i.ptr()->back()->setPosition(BSplineHandleRepositionFixed(i.ptr()->back(),pos)); + } + //BSplie End build_segment(builder, prev.ptr(), i.ptr()); prev = i; } if (subpath->closed()) { // Here we link the last and first node if the path is closed. // If the last segment is Bezier, we add it. + if (this->isBSpline()) { + float pos = BSplineMaxPosition(prev.ptr()); + subpath->begin().ptr()->front()->setPosition(BSplineHandleRepositionFixed(subpath->begin().ptr()->front(),pos)); + prev.ptr()->back()->setPosition(BSplineHandleRepositionFixed(prev.ptr()->back(),pos)); + + } if (!prev->front()->isDegenerate() || !subpath->begin()->back()->isDegenerate()) { build_segment(builder, prev.ptr(), subpath->begin().ptr()); } @@ -1200,6 +1279,7 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) } ++spi; } + builder.finish(); Geom::PathVector pathv = builder.peek() * (_edit_transform * _i2d_transform).inverse(); _spcurve->set_pathvector(pathv); @@ -1261,24 +1341,6 @@ void PathManipulator::_updateOutline() } Geom::PathVector pv = _spcurve->get_pathvector(); pv *= (_edit_transform * _i2d_transform); - //BSpline - if (SP_IS_LPE_ITEM(_path) && sp_lpe_item_has_path_effect(SP_LPE_ITEM(_path))) { - PathEffectList effect_list = sp_lpe_item_get_effect_list(SP_LPE_ITEM(_path)); - LivePathEffect::LPEBSpline *lpe_bsp = dynamic_cast( effect_list.front()->lpeobject->get_lpe()); - if (lpe_bsp) { - Geom::PathVector pv2; - for (Geom::PathVector::iterator i = pv.begin(); i != pv.end(); ++i) { - Geom::Path &path = *i; - for (Geom::Path::const_iterator j = path.begin(); j != path.end_default(); ++j) { - Geom::Path pv2j(j->pointAt(0)); - pv2j.appendNew(j->pointAt(1)); - pv2.push_back(pv2j); - } - } - pv = pv2; - } - } - //BSpline End // This SPCurve thing has to be killed with extreme prejudice SPCurve *_hc = new SPCurve(); if (_show_path_direction) { diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index a51b8c410..72d84a241 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -104,6 +104,12 @@ private: typedef boost::shared_ptr SubpathPtr; void _createControlPointsFromGeometry(); + //BSpline + bool isBSpline(); + double BSplineMaxPosition(Node *n); + Geom::Point BSplineHandleReposition(Handle *h); + Geom::Point BSplineHandleRepositionFixed(Handle *h,double pos); + //BSpline End void _createGeometryFromControlPoints(bool alert_LPE = false); unsigned _deleteStretch(NodeList::iterator first, NodeList::iterator last, bool keep_shape); std::string _createTypeString(); -- cgit v1.2.3 From dfe131791aef37e26fd0358c32222dacf813864c Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 19 Feb 2013 12:08:14 +0100 Subject: Mayor refactor (bzr r11950.1.36) --- src/live_effects/lpe-bspline.cpp | 80 +++++++++++++++-------------------- src/pen-context.cpp | 82 ++++++++++++++++-------------------- src/ui/tool/node.cpp | 39 +++++++++++++---- src/ui/tool/path-manipulator.cpp | 90 ++++++++++++++++++++++------------------ src/ui/tool/path-manipulator.h | 4 +- 5 files changed, 151 insertions(+), 144 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 858a09159..8147ae014 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -41,9 +41,6 @@ LPEBSpline::doEffect(SPCurve * curve) Geom::PathVector const original_pathv = curve->get_pathvector(); curve->reset(); //Sbasis - Geom::D2< Geom::SBasis > SBasisIn; - Geom::D2< Geom::SBasis > SBasisOut; - Geom::D2< Geom::SBasis > SBasisEnd; Geom::D2< Geom::SBasis > SBasisHelper; //curves SPCurve * in = new SPCurve(); @@ -66,7 +63,9 @@ LPEBSpline::doEffect(SPCurve * curve) Geom::Point nextPointAt1(0,0); Geom::Point nextPointAt2(0,0); Geom::Point nextPointAt3(0,0); - Geom::BezierCurve const *bezier; + Geom::CubicBezier const *cubicIn; + Geom::CubicBezier const *cubicOut; + Geom::CubicBezier const *cubicEnd; //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { //Si está vacío... @@ -93,15 +92,12 @@ LPEBSpline::doEffect(SPCurve * curve) //Si la curva está cerrada calculamos el punto donde //deveria estar el nodo BSpline de cierre/inicio de la curva //en posible caso de que se cierre con una linea recta creando un nodo BSPline - bezier = dynamic_cast(&*curve_end); - if (path_it->closed() && bezier && (*bezier)[2] != (*bezier)[3]) { + cubicEnd = dynamic_cast(&*curve_end); + cubicIn = dynamic_cast(&*curve_it1); + if (path_it->closed() && cubicEnd && cubicIn) { //Calculamos el nodo de inicio BSpline - SBasisIn = in->first_segment()->toSBasis(); - SBasisEnd = end->first_segment()->toSBasis(); - bezier = dynamic_cast(&*curve_it1); - lineHelper->moveto(SBasisIn.valueAt(Geom::nearest_point((*bezier)[1],*in->first_segment()))); - bezier = dynamic_cast(&*curve_end); - lineHelper->lineto(SBasisEnd.valueAt(Geom::nearest_point((*bezier)[2],*end->first_segment()))); + lineHelper->moveto((*cubicIn)[1]); + lineHelper->lineto((*cubicEnd)[2]); SBasisHelper = lineHelper->first_segment()->toSBasis(); lineHelper->reset(); //Guardamos el principio de la curva @@ -118,53 +114,45 @@ LPEBSpline::doEffect(SPCurve * curve) //Recorremos todos los segmentos menos el último while ( curve_it2 != curve_endit ) { - SBasisIn = in->first_segment()->toSBasis(); - SBasisOut = out->first_segment()->toSBasis(); //previousPointAt3 = pointAt3; //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida - bezier = dynamic_cast(&*curve_it1); - if(bezier){ - pointAt0 = SBasisIn.valueAt(0); - pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*bezier)[1],*in->first_segment())); - pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*bezier)[2],*in->first_segment())); - pointAt3 = SBasisIn.valueAt(1); + cubicIn = dynamic_cast(&*curve_it1); + if(cubicIn){ + pointAt0 = (*cubicIn)[0]; + pointAt1 = (*cubicIn)[1]; + pointAt2 = (*cubicIn)[2]; + pointAt3 = (*cubicIn)[3]; }else{ - pointAt0 = SBasisIn.valueAt(0); - pointAt1 = SBasisIn.valueAt(0); - pointAt2 = SBasisIn.valueAt(1); - pointAt3 = SBasisIn.valueAt(1); + pointAt0 = in->first_segment()->initialPoint(); + pointAt1 = in->first_segment()->initialPoint(); + pointAt2 = in->first_segment()->finalPoint(); + pointAt3 = in->first_segment()->finalPoint(); } //Y hacemos lo propio con el path de salida //nextPointAt0 = curveOut.valueAt(0); - bezier = dynamic_cast(&*curve_it2); - if(bezier){ - nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*bezier)[1],*out->first_segment())); - nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*bezier)[2],*out->first_segment())); - nextPointAt3 = SBasisOut.valueAt(1); + cubicOut = dynamic_cast(&*curve_it2); + if(cubicOut){ + nextPointAt1 = (*cubicOut)[1]; + nextPointAt2 = (*cubicOut)[2]; + nextPointAt3 = (*cubicOut)[3]; }else{ - nextPointAt1 = SBasisOut.valueAt(0); - nextPointAt2 = SBasisOut.valueAt(1); - nextPointAt3 = SBasisOut.valueAt(1); + nextPointAt1 = in->first_segment()->initialPoint(); + nextPointAt2 = in->first_segment()->finalPoint(); + nextPointAt3 = in->first_segment()->finalPoint(); } //La curva BSpline se forma calculando el centro del segmanto de unión //de el punto situado en las 2/3 partes de el segmento de entrada //con el punto situado en la posición 1/3 del segmento de salida //Estos dos puntos ademas estan posicionados en el lugas correspondiente de //los manejadores de la curva - if(nextPointAt1 != pointAt2){ - lineHelper->moveto(pointAt2); - lineHelper->lineto(nextPointAt1); - SBasisHelper = lineHelper->first_segment()->toSBasis(); - lineHelper->reset(); - //almacenamos el punto del anterior bucle -o el de cierre- que nos hara de principio de curva - previousNode = node; - //Y este hará de final de curva - node = SBasisHelper.valueAt(0.5); - }else{ - previousNode = node; - //Y este hará de final de curva - node = nextPointAt1; - } + lineHelper->moveto(pointAt2); + lineHelper->lineto(nextPointAt1); + SBasisHelper = lineHelper->first_segment()->toSBasis(); + lineHelper->reset(); + //almacenamos el punto del anterior bucle -o el de cierre- que nos hara de principio de curva + previousNode = node; + //Y este hará de final de curva + node = SBasisHelper.valueAt(0.5); curveHelper->moveto(previousNode); curveHelper->curveto(pointAt1, pointAt2, node); //añadimos la curva generada a la curva pricipal diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 26eb77b06..e393a706b 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -1985,9 +1985,6 @@ static void __attribute__((optimize(0))) bspline_doEffect(SPCurve * curve) Geom::PathVector const original_pathv = curve->get_pathvector(); curve->reset(); //Sbasis - Geom::D2< Geom::SBasis > SBasisIn; - Geom::D2< Geom::SBasis > SBasisOut; - Geom::D2< Geom::SBasis > SBasisEnd; Geom::D2< Geom::SBasis > SBasisHelper; //curves SPCurve * in = new SPCurve(); @@ -2010,7 +2007,9 @@ static void __attribute__((optimize(0))) bspline_doEffect(SPCurve * curve) Geom::Point nextPointAt1(0,0); Geom::Point nextPointAt2(0,0); Geom::Point nextPointAt3(0,0); - Geom::BezierCurve const *bezier; + Geom::CubicBezier const *cubicIn; + Geom::CubicBezier const *cubicOut; + Geom::CubicBezier const *cubicEnd; //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { //Si está vacío... @@ -2037,15 +2036,12 @@ static void __attribute__((optimize(0))) bspline_doEffect(SPCurve * curve) //Si la curva está cerrada calculamos el punto donde //deveria estar el nodo BSpline de cierre/inicio de la curva //en posible caso de que se cierre con una linea recta creando un nodo BSPline - bezier = dynamic_cast(&*curve_end); - if (path_it->closed() && bezier && (*bezier)[2] != (*bezier)[3]) { + cubicEnd = dynamic_cast(&*curve_end); + cubicIn = dynamic_cast(&*curve_it1); + if (path_it->closed() && cubicEnd && cubicIn) { //Calculamos el nodo de inicio BSpline - SBasisIn = in->first_segment()->toSBasis(); - SBasisEnd = end->first_segment()->toSBasis(); - bezier = dynamic_cast(&*curve_it1); - lineHelper->moveto(SBasisIn.valueAt(Geom::nearest_point((*bezier)[1],*in->first_segment()))); - bezier = dynamic_cast(&*curve_end); - lineHelper->lineto(SBasisEnd.valueAt(Geom::nearest_point((*bezier)[2],*end->first_segment()))); + lineHelper->moveto((*cubicIn)[1]); + lineHelper->lineto((*cubicEnd)[2]); SBasisHelper = lineHelper->first_segment()->toSBasis(); lineHelper->reset(); //Guardamos el principio de la curva @@ -2062,53 +2058,45 @@ static void __attribute__((optimize(0))) bspline_doEffect(SPCurve * curve) //Recorremos todos los segmentos menos el último while ( curve_it2 != curve_endit ) { - SBasisIn = in->first_segment()->toSBasis(); - SBasisOut = out->first_segment()->toSBasis(); //previousPointAt3 = pointAt3; //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida - bezier = dynamic_cast(&*curve_it1); - if(bezier){ - pointAt0 = SBasisIn.valueAt(0); - pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*bezier)[1],*in->first_segment())); - pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*bezier)[2],*in->first_segment())); - pointAt3 = SBasisIn.valueAt(1); + cubicIn = dynamic_cast(&*curve_it1); + if(cubicIn){ + pointAt0 = (*cubicIn)[0]; + pointAt1 = (*cubicIn)[1]; + pointAt2 = (*cubicIn)[2]; + pointAt3 = (*cubicIn)[3]; }else{ - pointAt0 = SBasisIn.valueAt(0); - pointAt1 = SBasisIn.valueAt(0); - pointAt2 = SBasisIn.valueAt(1); - pointAt3 = SBasisIn.valueAt(1); + pointAt0 = in->first_segment()->initialPoint(); + pointAt1 = in->first_segment()->initialPoint(); + pointAt2 = in->first_segment()->finalPoint(); + pointAt3 = in->first_segment()->finalPoint(); } //Y hacemos lo propio con el path de salida //nextPointAt0 = curveOut.valueAt(0); - bezier = dynamic_cast(&*curve_it2); - if(bezier){ - nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*bezier)[1],*out->first_segment())); - nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*bezier)[2],*out->first_segment())); - nextPointAt3 = SBasisOut.valueAt(1); + cubicOut = dynamic_cast(&*curve_it2); + if(cubicOut){ + nextPointAt1 = (*cubicOut)[1]; + nextPointAt2 = (*cubicOut)[2]; + nextPointAt3 = (*cubicOut)[3]; }else{ - nextPointAt1 = SBasisOut.valueAt(0); - nextPointAt2 = SBasisOut.valueAt(1); - nextPointAt3 = SBasisOut.valueAt(1); + nextPointAt1 = in->first_segment()->initialPoint(); + nextPointAt2 = in->first_segment()->finalPoint(); + nextPointAt3 = in->first_segment()->finalPoint(); } //La curva BSpline se forma calculando el centro del segmanto de unión //de el punto situado en las 2/3 partes de el segmento de entrada //con el punto situado en la posición 1/3 del segmento de salida //Estos dos puntos ademas estan posicionados en el lugas correspondiente de //los manejadores de la curva - if(nextPointAt1 != pointAt2){ - lineHelper->moveto(pointAt2); - lineHelper->lineto(nextPointAt1); - SBasisHelper = lineHelper->first_segment()->toSBasis(); - lineHelper->reset(); - //almacenamos el punto del anterior bucle -o el de cierre- que nos hara de principio de curva - previousNode = node; - //Y este hará de final de curva - node = SBasisHelper.valueAt(0.5); - }else{ - previousNode = node; - //Y este hará de final de curva - node = nextPointAt1; - } + lineHelper->moveto(pointAt2); + lineHelper->lineto(nextPointAt1); + SBasisHelper = lineHelper->first_segment()->toSBasis(); + lineHelper->reset(); + //almacenamos el punto del anterior bucle -o el de cierre- que nos hara de principio de curva + previousNode = node; + //Y este hará de final de curva + node = SBasisHelper.valueAt(0.5); curveHelper->moveto(previousNode); curveHelper->curveto(pointAt1, pointAt2, node); //añadimos la curva generada a la curva pricipal @@ -2159,7 +2147,7 @@ static void __attribute__((optimize(0))) bspline_doEffect(SPCurve * curve) //Todo: remove? //delete SBasisHelper; } - + //BSpline end static void spdc_pen_set_subsequent_point(SPPenContext *const pc, Geom::Point const p, bool statusbar, guint status) diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index dff8d3dd9..1a196c857 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -135,6 +135,15 @@ void Handle::move(Geom::Point const &new_pos) Node *node_away = _parent->nodeAwayFrom(this); // node in the opposite direction Handle *towards = node_towards ? node_towards->handleAwayFrom(_parent) : NULL; Handle *towards_second = node_towards ? node_towards->handleToward(_parent) : NULL; + //BSpline + bool isBSpline = false; + double pos = 0; + Handle *h = NULL; + Handle *h2 = NULL; + if(_pm().isBSpline()){ + isBSpline = true; + //BSpline End + } if (Geom::are_near(new_pos, _parent->position())) { // The handle becomes degenerate. @@ -165,6 +174,15 @@ void Handle::move(Geom::Point const &new_pos) other->setDirection(*node_towards, *_parent); } } + //BSpline + if(isBSpline){ + h = this; + setPosition(_pm().BSplineHandleReposition(h)); + pos = _pm().BSplineHandlePosition(h); + h2 = this->other(); + this->other()->setPosition(_pm().BSplineHandleReposition(h2,pos)); + } + //BSpline End setPosition(new_pos); return; } @@ -195,12 +213,15 @@ void Handle::move(Geom::Point const &new_pos) break; default: break; } + setPosition(new_pos); //BSpline - if(_pm().isBSpline()){ - Handle *h = this; + if(isBSpline){ + h = this; setPosition(_pm().BSplineHandleReposition(h)); - }else - setPosition(new_pos); + pos = _pm().BSplineHandlePosition(h); + h2 = this->other(); + this->other()->setPosition(_pm().BSplineHandleReposition(h2,pos)); + } //BSpline End } @@ -555,10 +576,12 @@ void Node::move(Geom::Point const &new_pos) Geom::Point old_pos = position(); Geom::Point delta = new_pos - position(); //BSpline - float pos = 0; + double pos = 0; if(_pm().isBSpline()){ Node *n = this; - pos = _pm().BSplineMaxPosition(n); + pos = _pm().BSplineHandlePosition(n->front()); + if(pos == 0) + pos = _pm().BSplineHandlePosition(n->back()); } //BSpline End setPosition(new_pos); @@ -568,8 +591,8 @@ void Node::move(Geom::Point const &new_pos) if(_pm().isBSpline()){ Handle* front = &_front; Handle* back = &_back; - _front.setPosition(_pm().BSplineHandleRepositionFixed(front,pos)); - _back.setPosition(_pm().BSplineHandleRepositionFixed(back,pos)); + _front.setPosition(_pm().BSplineHandleReposition(front,pos)); + _back.setPosition(_pm().BSplineHandleReposition(back,pos)); } //BSpline End // if the node has a smooth handle after a line segment, it should be kept colinear diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index b650987bc..c4158931a 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1182,31 +1182,8 @@ bool PathManipulator::isBSpline(){ } return false; } -double PathManipulator::BSplineMaxPosition(Node *n){ - double nearestPointAt = 0; - Geom::D2< Geom::SBasis > SBasisInsideNodes; - SPCurve *lineInsideNodes = new SPCurve(); - Node * frontNode = n->nodeToward(n->front()); - if(frontNode){ - lineInsideNodes->moveto(n->position()); - lineInsideNodes->lineto(frontNode->position()); - SBasisInsideNodes = lineInsideNodes->first_segment()->toSBasis(); - nearestPointAt = Geom::nearest_point(n->front()->position(),*lineInsideNodes->first_segment()); - } - Node * backNode = n->nodeToward(n->back()); - if(backNode){ - lineInsideNodes->reset(); - lineInsideNodes->moveto(n->position()); - lineInsideNodes->lineto(backNode->position()); - SBasisInsideNodes = lineInsideNodes->first_segment()->toSBasis(); - using std::max; - nearestPointAt = max(nearestPointAt,1-Geom::nearest_point(n->back()->position(),*lineInsideNodes->first_segment())); - } - return nearestPointAt; -} - -Geom::Point PathManipulator::BSplineHandleReposition(Handle *h){ - double nearestPointAt = 0; +double PathManipulator::BSplineHandlePosition(Handle *h){ + double pos = 0; Node *n = h->parent(); Geom::D2< Geom::SBasis > SBasisInsideNodes; SPCurve *lineInsideNodes = new SPCurve(); @@ -1215,19 +1192,23 @@ Geom::Point PathManipulator::BSplineHandleReposition(Handle *h){ lineInsideNodes->moveto(n->position()); lineInsideNodes->lineto(nextNode->position()); SBasisInsideNodes = lineInsideNodes->first_segment()->toSBasis(); - nearestPointAt = Geom::nearest_point(n->front()->position(),*lineInsideNodes->first_segment()); + pos = Geom::nearest_point(h->position(),*lineInsideNodes->first_segment()); } - return SBasisInsideNodes.valueAt(nearestPointAt); + return pos; } -Geom::Point PathManipulator::BSplineHandleRepositionFixed(Handle *h,double pos){ +Geom::Point PathManipulator::BSplineHandleReposition(Handle *h){ + double pos = 0; + pos = this->BSplineHandlePosition(h); + return BSplineHandleReposition(h,pos); +} + +Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){ Node *n = h->parent(); - if(n->back()->position() == h->position()) - pos = 1-pos; Geom::D2< Geom::SBasis > SBasisInsideNodes; SPCurve *lineInsideNodes = new SPCurve(); Node * nextNode = n->nodeToward(h); - if(nextNode){ + if(nextNode && pos != 0){ lineInsideNodes->moveto(n->position()); lineInsideNodes->lineto(nextNode->position()); SBasisInsideNodes = lineInsideNodes->first_segment()->toSBasis(); @@ -1251,26 +1232,53 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) continue; } NodeList::iterator prev = subpath->begin(); + //BSpline + float pos = NULL; + bool isBSpline = false; + if(this->isBSpline()) + isBSpline = true; + if(isBSpline){ + pos = BSplineHandlePosition(prev.ptr()->front()); + prev.ptr()->front()->setPosition(BSplineHandleReposition(prev.ptr()->front(),pos)); + if(pos == 0){ + prev.ptr()->setPosition(BSplineHandleReposition(i.ptr()->front(),pos)); + } + } + //BSpline End builder.moveTo(prev->position()); for (NodeList::iterator i = ++subpath->begin(); i != subpath->end(); ++i) { - if (this->isBSpline()) { - float pos = BSplineMaxPosition(i.ptr()); - i.ptr()->front()->setPosition(BSplineHandleRepositionFixed(i.ptr()->front(),pos)); - i.ptr()->back()->setPosition(BSplineHandleRepositionFixed(i.ptr()->back(),pos)); + //BSpline + if (isBSpline) { + pos = BSplineHandlePosition(i.ptr()->front()); + if(pos == 0) + pos = BSplineHandlePosition(i.ptr()->back()); + i.ptr()->front()->setPosition(BSplineHandleReposition(i.ptr()->front(),pos)); + i.ptr()->back()->setPosition(BSplineHandleReposition(i.ptr()->back(),pos)); + if(pos == 0){ + i.ptr()->setPosition(BSplineHandleReposition(i.ptr()->front(),pos)); + } } - //BSplie End + + //BSpline End build_segment(builder, prev.ptr(), i.ptr()); prev = i; } if (subpath->closed()) { // Here we link the last and first node if the path is closed. // If the last segment is Bezier, we add it. - if (this->isBSpline()) { - float pos = BSplineMaxPosition(prev.ptr()); - subpath->begin().ptr()->front()->setPosition(BSplineHandleRepositionFixed(subpath->begin().ptr()->front(),pos)); - prev.ptr()->back()->setPosition(BSplineHandleRepositionFixed(prev.ptr()->back(),pos)); - + //BSpline + if (isBSpline) { + pos = BSplineHandlePosition(prev.ptr()->front()); + if(pos == 0) + pos = BSplineHandlePosition(subpath->begin().ptr()->back()); + subpath->begin().ptr()->front()->setPosition(BSplineHandleReposition(subpath->begin().ptr()->front(),pos)); + prev.ptr()->back()->setPosition(BSplineHandleReposition(prev.ptr()->back(),pos)); + if(pos == 0){ + subpath->begin().ptr()->setPosition(BSplineHandleReposition(subpath->begin().ptr()->front(),pos)); + prev.ptr()->setPosition(BSplineHandleReposition(prev.ptr()->back(),pos)); + } } + //BSpline End if (!prev->front()->isDegenerate() || !subpath->begin()->back()->isDegenerate()) { build_segment(builder, prev.ptr(), subpath->begin().ptr()); } diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index 72d84a241..55958530d 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -106,9 +106,9 @@ private: void _createControlPointsFromGeometry(); //BSpline bool isBSpline(); - double BSplineMaxPosition(Node *n); + double BSplineHandlePosition(Handle *h); Geom::Point BSplineHandleReposition(Handle *h); - Geom::Point BSplineHandleRepositionFixed(Handle *h,double pos); + Geom::Point BSplineHandleReposition(Handle *h,double pos); //BSpline End void _createGeometryFromControlPoints(bool alert_LPE = false); unsigned _deleteStretch(NodeList::iterator first, NodeList::iterator last, bool keep_shape); -- cgit v1.2.3 From 9af17a6572db964acebd2b7eeea29c8b722c8221 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 23 Feb 2013 23:34:58 +0100 Subject: Saved for next refactor (bzr r11950.1.37) --- src/live_effects/lpe-bspline.cpp | 77 +++++++++++------- src/pen-context.cpp | 171 ++++++++++++++++++++++----------------- src/ui/tool/curve-drag-point.cpp | 20 +++-- src/ui/tool/node.cpp | 5 +- src/ui/tool/path-manipulator.cpp | 38 +++------ 5 files changed, 170 insertions(+), 141 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 8147ae014..8dc840556 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -32,15 +32,15 @@ LPEBSpline::~LPEBSpline() void LPEBSpline::doEffect(SPCurve * curve) { - using Geom::X; - using Geom::Y; - if(curve->get_segment_count() < 2) return; // Make copy of old path as it is changed during processing Geom::PathVector const original_pathv = curve->get_pathvector(); curve->reset(); //Sbasis + Geom::D2< Geom::SBasis > SBasisIn; + Geom::D2< Geom::SBasis > SBasisOut; + Geom::D2< Geom::SBasis > SBasisEnd; Geom::D2< Geom::SBasis > SBasisHelper; //curves SPCurve * in = new SPCurve(); @@ -63,9 +63,9 @@ LPEBSpline::doEffect(SPCurve * curve) Geom::Point nextPointAt1(0,0); Geom::Point nextPointAt2(0,0); Geom::Point nextPointAt3(0,0); - Geom::CubicBezier const *cubicIn; - Geom::CubicBezier const *cubicOut; - Geom::CubicBezier const *cubicEnd; + + Geom::Point endPointAt2(0,0); + Geom::CubicBezier const *cubic; //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { //Si está vacío... @@ -75,7 +75,7 @@ LPEBSpline::doEffect(SPCurve * curve) Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve - Geom::Path::const_iterator curve_end = path_it->end(); // end curve + Geom::Path::const_iterator curve_end = path_it->end_open(); // end curve Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop //Creamos las lineas rectas que unen todos los puntos del trazado y donde se calcularán @@ -92,12 +92,31 @@ LPEBSpline::doEffect(SPCurve * curve) //Si la curva está cerrada calculamos el punto donde //deveria estar el nodo BSpline de cierre/inicio de la curva //en posible caso de que se cierre con una linea recta creando un nodo BSPline - cubicEnd = dynamic_cast(&*curve_end); - cubicIn = dynamic_cast(&*curve_it1); - if (path_it->closed() && cubicEnd && cubicIn) { - //Calculamos el nodo de inicio BSpline - lineHelper->moveto((*cubicIn)[1]); - lineHelper->lineto((*cubicEnd)[2]); + + if (path_it->closed()) { + // if the path is closed, maybe we have to stop a bit earlier because the closing line segment has zerolength. + const Geom::Curve &closingline = path_it->back_closed(); // the closing line segment is always of type Geom::LineSegment. + if (are_near(closingline.initialPoint(), closingline.finalPoint())) { + // closingline.isDegenerate() did not work, because it only checks for *exact* zero length, which goes wrong for relative coordinates and rounding errors... + // the closing line segment has zero-length. So stop before that one! + curve_endit = path_it->end_open(); + } + SBasisIn = in->first_segment()->toSBasis(); + SBasisEnd = end->first_segment()->toSBasis(); + cubic = dynamic_cast(&*curve_it1); + if(cubic){ + pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[1],*in->first_segment())); + }else{ + pointAt1 = in->first_segment()->initialPoint(); + } + cubic = dynamic_cast(&*curve_end); + if(cubic){ + endPointAt2 = SBasisEnd.valueAt(Geom::nearest_point((*cubic)[2],*end->first_segment())); + }else{ + endPointAt2 = end->first_segment()->finalPoint(); + } + lineHelper->moveto(pointAt1); + lineHelper->lineto(endPointAt2); SBasisHelper = lineHelper->first_segment()->toSBasis(); lineHelper->reset(); //Guardamos el principio de la curva @@ -110,18 +129,18 @@ LPEBSpline::doEffect(SPCurve * curve) //Definimos el punto de inicio original de la curva resultante node = startNode; } - //Recorremos todos los segmentos menos el último while ( curve_it2 != curve_endit ) { //previousPointAt3 = pointAt3; //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida - cubicIn = dynamic_cast(&*curve_it1); - if(cubicIn){ - pointAt0 = (*cubicIn)[0]; - pointAt1 = (*cubicIn)[1]; - pointAt2 = (*cubicIn)[2]; - pointAt3 = (*cubicIn)[3]; + cubic = dynamic_cast(&*curve_it1); + if(cubic){ + SBasisIn = in->first_segment()->toSBasis(); + pointAt0 = (*cubic)[0]; + pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[1],*in->first_segment())); + pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[2],*in->first_segment())); + pointAt3 = (*cubic)[3]; }else{ pointAt0 = in->first_segment()->initialPoint(); pointAt1 = in->first_segment()->initialPoint(); @@ -130,15 +149,16 @@ LPEBSpline::doEffect(SPCurve * curve) } //Y hacemos lo propio con el path de salida //nextPointAt0 = curveOut.valueAt(0); - cubicOut = dynamic_cast(&*curve_it2); - if(cubicOut){ - nextPointAt1 = (*cubicOut)[1]; - nextPointAt2 = (*cubicOut)[2]; - nextPointAt3 = (*cubicOut)[3]; + cubic = dynamic_cast(&*curve_it2); + if(cubic){ + SBasisOut = out->first_segment()->toSBasis(); + nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[1],*out->first_segment())); + nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[2],*out->first_segment()));; + nextPointAt3 = (*cubic)[3]; }else{ - nextPointAt1 = in->first_segment()->initialPoint(); - nextPointAt2 = in->first_segment()->finalPoint(); - nextPointAt3 = in->first_segment()->finalPoint(); + nextPointAt1 = out->first_segment()->initialPoint(); + nextPointAt2 = out->first_segment()->finalPoint(); + nextPointAt3 = out->first_segment()->finalPoint(); } //La curva BSpline se forma calculando el centro del segmanto de unión //de el punto situado en las 2/3 partes de el segmento de entrada @@ -203,7 +223,6 @@ LPEBSpline::doEffect(SPCurve * curve) //Todo: remove? //delete SBasisHelper; } - }; //namespace LivePathEffect }; /* namespace Inkscape */ diff --git a/src/pen-context.cpp b/src/pen-context.cpp index e393a706b..350924adb 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -1788,49 +1788,10 @@ static void bspline(SPPenContext *const pc, bool Shift) using Geom::X; using Geom::Y; Geom::CubicBezier const *cubic; - if(!Shift){ - //NODO CUSP formado por nodo SMOOTH - //solo mobemos el manejador del nodo final de cada segmento - //Es suficiente para mostrar el nodo como CUSP - //Usamos 5 puntos - if(!pc->red_curve->is_empty()){ - pc->npoints = 5; - pc->p[0] = pc->red_curve->first_segment()->initialPoint(); - pc->p[3] = pc->red_curve->first_segment()->finalPoint(); - if(pc->green_curve->is_empty()){ - pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]); - pc->p[1] = Geom::Point(pc->p[1][X]+1,pc->p[1][Y]+1); - }else{ - cubic = dynamic_cast(&*pc->green_curve->last_segment()); - if(!cubic || ((*cubic)[2] == (*cubic)[3])) - pc->p[1] = pc->p[0]; - else{ - SPCurve * WPower = new SPCurve(); - Geom::D2< Geom::SBasis > SBasisWPower; - WPower->moveto(pc->green_curve->last_segment()->finalPoint()); - WPower->lineto(pc->green_curve->last_segment()->initialPoint()); - float WP = Geom::nearest_point((*cubic)[2],*WPower->first_segment()); - WPower->reset(); - WPower->moveto(pc->red_curve->last_segment()->initialPoint()); - WPower->lineto(pc->red_curve->last_segment()->finalPoint()); - SBasisWPower = WPower->first_segment()->toSBasis(); - WPower->reset(); - pc->p[1] = SBasisWPower.valueAt(WP); - pc->p[1] = Geom::Point(pc->p[1][X]+1,pc->p[1][Y]+1); - } - } - pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); - pc->p[2] = Geom::Point(pc->p[2][X]+1,pc->p[2][Y]+1); - } - if(pc->green_curve->is_empty() && saShift) - pc->p[1] = pc->p[0]; - if(pc->anchor_statusbar && pc->red_curve->is_empty()) - saShift = false; - }else{ + if(Shift){ //Continuamos la curva en modo CUSP //Guardamos el valor de inicio en cusp para que no se redibuje como SYMM if(pc->anchor_statusbar && pc->red_curve->is_empty()){ - saShift = true; SPCurve *previousCurve = new SPCurve(); if(pc->sa && !pc->sa->curve->is_empty()){ previousCurve = pc->sa->curve->copy(); @@ -1844,10 +1805,15 @@ static void bspline(SPPenContext *const pc, bool Shift) lastSeg->curveto((*cubic)[1],(*cubic)[3],(*cubic)[3]); previousCurve->backspace(); previousCurve->append_continuous(lastSeg, 0.0625); + if (pc->sa->start) { + previousCurve = previousCurve->create_reverse(); + } + pc->sa->curve->reset(); pc->sa->curve = previousCurve; } } } + if(pc->anchor_statusbar && !pc->red_curve->is_empty()){ // Step B - both start and end anchored to same curve if ( pc->sa && pc->ea @@ -1866,7 +1832,10 @@ static void bspline(SPPenContext *const pc, bool Shift) lastSeg->curveto((*cubic)[1],(*cubic)[3],(*cubic)[3]); same->backspace(); same->append_continuous(lastSeg, 0.0625); - same = same->create_reverse(); + if (pc->sa->start) { + same = same->create_reverse(); + } + pc->sa->curve->reset(); pc->sa->curve = same; } } @@ -1882,16 +1851,12 @@ static void bspline(SPPenContext *const pc, bool Shift) green->backspace(); green->append_continuous(lastSeg, 0.0625); green = green->create_reverse(); + pc->green_curve->reset(); pc->green_curve = green; } } } - if(!pc->green_curve->is_empty()){ - //Damos valor original a la variable por si se necesita de nuevo - saShift = false; - } - if (!pc->red_curve->is_empty()){ pc->npoints = 5; pc->p[0] = pc->red_curve->first_segment()->initialPoint(); @@ -1911,6 +1876,42 @@ static void bspline(SPPenContext *const pc, bool Shift) } } + }else{ + //NODO CUSP formado por nodo SMOOTH + //solo mobemos el manejador del nodo final de cada segmento + //Es suficiente para mostrar el nodo como CUSP + //Usamos 5 puntos + if(!pc->red_curve->is_empty()){ + pc->npoints = 5; + pc->p[0] = pc->red_curve->first_segment()->initialPoint(); + pc->p[3] = pc->red_curve->first_segment()->finalPoint(); + if(pc->green_curve->is_empty()){ + if(!pc->sa || (pc->sa && pc->p[0] != pc->p[1])){ + pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]); + pc->p[1] = Geom::Point(pc->p[1][X]+1,pc->p[1][Y]+1); + } + }else{ + cubic = dynamic_cast(&*pc->green_curve->last_segment()); + if(!cubic || ((*cubic)[2] == (*cubic)[3])) + pc->p[1] = pc->p[0]; + else{ + SPCurve * WPower = new SPCurve(); + Geom::D2< Geom::SBasis > SBasisWPower; + WPower->moveto(pc->green_curve->last_segment()->finalPoint()); + WPower->lineto(pc->green_curve->last_segment()->initialPoint()); + float WP = Geom::nearest_point((*cubic)[2],*WPower->first_segment()); + WPower->reset(); + WPower->moveto(pc->red_curve->last_segment()->initialPoint()); + WPower->lineto(pc->red_curve->last_segment()->finalPoint()); + SBasisWPower = WPower->first_segment()->toSBasis(); + WPower->reset(); + pc->p[1] = SBasisWPower.valueAt(WP); + pc->p[1] = Geom::Point(pc->p[1][X]+1,pc->p[1][Y]+1); + } + } + pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); + pc->p[2] = Geom::Point(pc->p[2][X]+1,pc->p[2][Y]+1); + } } bspline_build(pc); } @@ -1974,17 +1975,17 @@ static void bspline_build(SPPenContext *const pc) } } -static void __attribute__((optimize(0))) bspline_doEffect(SPCurve * curve) +static void bspline_doEffect(SPCurve * curve) { - using Geom::X; - using Geom::Y; - if(curve->get_segment_count() < 2) return; // Make copy of old path as it is changed during processing Geom::PathVector const original_pathv = curve->get_pathvector(); curve->reset(); //Sbasis + Geom::D2< Geom::SBasis > SBasisIn; + Geom::D2< Geom::SBasis > SBasisOut; + Geom::D2< Geom::SBasis > SBasisEnd; Geom::D2< Geom::SBasis > SBasisHelper; //curves SPCurve * in = new SPCurve(); @@ -2007,9 +2008,9 @@ static void __attribute__((optimize(0))) bspline_doEffect(SPCurve * curve) Geom::Point nextPointAt1(0,0); Geom::Point nextPointAt2(0,0); Geom::Point nextPointAt3(0,0); - Geom::CubicBezier const *cubicIn; - Geom::CubicBezier const *cubicOut; - Geom::CubicBezier const *cubicEnd; + + Geom::Point endPointAt2(0,0); + Geom::CubicBezier const *cubic; //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { //Si está vacío... @@ -2019,7 +2020,7 @@ static void __attribute__((optimize(0))) bspline_doEffect(SPCurve * curve) Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve - Geom::Path::const_iterator curve_end = path_it->end(); // end curve + Geom::Path::const_iterator curve_end = path_it->end_open(); // end curve Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop //Creamos las lineas rectas que unen todos los puntos del trazado y donde se calcularán @@ -2036,12 +2037,31 @@ static void __attribute__((optimize(0))) bspline_doEffect(SPCurve * curve) //Si la curva está cerrada calculamos el punto donde //deveria estar el nodo BSpline de cierre/inicio de la curva //en posible caso de que se cierre con una linea recta creando un nodo BSPline - cubicEnd = dynamic_cast(&*curve_end); - cubicIn = dynamic_cast(&*curve_it1); - if (path_it->closed() && cubicEnd && cubicIn) { - //Calculamos el nodo de inicio BSpline - lineHelper->moveto((*cubicIn)[1]); - lineHelper->lineto((*cubicEnd)[2]); + + if (path_it->closed()) { + // if the path is closed, maybe we have to stop a bit earlier because the closing line segment has zerolength. + const Geom::Curve &closingline = path_it->back_closed(); // the closing line segment is always of type Geom::LineSegment. + if (are_near(closingline.initialPoint(), closingline.finalPoint())) { + // closingline.isDegenerate() did not work, because it only checks for *exact* zero length, which goes wrong for relative coordinates and rounding errors... + // the closing line segment has zero-length. So stop before that one! + curve_endit = path_it->end_open(); + } + SBasisIn = in->first_segment()->toSBasis(); + SBasisEnd = end->first_segment()->toSBasis(); + cubic = dynamic_cast(&*curve_it1); + if(cubic){ + pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[1],*in->first_segment())); + }else{ + pointAt1 = in->first_segment()->initialPoint(); + } + cubic = dynamic_cast(&*curve_end); + if(cubic){ + endPointAt2 = SBasisEnd.valueAt(Geom::nearest_point((*cubic)[2],*end->first_segment())); + }else{ + endPointAt2 = end->first_segment()->finalPoint(); + } + lineHelper->moveto(pointAt1); + lineHelper->lineto(endPointAt2); SBasisHelper = lineHelper->first_segment()->toSBasis(); lineHelper->reset(); //Guardamos el principio de la curva @@ -2054,18 +2074,18 @@ static void __attribute__((optimize(0))) bspline_doEffect(SPCurve * curve) //Definimos el punto de inicio original de la curva resultante node = startNode; } - //Recorremos todos los segmentos menos el último while ( curve_it2 != curve_endit ) { //previousPointAt3 = pointAt3; //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida - cubicIn = dynamic_cast(&*curve_it1); - if(cubicIn){ - pointAt0 = (*cubicIn)[0]; - pointAt1 = (*cubicIn)[1]; - pointAt2 = (*cubicIn)[2]; - pointAt3 = (*cubicIn)[3]; + cubic = dynamic_cast(&*curve_it1); + if(cubic){ + SBasisIn = in->first_segment()->toSBasis(); + pointAt0 = (*cubic)[0]; + pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[1],*in->first_segment())); + pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[2],*in->first_segment())); + pointAt3 = (*cubic)[3]; }else{ pointAt0 = in->first_segment()->initialPoint(); pointAt1 = in->first_segment()->initialPoint(); @@ -2074,15 +2094,16 @@ static void __attribute__((optimize(0))) bspline_doEffect(SPCurve * curve) } //Y hacemos lo propio con el path de salida //nextPointAt0 = curveOut.valueAt(0); - cubicOut = dynamic_cast(&*curve_it2); - if(cubicOut){ - nextPointAt1 = (*cubicOut)[1]; - nextPointAt2 = (*cubicOut)[2]; - nextPointAt3 = (*cubicOut)[3]; + cubic = dynamic_cast(&*curve_it2); + if(cubic){ + SBasisOut = out->first_segment()->toSBasis(); + nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[1],*out->first_segment())); + nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[2],*out->first_segment()));; + nextPointAt3 = (*cubic)[3]; }else{ - nextPointAt1 = in->first_segment()->initialPoint(); - nextPointAt2 = in->first_segment()->finalPoint(); - nextPointAt3 = in->first_segment()->finalPoint(); + nextPointAt1 = out->first_segment()->initialPoint(); + nextPointAt2 = out->first_segment()->finalPoint(); + nextPointAt3 = out->first_segment()->finalPoint(); } //La curva BSpline se forma calculando el centro del segmanto de unión //de el punto situado en las 2/3 partes de el segmento de entrada diff --git a/src/ui/tool/curve-drag-point.cpp b/src/ui/tool/curve-drag-point.cpp index b83ce1b3c..40dcb5058 100644 --- a/src/ui/tool/curve-drag-point.cpp +++ b/src/ui/tool/curve-drag-point.cpp @@ -53,9 +53,12 @@ bool CurveDragPoint::grabbed(GdkEventMotion */*event*/) // delta is a vector equal 1/3 of distance from first to second Geom::Point delta = (second->position() - first->position()) / 3.0; - first->front()->move(first->front()->position() + delta); - second->back()->move(second->back()->position() - delta); - + //BSpline + if(!_pm.isBSpline()){ + first->front()->move(first->front()->position() + delta); + second->back()->move(second->back()->position() - delta); + } + //BSpline End _pm.update(); } else { _segment_was_degenerate = false; @@ -87,10 +90,13 @@ void CurveDragPoint::dragged(Geom::Point &new_pos, GdkEventMotion *event) Geom::Point delta = new_pos - position(); Geom::Point offset0 = ((1-weight)/(3*t*(1-t)*(1-t))) * delta; Geom::Point offset1 = (weight/(3*t*t*(1-t))) * delta; - - first->front()->move(first->front()->position() + offset0); - second->back()->move(second->back()->position() + offset1); - + //BSpline + if(!_pm.isBSpline()){ + first->front()->move(first->front()->position() + offset0); + second->back()->move(second->back()->position() + offset1); + }else if(weight>=0.8)second->back()->move(new_pos); + else if(weight<=0.2)first->front()->move(new_pos); + //BSpline End _pm.update(); } diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 1a196c857..c6a2df749 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -142,6 +142,7 @@ void Handle::move(Geom::Point const &new_pos) Handle *h2 = NULL; if(_pm().isBSpline()){ isBSpline = true; + _parent->_selection.insert(_parent); //BSpline End } @@ -174,6 +175,7 @@ void Handle::move(Geom::Point const &new_pos) other->setDirection(*node_towards, *_parent); } } + setPosition(new_pos); //BSpline if(isBSpline){ h = this; @@ -183,7 +185,6 @@ void Handle::move(Geom::Point const &new_pos) this->other()->setPosition(_pm().BSplineHandleReposition(h2,pos)); } //BSpline End - setPosition(new_pos); return; } @@ -580,8 +581,6 @@ void Node::move(Geom::Point const &new_pos) if(_pm().isBSpline()){ Node *n = this; pos = _pm().BSplineHandlePosition(n->front()); - if(pos == 0) - pos = _pm().BSplineHandlePosition(n->back()); } //BSpline End setPosition(new_pos); diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index c4158931a..ecb8abcf4 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1185,21 +1185,18 @@ bool PathManipulator::isBSpline(){ double PathManipulator::BSplineHandlePosition(Handle *h){ double pos = 0; Node *n = h->parent(); - Geom::D2< Geom::SBasis > SBasisInsideNodes; SPCurve *lineInsideNodes = new SPCurve(); Node * nextNode = n->nodeToward(h); if(nextNode){ lineInsideNodes->moveto(n->position()); lineInsideNodes->lineto(nextNode->position()); - SBasisInsideNodes = lineInsideNodes->first_segment()->toSBasis(); pos = Geom::nearest_point(h->position(),*lineInsideNodes->first_segment()); } return pos; } Geom::Point PathManipulator::BSplineHandleReposition(Handle *h){ - double pos = 0; - pos = this->BSplineHandlePosition(h); + double pos = this->BSplineHandlePosition(h); return BSplineHandleReposition(h,pos); } @@ -1208,7 +1205,7 @@ Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){ Geom::D2< Geom::SBasis > SBasisInsideNodes; SPCurve *lineInsideNodes = new SPCurve(); Node * nextNode = n->nodeToward(h); - if(nextNode && pos != 0){ + if(nextNode){ lineInsideNodes->moveto(n->position()); lineInsideNodes->lineto(nextNode->position()); SBasisInsideNodes = lineInsideNodes->first_segment()->toSBasis(); @@ -1233,50 +1230,37 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) } NodeList::iterator prev = subpath->begin(); //BSpline - float pos = NULL; + double pos =0; bool isBSpline = false; if(this->isBSpline()) isBSpline = true; if(isBSpline){ pos = BSplineHandlePosition(prev.ptr()->front()); - prev.ptr()->front()->setPosition(BSplineHandleReposition(prev.ptr()->front(),pos)); - if(pos == 0){ - prev.ptr()->setPosition(BSplineHandleReposition(i.ptr()->front(),pos)); - } + prev->front()->setPosition(BSplineHandleReposition(prev->front(),pos)); } //BSpline End builder.moveTo(prev->position()); for (NodeList::iterator i = ++subpath->begin(); i != subpath->end(); ++i) { //BSpline if (isBSpline) { - pos = BSplineHandlePosition(i.ptr()->front()); - if(pos == 0) - pos = BSplineHandlePosition(i.ptr()->back()); - i.ptr()->front()->setPosition(BSplineHandleReposition(i.ptr()->front(),pos)); - i.ptr()->back()->setPosition(BSplineHandleReposition(i.ptr()->back(),pos)); - if(pos == 0){ - i.ptr()->setPosition(BSplineHandleReposition(i.ptr()->front(),pos)); - } + pos = BSplineHandlePosition(i->back()); + i->front()->setPosition(BSplineHandleReposition(i->front(),pos)); + i->back()->setPosition(BSplineHandleReposition(i->back(),pos)); } //BSpline End build_segment(builder, prev.ptr(), i.ptr()); prev = i; } + if (subpath->closed()) { // Here we link the last and first node if the path is closed. // If the last segment is Bezier, we add it. //BSpline if (isBSpline) { - pos = BSplineHandlePosition(prev.ptr()->front()); - if(pos == 0) - pos = BSplineHandlePosition(subpath->begin().ptr()->back()); - subpath->begin().ptr()->front()->setPosition(BSplineHandleReposition(subpath->begin().ptr()->front(),pos)); - prev.ptr()->back()->setPosition(BSplineHandleReposition(prev.ptr()->back(),pos)); - if(pos == 0){ - subpath->begin().ptr()->setPosition(BSplineHandleReposition(subpath->begin().ptr()->front(),pos)); - prev.ptr()->setPosition(BSplineHandleReposition(prev.ptr()->back(),pos)); - } + pos = BSplineHandlePosition(prev.next()->back()); + subpath->begin()->front()->setPosition(BSplineHandleReposition(subpath->begin()->front(),pos)); + prev.next()->back()->setPosition(BSplineHandleReposition(prev.next()->back(),pos)); } //BSpline End if (!prev->front()->isDegenerate() || !subpath->begin()->back()->isDegenerate()) { -- cgit v1.2.3 From ca40dfd444c2543a6debc0786fa8679a108b1056 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 25 Feb 2013 10:59:10 +0100 Subject: BSpline refactor (bzr r11950.1.38) --- src/pen-context.cpp | 311 ++++++++++++++++++++++++++++++++++++++++----------- src/ui/tool/node.cpp | 18 ++- 2 files changed, 264 insertions(+), 65 deletions(-) (limited to 'src') diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 350924adb..4270aecea 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -97,6 +97,7 @@ static void sp_pen_context_set_mode(SPPenContext *const pc, guint mode); static void spiro_color(SPPenContext *const pc); //Guarda el valor si se ha pulsado la tecla SHIFT al continuar una curva static bool saShift = false; + //Preparamos la curva roja para que se muestre según esté pulsada la tecla SHIFT static void spiro(SPPenContext *const pc, bool Shift); //Unimos todas las curvas en juego y llamamos a la función doEffect. @@ -104,7 +105,14 @@ static void spiro_build(SPPenContext *const pc); //function spiro cloned from lpe-spiro.cpp static void spiro_doEffect(SPCurve * curve); //Preparamos la curva roja para que se muestre según esté pulsada la tecla SHIFT -static void bspline(SPPenContext *const pc,bool Shift); +static void bspline(SPPenContext *const pc,bool shift); +static void bsplineInMotion(SPPenContext *const pc,bool shift); +static void bsplineOn(SPPenContext *const pc); +static void bsplineStartAnchorOn(SPPenContext *const pc); +static void bsplineEndAnchorOn(SPPenContext *const pc); +static void bsplineOff(SPPenContext *const pc); +static void bsplineStartAnchorOff(SPPenContext *const pc); +static void bsplineEndAnchorOff(SPPenContext *const pc); //Unimos todas las curvas en juego y llamamos a la función doEffect. static void bspline_build(SPPenContext *const pc); //function bspline cloned from lpe-bspline.cpp @@ -528,6 +536,16 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const // Set start anchor pc->sa = anchor; + //BSpline + if(anchor){ + if(pc->spiro){ + spiro(pc,(bevent.state & GDK_SHIFT_MASK)); + } + if(pc->bspline){ + bspline(pc,(bevent.state & GDK_SHIFT_MASK)); + } + } + //BSpline End if (anchor && !sp_pen_context_has_waiting_LPE(pc)) { // Adjust point to anchor if needed; if we have a waiting LPE, we need // a fresh path to be created so don't continue an existing one @@ -578,12 +596,8 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const spdc_pen_set_subsequent_point(pc, p, true); } } - - pc->state = pc->polylines_only ? SP_PEN_CONTEXT_POINT : SP_PEN_CONTEXT_CONTROL; - //BSpline - //Esto evita arrastrar los manejadores ya que el punto se crea - //al soltar el botón del ratón. - if((pc->spiro || pc->bspline) && pc->state != SP_PEN_CONTEXT_CLOSE) pc->state = SP_PEN_CONTEXT_POINT; + //BSpline; + pc->state = (pc->polylines_only || pc->spiro || pc->bspline )? SP_PEN_CONTEXT_POINT : SP_PEN_CONTEXT_CONTROL; //BSpline End ret = TRUE; break; @@ -665,7 +679,6 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons // Find desktop coordinates Geom::Point p = dt->w2d(event_w); - // Test, whether we hit any anchor SPDrawAnchor *anchor = spdc_test_inside(pc, event_w); switch (pc->mode) { @@ -750,9 +763,7 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons // snap the handle spdc_endpoint_snap_handle(pc, p, mevent.state); - //BSpline - if (!pc->polylines_only && !pc->spiro && !pc->bspline) { - //BSpline End + if (!pc->polylines_only) { spdc_pen_set_ctrl(pc, p, mevent.state); } else { spdc_pen_set_ctrl(pc, pc->p[1], mevent.state); @@ -782,7 +793,7 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons spiro(pc,(mevent.state & GDK_SHIFT_MASK)); } if(pc->bspline){ - bspline(pc,(mevent.state & GDK_SHIFT_MASK)); + bsplineInMotion(pc,(mevent.state & GDK_SHIFT_MASK)); } pen_drag_origin_w = event_w; } @@ -830,6 +841,14 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con p = anchor->dp; } pc->sa = anchor; + //BSpline + if(pc->spiro){ + spiro(pc,(revent.state & GDK_SHIFT_MASK)); + } + if(pc->bspline){ + bspline(pc,(revent.state & GDK_SHIFT_MASK)); + } + //BSpline End spdc_pen_set_initial_point(pc, p); } else { // Set end anchor here @@ -838,14 +857,6 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con p = anchor->dp; } } - //BSpline - if(pc->spiro){ - spiro(pc,(revent.state & GDK_SHIFT_MASK)); - } - if(pc->bspline){ - bspline(pc,(revent.state & GDK_SHIFT_MASK)); - } - //BSpline End pc->state = SP_PEN_CONTEXT_CONTROL; ret = TRUE; break; @@ -984,20 +995,8 @@ static void pen_redraw_all (SPPenContext *const pc) // handles //BSpline - SPCurve * WPower = new SPCurve(); - Geom::D2< Geom::SBasis > SBasisWPower; - float WP = 0; - if (pc->p[0] != pc->p[1] && !pc->spiro /*&& !pc->bspline*/) { + if (pc->p[0] != pc->p[1] && !pc->spiro && !pc->bspline) { //BSpline End - if(pc->bspline){ - WPower->moveto(pc->red_curve->first_segment()->initialPoint()); - WPower->lineto(pc->red_curve->first_segment()->finalPoint()); - SBasisWPower = WPower->first_segment()->toSBasis(); - - WPower->reset(); - pc->p[1] = SBasisWPower.valueAt(WP); - } - SP_CTRL(pc->c1)->moveto(pc->p[1]); pc->cl1->setCoords(pc->p[0], pc->p[1]); sp_canvas_item_show(pc->c1); @@ -1006,23 +1005,16 @@ static void pen_redraw_all (SPPenContext *const pc) sp_canvas_item_hide(pc->c1); sp_canvas_item_hide(pc->cl1); } - Geom::Point p2; + Geom::Curve const * last_seg = pc->green_curve->last_segment(); if (last_seg) { Geom::CubicBezier const * cubic = dynamic_cast( last_seg ); //BSpline if ( cubic && - (*cubic)[2] != pc->p[0]&& !pc->spiro /*&& !pc->bspline*/ ) + (*cubic)[2] != pc->p[0]&& !pc->spiro && !pc->bspline ) { //BSpline End - if(pc->bspline){ - WPower->moveto(last_seg->finalPoint()); - WPower->lineto(last_seg->initialPoint()); - SBasisWPower = WPower->first_segment()->toSBasis(); - p2 = SBasisWPower.valueAt(WP); - }else{ - p2 = (*cubic)[2]; - } + Geom::Point p2 = (*cubic)[2]; SP_CTRL(pc->c0)->moveto(p2); pc->cl0->setCoords(p2, pc->p[0]); sp_canvas_item_show(pc->c0); @@ -1378,12 +1370,6 @@ static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) } } else { // Reset red curve - //BSpline - if ((pc->spiro || pc->bspline) && pc->green_curve->get_segment_count()==1) { - pen_cancel (pc); - ret = TRUE; - } - //BSpline End pc->red_curve->reset(); // Destroy topmost green bpath if (pc->green_bpaths) { @@ -1415,13 +1401,11 @@ static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) spdc_pen_set_subsequent_point(pc, pt, true); pen_last_paraxial_dir = !pen_last_paraxial_dir; //BSpline - if(pc->spiro || pc->bspline){ - SPCanvasItem *cshape = sp_canvas_bpath_new(sp_desktop_sketch(pc->desktop), pc->green_curve); - sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cshape), pc->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); - sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(cshape), 0, SP_WIND_RULE_NONZERO); - pc->green_bpaths = g_slist_prepend(pc->green_bpaths, cshape); - pen_redraw_all(pc); - } + if((pc->spiro || pc->bspline) && ( pc->green_curve->is_empty() || pc->green_curve->last_segment() == NULL )){ + pen_cancel (pc); + ret = TRUE; + } pc->blue_curve->reset(); + if(pc->spiro || pc->bspline) bspline_build(pc); //BSpline End ret = TRUE; } @@ -1782,6 +1766,209 @@ static void spiro_doEffect(SPCurve * curve) g_free (path); } +//Unimos todas las curvas en juego y llamamos a la función doEffect. + +static void bspline(SPPenContext *const pc, bool shift) +{ + shift?bsplineOff(pc):bsplineOn(pc); + bspline_build(pc); +} + +static void bsplineInMotion(SPPenContext *const pc, bool shift){ + SPCurve *tmpCurve = new SPCurve(); + if(pc->green_curve->is_empty() && !pc->sa){ + pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]); + }else if(!pc->green_curve->is_empty()){ + tmpCurve = pc->green_curve->copy(); + }else{ + tmpCurve = pc->sa->curve->copy(); + if(pc->sa->start) + tmpCurve = tmpCurve->create_reverse(); + } + if(!tmpCurve->is_empty() && !pc->red_curve->is_empty()){ + Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); + if(cubic){ + SPCurve * WPower = new SPCurve(); + Geom::D2< Geom::SBasis > SBasisWPower; + WPower->moveto(tmpCurve->last_segment()->finalPoint()); + WPower->lineto(tmpCurve->last_segment()->initialPoint()); + float WP = Geom::nearest_point((*cubic)[2],*WPower->first_segment()); + WPower->reset(); + WPower->moveto(pc->red_curve->last_segment()->initialPoint()); + WPower->lineto(pc->red_curve->last_segment()->finalPoint()); + SBasisWPower = WPower->first_segment()->toSBasis(); + WPower->reset(); + pc->p[1] = SBasisWPower.valueAt(WP); + }else{ + pc->p[1] = pc->p[0]; + } + } + + if(pc->anchor_statusbar && !pc->red_curve->is_empty()){ + if(shift) + bsplineEndAnchorOff(pc); + else + bsplineEndAnchorOn(pc); + } + + bspline_build(pc); +} + +static void bsplineOff(SPPenContext *const pc) +{ + if(!pc->red_curve->is_empty()){ + pc->npoints = 5; + pc->p[0] = pc->red_curve->first_segment()->initialPoint(); + pc->p[3] = pc->red_curve->first_segment()->finalPoint(); + pc->p[2] = pc->p[3]; + pc->p[4] = pc->p[3]; + } + if(pc->anchor_statusbar && pc->sa && !pc->sa->curve->is_empty() && pc->red_curve->is_empty()) + bsplineStartAnchorOff(pc); +} + +static void bsplineStartAnchorOff(SPPenContext *const pc) +{ + SPCurve *tmpCurve = new SPCurve(); + tmpCurve = pc->sa->curve->copy(); + if(pc->sa->start) + tmpCurve = tmpCurve->create_reverse(); + Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); + if(cubic){ + SPCurve *lastSeg = new SPCurve(); + lastSeg->moveto((*cubic)[0]); + lastSeg->curveto((*cubic)[1],(*cubic)[3],(*cubic)[3]); + tmpCurve->backspace(); + tmpCurve->append_continuous(lastSeg, 0.0625); + if (pc->sa->start) { + tmpCurve = tmpCurve->create_reverse(); + } + pc->sa->curve->reset(); + pc->sa->curve = tmpCurve; + } + +} + +static void bsplineEndAnchorOff(SPPenContext *const pc) +{ + pc->p[2] = pc->p[3]; + SPCurve *tmpCurve = new SPCurve(); + SPCurve *lastSeg = new SPCurve(); + if(!pc->sa || pc->sa->curve->is_empty()){ + tmpCurve = pc->green_curve->create_reverse(); + Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); + if(cubic){ + lastSeg->moveto((*cubic)[0]); + lastSeg->curveto((*cubic)[1],(*cubic)[3],(*cubic)[3]); + tmpCurve->backspace(); + tmpCurve->append_continuous(lastSeg, 0.0625); + tmpCurve = tmpCurve->create_reverse(); + pc->green_curve->reset(); + pc->green_curve = tmpCurve; + } + }else{ + tmpCurve = pc->sa->curve->copy(); + if(!pc->sa->start) + tmpCurve = tmpCurve->create_reverse(); + Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); + if(cubic){ + lastSeg->moveto((*cubic)[0]); + lastSeg->curveto((*cubic)[1],(*cubic)[3],(*cubic)[3]); + tmpCurve->backspace(); + tmpCurve->append_continuous(lastSeg, 0.0625); + if (!pc->sa->start) { + tmpCurve = tmpCurve->create_reverse(); + } + pc->sa->curve->reset(); + pc->sa->curve = tmpCurve; + } + } +} + +static void bsplineOn(SPPenContext *const pc){ + if(!pc->red_curve->is_empty()){ + pc->npoints = 5; + pc->p[0] = pc->red_curve->first_segment()->initialPoint(); + pc->p[3] = pc->red_curve->first_segment()->finalPoint(); + pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); + } + if(pc->anchor_statusbar && pc->sa && !pc->sa->curve->is_empty() && pc->red_curve->is_empty()) + bsplineStartAnchorOn(pc); +} + +static void bsplineStartAnchorOn(SPPenContext *const pc) +{ + SPCurve *tmpCurve = new SPCurve(); + tmpCurve = pc->sa->curve->copy(); + if(pc->sa->start) + tmpCurve = tmpCurve->create_reverse(); + Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); + SPCurve *lastSeg = new SPCurve(); + Geom::Point A = tmpCurve->last_segment()->initialPoint(); + Geom::Point D = tmpCurve->last_segment()->finalPoint(); + Geom::Point C(0,0); + if(cubic){ + C = D + (1./3)*(A - D); + lastSeg->moveto(A); + lastSeg->curveto((*cubic)[1],C,D); + }else{ + lastSeg->moveto(A); + lastSeg->curveto(A,C,D); + } + tmpCurve->backspace(); + tmpCurve->append_continuous(lastSeg, 0.0625); + if (pc->sa->start) { + tmpCurve = tmpCurve->create_reverse(); + } + pc->sa->curve->reset(); + pc->sa->curve = tmpCurve; +} + +static void bsplineEndAnchorOn(SPPenContext *const pc) +{ + pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); + SPCurve *tmpCurve = new SPCurve(); + SPCurve *lastSeg = new SPCurve(); + Geom::Point C(0,0); + if(!pc->sa || pc->sa->curve->is_empty()){ + tmpCurve = pc->green_curve->create_reverse(); + Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); + C = tmpCurve->last_segment()->finalPoint() + (1./3)*(tmpCurve->last_segment()->initialPoint() - tmpCurve->last_segment()->finalPoint()); + if(cubic){ + lastSeg->moveto((*cubic)[0]); + lastSeg->curveto((*cubic)[1],C,(*cubic)[3]); + }else{ + lastSeg->moveto(tmpCurve->last_segment()->initialPoint()); + lastSeg->curveto(tmpCurve->last_segment()->initialPoint(),C,tmpCurve->last_segment()->finalPoint()); + } + tmpCurve->backspace(); + tmpCurve->append_continuous(lastSeg, 0.0625); + tmpCurve = tmpCurve->create_reverse(); + pc->green_curve->reset(); + pc->green_curve = tmpCurve; + }else{ + tmpCurve = pc->sa->curve->copy(); + if(!pc->sa->start) + tmpCurve = tmpCurve->create_reverse(); + Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); + C = tmpCurve->last_segment()->finalPoint() + (1./3)*(tmpCurve->last_segment()->initialPoint() - tmpCurve->last_segment()->finalPoint()); + if(cubic){ + lastSeg->moveto((*cubic)[0]); + lastSeg->curveto((*cubic)[1],C,(*cubic)[3]); + }else{ + lastSeg->moveto(tmpCurve->last_segment()->initialPoint()); + lastSeg->curveto(tmpCurve->last_segment()->initialPoint(),C,tmpCurve->last_segment()->finalPoint()); + } + tmpCurve->backspace(); + tmpCurve->append_continuous(lastSeg, 0.0625); + if (!pc->sa->start) { + tmpCurve = tmpCurve->create_reverse(); + } + pc->sa->curve->reset(); + pc->sa->curve = tmpCurve; + } +} +/* //Unimos todas las curvas en juego y llamamos a la función doEffect. static void bspline(SPPenContext *const pc, bool Shift) { @@ -1789,6 +1976,7 @@ static void bspline(SPPenContext *const pc, bool Shift) using Geom::Y; Geom::CubicBezier const *cubic; if(Shift){ + //Continuamos la curva en modo CUSP //Guardamos el valor de inicio en cusp para que no se redibuje como SYMM if(pc->anchor_statusbar && pc->red_curve->is_empty()){ @@ -1916,7 +2104,7 @@ static void bspline(SPPenContext *const pc, bool Shift) bspline_build(pc); } - +/*/ //preparates the curves for its trasformation into BSline curves. static void bspline_build(SPPenContext *const pc) @@ -2272,14 +2460,12 @@ static void spdc_pen_finish_segment(SPPenContext *const pc, Geom::Point const p, ++pc->num_clicks; if (!pc->red_curve->is_empty()) { - //BSpline if(pc->spiro){ - spiro(pc, (state & GDK_SHIFT_MASK)); + spiro(pc,(state & GDK_SHIFT_MASK)); } if(pc->bspline){ - bspline(pc, (state & GDK_SHIFT_MASK)); + bspline(pc,(state & GDK_SHIFT_MASK)); } - //BSpline End pc->green_curve->append_continuous(pc->red_curve, 0.0625); SPCurve *curve = pc->red_curve->copy(); /// \todo fixme: @@ -2305,9 +2491,6 @@ static void spdc_pen_finish(SPPenContext *const pc, gboolean const closed) } pc->num_clicks = 0; - if(pc->spiro || pc->bspline){ - saShift = false; - } pen_disable_events(pc); SPDesktop *const desktop = pc->desktop; diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index c6a2df749..6dc6c7528 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -577,13 +577,29 @@ void Node::move(Geom::Point const &new_pos) Geom::Point old_pos = position(); Geom::Point delta = new_pos - position(); //BSpline + double prevPos = 0; double pos = 0; + double nextPos = 0; + Node *n = this; + Node * nextNode = n->nodeToward(n->front()); + Node * prevNode = n->nodeToward(n->back()); if(_pm().isBSpline()){ - Node *n = this; + if(prevNode) + prevPos = _pm().BSplineHandlePosition(prevNode->front()); pos = _pm().BSplineHandlePosition(n->front()); + if(nextNode) + nextPos = _pm().BSplineHandlePosition(nextNode->back()); } //BSpline End setPosition(new_pos); + //BSpline + if(prevNode){ + prevNode->front()->setPosition(_pm().BSplineHandleReposition(prevNode->front(),prevPos)); + } + if(nextNode){ + nextNode->back()->setPosition(_pm().BSplineHandleReposition(nextNode->back(),nextPos)); + } + //BSpline End _front.setPosition(_front.position() + delta); _back.setPosition(_back.position() + delta); //BSpline -- cgit v1.2.3 From ecc57932f1e7d157950ada2901f6ea6f3acc8aad Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 28 Feb 2013 04:43:21 +0100 Subject: Fixed closed pc->ea (bzr r11950.1.40) --- src/draw-context.cpp | 22 +- src/live_effects/lpe-bspline.cpp | 10 +- src/pen-context.cpp | 420 ++++++++++++++++++++++----------------- src/ui/tool/node.cpp | 38 ++-- src/ui/tool/path-manipulator.cpp | 45 ++--- 5 files changed, 293 insertions(+), 242 deletions(-) (limited to 'src') diff --git a/src/draw-context.cpp b/src/draw-context.cpp index 8da39b027..dcd0fc7ec 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -561,7 +561,15 @@ void spdc_concat_colors_and_flush(SPDrawContext *dc, gboolean forceclosed) dc->sa->curve->append_continuous(c, 0.0625); c->unref(); dc->sa->curve->closepath_current(); - spdc_flush_white(dc, NULL); + //BSpline + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || + prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ + dc->white_curves = g_slist_remove(dc->white_curves, dc->sa->curve); + spdc_flush_white(dc, dc->sa->curve); + }else + //BSpline End + spdc_flush_white(dc, NULL); return; } @@ -687,6 +695,18 @@ SPDrawAnchor *spdc_test_inside(SPDrawContext *dc, Geom::Point p) } } + //BSpline + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if((prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || + prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2) && + dc->sa && !dc->red_curve->is_empty() && !dc->green_anchor){ + if(active){ + active->curve = dc->sa->curve; + active->curve->ref(); + } + } + //BSpline End + return active; } diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 8dc840556..36caf73c5 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -34,6 +34,8 @@ LPEBSpline::doEffect(SPCurve * curve) { if(curve->get_segment_count() < 2) return; + using Geom::X; + using Geom::Y; // Make copy of old path as it is changed during processing Geom::PathVector const original_pathv = curve->get_pathvector(); curve->reset(); @@ -94,13 +96,6 @@ LPEBSpline::doEffect(SPCurve * curve) //en posible caso de que se cierre con una linea recta creando un nodo BSPline if (path_it->closed()) { - // if the path is closed, maybe we have to stop a bit earlier because the closing line segment has zerolength. - const Geom::Curve &closingline = path_it->back_closed(); // the closing line segment is always of type Geom::LineSegment. - if (are_near(closingline.initialPoint(), closingline.finalPoint())) { - // closingline.isDegenerate() did not work, because it only checks for *exact* zero length, which goes wrong for relative coordinates and rounding errors... - // the closing line segment has zero-length. So stop before that one! - curve_endit = path_it->end_open(); - } SBasisIn = in->first_segment()->toSBasis(); SBasisEnd = end->first_segment()->toSBasis(); cubic = dynamic_cast(&*curve_it1); @@ -223,6 +218,7 @@ LPEBSpline::doEffect(SPCurve * curve) //Todo: remove? //delete SBasisHelper; } + }; //namespace LivePathEffect }; /* namespace Inkscape */ diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 4270aecea..6910e903b 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -106,12 +106,13 @@ static void spiro_build(SPPenContext *const pc); static void spiro_doEffect(SPCurve * curve); //Preparamos la curva roja para que se muestre según esté pulsada la tecla SHIFT static void bspline(SPPenContext *const pc,bool shift); -static void bsplineInMotion(SPPenContext *const pc,bool shift); static void bsplineOn(SPPenContext *const pc); -static void bsplineStartAnchorOn(SPPenContext *const pc); -static void bsplineEndAnchorOn(SPPenContext *const pc); static void bsplineOff(SPPenContext *const pc); +static void bsplineStartAnchor(SPPenContext *const pc,bool shift); +static void bsplineStartAnchorOn(SPPenContext *const pc); static void bsplineStartAnchorOff(SPPenContext *const pc); +static void bsplineMotion(SPPenContext *const pc,bool shift); +static void bsplineEndAnchorOn(SPPenContext *const pc); static void bsplineEndAnchorOff(SPPenContext *const pc); //Unimos todas las curvas en juego y llamamos a la función doEffect. static void bspline_build(SPPenContext *const pc); @@ -466,7 +467,8 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const Geom::Point event_dt(desktop->w2d(event_w)); SPEventContext *event_context = SP_EVENT_CONTEXT(pc); //Test whether we hit any anchor. - SPDrawAnchor * const anchor = spdc_test_inside(pc, event_w); + //Anchor changed from Const because need to update pc->ea for BSpline. + SPDrawAnchor * anchor = spdc_test_inside(pc, event_w); //BSpline //with this we avoid creating a new point over the existing one if((pc->spiro || pc->bspline) && pc->npoints > 0 && pc->p[0] == pc->p[3]){ @@ -542,7 +544,7 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const spiro(pc,(bevent.state & GDK_SHIFT_MASK)); } if(pc->bspline){ - bspline(pc,(bevent.state & GDK_SHIFT_MASK)); + bsplineStartAnchor(pc,(bevent.state & GDK_SHIFT_MASK)); } } //BSpline End @@ -596,8 +598,10 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const spdc_pen_set_subsequent_point(pc, p, true); } } - //BSpline; - pc->state = (pc->polylines_only || pc->spiro || pc->bspline )? SP_PEN_CONTEXT_POINT : SP_PEN_CONTEXT_CONTROL; + //BSpline + //Esto evita arrastrar los manejadores ya que el punto se crea + //al soltar el botón del ratón. + pc->state = (pc->spiro || pc->bspline || pc->polylines_only) ? SP_PEN_CONTEXT_POINT : SP_PEN_CONTEXT_CONTROL; //BSpline End ret = TRUE; break; @@ -760,7 +764,6 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons case SP_PEN_CONTEXT_CONTROL: case SP_PEN_CONTEXT_CLOSE: // Placing controls is last operation in CLOSE state - // snap the handle spdc_endpoint_snap_handle(pc, p, mevent.state); if (!pc->polylines_only) { @@ -768,6 +771,7 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons } else { spdc_pen_set_ctrl(pc, pc->p[1], mevent.state); } + gobble_motion_events(GDK_BUTTON1_MASK); ret = TRUE; break; @@ -793,7 +797,7 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons spiro(pc,(mevent.state & GDK_SHIFT_MASK)); } if(pc->bspline){ - bsplineInMotion(pc,(mevent.state & GDK_SHIFT_MASK)); + bsplineMotion(pc,(mevent.state & GDK_SHIFT_MASK)); } pen_drag_origin_w = event_w; } @@ -842,11 +846,13 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con } pc->sa = anchor; //BSpline - if(pc->spiro){ - spiro(pc,(revent.state & GDK_SHIFT_MASK)); - } - if(pc->bspline){ - bspline(pc,(revent.state & GDK_SHIFT_MASK)); + if (anchor) { + if(pc->spiro){ + spiro(pc,(revent.state & GDK_SHIFT_MASK)); + } + if(pc->bspline){ + bsplineStartAnchor(pc,(revent.state & GDK_SHIFT_MASK)); + } } //BSpline End spdc_pen_set_initial_point(pc, p); @@ -900,7 +906,10 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con spdc_pen_finish_segment(pc, p, revent.state); break; case SP_PEN_CONTEXT_CLOSE: - spdc_endpoint_snap(pc, p, revent.state); + // End current segment + if (!anchor) { // Snap node only if not hitting anchor + spdc_endpoint_snap(pc, p, revent.state); + } spdc_pen_finish_segment(pc, p, revent.state); //BSpline //Ocultamos la guia del penultimo nodo al cerrar la curva @@ -919,7 +928,7 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con case SP_PEN_CONTEXT_STOP: // This is allowed, if we just cancelled curve break; - default: + default: break; } pc->state = SP_PEN_CONTEXT_POINT; @@ -1011,7 +1020,7 @@ static void pen_redraw_all (SPPenContext *const pc) Geom::CubicBezier const * cubic = dynamic_cast( last_seg ); //BSpline if ( cubic && - (*cubic)[2] != pc->p[0]&& !pc->spiro && !pc->bspline ) + (*cubic)[2] != pc->p[0] && !pc->spiro && !pc->bspline ) { //BSpline End Geom::Point p2 = (*cubic)[2]; @@ -1387,24 +1396,37 @@ static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) pc->p[0] = crv->initialPoint(); if ( Geom::CubicBezier const * cubic = dynamic_cast(crv)) { pc->p[1] = (*cubic)[1]; + //BSpline + if(pc->spiro || pc->bspline)pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]); + //BSpline End } else { pc->p[1] = pc->p[0]; } - Geom::Point const pt(( pc->npoints < 4 + + Geom::Point const pt((pc->npoints < 4 ? (Geom::Point)(crv->finalPoint()) - : pc->p[3] )); + : pc->p[3])); + pc->npoints = 2; - pc->green_curve->backspace(); + //BSpline + if( pc->green_curve->get_segment_count() == 1){ + pc->npoints = 5; + if (pc->green_bpaths) { + if (pc->green_bpaths->data) + sp_canvas_item_destroy(SP_CANVAS_ITEM(pc->green_bpaths->data)); + pc->green_bpaths = g_slist_remove(pc->green_bpaths, pc->green_bpaths->data); + } + pc->green_curve->reset(); + }else{ + pc->green_curve->backspace(); + } + //BSpline End sp_canvas_item_hide(pc->cl0); sp_canvas_item_hide(pc->cl1); pc->state = SP_PEN_CONTEXT_POINT; spdc_pen_set_subsequent_point(pc, pt, true); pen_last_paraxial_dir = !pen_last_paraxial_dir; //BSpline - if((pc->spiro || pc->bspline) && ( pc->green_curve->is_empty() || pc->green_curve->last_segment() == NULL )){ - pen_cancel (pc); - ret = TRUE; - } pc->blue_curve->reset(); if(pc->spiro || pc->bspline) bspline_build(pc); //BSpline End ret = TRUE; @@ -1770,48 +1792,22 @@ static void spiro_doEffect(SPCurve * curve) static void bspline(SPPenContext *const pc, bool shift) { - shift?bsplineOff(pc):bsplineOn(pc); + if(!pc->anchor_statusbar) + shift?bsplineOff(pc):bsplineOn(pc); + bspline_build(pc); } -static void bsplineInMotion(SPPenContext *const pc, bool shift){ - SPCurve *tmpCurve = new SPCurve(); - if(pc->green_curve->is_empty() && !pc->sa){ - pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]); - }else if(!pc->green_curve->is_empty()){ - tmpCurve = pc->green_curve->copy(); - }else{ - tmpCurve = pc->sa->curve->copy(); - if(pc->sa->start) - tmpCurve = tmpCurve->create_reverse(); - } - if(!tmpCurve->is_empty() && !pc->red_curve->is_empty()){ - Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); - if(cubic){ - SPCurve * WPower = new SPCurve(); - Geom::D2< Geom::SBasis > SBasisWPower; - WPower->moveto(tmpCurve->last_segment()->finalPoint()); - WPower->lineto(tmpCurve->last_segment()->initialPoint()); - float WP = Geom::nearest_point((*cubic)[2],*WPower->first_segment()); - WPower->reset(); - WPower->moveto(pc->red_curve->last_segment()->initialPoint()); - WPower->lineto(pc->red_curve->last_segment()->finalPoint()); - SBasisWPower = WPower->first_segment()->toSBasis(); - WPower->reset(); - pc->p[1] = SBasisWPower.valueAt(WP); - }else{ - pc->p[1] = pc->p[0]; - } - } - - if(pc->anchor_statusbar && !pc->red_curve->is_empty()){ - if(shift) - bsplineEndAnchorOff(pc); - else - bsplineEndAnchorOn(pc); +static void bsplineOn(SPPenContext *const pc){ + if(!pc->red_curve->is_empty()){ + using Geom::X; + using Geom::Y; + pc->npoints = 5; + pc->p[0] = pc->red_curve->first_segment()->initialPoint(); + pc->p[3] = pc->red_curve->first_segment()->finalPoint(); + pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); + pc->p[2] = Geom::Point(pc->p[2][X] + 0.0625,pc->p[2][Y] + 0.0625); } - - bspline_build(pc); } static void bsplineOff(SPPenContext *const pc) @@ -1821,10 +1817,54 @@ static void bsplineOff(SPPenContext *const pc) pc->p[0] = pc->red_curve->first_segment()->initialPoint(); pc->p[3] = pc->red_curve->first_segment()->finalPoint(); pc->p[2] = pc->p[3]; - pc->p[4] = pc->p[3]; } - if(pc->anchor_statusbar && pc->sa && !pc->sa->curve->is_empty() && pc->red_curve->is_empty()) +} + +static void bsplineStartAnchor(SPPenContext *const pc, bool shift) +{ + if(pc->sa->curve->is_empty()) + return; + + if(shift) bsplineStartAnchorOff(pc); + else + bsplineStartAnchorOn(pc); +} + +static void bsplineStartAnchorOn(SPPenContext *const pc) +{ + using Geom::X; + using Geom::Y; + SPCurve *tmpCurve = new SPCurve(); + tmpCurve = pc->sa->curve->copy(); + if(pc->sa->start) + tmpCurve = tmpCurve->create_reverse(); + Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); + SPCurve *lastSeg = new SPCurve(); + Geom::Point A = tmpCurve->last_segment()->initialPoint(); + Geom::Point D = tmpCurve->last_segment()->finalPoint(); + Geom::Point C = D + (1./3)*(A - D); + C = Geom::Point(C[X] + 0.0625,C[Y] + 0.0625); + if(cubic){ + lastSeg->moveto(A); + lastSeg->curveto((*cubic)[1],C,D); + }else{ + lastSeg->moveto(A); + lastSeg->curveto(A,C,D); + } + if( tmpCurve->get_segment_count() == 1){ + tmpCurve = lastSeg; + }else{ + //we eliminate the last segment + tmpCurve->backspace(); + //and we add it again with the recreation + tmpCurve->append_continuous(lastSeg, 0.0625); + } + if (pc->sa->start) { + tmpCurve = tmpCurve->create_reverse(); + } + pc->sa->curve->reset(); + pc->sa->curve = tmpCurve; } static void bsplineStartAnchorOff(SPPenContext *const pc) @@ -1838,8 +1878,14 @@ static void bsplineStartAnchorOff(SPPenContext *const pc) SPCurve *lastSeg = new SPCurve(); lastSeg->moveto((*cubic)[0]); lastSeg->curveto((*cubic)[1],(*cubic)[3],(*cubic)[3]); - tmpCurve->backspace(); - tmpCurve->append_continuous(lastSeg, 0.0625); + if( tmpCurve->get_segment_count() == 1){ + tmpCurve = lastSeg; + }else{ + //we eliminate the last segment + tmpCurve->backspace(); + //and we add it again with the recreation + tmpCurve->append_continuous(lastSeg, 0.0625); + } if (pc->sa->start) { tmpCurve = tmpCurve->create_reverse(); } @@ -1849,84 +1895,61 @@ static void bsplineStartAnchorOff(SPPenContext *const pc) } -static void bsplineEndAnchorOff(SPPenContext *const pc) -{ - pc->p[2] = pc->p[3]; +static void bsplineMotion(SPPenContext *const pc, bool shift){ + using Geom::X; + using Geom::Y; SPCurve *tmpCurve = new SPCurve(); - SPCurve *lastSeg = new SPCurve(); - if(!pc->sa || pc->sa->curve->is_empty()){ - tmpCurve = pc->green_curve->create_reverse(); - Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); - if(cubic){ - lastSeg->moveto((*cubic)[0]); - lastSeg->curveto((*cubic)[1],(*cubic)[3],(*cubic)[3]); - tmpCurve->backspace(); - tmpCurve->append_continuous(lastSeg, 0.0625); - tmpCurve = tmpCurve->create_reverse(); - pc->green_curve->reset(); - pc->green_curve = tmpCurve; - } + if(shift) + pc->p[2] = pc->p[3]; + else + pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); + pc->p[2] = Geom::Point(pc->p[2][X] + 0.0625,pc->p[2][Y] + 0.0625); + + if(pc->green_curve->is_empty() && !pc->sa){ + pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]); + }else if(!pc->green_curve->is_empty()){ + tmpCurve = pc->green_curve->copy(); }else{ tmpCurve = pc->sa->curve->copy(); - if(!pc->sa->start) + if(pc->sa->start) tmpCurve = tmpCurve->create_reverse(); + } + if(!tmpCurve->is_empty() && !pc->red_curve->is_empty()){ Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); if(cubic){ - lastSeg->moveto((*cubic)[0]); - lastSeg->curveto((*cubic)[1],(*cubic)[3],(*cubic)[3]); - tmpCurve->backspace(); - tmpCurve->append_continuous(lastSeg, 0.0625); - if (!pc->sa->start) { - tmpCurve = tmpCurve->create_reverse(); - } - pc->sa->curve->reset(); - pc->sa->curve = tmpCurve; + SPCurve * WPower = new SPCurve(); + Geom::D2< Geom::SBasis > SBasisWPower; + WPower->moveto(tmpCurve->last_segment()->finalPoint()); + WPower->lineto(tmpCurve->last_segment()->initialPoint()); + float WP = Geom::nearest_point((*cubic)[2],*WPower->first_segment()); + WPower->reset(); + WPower->moveto(pc->red_curve->last_segment()->initialPoint()); + WPower->lineto(pc->red_curve->last_segment()->finalPoint()); + SBasisWPower = WPower->first_segment()->toSBasis(); + WPower->reset(); + pc->p[1] = SBasisWPower.valueAt(WP); + pc->p[1] = Geom::Point(pc->p[1][X] + 0.0625,pc->p[1][Y] + 0.0625); + }else{ + pc->p[1] = pc->p[0]; } } -} -static void bsplineOn(SPPenContext *const pc){ - if(!pc->red_curve->is_empty()){ - pc->npoints = 5; - pc->p[0] = pc->red_curve->first_segment()->initialPoint(); - pc->p[3] = pc->red_curve->first_segment()->finalPoint(); - pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); + if(pc->anchor_statusbar && !pc->red_curve->is_empty()){ + if(shift) + bsplineEndAnchorOff(pc); + else + bsplineEndAnchorOn(pc); } - if(pc->anchor_statusbar && pc->sa && !pc->sa->curve->is_empty() && pc->red_curve->is_empty()) - bsplineStartAnchorOn(pc); -} -static void bsplineStartAnchorOn(SPPenContext *const pc) -{ - SPCurve *tmpCurve = new SPCurve(); - tmpCurve = pc->sa->curve->copy(); - if(pc->sa->start) - tmpCurve = tmpCurve->create_reverse(); - Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); - SPCurve *lastSeg = new SPCurve(); - Geom::Point A = tmpCurve->last_segment()->initialPoint(); - Geom::Point D = tmpCurve->last_segment()->finalPoint(); - Geom::Point C(0,0); - if(cubic){ - C = D + (1./3)*(A - D); - lastSeg->moveto(A); - lastSeg->curveto((*cubic)[1],C,D); - }else{ - lastSeg->moveto(A); - lastSeg->curveto(A,C,D); - } - tmpCurve->backspace(); - tmpCurve->append_continuous(lastSeg, 0.0625); - if (pc->sa->start) { - tmpCurve = tmpCurve->create_reverse(); - } - pc->sa->curve->reset(); - pc->sa->curve = tmpCurve; + bspline_build(pc); } static void bsplineEndAnchorOn(SPPenContext *const pc) { + using Geom::X; + using Geom::Y; pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); + pc->p[2] = Geom::Point(pc->p[2][X] + 0.0625,pc->p[2][Y] + 0.0625); SPCurve *tmpCurve = new SPCurve(); SPCurve *lastSeg = new SPCurve(); Geom::Point C(0,0); @@ -1934,6 +1957,7 @@ static void bsplineEndAnchorOn(SPPenContext *const pc) tmpCurve = pc->green_curve->create_reverse(); Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); C = tmpCurve->last_segment()->finalPoint() + (1./3)*(tmpCurve->last_segment()->initialPoint() - tmpCurve->last_segment()->finalPoint()); + C = Geom::Point(C[X] + 0.0625,C[Y] + 0.0625); if(cubic){ lastSeg->moveto((*cubic)[0]); lastSeg->curveto((*cubic)[1],C,(*cubic)[3]); @@ -1941,8 +1965,14 @@ static void bsplineEndAnchorOn(SPPenContext *const pc) lastSeg->moveto(tmpCurve->last_segment()->initialPoint()); lastSeg->curveto(tmpCurve->last_segment()->initialPoint(),C,tmpCurve->last_segment()->finalPoint()); } - tmpCurve->backspace(); - tmpCurve->append_continuous(lastSeg, 0.0625); + if( tmpCurve->get_segment_count() == 1){ + tmpCurve = lastSeg; + }else{ + //we eliminate the last segment + tmpCurve->backspace(); + //and we add it again with the recreation + tmpCurve->append_continuous(lastSeg, 0.0625); + } tmpCurve = tmpCurve->create_reverse(); pc->green_curve->reset(); pc->green_curve = tmpCurve; @@ -1952,6 +1982,7 @@ static void bsplineEndAnchorOn(SPPenContext *const pc) tmpCurve = tmpCurve->create_reverse(); Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); C = tmpCurve->last_segment()->finalPoint() + (1./3)*(tmpCurve->last_segment()->initialPoint() - tmpCurve->last_segment()->finalPoint()); + C = Geom::Point(C[X] + 0.0625,C[Y] + 0.0625); if(cubic){ lastSeg->moveto((*cubic)[0]); lastSeg->curveto((*cubic)[1],C,(*cubic)[3]); @@ -1959,8 +1990,14 @@ static void bsplineEndAnchorOn(SPPenContext *const pc) lastSeg->moveto(tmpCurve->last_segment()->initialPoint()); lastSeg->curveto(tmpCurve->last_segment()->initialPoint(),C,tmpCurve->last_segment()->finalPoint()); } - tmpCurve->backspace(); - tmpCurve->append_continuous(lastSeg, 0.0625); + if( tmpCurve->get_segment_count() == 1){ + tmpCurve = lastSeg; + }else{ + //we eliminate the last segment + tmpCurve->backspace(); + //and we add it again with the recreation + tmpCurve->append_continuous(lastSeg, 0.0625); + } if (!pc->sa->start) { tmpCurve = tmpCurve->create_reverse(); } @@ -1968,6 +2005,55 @@ static void bsplineEndAnchorOn(SPPenContext *const pc) pc->sa->curve = tmpCurve; } } + +static void bsplineEndAnchorOff(SPPenContext *const pc) +{ + pc->p[2] = pc->p[3]; + SPCurve *tmpCurve = new SPCurve(); + SPCurve *lastSeg = new SPCurve(); + if(!pc->sa || pc->sa->curve->is_empty()){ + tmpCurve = pc->green_curve->create_reverse(); + Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); + if(cubic){ + lastSeg->moveto((*cubic)[0]); + lastSeg->curveto((*cubic)[1],(*cubic)[3],(*cubic)[3]); + if( tmpCurve->get_segment_count() == 1){ + tmpCurve = lastSeg; + }else{ + //we eliminate the last segment + tmpCurve->backspace(); + //and we add it again with the recreation + tmpCurve->append_continuous(lastSeg, 0.0625); + } + tmpCurve = tmpCurve->create_reverse(); + pc->green_curve->reset(); + pc->green_curve = tmpCurve; + } + }else{ + tmpCurve = pc->sa->curve->copy(); + if(!pc->sa->start) + tmpCurve = tmpCurve->create_reverse(); + Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); + if(cubic){ + lastSeg->moveto((*cubic)[0]); + lastSeg->curveto((*cubic)[1],(*cubic)[3],(*cubic)[3]); + if( tmpCurve->get_segment_count() == 1){ + tmpCurve = lastSeg; + }else{ + //we eliminate the last segment + tmpCurve->backspace(); + //and we add it again with the recreation + tmpCurve->append_continuous(lastSeg, 0.0625); + } + if (!pc->sa->start) { + tmpCurve = tmpCurve->create_reverse(); + } + pc->sa->curve->reset(); + pc->sa->curve = tmpCurve; + } + } +} + /* //Unimos todas las curvas en juego y llamamos a la función doEffect. static void bspline(SPPenContext *const pc, bool Shift) @@ -2118,7 +2204,7 @@ static void bspline_build(SPPenContext *const pc) curve = curve->create_reverse(); } } - //We add also the green curve + if (!pc->green_curve->is_empty()) curve->append_continuous(pc->green_curve, 0.0625); @@ -2126,16 +2212,12 @@ static void bspline_build(SPPenContext *const pc) if (!pc->red_curve->is_empty()){ pc->red_curve->reset(); pc->red_curve->moveto(pc->p[0]); - if(pc->npoints == 2){ - pc->red_curve->lineto(pc->p[1]); - }else{ - pc->red_curve->curveto(pc->p[1],pc->p[2],pc->p[3]); - } + pc->red_curve->curveto(pc->p[1],pc->p[2],pc->p[3]); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), pc->red_curve); curve->append_continuous(pc->red_curve, 0.0625); } - if(curve->get_segment_count() > 1 ){ + if(!curve->is_empty()){ //cerramos la curva si estan cerca los puntos finales de la curva spiro if(Geom::are_near(curve->first_path()->initialPoint(), curve->last_path()->finalPoint())){ curve->closepath_current(); @@ -2167,6 +2249,8 @@ static void bspline_doEffect(SPCurve * curve) { if(curve->get_segment_count() < 2) return; + using Geom::X; + using Geom::Y; // Make copy of old path as it is changed during processing Geom::PathVector const original_pathv = curve->get_pathvector(); curve->reset(); @@ -2227,29 +2311,11 @@ static void bspline_doEffect(SPCurve * curve) //en posible caso de que se cierre con una linea recta creando un nodo BSPline if (path_it->closed()) { - // if the path is closed, maybe we have to stop a bit earlier because the closing line segment has zerolength. - const Geom::Curve &closingline = path_it->back_closed(); // the closing line segment is always of type Geom::LineSegment. - if (are_near(closingline.initialPoint(), closingline.finalPoint())) { - // closingline.isDegenerate() did not work, because it only checks for *exact* zero length, which goes wrong for relative coordinates and rounding errors... - // the closing line segment has zero-length. So stop before that one! - curve_endit = path_it->end_open(); - } + //Calculamos el nodo de inicio BSpline SBasisIn = in->first_segment()->toSBasis(); SBasisEnd = end->first_segment()->toSBasis(); - cubic = dynamic_cast(&*curve_it1); - if(cubic){ - pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[1],*in->first_segment())); - }else{ - pointAt1 = in->first_segment()->initialPoint(); - } - cubic = dynamic_cast(&*curve_end); - if(cubic){ - endPointAt2 = SBasisEnd.valueAt(Geom::nearest_point((*cubic)[2],*end->first_segment())); - }else{ - endPointAt2 = end->first_segment()->finalPoint(); - } - lineHelper->moveto(pointAt1); - lineHelper->lineto(endPointAt2); + lineHelper->moveto(SBasisIn.valueAt(0.3334)); + lineHelper->lineto(SBasisEnd.valueAt(0.6667)); SBasisHelper = lineHelper->first_segment()->toSBasis(); lineHelper->reset(); //Guardamos el principio de la curva @@ -2267,32 +2333,17 @@ static void bspline_doEffect(SPCurve * curve) { //previousPointAt3 = pointAt3; //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida - cubic = dynamic_cast(&*curve_it1); - if(cubic){ - SBasisIn = in->first_segment()->toSBasis(); - pointAt0 = (*cubic)[0]; - pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[1],*in->first_segment())); - pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[2],*in->first_segment())); - pointAt3 = (*cubic)[3]; - }else{ - pointAt0 = in->first_segment()->initialPoint(); - pointAt1 = in->first_segment()->initialPoint(); - pointAt2 = in->first_segment()->finalPoint(); - pointAt3 = in->first_segment()->finalPoint(); - } + SBasisIn = in->first_segment()->toSBasis(); + SBasisOut = out->first_segment()->toSBasis(); + pointAt0 = SBasisIn.valueAt(0); + pointAt1 = SBasisIn.valueAt(0.3334); + pointAt2 = SBasisIn.valueAt(0.6667); + pointAt3 = SBasisIn.valueAt(1); //Y hacemos lo propio con el path de salida //nextPointAt0 = curveOut.valueAt(0); - cubic = dynamic_cast(&*curve_it2); - if(cubic){ - SBasisOut = out->first_segment()->toSBasis(); - nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[1],*out->first_segment())); - nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[2],*out->first_segment()));; - nextPointAt3 = (*cubic)[3]; - }else{ - nextPointAt1 = out->first_segment()->initialPoint(); - nextPointAt2 = out->first_segment()->finalPoint(); - nextPointAt3 = out->first_segment()->finalPoint(); - } + nextPointAt1 = SBasisOut.valueAt(0.3334); + nextPointAt2 = SBasisOut.valueAt(0.6667);; + nextPointAt3 = SBasisOut.valueAt(1); //La curva BSpline se forma calculando el centro del segmanto de unión //de el punto situado en las 2/3 partes de el segmento de entrada //con el punto situado en la posición 1/3 del segmento de salida @@ -2356,7 +2407,6 @@ static void bspline_doEffect(SPCurve * curve) //Todo: remove? //delete SBasisHelper; } - //BSpline end static void spdc_pen_set_subsequent_point(SPPenContext *const pc, Geom::Point const p, bool statusbar, guint status) diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index fef904006..4cac0e543 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -138,12 +138,14 @@ void Handle::move(Geom::Point const &new_pos) //BSpline bool isBSpline = false; double pos = 0; - Handle *h = this; + Handle *h = NULL; + Handle *h2 = NULL; if(_pm().isBSpline()){ isBSpline = true; - _parent->_selection.insert(_parent); - //BSpline End + if(!_parent->selected()) + _parent->_selection.insert(_parent); } + //BSpline End if (Geom::are_near(new_pos, _parent->position())) { // The handle becomes degenerate. @@ -177,12 +179,11 @@ void Handle::move(Geom::Point const &new_pos) setPosition(new_pos); //BSpline if(isBSpline){ + h = this; setPosition(_pm().BSplineHandleReposition(h)); pos = _pm().BSplineHandlePosition(h); - other->setPosition(_pm().BSplineHandleReposition(other,pos)); - if(pos == 0){ - _parent->setPosition(h->position()); - } + h2 = this->other(); + this->other()->setPosition(_pm().BSplineHandleReposition(h2,pos)); } //BSpline End return; @@ -217,12 +218,11 @@ void Handle::move(Geom::Point const &new_pos) setPosition(new_pos); //BSpline if(isBSpline){ + h = this; setPosition(_pm().BSplineHandleReposition(h)); pos = _pm().BSplineHandlePosition(h); - other->setPosition(_pm().BSplineHandleReposition(other,pos)); - if(pos == 0){ - _parent->setPosition(h->position()); - } + h2 = this->other(); + this->other()->setPosition(_pm().BSplineHandleReposition(h2,pos)); } //BSpline End } @@ -588,21 +588,25 @@ void Node::move(Geom::Point const &new_pos) if(prevNode) prevPos = _pm().BSplineHandlePosition(prevNode->front()); pos = _pm().BSplineHandlePosition(n->front()); + if(pos == 0) + pos = _pm().BSplineHandlePosition(n->back()); if(nextNode) nextPos = _pm().BSplineHandlePosition(nextNode->back()); } //BSpline End setPosition(new_pos); //BSpline - if(prevNode){ + if(prevNode) prevNode->front()->setPosition(_pm().BSplineHandleReposition(prevNode->front(),prevPos)); - } - if(nextNode){ + if(nextNode) nextNode->back()->setPosition(_pm().BSplineHandleReposition(nextNode->back(),nextPos)); - } //BSpline End _front.setPosition(_front.position() + delta); _back.setPosition(_back.position() + delta); + //BSpline End + // if the node has a smooth handle after a line segment, it should be kept colinear + // with the segment + _fixNeighbors(old_pos, new_pos); //BSpline if(_pm().isBSpline()){ Handle* front = &_front; @@ -610,10 +614,6 @@ void Node::move(Geom::Point const &new_pos) _front.setPosition(_pm().BSplineHandleReposition(front,pos)); _back.setPosition(_pm().BSplineHandleReposition(back,pos)); } - //BSpline End - // if the node has a smooth handle after a line segment, it should be kept colinear - // with the segment - _fixNeighbors(old_pos, new_pos); } void Node::transform(Geom::Affine const &m) diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index ecb8abcf4..7c23ee153 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1182,15 +1182,20 @@ bool PathManipulator::isBSpline(){ } return false; } + double PathManipulator::BSplineHandlePosition(Handle *h){ + using Geom::X; + using Geom::Y; double pos = 0; Node *n = h->parent(); SPCurve *lineInsideNodes = new SPCurve(); Node * nextNode = n->nodeToward(h); - if(nextNode){ + Geom::Point positionH = h->position(); + positionH = Geom::Point(positionH[X] - 0.0625,positionH[Y] - 0.0625); + if(nextNode && n->position() != h->position()){ lineInsideNodes->moveto(n->position()); lineInsideNodes->lineto(nextNode->position()); - pos = Geom::nearest_point(h->position(),*lineInsideNodes->first_segment()); + pos = Geom::nearest_point(positionH,*lineInsideNodes->first_segment()); } return pos; } @@ -1201,18 +1206,23 @@ Geom::Point PathManipulator::BSplineHandleReposition(Handle *h){ } Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){ + using Geom::X; + using Geom::Y; + Geom::Point ret(0,0); Node *n = h->parent(); Geom::D2< Geom::SBasis > SBasisInsideNodes; SPCurve *lineInsideNodes = new SPCurve(); Node * nextNode = n->nodeToward(h); - if(nextNode){ + if(nextNode && pos != 0){ lineInsideNodes->moveto(n->position()); lineInsideNodes->lineto(nextNode->position()); SBasisInsideNodes = lineInsideNodes->first_segment()->toSBasis(); + ret = SBasisInsideNodes.valueAt(pos); + ret = Geom::Point(ret[X] + 0.0625,ret[Y] + 0.0625); }else{ - return n->position(); + ret = n->position(); } - return SBasisInsideNodes.valueAt(pos); + return ret; } /** Construct the geometric representation of nodes and handles, update the outline @@ -1229,26 +1239,8 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) continue; } NodeList::iterator prev = subpath->begin(); - //BSpline - double pos =0; - bool isBSpline = false; - if(this->isBSpline()) - isBSpline = true; - if(isBSpline){ - pos = BSplineHandlePosition(prev.ptr()->front()); - prev->front()->setPosition(BSplineHandleReposition(prev->front(),pos)); - } - //BSpline End builder.moveTo(prev->position()); for (NodeList::iterator i = ++subpath->begin(); i != subpath->end(); ++i) { - //BSpline - if (isBSpline) { - pos = BSplineHandlePosition(i->back()); - i->front()->setPosition(BSplineHandleReposition(i->front(),pos)); - i->back()->setPosition(BSplineHandleReposition(i->back(),pos)); - } - - //BSpline End build_segment(builder, prev.ptr(), i.ptr()); prev = i; } @@ -1256,13 +1248,6 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) if (subpath->closed()) { // Here we link the last and first node if the path is closed. // If the last segment is Bezier, we add it. - //BSpline - if (isBSpline) { - pos = BSplineHandlePosition(prev.next()->back()); - subpath->begin()->front()->setPosition(BSplineHandleReposition(subpath->begin()->front(),pos)); - prev.next()->back()->setPosition(BSplineHandleReposition(prev.next()->back(),pos)); - } - //BSpline End if (!prev->front()->isDegenerate() || !subpath->begin()->back()->isDegenerate()) { build_segment(builder, prev.ptr(), subpath->begin().ptr()); } -- cgit v1.2.3 From 9c35b88816e60d7fe413a76b48d1764e45157612 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 1 Mar 2013 02:36:23 +0100 Subject: BSpline refactor (bzr r11950.1.41) --- src/live_effects/lpe-bspline.cpp | 118 +++++++++++++++------------------ src/pen-context.cpp | 140 +++++++++++++++++++++------------------ 2 files changed, 128 insertions(+), 130 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 36caf73c5..d046ad683 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -33,41 +33,11 @@ void LPEBSpline::doEffect(SPCurve * curve) { if(curve->get_segment_count() < 2) - return; - using Geom::X; - using Geom::Y; + return; // Make copy of old path as it is changed during processing Geom::PathVector const original_pathv = curve->get_pathvector(); curve->reset(); - //Sbasis - Geom::D2< Geom::SBasis > SBasisIn; - Geom::D2< Geom::SBasis > SBasisOut; - Geom::D2< Geom::SBasis > SBasisEnd; - Geom::D2< Geom::SBasis > SBasisHelper; - //curves - SPCurve * in = new SPCurve(); - SPCurve * out = new SPCurve(); - SPCurve * end = new SPCurve(); - //Curvas temporales - SPCurve *lineHelper = new SPCurve(); - SPCurve *curveHelper = new SPCurve(); - SPCurve *nCurve = new SPCurve(); - //Puntos a usar. Ponemos todos los posibles para hacer más inteligible el código - Geom::Point startNode(0,0); - Geom::Point previousNode(0,0); - Geom::Point node(0,0); - //Geom::Point previousPointAt3(0,0); - Geom::Point pointAt0(0,0); - Geom::Point pointAt1(0,0); - Geom::Point pointAt2(0,0); - Geom::Point pointAt3(0,0); - //Geom::Point nextPointAt0(0,0); - Geom::Point nextPointAt1(0,0); - Geom::Point nextPointAt2(0,0); - Geom::Point nextPointAt3(0,0); - - Geom::Point endPointAt2(0,0); - Geom::CubicBezier const *cubic; + //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { //Si está vacío... @@ -77,43 +47,60 @@ LPEBSpline::doEffect(SPCurve * curve) Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve - Geom::Path::const_iterator curve_end = path_it->end_open(); // end curve Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop - //Creamos las lineas rectas que unen todos los puntos del trazado y donde se calcularán //los puntos clave para los manejadores. //Esto hace que la curva BSpline no pierda su condición aunque se trasladen //dichos manejadores + SPCurve * in = new SPCurve(); in->moveto(curve_it1->initialPoint()); in->lineto(curve_it1->finalPoint()); + SPCurve * out = new SPCurve(); out->moveto(curve_it2->initialPoint()); out->lineto(curve_it2->finalPoint()); - //este no cambia. - end->moveto(curve_end->initialPoint()); - end->lineto(curve_end->finalPoint()); + SPCurve *nCurve = new SPCurve(); + Geom::Point startNode(0,0); + Geom::Point previousNode(0,0); + Geom::Point node(0,0); + Geom::Point pointAt1(0,0); + Geom::Point pointAt2(0,0); + Geom::Point nextPointAt1(0,0); + Geom::Point nextPointAt2(0,0); + Geom::Point nextPointAt3(0,0); + Geom::CubicBezier const *cubic = NULL; //Si la curva está cerrada calculamos el punto donde //deveria estar el nodo BSpline de cierre/inicio de la curva //en posible caso de que se cierre con una linea recta creando un nodo BSPline if (path_it->closed()) { - SBasisIn = in->first_segment()->toSBasis(); - SBasisEnd = end->first_segment()->toSBasis(); + //Calculamos el nodo de inicio BSpline + const Geom::Curve &closingline = path_it->back_closed(); + if (are_near(closingline.initialPoint(), closingline.finalPoint())) { + curve_endit = path_it->end_open(); + } + SPCurve * end = new SPCurve(); + end->moveto(curve_endit->initialPoint()); + end->lineto(curve_endit->finalPoint()); + Geom::D2< Geom::SBasis > SBasisIn = in->first_segment()->toSBasis(); + Geom::D2< Geom::SBasis > SBasisEnd = end->first_segment()->toSBasis(); + end->reset(); + delete end; + SPCurve *lineHelper = new SPCurve(); cubic = dynamic_cast(&*curve_it1); if(cubic){ - pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[1],*in->first_segment())); + lineHelper->moveto(SBasisIn.valueAt(Geom::nearest_point((*cubic)[1],*in->first_segment()))); }else{ - pointAt1 = in->first_segment()->initialPoint(); + lineHelper->moveto(in->first_segment()->initialPoint()); } - cubic = dynamic_cast(&*curve_end); + cubic = dynamic_cast(&*curve_endit); if(cubic){ - endPointAt2 = SBasisEnd.valueAt(Geom::nearest_point((*cubic)[2],*end->first_segment())); + lineHelper->lineto(SBasisEnd.valueAt(Geom::nearest_point((*cubic)[2],*end->first_segment()))); }else{ - endPointAt2 = end->first_segment()->finalPoint(); + lineHelper->lineto(end->first_segment()->finalPoint()); } - lineHelper->moveto(pointAt1); - lineHelper->lineto(endPointAt2); - SBasisHelper = lineHelper->first_segment()->toSBasis(); + Geom::D2< Geom::SBasis > SBasisHelper = lineHelper->first_segment()->toSBasis(); lineHelper->reset(); + delete lineHelper; //Guardamos el principio de la curva startNode = SBasisHelper.valueAt(0.5); //Definimos el punto de inicio original de la curva resultante @@ -131,22 +118,18 @@ LPEBSpline::doEffect(SPCurve * curve) //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida cubic = dynamic_cast(&*curve_it1); if(cubic){ - SBasisIn = in->first_segment()->toSBasis(); - pointAt0 = (*cubic)[0]; + Geom::D2< Geom::SBasis > SBasisIn = in->first_segment()->toSBasis(); pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[1],*in->first_segment())); pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[2],*in->first_segment())); - pointAt3 = (*cubic)[3]; }else{ - pointAt0 = in->first_segment()->initialPoint(); pointAt1 = in->first_segment()->initialPoint(); pointAt2 = in->first_segment()->finalPoint(); - pointAt3 = in->first_segment()->finalPoint(); } //Y hacemos lo propio con el path de salida //nextPointAt0 = curveOut.valueAt(0); cubic = dynamic_cast(&*curve_it2); if(cubic){ - SBasisOut = out->first_segment()->toSBasis(); + Geom::D2< Geom::SBasis > SBasisOut = out->first_segment()->toSBasis(); nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[1],*out->first_segment())); nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[2],*out->first_segment()));; nextPointAt3 = (*cubic)[3]; @@ -160,33 +143,41 @@ LPEBSpline::doEffect(SPCurve * curve) //con el punto situado en la posición 1/3 del segmento de salida //Estos dos puntos ademas estan posicionados en el lugas correspondiente de //los manejadores de la curva + SPCurve *lineHelper = new SPCurve(); lineHelper->moveto(pointAt2); lineHelper->lineto(nextPointAt1); - SBasisHelper = lineHelper->first_segment()->toSBasis(); + Geom::D2< Geom::SBasis > SBasisHelper = lineHelper->first_segment()->toSBasis(); lineHelper->reset(); + delete lineHelper; //almacenamos el punto del anterior bucle -o el de cierre- que nos hara de principio de curva previousNode = node; //Y este hará de final de curva node = SBasisHelper.valueAt(0.5); + SPCurve *curveHelper = new SPCurve(); curveHelper->moveto(previousNode); curveHelper->curveto(pointAt1, pointAt2, node); //añadimos la curva generada a la curva pricipal nCurve->append_continuous(curveHelper, 0.0625); curveHelper->reset(); + delete curveHelper; //aumentamos los valores para el siguiente paso en el bucle ++curve_it1; ++curve_it2; - //Damos valor a el objeto para el path de entrada y el de salida in->reset(); + delete in; + SPCurve * in = new SPCurve(); in->moveto(curve_it1->initialPoint()); in->lineto(curve_it1->finalPoint()); out->reset(); - if(curve_it1 != curve_end){ + delete out; + if(curve_it1 != curve_endit){ + SPCurve * out = new SPCurve(); out->moveto(curve_it2->initialPoint()); out->lineto(curve_it2->finalPoint()); } } //Aberiguamos la ultima parte de la curva correspondiente al último segmento + SPCurve *curveHelper = new SPCurve(); curveHelper->moveto(node); //Si está cerrada la curva, la cerramos sobre el valor guardado previamente //Si no finalizamos en el punto final @@ -197,26 +188,21 @@ LPEBSpline::doEffect(SPCurve * curve) } //añadimos este último segmento nCurve->append_continuous(curveHelper, 0.0625); + curveHelper->reset(); + delete curveHelper; //y cerramos la curva if (path_it->closed()) { nCurve->closepath_current(); } curve->append(nCurve,false); nCurve->reset(); + delete nCurve; //Limpiamos in->reset(); out->reset(); - end->reset(); - lineHelper->reset(); - curveHelper->reset(); + delete in; + delete out; } - delete in; - delete out; - delete end; - delete lineHelper; - delete curveHelper; - //Todo: remove? - //delete SBasisHelper; } }; //namespace LivePathEffect diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 6910e903b..a505f8de7 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -2248,41 +2248,11 @@ static void bspline_build(SPPenContext *const pc) static void bspline_doEffect(SPCurve * curve) { if(curve->get_segment_count() < 2) - return; - using Geom::X; - using Geom::Y; + return; // Make copy of old path as it is changed during processing Geom::PathVector const original_pathv = curve->get_pathvector(); curve->reset(); - //Sbasis - Geom::D2< Geom::SBasis > SBasisIn; - Geom::D2< Geom::SBasis > SBasisOut; - Geom::D2< Geom::SBasis > SBasisEnd; - Geom::D2< Geom::SBasis > SBasisHelper; - //curves - SPCurve * in = new SPCurve(); - SPCurve * out = new SPCurve(); - SPCurve * end = new SPCurve(); - //Curvas temporales - SPCurve *lineHelper = new SPCurve(); - SPCurve *curveHelper = new SPCurve(); - SPCurve *nCurve = new SPCurve(); - //Puntos a usar. Ponemos todos los posibles para hacer más inteligible el código - Geom::Point startNode(0,0); - Geom::Point previousNode(0,0); - Geom::Point node(0,0); - //Geom::Point previousPointAt3(0,0); - Geom::Point pointAt0(0,0); - Geom::Point pointAt1(0,0); - Geom::Point pointAt2(0,0); - Geom::Point pointAt3(0,0); - //Geom::Point nextPointAt0(0,0); - Geom::Point nextPointAt1(0,0); - Geom::Point nextPointAt2(0,0); - Geom::Point nextPointAt3(0,0); - - Geom::Point endPointAt2(0,0); - Geom::CubicBezier const *cubic; + //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { //Si está vacío... @@ -2292,32 +2262,60 @@ static void bspline_doEffect(SPCurve * curve) Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve - Geom::Path::const_iterator curve_end = path_it->end_open(); // end curve Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop - //Creamos las lineas rectas que unen todos los puntos del trazado y donde se calcularán //los puntos clave para los manejadores. //Esto hace que la curva BSpline no pierda su condición aunque se trasladen //dichos manejadores + SPCurve * in = new SPCurve(); in->moveto(curve_it1->initialPoint()); in->lineto(curve_it1->finalPoint()); + SPCurve * out = new SPCurve(); out->moveto(curve_it2->initialPoint()); out->lineto(curve_it2->finalPoint()); - //este no cambia. - end->moveto(curve_end->initialPoint()); - end->lineto(curve_end->finalPoint()); + SPCurve *nCurve = new SPCurve(); + Geom::Point startNode(0,0); + Geom::Point previousNode(0,0); + Geom::Point node(0,0); + Geom::Point pointAt1(0,0); + Geom::Point pointAt2(0,0); + Geom::Point nextPointAt1(0,0); + Geom::Point nextPointAt2(0,0); + Geom::Point nextPointAt3(0,0); + Geom::CubicBezier const *cubic = NULL; //Si la curva está cerrada calculamos el punto donde //deveria estar el nodo BSpline de cierre/inicio de la curva //en posible caso de que se cierre con una linea recta creando un nodo BSPline if (path_it->closed()) { //Calculamos el nodo de inicio BSpline - SBasisIn = in->first_segment()->toSBasis(); - SBasisEnd = end->first_segment()->toSBasis(); - lineHelper->moveto(SBasisIn.valueAt(0.3334)); - lineHelper->lineto(SBasisEnd.valueAt(0.6667)); - SBasisHelper = lineHelper->first_segment()->toSBasis(); + const Geom::Curve &closingline = path_it->back_closed(); + if (are_near(closingline.initialPoint(), closingline.finalPoint())) { + curve_endit = path_it->end_open(); + } + SPCurve * end = new SPCurve(); + end->moveto(curve_endit->initialPoint()); + end->lineto(curve_endit->finalPoint()); + Geom::D2< Geom::SBasis > SBasisIn = in->first_segment()->toSBasis(); + Geom::D2< Geom::SBasis > SBasisEnd = end->first_segment()->toSBasis(); + end->reset(); + delete end; + SPCurve *lineHelper = new SPCurve(); + cubic = dynamic_cast(&*curve_it1); + if(cubic){ + lineHelper->moveto(SBasisIn.valueAt(Geom::nearest_point((*cubic)[1],*in->first_segment()))); + }else{ + lineHelper->moveto(in->first_segment()->initialPoint()); + } + cubic = dynamic_cast(&*curve_endit); + if(cubic){ + lineHelper->lineto(SBasisEnd.valueAt(Geom::nearest_point((*cubic)[2],*end->first_segment()))); + }else{ + lineHelper->lineto(end->first_segment()->finalPoint()); + } + Geom::D2< Geom::SBasis > SBasisHelper = lineHelper->first_segment()->toSBasis(); lineHelper->reset(); + delete lineHelper; //Guardamos el principio de la curva startNode = SBasisHelper.valueAt(0.5); //Definimos el punto de inicio original de la curva resultante @@ -2333,49 +2331,68 @@ static void bspline_doEffect(SPCurve * curve) { //previousPointAt3 = pointAt3; //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida - SBasisIn = in->first_segment()->toSBasis(); - SBasisOut = out->first_segment()->toSBasis(); - pointAt0 = SBasisIn.valueAt(0); - pointAt1 = SBasisIn.valueAt(0.3334); - pointAt2 = SBasisIn.valueAt(0.6667); - pointAt3 = SBasisIn.valueAt(1); + cubic = dynamic_cast(&*curve_it1); + if(cubic){ + Geom::D2< Geom::SBasis > SBasisIn = in->first_segment()->toSBasis(); + pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[1],*in->first_segment())); + pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[2],*in->first_segment())); + }else{ + pointAt1 = in->first_segment()->initialPoint(); + pointAt2 = in->first_segment()->finalPoint(); + } //Y hacemos lo propio con el path de salida //nextPointAt0 = curveOut.valueAt(0); - nextPointAt1 = SBasisOut.valueAt(0.3334); - nextPointAt2 = SBasisOut.valueAt(0.6667);; - nextPointAt3 = SBasisOut.valueAt(1); + cubic = dynamic_cast(&*curve_it2); + if(cubic){ + Geom::D2< Geom::SBasis > SBasisOut = out->first_segment()->toSBasis(); + nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[1],*out->first_segment())); + nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[2],*out->first_segment()));; + nextPointAt3 = (*cubic)[3]; + }else{ + nextPointAt1 = out->first_segment()->initialPoint(); + nextPointAt2 = out->first_segment()->finalPoint(); + nextPointAt3 = out->first_segment()->finalPoint(); + } //La curva BSpline se forma calculando el centro del segmanto de unión //de el punto situado en las 2/3 partes de el segmento de entrada //con el punto situado en la posición 1/3 del segmento de salida //Estos dos puntos ademas estan posicionados en el lugas correspondiente de //los manejadores de la curva + SPCurve *lineHelper = new SPCurve(); lineHelper->moveto(pointAt2); lineHelper->lineto(nextPointAt1); - SBasisHelper = lineHelper->first_segment()->toSBasis(); + Geom::D2< Geom::SBasis > SBasisHelper = lineHelper->first_segment()->toSBasis(); lineHelper->reset(); + delete lineHelper; //almacenamos el punto del anterior bucle -o el de cierre- que nos hara de principio de curva previousNode = node; //Y este hará de final de curva node = SBasisHelper.valueAt(0.5); + SPCurve *curveHelper = new SPCurve(); curveHelper->moveto(previousNode); curveHelper->curveto(pointAt1, pointAt2, node); //añadimos la curva generada a la curva pricipal nCurve->append_continuous(curveHelper, 0.0625); curveHelper->reset(); + delete curveHelper; //aumentamos los valores para el siguiente paso en el bucle ++curve_it1; ++curve_it2; - //Damos valor a el objeto para el path de entrada y el de salida in->reset(); + delete in; + SPCurve * in = new SPCurve(); in->moveto(curve_it1->initialPoint()); in->lineto(curve_it1->finalPoint()); out->reset(); - if(curve_it1 != curve_end){ + delete out; + if(curve_it1 != curve_endit){ + SPCurve * out = new SPCurve(); out->moveto(curve_it2->initialPoint()); out->lineto(curve_it2->finalPoint()); } } //Aberiguamos la ultima parte de la curva correspondiente al último segmento + SPCurve *curveHelper = new SPCurve(); curveHelper->moveto(node); //Si está cerrada la curva, la cerramos sobre el valor guardado previamente //Si no finalizamos en el punto final @@ -2386,26 +2403,21 @@ static void bspline_doEffect(SPCurve * curve) } //añadimos este último segmento nCurve->append_continuous(curveHelper, 0.0625); + curveHelper->reset(); + delete curveHelper; //y cerramos la curva if (path_it->closed()) { nCurve->closepath_current(); } curve->append(nCurve,false); nCurve->reset(); + delete nCurve; //Limpiamos in->reset(); out->reset(); - end->reset(); - lineHelper->reset(); - curveHelper->reset(); + delete in; + delete out; } - delete in; - delete out; - delete end; - delete lineHelper; - delete curveHelper; - //Todo: remove? - //delete SBasisHelper; } //BSpline end -- cgit v1.2.3 From 558d770276900cf82341f00970609c0663237130 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 3 Mar 2013 23:19:39 +0100 Subject: Fix sintax (bzr r11950.1.43) --- src/pen-context.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 0af9570c1..e781a048f 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -1708,7 +1708,7 @@ static void spiroEndAnchorOn(SPPenContext *const pc) if(!pc->sa || pc->sa->curve->is_empty()){ tmpCurve = pc->green_curve->create_reverse(); Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); - C = tmpCurve->last_segment()->finalPoint() + + (Geom::Point)(tmpCurve->last_segment()->finalPoint() - pc->p[2]); + C = tmpCurve->last_segment()->finalPoint() + (Geom::Point)(tmpCurve->last_segment()->finalPoint() - pc->p[2]); if(cubic){ lastSeg->moveto((*cubic)[0]); lastSeg->curveto((*cubic)[1],C,(*cubic)[3]); @@ -1732,7 +1732,7 @@ static void spiroEndAnchorOn(SPPenContext *const pc) if(!pc->sa->start) tmpCurve = tmpCurve->create_reverse(); Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); - C = tmpCurve->last_segment()->finalPoint() + + (Geom::Point)(tmpCurve->last_segment()->finalPoint() - pc->p[2]); + C = tmpCurve->last_segment()->finalPoint() + (Geom::Point)(tmpCurve->last_segment()->finalPoint() - pc->p[2]); if(cubic){ lastSeg->moveto((*cubic)[0]); lastSeg->curveto((*cubic)[1],C,(*cubic)[3]); -- cgit v1.2.3 From 93394bdda7e0c876eafe9847a01c6d91e0dc0f7a Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 5 Mar 2013 22:51:31 +0100 Subject: BPower for testing. (bzr r11950.1.45) --- src/pen-context.cpp | 216 ++++++++++++++++++++++----------------------------- src/ui/tool/node.cpp | 20 +++-- 2 files changed, 107 insertions(+), 129 deletions(-) (limited to 'src') diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 26f800328..6232c5e59 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -1055,69 +1055,51 @@ static void pen_lastpoint_tocurve (SPPenContext *const pc) return; //BSpline Geom::CubicBezier const * cubic; - if(!pc->bspline) - pc->p[1] = pc->p[0]; + pc->p[1] = pc->red_curve->last_segment()->initialPoint() + (1./3)* (Geom::Point)(pc->red_curve->last_segment()->finalPoint() - pc->red_curve->last_segment()->initialPoint()); //Para formar una curva necesitamos un nodo symm en el "lastpoint" //de esta manera modificamos el final de la "curva_verde" para que sea symm con el pricipio de la "red_curve" - if(pc->spiro){ - Geom::Point A(0,0); - Geom::Point B(0,0); - Geom::Point C(0,0); - Geom::Point D(0,0); - SPCurve * previous = new SPCurve(); - cubic = dynamic_cast( pc->green_curve->last_segment() ); - //We obtain the last segment 4 points in the previous curve - if ( cubic ){ - A = (*cubic)[0]; - B = (*cubic)[1]; - C = pc->p[0] + (Geom::Point)(pc->p[0] - pc->p[1]); - D = (*cubic)[3]; - }else{ - A = pc->green_curve->last_segment()->initialPoint(); - B = pc->green_curve->last_segment()->initialPoint(); - C = pc->p[0] + (Geom::Point)(pc->p[0] - pc->p[1]); - D = pc->green_curve->last_segment()->finalPoint(); + if(pc->spiro||pc->bspline){ + if(!pc->green_curve->is_empty()){ + Geom::Point A(0,0); + Geom::Point B(0,0); + Geom::Point C(0,0); + Geom::Point D(0,0); + SPCurve * previous = new SPCurve(); + cubic = dynamic_cast( pc->green_curve->last_segment() ); + //We obtain the last segment 4 points in the previous curve + if ( cubic ){ + A = (*cubic)[0]; + B = (*cubic)[1]; + if(pc->spiro){ + C = pc->p[0] + (Geom::Point)(pc->p[0] - pc->p[1]); + }else + C = pc->green_curve->last_segment()->finalPoint() + (1./3)* (Geom::Point)(pc->green_curve->last_segment()->initialPoint() - pc->green_curve->last_segment()->finalPoint()); + D = (*cubic)[3]; + }else{ + A = pc->green_curve->last_segment()->initialPoint(); + B = pc->green_curve->last_segment()->initialPoint(); + if(pc->spiro) + C = pc->p[0] + (Geom::Point)(pc->p[0] - pc->p[1]); + else + C = pc->green_curve->last_segment()->finalPoint() + (1./3)* (Geom::Point)(pc->green_curve->last_segment()->initialPoint() - pc->green_curve->last_segment()->finalPoint()); + D = pc->green_curve->last_segment()->finalPoint(); + } + previous->moveto(A); + previous->curveto(B, C, D); + if( pc->green_curve->get_segment_count() == 1){ + pc->green_curve = previous; + }else{ + //we eliminate the last segment + pc->green_curve->backspace(); + //and we add it again with the recreation + pc->green_curve->append_continuous(previous, 0.0625); + } } - previous->moveto(A); - previous->curveto(B, C, D); - if( pc->green_curve->get_segment_count() == 1){ - pc->green_curve = previous; - }else{ - //we eliminate the last segment - pc->green_curve->backspace(); - //and we add it again with the recreation - pc->green_curve->append_continuous(previous, 0.0625); + if(pc->green_curve->is_empty() && pc->sa && !pc->sa->curve->is_empty()){ + bspline_spiro_start_anchor(pc, false); } } -//BSpline - //Para formar una recta necesitamos un nodo con manejador en el "lastpoint" - //de esta manera modificamos el final de la "curva_verde" para que tenga manejador - if(pc->bspline && !pc->green_curve->is_empty()){ - Geom::Point A(0,0); - Geom::Point B(0,0); - Geom::Point C(0,0); - Geom::Point D(0,0); - using Geom::X; - using Geom::Y; - SPCurve * previous = new SPCurve(); - //We obtain the last segment 4 points in the previous curve - A = pc->green_curve->last_segment()->initialPoint(); - B = pc->green_curve->last_segment()->initialPoint(); - C = pc->green_curve->last_segment()->finalPoint() + (1./3)* (Geom::Point)(pc->green_curve->last_segment()->initialPoint() - pc->green_curve->last_segment()->finalPoint()); - pc->p[1] = pc->p[0] + (1./3)*(C - pc->p[0]); - D = pc->green_curve->last_segment()->finalPoint(); - previous->moveto(A); - previous->curveto(B, C, D); - if( pc->green_curve->get_segment_count() == 1){ - pc->green_curve = previous; - }else{ - //we eliminate the last segment - pc->green_curve->backspace(); - //and we add it again with the recreation - pc->green_curve->append_continuous(previous, 0.0625); - } - } //Spiro Live pen_redraw_all(pc); } @@ -1128,70 +1110,43 @@ static void pen_lastpoint_toline (SPPenContext *const pc) //Si no es bspline if (pc->npoints != 5 && !pc->bspline) return; - Geom::CubicBezier const * cubic; - if(pc->spiro){ - Geom::Point A(0,0); - Geom::Point B(0,0); - Geom::Point C(0,0); - Geom::Point D(0,0); - SPCurve * previous = new SPCurve(); - Geom::CubicBezier const * cubic = dynamic_cast( pc->green_curve->last_segment() ); - if ( cubic ) { - A = pc->green_curve->last_segment()->initialPoint(); - B = (*cubic)[1]; - C = pc->green_curve->last_segment()->finalPoint(); - D = C; - pc->p[1] = pc->p[0] + (Geom::Point)( (*cubic)[3] - (*cubic)[2] ); - } else { - //We obtain the last segment 4 points in the previous curve - A = pc->green_curve->last_segment()->initialPoint(); - B = A; - C = pc->green_curve->last_segment()->finalPoint(); - D = C; - } - previous->moveto(A); - previous->curveto(B, C, D); - if( pc->green_curve->get_segment_count() == 1){ - pc->green_curve = previous; - }else{ - //we eliminate the last segment - pc->green_curve->backspace(); - //and we add it again with the recreation - pc->green_curve->append_continuous(previous, 0.0625); + if(pc->spiro || pc->bspline){ + if(!pc->green_curve->is_empty()){ + Geom::Point A(0,0); + Geom::Point B(0,0); + Geom::Point C(0,0); + Geom::Point D(0,0); + SPCurve * previous = new SPCurve(); + Geom::CubicBezier const * cubic = dynamic_cast( pc->green_curve->last_segment() ); + if ( cubic ) { + A = pc->green_curve->last_segment()->initialPoint(); + B = (*cubic)[1]; + C = pc->green_curve->last_segment()->finalPoint(); + D = C; + } else { + //We obtain the last segment 4 points in the previous curve + A = pc->green_curve->last_segment()->initialPoint(); + B = A; + C = pc->green_curve->last_segment()->finalPoint(); + D = C; + } + previous->moveto(A); + previous->curveto(B, C, D); + if( pc->green_curve->get_segment_count() == 1){ + pc->green_curve = previous; + }else{ + //we eliminate the last segment + pc->green_curve->backspace(); + //and we add it again with the recreation + pc->green_curve->append_continuous(previous, 0.0625); + } } - } - - if(!pc->bspline){ - cubic = dynamic_cast( pc->green_curve->last_segment() ); - if ( cubic ) { - pc->p[1] = pc->p[0] + (Geom::Point)( pc->p[0] - (*cubic)[2] ); - } else { - pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]); + if(pc->green_curve->is_empty() && pc->sa && !pc->sa->curve->is_empty()){ + bspline_spiro_start_anchor(pc, true); } } - - //Para formar una curva bspline necesitamos un nodo cusp en el "lastpoint" - //de esta manera modificamos el final de la "curva_verde" para que sea cusp con el pricipio de la "red_curve" - //Que se quedará recta - if(pc->bspline){ - Geom::Point A(0,0); - Geom::Point B(0,0); - SPCurve * previous = new SPCurve(); - //We obtain the last segment 2 points in the previous curve - A = pc->green_curve->last_segment()->initialPoint(); - B = pc->green_curve->last_segment()->finalPoint(); - previous->moveto(A); - previous->lineto(B); - if( pc->green_curve->get_segment_count() == 1){ - pc->green_curve = previous; - }else{ - //we eliminate the last segment - pc->green_curve->backspace(); - //and we add it again with the recreation - pc->green_curve->append_continuous(previous, 0.0625); - } - - } + + pc->p[1] = pc->p[0]; pen_redraw_all(pc); } @@ -1352,6 +1307,7 @@ static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) } } else { // Reset red curve + Geom::CubicBezier const * cubic = NULL; pc->red_curve->reset(); // Destroy topmost green bpath if (pc->green_bpaths) { @@ -1367,14 +1323,15 @@ static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) // The code below assumes that pc->green_curve has only ONE path ! Geom::Curve const * crv = pc->green_curve->last_segment(); pc->p[0] = crv->initialPoint(); - if ( Geom::CubicBezier const * cubic = dynamic_cast(crv)) { + cubic = dynamic_cast(crv); + if ( cubic ) { pc->p[1] = (*cubic)[1]; - //BSpline - if(pc->spiro || pc->bspline)pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]); - //BSpline End } else { pc->p[1] = pc->p[0]; } + if(pc->bspline){ + pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]); + } Geom::Point const pt((pc->npoints < 4 ? (Geom::Point)(crv->finalPoint()) @@ -1393,6 +1350,15 @@ static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) }else{ pc->green_curve->backspace(); } + if(pc->spiro){ + cubic = dynamic_cast(pc->green_curve->last_segment()); + if ( cubic ) { + pc->p[1] = (*cubic)[3] + (Geom::Point)((*cubic)[3] - (*cubic)[2]); + SP_CTRL(pc->c1)->moveto(pc->p[0]); + } else { + pc->p[1] = pc->p[0]; + } + } //BSpline End sp_canvas_item_hide(pc->cl0); sp_canvas_item_hide(pc->cl1); @@ -1856,7 +1822,11 @@ static void bspline_spiro_build(SPPenContext *const pc) curve->unref(); pc->blue_curve->reset(); //We hide the holders that doesn't contribute anything - sp_canvas_item_hide(pc->c1); + if(pc->spiro){ + sp_canvas_item_show(pc->c1); + SP_CTRL(pc->c1)->moveto(pc->p[0]); + }else + sp_canvas_item_hide(pc->c1); sp_canvas_item_hide(pc->cl1); sp_canvas_item_hide(pc->c0); sp_canvas_item_hide(pc->cl0); diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 4cac0e543..e7d62d619 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -142,8 +142,14 @@ void Handle::move(Geom::Point const &new_pos) Handle *h2 = NULL; if(_pm().isBSpline()){ isBSpline = true; - if(!_parent->selected()) - _parent->_selection.insert(_parent); + typedef ControlPointSelection::Set Set; + Set &nodes = _parent->_selection.allPoints(); + for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { + Node *n = static_cast(*i); + _parent->_selection.erase(n); + } + //if(!_parent->selected()) + _parent->_selection.insert(_parent); } //BSpline End @@ -596,10 +602,12 @@ void Node::move(Geom::Point const &new_pos) //BSpline End setPosition(new_pos); //BSpline - if(prevNode) - prevNode->front()->setPosition(_pm().BSplineHandleReposition(prevNode->front(),prevPos)); - if(nextNode) - nextNode->back()->setPosition(_pm().BSplineHandleReposition(nextNode->back(),nextPos)); + if(_pm().isBSpline()){ + if(prevNode) + prevNode->front()->setPosition(_pm().BSplineHandleReposition(prevNode->front(),prevPos)); + if(nextNode) + nextNode->back()->setPosition(_pm().BSplineHandleReposition(nextNode->back(),nextPos)); + } //BSpline End _front.setPosition(_front.position() + delta); _back.setPosition(_back.position() + delta); -- cgit v1.2.3 From caaed5a4603d40a0043bdcb564e213ea9e7d0021 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 6 Mar 2013 04:01:15 +0100 Subject: Permanent show outline in BSpline mode (bzr r11950.1.47) --- src/ui/tool/path-manipulator.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 7c23ee153..0a100ecfb 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -895,6 +895,9 @@ void PathManipulator::showHandles(bool show) /** Set the visibility of outline. */ void PathManipulator::showOutline(bool show) { + //BSpline + if(isBSpline()) show = true; + //BSpline if (show == _show_outline) return; _show_outline = show; _updateOutline(); -- cgit v1.2.3 From 8e034f847b5d49b1ed1aaa0a005da626fdc213da Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 10 Mar 2013 21:34:14 +0100 Subject: Add pencil BSpline mode (bzr r11950.1.49) --- src/pencil-context.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp index 5c5780fbb..1ece4528a 100644 --- a/src/pencil-context.cpp +++ b/src/pencil-context.cpp @@ -759,7 +759,9 @@ interpolate(SPPencilContext *pc) for (int c = 0; c < n_segs; c++) { //BSpline if(mode == 2){ - pc->green_curve->lineto(b[4*c+3]); + Geom::Point BP = b[4*c+0] + (1./3)*(b[4*c+3] - b[4*c+0]); + Geom::Point CP = b[4*c+3] + (1./3)*(b[4*c+0] - b[4*c+3]); + pc->green_curve->curveto(BP,CP,b[4*c+3]); }else{ pc->green_curve->curveto(b[4*c+1], b[4*c+2], b[4*c+3]); } @@ -908,7 +910,9 @@ fit_and_split(SPPencilContext *pc) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); guint mode = prefs->getInt("/tools/freehand/pencil/freehand-mode", 0); if(mode == 2){ - pc->red_curve->lineto(b[3]); + Geom::Point B = b[0] + (1./3)*(b[3] - b[0]); + Geom::Point C = b[3] + (1./3)*(b[0] - b[3]); + pc->red_curve->curveto(B,C,b[3]); }else{ pc->red_curve->curveto(b[1], b[2], b[3]); } -- cgit v1.2.3 From b2981a3b8f54bccfa45c76f57b38c9c93808d2fc Mon Sep 17 00:00:00 2001 From: root Date: Tue, 12 Mar 2013 00:48:05 +0100 Subject: ~sub fix, double click to reset default handles and control to 10% step (bzr r11950.1.51) --- src/draw-context.cpp | 6 ++ src/live_effects/lpe-bspline.cpp | 135 ++++++++++++++++++++++++++++++++- src/live_effects/lpe-bspline.h | 5 +- src/pen-context.cpp | 50 +++++++----- src/pencil-context.cpp | 4 +- src/ui/tool/multi-path-manipulator.cpp | 4 +- src/ui/tool/node.cpp | 68 +++++++++++++++-- src/ui/tool/node.h | 3 + 8 files changed, 248 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/draw-context.cpp b/src/draw-context.cpp index dcd0fc7ec..356853e09 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -291,6 +291,7 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item Effect::createAndApply(SPIRO, dc->desktop->doc(), item); } //BSpline + //Añadimos el modo BSpline a los efectos en espera if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2) { Effect::createAndApply(BSPLINE, dc->desktop->doc(), item); } @@ -562,6 +563,8 @@ void spdc_concat_colors_and_flush(SPDrawContext *dc, gboolean forceclosed) c->unref(); dc->sa->curve->closepath_current(); //BSpline + //Si la curva tiene un LPE del tipo BSpline ejecutamos spdc_flush_white + //pasándole la curva de inicio necesaria Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ @@ -696,6 +699,9 @@ SPDrawAnchor *spdc_test_inside(SPDrawContext *dc, Geom::Point p) } //BSpline + //Modificamos la curva del "anchor" final para que sea igual que la curva de inicio. + //Esta curva fue modificada al continuar la curva y necesitamos que sea igual que la curva en + //la que cerramos el trazado. Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if((prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2) && diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index d91f7297e..fcca38e4c 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -11,7 +11,7 @@ #include <2geom/affine.h> #include <2geom/bezier-curve.h> #include "helper/geom-curves.h" - +#include // For handling un-continuous paths: #include "message-stack.h" #include "inkscape.h" @@ -21,8 +21,11 @@ namespace Inkscape { namespace LivePathEffect { LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) : - Effect(lpeobject) + Effect(lpeobject),unify_weights(_("Unify weights:"), + _("Percent of the with for all poinrs"), "unify_weights", &wr, this, 33.) { + registerParameter( dynamic_cast(&unify_weights) ); + unify_weights.param_set_range(0, 100.); } LPEBSpline::~LPEBSpline() @@ -205,6 +208,134 @@ LPEBSpline::doEffect(SPCurve * curve) } } +std::vector +LPEBSpline::doEffect_path (std::vector const &path_in) +{ + Geom::PathVector const original_pathv = path_in; + SPCurve *curve = new SPCurve(); + //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo + for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { + //Si está vacío... + if (path_it->empty()) + continue; + //Itreadores + + Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve + Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve + Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop + //Creamos las lineas rectas que unen todos los puntos del trazado y donde se calcularán + //los puntos clave para los manejadores. + //Esto hace que la curva BSpline no pierda su condición aunque se trasladen + //dichos manejadores + SPCurve *nCurve = new SPCurve(); + Geom::Point previousNode(0,0); + Geom::Point node(0,0); + Geom::Point pointAt0(0,0); + Geom::Point pointAt1(0,0); + Geom::Point pointAt2(0,0); + Geom::Point pointAt3(0,0); + double pos1 = 0; + double pos2 = 0; + Geom::Point nextPointAt1(0,0); + Geom::Point nextPointAt2(0,0); + Geom::Point nextPointAt3(0,0); + Geom::D2< Geom::SBasis > SBasisIn; + Geom::D2< Geom::SBasis > SBasisOut; + Geom::D2< Geom::SBasis > SBasisHelper; + Geom::CubicBezier const *cubic = NULL; + if (path_it->closed()) { + // if the path is closed, maybe we have to stop a bit earlier because the closing line segment has zerolength. + const Geom::Curve &closingline = path_it->back_closed(); // the closing line segment is always of type Geom::LineSegment. + if (are_near(closingline.initialPoint(), closingline.finalPoint())) { + // closingline.isDegenerate() did not work, because it only checks for *exact* zero length, which goes wrong for relative coordinates and rounding errors... + // the closing line segment has zero-length. So stop before that one! + curve_endit = path_it->end_open(); + } + } + //Si la curva está cerrada calculamos el punto donde + //deveria estar el nodo BSpline de cierre/inicio de la curva + //en posible caso de que se cierre con una linea recta creando un nodo BSPline + + //Recorremos todos los segmentos menos el último + while ( curve_it2 != curve_endit ) + { + //previousPointAt3 = pointAt3; + //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida + SPCurve * in = new SPCurve(); + in->moveto(curve_it1->initialPoint()); + in->lineto(curve_it1->finalPoint()); + cubic = dynamic_cast(&*curve_it1); + if(cubic){ + SBasisIn = in->first_segment()->toSBasis(); + pointAt0 = in->first_segment()->initialPoint(); + pos1 = unify_weights/100; + pos2 = 1-unify_weights/100; + pointAt1 = SBasisIn.valueAt(pos1); + pointAt2 = SBasisIn.valueAt(pos2); + pointAt3 = in->first_segment()->finalPoint(); + }else{ + pointAt0 = in->first_segment()->initialPoint(); + pointAt1 = in->first_segment()->initialPoint(); + pointAt2 = in->first_segment()->finalPoint(); + pointAt3 = in->first_segment()->finalPoint(); + } + in->reset(); + delete in; + //Y hacemos lo propio con el path de salida + //nextPointAt0 = curveOut.valueAt(0); + SPCurve * out = new SPCurve(); + out->moveto(curve_it2->initialPoint()); + out->lineto(curve_it2->finalPoint()); + cubic = dynamic_cast(&*curve_it2); + if(cubic){ + SBasisOut = out->first_segment()->toSBasis(); + pos1 = unify_weights/100; + pos2 = 1-unify_weights/100; + nextPointAt1 = SBasisOut.valueAt(pos1); + nextPointAt2 = SBasisOut.valueAt(pos2); + nextPointAt3 = (*cubic)[3]; + }else{ + nextPointAt1 = out->first_segment()->initialPoint(); + nextPointAt2 = out->first_segment()->finalPoint(); + nextPointAt3 = out->first_segment()->finalPoint(); + } + out->reset(); + delete out; + //Y este hará de final de curva + SPCurve *curveHelper = new SPCurve(); + curveHelper->moveto(pointAt0); + curveHelper->curveto(pointAt1, pointAt2, pointAt3); + //añadimos la curva generada a la curva pricipal + nCurve->append_continuous(curveHelper, 0.0625); + curveHelper->reset(); + delete curveHelper; + //aumentamos los valores para el siguiente paso en el bucle + ++curve_it1; + ++curve_it2; + } + //Aberiguamos la ultima parte de la curva correspondiente al último segmento + SPCurve *curveHelper = new SPCurve(); + curveHelper->moveto(node); + //Si está cerrada la curva, la cerramos sobre el valor guardado previamente + //Si no finalizamos en el punto final + Geom::Point startNode(0,0); + startNode = path_it->begin()->initialPoint(); + curveHelper->curveto(nextPointAt1, nextPointAt2, nextPointAt3); + nCurve->append_continuous(curveHelper, 0.0625); + nCurve->move_endpoints(startNode,nextPointAt3); + curveHelper->reset(); + delete curveHelper; + //y cerramos la curva + if (path_it->closed()) { + nCurve->closepath_current(); + } + curve->append(nCurve,false); + nCurve->reset(); + delete nCurve; + } + return curve->get_pathvector(); +} + }; //namespace LivePathEffect }; /* namespace Inkscape */ diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index d983a7654..27c79f040 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -8,7 +8,7 @@ */ #include "live_effects/effect.h" - +#include "live_effects/parameter/parameter.h" namespace Inkscape { namespace LivePathEffect { @@ -18,11 +18,14 @@ public: LPEBSpline(LivePathEffectObject *lpeobject); virtual ~LPEBSpline(); + virtual std::vector doEffect_path (std::vector const & input_path); + virtual LPEPathFlashType pathFlashType() const { return SUPPRESS_FLASH; } virtual void doEffect(SPCurve * curve); private: + ScalarParam unify_weights; LPEBSpline(const LPEBSpline&); LPEBSpline& operator=(const LPEBSpline&); }; diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 6232c5e59..79e4cbabf 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -45,7 +45,7 @@ #include "tools-switch.h" #include "ui/control-manager.h" //BSpline -//Incluimos +//Incluimos los archivos necesarios para las BSpline y Spiro #define INKSCAPE_LPE_SPIRO_C #include "live_effects/lpe-spiro.h" @@ -86,23 +86,27 @@ static void spdc_pen_set_initial_point(SPPenContext *pc, Geom::Point const p); *BSpline *Added functions */ - -/* - *Sobrecarga la función "sp_pen_context_set_polyline_mode" - *Le da valor a la nueva propiedad "pc->spiro" que como se auto define indica si estamos en modo spiro - *En el futuro se la dará a "pc->bspline" -*/ +//Añade los modos spiro y bspline static void sp_pen_context_set_mode(SPPenContext *const pc, guint mode); //Esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro static void bspline_spiro_color(SPPenContext *const pc); +//Crea un nodo en modo bspline o spiro static void bspline_spiro(SPPenContext *const pc,bool shift); +//Crea un nodo de modo spiro o bspline static void bspline_spiro_on(SPPenContext *const pc); +//Crea un nodo de tipo CUSP static void bspline_spiro_off(SPPenContext *const pc); +//Continua una curva existente en modo bspline o spiro static void bspline_spiro_start_anchor(SPPenContext *const pc,bool shift); +//Continua una curva exsitente con el nodo de union en modo bspline o spiro static void bspline_spiro_start_anchor_on(SPPenContext *const pc); +//Continua una curva existente con el nodo de union en modo CUSP static void bspline_spiro_start_anchor_off(SPPenContext *const pc); +//Modifica la "red_curve" cuando se detecta movimiento static void bspline_spiro_motion(SPPenContext *const pc,bool shift); +//Cierra la curva con el último nodo en modo bspline o spiro static void bspline_spiro_end_anchor_on(SPPenContext *const pc); +//Cierra la curva con el último nodo en modo CUSP static void bspline_spiro_end_anchor_off(SPPenContext *const pc); //Unimos todas las curvas en juego y llamamos a la función doEffect. static void bspline_spiro_build(SPPenContext *const pc); @@ -224,7 +228,7 @@ void sp_pen_context_set_polyline_mode(SPPenContext *const pc) { pc->polylines_only = (mode == 3 || mode == 4); pc->polylines_paraxial = (mode == 4); //BSpline - //we call the function which defines the Spiro modes and the B-spline in the future + //we call the function which defines the Spiro modes and the BSpline //todo: merge to one function only sp_pen_context_set_mode(pc, mode); //BSpline End @@ -232,7 +236,7 @@ void sp_pen_context_set_polyline_mode(SPPenContext *const pc) { //BSpline /* -*.Set the mode of draw now spiro, and later b-splines +*.Set the mode of draw spiro, and bsplines */ void sp_pen_context_set_mode(SPPenContext *const pc, guint mode) { pc->spiro = (mode == 1); @@ -461,7 +465,7 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const //Test whether we hit any anchor. SPDrawAnchor * const anchor = spdc_test_inside(pc, event_w); //with this we avoid creating a new point over the existing one - if((pc->spiro || pc->bspline) && pc->npoints > 0 && pc->p[0] == pc->p[3]){ + if(!bevent.button == 3 && (pc->spiro || pc->bspline) && pc->npoints > 0 && pc->p[0] == pc->p[3]){ return FALSE; } //BSpline end @@ -529,9 +533,9 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const // Set start anchor pc->sa = anchor; //BSpline + //Continuamos una curva existente if(anchor){ - if(pc->bspline || pc->spiro) - bspline_spiro_start_anchor(pc,(bevent.state & GDK_SHIFT_MASK)); + bspline_spiro_start_anchor(pc,(bevent.state & GDK_SHIFT_MASK)); } //BSpline End if (anchor && !sp_pen_context_has_waiting_LPE(pc)) { @@ -585,8 +589,7 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const } } //BSpline - //Esto evita arrastrar los manejadores ya que el punto se crea - //al soltar el botón del ratón. + //Evitamos la creación de un punto de control para que se cree el nodo en el evento de soltar pc->state = (pc->spiro || pc->bspline || pc->polylines_only) ? SP_PEN_CONTEXT_POINT : SP_PEN_CONTEXT_CONTROL; //BSpline End ret = TRUE; @@ -778,6 +781,7 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons break; } //BSpline + //Lanzamos la función "bspline_spiro_motion" al moverse el ratón o cuando se para. if ( Geom::LInfty( event_w - pen_drag_origin_w ) > tolerance || mevent.time == 0) { bspline_spiro_motion(pc,(mevent.state & GDK_SHIFT_MASK)); pen_drag_origin_w = event_w; @@ -809,6 +813,7 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con // Test whether we hit any anchor. SPDrawAnchor *anchor = spdc_test_inside(pc, event_w); //BSpline + //with this we avoid creating a new point over the existing one if(pc->spiro || pc->bspline){ //Si intentamos crear un nodo en el mismo sitio que el origen, paramos. if(pc->npoints > 0 && pc->p[0] == pc->p[3]){ @@ -827,6 +832,7 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con } pc->sa = anchor; //BSpline + //continuamos una curva existente if (anchor) { if(pc->bspline || pc->spiro){ bspline_spiro_start_anchor(pc,(revent.state & GDK_SHIFT_MASK)); @@ -982,6 +988,7 @@ static void pen_redraw_all (SPPenContext *const pc) // handles //BSpline + //Ocultamos los tiradores en modo BSpline y spiro if (pc->p[0] != pc->p[1] && !pc->spiro && !pc->bspline) { //BSpline End SP_CTRL(pc->c1)->moveto(pc->p[1]); @@ -997,6 +1004,7 @@ static void pen_redraw_all (SPPenContext *const pc) if (last_seg) { Geom::CubicBezier const * cubic = dynamic_cast( last_seg ); //BSpline + //Ocultamos los tiradores en modo BSpline y spiro if ( cubic && (*cubic)[2] != pc->p[0] && !pc->spiro && !pc->bspline ) { @@ -1017,6 +1025,7 @@ static void pen_redraw_all (SPPenContext *const pc) //sino al final de esta //BSpline + //Lanzamos solamente el redibujado bspline_spiro_build(pc); //BSpline End } @@ -1056,8 +1065,7 @@ static void pen_lastpoint_tocurve (SPPenContext *const pc) //BSpline Geom::CubicBezier const * cubic; pc->p[1] = pc->red_curve->last_segment()->initialPoint() + (1./3)* (Geom::Point)(pc->red_curve->last_segment()->finalPoint() - pc->red_curve->last_segment()->initialPoint()); - //Para formar una curva necesitamos un nodo symm en el "lastpoint" - //de esta manera modificamos el final de la "curva_verde" para que sea symm con el pricipio de la "red_curve" + //Modificamos el último segmento de la curva verde para que forme el tipo de nodo que deseamos if(pc->spiro||pc->bspline){ if(!pc->green_curve->is_empty()){ Geom::Point A(0,0); @@ -1095,6 +1103,7 @@ static void pen_lastpoint_tocurve (SPPenContext *const pc) pc->green_curve->append_continuous(previous, 0.0625); } } + //Si el último nodo es una union con otra curva if(pc->green_curve->is_empty() && pc->sa && !pc->sa->curve->is_empty()){ bspline_spiro_start_anchor(pc, false); } @@ -1107,9 +1116,11 @@ static void pen_lastpoint_tocurve (SPPenContext *const pc) static void pen_lastpoint_toline (SPPenContext *const pc) { //BSpline - //Si no es bspline + //Evitamos que si la "red_curve" tiene solo dos puntos -recta- no se pare aqui. if (pc->npoints != 5 && !pc->bspline) return; + + //Modificamos el último segmento de la curva verde para que forme el tipo de nodo que deseamos if(pc->spiro || pc->bspline){ if(!pc->green_curve->is_empty()){ Geom::Point A(0,0); @@ -1141,6 +1152,7 @@ static void pen_lastpoint_toline (SPPenContext *const pc) pc->green_curve->append_continuous(previous, 0.0625); } } + //Si el último nodo es una union con otra curva if(pc->green_curve->is_empty() && pc->sa && !pc->sa->curve->is_empty()){ bspline_spiro_start_anchor(pc, true); } @@ -1329,6 +1341,7 @@ static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) } else { pc->p[1] = pc->p[0]; } + //Asignamos el valor a un tercio de distancia del último segmento. if(pc->bspline){ pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]); } @@ -1339,6 +1352,7 @@ static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) pc->npoints = 2; //BSpline + //Eliminamos el último segmento de la curva verde if( pc->green_curve->get_segment_count() == 1){ pc->npoints = 5; if (pc->green_bpaths) { @@ -1350,6 +1364,7 @@ static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) }else{ pc->green_curve->backspace(); } + //Asignamos el valor de pc->p[1] a el opuesto de el ultimo segmento de la línea verde if(pc->spiro){ cubic = dynamic_cast(pc->green_curve->last_segment()); if ( cubic ) { @@ -1366,6 +1381,7 @@ static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event) spdc_pen_set_subsequent_point(pc, pt, true); pen_last_paraxial_dir = !pen_last_paraxial_dir; //BSpline + //Redibujamos bspline_spiro_build(pc); //BSpline End ret = TRUE; diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp index 1ece4528a..37df2588a 100644 --- a/src/pencil-context.cpp +++ b/src/pencil-context.cpp @@ -757,7 +757,8 @@ interpolate(SPPencilContext *pc) guint mode = prefs->getInt("/tools/freehand/pencil/freehand-mode", 0); //BSpline End for (int c = 0; c < n_segs; c++) { - //BSpline + //BSpline + //Si el modo es BSpline modificamos para que el trazado cree los nodos adhoc if(mode == 2){ Geom::Point BP = b[4*c+0] + (1./3)*(b[4*c+3] - b[4*c+0]); Geom::Point CP = b[4*c+3] + (1./3)*(b[4*c+0] - b[4*c+3]); @@ -907,6 +908,7 @@ fit_and_split(SPPencilContext *pc) pc->red_curve->reset(); pc->red_curve->moveto(b[0]); //BSpline + //Si el modo es BSpline modificamos para que el trazado cree los nodos adhoc Inkscape::Preferences *prefs = Inkscape::Preferences::get(); guint mode = prefs->getInt("/tools/freehand/pencil/freehand-mode", 0); if(mode == 2){ diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp index c9e35e5b2..2ef8c1766 100644 --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@ -296,6 +296,7 @@ void MultiPathManipulator::invertSelectionInSubpaths() invokeForAll(&PathManipulator::invertSelectionInSubpaths); } + void MultiPathManipulator::setNodeType(NodeType type) { if (_selection.empty()) return; @@ -307,7 +308,7 @@ void MultiPathManipulator::setNodeType(NodeType type) Node *node = dynamic_cast(*i); if (node) { retract_handles &= (node->type() == NODE_CUSP); - node->setType(type); + node->setType(type,true); } } @@ -324,6 +325,7 @@ void MultiPathManipulator::setNodeType(NodeType type) _done(retract_handles ? _("Retract handles") : _("Change node type")); } + void MultiPathManipulator::setSegmentType(SegmentType type) { if (_selection.empty()) return; diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index e7d62d619..bee2cc477 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -29,6 +29,9 @@ #include "ui/tool/node.h" #include "ui/tool/path-manipulator.h" #include +//BSpline +#include +//BSpline End; namespace { @@ -146,10 +149,11 @@ void Handle::move(Geom::Point const &new_pos) Set &nodes = _parent->_selection.allPoints(); for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { Node *n = static_cast(*i); - _parent->_selection.erase(n); - } - //if(!_parent->selected()) - _parent->_selection.insert(_parent); + if(n != _parent) + _parent->_selection.erase(n); + } + if(!_parent->selected()) + _parent->_selection.insert(_parent); } //BSpline End @@ -307,12 +311,33 @@ bool Handle::_eventHandler(SPEventContext *event_context, GdkEvent *event) break; default: break; } + //BSpline + case GDK_2BUTTON_PRESS: + handle_2button_press(); + break; + //BSpline End default: break; } return ControlPoint::_eventHandler(event_context, event); } +//BSpline +void Handle::handle_2button_press(){ + if(_pm().isBSpline()){ + Handle *h = NULL; + Handle *h2 = NULL; + double pos = 0; + h = this; + setPosition(_pm().BSplineHandleReposition(h,0.3334)); + pos = _pm().BSplineHandlePosition(h); + h2 = this->other(); + this->other()->setPosition(_pm().BSplineHandleReposition(h2,pos)); + _pm().update(); + } +} +//BSpline End + bool Handle::grabbed(GdkEventMotion *) { _saved_other_pos = other()->position(); @@ -360,6 +385,16 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) ctrl_constraint = Inkscape::Snapper::SnapConstraint(parent_pos, parent_pos - perp_pos); } new_pos = result; + //BSpline + if(_pm().isBSpline()){ + Handle *h = NULL; + double pos = 0; + h = this; + setPosition(new_pos); + pos = ceilf(_pm().BSplineHandlePosition(h)*10)/10; + new_pos=_pm().BSplineHandleReposition(h,pos); + } + //BSpline End } std::vector unselected; @@ -728,7 +763,7 @@ void Node::updateHandles() _front._handleControlStyling(); _back._handleControlStyling(); } - + void Node::setType(NodeType type, bool update_handles) { @@ -738,6 +773,27 @@ void Node::setType(NodeType type, bool update_handles) return; } + //BSpline + if(_pm().isBSpline()){ + if (isEndNode()) return; + Handle* front = &_front; + Handle* back = &_back; + double pos = 0.3334; + switch (type) { + case NODE_CUSP: + if(update_handles) + pos = 0; + else + pos = _pm().BSplineHandlePosition(front);; + break; + default: break; + } + type = NODE_CUSP; + _front.setPosition(_pm().BSplineHandleReposition(front,pos)); + _back.setPosition(_pm().BSplineHandleReposition(back,pos)); + } + //BSpline End + // if update_handles is true, adjust handle positions to match the node type // handle degenerate handles appropriately if (update_handles) { @@ -821,7 +877,9 @@ void Node::setType(NodeType type, bool update_handles) default: break; } } + _type = type; + _setControlType(nodeTypeToCtrlType(_type)); updateState(); } diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h index 591dd8532..e74698b1a 100644 --- a/src/ui/tool/node.h +++ b/src/ui/tool/node.h @@ -107,6 +107,9 @@ protected: Handle(NodeSharedData const &data, Geom::Point const &initial_pos, Node *parent); virtual bool _eventHandler(SPEventContext *event_context, GdkEvent *event); + //Bspline + virtual void handle_2button_press(); + //BSpline End virtual void dragged(Geom::Point &new_pos, GdkEventMotion *event); virtual bool grabbed(GdkEventMotion *event); virtual void ungrabbed(GdkEventButton *event); -- cgit v1.2.3 From d0bebd018087b363bfde91bce46744dfd004549c Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 14 Mar 2013 22:28:34 +0100 Subject: Updating original path (bzr r11950.1.53) --- src/live_effects/lpe-bspline.cpp | 208 +++++++++++-------------------- src/live_effects/lpe-bspline.h | 6 + src/live_effects/parameter/parameter.cpp | 7 +- 3 files changed, 85 insertions(+), 136 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index fcca38e4c..f5dff3abe 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -34,6 +34,11 @@ LPEBSpline::~LPEBSpline() void LPEBSpline::doEffect(SPCurve * curve) +{ +LPEBSpline::doEffect(curve,NULL) +} +void +LPEBSpline::doEffect(SPCurve * curve,int value) { if(curve->get_segment_count() < 2) return; @@ -91,11 +96,21 @@ LPEBSpline::doEffect(SPCurve * curve) cubic = dynamic_cast(&*curve_it1); if(cubic){ SBasisIn = in->first_segment()->toSBasis(); - pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[1],*in->first_segment())); - pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[2],*in->first_segment())); + if(value){ + pointAt1 = SBasisIn.valueAt(value); + pointAt2 = SBasisIn.valueAt(1-value); + }else{ + pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[1],*in->first_segment())); + pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[2],*in->first_segment())); + } }else{ - pointAt1 = in->first_segment()->initialPoint(); - pointAt2 = in->first_segment()->finalPoint(); + if(value){ + pointAt1 = SBasisIn.valueAt(value); + pointAt2 = SBasisIn.valueAt(1-value); + }else{ + pointAt1 = in->first_segment()->initialPoint(); + pointAt2 = in->first_segment()->finalPoint(); + } } in->reset(); delete in; @@ -107,12 +122,22 @@ LPEBSpline::doEffect(SPCurve * curve) cubic = dynamic_cast(&*curve_it2); if(cubic){ SBasisOut = out->first_segment()->toSBasis(); - nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[1],*out->first_segment())); - nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[2],*out->first_segment()));; + if(value){ + nextPointAt1 = SBasisIn.valueAt(value); + nextPointAt2 = SBasisIn.valueAt(1-value); + }else{ + nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[1],*out->first_segment())); + nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[2],*out->first_segment()));; + ] nextPointAt3 = (*cubic)[3]; }else{ - nextPointAt1 = out->first_segment()->initialPoint(); - nextPointAt2 = out->first_segment()->finalPoint(); + if(value){ + nextPointAt1 = SBasisIn.valueAt(value); + nextPointAt2 = SBasisIn.valueAt(1-value); + }else{ + nextPointAt1 = out->first_segment()->initialPoint(); + nextPointAt2 = out->first_segment()->finalPoint(); + } nextPointAt3 = out->first_segment()->finalPoint(); } out->reset(); @@ -133,8 +158,13 @@ LPEBSpline::doEffect(SPCurve * curve) //Y este hará de final de curva node = SBasisHelper.valueAt(0.5); SPCurve *curveHelper = new SPCurve(); - curveHelper->moveto(previousNode); - curveHelper->curveto(pointAt1, pointAt2, node); + if(value){ + curveHelper->moveto(*in->first_segment()->initialPoint()); + curveHelper->curveto(pointAt1, pointAt2, *in->first_segment()->finalPoint()); + }else{ + curveHelper->moveto(previousNode); + curveHelper->curveto(pointAt1, pointAt2, node); + } //añadimos la curva generada a la curva pricipal nCurve->append_continuous(curveHelper, 0.0625); curveHelper->reset(); @@ -181,7 +211,10 @@ LPEBSpline::doEffect(SPCurve * curve) lineHelper->reset(); delete lineHelper; //Guardamos el principio de la curva - startNode = SBasisHelper.valueAt(0.5); + if(value) + startNode = path_it->begin()->initialPoint(); + else + startNode = SBasisHelper.valueAt(0.5); curveHelper->curveto(nextPointAt1, nextPointAt2, startNode); nCurve->append_continuous(curveHelper, 0.0625); nCurve->move_endpoints(startNode,startNode); @@ -208,132 +241,37 @@ LPEBSpline::doEffect(SPCurve * curve) } } -std::vector -LPEBSpline::doEffect_path (std::vector const &path_in) +void +LPEBSpline::updateAllHandles(int value) { - Geom::PathVector const original_pathv = path_in; - SPCurve *curve = new SPCurve(); - //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo - for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { - //Si está vacío... - if (path_it->empty()) - continue; - //Itreadores - - Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve - Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve - Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop - //Creamos las lineas rectas que unen todos los puntos del trazado y donde se calcularán - //los puntos clave para los manejadores. - //Esto hace que la curva BSpline no pierda su condición aunque se trasladen - //dichos manejadores - SPCurve *nCurve = new SPCurve(); - Geom::Point previousNode(0,0); - Geom::Point node(0,0); - Geom::Point pointAt0(0,0); - Geom::Point pointAt1(0,0); - Geom::Point pointAt2(0,0); - Geom::Point pointAt3(0,0); - double pos1 = 0; - double pos2 = 0; - Geom::Point nextPointAt1(0,0); - Geom::Point nextPointAt2(0,0); - Geom::Point nextPointAt3(0,0); - Geom::D2< Geom::SBasis > SBasisIn; - Geom::D2< Geom::SBasis > SBasisOut; - Geom::D2< Geom::SBasis > SBasisHelper; - Geom::CubicBezier const *cubic = NULL; - if (path_it->closed()) { - // if the path is closed, maybe we have to stop a bit earlier because the closing line segment has zerolength. - const Geom::Curve &closingline = path_it->back_closed(); // the closing line segment is always of type Geom::LineSegment. - if (are_near(closingline.initialPoint(), closingline.finalPoint())) { - // closingline.isDegenerate() did not work, because it only checks for *exact* zero length, which goes wrong for relative coordinates and rounding errors... - // the closing line segment has zero-length. So stop before that one! - curve_endit = path_it->end_open(); - } - } - //Si la curva está cerrada calculamos el punto donde - //deveria estar el nodo BSpline de cierre/inicio de la curva - //en posible caso de que se cierre con una linea recta creando un nodo BSPline - - //Recorremos todos los segmentos menos el último - while ( curve_it2 != curve_endit ) - { - //previousPointAt3 = pointAt3; - //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida - SPCurve * in = new SPCurve(); - in->moveto(curve_it1->initialPoint()); - in->lineto(curve_it1->finalPoint()); - cubic = dynamic_cast(&*curve_it1); - if(cubic){ - SBasisIn = in->first_segment()->toSBasis(); - pointAt0 = in->first_segment()->initialPoint(); - pos1 = unify_weights/100; - pos2 = 1-unify_weights/100; - pointAt1 = SBasisIn.valueAt(pos1); - pointAt2 = SBasisIn.valueAt(pos2); - pointAt3 = in->first_segment()->finalPoint(); - }else{ - pointAt0 = in->first_segment()->initialPoint(); - pointAt1 = in->first_segment()->initialPoint(); - pointAt2 = in->first_segment()->finalPoint(); - pointAt3 = in->first_segment()->finalPoint(); - } - in->reset(); - delete in; - //Y hacemos lo propio con el path de salida - //nextPointAt0 = curveOut.valueAt(0); - SPCurve * out = new SPCurve(); - out->moveto(curve_it2->initialPoint()); - out->lineto(curve_it2->finalPoint()); - cubic = dynamic_cast(&*curve_it2); - if(cubic){ - SBasisOut = out->first_segment()->toSBasis(); - pos1 = unify_weights/100; - pos2 = 1-unify_weights/100; - nextPointAt1 = SBasisOut.valueAt(pos1); - nextPointAt2 = SBasisOut.valueAt(pos2); - nextPointAt3 = (*cubic)[3]; - }else{ - nextPointAt1 = out->first_segment()->initialPoint(); - nextPointAt2 = out->first_segment()->finalPoint(); - nextPointAt3 = out->first_segment()->finalPoint(); - } - out->reset(); - delete out; - //Y este hará de final de curva - SPCurve *curveHelper = new SPCurve(); - curveHelper->moveto(pointAt0); - curveHelper->curveto(pointAt1, pointAt2, pointAt3); - //añadimos la curva generada a la curva pricipal - nCurve->append_continuous(curveHelper, 0.0625); - curveHelper->reset(); - delete curveHelper; - //aumentamos los valores para el siguiente paso en el bucle - ++curve_it1; - ++curve_it2; - } - //Aberiguamos la ultima parte de la curva correspondiente al último segmento - SPCurve *curveHelper = new SPCurve(); - curveHelper->moveto(node); - //Si está cerrada la curva, la cerramos sobre el valor guardado previamente - //Si no finalizamos en el punto final - Geom::Point startNode(0,0); - startNode = path_it->begin()->initialPoint(); - curveHelper->curveto(nextPointAt1, nextPointAt2, nextPointAt3); - nCurve->append_continuous(curveHelper, 0.0625); - nCurve->move_endpoints(startNode,nextPointAt3); - curveHelper->reset(); - delete curveHelper; - //y cerramos la curva - if (path_it->closed()) { - nCurve->closepath_current(); - } - curve->append(nCurve,false); - nCurve->reset(); - delete nCurve; + SPDesktop *desktop = inkscape_active_desktop(); // TODO: Is there a better method to find the item's desktop? + Inkscape::Selection *selection = sp_desktop_selection(desktop); + for (GSList *items = (GSList *) selection->itemList(); + items != NULL; + items = items->next) { + if (SP_IS_LPE_ITEM(items->data) && sp_lpe_item_has_path_effect(items->data)){ + PathEffectList effect_list = sp_lpe_item_get_effect_list(SP_LPE_ITEM(_path)); + lpe_bsp = dynamic_cast( effect_list.front()->lpeobject->get_lpe()); + if(lpe_bsp) + LPEBSpline::updateHandles((SPItem *) items->data,value); + } +} +void +LPEBSpline::updateHandles(SPItem * item,int value){ + + Inkscape::XML::Node *newitem = item->getRepr(); + Inkscape::XML::Node *path = sp_repr_lookup_child(newitem,"svg:path", -1); //unlimited search depth + if ( path != NULL ){ + gchar const *svgd = path->attribute("d"); } - return curve->get_pathvector(); + + SPCurve *original = new SPCurve(); + original = (SPPath *)item->original_curve(); + LPEBSpline::doEffect(original,value); + gchar *str = sp_svg_write_path( original->get_pathvector() ); + g_assert( str != NULL ); + path->setAttribute ("inkscaspe:original-d", str); + item->updateRepr(); } }; //namespace LivePathEffect diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index 27c79f040..501b1fdaf 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -23,6 +23,12 @@ public: virtual LPEPathFlashType pathFlashType() const { return SUPPRESS_FLASH; } virtual void doEffect(SPCurve * curve); + + virtual void doEffect(SPCurve * curve, int value); + + virtual void updateAllHandles(int value); + + virtual void updateHandles(SPItem * item , int value); private: ScalarParam unify_weights; diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index 8615721b0..30414842d 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -128,7 +128,12 @@ ScalarParam::param_newWidget() { Inkscape::UI::Widget::RegisteredScalar *rsu = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalar( param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc() ) ); - + //BSpline + lpe_bsp = dynamic_cast(param_effect->get_lpe()); + if(lpe_bsp){ + lpe_bsp->updateAllHandles(value/100); + } + //BSpline End rsu->setValue(value); rsu->setDigits(digits); rsu->setIncrements(inc_step, inc_page); -- cgit v1.2.3 From 732618cd7d6159ee47cc0dd8b86cf07790e3e724 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 17 Mar 2013 13:29:02 +0100 Subject: Working with widjets (bzr r11950.1.56) --- src/common-context.h | 4 +++ src/composite-undo-stack-observer.h | 2 +- src/desktop.h | 2 +- src/display/cairo-utils.cpp | 10 +++--- src/display/canvas-axonomgrid.h | 2 +- src/display/guideline.h | 2 +- src/display/nr-filter-diffuselighting.h | 8 ++--- src/display/nr-filter-flood.h | 2 +- src/display/nr-filter-specularlighting.h | 8 ++--- src/display/nr-style.h | 3 +- src/display/nr-svgfonts.cpp | 3 ++ src/display/nr-svgfonts.h | 4 +-- src/display/sp-ctrlcurve.h | 2 +- src/document-subset.h | 2 +- src/dom/events.h | 1 + src/dropper-context.cpp | 1 + src/dropper-context.h | 3 ++ src/dyna-draw-context.h | 3 ++ src/eraser-context.h | 3 ++ src/event-context.h | 2 +- src/extension/internal/cairo-render-context.h | 6 ++-- src/extension/internal/cairo-renderer.h | 2 +- src/extension/internal/pdfinput/pdf-input.cpp | 1 - src/extension/internal/pdfinput/svg-builder.h | 6 ++-- src/file.cpp | 3 ++ src/file.h | 2 +- src/filter-chemistry.h | 2 +- src/filters/blend.h | 2 ++ src/filters/colormatrix.h | 2 ++ src/filters/componenttransfer-funcnode.h | 6 +++- src/filters/componenttransfer.h | 2 ++ src/filters/composite.h | 2 ++ src/filters/convolvematrix.h | 2 ++ src/filters/diffuselighting.h | 4 ++- src/filters/displacementmap.h | 2 ++ src/filters/distantlight.h | 4 +++ src/filters/flood.h | 2 ++ src/filters/gaussian-blur.h | 4 ++- src/filters/image.h | 2 ++ src/filters/merge.h | 2 ++ src/filters/mergenode.h | 3 ++ src/filters/morphology.h | 2 ++ src/filters/offset.h | 2 ++ src/filters/pointlight.h | 6 ++++ src/filters/specularlighting.h | 4 ++- src/filters/spotlight.h | 6 ++++ src/filters/tile.h | 2 ++ src/filters/turbulence.h | 1 + src/flood-context.h | 3 ++ src/gradient-context.h | 3 ++ src/gradient-drag.h | 6 ++-- src/inkscape-private.h | 2 +- src/inkscape.cpp | 2 +- src/libgdl/Makefile_insert | 8 ----- src/libnrtype/Layout-TNG-Output.cpp | 1 + src/libnrtype/Layout-TNG.h | 2 +- src/libnrtype/font-lister.cpp | 1 + src/livarot/Path.h | 10 +++--- src/livarot/Shape.h | 6 ++-- src/live_effects/lpe-bspline.cpp | 48 ++++++++++----------------- src/live_effects/lpe-bspline.h | 32 ++++++++---------- src/live_effects/lpe-recursiveskeleton.cpp | 3 +- src/lpe-tool-context.h | 3 ++ src/marker.cpp | 12 +++---- src/marker.h | 4 ++- src/measure-context.h | 3 ++ src/menus-skeleton.h | 2 ++ src/mesh-context.h | 3 ++ src/pixmaps/cursor-dropper.xpm | 38 +++++++++++++++++++++ src/rect-context.h | 3 ++ src/select-context.h | 2 ++ src/selection.cpp | 1 + src/seltrans-handles.h | 2 +- src/seltrans.h | 2 +- src/snap.cpp | 1 + src/sp-clippath.h | 2 +- src/sp-desc.h | 3 ++ src/sp-filter-primitive.h | 2 ++ src/sp-filter.h | 2 +- src/sp-flowregion.cpp | 39 ++++++++++++---------- src/sp-font-face.cpp | 3 ++ src/sp-font-face.h | 2 ++ src/sp-font.cpp | 3 ++ src/sp-glyph-kerning.cpp | 2 ++ src/sp-glyph-kerning.h | 2 ++ src/sp-glyph.cpp | 2 ++ src/sp-glyph.h | 2 ++ src/sp-gradient.h | 4 +-- src/sp-image.h | 3 ++ src/sp-item.h | 4 +-- src/sp-linear-gradient-fns.h | 2 +- src/sp-mask.h | 4 ++- src/sp-metadata.cpp | 10 +++--- src/sp-metadata.h | 3 ++ src/sp-missing-glyph.cpp | 3 ++ src/sp-missing-glyph.h | 2 ++ src/sp-object-group.cpp | 4 ++- src/sp-object-repr.cpp | 14 +++++--- src/sp-offset.h | 2 ++ src/sp-pattern.h | 3 +- src/sp-polyline.cpp | 11 +++--- src/sp-radial-gradient-fns.h | 2 +- src/sp-rect.h | 3 ++ src/sp-spiral.h | 3 ++ src/sp-star.h | 5 +++ src/sp-stop.h | 1 + src/sp-switch.h | 2 +- src/sp-symbol.cpp | 33 +++++++----------- src/sp-symbol.h | 3 ++ src/sp-title.h | 3 ++ src/sp-tref.h | 3 ++ src/sp-use.h | 2 ++ src/spiral-context.h | 3 ++ src/splivarot.cpp | 36 ++++++++++++++++++-- src/spray-context.h | 3 ++ src/star-context.h | 3 ++ src/style.cpp | 2 +- src/style.h | 4 ++- src/svg-view-widget.h | 2 ++ src/svg-view.h | 2 +- src/svg/svg-color.h | 2 +- src/text-context.h | 2 ++ src/text-editing.cpp | 2 +- src/trace/siox.cpp | 4 +-- src/tweak-context.h | 3 ++ src/ui/dialog/dialog-manager.cpp | 7 ++++ src/ui/dialog/document-properties.cpp | 2 ++ src/ui/dialog/export.cpp | 26 +++------------ src/ui/dialog/export.h | 19 +++++++---- src/ui/dialog/fill-and-stroke.cpp | 15 --------- src/ui/dialog/find.cpp | 4 --- src/ui/dialog/find.h | 6 +--- src/ui/dialog/glyphs.h | 2 +- src/ui/dialog/icon-preview.cpp | 4 --- src/ui/dialog/input.cpp | 2 -- src/ui/dialog/layer-properties.h | 6 ++-- src/ui/dialog/object-properties.cpp | 6 ---- src/ui/dialog/object-properties.h | 10 ------ src/ui/dialog/svg-fonts-dialog.cpp | 4 +++ src/ui/dialog/svg-fonts-dialog.h | 4 +-- src/ui/dialog/text-edit.cpp | 1 - src/ui/dialog/text-edit.h | 2 +- src/ui/dialog/tracedialog.cpp | 1 - src/ui/dialog/xml-tree.h | 2 +- src/ui/tool/control-point.cpp | 2 +- src/ui/tool/node-tool.h | 3 ++ src/ui/tool/path-manipulator.h | 2 +- src/ui/widget/entry.cpp | 2 -- src/ui/widget/entry.h | 6 ++-- src/ui/widget/frame.h | 8 +++-- src/ui/widget/registered-widget.h | 2 +- src/ui/widget/selected-style.h | 2 +- src/ui/widget/style-swatch.h | 2 +- src/undo-stack-observer.h | 2 +- src/widgets/gradient-vector.h | 2 +- src/widgets/paint-selector.h | 2 +- src/widgets/swatch-selector.h | 6 ++-- src/xml/composite-node-observer.h | 2 +- src/zoom-context.h | 3 ++ 159 files changed, 483 insertions(+), 301 deletions(-) create mode 100644 src/pixmaps/cursor-dropper.xpm (limited to 'src') diff --git a/src/common-context.h b/src/common-context.h index 8903be391..ae0f398b2 100644 --- a/src/common-context.h +++ b/src/common-context.h @@ -29,8 +29,12 @@ #define SP_IS_COMMON_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_COMMON_CONTEXT)) #define SP_IS_COMMON_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_COMMON_CONTEXT)) +class SPCommonContext; +class SPCommonContextClass; + #define SAMPLING_SIZE 8 /* fixme: ?? */ + struct SPCommonContext : public SPEventContext { /** accumulated shape which ultimately goes in svg:path */ SPCurve *accumulated; diff --git a/src/composite-undo-stack-observer.h b/src/composite-undo-stack-observer.h index 669c39a86..c34ab7234 100644 --- a/src/composite-undo-stack-observer.h +++ b/src/composite-undo-stack-observer.h @@ -18,7 +18,7 @@ namespace Inkscape { -struct Event; +class Event; /** * Aggregates UndoStackObservers for management and triggering in an SPDocument's undo/redo diff --git a/src/desktop.h b/src/desktop.h index 56de56c65..d8d4e151d 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -77,7 +77,7 @@ namespace Inkscape { } namespace View { - struct EditWidgetInterface; + class EditWidgetInterface; } } namespace Whiteboard { diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp index fc56c7b26..a55b05fe3 100644 --- a/src/display/cairo-utils.cpp +++ b/src/display/cairo-utils.cpp @@ -655,8 +655,8 @@ int ink_cairo_surface_srgb_to_linear(cairo_surface_t *surface) cairo_surface_flush(surface); int width = cairo_image_surface_get_width(surface); int height = cairo_image_surface_get_height(surface); - // int stride = cairo_image_surface_get_stride(surface); - // unsigned char *data = cairo_image_surface_get_data(surface); + int stride = cairo_image_surface_get_stride(surface); + unsigned char *data = cairo_image_surface_get_data(surface); ink_cairo_surface_filter( surface, surface, SurfaceSrgbToLinear() ); @@ -698,8 +698,8 @@ int ink_cairo_surface_linear_to_srgb(cairo_surface_t *surface) cairo_surface_flush(surface); int width = cairo_image_surface_get_width(surface); int height = cairo_image_surface_get_height(surface); - // int stride = cairo_image_surface_get_stride(surface); - // unsigned char *data = cairo_image_surface_get_data(surface); + int stride = cairo_image_surface_get_stride(surface); + unsigned char *data = cairo_image_surface_get_data(surface); ink_cairo_surface_filter( surface, surface, SurfaceLinearToSrgb() ); @@ -888,4 +888,4 @@ guint32 argb32_from_rgba(guint32 in) fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/display/canvas-axonomgrid.h b/src/display/canvas-axonomgrid.h index f58ea3aca..0e24d3f56 100644 --- a/src/display/canvas-axonomgrid.h +++ b/src/display/canvas-axonomgrid.h @@ -12,7 +12,7 @@ #include "line-snapper.h" #include "canvas-grid.h" -struct SPCanvasBuf; +class SPCanvasBuf; class SPDesktop; struct SPNamedView; diff --git a/src/display/guideline.h b/src/display/guideline.h index 2d9a87d9b..164244c46 100644 --- a/src/display/guideline.h +++ b/src/display/guideline.h @@ -21,7 +21,7 @@ #define SP_GUIDELINE(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_GUIDELINE, SPGuideLine)) #define SP_IS_GUIDELINE(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_GUIDELINE)) -struct SPCtrlPoint; +class SPCtrlPoint; struct SPGuideLine { SPCanvasItem item; diff --git a/src/display/nr-filter-diffuselighting.h b/src/display/nr-filter-diffuselighting.h index 15cc8e1ff..315bf9f48 100644 --- a/src/display/nr-filter-diffuselighting.h +++ b/src/display/nr-filter-diffuselighting.h @@ -19,10 +19,10 @@ #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" -struct SPFeDistantLight; -struct SPFePointLight; -struct SPFeSpotLight; -struct SVGICCColor; +class SPFeDistantLight; +class SPFePointLight; +class SPFeSpotLight; +class SVGICCColor; namespace Inkscape { namespace Filters { diff --git a/src/display/nr-filter-flood.h b/src/display/nr-filter-flood.h index 9a968047d..8568502ff 100644 --- a/src/display/nr-filter-flood.h +++ b/src/display/nr-filter-flood.h @@ -14,7 +14,7 @@ #include "display/nr-filter-primitive.h" -struct SVGICCColor; +class SVGICCColor; namespace Inkscape { namespace Filters { diff --git a/src/display/nr-filter-specularlighting.h b/src/display/nr-filter-specularlighting.h index 0d1c0644f..4f8c2d112 100644 --- a/src/display/nr-filter-specularlighting.h +++ b/src/display/nr-filter-specularlighting.h @@ -17,10 +17,10 @@ #include "display/nr-light-types.h" #include "display/nr-filter-primitive.h" -struct SPFeDistantLight; -struct SPFePointLight; -struct SPFeSpotLight; -struct SVGICCColor; +class SPFeDistantLight; +class SPFePointLight; +class SPFeSpotLight; +class SVGICCColor; namespace Inkscape { namespace Filters { diff --git a/src/display/nr-style.h b/src/display/nr-style.h index 80547c43e..597ae7a2c 100644 --- a/src/display/nr-style.h +++ b/src/display/nr-style.h @@ -16,7 +16,8 @@ #include <2geom/rect.h> #include "color.h" -struct SPPaintServer; +class SPColor; +class SPPaintServer; struct SPStyle; namespace Inkscape { diff --git a/src/display/nr-svgfonts.cpp b/src/display/nr-svgfonts.cpp index 84b4bd080..0d1b56d54 100644 --- a/src/display/nr-svgfonts.cpp +++ b/src/display/nr-svgfonts.cpp @@ -1,4 +1,5 @@ #include "config.h" +#ifdef ENABLE_SVG_FONTS /* * SVGFonts rendering implementation * @@ -355,6 +356,8 @@ void SvgFont::refresh(){ this->userfont = NULL; } +#endif //#ifdef ENABLE_SVG_FONTS + /* Local Variables: mode:c++ diff --git a/src/display/nr-svgfonts.h b/src/display/nr-svgfonts.h index 1101f93f2..6138e2fbb 100644 --- a/src/display/nr-svgfonts.h +++ b/src/display/nr-svgfonts.h @@ -18,8 +18,8 @@ class SvgFont; struct SPFont; -struct SPGlyph; -struct SPMissingGlyph; +class SPGlyph; +class SPMissingGlyph; struct _GdkEventExpose; typedef _GdkEventExpose GdkEventExpose; diff --git a/src/display/sp-ctrlcurve.h b/src/display/sp-ctrlcurve.h index 90936185c..15de20161 100644 --- a/src/display/sp-ctrlcurve.h +++ b/src/display/sp-ctrlcurve.h @@ -17,7 +17,7 @@ #include "display/sp-ctrlline.h" -class SPItem; +struct SPItem; #define SP_TYPE_CTRLCURVE (SPCtrlCurve::getType()) #define SP_CTRLCURVE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_CTRLCURVE, SPCtrlCurve)) diff --git a/src/document-subset.h b/src/document-subset.h index 298b7872d..5f87e6429 100644 --- a/src/document-subset.h +++ b/src/document-subset.h @@ -51,7 +51,7 @@ private: void _remove(SPObject *obj, bool subtree); - struct Relations; + class Relations; Relations *_relations; }; diff --git a/src/dom/events.h b/src/dom/events.h index e62c5d420..59d83afcf 100644 --- a/src/dom/events.h +++ b/src/dom/events.h @@ -66,6 +66,7 @@ typedef dom::NodePtr NodePtr ; //forward declarations +class Event; class EventTarget; class EventListener; class DocumentEvent; diff --git a/src/dropper-context.cpp b/src/dropper-context.cpp index d41e4059d..66dcf4ab9 100644 --- a/src/dropper-context.cpp +++ b/src/dropper-context.cpp @@ -39,6 +39,7 @@ #include "document.h" #include "document-undo.h" +#include "pixmaps/cursor-dropper.xpm" #include "pixmaps/cursor-dropper-f.xpm" #include "pixmaps/cursor-dropper-s.xpm" diff --git a/src/dropper-context.h b/src/dropper-context.h index be4b543ae..68ae3df07 100644 --- a/src/dropper-context.h +++ b/src/dropper-context.h @@ -20,6 +20,9 @@ G_BEGIN_DECLS #define SP_DROPPER_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_DROPPER_CONTEXT, SPDropperContext)) #define SP_IS_DROPPER_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_DROPPER_CONTEXT)) +class SPDropperContext; +class SPDropperContextClass; + enum { SP_DROPPER_PICK_VISIBLE, SP_DROPPER_PICK_ACTUAL diff --git a/src/dyna-draw-context.h b/src/dyna-draw-context.h index 8509e450b..af63bf653 100644 --- a/src/dyna-draw-context.h +++ b/src/dyna-draw-context.h @@ -27,6 +27,9 @@ #define SP_IS_DYNA_DRAW_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_DYNA_DRAW_CONTEXT)) #define SP_IS_DYNA_DRAW_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_DYNA_DRAW_CONTEXT)) +class SPDynaDrawContext; +class SPDynaDrawContextClass; + #define DDC_MIN_PRESSURE 0.0 #define DDC_MAX_PRESSURE 1.0 #define DDC_DEFAULT_PRESSURE 1.0 diff --git a/src/eraser-context.h b/src/eraser-context.h index bc4268aef..7c147c32f 100644 --- a/src/eraser-context.h +++ b/src/eraser-context.h @@ -29,6 +29,9 @@ G_BEGIN_DECLS #define SP_IS_ERASER_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_ERASER_CONTEXT)) #define SP_IS_ERASER_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_ERASER_CONTEXT)) +class SPEraserContext; +class SPEraserContextClass; + #define ERC_MIN_PRESSURE 0.0 #define ERC_MAX_PRESSURE 1.0 #define ERC_DEFAULT_PRESSURE 1.0 diff --git a/src/event-context.h b/src/event-context.h index e97a8ad8f..9936aa668 100644 --- a/src/event-context.h +++ b/src/event-context.h @@ -19,7 +19,7 @@ #include "2geom/forward.h" #include "preferences.h" -class GrDrag; +struct GrDrag; class SPDesktop; class SPItem; class ShapeEditor; diff --git a/src/extension/internal/cairo-render-context.h b/src/extension/internal/cairo-render-context.h index 8829940c6..94c7bb294 100644 --- a/src/extension/internal/cairo-render-context.h +++ b/src/extension/internal/cairo-render-context.h @@ -29,7 +29,7 @@ #include class SPClipPath; -struct SPMask; +class SPMask; namespace Inkscape { namespace Extension { @@ -37,8 +37,8 @@ namespace Internal { class CairoRenderer; class CairoRenderContext; -struct CairoRenderState; -struct CairoGlyphInfo; +class CairoRenderState; +class CairoGlyphInfo; // Holds info for rendering a glyph struct CairoGlyphInfo { diff --git a/src/extension/internal/cairo-renderer.h b/src/extension/internal/cairo-renderer.h index c1482d82e..db3068fed 100644 --- a/src/extension/internal/cairo-renderer.h +++ b/src/extension/internal/cairo-renderer.h @@ -28,7 +28,7 @@ #include class SPClipPath; -struct SPMask; +class SPMask; namespace Inkscape { namespace Extension { diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp index b04c9782f..531cda20a 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -32,7 +32,6 @@ #endif #include -#include #include #include #include diff --git a/src/extension/internal/pdfinput/svg-builder.h b/src/extension/internal/pdfinput/svg-builder.h index 610822959..46cddd73b 100644 --- a/src/extension/internal/pdfinput/svg-builder.h +++ b/src/extension/internal/pdfinput/svg-builder.h @@ -31,10 +31,10 @@ namespace Inkscape { #include "CharTypes.h" class GooString; class Function; -class GfxState; -struct GfxColor; +struct GfxState; +class GfxColor; class GfxColorSpace; -struct GfxRGB; +class GfxRGB; class GfxPath; class GfxPattern; class GfxTilingPattern; diff --git a/src/file.cpp b/src/file.cpp index 5737f0a8a..97087c1a1 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1124,6 +1124,9 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, prevent_id_clashes(doc, in_doc); + SPObject *in_defs = in_doc->getDefs(); + Inkscape::XML::Node *last_def = in_defs->getRepr()->lastChild(); + SPCSSAttr *style = sp_css_attr_from_object(doc->getRoot()); // Count the number of top-level items in the imported document. diff --git a/src/file.h b/src/file.h index b173ca58c..b8e15bf3e 100644 --- a/src/file.h +++ b/src/file.h @@ -24,7 +24,7 @@ class SPObject; namespace Inkscape { namespace Extension { - class Extension; + struct Extension; } } diff --git a/src/filter-chemistry.h b/src/filter-chemistry.h index b00e33bcc..751885ad2 100644 --- a/src/filter-chemistry.h +++ b/src/filter-chemistry.h @@ -20,7 +20,7 @@ class SPDocument; struct SPFilter; -struct SPFilterPrimitive; +class SPFilterPrimitive; class SPItem; class SPObject; diff --git a/src/filters/blend.h b/src/filters/blend.h index 5d65c92fc..e7fc410e7 100644 --- a/src/filters/blend.h +++ b/src/filters/blend.h @@ -22,6 +22,8 @@ #define SP_IS_FEBLEND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEBLEND)) #define SP_IS_FEBLEND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEBLEND)) +class SPFeBlendClass; + struct SPFeBlend : public SPFilterPrimitive { Inkscape::Filters::FilterBlendMode blend_mode; int in2; diff --git a/src/filters/colormatrix.h b/src/filters/colormatrix.h index 558f01070..8eb750ac1 100644 --- a/src/filters/colormatrix.h +++ b/src/filters/colormatrix.h @@ -21,6 +21,8 @@ #define SP_IS_FECOLORMATRIX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FECOLORMATRIX)) #define SP_IS_FECOLORMATRIX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FECOLORMATRIX)) +class SPFeColorMatrixClass; + struct SPFeColorMatrix : public SPFilterPrimitive { Inkscape::Filters::FilterColorMatrixType type; gdouble value; diff --git a/src/filters/componenttransfer-funcnode.h b/src/filters/componenttransfer-funcnode.h index ae1b2f8bb..d81e50577 100644 --- a/src/filters/componenttransfer-funcnode.h +++ b/src/filters/componenttransfer-funcnode.h @@ -34,6 +34,11 @@ #define SP_IS_FEFUNCNODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEFUNCNODE)) +/* Component Transfer funcNode class */ + +class SPFeFuncNode; +class SPFeFuncNodeClass; + struct SPFeFuncNode : public SPObject { Inkscape::Filters::FilterComponentTransferType type; std::vector tableValues; @@ -44,7 +49,6 @@ struct SPFeFuncNode : public SPObject { double offset; }; -/* Component Transfer funcNode class */ struct SPFeFuncNodeClass { SPObjectClass parent_class; }; diff --git a/src/filters/componenttransfer.h b/src/filters/componenttransfer.h index deb6fb740..2df64009f 100644 --- a/src/filters/componenttransfer.h +++ b/src/filters/componenttransfer.h @@ -24,6 +24,8 @@ namespace Filters { class FilterComponentTransfer; } } +class SPFeComponentTransferClass; + struct SPFeComponentTransfer : public SPFilterPrimitive { Inkscape::Filters::FilterComponentTransfer *renderer; }; diff --git a/src/filters/composite.h b/src/filters/composite.h index 4f2d1ff69..3eb62716f 100644 --- a/src/filters/composite.h +++ b/src/filters/composite.h @@ -32,6 +32,8 @@ enum FeCompositeOperator { COMPOSITE_ENDOPERATOR }; +class SPFeCompositeClass; + struct SPFeComposite : public SPFilterPrimitive { FeCompositeOperator composite_operator; double k1, k2, k3, k4; diff --git a/src/filters/convolvematrix.h b/src/filters/convolvematrix.h index cb2fbfb8d..4c5261e05 100644 --- a/src/filters/convolvematrix.h +++ b/src/filters/convolvematrix.h @@ -24,6 +24,8 @@ #define SP_IS_FECONVOLVEMATRIX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FECONVOLVEMATRIX)) #define SP_IS_FECONVOLVEMATRIX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FECONVOLVEMATRIX)) +class SPFeConvolveMatrixClass; + struct SPFeConvolveMatrix : public SPFilterPrimitive { NumberOptNumber order; std::vector kernelMatrix; diff --git a/src/filters/diffuselighting.h b/src/filters/diffuselighting.h index 1572385b9..99dccb394 100644 --- a/src/filters/diffuselighting.h +++ b/src/filters/diffuselighting.h @@ -21,13 +21,15 @@ #define SP_IS_FEDIFFUSELIGHTING(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEDIFFUSELIGHTING)) #define SP_IS_FEDIFFUSELIGHTING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEDIFFUSELIGHTING)) -struct SVGICCColor; +class SVGICCColor; namespace Inkscape { namespace Filters { class FilterDiffuseLighting; } } +class SPFeDiffuseLightingClass; + struct SPFeDiffuseLighting : public SPFilterPrimitive { gfloat surfaceScale; guint surfaceScale_set : 1; diff --git a/src/filters/displacementmap.h b/src/filters/displacementmap.h index 93dc86d27..6232f0937 100644 --- a/src/filters/displacementmap.h +++ b/src/filters/displacementmap.h @@ -28,6 +28,8 @@ enum FilterDisplacementMapChannelSelector { DISPLACEMENTMAP_CHANNEL_ENDTYPE }; +class SPFeDisplacementMapClass; + struct SPFeDisplacementMap : public SPFilterPrimitive { int in2; double scale; diff --git a/src/filters/distantlight.h b/src/filters/distantlight.h index b1febf5d3..a68746334 100644 --- a/src/filters/distantlight.h +++ b/src/filters/distantlight.h @@ -25,6 +25,10 @@ /* Distant light class */ + +class SPFeDistantLight; +class SPFeDistantLightClass; + struct SPFeDistantLight : public SPObject { /** azimuth attribute */ diff --git a/src/filters/flood.h b/src/filters/flood.h index ab9f061d6..d60321689 100644 --- a/src/filters/flood.h +++ b/src/filters/flood.h @@ -23,6 +23,8 @@ G_BEGIN_DECLS #define SP_IS_FEFLOOD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEFLOOD)) #define SP_IS_FEFLOOD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEFLOOD)) +class SPFeFloodClass; + struct SPFeFlood : public SPFilterPrimitive { guint32 color; SVGICCColor *icc; diff --git a/src/filters/gaussian-blur.h b/src/filters/gaussian-blur.h index 8929627ba..417f8a6f4 100644 --- a/src/filters/gaussian-blur.h +++ b/src/filters/gaussian-blur.h @@ -21,12 +21,14 @@ #define SP_IS_GAUSSIANBLUR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_GAUSSIANBLUR)) #define SP_IS_GAUSSIANBLUR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_GAUSSIANBLUR)) +/* GaussianBlur base class */ +class SPGaussianBlurClass; + struct SPGaussianBlur : public SPFilterPrimitive { /** stdDeviation attribute */ NumberOptNumber stdDeviation; }; -/* GaussianBlur base class */ struct SPGaussianBlurClass { SPFilterPrimitiveClass parent_class; }; diff --git a/src/filters/image.h b/src/filters/image.h index a96e650b7..b4081602a 100644 --- a/src/filters/image.h +++ b/src/filters/image.h @@ -24,6 +24,8 @@ #define SP_IS_FEIMAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEIMAGE)) #define SP_IS_FEIMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEIMAGE)) +class SPFeImageClass; + struct SPFeImage : public SPFilterPrimitive { gchar *href; diff --git a/src/filters/merge.h b/src/filters/merge.h index 40a9bb848..3243073ca 100644 --- a/src/filters/merge.h +++ b/src/filters/merge.h @@ -18,6 +18,8 @@ #define SP_IS_FEMERGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEMERGE)) #define SP_IS_FEMERGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEMERGE)) +class SPFeMergeClass; + struct SPFeMerge : public SPFilterPrimitive { }; diff --git a/src/filters/mergenode.h b/src/filters/mergenode.h index edb35faec..8352632a6 100644 --- a/src/filters/mergenode.h +++ b/src/filters/mergenode.h @@ -21,6 +21,9 @@ #define SP_FEMERGENODE(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_FEMERGENODE, SPFeMergeNode)) #define SP_IS_FEMERGENODE(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_FEMERGENODE)) +class SPFeMergeNode; +class SPFeMergeNodeClass; + struct SPFeMergeNode : public SPObject { int input; }; diff --git a/src/filters/morphology.h b/src/filters/morphology.h index 9084d1b94..b7005a3d9 100644 --- a/src/filters/morphology.h +++ b/src/filters/morphology.h @@ -22,6 +22,8 @@ #define SP_IS_FEMORPHOLOGY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEMORPHOLOGY)) #define SP_IS_FEMORPHOLOGY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEMORPHOLOGY)) +class SPFeMorphologyClass; + struct SPFeMorphology : public SPFilterPrimitive { Inkscape::Filters::FilterMorphologyOperator Operator; NumberOptNumber radius; diff --git a/src/filters/offset.h b/src/filters/offset.h index 08954a8e4..dba7ed8ef 100644 --- a/src/filters/offset.h +++ b/src/filters/offset.h @@ -20,6 +20,8 @@ #define SP_IS_FEOFFSET(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEOFFSET)) #define SP_IS_FEOFFSET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEOFFSET)) +class SPFeOffsetClass; + struct SPFeOffset : public SPFilterPrimitive { double dx, dy; }; diff --git a/src/filters/pointlight.h b/src/filters/pointlight.h index 3ec5d5791..c0b272021 100644 --- a/src/filters/pointlight.h +++ b/src/filters/pointlight.h @@ -23,6 +23,12 @@ #define SP_IS_FEPOINTLIGHT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEPOINTLIGHT)) #define SP_IS_FEPOINTLIGHT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEPOINTLIGHT)) +/* Distant light class */ + + +class SPFePointLight; +class SPFePointLightClass; + struct SPFePointLight : public SPObject { /** x coordinate of the light source */ diff --git a/src/filters/specularlighting.h b/src/filters/specularlighting.h index 4b31eb4c4..44bd98c6c 100644 --- a/src/filters/specularlighting.h +++ b/src/filters/specularlighting.h @@ -23,7 +23,7 @@ #define SP_IS_FESPECULARLIGHTING(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FESPECULARLIGHTING)) #define SP_IS_FESPECULARLIGHTING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FESPECULARLIGHTING)) -struct SVGICCColor; +class SVGICCColor; namespace Inkscape { namespace Filters { @@ -31,6 +31,8 @@ class FilterSpecularLighting; } } +class SPFeSpecularLightingClass; + struct SPFeSpecularLighting : public SPFilterPrimitive { gfloat surfaceScale; guint surfaceScale_set : 1; diff --git a/src/filters/spotlight.h b/src/filters/spotlight.h index 1750ca95b..6e2463c08 100644 --- a/src/filters/spotlight.h +++ b/src/filters/spotlight.h @@ -23,6 +23,12 @@ #define SP_IS_FESPOTLIGHT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FESPOTLIGHT)) #define SP_IS_FESPOTLIGHT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FESPOTLIGHT)) +/* Distant light class */ + + +class SPFeSpotLight; +class SPFeSpotLightClass; + struct SPFeSpotLight : public SPObject { /** x coordinate of the light source */ diff --git a/src/filters/tile.h b/src/filters/tile.h index 48a552fc8..a376a6e10 100644 --- a/src/filters/tile.h +++ b/src/filters/tile.h @@ -21,6 +21,8 @@ #define SP_IS_FETILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FETILE)) /* FeTile base class */ +class SPFeTileClass; + struct SPFeTile : public SPFilterPrimitive { }; diff --git a/src/filters/turbulence.h b/src/filters/turbulence.h index bad8315c1..cbc4fb082 100644 --- a/src/filters/turbulence.h +++ b/src/filters/turbulence.h @@ -24,6 +24,7 @@ #define SP_IS_FETURBULENCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FETURBULENCE)) /* FeTurbulence base class */ +class SPFeTurbulenceClass; struct SPFeTurbulence : public SPFilterPrimitive { /** TURBULENCE ATTRIBUTES HERE */ diff --git a/src/flood-context.h b/src/flood-context.h index 3e81cd01e..0cab0f7c5 100644 --- a/src/flood-context.h +++ b/src/flood-context.h @@ -29,6 +29,9 @@ #define FLOOD_COLOR_CHANNEL_B 4 #define FLOOD_COLOR_CHANNEL_A 8 +class SPFloodContext; +class SPFloodContextClass; + struct SPFloodContext : public SPEventContext { SPItem *item; diff --git a/src/gradient-context.h b/src/gradient-context.h index 464b95ad4..9c08677ae 100644 --- a/src/gradient-context.h +++ b/src/gradient-context.h @@ -25,6 +25,9 @@ #define SP_IS_GRADIENT_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_GRADIENT_CONTEXT)) #define SP_IS_GRADIENT_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_GRADIENT_CONTEXT)) +class SPGradientContext; +class SPGradientContextClass; + struct SPGradientContext : public SPEventContext { Geom::Point origin; diff --git a/src/gradient-drag.h b/src/gradient-drag.h index 2a2465590..cd76d8a3c 100644 --- a/src/gradient-drag.h +++ b/src/gradient-drag.h @@ -33,12 +33,12 @@ struct SPKnot; class SPDesktop; class SPCSSAttr; -struct SPLinearGradient; +class SPLinearGradient; struct SPMeshGradient; class SPItem; class SPObject; -struct SPRadialGradient; -struct SPStop; +class SPRadialGradient; +class SPStop; namespace Inkscape { class Selection; diff --git a/src/inkscape-private.h b/src/inkscape-private.h index 09bcef12b..470a1f5bd 100644 --- a/src/inkscape-private.h +++ b/src/inkscape-private.h @@ -22,7 +22,7 @@ #include "inkscape.h" -struct SPColor; +class SPColor; namespace Inkscape { class Selection; } GType inkscape_get_type (void); diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 491acd73e..449220357 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -91,7 +91,7 @@ enum { ################################*/ namespace Inkscape { -struct ApplicationClass; +class ApplicationClass; } static void inkscape_class_init (Inkscape::ApplicationClass *klass); diff --git a/src/libgdl/Makefile_insert b/src/libgdl/Makefile_insert index e92223f0b..3f5228a20 100644 --- a/src/libgdl/Makefile_insert +++ b/src/libgdl/Makefile_insert @@ -44,14 +44,6 @@ libgdl/all: libgdl/libgdl.a libgdl/clean: rm -f libgdl/libgdl.a $(libgdl_gdl_a_OBJECTS) -if CC_W_NO_SUPPORTED -# Suppress some non-critical warnings for libgdl. We will drop our forked copy -# of GDL once we upgrade to Gtk+ 3 so it's more important to minimise the number -# of changes we make to GDL than to fix these minor issues in trunk. - -libgdl_libgdl_a_CFLAGS = -Wno-unused-parameter -Wno-sign-compare -Wno-unused-variable -Wno-unused-but-set-variable $(AM_CFLAGS) -endif - libgdl_libgdl_a_SOURCES = \ libgdl/gdl-dock-object.h \ libgdl/gdl-dock-master.h \ diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index 0f853c681..1d086b57b 100644 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -26,6 +26,7 @@ namespace Inkscape { namespace Extension { namespace Internal { class CairoRenderContext; + class CairoGlyphInfo; } } } diff --git a/src/libnrtype/Layout-TNG.h b/src/libnrtype/Layout-TNG.h index 0f5f08a53..488a974ea 100644 --- a/src/libnrtype/Layout-TNG.h +++ b/src/libnrtype/Layout-TNG.h @@ -36,7 +36,7 @@ using Inkscape::Extension::Internal::CairoRenderContext; struct SPStyle; class Shape; -struct SPPrintContext; +class SPPrintContext; class SVGLength; class Path; class SPCurve; diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp index 90900baba..712c17915 100644 --- a/src/libnrtype/font-lister.cpp +++ b/src/libnrtype/font-lister.cpp @@ -2,6 +2,7 @@ # include #endif +#include #include #include #include diff --git a/src/livarot/Path.h b/src/livarot/Path.h index a109298a2..cd939bf7d 100644 --- a/src/livarot/Path.h +++ b/src/livarot/Path.h @@ -14,11 +14,11 @@ #include <2geom/point.h> struct PathDescr; -struct PathDescrLineTo; -struct PathDescrArcTo; -struct PathDescrCubicTo; -struct PathDescrBezierTo; -struct PathDescrIntermBezierTo; +class PathDescrLineTo; +class PathDescrArcTo; +class PathDescrCubicTo; +class PathDescrBezierTo; +class PathDescrIntermBezierTo; struct SPStyle; diff --git a/src/livarot/Shape.h b/src/livarot/Shape.h index dcd172da2..1a804a48c 100644 --- a/src/livarot/Shape.h +++ b/src/livarot/Shape.h @@ -21,9 +21,9 @@ class Path; class FloatLigne; -class SweepTree; -class SweepTreeList; -class SweepEventQueue; +struct SweepTree; +struct SweepTreeList; +struct SweepEventQueue; enum { tweak_mode_grow, diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 785c545b5..b1e40655d 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -39,13 +39,18 @@ using Inkscape::DocumentUndo; - namespace Inkscape { namespace LivePathEffect { LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) : Effect(lpeobject) { + Glib::ustring title = Glib::ustring(_("Ignore cusp nodes")); + Glib::ustring tip = Glib::ustring(_("Ignore cusp nodes")); + LPEBSpline::Gtk::Widget *noCusp = new LPEBSpline::newCheckButton(title,tip); + title = Glib::ustring(_("Unify weights:")); + tip = Glib::ustring(_("Percent of the with for all poinrs")); + LPEBSpline::Gtk::Widget *scal = new LPEBSpline::newScalar(title,tip); } LPEBSpline::~LPEBSpline() @@ -239,25 +244,20 @@ Gtk::Widget * LPEBSpline::newWidget() { Gtk::VBox * vbox = dynamic_cast(Effect::newWidget()); - Glib::ustring title = Glib::ustring(_("Ignore cusp nodes")); - Glib::ustring tip = Glib::ustring(_("Ignore cusp nodes")); - this->setNoCuspWidget(this->newCheckButton(title)); - title = Glib::ustring(_("Unify weights:")); - tip = Glib::ustring(_("Percent of the with for all poinrs")); - this->setScalWidget(this->newScalar(title,tip)); vbox->set_border_width(5); - vbox->pack_start(*this->getNoCuspWidget(), true, true,2); - vbox->pack_start(*this->getScalWidget(),true,true,(guint)2); + vbox->pack_start(&noCusp,true,true,(guint)2); + vbox->pack_start(&scal, true, true,2); return dynamic_cast (vbox); } Gtk::Widget * LPEBSpline::newScalar(Glib::ustring title, Glib::ustring tip) { - Inkscape::UI::Widget::Scalar * scal = Gtk::manage( new Inkscape::UI::Widget::Scalar(title, tip, 2)); - scal->setRange(0.01, 100.); - scal->setIncrements(1., 5.); + scal = Gtk::manage( new Inkscape::UI::Widget::Scalar(title, tip)); scal->setValue(33.); + scal->setDigits(2); + scal->setIncrements(1., 5.); + scal->setRange(0, 100.); scal->setProgrammatically = false; scal->addSlider(); scal->signal_value_changed().connect(sigc::mem_fun (*this,&LPEBSpline::updateAllHandles)); @@ -265,20 +265,17 @@ LPEBSpline::newScalar(Glib::ustring title, Glib::ustring tip) } Gtk::Widget * -LPEBSpline::newCheckButton(Glib::ustring title) +LPEBSpline::newCheckButton(Glib::ustring title, Glib::ustring tip) { - Gtk::CheckButton * noCusp = Gtk::manage( new Gtk::CheckButton(title,true)); - noCusp->set_alignment(1.0,0.0); + noCusp = Gtk::manage( new Gtk::CheckButton(title,tip)); return dynamic_cast(noCusp); } void LPEBSpline::updateAllHandles() { - Inkscape::UI::Widget::Scalar * scal = dynamic_cast(this->getScalWidget()); - double value = scal->getValue()/100; - Gtk::CheckButton * noCusp = dynamic_cast(this->getNoCuspWidget()); - bool noCuspValue = noCusp->get_active(); + double value = scal->setValue(33.); + bool noCusp = false; SPDesktop *desktop = inkscape_active_desktop(); // TODO: Is there a better method to find the item's desktop? Inkscape::Selection *selection = sp_desktop_selection(desktop); for (GSList *items = (GSList *) selection->itemList(); @@ -291,7 +288,7 @@ LPEBSpline::updateAllHandles() SPItem *item = (SPItem *) items->data; SPPath *path = SP_PATH(item); SPCurve *curve = path->get_curve_for_edit(); - LPEBSpline::doBSplineFromWidget(curve,value,noCuspValue); + LPEBSpline::doBSplineFromWidget(curve,value,noCusp); gchar *str = sp_svg_write_path(curve->get_pathvector()); path->getRepr()->setAttribute("inkscape:original-d", str); g_free(str); @@ -313,8 +310,6 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double value , bool noCusp) // Make copy of old path as it is changed during processing Geom::PathVector const original_pathv = curve->get_pathvector(); curve->reset(); - using Geom::X; - using Geom::Y; //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { @@ -368,20 +363,16 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double value , bool noCusp) if(cubic){ if(!noCusp || (*cubic)[1] != in->first_segment()->initialPoint()) pointAt1 = SBasisIn.valueAt(value); - pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); else pointAt1 = in->first_segment()->initialPoint(); if(!noCusp || (*cubic)[2] != in->first_segment()->finalPoint()) pointAt2 = SBasisIn.valueAt(1-value); - pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); else pointAt2 = in->first_segment()->finalPoint(); }else{ if(!noCusp){ pointAt1 = SBasisIn.valueAt(value); - pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); pointAt2 = SBasisIn.valueAt(1-value); - pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); }else{ pointAt1 = in->first_segment()->initialPoint(); pointAt2 = in->first_segment()->finalPoint(); @@ -400,20 +391,16 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double value , bool noCusp) if(cubic){ if(!noCusp || (*cubic)[1] != out->first_segment()->initialPoint()) nextPointAt1 = SBasisOut.valueAt(value); - nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); else nextPointAt1 = out->first_segment()->initialPoint(); if(!noCusp || (*cubic)[2] != out->first_segment()->finalPoint()) nextPointAt2 = SBasisOut.valueAt(1-value); - nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); else nextPointAt2 = out->first_segment()->finalPoint(); }else{ if(!noCusp){ nextPointAt1 = SBasisOut.valueAt(value); - nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); nextPointAt2 = SBasisOut.valueAt(1-value); - nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); }else{ nextPointAt1 = out->first_segment()->initialPoint(); nextPointAt2 = out->first_segment()->finalPoint(); @@ -422,7 +409,6 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double value , bool noCusp) nextPointAt3 = out->first_segment()->finalPoint(); out->reset(); delete out; - //La curva BSpline se forma calculando el centro del segmanto de unión //de el punto situado en las 2/3 partes de el segmento de entrada //con el punto situado en la posición 1/3 del segmento de salida diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index a0f1554d0..dbe0789f2 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -8,7 +8,9 @@ */ #include "live_effects/effect.h" - +#include "live_effects/parameter/parameter.h" +#include "ui/widget/scalar.h" +#include namespace Inkscape { namespace LivePathEffect { @@ -16,13 +18,6 @@ namespace LivePathEffect { class LPEBSpline : public Effect { - -private: - double scalWidget; - bool noCuspWidget; - LPEBSpline(const LPEBSpline&); - LPEBSpline& operator=(const LPEBSpline&); - public: LPEBSpline(LivePathEffectObject *lpeobject); virtual ~LPEBSpline(); @@ -35,22 +30,21 @@ public: virtual void updateAllHandles(); - virtual Gtk::Widget* newScalar(Glib::ustring title, Glib::ustring tip); + virtual void newScalar(Glib::ustring title, Glib::ustring tip); + + virtual void newCheckButton(Glib::ustring title, Glib::ustring tip); - virtual Gtk::Widget* newCheckButton(Glib::ustring title); virtual void doBSplineFromWidget(SPCurve * curve, double value, bool noCusp); - virtual double getScal(){return scal;}; - - virtual double setScal(double setScal){scal = setScal;}; - - virtual bool getNoCusp(){return noCusp;}; - - virtual bool setNoCusp(bool setNoCusp){noCusp = setNoCusp;}; - - virtual Gtk::Widget* newWidget(); + virtual Gtk::Widget * newWidget(); + +private: + Gtk::Widget * scal; + Gtk::Widget * noCusp; + LPEBSpline(const LPEBSpline&); + LPEBSpline& operator=(const LPEBSpline&); }; }; //namespace LivePathEffect diff --git a/src/live_effects/lpe-recursiveskeleton.cpp b/src/live_effects/lpe-recursiveskeleton.cpp index ac571d963..452139344 100644 --- a/src/live_effects/lpe-recursiveskeleton.cpp +++ b/src/live_effects/lpe-recursiveskeleton.cpp @@ -91,8 +91,7 @@ LPERecursiveSkeleton::doEffect_pwd2 (Geom::Piecewise > co double scaling = (uskeleton.domain().extent() - toffset)/pattBndsX->extent(); // TODO investigate why pattWidth is not being used: - // - Doesn't appear to have been used anywhere in bzr history (Alex V: 2013-03-16) - // double pattWidth = pattBndsX->extent() * scaling; + double pattWidth = pattBndsX->extent() * scaling; if (scaling != 1.0) { x*=scaling; diff --git a/src/lpe-tool-context.h b/src/lpe-tool-context.h index fb3a5d4e2..12e4b3838 100644 --- a/src/lpe-tool-context.h +++ b/src/lpe-tool-context.h @@ -24,6 +24,9 @@ #define SP_IS_LPETOOL_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_LPETOOL_CONTEXT)) #define SP_IS_LPETOOL_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_LPETOOL_CONTEXT)) +class SPLPEToolContext; +class SPLPEToolContextClass; + /* This is the list of subtools from which the toolbar of the LPETool is built automatically */ extern const int num_subtools; diff --git a/src/marker.cpp b/src/marker.cpp index 9717160ed..ba5cd4b05 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -324,13 +324,13 @@ static void sp_marker_update(SPObject *object, SPCtx *ctx, guint flags) // Now set up viewbox transformation // Determine actual viewbox in viewport coordinates - // double x = 0; - // double y = 0; + double x = 0; + double y = 0; double width = 0; double height = 0; if (marker->aspect_align == SP_ASPECT_NONE) { - // x = 0.0; - // y = 0.0; + x = 0.0; + y = 0.0; width = rctx.viewport.width(); height = rctx.viewport.height(); } else { @@ -343,7 +343,7 @@ static void sp_marker_update(SPObject *object, SPCtx *ctx, guint flags) height = (vb.height()) * scale; // Now place viewbox to requested position - /*switch (marker->aspect_align) { + switch (marker->aspect_align) { case SP_ASPECT_XMIN_YMIN: x = 0.0; y = 0.0; @@ -384,7 +384,7 @@ static void sp_marker_update(SPObject *object, SPCtx *ctx, guint flags) x = 0.0; y = 0.0; break; - }*/ + } } // TODO fixme: all that work is done to figure out x and y, which are just ignored. Check why. diff --git a/src/marker.h b/src/marker.h index 147fafeb8..e8d2dd9a1 100644 --- a/src/marker.h +++ b/src/marker.h @@ -22,7 +22,9 @@ #define SP_MARKER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_MARKER, SPMarker)) #define SP_IS_MARKER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_MARKER)) -struct SPMarkerView; +class SPMarker; +class SPMarkerClass; +class SPMarkerView; #include <2geom/rect.h> #include <2geom/affine.h> diff --git a/src/measure-context.h b/src/measure-context.h index b7673ad0d..baf74d30e 100644 --- a/src/measure-context.h +++ b/src/measure-context.h @@ -18,6 +18,9 @@ #define SP_MEASURE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_MEASURE_CONTEXT, SPMeasureContext)) #define SP_IS_MEASURE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_MEASURE_CONTEXT)) +class SPMeasureContext; +class SPMeasureContextClass; + struct SPMeasureContext { SPEventContext event_context; SPCanvasItem *grabbed; diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h index 694619089..868b606a4 100644 --- a/src/menus-skeleton.h +++ b/src/menus-skeleton.h @@ -252,7 +252,9 @@ static char const menus_skeleton[] = " \n" " \n" " \n" +#ifdef ENABLE_SVG_FONTS " \n" +#endif // ENABLE_SVG_FONTS " \n" " \n" " \n" diff --git a/src/mesh-context.h b/src/mesh-context.h index e5d06ec0a..ed93e404f 100644 --- a/src/mesh-context.h +++ b/src/mesh-context.h @@ -27,6 +27,9 @@ #define SP_IS_MESH_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_MESH_CONTEXT)) #define SP_IS_MESH_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_MESH_CONTEXT)) +class SPMeshContext; +class SPMeshContextClass; + struct SPMeshContext : public SPEventContext { Geom::Point origin; diff --git a/src/pixmaps/cursor-dropper.xpm b/src/pixmaps/cursor-dropper.xpm new file mode 100644 index 000000000..21f96edd0 --- /dev/null +++ b/src/pixmaps/cursor-dropper.xpm @@ -0,0 +1,38 @@ +/* XPM */ +static const char * cursor_dropper_xpm[] = { +"32 32 3 1", +" c None", +". c #FFFFFF", +"+ c #000000", +" ... ", +" .+. ", +" .+. ", +" .+. ", +".... .... ", +".+++ +++. ", +".... .... ", +" .+. ", +" .+. .... ", +" .+. .+++. ", +" ... .+..+. ", +" .++..+. ", +" .++..+. ", +" .++..+. ", +" .++..+. . ", +" .++..+.+. ", +" .++..+++. ", +" .++++.+. ", +" .++++.+.. ", +" .++++++.++. ", +" .++++++..+. ", +" ..+++++.+. ", +" .++++++. ", +" .+++++. ", +" .+++. ", +" ... ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/src/rect-context.h b/src/rect-context.h index 5b6c5373e..b6fbb6854 100644 --- a/src/rect-context.h +++ b/src/rect-context.h @@ -25,6 +25,9 @@ #define SP_IS_RECT_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_RECT_CONTEXT)) #define SP_IS_RECT_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_RECT_CONTEXT)) +class SPRectContext; +class SPRectContextClass; + struct SPRectContext : public SPEventContext { SPItem *item; Geom::Point center; diff --git a/src/select-context.h b/src/select-context.h index a6877f802..ce2039a2d 100644 --- a/src/select-context.h +++ b/src/select-context.h @@ -22,6 +22,8 @@ #define SP_IS_SELECT_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_SELECT_CONTEXT)) struct SPCanvasItem; +class SPSelectContext; +class SPSelectContextClass; namespace Inkscape { class MessageContext; diff --git a/src/selection.cpp b/src/selection.cpp index 564f1fdd3..72f50137c 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -418,6 +418,7 @@ Geom::OptRect Selection::documentBounds(SPItem::BBoxType type) const // will be returned; this is also the case in SelTrans::centerRequest() boost::optional Selection::center() const { GSList *items = (GSList *) const_cast(this)->itemList(); + Geom::Point center; if (items) { SPItem *first = reinterpret_cast(g_slist_last(items)->data); // from the first item in selection if (first->isCenterSet()) { // only if set explicitly diff --git a/src/seltrans-handles.h b/src/seltrans-handles.h index 14f50d784..f625ebd68 100644 --- a/src/seltrans-handles.h +++ b/src/seltrans-handles.h @@ -21,7 +21,7 @@ namespace Inkscape class SelTrans; } -struct SPSelTransHandle; +class SPSelTransHandle; // request handlers gboolean sp_sel_trans_scale_request(Inkscape::SelTrans *seltrans, diff --git a/src/seltrans.h b/src/seltrans.h index effc767e3..55c109ed7 100644 --- a/src/seltrans.h +++ b/src/seltrans.h @@ -30,7 +30,7 @@ struct SPKnot; class SPDesktop; struct SPCanvasItem; struct SPCtrlLine; -struct SPSelTransHandle; +class SPSelTransHandle; namespace Inkscape { diff --git a/src/snap.cpp b/src/snap.cpp index 15f24ef53..695424194 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -500,6 +500,7 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( /* The current best metric for the best transformation; lower is better, Geom::infinity() ** means that we haven't snapped anything. */ + Geom::Point best_scale_metric(Geom::infinity(), Geom::infinity()); Inkscape::SnappedPoint best_snapped_point; g_assert(best_snapped_point.getAlwaysSnap() == false); // Check initialization of snapped point g_assert(best_snapped_point.getAtIntersection() == false); diff --git a/src/sp-clippath.h b/src/sp-clippath.h index 17546c6d3..a77383c63 100644 --- a/src/sp-clippath.h +++ b/src/sp-clippath.h @@ -21,7 +21,7 @@ #define SP_IS_CLIPPATH(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_CLIPPATH)) #define SP_IS_CLIPPATH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_CLIPPATH)) -struct SPClipPathView; +class SPClipPathView; #include "sp-object-group.h" #include "uri-references.h" diff --git a/src/sp-desc.h b/src/sp-desc.h index 41ef08020..8c5a8a663 100644 --- a/src/sp-desc.h +++ b/src/sp-desc.h @@ -17,6 +17,9 @@ #define SP_TYPE_DESC (sp_desc_get_type ()) #define SP_IS_DESC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_DESC)) +class SPDesc; +class SPDescClass; + struct SPDesc : public SPObject { }; diff --git a/src/sp-filter-primitive.h b/src/sp-filter-primitive.h index f06df5611..60104047e 100644 --- a/src/sp-filter-primitive.h +++ b/src/sp-filter-primitive.h @@ -23,6 +23,8 @@ #define SP_IS_FILTER_PRIMITIVE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_FILTER_PRIMITIVE)) #define SP_IS_FILTER_PRIMITIVE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_FILTER_PRIMITIVE)) +class SPFilterPrimitive; +class SPFilterPrimitiveClass; namespace Inkscape { namespace Filters { class Filter; diff --git a/src/sp-filter.h b/src/sp-filter.h index 5afe47438..a3e7cd35c 100644 --- a/src/sp-filter.h +++ b/src/sp-filter.h @@ -36,7 +36,7 @@ class Filter; } } class SPFilterReference; -struct SPFilterPrimitive; +class SPFilterPrimitive; struct ltstr { bool operator()(const char* s1, const char* s2) const; diff --git a/src/sp-flowregion.cpp b/src/sp-flowregion.cpp index 627907cef..a8de68f9b 100644 --- a/src/sp-flowregion.cpp +++ b/src/sp-flowregion.cpp @@ -86,13 +86,15 @@ sp_flowregion_dispose(GObject *object) group->computed.~vector(); } -static void -sp_flowregion_child_added(SPObject *object, - Inkscape::XML::Node *child, - Inkscape::XML::Node *ref) +static void sp_flowregion_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { - SP_OBJECT_CLASS (sp_flowregion_parent_class)->child_added (object, child, ref); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + SP_ITEM(object); + + if (((SPObjectClass *) (sp_flowregion_parent_class))->child_added) { + (* ((SPObjectClass *) (sp_flowregion_parent_class))->child_added) (object, child, ref); + } + + object->requestModified(SP_OBJECT_MODIFIED_FLAG); } /* fixme: hide (Lauris) */ @@ -162,10 +164,10 @@ void SPFlowregion::UpdateComputed(void) } } -static void -sp_flowregion_modified(SPObject *object, - guint flags) +static void sp_flowregion_modified(SPObject *object, guint flags) { + SP_FLOWREGION(object); // ensure it is the proper type. + if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; } @@ -276,14 +278,15 @@ sp_flowregionexclude_dispose(GObject *object) } } -static void -sp_flowregionexclude_child_added(SPObject *object, - Inkscape::XML::Node *child, - Inkscape::XML::Node *ref) +static void sp_flowregionexclude_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { - SP_OBJECT_CLASS (sp_flowregionexclude_parent_class)->child_added (object, child, ref); + SP_ITEM(object); + + if (((SPObjectClass *) (sp_flowregionexclude_parent_class))->child_added) { + (* ((SPObjectClass *) (sp_flowregionexclude_parent_class))->child_added) (object, child, ref); + } - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + object->requestModified(SP_OBJECT_MODIFIED_FLAG); } /* fixme: hide (Lauris) */ @@ -351,10 +354,10 @@ void SPFlowregionExclude::UpdateComputed(void) } } -static void -sp_flowregionexclude_modified(SPObject *object, - guint flags) +static void sp_flowregionexclude_modified(SPObject *object, guint flags) { + SP_FLOWREGIONEXCLUDE(object); // Ensure it is the proper type + if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; } diff --git a/src/sp-font-face.cpp b/src/sp-font-face.cpp index 0a649b17f..4288a5d64 100644 --- a/src/sp-font-face.cpp +++ b/src/sp-font-face.cpp @@ -2,6 +2,8 @@ # include #endif +#ifdef ENABLE_SVG_FONTS + /* * SVG element implementation * @@ -847,6 +849,7 @@ static Inkscape::XML::Node *sp_fontface_write(SPObject *object, Inkscape::XML::D return repr; } +#endif //#ifdef ENABLE_SVG_FONTS /* Local Variables: mode:c++ diff --git a/src/sp-font-face.h b/src/sp-font-face.h index 968644556..57702b683 100644 --- a/src/sp-font-face.h +++ b/src/sp-font-face.h @@ -2,6 +2,7 @@ # include #endif +#ifdef ENABLE_SVG_FONTS #ifndef __SP_FONTFACE_H__ #define __SP_FONTFACE_H__ @@ -121,3 +122,4 @@ GType sp_fontface_get_type (void); G_END_DECLS #endif //#ifndef __SP_FONTFACE_H__ +#endif //#ifdef ENABLE_SVG_FONTS diff --git a/src/sp-font.cpp b/src/sp-font.cpp index a03890fc7..6ebbd5218 100644 --- a/src/sp-font.cpp +++ b/src/sp-font.cpp @@ -2,6 +2,8 @@ # include #endif +#ifdef ENABLE_SVG_FONTS + /* * SVG element implementation * @@ -248,6 +250,7 @@ static Inkscape::XML::Node *sp_font_write(SPObject *object, Inkscape::XML::Docum return repr; } +#endif //#ifdef ENABLE_SVG_FONTS /* Local Variables: mode:c++ diff --git a/src/sp-glyph-kerning.cpp b/src/sp-glyph-kerning.cpp index 10884fb81..652d965bb 100644 --- a/src/sp-glyph-kerning.cpp +++ b/src/sp-glyph-kerning.cpp @@ -2,6 +2,7 @@ # include #endif +#ifdef ENABLE_SVG_FONTS #define __SP_ANCHOR_C__ /* @@ -266,6 +267,7 @@ static Inkscape::XML::Node *sp_glyph_kerning_write(SPObject *object, Inkscape::X return repr; } +#endif //#ifdef ENABLE_SVG_FONTS /* Local Variables: mode:c++ diff --git a/src/sp-glyph-kerning.h b/src/sp-glyph-kerning.h index b7f733cad..ce9b4bb15 100644 --- a/src/sp-glyph-kerning.h +++ b/src/sp-glyph-kerning.h @@ -2,6 +2,7 @@ # include #endif +#ifdef ENABLE_SVG_FONTS #ifndef __SP_GLYPH_KERNING_H__ #define __SP_GLYPH_KERNING_H__ @@ -59,3 +60,4 @@ GType sp_glyph_kerning_h_get_type (void); GType sp_glyph_kerning_v_get_type (void); #endif //#ifndef __SP_GLYPH_KERNING_H__ +#endif //#ifdef ENABLE_SVG_FONTS diff --git a/src/sp-glyph.cpp b/src/sp-glyph.cpp index 0417ea8c1..e14ef8667 100644 --- a/src/sp-glyph.cpp +++ b/src/sp-glyph.cpp @@ -2,6 +2,7 @@ # include #endif +#ifdef ENABLE_SVG_FONTS #define __SP_GLYPH_C__ /* @@ -283,6 +284,7 @@ static Inkscape::XML::Node *sp_glyph_write(SPObject *object, Inkscape::XML::Docu return repr; } +#endif //#ifdef ENABLE_SVG_FONTS /* Local Variables: mode:c++ diff --git a/src/sp-glyph.h b/src/sp-glyph.h index 7556b0e25..316204c23 100644 --- a/src/sp-glyph.h +++ b/src/sp-glyph.h @@ -2,6 +2,7 @@ # include #endif +#ifdef ENABLE_SVG_FONTS #ifndef __SP_GLYPH_H__ #define __SP_GLYPH_H__ @@ -57,3 +58,4 @@ struct SPGlyphClass { GType sp_glyph_get_type (void); #endif //#ifndef __SP_GLYPH_H__ +#endif //#ifdef ENABLE_SVG_FONTS diff --git a/src/sp-gradient.h b/src/sp-gradient.h index 57ffa5570..a21a413f4 100644 --- a/src/sp-gradient.h +++ b/src/sp-gradient.h @@ -27,8 +27,8 @@ #include #include -class SPGradientReference; -struct SPStop; +struct SPGradientReference; +class SPStop; #define SP_TYPE_GRADIENT (SPGradient::getType()) #define SP_GRADIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_GRADIENT, SPGradient)) diff --git a/src/sp-image.h b/src/sp-image.h index d6fc82a59..c657d0a2f 100644 --- a/src/sp-image.h +++ b/src/sp-image.h @@ -20,6 +20,9 @@ #define SP_IS_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_IMAGE)) #define SP_IS_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_IMAGE)) +class SPImage; +class SPImageClass; + /* SPImage */ #include diff --git a/src/sp-item.h b/src/sp-item.h index e65ffc829..a3ba1dbe2 100644 --- a/src/sp-item.h +++ b/src/sp-item.h @@ -28,8 +28,8 @@ #include "snap-candidate.h" class SPGuideConstraint; -class SPClipPathReference; -class SPMaskReference; +struct SPClipPathReference; +struct SPMaskReference; class SPAvoidRef; struct SPPrintContext; diff --git a/src/sp-linear-gradient-fns.h b/src/sp-linear-gradient-fns.h index 14e575ebe..1bdf0b89e 100644 --- a/src/sp-linear-gradient-fns.h +++ b/src/sp-linear-gradient-fns.h @@ -14,7 +14,7 @@ class Node; } } -struct SPLinearGradient; +class SPLinearGradient; #define SP_TYPE_LINEARGRADIENT (sp_lineargradient_get_type()) #define SP_LINEARGRADIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_LINEARGRADIENT, SPLinearGradient)) diff --git a/src/sp-mask.h b/src/sp-mask.h index 97cf95ae1..e249e0c76 100644 --- a/src/sp-mask.h +++ b/src/sp-mask.h @@ -24,7 +24,9 @@ #define SP_IS_MASK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_MASK)) #define SP_IS_MASK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_MASK)) -struct SPMaskView; +class SPMask; +class SPMaskClass; +class SPMaskView; namespace Inkscape { diff --git a/src/sp-metadata.cpp b/src/sp-metadata.cpp index 79953b708..9978d0a3a 100644 --- a/src/sp-metadata.cpp +++ b/src/sp-metadata.cpp @@ -116,17 +116,15 @@ static void sp_metadata_release(SPObject *object) /** * Sets a specific value in the SPMetadata. */ -static void -sp_metadata_set(SPObject *object, - unsigned int key, - const gchar *value) +static void sp_metadata_set(SPObject *object, unsigned int key, const gchar *value) { debug("0x%08x %s(%u): '%s'",(unsigned int)object, sp_attribute_name(key),key,value); + SP_METADATA(object); // ensures the object is of the proper type. // see if any parents need this value - if (SP_OBJECT_CLASS(sp_metadata_parent_class)->set) { - SP_OBJECT_CLASS(sp_metadata_parent_class)->set(object, key, value); + if (reinterpret_cast(sp_metadata_parent_class)->set) { + reinterpret_cast(sp_metadata_parent_class)->set(object, key, value); } } diff --git a/src/sp-metadata.h b/src/sp-metadata.h index 454fd8d18..82b7c4fc5 100644 --- a/src/sp-metadata.h +++ b/src/sp-metadata.h @@ -21,6 +21,9 @@ #define SP_METADATA(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_METADATA, SPMetadata)) #define SP_IS_METADATA(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_METADATA)) +class SPMetadata; +class SPMetadataClass; + struct SPMetadata : public SPObject { }; diff --git a/src/sp-missing-glyph.cpp b/src/sp-missing-glyph.cpp index 911c9be92..bdf993e5b 100644 --- a/src/sp-missing-glyph.cpp +++ b/src/sp-missing-glyph.cpp @@ -2,6 +2,8 @@ # include #endif +#ifdef ENABLE_SVG_FONTS + /* * SVG element implementation * @@ -162,6 +164,7 @@ static Inkscape::XML::Node *sp_missing_glyph_write(SPObject *object, Inkscape::X return repr; } +#endif //#ifdef ENABLE_SVG_FONTS /* Local Variables: mode:c++ diff --git a/src/sp-missing-glyph.h b/src/sp-missing-glyph.h index 7930df513..0b3f74360 100644 --- a/src/sp-missing-glyph.h +++ b/src/sp-missing-glyph.h @@ -2,6 +2,7 @@ # include #endif +#ifdef ENABLE_SVG_FONTS #ifndef __SP_MISSING_GLYPH_H__ #define __SP_MISSING_GLYPH_H__ @@ -39,3 +40,4 @@ struct SPMissingGlyphClass { GType sp_missing_glyph_get_type (void); #endif //#ifndef __SP_MISSING_GLYPH_H__ +#endif //#ifdef ENABLE_SVG_FONTS diff --git a/src/sp-object-group.cpp b/src/sp-object-group.cpp index e2b601ab9..5158ec70a 100644 --- a/src/sp-object-group.cpp +++ b/src/sp-object-group.cpp @@ -93,6 +93,8 @@ sp_objectgroup_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) { + SP_OBJECTGROUP(object); // Ensure we have the right type of SPObject + if (flags & SP_OBJECT_WRITE_BUILD) { if (!repr) { repr = xml_doc->createElement("svg:g"); @@ -116,7 +118,7 @@ sp_objectgroup_write(SPObject *object, } if ((SP_OBJECT_CLASS(sp_objectgroup_parent_class))->write) { - SP_OBJECT_CLASS(sp_objectgroup_parent_class)->write(object, xml_doc, repr, flags); + (SP_OBJECT_CLASS(sp_objectgroup_parent_class))->write(object, xml_doc, repr, flags); } return repr; diff --git a/src/sp-object-repr.cpp b/src/sp-object-repr.cpp index eba38ec67..cd332cd34 100644 --- a/src/sp-object-repr.cpp +++ b/src/sp-object-repr.cpp @@ -48,11 +48,13 @@ #include "sp-script.h" #include "config.h" -#include "sp-font.h" -#include "sp-font-face.h" -#include "sp-glyph.h" -#include "sp-missing-glyph.h" -#include "sp-glyph-kerning.h" +#ifdef ENABLE_SVG_FONTS + #include "sp-font.h" + #include "sp-font-face.h" + #include "sp-glyph.h" + #include "sp-missing-glyph.h" + #include "sp-glyph-kerning.h" +#endif #include "sp-style-elem.h" #include "sp-switch.h" @@ -149,12 +151,14 @@ populate_dtables() { "svg:flowRegionExclude", SP_TYPE_FLOWREGIONEXCLUDE }, { "svg:flowRoot", SP_TYPE_FLOWTEXT }, { "svg:flowSpan", SP_TYPE_FLOWTSPAN }, +#ifdef ENABLE_SVG_FONTS { "svg:font", SP_TYPE_FONT }, { "svg:font-face", SP_TYPE_FONTFACE }, { "svg:glyph", SP_TYPE_GLYPH }, { "svg:missing-glyph", SP_TYPE_MISSING_GLYPH }, { "svg:hkern", SP_TYPE_HKERN }, { "svg:vkern", SP_TYPE_VKERN }, +#endif { "svg:g", SP_TYPE_GROUP }, { "svg:feBlend", SP_TYPE_FEBLEND }, { "svg:feColorMatrix", SP_TYPE_FECOLORMATRIX }, diff --git a/src/sp-offset.h b/src/sp-offset.h index 904f8607c..4e245f952 100644 --- a/src/sp-offset.h +++ b/src/sp-offset.h @@ -22,6 +22,8 @@ #define SP_IS_OFFSET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_OFFSET)) #define SP_IS_OFFSET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_OFFSET)) +class SPOffset; +class SPOffsetClass; class SPUseReference; /** diff --git a/src/sp-pattern.h b/src/sp-pattern.h index bcf8dd520..e0a7dce54 100644 --- a/src/sp-pattern.h +++ b/src/sp-pattern.h @@ -24,7 +24,8 @@ GType sp_pattern_get_type (void); -struct SPPattern; +class SPPattern; +class SPPatternClass; #include "svg/svg-length.h" #include "sp-paint-server.h" diff --git a/src/sp-polyline.cpp b/src/sp-polyline.cpp index 2922b66ed..e5d89a802 100644 --- a/src/sp-polyline.cpp +++ b/src/sp-polyline.cpp @@ -116,11 +116,10 @@ sp_polyline_set(SPObject *object, unsigned int key, const gchar *value) } static Inkscape::XML::Node* -sp_polyline_write(SPObject *object, - Inkscape::XML::Document *xml_doc, - Inkscape::XML::Node *repr, - guint flags) +sp_polyline_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + SP_POLYLINE(object); + if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:polyline"); } @@ -129,7 +128,9 @@ sp_polyline_write(SPObject *object, repr->mergeFrom(object->getRepr(), "id"); } - SP_OBJECT_CLASS(sp_polyline_parent_class)->write (object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_polyline_parent_class))->write) { + ((SPObjectClass *) (sp_polyline_parent_class))->write (object, xml_doc, repr, flags); + } return repr; } diff --git a/src/sp-radial-gradient-fns.h b/src/sp-radial-gradient-fns.h index 43ed7bf03..912508a33 100644 --- a/src/sp-radial-gradient-fns.h +++ b/src/sp-radial-gradient-fns.h @@ -13,7 +13,7 @@ class Node; } } -struct SPRadialGradient; +class SPRadialGradient; #define SP_TYPE_RADIALGRADIENT (sp_radialgradient_get_type()) #define SP_RADIALGRADIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_RADIALGRADIENT, SPRadialGradient)) diff --git a/src/sp-rect.h b/src/sp-rect.h index 1127889c1..5e518dcd7 100644 --- a/src/sp-rect.h +++ b/src/sp-rect.h @@ -26,6 +26,9 @@ G_BEGIN_DECLS #define SP_IS_RECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_RECT)) #define SP_IS_RECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_RECT)) +class SPRect; +class SPRectClass; + struct SPRect : public SPShape { SVGLength x; SVGLength y; diff --git a/src/sp-spiral.h b/src/sp-spiral.h index 64cb8521b..6da7c38a4 100644 --- a/src/sp-spiral.h +++ b/src/sp-spiral.h @@ -29,6 +29,9 @@ #define SP_IS_SPIRAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_SPIRAL)) #define SP_IS_SPIRAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_SPIRAL)) +class SPSpiral; +class SPSpiralClass; + /** * A spiral Shape. * diff --git a/src/sp-star.h b/src/sp-star.h index 888eeb8d2..bd271ccc0 100644 --- a/src/sp-star.h +++ b/src/sp-star.h @@ -16,12 +16,17 @@ #include "sp-polygon.h" + + #define SP_TYPE_STAR (sp_star_get_type ()) #define SP_STAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_STAR, SPStar)) #define SP_STAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_STAR, SPStarClass)) #define SP_IS_STAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_STAR)) #define SP_IS_STAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_STAR)) +class SPStar; +class SPStarClass; + typedef enum { SP_STAR_POINT_KNOT1, SP_STAR_POINT_KNOT2 diff --git a/src/sp-stop.h b/src/sp-stop.h index b82dd0b13..c3b1e2753 100644 --- a/src/sp-stop.h +++ b/src/sp-stop.h @@ -14,6 +14,7 @@ #include "color.h" class SPObjectClass; +class SPColor; struct SPStop; struct SPStopClass; diff --git a/src/sp-switch.h b/src/sp-switch.h index 24a204731..f0442f27b 100644 --- a/src/sp-switch.h +++ b/src/sp-switch.h @@ -35,7 +35,7 @@ public: CSwitch(SPGroup *group); virtual ~CSwitch(); - friend struct SPSwitch; + friend class SPSwitch; virtual void onChildAdded(Inkscape::XML::Node *child); virtual void onChildRemoved(Inkscape::XML::Node *child); diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 989a5b7f3..d4db403e3 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -307,19 +307,19 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) } } -static void -sp_symbol_modified(SPObject *object, - guint flags) +static void sp_symbol_modified(SPObject *object, guint flags) { - SP_OBJECT_CLASS(sp_symbol_parent_class)->modified (object, flags); + SP_SYMBOL(object); + + if (((SPObjectClass *) (sp_symbol_parent_class))->modified) { + (* ((SPObjectClass *) (sp_symbol_parent_class))->modified) (object, flags); + } } -static Inkscape::XML::Node * -sp_symbol_write(SPObject *object, - Inkscape::XML::Document *xml_doc, - Inkscape::XML::Node *repr, - guint flags) +static Inkscape::XML::Node *sp_symbol_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + SP_SYMBOL(object); + if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:symbol"); } @@ -330,7 +330,9 @@ sp_symbol_write(SPObject *object, //XML Tree being used directly here while it shouldn't be. repr->setAttribute("preserveAspectRatio", object->getRepr()->attribute("preserveAspectRatio")); - SP_OBJECT_CLASS(sp_symbol_parent_class)->write (object, xml_doc, repr, flags); + if (((SPObjectClass *) (sp_symbol_parent_class))->write) { + ((SPObjectClass *) (sp_symbol_parent_class))->write (object, xml_doc, repr, flags); + } return repr; } @@ -402,14 +404,3 @@ static void sp_symbol_print(SPItem *item, SPPrintContext *ctx) sp_print_release (ctx); } } - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/sp-symbol.h b/src/sp-symbol.h index 10d642e8b..59f343285 100644 --- a/src/sp-symbol.h +++ b/src/sp-symbol.h @@ -21,6 +21,9 @@ #define SP_SYMBOL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_SYMBOL, SPSymbol)) #define SP_IS_SYMBOL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_SYMBOL)) +class SPSymbol; +class SPSymbolClass; + #include <2geom/affine.h> #include "svg/svg-length.h" #include "enums.h" diff --git a/src/sp-title.h b/src/sp-title.h index d10d58188..a5f0a2fea 100644 --- a/src/sp-title.h +++ b/src/sp-title.h @@ -17,6 +17,9 @@ #define SP_TYPE_TITLE (sp_title_get_type ()) #define SP_IS_TITLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_TITLE)) +class SPTitle; +class SPTitleClass; + struct SPTitle : public SPObject { }; diff --git a/src/sp-tref.h b/src/sp-tref.h index 33a8138d1..cc80e48a8 100644 --- a/src/sp-tref.h +++ b/src/sp-tref.h @@ -28,6 +28,9 @@ #define SP_IS_TREF(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_TREF)) #define SP_IS_TREF_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_TREF)) +class SPTRef; +class SPTRef; + struct SPTRef : public SPItem { // Attributes that are used in the same way they would be in a tspan TextTagAttributes attributes; diff --git a/src/sp-use.h b/src/sp-use.h index 3dd0726aa..399f30a4c 100644 --- a/src/sp-use.h +++ b/src/sp-use.h @@ -25,6 +25,8 @@ #define SP_IS_USE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_USE)) #define SP_IS_USE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_USE)) +class SPUse; +class SPUseClass; class SPUseReference; struct SPUse : public SPItem { diff --git a/src/spiral-context.h b/src/spiral-context.h index 7f696dfa2..12c0b5d68 100644 --- a/src/spiral-context.h +++ b/src/spiral-context.h @@ -27,6 +27,9 @@ #define SP_IS_SPIRAL_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_SPIRAL_CONTEXT)) #define SP_IS_SPIRAL_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_SPIRAL_CONTEXT)) +class SPSpiralContext; +class SPSpiralContextClass; + struct SPSpiralContext : public SPEventContext { SPItem * item; Geom::Point center; diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 2015ffd27..061d32554 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -1369,18 +1369,48 @@ void sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool Inkscape::XML::Node *parent = item->getRepr()->parent(); float o_width = 0; + JoinType o_join = join_straight; + ButtType o_butt = butt_straight; + float o_miter = 0; { SPStyle *i_style = item->style; + int jointype = i_style->stroke_linejoin.value; + int captype = i_style->stroke_linecap.value; o_width = i_style->stroke_width.computed; + if (jointype == SP_STROKE_LINEJOIN_MITER) + { + o_join = join_pointy; + } + else if (jointype == SP_STROKE_LINEJOIN_ROUND) + { + o_join = join_round; + } + else + { + o_join = join_straight; + } + if (captype == SP_STROKE_LINECAP_SQUARE) + { + o_butt = butt_square; + } + else if (captype == SP_STROKE_LINECAP_ROUND) + { + o_butt = butt_round; + } + else + { + o_butt = butt_straight; + } + { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); o_width = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0, "px"); } - if (o_width < 0.01){ + if (o_width < 0.01) o_width = 0.01; - } + o_miter = i_style->stroke_miterlimit.value * o_width; } Path *orig = Path_for_item(item, true, false); @@ -1478,7 +1508,7 @@ void sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool // move to the saved position repr->setPosition(pos > 0 ? pos : 0); - SPItem *nitem = reinterpret_cast(sp_desktop_document(desktop)->getObjectByRepr(repr)); + SPItem *nitem = (SPItem *) sp_desktop_document(desktop)->getObjectByRepr(repr); if ( !updating ) { // delete original, apply the transform to the offset diff --git a/src/spray-context.h b/src/spray-context.h index 781bbcce8..64368c7a6 100644 --- a/src/spray-context.h +++ b/src/spray-context.h @@ -27,6 +27,9 @@ #define SP_IS_SPRAY_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_SPRAY_CONTEXT)) #define SP_IS_SPRAY_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_SPRAY_CONTEXT)) +class SPSprayContext; +class SPSprayContextClass; + namespace Inkscape { namespace UI { namespace Dialog { diff --git a/src/star-context.h b/src/star-context.h index 4daafb3e4..7bcb26c41 100644 --- a/src/star-context.h +++ b/src/star-context.h @@ -25,6 +25,9 @@ #define SP_IS_STAR_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_STAR_CONTEXT)) #define SP_IS_STAR_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_STAR_CONTEXT)) +class SPStarContext; +class SPStarContextClass; + struct SPStarContext : public SPEventContext { SPItem *item; Geom::Point center; diff --git a/src/style.cpp b/src/style.cpp index eef1c6ee5..650b08aea 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -63,7 +63,7 @@ using std::vector; #define SP_CSS_FONT_SIZE_DEFAULT 12.0; -struct SPStyleEnum; +class SPStyleEnum; /*######################### ## FORWARD DECLARATIONS diff --git a/src/style.h b/src/style.h index 0710f5c8e..1c8cb4774 100644 --- a/src/style.h +++ b/src/style.h @@ -134,6 +134,8 @@ struct SPILength { #define SP_STYLE_FILL_SERVER(s) ((const_cast (s))->getFillPaintServer()) #define SP_STYLE_STROKE_SERVER(s) ((const_cast (s))->getStrokePaintServer()) +class SVGICCColor; + /// Paint type internal to SPStyle. struct SPIPaint { unsigned set : 1; @@ -244,7 +246,7 @@ struct SPILengthOrNormal { float computed; }; -struct SPTextStyle; +class SPTextStyle; /// Stroke dash details. class NRVpathDash { diff --git a/src/svg-view-widget.h b/src/svg-view-widget.h index eab5be75b..d489ccbdd 100644 --- a/src/svg-view-widget.h +++ b/src/svg-view-widget.h @@ -15,6 +15,8 @@ #include "ui/view/view-widget.h" class SPDocument; +class SPSVGSPViewWidget; +class SPSVGSPViewWidgetClass; #define SP_TYPE_SVG_VIEW_WIDGET (sp_svg_view_widget_get_type ()) #define SP_SVG_VIEW_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_SVG_VIEW_WIDGET, SPSVGSPViewWidget)) diff --git a/src/svg-view.h b/src/svg-view.h index 89f38ad34..aaaa8a9a5 100644 --- a/src/svg-view.h +++ b/src/svg-view.h @@ -13,7 +13,7 @@ #include "ui/view/view.h" -struct SPCanvasGroup; +class SPCanvasGroup; struct SPCanvasItem; diff --git a/src/svg/svg-color.h b/src/svg/svg-color.h index b8e317e3b..d1c7bee03 100644 --- a/src/svg/svg-color.h +++ b/src/svg/svg-color.h @@ -3,7 +3,7 @@ #include -struct SVGICCColor; +class SVGICCColor; guint32 sp_svg_read_color(gchar const *str, unsigned int dfl); guint32 sp_svg_read_color(gchar const *str, gchar const **end_ptr, guint32 def); diff --git a/src/text-context.h b/src/text-context.h index a33c69e0a..9915583eb 100644 --- a/src/text-context.h +++ b/src/text-context.h @@ -30,6 +30,8 @@ #define SP_IS_TEXT_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_TEXT_CONTEXT)) struct SPCtrlLine; +class SPTextContext; +class SPTextContextClass; struct SPTextContext : public SPEventContext { diff --git a/src/text-editing.cpp b/src/text-editing.cpp index 401f56bb2..47b4d35ac 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -69,7 +69,7 @@ void te_update_layout_now_recursive(SPItem *item) if (SP_IS_GROUP(item)) { GSList *item_list = sp_item_group_item_list(SP_GROUP(item)); for(GSList* elem = item_list; elem; elem = elem->next) { - SPItem* list_item = static_cast(elem->data); + SPItem* list_item = (SPItem*) elem->data; te_update_layout_now_recursive(list_item); } g_slist_free(item_list); diff --git a/src/trace/siox.cpp b/src/trace/siox.cpp index 1a1426b83..9376fad66 100644 --- a/src/trace/siox.cpp +++ b/src/trace/siox.cpp @@ -591,7 +591,7 @@ bool SioxImage::writePPM(const std::string &fileName) if (!f) return false; - fprintf(f, "P6 %u %u 255\n", width, height); + fprintf(f, "P6 %d %d 255\n", width, height); for (unsigned int y=0 ; y); // registerFactory("PrintColorsPreviewDialog", &create); registerFactory("Script", &create); +#ifdef ENABLE_SVG_FONTS registerFactory("SvgFontsDialog", &create); +#endif registerFactory("Swatches", &create); registerFactory("Symbols", &create); registerFactory("TileDialog", &create); @@ -149,7 +154,9 @@ DialogManager::DialogManager() { registerFactory("ObjectProperties", &create); // registerFactory("PrintColorsPreviewDialog", &create); registerFactory("Script", &create); +#ifdef ENABLE_SVG_FONTS registerFactory("SvgFontsDialog", &create); +#endif registerFactory("Swatches", &create); registerFactory("Symbols", &create); registerFactory("TileDialog", &create); diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index d335fb303..045b34814 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -792,6 +792,8 @@ void DocumentProperties::build_scripting() _page_external_scripts->table().attach(_external_remove_btn, 2, 3, row, row + 1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0, 0, 0); #endif + row++; + //# Set up the External Scripts box _ExternalScriptsListStore = Gtk::ListStore::create(_ExternalScriptsListColumns); _ExternalScriptsList.set_model(_ExternalScriptsListStore); diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 086e52a6c..603786742 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -22,21 +22,14 @@ #include #include -#include +#include +#include +#include #include #include -#include -#include -#include #include -#if WITH_GTKMM_3_0 -# include -#else -# include -#endif -#include -#include - +#include +#include #ifdef WITH_GNOME_VFS # include // gnome_vfs_initialized #endif @@ -133,15 +126,6 @@ namespace Inkscape { namespace UI { namespace Dialog { -/** A list of strings that is used both in the preferences, and in the - data fields to describe the various values of \c selection_type. */ -static const char * selection_names[SELECTION_NUMBER_OF] = { - "page", "drawing", "selection", "custom"}; - -/** The names on the buttons for the various selection types. */ -static const char * selection_labels[SELECTION_NUMBER_OF] = { - N_("_Page"), N_("_Drawing"), N_("_Selection"), N_("_Custom")}; - Export::Export (void) : UI::Widget::Panel ("", "/dialogs/export/", SP_VERB_DIALOG_EXPORT), current_key(SELECTION_PAGE), diff --git a/src/ui/dialog/export.h b/src/ui/dialog/export.h index b10c98fd2..5dca9cfa5 100644 --- a/src/ui/dialog/export.h +++ b/src/ui/dialog/export.h @@ -14,12 +14,10 @@ #include #include - -#include #include #include -#include #include +#include #include "desktop.h" #include "ui/dialog/desktop-tracker.h" @@ -27,14 +25,11 @@ #include "ui/widget/button.h" #include "ui/widget/entry.h" -namespace Gtk { -class Dialog; -} - namespace Inkscape { namespace UI { namespace Dialog { + /** What type of button is being pressed */ enum selection_type { SELECTION_PAGE = 0, /**< Export the whole page */ @@ -44,6 +39,16 @@ enum selection_type { SELECTION_NUMBER_OF /**< A counter for the number of these guys */ }; +/** A list of strings that is used both in the preferences, and in the + data fields to describe the various values of \c selection_type. */ +static const char * selection_names[SELECTION_NUMBER_OF] = { + "page", "drawing", "selection", "custom"}; + +/** The names on the buttons for the various selection types. */ +static const char * selection_labels[SELECTION_NUMBER_OF] = { + N_("_Page"), N_("_Drawing"), N_("_Selection"), N_("_Custom")}; + + /** * A dialog widget to export to various image formats such as bitmap and png. * diff --git a/src/ui/dialog/fill-and-stroke.cpp b/src/ui/dialog/fill-and-stroke.cpp index 19b873d54..8de2da18b 100644 --- a/src/ui/dialog/fill-and-stroke.cpp +++ b/src/ui/dialog/fill-and-stroke.cpp @@ -132,24 +132,14 @@ void FillAndStroke::_layoutPageFill() { fillWdgt = manage(sp_fill_style_widget_new()); - -#if WITH_GTKMM_3_0 _page_fill->table().attach(*fillWdgt, 0, 0, 1, 1); -#else - _page_fill->table().attach(*fillWdgt, 0, 1, 0, 1); -#endif } void FillAndStroke::_layoutPageStrokePaint() { strokeWdgt = manage(sp_stroke_style_paint_widget_new()); - -#if WITH_GTKMM_3_0 _page_stroke_paint->table().attach(*strokeWdgt, 0, 0, 1, 1); -#else - _page_stroke_paint->table().attach(*strokeWdgt, 0, 1, 0, 1); -#endif } void @@ -158,12 +148,7 @@ FillAndStroke::_layoutPageStrokeStyle() //Gtk::Widget *strokeStyleWdgt = manage(Glib::wrap(sp_stroke_style_line_widget_new())); //Gtk::Widget *strokeStyleWdgt = static_cast(sp_stroke_style_line_widget_new()); strokeStyleWdgt = sp_stroke_style_line_widget_new(); - -#if WITH_GTKMM_3_0 _page_stroke_style->table().attach(*strokeStyleWdgt, 0, 0, 1, 1); -#else - _page_stroke_style->table().attach(*strokeStyleWdgt, 0, 1, 0, 1); -#endif } void diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index def7b5bdb..d3ce99b00 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -15,10 +15,7 @@ #endif #include "find.h" - -#include #include - #include "verbs.h" #include "message-stack.h" @@ -59,7 +56,6 @@ #include "xml/attribute-record.h" #include -#include namespace Inkscape { namespace UI { diff --git a/src/ui/dialog/find.h b/src/ui/dialog/find.h index 14d54b8d4..77a6c9d02 100644 --- a/src/ui/dialog/find.h +++ b/src/ui/dialog/find.h @@ -21,11 +21,7 @@ #include "ui/widget/entry.h" #include "ui/widget/frame.h" #include - -#include -#include -#include -#include +#include #include "desktop.h" #include "ui/dialog/desktop-tracker.h" diff --git a/src/ui/dialog/glyphs.h b/src/ui/dialog/glyphs.h index 3d0571244..6571af0a4 100644 --- a/src/ui/dialog/glyphs.h +++ b/src/ui/dialog/glyphs.h @@ -20,7 +20,7 @@ class Label; class ListStore; } -struct SPFontSelector; +class SPFontSelector; class font_instance; diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index 801ab2922..de213ca85 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -20,11 +20,7 @@ #include #include #include - #include -#include -#include - #include #include #include diff --git a/src/ui/dialog/input.cpp b/src/ui/dialog/input.cpp index 82e65435d..9c9f7faa3 100644 --- a/src/ui/dialog/input.cpp +++ b/src/ui/dialog/input.cpp @@ -17,9 +17,7 @@ #include #include - #include -#include #include #include #include diff --git a/src/ui/dialog/layer-properties.h b/src/ui/dialog/layer-properties.h index 0e2f8ed94..9de303f89 100644 --- a/src/ui/dialog/layer-properties.h +++ b/src/ui/dialog/layer-properties.h @@ -80,9 +80,9 @@ protected: void perform(LayerPropertiesDialog &dialog); }; - friend struct Rename; - friend struct Create; - friend struct Move; + friend class Rename; + friend class Create; + friend class Move; Strategy *_strategy; SPDesktop *_desktop; diff --git a/src/ui/dialog/object-properties.cpp b/src/ui/dialog/object-properties.cpp index 8a2b0299a..114204961 100644 --- a/src/ui/dialog/object-properties.cpp +++ b/src/ui/dialog/object-properties.cpp @@ -38,12 +38,6 @@ #include "sp-item.h" #include -#if WITH_GTKMM_3_0 -# include -#else -# include -#endif - namespace Inkscape { namespace UI { diff --git a/src/ui/dialog/object-properties.h b/src/ui/dialog/object-properties.h index 624a18246..b49293ea1 100644 --- a/src/ui/dialog/object-properties.h +++ b/src/ui/dialog/object-properties.h @@ -35,8 +35,6 @@ #include "ui/widget/panel.h" #include "ui/widget/frame.h" - -#include #include #include #include @@ -48,14 +46,6 @@ class SPAttributeTable; class SPDesktop; class SPItem; -namespace Gtk { -#if WITH_GTKMM_3_0 -class Grid; -#else -class Table; -#endif -} - namespace Inkscape { namespace UI { namespace Dialog { diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index bce63093d..0da39dd73 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -15,6 +15,8 @@ # include #endif +#ifdef ENABLE_SVG_FONTS + #include "svg-fonts-dialog.h" #include "document-private.h" #include "document-undo.h" @@ -943,6 +945,8 @@ SvgFontsDialog::~SvgFontsDialog(){} } // namespace UI } // namespace Inkscape +#endif //#ifdef ENABLE_SVG_FONTS + /* Local Variables: mode:c++ diff --git a/src/ui/dialog/svg-fonts-dialog.h b/src/ui/dialog/svg-fonts-dialog.h index 01f70654a..9be984820 100644 --- a/src/ui/dialog/svg-fonts-dialog.h +++ b/src/ui/dialog/svg-fonts-dialog.h @@ -34,8 +34,8 @@ class HScale; #endif } -struct SPGlyph; -struct SPGlyphKerning; +class SPGlyph; +class SPGlyphKerning; class SvgFont; class SvgFontDrawingArea : Gtk::DrawingArea{ diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp index 67c6578f9..a71227861 100644 --- a/src/ui/dialog/text-edit.cpp +++ b/src/ui/dialog/text-edit.cpp @@ -57,7 +57,6 @@ extern "C" { #include "widgets/icon.h" #include "widgets/font-selector.h" #include -#include #include "unit-constants.h" diff --git a/src/ui/dialog/text-edit.h b/src/ui/dialog/text-edit.h index f27fdfc87..3fdeea05d 100644 --- a/src/ui/dialog/text-edit.h +++ b/src/ui/dialog/text-edit.h @@ -30,7 +30,7 @@ #include "ui/dialog/desktop-tracker.h" class SPItem; -struct SPFontSelector; +class SPFontSelector; class font_instance; class SPCSSAttr; diff --git a/src/ui/dialog/tracedialog.cpp b/src/ui/dialog/tracedialog.cpp index bd467555e..1ad827a56 100644 --- a/src/ui/dialog/tracedialog.cpp +++ b/src/ui/dialog/tracedialog.cpp @@ -20,7 +20,6 @@ #include #include "ui/widget/spinbutton.h" #include "ui/widget/frame.h" -#include #include #include //for GTK_RESPONSE* types diff --git a/src/ui/dialog/xml-tree.h b/src/ui/dialog/xml-tree.h index 58ef3aef8..0a6e3a786 100644 --- a/src/ui/dialog/xml-tree.h +++ b/src/ui/dialog/xml-tree.h @@ -29,7 +29,7 @@ #include "message.h" class SPDesktop; -class SPObject; +struct SPObject; struct SPXMLViewAttrList; struct SPXMLViewContent; struct SPXMLViewTree; diff --git a/src/ui/tool/control-point.cpp b/src/ui/tool/control-point.cpp index 069dcc67b..8c4924f26 100644 --- a/src/ui/tool/control-point.cpp +++ b/src/ui/tool/control-point.cpp @@ -7,8 +7,8 @@ */ #include -#include #include +#include #include <2geom/point.h> #include "desktop.h" #include "desktop-handles.h" diff --git a/src/ui/tool/node-tool.h b/src/ui/tool/node-tool.h index bc5267bb2..49b1496d4 100644 --- a/src/ui/tool/node-tool.h +++ b/src/ui/tool/node-tool.h @@ -25,6 +25,9 @@ #define INK_IS_NODE_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INK_TYPE_NODE_TOOL)) #define INK_IS_NODE_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INK_TYPE_NODE_TOOL)) +class InkNodeTool; +class InkNodeToolClass; + namespace Inkscape { namespace Display { diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index 8bc097ed6..a235a3b05 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -22,7 +22,7 @@ struct SPCanvasItem; class SPCurve; -class SPPath; +struct SPPath; namespace Inkscape { namespace XML { class Node; } diff --git a/src/ui/widget/entry.cpp b/src/ui/widget/entry.cpp index 64d28119a..173e014d9 100644 --- a/src/ui/widget/entry.cpp +++ b/src/ui/widget/entry.cpp @@ -13,8 +13,6 @@ #include "entry.h" -#include - namespace Inkscape { namespace UI { namespace Widget { diff --git a/src/ui/widget/entry.h b/src/ui/widget/entry.h index de5cceadd..53b848fc9 100644 --- a/src/ui/widget/entry.h +++ b/src/ui/widget/entry.h @@ -11,10 +11,10 @@ #define INKSCAPE_UI_WIDGET_ENTRY__H #include "labelled.h" +#include -namespace Gtk { -class Entry; -} +#include +#include namespace Inkscape { namespace UI { diff --git a/src/ui/widget/frame.h b/src/ui/widget/frame.h index a04666651..cf736d8a1 100644 --- a/src/ui/widget/frame.h +++ b/src/ui/widget/frame.h @@ -10,9 +10,11 @@ #ifndef INKSCAPE_UI_WIDGET_FRAME_H #define INKSCAPE_UI_WIDGET_FRAME_H -#include -#include -#include +#include + +namespace Gtk { +class Frame; +} namespace Inkscape { namespace UI { diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h index fa35b815e..2a7843a51 100644 --- a/src/ui/widget/registered-widget.h +++ b/src/ui/widget/registered-widget.h @@ -32,7 +32,7 @@ #include -struct SPUnit; +class SPUnit; class SPDocument; namespace Gtk { diff --git a/src/ui/widget/selected-style.h b/src/ui/widget/selected-style.h index 9b78cb17f..6d5222429 100644 --- a/src/ui/widget/selected-style.h +++ b/src/ui/widget/selected-style.h @@ -40,7 +40,7 @@ #include "helper/units.h" class SPDesktop; -struct SPUnit; +class SPUnit; namespace Inkscape { namespace UI { diff --git a/src/ui/widget/style-swatch.h b/src/ui/widget/style-swatch.h index d7bab3732..2b9c32b2e 100644 --- a/src/ui/widget/style-swatch.h +++ b/src/ui/widget/style-swatch.h @@ -26,7 +26,7 @@ #include "button.h" #include "preferences.h" -struct SPUnit; +class SPUnit; struct SPStyle; class SPCSSAttr; diff --git a/src/undo-stack-observer.h b/src/undo-stack-observer.h index 1057ace8f..f4d67e841 100644 --- a/src/undo-stack-observer.h +++ b/src/undo-stack-observer.h @@ -14,7 +14,7 @@ namespace Inkscape { -struct Event; +class Event; /** * Observes changes made to the undo and redo stacks. diff --git a/src/widgets/gradient-vector.h b/src/widgets/gradient-vector.h index 6719691d1..1ed6c6c46 100644 --- a/src/widgets/gradient-vector.h +++ b/src/widgets/gradient-vector.h @@ -33,7 +33,7 @@ class SPDocument; class SPObject; class SPGradient; -struct SPStop; +class SPStop; struct SPGradientVectorSelector { GtkVBox vbox; diff --git a/src/widgets/paint-selector.h b/src/widgets/paint-selector.h index a66758434..d3b3f4116 100644 --- a/src/widgets/paint-selector.h +++ b/src/widgets/paint-selector.h @@ -22,7 +22,7 @@ class SPGradient; class SPDesktop; -struct SPPattern; +class SPPattern; struct SPStyle; #define SP_TYPE_PAINT_SELECTOR (sp_paint_selector_get_type ()) diff --git a/src/widgets/swatch-selector.h b/src/widgets/swatch-selector.h index 4b7aa483f..b97aac4f1 100644 --- a/src/widgets/swatch-selector.h +++ b/src/widgets/swatch-selector.h @@ -1,12 +1,14 @@ #ifndef SEEN_SP_SWATCH_SELECTOR_H #define SEEN_SP_SWATCH_SELECTOR_H + + #include class SPDocument; class SPGradient; -struct SPColorSelector; -struct SPGradientSelector; +class SPColorSelector; +class SPGradientSelector; namespace Inkscape { diff --git a/src/xml/composite-node-observer.h b/src/xml/composite-node-observer.h index 3e4b1673a..96825d607 100644 --- a/src/xml/composite-node-observer.h +++ b/src/xml/composite-node-observer.h @@ -23,7 +23,7 @@ namespace Inkscape { namespace XML { -struct NodeEventVector; +class NodeEventVector; /** * @brief An observer that relays notifications to multiple other observers diff --git a/src/zoom-context.h b/src/zoom-context.h index c09b5a1b3..e36dc3fbe 100644 --- a/src/zoom-context.h +++ b/src/zoom-context.h @@ -19,6 +19,9 @@ #define SP_ZOOM_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_ZOOM_CONTEXT, SPZoomContext)) #define SP_IS_ZOOM_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_ZOOM_CONTEXT)) +class SPZoomContext; +class SPZoomContextClass; + struct SPZoomContext { SPEventContext event_context; SPCanvasItem *grabbed; -- cgit v1.2.3 From a5fc5840c370d58f395b7b256a11fd11ef3a9a54 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 18 Mar 2013 02:53:59 +0100 Subject: working whith widgets (bzr r11950.1.57) --- src/live_effects/lpe-bspline.cpp | 94 +++++++++++++++++++++++++++++----------- src/live_effects/lpe-bspline.h | 47 +++++++++++++++----- src/ui/tool/node.cpp | 5 ++- src/ui/tool/node.h | 3 ++ src/ui/tool/path-manipulator.cpp | 16 +++++-- src/ui/tool/path-manipulator.h | 3 ++ 6 files changed, 127 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index b1e40655d..5d50eae87 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -31,7 +31,6 @@ #include "helper/geom-curves.h" #include "ui/widget/scalar.h" - // For handling un-continuous paths: #include "message-stack.h" #include "inkscape.h" @@ -42,15 +41,20 @@ using Inkscape::DocumentUndo; namespace Inkscape { namespace LivePathEffect { + LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) : Effect(lpeobject) { - Glib::ustring title = Glib::ustring(_("Ignore cusp nodes")); - Glib::ustring tip = Glib::ustring(_("Ignore cusp nodes")); - LPEBSpline::Gtk::Widget *noCusp = new LPEBSpline::newCheckButton(title,tip); - title = Glib::ustring(_("Unify weights:")); - tip = Glib::ustring(_("Percent of the with for all poinrs")); - LPEBSpline::Gtk::Widget *scal = new LPEBSpline::newScalar(title,tip); + Glib::ustring title = Glib::ustring(_("Unify weights:")); + Glib::ustring tip = Glib::ustring(_("Percent of the with for all poinrs")); + registerScal(title,tip); + title = Glib::ustring(_("Ignore cusp nodes")); + registerNoCusp(title); + title = Glib::ustring(_("Reset")); + registerReset(title); + title = Glib::ustring(_("CTRL handle steps:")); + tip = Glib::ustring(_("CTRL handle steps")); + registerStepsHandles(title,tip); } LPEBSpline::~LPEBSpline() @@ -243,39 +247,79 @@ LPEBSpline::doEffect(SPCurve * curve) Gtk::Widget * LPEBSpline::newWidget() { - Gtk::VBox * vbox = dynamic_cast(Effect::newWidget()); + Gtk::VBox * vbox = Gtk::manage( dynamic_cast(LPEBSpline::newWidget())); vbox->set_border_width(5); - vbox->pack_start(&noCusp,true,true,(guint)2); - vbox->pack_start(&scal, true, true,2); + vbox->pack_start(*noCusp,true,true,2); + vbox->pack_start(*scal, true, true,2); + vbox->pack_start(*reset, true, true,2); + vbox->pack_start(*stepsHandles, true, true,2); return dynamic_cast (vbox); } Gtk::Widget * -LPEBSpline::newScalar(Glib::ustring title, Glib::ustring tip) +LPEBSpline::newScal(Glib::ustring title, Glib::ustring tip) +{ + Inkscape::UI::Widget::Scalar *scalIn = Gtk::manage( new Inkscape::UI::Widget::Scalar(title, tip)); + scalIn->setRange(0, 100.); + scalIn->setDigits(2); + scalIn->setIncrements(1., 5.); + scalIn->setValue(33.33); + scalIn->setProgrammatically = false; + scalIn->addSlider(); + scalIn->signal_value_changed().connect(sigc::mem_fun (*this,&LPEBSpline::updateAllHandles)); + return dynamic_cast(scalIn); +} + +Gtk::Widget * +LPEBSpline::newNoCusp(Glib::ustring title) +{ + Gtk::CheckButton * noCuspIn = Gtk::manage( new Gtk::CheckButton(title,true)); + noCuspIn->set_alignment(0.0, 0.5); + return dynamic_cast(noCuspIn); +} + +Gtk::Widget * +LPEBSpline::newReset(Glib::ustring title) { - scal = Gtk::manage( new Inkscape::UI::Widget::Scalar(title, tip)); - scal->setValue(33.); - scal->setDigits(2); - scal->setIncrements(1., 5.); - scal->setRange(0, 100.); - scal->setProgrammatically = false; - scal->addSlider(); - scal->signal_value_changed().connect(sigc::mem_fun (*this,&LPEBSpline::updateAllHandles)); - return dynamic_cast(scal); + Gtk::Button * resetIn = Gtk::manage(new Gtk::Button(title)); + resetIn->signal_clicked().connect(sigc::mem_fun (*this,&LPEBSpline::resetHandles)); + resetIn->set_alignment(0.0, 0.5); + return dynamic_cast(resetIn); } Gtk::Widget * -LPEBSpline::newCheckButton(Glib::ustring title, Glib::ustring tip) +LPEBSpline::newStepsHandles(Glib::ustring title, Glib::ustring tip) { - noCusp = Gtk::manage( new Gtk::CheckButton(title,tip)); - return dynamic_cast(noCusp); + Inkscape::UI::Widget::Scalar *stepsIn = Gtk::manage( new Inkscape::UI::Widget::Scalar(title, tip)); + stepsIn->setRange(1, 10); + stepsIn->setDigits(0); + stepsIn->setIncrements(1.,1.); + stepsIn->setValue(2); + stepsIn->setProgrammatically = false; + stepsIn->signal_value_changed().connect(sigc::mem_fun (*this,&LPEBSpline::updateSteps)); + return dynamic_cast(stepsIn); +} + +void +LPEBSpline::resetHandles(){ + Inkscape::UI::Widget::Scalar * scalIn = dynamic_cast(scal); + scalIn->setValue(33.33); + updateAllHandles(); +} + +void +LPEBSpline::updateSteps(){ + Inkscape::UI::Widget::Scalar * stepsIn = dynamic_cast(stepsHandles); + updateStepsValue(stepsIn->getValue()); } void LPEBSpline::updateAllHandles() { - double value = scal->setValue(33.); - bool noCusp = false; + Inkscape::UI::Widget::Scalar * scalIn = dynamic_cast(scal); + double value = scalIn->getValue()/100; + Gtk::CheckButton * noCuspIn = dynamic_cast(noCusp); + bool noCusp = noCuspIn->get_active(); SPDesktop *desktop = inkscape_active_desktop(); // TODO: Is there a better method to find the item's desktop? Inkscape::Selection *selection = sp_desktop_selection(desktop); for (GSList *items = (GSList *) selection->itemList(); diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index dbe0789f2..3915a476c 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -8,16 +8,12 @@ */ #include "live_effects/effect.h" -#include "live_effects/parameter/parameter.h" -#include "ui/widget/scalar.h" -#include namespace Inkscape { namespace LivePathEffect { - - class LPEBSpline : public Effect { + public: LPEBSpline(LivePathEffectObject *lpeobject); virtual ~LPEBSpline(); @@ -28,23 +24,50 @@ public: virtual void doEffect(SPCurve * curve); - virtual void updateAllHandles(); + virtual void doBSplineFromWidget(SPCurve * curve, double value, bool noCusp); - virtual void newScalar(Glib::ustring title, Glib::ustring tip); + virtual Gtk::Widget * newWidget(); - virtual void newCheckButton(Glib::ustring title, Glib::ustring tip); + int steps; +protected: - virtual void doBSplineFromWidget(SPCurve * curve, double value, bool noCusp); + Gtk::Widget* scal; - virtual Gtk::Widget * newWidget(); + Gtk::Widget* noCusp; + + Gtk::Widget* reset; + + Gtk::Widget* stepsHandles; + + virtual void registerScal(Glib::ustring title, Glib::ustring tip){scal = LPEBSpline::newScal(title,tip);}; + + virtual void registerNoCusp(Glib::ustring title){noCusp = LPEBSpline::newNoCusp(title);}; + + virtual void registerReset(Glib::ustring title){reset = LPEBSpline::newReset(title);}; + + virtual void registerStepsHandles(Glib::ustring title, Glib::ustring tip){stepsHandles = LPEBSpline::newStepsHandles(title,tip);}; + + virtual Gtk::Widget* newScal(Glib::ustring title, Glib::ustring tip); + + virtual Gtk::Widget* newNoCusp(Glib::ustring title); + + virtual Gtk::Widget* newReset(Glib::ustring title); + + virtual Gtk::Widget* newStepsHandles(Glib::ustring title, Glib::ustring tip); + + virtual void updateAllHandles(); + + virtual void resetHandles(); + + virtual void updateSteps(); + virtual void updateStepsValue(int stepsValue){steps=stepsValue;}; private: - Gtk::Widget * scal; - Gtk::Widget * noCusp; LPEBSpline(const LPEBSpline&); LPEBSpline& operator=(const LPEBSpline&); + }; }; //namespace LivePathEffect diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index bee2cc477..b628d3500 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -113,6 +113,9 @@ Handle::Handle(NodeSharedData const &data, Geom::Point const &initial_pos, Node _degenerate(true) { setVisible(false); + //BSpline + setControlBsplineSteps( _pm().getControlBsplineSteps()); + //BSpline End; } Handle::~Handle() @@ -391,7 +394,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) double pos = 0; h = this; setPosition(new_pos); - pos = ceilf(_pm().BSplineHandlePosition(h)*10)/10; + pos = ceilf(_pm().BSplineHandlePosition(h)*controlBsplineSteps)/controlBsplineSteps; new_pos=_pm().BSplineHandleReposition(h,pos); } //BSpline End diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h index e74698b1a..953ac0061 100644 --- a/src/ui/tool/node.h +++ b/src/ui/tool/node.h @@ -109,12 +109,15 @@ protected: virtual bool _eventHandler(SPEventContext *event_context, GdkEvent *event); //Bspline virtual void handle_2button_press(); + virtual void setControlBsplineSteps(int controlBsplineStepsValue){controlBsplineSteps = controlBsplineStepsValue;}; + int controlBsplineSteps; //BSpline End virtual void dragged(Geom::Point &new_pos, GdkEventMotion *event); virtual bool grabbed(GdkEventMotion *event); virtual void ungrabbed(GdkEventButton *event); virtual bool clicked(GdkEventButton *event); + virtual Glib::ustring _getTip(unsigned state) const; virtual Glib::ustring _getDragTip(GdkEventMotion *event) const; virtual bool _hasDragTips() const { return true; } diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 0a100ecfb..b46e85622 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -36,6 +36,7 @@ #include "live_effects/lpeobject-reference.h" #include "live_effects/parameter/path.h" #include "sp-path.h" +#include "sp-lpe-item.h" #include "helper/geom.h" #include "preferences.h" #include "style.h" @@ -1174,9 +1175,8 @@ void PathManipulator::_createControlPointsFromGeometry() bool PathManipulator::isBSpline(){ LivePathEffect::LPEBSpline *lpe_bsp = NULL; - if (SP_IS_LPE_ITEM(_path) && sp_lpe_item_has_path_effect(SP_LPE_ITEM(_path))) { - PathEffectList effect_list = sp_lpe_item_get_effect_list(SP_LPE_ITEM(_path)); - lpe_bsp = dynamic_cast( effect_list.front()->lpeobject->get_lpe()); + if (SP_LPE_ITEM(_path) && sp_lpe_item_has_path_effect(SP_LPE_ITEM(_path))){ + lpe_bsp = dynamic_cast(sp_lpe_item_has_path_effect_of_type(SP_LPE_ITEM(_path),Inkscape::LivePathEffect::BSPLINE)->getLPEObj()->get_lpe()); }else{ lpe_bsp = NULL; } @@ -1186,6 +1186,16 @@ bool PathManipulator::isBSpline(){ return false; } +int PathManipulator::getControlBsplineSteps(){ + LivePathEffect::LPEBSpline *lpe_bsp = NULL; + if (SP_LPE_ITEM(_path) && sp_lpe_item_has_path_effect(SP_LPE_ITEM(_path))){ + lpe_bsp = dynamic_cast(sp_lpe_item_has_path_effect_of_type(SP_LPE_ITEM(_path),Inkscape::LivePathEffect::BSPLINE)->getLPEObj()->get_lpe()); + if(lpe_bsp){ + return lpe_bsp->steps; + } + } + return 2; +} double PathManipulator::BSplineHandlePosition(Handle *h){ using Geom::X; using Geom::Y; diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index a235a3b05..04148592b 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -89,6 +89,9 @@ public: void updateHandles(); void setControlsTransform(Geom::Affine const &); void hideDragPoint(); + //BSpline + int getControlBsplineSteps(); + //BSpline End MultiPathManipulator &mpm() { return _multi_path_manipulator; } NodeList::iterator subdivideSegment(NodeList::iterator after, double t); -- cgit v1.2.3 From 4e41340374ba833e748ffbbc610a28c7c3559557 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 19 Mar 2013 04:35:35 +0100 Subject: Working width widgets (bzr r11950.1.58) --- src/live_effects/lpe-bspline.cpp | 236 +++++++++++++++++++-------------------- src/live_effects/lpe-bspline.h | 49 ++------ src/pen-context.cpp | 15 +-- src/ui/tool/node.cpp | 7 +- src/ui/tool/node.h | 5 +- src/ui/tool/path-manipulator.cpp | 2 +- 6 files changed, 132 insertions(+), 182 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 5d50eae87..e6461e94c 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -13,23 +13,20 @@ #include "style.h" #include "document.h" #include "document-undo.h" -#include "selection.h" -#include "desktop.h" -#include "verbs.h" #include "desktop-handles.h" -#include -#include -#include -#include +#include "verbs.h" #include "live_effects/lpe-bspline.h" -#include "live_effects/lpeobject.h" -#include "live_effects/lpeobject-reference.h" +#include +#include #include "sp-lpe-item.h" +#include "live_effects/lpeobject.h" +#include "live_effects/parameter/parameter.h" #include "display/sp-canvas.h" #include #include <2geom/bezier-curve.h> #include "helper/geom-curves.h" #include "ui/widget/scalar.h" +#include "selection.h" // For handling un-continuous paths: #include "message-stack.h" @@ -38,23 +35,29 @@ using Inkscape::DocumentUndo; + namespace Inkscape { namespace LivePathEffect { + LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) : - Effect(lpeobject) + Effect(lpeobject), + // initialise your parameters here: + //testpointA(_("Test Point A"), _("Test A"), "ptA", &wr, this, Geom::Point(100,100)), + ignoreCusp(_("Ignore cusp nodes:"), _("Change ignoring cusp nodes"), "ignoreCusp", &wr, this, true), + weight(_("Change weight:"), _("Change weight of the effect"), "weight", &wr, this, 33.33), + steps(_("Steps whith CTRL:"), _("Change number of steps whith CTRL pressed"), "steps", &wr, this, 2) { - Glib::ustring title = Glib::ustring(_("Unify weights:")); - Glib::ustring tip = Glib::ustring(_("Percent of the with for all poinrs")); - registerScal(title,tip); - title = Glib::ustring(_("Ignore cusp nodes")); - registerNoCusp(title); - title = Glib::ustring(_("Reset")); - registerReset(title); - title = Glib::ustring(_("CTRL handle steps:")); - tip = Glib::ustring(_("CTRL handle steps")); - registerStepsHandles(title,tip); + registerParameter( dynamic_cast(&ignoreCusp) ); + registerParameter( dynamic_cast(&weight) ); + registerParameter( dynamic_cast(&steps) ); + weight.param_set_range(0.00, 100); + weight.param_set_increments(1., 1.); + weight.param_set_digits(2); + steps.param_set_range(1, 10); + steps.param_set_increments(1, 1); + steps.param_set_digits(0); } LPEBSpline::~LPEBSpline() @@ -247,108 +250,81 @@ LPEBSpline::doEffect(SPCurve * curve) Gtk::Widget * LPEBSpline::newWidget() { - Gtk::VBox * vbox = Gtk::manage( dynamic_cast(LPEBSpline::newWidget())); + // use manage here, because after deletion of Effect object, others might still be pointing to this widget. + Gtk::VBox * vbox = Gtk::manage( new Gtk::VBox(Effect::newWidget()) ); + vbox->set_border_width(5); - vbox->pack_start(*noCusp,true,true,2); - vbox->pack_start(*scal, true, true,2); - vbox->pack_start(*reset, true, true,2); - vbox->pack_start(*stepsHandles, true, true,2); - return dynamic_cast (vbox); -} -Gtk::Widget * -LPEBSpline::newScal(Glib::ustring title, Glib::ustring tip) -{ - Inkscape::UI::Widget::Scalar *scalIn = Gtk::manage( new Inkscape::UI::Widget::Scalar(title, tip)); - scalIn->setRange(0, 100.); - scalIn->setDigits(2); - scalIn->setIncrements(1., 5.); - scalIn->setValue(33.33); - scalIn->setProgrammatically = false; - scalIn->addSlider(); - scalIn->signal_value_changed().connect(sigc::mem_fun (*this,&LPEBSpline::updateAllHandles)); - return dynamic_cast(scalIn); -} + Gtk::Button* defaultWeight = Gtk::manage(new Gtk::Button(Glib::ustring(_("Default weight")))); + defaultWeight->set_alignment(0.0, 0.5); + Gtk::Widget* defaultWeightWidget = dynamic_cast(defaultWeight); + defaultWeight->signal_clicked().connect(sigc::mem_fun (*this,&LPEBSpline::toDefaultWeight)); + vbox->pack_start(*defaultWeightWidget, true, true,2); -Gtk::Widget * -LPEBSpline::newNoCusp(Glib::ustring title) -{ - Gtk::CheckButton * noCuspIn = Gtk::manage( new Gtk::CheckButton(title,true)); - noCuspIn->set_alignment(0.0, 0.5); - return dynamic_cast(noCuspIn); -} - -Gtk::Widget * -LPEBSpline::newReset(Glib::ustring title) -{ - Gtk::Button * resetIn = Gtk::manage(new Gtk::Button(title)); - resetIn->signal_clicked().connect(sigc::mem_fun (*this,&LPEBSpline::resetHandles)); - resetIn->set_alignment(0.0, 0.5); - return dynamic_cast(resetIn); -} + std::vector::iterator it = param_vector.begin(); + while (it != param_vector.end()) { + if ((*it)->widget_is_visible) { + Parameter * param = *it; + Gtk::Widget * widg = param->param_newWidget(); + if(param->param_key == "weight"){ + Inkscape::UI::Widget::Scalar * widgRegistered = dynamic_cast(widg); + widgRegistered->signal_value_changed().connect(sigc::mem_fun (*this,&LPEBSpline::toWeight)); + } + Glib::ustring * tip = param->param_getTooltip(); + if (widg) { + vbox->pack_start(*widg, true, true, 2); + if (tip) { + widg->set_tooltip_text(*tip); + } else { + widg->set_tooltip_text(""); + widg->set_has_tooltip(false); + } + } + } -Gtk::Widget * -LPEBSpline::newStepsHandles(Glib::ustring title, Glib::ustring tip) -{ - Inkscape::UI::Widget::Scalar *stepsIn = Gtk::manage( new Inkscape::UI::Widget::Scalar(title, tip)); - stepsIn->setRange(1, 10); - stepsIn->setDigits(0); - stepsIn->setIncrements(1.,1.); - stepsIn->setValue(2); - stepsIn->setProgrammatically = false; - stepsIn->signal_value_changed().connect(sigc::mem_fun (*this,&LPEBSpline::updateSteps)); - return dynamic_cast(stepsIn); + ++it; + } + return dynamic_cast(vbox); } -void -LPEBSpline::resetHandles(){ - Inkscape::UI::Widget::Scalar * scalIn = dynamic_cast(scal); - scalIn->setValue(33.33); - updateAllHandles(); +void +LPEBSpline::toDefaultWeight(){ +double weightValue = 0.3333; +changeWeight(weightValue); +weight.param_set_value(33.33); +gtk_widget_draw(GTK_WIDGET(LPEBSpline::newWidget()), NULL); } -void -LPEBSpline::updateSteps(){ - Inkscape::UI::Widget::Scalar * stepsIn = dynamic_cast(stepsHandles); - updateStepsValue(stepsIn->getValue()); +void +LPEBSpline::toWeight(){ +double weightValue = weight/100; +changeWeight(weightValue); } void -LPEBSpline::updateAllHandles() +LPEBSpline::changeWeight(double weightValue) { - Inkscape::UI::Widget::Scalar * scalIn = dynamic_cast(scal); - double value = scalIn->getValue()/100; - Gtk::CheckButton * noCuspIn = dynamic_cast(noCusp); - bool noCusp = noCuspIn->get_active(); - SPDesktop *desktop = inkscape_active_desktop(); // TODO: Is there a better method to find the item's desktop? + SPDesktop *desktop = inkscape_active_desktop(); Inkscape::Selection *selection = sp_desktop_selection(desktop); - for (GSList *items = (GSList *) selection->itemList(); - items != NULL; - items = items->next) { - if (SP_IS_LPE_ITEM((SPLPEItem *)items->data) && sp_lpe_item_has_path_effect((SPLPEItem *)items->data)){ - LivePathEffect::LPEBSpline *lpe_bsp = NULL; - lpe_bsp = dynamic_cast(sp_lpe_item_has_path_effect_of_type(SP_LPE_ITEM((SPLPEItem *)items->data),Inkscape::LivePathEffect::BSPLINE)->getLPEObj()->get_lpe()); - if(lpe_bsp){ - SPItem *item = (SPItem *) items->data; - SPPath *path = SP_PATH(item); - SPCurve *curve = path->get_curve_for_edit(); - LPEBSpline::doBSplineFromWidget(curve,value,noCusp); - gchar *str = sp_svg_write_path(curve->get_pathvector()); - path->getRepr()->setAttribute("inkscape:original-d", str); - g_free(str); - curve->unref(); - SPDesktop *desktop = inkscape_active_desktop(); - desktop->clearWaitingCursor(); - DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_LPE, - _("Modified the weight of the BSpline")); - } - } - } + GSList *items = (GSList *) selection->itemList(); + SPItem *item = (SPItem *)g_slist_nth(items,0)->data; + SPPath *path = SP_PATH(item); + SPCurve *curve = path->get_curve_for_edit(); + LPEBSpline::doBSplineFromWidget(curve,weightValue,ignoreCusp); + gchar *str = sp_svg_write_path(curve->get_pathvector()); + path->getRepr()->setAttribute("inkscape:original-d", str); + g_free(str); + curve->unref(); + desktop->clearWaitingCursor(); + DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_LPE, + _("Modified the weight of the BSpline")); } void -LPEBSpline::doBSplineFromWidget(SPCurve * curve, double value , bool noCusp) +LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue , bool ignoreCusp) { + using Geom::X; + using Geom::Y; if(curve->get_segment_count() < 2) return; // Make copy of old path as it is changed during processing @@ -404,19 +380,25 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double value , bool noCusp) cubic = dynamic_cast(&*curve_it1); pointAt0 = in->first_segment()->initialPoint(); SBasisIn = in->first_segment()->toSBasis(); - if(cubic){ - if(!noCusp || (*cubic)[1] != in->first_segment()->initialPoint()) - pointAt1 = SBasisIn.valueAt(value); - else + if(cubic){ + if(!ignoreCusp || !Geom::are_near((*cubic)[1],in->first_segment()->initialPoint())){ + pointAt1 = SBasisIn.valueAt(weightValue); + pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); + }else{ pointAt1 = in->first_segment()->initialPoint(); - if(!noCusp || (*cubic)[2] != in->first_segment()->finalPoint()) - pointAt2 = SBasisIn.valueAt(1-value); - else + } + if(!ignoreCusp || !Geom::are_near((*cubic)[2],in->first_segment()->finalPoint())){ + pointAt2 = SBasisIn.valueAt(1-weightValue); + pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); + }else{ pointAt2 = in->first_segment()->finalPoint(); + } }else{ - if(!noCusp){ - pointAt1 = SBasisIn.valueAt(value); - pointAt2 = SBasisIn.valueAt(1-value); + if(!ignoreCusp){ + pointAt1 = SBasisIn.valueAt(weightValue); + pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); + pointAt2 = SBasisIn.valueAt(1-weightValue); + pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); }else{ pointAt1 = in->first_segment()->initialPoint(); pointAt2 = in->first_segment()->finalPoint(); @@ -433,18 +415,24 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double value , bool noCusp) SBasisOut = out->first_segment()->toSBasis(); cubic = dynamic_cast(&*curve_it2); if(cubic){ - if(!noCusp || (*cubic)[1] != out->first_segment()->initialPoint()) - nextPointAt1 = SBasisOut.valueAt(value); - else + if(!ignoreCusp || !Geom::are_near((*cubic)[1],out->first_segment()->initialPoint())){ + nextPointAt1 = SBasisOut.valueAt(weightValue); + nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); + }else{ nextPointAt1 = out->first_segment()->initialPoint(); - if(!noCusp || (*cubic)[2] != out->first_segment()->finalPoint()) - nextPointAt2 = SBasisOut.valueAt(1-value); - else + } + if(!ignoreCusp || !Geom::are_near((*cubic)[2],out->first_segment()->finalPoint())){ + nextPointAt2 = SBasisOut.valueAt(1-weightValue); + nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); + }else{ nextPointAt2 = out->first_segment()->finalPoint(); + } }else{ - if(!noCusp){ - nextPointAt1 = SBasisOut.valueAt(value); - nextPointAt2 = SBasisOut.valueAt(1-value); + if(!ignoreCusp){ + nextPointAt1 = SBasisOut.valueAt(weightValue); + nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); + nextPointAt2 = SBasisOut.valueAt(1-weightValue); + nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); }else{ nextPointAt1 = out->first_segment()->initialPoint(); nextPointAt2 = out->first_segment()->finalPoint(); diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index 3915a476c..10d157ac1 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -8,12 +8,20 @@ */ #include "live_effects/effect.h" +#include "live_effects/parameter/bool.h" namespace Inkscape { namespace LivePathEffect { class LPEBSpline : public Effect { +private: + BoolParam ignoreCusp; + ScalarParam weight; + + LPEBSpline(const LPEBSpline&); + LPEBSpline& operator=(const LPEBSpline&); + public: LPEBSpline(LivePathEffectObject *lpeobject); virtual ~LPEBSpline(); @@ -28,49 +36,16 @@ public: virtual Gtk::Widget * newWidget(); - int steps; - -protected: - - Gtk::Widget* scal; - - Gtk::Widget* noCusp; - - Gtk::Widget* reset; - - Gtk::Widget* stepsHandles; - - virtual void registerScal(Glib::ustring title, Glib::ustring tip){scal = LPEBSpline::newScal(title,tip);}; + virtual void changeWeight(double weightValue); - virtual void registerNoCusp(Glib::ustring title){noCusp = LPEBSpline::newNoCusp(title);}; + virtual void toDefaultWeight(); - virtual void registerReset(Glib::ustring title){reset = LPEBSpline::newReset(title);}; + virtual void toWeight(); - virtual void registerStepsHandles(Glib::ustring title, Glib::ustring tip){stepsHandles = LPEBSpline::newStepsHandles(title,tip);}; + ScalarParam steps; - virtual Gtk::Widget* newScal(Glib::ustring title, Glib::ustring tip); - - virtual Gtk::Widget* newNoCusp(Glib::ustring title); - - virtual Gtk::Widget* newReset(Glib::ustring title); - - virtual Gtk::Widget* newStepsHandles(Glib::ustring title, Glib::ustring tip); - - virtual void updateAllHandles(); - - virtual void resetHandles(); - - virtual void updateSteps(); - - virtual void updateStepsValue(int stepsValue){steps=stepsValue;}; - -private: - LPEBSpline(const LPEBSpline&); - LPEBSpline& operator=(const LPEBSpline&); - }; }; //namespace LivePathEffect }; //namespace Inkscape - #endif diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 79e4cbabf..6f61ceb99 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -19,7 +19,6 @@ #include #include #include - #include "pen-context.h" #include "sp-namedview.h" #include "sp-metrics.h" @@ -69,7 +68,6 @@ #define INKSCAPE_LPE_BSPLINE_C #include "live_effects/lpe-bspline.h" #include <2geom/nearest-point.h> - //BSpline End using Inkscape::ControlManager; @@ -1580,8 +1578,6 @@ static void bspline_spiro_start_anchor_on(SPPenContext *const pc) if (pc->sa->start) { tmpCurve = tmpCurve->create_reverse(); } - pc->sa->curve->reset(); - pc->sa->curve = tmpCurve; } static void bspline_spiro_start_anchor_off(SPPenContext *const pc) @@ -1619,12 +1615,7 @@ static void bspline_spiro_motion(SPPenContext *const pc, bool shift){ using Geom::X; using Geom::Y; SPCurve *tmpCurve = new SPCurve(); - if(shift) - pc->p[2] = pc->p[3]; - else - pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); - pc->p[2] = Geom::Point(pc->p[2][X] + 0.0625,pc->p[2][Y] + 0.0625); - + pc->p[2] = pc->p[3]; if(pc->green_curve->is_empty() && !pc->sa){ pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]); }else if(!pc->green_curve->is_empty()){ @@ -1633,6 +1624,7 @@ static void bspline_spiro_motion(SPPenContext *const pc, bool shift){ tmpCurve = pc->sa->curve->copy(); if(pc->sa->start) tmpCurve = tmpCurve->create_reverse(); + } if(!tmpCurve->is_empty() && !pc->red_curve->is_empty()){ Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); @@ -1649,7 +1641,8 @@ static void bspline_spiro_motion(SPPenContext *const pc, bool shift){ SBasisWPower = WPower->first_segment()->toSBasis(); WPower->reset(); pc->p[1] = SBasisWPower.valueAt(WP); - pc->p[1] = Geom::Point(pc->p[1][X] + 0.0625,pc->p[1][Y] + 0.0625); + if(!Geom::are_near(pc->p[1],pc->p[0])) + pc->p[1] = Geom::Point(pc->p[1][X] + 0.0625,pc->p[1][Y] + 0.0625); }else{ pc->p[1] = (*cubic)[3] + (Geom::Point)((*cubic)[3] - (*cubic)[2] ); } diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index b628d3500..819f5db54 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -110,12 +110,9 @@ Handle::Handle(NodeSharedData const &data, Geom::Point const &initial_pos, Node _handle_colors, data.handle_group), _parent(parent), _handle_line(ControlManager::getManager().createControlLine(data.handle_line_group)), - _degenerate(true) + _degenerate(true),controlBsplineSteps(2) { setVisible(false); - //BSpline - setControlBsplineSteps( _pm().getControlBsplineSteps()); - //BSpline End; } Handle::~Handle() @@ -394,7 +391,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) double pos = 0; h = this; setPosition(new_pos); - pos = ceilf(_pm().BSplineHandlePosition(h)*controlBsplineSteps)/controlBsplineSteps; + pos = ceilf(_pm().BSplineHandlePosition(h)*_pm().getControlBsplineSteps())/_pm().getControlBsplineSteps(); new_pos=_pm().BSplineHandleReposition(h,pos); } //BSpline End diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h index 953ac0061..7152f37fd 100644 --- a/src/ui/tool/node.h +++ b/src/ui/tool/node.h @@ -89,7 +89,6 @@ public: virtual void setVisible(bool); virtual void move(Geom::Point const &p); - virtual void setPosition(Geom::Point const &p); inline void setRelativePos(Geom::Point const &p); void setLength(double len); @@ -109,8 +108,6 @@ protected: virtual bool _eventHandler(SPEventContext *event_context, GdkEvent *event); //Bspline virtual void handle_2button_press(); - virtual void setControlBsplineSteps(int controlBsplineStepsValue){controlBsplineSteps = controlBsplineStepsValue;}; - int controlBsplineSteps; //BSpline End virtual void dragged(Geom::Point &new_pos, GdkEventMotion *event); virtual bool grabbed(GdkEventMotion *event); @@ -129,7 +126,7 @@ private: // so a naked pointer is OK and allows setting it during Node's construction SPCtrlLine *_handle_line; bool _degenerate; // True if the handle is retracted, i.e. has zero length. This is used often internally so it makes sense to cache this - + int controlBsplineSteps; /** * Control point of a cubic Bezier curve in a path. * diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index b46e85622..853d9336a 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1191,7 +1191,7 @@ int PathManipulator::getControlBsplineSteps(){ if (SP_LPE_ITEM(_path) && sp_lpe_item_has_path_effect(SP_LPE_ITEM(_path))){ lpe_bsp = dynamic_cast(sp_lpe_item_has_path_effect_of_type(SP_LPE_ITEM(_path),Inkscape::LivePathEffect::BSPLINE)->getLPEObj()->get_lpe()); if(lpe_bsp){ - return lpe_bsp->steps; + return lpe_bsp->steps+1; } } return 2; -- cgit v1.2.3 From fc95705f9d5761fe111a445c51afc505d08738a7 Mon Sep 17 00:00:00 2001 From: jtx Date: Tue, 19 Mar 2013 17:56:26 +0100 Subject: Fixing regression (bzr r11950.1.61) --- src/common-context.h | 4 --- src/composite-undo-stack-observer.h | 2 +- src/desktop.h | 2 +- src/display/cairo-utils.cpp | 10 +++---- src/display/canvas-axonomgrid.h | 2 +- src/display/guideline.h | 2 +- src/display/nr-filter-diffuselighting.h | 8 +++--- src/display/nr-filter-flood.h | 2 +- src/display/nr-filter-specularlighting.h | 8 +++--- src/display/nr-style.h | 3 +-- src/display/nr-svgfonts.cpp | 3 --- src/display/nr-svgfonts.h | 4 +-- src/display/sp-ctrlcurve.h | 2 +- src/document-subset.h | 2 +- src/dom/events.h | 1 - src/dropper-context.cpp | 1 - src/dropper-context.h | 3 --- src/dyna-draw-context.h | 3 --- src/eraser-context.h | 3 --- src/event-context.h | 2 +- src/extension/internal/cairo-render-context.h | 6 ++--- src/extension/internal/cairo-renderer.h | 2 +- src/extension/internal/pdfinput/pdf-input.cpp | 1 + src/extension/internal/pdfinput/svg-builder.h | 6 ++--- src/file.cpp | 3 --- src/file.h | 2 +- src/filter-chemistry.h | 2 +- src/filters/blend.h | 2 -- src/filters/colormatrix.h | 2 -- src/filters/componenttransfer-funcnode.h | 6 +---- src/filters/componenttransfer.h | 2 -- src/filters/composite.h | 2 -- src/filters/convolvematrix.h | 2 -- src/filters/diffuselighting.h | 4 +-- src/filters/displacementmap.h | 2 -- src/filters/distantlight.h | 4 --- src/filters/flood.h | 2 -- src/filters/gaussian-blur.h | 4 +-- src/filters/image.h | 2 -- src/filters/merge.h | 2 -- src/filters/mergenode.h | 3 --- src/filters/morphology.h | 2 -- src/filters/offset.h | 2 -- src/filters/pointlight.h | 6 ----- src/filters/specularlighting.h | 4 +-- src/filters/spotlight.h | 6 ----- src/filters/tile.h | 2 -- src/filters/turbulence.h | 1 - src/flood-context.h | 3 --- src/gradient-context.h | 3 --- src/gradient-drag.h | 6 ++--- src/inkscape-private.h | 2 +- src/inkscape.cpp | 2 +- src/libgdl/Makefile_insert | 1 - src/libnrtype/Layout-TNG-Output.cpp | 1 - src/libnrtype/Layout-TNG.h | 2 +- src/libnrtype/font-lister.cpp | 1 - src/livarot/Path.h | 10 +++---- src/livarot/Shape.h | 6 ++--- src/live_effects/lpe-recursiveskeleton.cpp | 3 ++- src/live_effects/parameter/parameter.cpp | 3 ++- src/lpe-tool-context.h | 3 --- src/marker.cpp | 12 ++++----- src/marker.h | 4 +-- src/measure-context.h | 3 --- src/menus-skeleton.h | 2 -- src/mesh-context.h | 3 --- src/pixmaps/cursor-dropper.xpm | 38 -------------------------- src/rect-context.h | 3 --- src/select-context.h | 2 -- src/selection.cpp | 1 - src/seltrans-handles.h | 2 +- src/seltrans.h | 2 +- src/snap.cpp | 1 - src/sp-clippath.h | 2 +- src/sp-desc.h | 3 --- src/sp-filter-primitive.h | 2 -- src/sp-filter.h | 2 +- src/sp-flowregion.cpp | 39 +++++++++++++-------------- src/sp-font-face.cpp | 3 --- src/sp-font-face.h | 2 -- src/sp-font.cpp | 3 --- src/sp-glyph-kerning.cpp | 2 -- src/sp-glyph-kerning.h | 2 -- src/sp-glyph.cpp | 2 -- src/sp-glyph.h | 2 -- src/sp-gradient.h | 4 +-- src/sp-image.h | 3 --- src/sp-item.h | 4 +-- src/sp-linear-gradient-fns.h | 2 +- src/sp-mask.h | 4 +-- src/sp-metadata.cpp | 10 ++++--- src/sp-metadata.h | 3 --- src/sp-missing-glyph.cpp | 3 --- src/sp-missing-glyph.h | 2 -- src/sp-object-group.cpp | 4 +-- src/sp-object-repr.cpp | 14 ++++------ src/sp-offset.h | 2 -- src/sp-pattern.h | 3 +-- src/sp-polyline.cpp | 11 ++++---- src/sp-radial-gradient-fns.h | 2 +- src/sp-rect.h | 3 --- src/sp-spiral.h | 3 --- src/sp-star.h | 5 ---- src/sp-stop.h | 1 - src/sp-switch.h | 2 +- src/sp-symbol.cpp | 33 ++++++++++++++--------- src/sp-symbol.h | 3 --- src/sp-title.h | 3 --- src/sp-tref.h | 3 --- src/sp-use.h | 2 -- src/spiral-context.h | 3 --- src/splivarot.cpp | 36 +++---------------------- src/spray-context.h | 3 --- src/star-context.h | 3 --- src/style.cpp | 2 +- src/style.h | 4 +-- src/svg-view-widget.h | 2 -- src/svg-view.h | 2 +- src/svg/svg-color.h | 2 +- src/text-context.h | 2 -- src/text-editing.cpp | 2 +- src/trace/siox.cpp | 4 +-- src/tweak-context.h | 3 --- src/ui/dialog/dialog-manager.cpp | 7 ----- src/ui/dialog/document-properties.cpp | 2 -- src/ui/dialog/export.cpp | 26 ++++++++++++++---- src/ui/dialog/export.h | 19 +++++-------- src/ui/dialog/fill-and-stroke.cpp | 15 +++++++++++ src/ui/dialog/find.cpp | 4 +++ src/ui/dialog/find.h | 6 ++++- src/ui/dialog/glyphs.h | 2 +- src/ui/dialog/icon-preview.cpp | 4 +++ src/ui/dialog/input.cpp | 2 ++ src/ui/dialog/layer-properties.h | 6 ++--- src/ui/dialog/object-properties.cpp | 6 +++++ src/ui/dialog/object-properties.h | 10 +++++++ src/ui/dialog/svg-fonts-dialog.cpp | 4 --- src/ui/dialog/svg-fonts-dialog.h | 4 +-- src/ui/dialog/text-edit.cpp | 1 + src/ui/dialog/text-edit.h | 2 +- src/ui/dialog/tracedialog.cpp | 1 + src/ui/dialog/xml-tree.h | 2 +- src/ui/tool/control-point.cpp | 2 +- src/ui/tool/node-tool.h | 3 --- src/ui/tool/path-manipulator.h | 2 +- src/ui/widget/entry.cpp | 2 ++ src/ui/widget/entry.h | 6 ++--- src/ui/widget/frame.h | 8 +++--- src/ui/widget/registered-widget.h | 2 +- src/ui/widget/selected-style.h | 2 +- src/ui/widget/style-swatch.h | 2 +- src/undo-stack-observer.h | 2 +- src/widgets/gradient-vector.h | 2 +- src/widgets/paint-selector.h | 2 +- src/widgets/swatch-selector.h | 6 ++--- src/xml/composite-node-observer.h | 2 +- src/zoom-context.h | 3 --- 158 files changed, 245 insertions(+), 455 deletions(-) delete mode 100644 src/pixmaps/cursor-dropper.xpm (limited to 'src') diff --git a/src/common-context.h b/src/common-context.h index ae0f398b2..8903be391 100644 --- a/src/common-context.h +++ b/src/common-context.h @@ -29,12 +29,8 @@ #define SP_IS_COMMON_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_COMMON_CONTEXT)) #define SP_IS_COMMON_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_COMMON_CONTEXT)) -class SPCommonContext; -class SPCommonContextClass; - #define SAMPLING_SIZE 8 /* fixme: ?? */ - struct SPCommonContext : public SPEventContext { /** accumulated shape which ultimately goes in svg:path */ SPCurve *accumulated; diff --git a/src/composite-undo-stack-observer.h b/src/composite-undo-stack-observer.h index c34ab7234..669c39a86 100644 --- a/src/composite-undo-stack-observer.h +++ b/src/composite-undo-stack-observer.h @@ -18,7 +18,7 @@ namespace Inkscape { -class Event; +struct Event; /** * Aggregates UndoStackObservers for management and triggering in an SPDocument's undo/redo diff --git a/src/desktop.h b/src/desktop.h index d8d4e151d..56de56c65 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -77,7 +77,7 @@ namespace Inkscape { } namespace View { - class EditWidgetInterface; + struct EditWidgetInterface; } } namespace Whiteboard { diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp index a55b05fe3..fc56c7b26 100644 --- a/src/display/cairo-utils.cpp +++ b/src/display/cairo-utils.cpp @@ -655,8 +655,8 @@ int ink_cairo_surface_srgb_to_linear(cairo_surface_t *surface) cairo_surface_flush(surface); int width = cairo_image_surface_get_width(surface); int height = cairo_image_surface_get_height(surface); - int stride = cairo_image_surface_get_stride(surface); - unsigned char *data = cairo_image_surface_get_data(surface); + // int stride = cairo_image_surface_get_stride(surface); + // unsigned char *data = cairo_image_surface_get_data(surface); ink_cairo_surface_filter( surface, surface, SurfaceSrgbToLinear() ); @@ -698,8 +698,8 @@ int ink_cairo_surface_linear_to_srgb(cairo_surface_t *surface) cairo_surface_flush(surface); int width = cairo_image_surface_get_width(surface); int height = cairo_image_surface_get_height(surface); - int stride = cairo_image_surface_get_stride(surface); - unsigned char *data = cairo_image_surface_get_data(surface); + // int stride = cairo_image_surface_get_stride(surface); + // unsigned char *data = cairo_image_surface_get_data(surface); ink_cairo_surface_filter( surface, surface, SurfaceLinearToSrgb() ); @@ -888,4 +888,4 @@ guint32 argb32_from_rgba(guint32 in) fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/display/canvas-axonomgrid.h b/src/display/canvas-axonomgrid.h index 0e24d3f56..f58ea3aca 100644 --- a/src/display/canvas-axonomgrid.h +++ b/src/display/canvas-axonomgrid.h @@ -12,7 +12,7 @@ #include "line-snapper.h" #include "canvas-grid.h" -class SPCanvasBuf; +struct SPCanvasBuf; class SPDesktop; struct SPNamedView; diff --git a/src/display/guideline.h b/src/display/guideline.h index 164244c46..2d9a87d9b 100644 --- a/src/display/guideline.h +++ b/src/display/guideline.h @@ -21,7 +21,7 @@ #define SP_GUIDELINE(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_GUIDELINE, SPGuideLine)) #define SP_IS_GUIDELINE(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_GUIDELINE)) -class SPCtrlPoint; +struct SPCtrlPoint; struct SPGuideLine { SPCanvasItem item; diff --git a/src/display/nr-filter-diffuselighting.h b/src/display/nr-filter-diffuselighting.h index 315bf9f48..15cc8e1ff 100644 --- a/src/display/nr-filter-diffuselighting.h +++ b/src/display/nr-filter-diffuselighting.h @@ -19,10 +19,10 @@ #include "display/nr-filter-slot.h" #include "display/nr-filter-units.h" -class SPFeDistantLight; -class SPFePointLight; -class SPFeSpotLight; -class SVGICCColor; +struct SPFeDistantLight; +struct SPFePointLight; +struct SPFeSpotLight; +struct SVGICCColor; namespace Inkscape { namespace Filters { diff --git a/src/display/nr-filter-flood.h b/src/display/nr-filter-flood.h index 8568502ff..9a968047d 100644 --- a/src/display/nr-filter-flood.h +++ b/src/display/nr-filter-flood.h @@ -14,7 +14,7 @@ #include "display/nr-filter-primitive.h" -class SVGICCColor; +struct SVGICCColor; namespace Inkscape { namespace Filters { diff --git a/src/display/nr-filter-specularlighting.h b/src/display/nr-filter-specularlighting.h index 4f8c2d112..0d1c0644f 100644 --- a/src/display/nr-filter-specularlighting.h +++ b/src/display/nr-filter-specularlighting.h @@ -17,10 +17,10 @@ #include "display/nr-light-types.h" #include "display/nr-filter-primitive.h" -class SPFeDistantLight; -class SPFePointLight; -class SPFeSpotLight; -class SVGICCColor; +struct SPFeDistantLight; +struct SPFePointLight; +struct SPFeSpotLight; +struct SVGICCColor; namespace Inkscape { namespace Filters { diff --git a/src/display/nr-style.h b/src/display/nr-style.h index 597ae7a2c..80547c43e 100644 --- a/src/display/nr-style.h +++ b/src/display/nr-style.h @@ -16,8 +16,7 @@ #include <2geom/rect.h> #include "color.h" -class SPColor; -class SPPaintServer; +struct SPPaintServer; struct SPStyle; namespace Inkscape { diff --git a/src/display/nr-svgfonts.cpp b/src/display/nr-svgfonts.cpp index 0d1b56d54..84b4bd080 100644 --- a/src/display/nr-svgfonts.cpp +++ b/src/display/nr-svgfonts.cpp @@ -1,5 +1,4 @@ #include "config.h" -#ifdef ENABLE_SVG_FONTS /* * SVGFonts rendering implementation * @@ -356,8 +355,6 @@ void SvgFont::refresh(){ this->userfont = NULL; } -#endif //#ifdef ENABLE_SVG_FONTS - /* Local Variables: mode:c++ diff --git a/src/display/nr-svgfonts.h b/src/display/nr-svgfonts.h index 6138e2fbb..1101f93f2 100644 --- a/src/display/nr-svgfonts.h +++ b/src/display/nr-svgfonts.h @@ -18,8 +18,8 @@ class SvgFont; struct SPFont; -class SPGlyph; -class SPMissingGlyph; +struct SPGlyph; +struct SPMissingGlyph; struct _GdkEventExpose; typedef _GdkEventExpose GdkEventExpose; diff --git a/src/display/sp-ctrlcurve.h b/src/display/sp-ctrlcurve.h index 15de20161..90936185c 100644 --- a/src/display/sp-ctrlcurve.h +++ b/src/display/sp-ctrlcurve.h @@ -17,7 +17,7 @@ #include "display/sp-ctrlline.h" -struct SPItem; +class SPItem; #define SP_TYPE_CTRLCURVE (SPCtrlCurve::getType()) #define SP_CTRLCURVE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_CTRLCURVE, SPCtrlCurve)) diff --git a/src/document-subset.h b/src/document-subset.h index 5f87e6429..298b7872d 100644 --- a/src/document-subset.h +++ b/src/document-subset.h @@ -51,7 +51,7 @@ private: void _remove(SPObject *obj, bool subtree); - class Relations; + struct Relations; Relations *_relations; }; diff --git a/src/dom/events.h b/src/dom/events.h index 59d83afcf..e62c5d420 100644 --- a/src/dom/events.h +++ b/src/dom/events.h @@ -66,7 +66,6 @@ typedef dom::NodePtr NodePtr ; //forward declarations -class Event; class EventTarget; class EventListener; class DocumentEvent; diff --git a/src/dropper-context.cpp b/src/dropper-context.cpp index 66dcf4ab9..d41e4059d 100644 --- a/src/dropper-context.cpp +++ b/src/dropper-context.cpp @@ -39,7 +39,6 @@ #include "document.h" #include "document-undo.h" -#include "pixmaps/cursor-dropper.xpm" #include "pixmaps/cursor-dropper-f.xpm" #include "pixmaps/cursor-dropper-s.xpm" diff --git a/src/dropper-context.h b/src/dropper-context.h index 68ae3df07..be4b543ae 100644 --- a/src/dropper-context.h +++ b/src/dropper-context.h @@ -20,9 +20,6 @@ G_BEGIN_DECLS #define SP_DROPPER_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_DROPPER_CONTEXT, SPDropperContext)) #define SP_IS_DROPPER_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_DROPPER_CONTEXT)) -class SPDropperContext; -class SPDropperContextClass; - enum { SP_DROPPER_PICK_VISIBLE, SP_DROPPER_PICK_ACTUAL diff --git a/src/dyna-draw-context.h b/src/dyna-draw-context.h index af63bf653..8509e450b 100644 --- a/src/dyna-draw-context.h +++ b/src/dyna-draw-context.h @@ -27,9 +27,6 @@ #define SP_IS_DYNA_DRAW_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_DYNA_DRAW_CONTEXT)) #define SP_IS_DYNA_DRAW_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_DYNA_DRAW_CONTEXT)) -class SPDynaDrawContext; -class SPDynaDrawContextClass; - #define DDC_MIN_PRESSURE 0.0 #define DDC_MAX_PRESSURE 1.0 #define DDC_DEFAULT_PRESSURE 1.0 diff --git a/src/eraser-context.h b/src/eraser-context.h index 7c147c32f..bc4268aef 100644 --- a/src/eraser-context.h +++ b/src/eraser-context.h @@ -29,9 +29,6 @@ G_BEGIN_DECLS #define SP_IS_ERASER_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_ERASER_CONTEXT)) #define SP_IS_ERASER_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_ERASER_CONTEXT)) -class SPEraserContext; -class SPEraserContextClass; - #define ERC_MIN_PRESSURE 0.0 #define ERC_MAX_PRESSURE 1.0 #define ERC_DEFAULT_PRESSURE 1.0 diff --git a/src/event-context.h b/src/event-context.h index 9936aa668..e97a8ad8f 100644 --- a/src/event-context.h +++ b/src/event-context.h @@ -19,7 +19,7 @@ #include "2geom/forward.h" #include "preferences.h" -struct GrDrag; +class GrDrag; class SPDesktop; class SPItem; class ShapeEditor; diff --git a/src/extension/internal/cairo-render-context.h b/src/extension/internal/cairo-render-context.h index 94c7bb294..8829940c6 100644 --- a/src/extension/internal/cairo-render-context.h +++ b/src/extension/internal/cairo-render-context.h @@ -29,7 +29,7 @@ #include class SPClipPath; -class SPMask; +struct SPMask; namespace Inkscape { namespace Extension { @@ -37,8 +37,8 @@ namespace Internal { class CairoRenderer; class CairoRenderContext; -class CairoRenderState; -class CairoGlyphInfo; +struct CairoRenderState; +struct CairoGlyphInfo; // Holds info for rendering a glyph struct CairoGlyphInfo { diff --git a/src/extension/internal/cairo-renderer.h b/src/extension/internal/cairo-renderer.h index db3068fed..c1482d82e 100644 --- a/src/extension/internal/cairo-renderer.h +++ b/src/extension/internal/cairo-renderer.h @@ -28,7 +28,7 @@ #include class SPClipPath; -class SPMask; +struct SPMask; namespace Inkscape { namespace Extension { diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp index 531cda20a..b04c9782f 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -32,6 +32,7 @@ #endif #include +#include #include #include #include diff --git a/src/extension/internal/pdfinput/svg-builder.h b/src/extension/internal/pdfinput/svg-builder.h index 46cddd73b..610822959 100644 --- a/src/extension/internal/pdfinput/svg-builder.h +++ b/src/extension/internal/pdfinput/svg-builder.h @@ -31,10 +31,10 @@ namespace Inkscape { #include "CharTypes.h" class GooString; class Function; -struct GfxState; -class GfxColor; +class GfxState; +struct GfxColor; class GfxColorSpace; -class GfxRGB; +struct GfxRGB; class GfxPath; class GfxPattern; class GfxTilingPattern; diff --git a/src/file.cpp b/src/file.cpp index 97087c1a1..5737f0a8a 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1124,9 +1124,6 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, prevent_id_clashes(doc, in_doc); - SPObject *in_defs = in_doc->getDefs(); - Inkscape::XML::Node *last_def = in_defs->getRepr()->lastChild(); - SPCSSAttr *style = sp_css_attr_from_object(doc->getRoot()); // Count the number of top-level items in the imported document. diff --git a/src/file.h b/src/file.h index b8e15bf3e..b173ca58c 100644 --- a/src/file.h +++ b/src/file.h @@ -24,7 +24,7 @@ class SPObject; namespace Inkscape { namespace Extension { - struct Extension; + class Extension; } } diff --git a/src/filter-chemistry.h b/src/filter-chemistry.h index 751885ad2..b00e33bcc 100644 --- a/src/filter-chemistry.h +++ b/src/filter-chemistry.h @@ -20,7 +20,7 @@ class SPDocument; struct SPFilter; -class SPFilterPrimitive; +struct SPFilterPrimitive; class SPItem; class SPObject; diff --git a/src/filters/blend.h b/src/filters/blend.h index e7fc410e7..5d65c92fc 100644 --- a/src/filters/blend.h +++ b/src/filters/blend.h @@ -22,8 +22,6 @@ #define SP_IS_FEBLEND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEBLEND)) #define SP_IS_FEBLEND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEBLEND)) -class SPFeBlendClass; - struct SPFeBlend : public SPFilterPrimitive { Inkscape::Filters::FilterBlendMode blend_mode; int in2; diff --git a/src/filters/colormatrix.h b/src/filters/colormatrix.h index 8eb750ac1..558f01070 100644 --- a/src/filters/colormatrix.h +++ b/src/filters/colormatrix.h @@ -21,8 +21,6 @@ #define SP_IS_FECOLORMATRIX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FECOLORMATRIX)) #define SP_IS_FECOLORMATRIX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FECOLORMATRIX)) -class SPFeColorMatrixClass; - struct SPFeColorMatrix : public SPFilterPrimitive { Inkscape::Filters::FilterColorMatrixType type; gdouble value; diff --git a/src/filters/componenttransfer-funcnode.h b/src/filters/componenttransfer-funcnode.h index d81e50577..ae1b2f8bb 100644 --- a/src/filters/componenttransfer-funcnode.h +++ b/src/filters/componenttransfer-funcnode.h @@ -34,11 +34,6 @@ #define SP_IS_FEFUNCNODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEFUNCNODE)) -/* Component Transfer funcNode class */ - -class SPFeFuncNode; -class SPFeFuncNodeClass; - struct SPFeFuncNode : public SPObject { Inkscape::Filters::FilterComponentTransferType type; std::vector tableValues; @@ -49,6 +44,7 @@ struct SPFeFuncNode : public SPObject { double offset; }; +/* Component Transfer funcNode class */ struct SPFeFuncNodeClass { SPObjectClass parent_class; }; diff --git a/src/filters/componenttransfer.h b/src/filters/componenttransfer.h index 2df64009f..deb6fb740 100644 --- a/src/filters/componenttransfer.h +++ b/src/filters/componenttransfer.h @@ -24,8 +24,6 @@ namespace Filters { class FilterComponentTransfer; } } -class SPFeComponentTransferClass; - struct SPFeComponentTransfer : public SPFilterPrimitive { Inkscape::Filters::FilterComponentTransfer *renderer; }; diff --git a/src/filters/composite.h b/src/filters/composite.h index 3eb62716f..4f2d1ff69 100644 --- a/src/filters/composite.h +++ b/src/filters/composite.h @@ -32,8 +32,6 @@ enum FeCompositeOperator { COMPOSITE_ENDOPERATOR }; -class SPFeCompositeClass; - struct SPFeComposite : public SPFilterPrimitive { FeCompositeOperator composite_operator; double k1, k2, k3, k4; diff --git a/src/filters/convolvematrix.h b/src/filters/convolvematrix.h index 4c5261e05..cb2fbfb8d 100644 --- a/src/filters/convolvematrix.h +++ b/src/filters/convolvematrix.h @@ -24,8 +24,6 @@ #define SP_IS_FECONVOLVEMATRIX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FECONVOLVEMATRIX)) #define SP_IS_FECONVOLVEMATRIX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FECONVOLVEMATRIX)) -class SPFeConvolveMatrixClass; - struct SPFeConvolveMatrix : public SPFilterPrimitive { NumberOptNumber order; std::vector kernelMatrix; diff --git a/src/filters/diffuselighting.h b/src/filters/diffuselighting.h index 99dccb394..1572385b9 100644 --- a/src/filters/diffuselighting.h +++ b/src/filters/diffuselighting.h @@ -21,15 +21,13 @@ #define SP_IS_FEDIFFUSELIGHTING(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEDIFFUSELIGHTING)) #define SP_IS_FEDIFFUSELIGHTING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEDIFFUSELIGHTING)) -class SVGICCColor; +struct SVGICCColor; namespace Inkscape { namespace Filters { class FilterDiffuseLighting; } } -class SPFeDiffuseLightingClass; - struct SPFeDiffuseLighting : public SPFilterPrimitive { gfloat surfaceScale; guint surfaceScale_set : 1; diff --git a/src/filters/displacementmap.h b/src/filters/displacementmap.h index 6232f0937..93dc86d27 100644 --- a/src/filters/displacementmap.h +++ b/src/filters/displacementmap.h @@ -28,8 +28,6 @@ enum FilterDisplacementMapChannelSelector { DISPLACEMENTMAP_CHANNEL_ENDTYPE }; -class SPFeDisplacementMapClass; - struct SPFeDisplacementMap : public SPFilterPrimitive { int in2; double scale; diff --git a/src/filters/distantlight.h b/src/filters/distantlight.h index a68746334..b1febf5d3 100644 --- a/src/filters/distantlight.h +++ b/src/filters/distantlight.h @@ -25,10 +25,6 @@ /* Distant light class */ - -class SPFeDistantLight; -class SPFeDistantLightClass; - struct SPFeDistantLight : public SPObject { /** azimuth attribute */ diff --git a/src/filters/flood.h b/src/filters/flood.h index d60321689..ab9f061d6 100644 --- a/src/filters/flood.h +++ b/src/filters/flood.h @@ -23,8 +23,6 @@ G_BEGIN_DECLS #define SP_IS_FEFLOOD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEFLOOD)) #define SP_IS_FEFLOOD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEFLOOD)) -class SPFeFloodClass; - struct SPFeFlood : public SPFilterPrimitive { guint32 color; SVGICCColor *icc; diff --git a/src/filters/gaussian-blur.h b/src/filters/gaussian-blur.h index 417f8a6f4..8929627ba 100644 --- a/src/filters/gaussian-blur.h +++ b/src/filters/gaussian-blur.h @@ -21,14 +21,12 @@ #define SP_IS_GAUSSIANBLUR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_GAUSSIANBLUR)) #define SP_IS_GAUSSIANBLUR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_GAUSSIANBLUR)) -/* GaussianBlur base class */ -class SPGaussianBlurClass; - struct SPGaussianBlur : public SPFilterPrimitive { /** stdDeviation attribute */ NumberOptNumber stdDeviation; }; +/* GaussianBlur base class */ struct SPGaussianBlurClass { SPFilterPrimitiveClass parent_class; }; diff --git a/src/filters/image.h b/src/filters/image.h index b4081602a..a96e650b7 100644 --- a/src/filters/image.h +++ b/src/filters/image.h @@ -24,8 +24,6 @@ #define SP_IS_FEIMAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEIMAGE)) #define SP_IS_FEIMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEIMAGE)) -class SPFeImageClass; - struct SPFeImage : public SPFilterPrimitive { gchar *href; diff --git a/src/filters/merge.h b/src/filters/merge.h index 3243073ca..40a9bb848 100644 --- a/src/filters/merge.h +++ b/src/filters/merge.h @@ -18,8 +18,6 @@ #define SP_IS_FEMERGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEMERGE)) #define SP_IS_FEMERGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEMERGE)) -class SPFeMergeClass; - struct SPFeMerge : public SPFilterPrimitive { }; diff --git a/src/filters/mergenode.h b/src/filters/mergenode.h index 8352632a6..edb35faec 100644 --- a/src/filters/mergenode.h +++ b/src/filters/mergenode.h @@ -21,9 +21,6 @@ #define SP_FEMERGENODE(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_FEMERGENODE, SPFeMergeNode)) #define SP_IS_FEMERGENODE(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_FEMERGENODE)) -class SPFeMergeNode; -class SPFeMergeNodeClass; - struct SPFeMergeNode : public SPObject { int input; }; diff --git a/src/filters/morphology.h b/src/filters/morphology.h index b7005a3d9..9084d1b94 100644 --- a/src/filters/morphology.h +++ b/src/filters/morphology.h @@ -22,8 +22,6 @@ #define SP_IS_FEMORPHOLOGY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEMORPHOLOGY)) #define SP_IS_FEMORPHOLOGY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEMORPHOLOGY)) -class SPFeMorphologyClass; - struct SPFeMorphology : public SPFilterPrimitive { Inkscape::Filters::FilterMorphologyOperator Operator; NumberOptNumber radius; diff --git a/src/filters/offset.h b/src/filters/offset.h index dba7ed8ef..08954a8e4 100644 --- a/src/filters/offset.h +++ b/src/filters/offset.h @@ -20,8 +20,6 @@ #define SP_IS_FEOFFSET(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEOFFSET)) #define SP_IS_FEOFFSET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEOFFSET)) -class SPFeOffsetClass; - struct SPFeOffset : public SPFilterPrimitive { double dx, dy; }; diff --git a/src/filters/pointlight.h b/src/filters/pointlight.h index c0b272021..3ec5d5791 100644 --- a/src/filters/pointlight.h +++ b/src/filters/pointlight.h @@ -23,12 +23,6 @@ #define SP_IS_FEPOINTLIGHT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEPOINTLIGHT)) #define SP_IS_FEPOINTLIGHT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEPOINTLIGHT)) -/* Distant light class */ - - -class SPFePointLight; -class SPFePointLightClass; - struct SPFePointLight : public SPObject { /** x coordinate of the light source */ diff --git a/src/filters/specularlighting.h b/src/filters/specularlighting.h index 44bd98c6c..4b31eb4c4 100644 --- a/src/filters/specularlighting.h +++ b/src/filters/specularlighting.h @@ -23,7 +23,7 @@ #define SP_IS_FESPECULARLIGHTING(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FESPECULARLIGHTING)) #define SP_IS_FESPECULARLIGHTING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FESPECULARLIGHTING)) -class SVGICCColor; +struct SVGICCColor; namespace Inkscape { namespace Filters { @@ -31,8 +31,6 @@ class FilterSpecularLighting; } } -class SPFeSpecularLightingClass; - struct SPFeSpecularLighting : public SPFilterPrimitive { gfloat surfaceScale; guint surfaceScale_set : 1; diff --git a/src/filters/spotlight.h b/src/filters/spotlight.h index 6e2463c08..1750ca95b 100644 --- a/src/filters/spotlight.h +++ b/src/filters/spotlight.h @@ -23,12 +23,6 @@ #define SP_IS_FESPOTLIGHT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FESPOTLIGHT)) #define SP_IS_FESPOTLIGHT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FESPOTLIGHT)) -/* Distant light class */ - - -class SPFeSpotLight; -class SPFeSpotLightClass; - struct SPFeSpotLight : public SPObject { /** x coordinate of the light source */ diff --git a/src/filters/tile.h b/src/filters/tile.h index a376a6e10..48a552fc8 100644 --- a/src/filters/tile.h +++ b/src/filters/tile.h @@ -21,8 +21,6 @@ #define SP_IS_FETILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FETILE)) /* FeTile base class */ -class SPFeTileClass; - struct SPFeTile : public SPFilterPrimitive { }; diff --git a/src/filters/turbulence.h b/src/filters/turbulence.h index cbc4fb082..bad8315c1 100644 --- a/src/filters/turbulence.h +++ b/src/filters/turbulence.h @@ -24,7 +24,6 @@ #define SP_IS_FETURBULENCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FETURBULENCE)) /* FeTurbulence base class */ -class SPFeTurbulenceClass; struct SPFeTurbulence : public SPFilterPrimitive { /** TURBULENCE ATTRIBUTES HERE */ diff --git a/src/flood-context.h b/src/flood-context.h index 0cab0f7c5..3e81cd01e 100644 --- a/src/flood-context.h +++ b/src/flood-context.h @@ -29,9 +29,6 @@ #define FLOOD_COLOR_CHANNEL_B 4 #define FLOOD_COLOR_CHANNEL_A 8 -class SPFloodContext; -class SPFloodContextClass; - struct SPFloodContext : public SPEventContext { SPItem *item; diff --git a/src/gradient-context.h b/src/gradient-context.h index 9c08677ae..464b95ad4 100644 --- a/src/gradient-context.h +++ b/src/gradient-context.h @@ -25,9 +25,6 @@ #define SP_IS_GRADIENT_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_GRADIENT_CONTEXT)) #define SP_IS_GRADIENT_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_GRADIENT_CONTEXT)) -class SPGradientContext; -class SPGradientContextClass; - struct SPGradientContext : public SPEventContext { Geom::Point origin; diff --git a/src/gradient-drag.h b/src/gradient-drag.h index cd76d8a3c..2a2465590 100644 --- a/src/gradient-drag.h +++ b/src/gradient-drag.h @@ -33,12 +33,12 @@ struct SPKnot; class SPDesktop; class SPCSSAttr; -class SPLinearGradient; +struct SPLinearGradient; struct SPMeshGradient; class SPItem; class SPObject; -class SPRadialGradient; -class SPStop; +struct SPRadialGradient; +struct SPStop; namespace Inkscape { class Selection; diff --git a/src/inkscape-private.h b/src/inkscape-private.h index 470a1f5bd..09bcef12b 100644 --- a/src/inkscape-private.h +++ b/src/inkscape-private.h @@ -22,7 +22,7 @@ #include "inkscape.h" -class SPColor; +struct SPColor; namespace Inkscape { class Selection; } GType inkscape_get_type (void); diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 449220357..491acd73e 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -91,7 +91,7 @@ enum { ################################*/ namespace Inkscape { -class ApplicationClass; +struct ApplicationClass; } static void inkscape_class_init (Inkscape::ApplicationClass *klass); diff --git a/src/libgdl/Makefile_insert b/src/libgdl/Makefile_insert index 7cfeaa8a2..6669a28fa 100644 --- a/src/libgdl/Makefile_insert +++ b/src/libgdl/Makefile_insert @@ -44,7 +44,6 @@ libgdl/all: libgdl/libgdl.a libgdl/clean: rm -f libgdl/libgdl.a $(libgdl_gdl_a_OBJECTS) - # Suppress some non-critical warnings for libgdl. We will drop our forked copy # of GDL once we upgrade to Gtk+ 3 so it's more important to minimise the number # of changes we make to GDL than to fix these minor issues in trunk. diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index 1d086b57b..0f853c681 100644 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -26,7 +26,6 @@ namespace Inkscape { namespace Extension { namespace Internal { class CairoRenderContext; - class CairoGlyphInfo; } } } diff --git a/src/libnrtype/Layout-TNG.h b/src/libnrtype/Layout-TNG.h index 488a974ea..0f5f08a53 100644 --- a/src/libnrtype/Layout-TNG.h +++ b/src/libnrtype/Layout-TNG.h @@ -36,7 +36,7 @@ using Inkscape::Extension::Internal::CairoRenderContext; struct SPStyle; class Shape; -class SPPrintContext; +struct SPPrintContext; class SVGLength; class Path; class SPCurve; diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp index 8401c227f..5b495d14d 100644 --- a/src/libnrtype/font-lister.cpp +++ b/src/libnrtype/font-lister.cpp @@ -2,7 +2,6 @@ # include #endif -#include #include #include #include diff --git a/src/livarot/Path.h b/src/livarot/Path.h index cd939bf7d..a109298a2 100644 --- a/src/livarot/Path.h +++ b/src/livarot/Path.h @@ -14,11 +14,11 @@ #include <2geom/point.h> struct PathDescr; -class PathDescrLineTo; -class PathDescrArcTo; -class PathDescrCubicTo; -class PathDescrBezierTo; -class PathDescrIntermBezierTo; +struct PathDescrLineTo; +struct PathDescrArcTo; +struct PathDescrCubicTo; +struct PathDescrBezierTo; +struct PathDescrIntermBezierTo; struct SPStyle; diff --git a/src/livarot/Shape.h b/src/livarot/Shape.h index 1a804a48c..dcd172da2 100644 --- a/src/livarot/Shape.h +++ b/src/livarot/Shape.h @@ -21,9 +21,9 @@ class Path; class FloatLigne; -struct SweepTree; -struct SweepTreeList; -struct SweepEventQueue; +class SweepTree; +class SweepTreeList; +class SweepEventQueue; enum { tweak_mode_grow, diff --git a/src/live_effects/lpe-recursiveskeleton.cpp b/src/live_effects/lpe-recursiveskeleton.cpp index 452139344..ac571d963 100644 --- a/src/live_effects/lpe-recursiveskeleton.cpp +++ b/src/live_effects/lpe-recursiveskeleton.cpp @@ -91,7 +91,8 @@ LPERecursiveSkeleton::doEffect_pwd2 (Geom::Piecewise > co double scaling = (uskeleton.domain().extent() - toffset)/pattBndsX->extent(); // TODO investigate why pattWidth is not being used: - double pattWidth = pattBndsX->extent() * scaling; + // - Doesn't appear to have been used anywhere in bzr history (Alex V: 2013-03-16) + // double pattWidth = pattBndsX->extent() * scaling; if (scaling != 1.0) { x*=scaling; diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index 7e155cb92..8615721b0 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -5,7 +5,7 @@ */ #include -#include "live_effects/lpe-bspline.h" + #include "live_effects/parameter/parameter.h" #include "live_effects/effect.h" #include "svg/svg.h" @@ -128,6 +128,7 @@ ScalarParam::param_newWidget() { Inkscape::UI::Widget::RegisteredScalar *rsu = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalar( param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc() ) ); + rsu->setValue(value); rsu->setDigits(digits); rsu->setIncrements(inc_step, inc_page); diff --git a/src/lpe-tool-context.h b/src/lpe-tool-context.h index 12e4b3838..fb3a5d4e2 100644 --- a/src/lpe-tool-context.h +++ b/src/lpe-tool-context.h @@ -24,9 +24,6 @@ #define SP_IS_LPETOOL_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_LPETOOL_CONTEXT)) #define SP_IS_LPETOOL_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_LPETOOL_CONTEXT)) -class SPLPEToolContext; -class SPLPEToolContextClass; - /* This is the list of subtools from which the toolbar of the LPETool is built automatically */ extern const int num_subtools; diff --git a/src/marker.cpp b/src/marker.cpp index 1c8542695..b3b493b00 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -324,13 +324,13 @@ static void sp_marker_update(SPObject *object, SPCtx *ctx, guint flags) // Now set up viewbox transformation // Determine actual viewbox in viewport coordinates - double x = 0; - double y = 0; + // double x = 0; + // double y = 0; double width = 0; double height = 0; if (marker->aspect_align == SP_ASPECT_NONE) { - x = 0.0; - y = 0.0; + // x = 0.0; + // y = 0.0; width = rctx.viewport.width(); height = rctx.viewport.height(); } else { @@ -343,7 +343,7 @@ static void sp_marker_update(SPObject *object, SPCtx *ctx, guint flags) height = (vb.height()) * scale; // Now place viewbox to requested position - switch (marker->aspect_align) { + /*switch (marker->aspect_align) { case SP_ASPECT_XMIN_YMIN: x = 0.0; y = 0.0; @@ -384,7 +384,7 @@ static void sp_marker_update(SPObject *object, SPCtx *ctx, guint flags) x = 0.0; y = 0.0; break; - } + }*/ } // TODO fixme: all that work is done to figure out x and y, which are just ignored. Check why. diff --git a/src/marker.h b/src/marker.h index e8d2dd9a1..147fafeb8 100644 --- a/src/marker.h +++ b/src/marker.h @@ -22,9 +22,7 @@ #define SP_MARKER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_MARKER, SPMarker)) #define SP_IS_MARKER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_MARKER)) -class SPMarker; -class SPMarkerClass; -class SPMarkerView; +struct SPMarkerView; #include <2geom/rect.h> #include <2geom/affine.h> diff --git a/src/measure-context.h b/src/measure-context.h index baf74d30e..b7673ad0d 100644 --- a/src/measure-context.h +++ b/src/measure-context.h @@ -18,9 +18,6 @@ #define SP_MEASURE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_MEASURE_CONTEXT, SPMeasureContext)) #define SP_IS_MEASURE_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_MEASURE_CONTEXT)) -class SPMeasureContext; -class SPMeasureContextClass; - struct SPMeasureContext { SPEventContext event_context; SPCanvasItem *grabbed; diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h index 868b606a4..694619089 100644 --- a/src/menus-skeleton.h +++ b/src/menus-skeleton.h @@ -252,9 +252,7 @@ static char const menus_skeleton[] = " \n" " \n" " \n" -#ifdef ENABLE_SVG_FONTS " \n" -#endif // ENABLE_SVG_FONTS " \n" " \n" " \n" diff --git a/src/mesh-context.h b/src/mesh-context.h index ed93e404f..e5d06ec0a 100644 --- a/src/mesh-context.h +++ b/src/mesh-context.h @@ -27,9 +27,6 @@ #define SP_IS_MESH_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_MESH_CONTEXT)) #define SP_IS_MESH_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_MESH_CONTEXT)) -class SPMeshContext; -class SPMeshContextClass; - struct SPMeshContext : public SPEventContext { Geom::Point origin; diff --git a/src/pixmaps/cursor-dropper.xpm b/src/pixmaps/cursor-dropper.xpm deleted file mode 100644 index 21f96edd0..000000000 --- a/src/pixmaps/cursor-dropper.xpm +++ /dev/null @@ -1,38 +0,0 @@ -/* XPM */ -static const char * cursor_dropper_xpm[] = { -"32 32 3 1", -" c None", -". c #FFFFFF", -"+ c #000000", -" ... ", -" .+. ", -" .+. ", -" .+. ", -".... .... ", -".+++ +++. ", -".... .... ", -" .+. ", -" .+. .... ", -" .+. .+++. ", -" ... .+..+. ", -" .++..+. ", -" .++..+. ", -" .++..+. ", -" .++..+. . ", -" .++..+.+. ", -" .++..+++. ", -" .++++.+. ", -" .++++.+.. ", -" .++++++.++. ", -" .++++++..+. ", -" ..+++++.+. ", -" .++++++. ", -" .+++++. ", -" .+++. ", -" ... ", -" ", -" ", -" ", -" ", -" ", -" "}; diff --git a/src/rect-context.h b/src/rect-context.h index b6fbb6854..5b6c5373e 100644 --- a/src/rect-context.h +++ b/src/rect-context.h @@ -25,9 +25,6 @@ #define SP_IS_RECT_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_RECT_CONTEXT)) #define SP_IS_RECT_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_RECT_CONTEXT)) -class SPRectContext; -class SPRectContextClass; - struct SPRectContext : public SPEventContext { SPItem *item; Geom::Point center; diff --git a/src/select-context.h b/src/select-context.h index ce2039a2d..a6877f802 100644 --- a/src/select-context.h +++ b/src/select-context.h @@ -22,8 +22,6 @@ #define SP_IS_SELECT_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_SELECT_CONTEXT)) struct SPCanvasItem; -class SPSelectContext; -class SPSelectContextClass; namespace Inkscape { class MessageContext; diff --git a/src/selection.cpp b/src/selection.cpp index 72f50137c..564f1fdd3 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -418,7 +418,6 @@ Geom::OptRect Selection::documentBounds(SPItem::BBoxType type) const // will be returned; this is also the case in SelTrans::centerRequest() boost::optional Selection::center() const { GSList *items = (GSList *) const_cast(this)->itemList(); - Geom::Point center; if (items) { SPItem *first = reinterpret_cast(g_slist_last(items)->data); // from the first item in selection if (first->isCenterSet()) { // only if set explicitly diff --git a/src/seltrans-handles.h b/src/seltrans-handles.h index f625ebd68..14f50d784 100644 --- a/src/seltrans-handles.h +++ b/src/seltrans-handles.h @@ -21,7 +21,7 @@ namespace Inkscape class SelTrans; } -class SPSelTransHandle; +struct SPSelTransHandle; // request handlers gboolean sp_sel_trans_scale_request(Inkscape::SelTrans *seltrans, diff --git a/src/seltrans.h b/src/seltrans.h index 55c109ed7..effc767e3 100644 --- a/src/seltrans.h +++ b/src/seltrans.h @@ -30,7 +30,7 @@ struct SPKnot; class SPDesktop; struct SPCanvasItem; struct SPCtrlLine; -class SPSelTransHandle; +struct SPSelTransHandle; namespace Inkscape { diff --git a/src/snap.cpp b/src/snap.cpp index 695424194..15f24ef53 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -500,7 +500,6 @@ Inkscape::SnappedPoint SnapManager::_snapTransformed( /* The current best metric for the best transformation; lower is better, Geom::infinity() ** means that we haven't snapped anything. */ - Geom::Point best_scale_metric(Geom::infinity(), Geom::infinity()); Inkscape::SnappedPoint best_snapped_point; g_assert(best_snapped_point.getAlwaysSnap() == false); // Check initialization of snapped point g_assert(best_snapped_point.getAtIntersection() == false); diff --git a/src/sp-clippath.h b/src/sp-clippath.h index a77383c63..17546c6d3 100644 --- a/src/sp-clippath.h +++ b/src/sp-clippath.h @@ -21,7 +21,7 @@ #define SP_IS_CLIPPATH(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_CLIPPATH)) #define SP_IS_CLIPPATH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_CLIPPATH)) -class SPClipPathView; +struct SPClipPathView; #include "sp-object-group.h" #include "uri-references.h" diff --git a/src/sp-desc.h b/src/sp-desc.h index 8c5a8a663..41ef08020 100644 --- a/src/sp-desc.h +++ b/src/sp-desc.h @@ -17,9 +17,6 @@ #define SP_TYPE_DESC (sp_desc_get_type ()) #define SP_IS_DESC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_DESC)) -class SPDesc; -class SPDescClass; - struct SPDesc : public SPObject { }; diff --git a/src/sp-filter-primitive.h b/src/sp-filter-primitive.h index 60104047e..f06df5611 100644 --- a/src/sp-filter-primitive.h +++ b/src/sp-filter-primitive.h @@ -23,8 +23,6 @@ #define SP_IS_FILTER_PRIMITIVE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_FILTER_PRIMITIVE)) #define SP_IS_FILTER_PRIMITIVE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_FILTER_PRIMITIVE)) -class SPFilterPrimitive; -class SPFilterPrimitiveClass; namespace Inkscape { namespace Filters { class Filter; diff --git a/src/sp-filter.h b/src/sp-filter.h index a3e7cd35c..5afe47438 100644 --- a/src/sp-filter.h +++ b/src/sp-filter.h @@ -36,7 +36,7 @@ class Filter; } } class SPFilterReference; -class SPFilterPrimitive; +struct SPFilterPrimitive; struct ltstr { bool operator()(const char* s1, const char* s2) const; diff --git a/src/sp-flowregion.cpp b/src/sp-flowregion.cpp index a8de68f9b..627907cef 100644 --- a/src/sp-flowregion.cpp +++ b/src/sp-flowregion.cpp @@ -86,15 +86,13 @@ sp_flowregion_dispose(GObject *object) group->computed.~vector(); } -static void sp_flowregion_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) +static void +sp_flowregion_child_added(SPObject *object, + Inkscape::XML::Node *child, + Inkscape::XML::Node *ref) { - SP_ITEM(object); - - if (((SPObjectClass *) (sp_flowregion_parent_class))->child_added) { - (* ((SPObjectClass *) (sp_flowregion_parent_class))->child_added) (object, child, ref); - } - - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + SP_OBJECT_CLASS (sp_flowregion_parent_class)->child_added (object, child, ref); + object->requestModified(SP_OBJECT_MODIFIED_FLAG); } /* fixme: hide (Lauris) */ @@ -164,10 +162,10 @@ void SPFlowregion::UpdateComputed(void) } } -static void sp_flowregion_modified(SPObject *object, guint flags) +static void +sp_flowregion_modified(SPObject *object, + guint flags) { - SP_FLOWREGION(object); // ensure it is the proper type. - if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; } @@ -278,15 +276,14 @@ sp_flowregionexclude_dispose(GObject *object) } } -static void sp_flowregionexclude_child_added(SPObject *object, Inkscape::XML::Node *child, Inkscape::XML::Node *ref) +static void +sp_flowregionexclude_child_added(SPObject *object, + Inkscape::XML::Node *child, + Inkscape::XML::Node *ref) { - SP_ITEM(object); - - if (((SPObjectClass *) (sp_flowregionexclude_parent_class))->child_added) { - (* ((SPObjectClass *) (sp_flowregionexclude_parent_class))->child_added) (object, child, ref); - } + SP_OBJECT_CLASS (sp_flowregionexclude_parent_class)->child_added (object, child, ref); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + object->requestModified(SP_OBJECT_MODIFIED_FLAG); } /* fixme: hide (Lauris) */ @@ -354,10 +351,10 @@ void SPFlowregionExclude::UpdateComputed(void) } } -static void sp_flowregionexclude_modified(SPObject *object, guint flags) +static void +sp_flowregionexclude_modified(SPObject *object, + guint flags) { - SP_FLOWREGIONEXCLUDE(object); // Ensure it is the proper type - if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; } diff --git a/src/sp-font-face.cpp b/src/sp-font-face.cpp index 4288a5d64..0a649b17f 100644 --- a/src/sp-font-face.cpp +++ b/src/sp-font-face.cpp @@ -2,8 +2,6 @@ # include #endif -#ifdef ENABLE_SVG_FONTS - /* * SVG element implementation * @@ -849,7 +847,6 @@ static Inkscape::XML::Node *sp_fontface_write(SPObject *object, Inkscape::XML::D return repr; } -#endif //#ifdef ENABLE_SVG_FONTS /* Local Variables: mode:c++ diff --git a/src/sp-font-face.h b/src/sp-font-face.h index 57702b683..968644556 100644 --- a/src/sp-font-face.h +++ b/src/sp-font-face.h @@ -2,7 +2,6 @@ # include #endif -#ifdef ENABLE_SVG_FONTS #ifndef __SP_FONTFACE_H__ #define __SP_FONTFACE_H__ @@ -122,4 +121,3 @@ GType sp_fontface_get_type (void); G_END_DECLS #endif //#ifndef __SP_FONTFACE_H__ -#endif //#ifdef ENABLE_SVG_FONTS diff --git a/src/sp-font.cpp b/src/sp-font.cpp index 6ebbd5218..a03890fc7 100644 --- a/src/sp-font.cpp +++ b/src/sp-font.cpp @@ -2,8 +2,6 @@ # include #endif -#ifdef ENABLE_SVG_FONTS - /* * SVG element implementation * @@ -250,7 +248,6 @@ static Inkscape::XML::Node *sp_font_write(SPObject *object, Inkscape::XML::Docum return repr; } -#endif //#ifdef ENABLE_SVG_FONTS /* Local Variables: mode:c++ diff --git a/src/sp-glyph-kerning.cpp b/src/sp-glyph-kerning.cpp index 652d965bb..10884fb81 100644 --- a/src/sp-glyph-kerning.cpp +++ b/src/sp-glyph-kerning.cpp @@ -2,7 +2,6 @@ # include #endif -#ifdef ENABLE_SVG_FONTS #define __SP_ANCHOR_C__ /* @@ -267,7 +266,6 @@ static Inkscape::XML::Node *sp_glyph_kerning_write(SPObject *object, Inkscape::X return repr; } -#endif //#ifdef ENABLE_SVG_FONTS /* Local Variables: mode:c++ diff --git a/src/sp-glyph-kerning.h b/src/sp-glyph-kerning.h index ce9b4bb15..b7f733cad 100644 --- a/src/sp-glyph-kerning.h +++ b/src/sp-glyph-kerning.h @@ -2,7 +2,6 @@ # include #endif -#ifdef ENABLE_SVG_FONTS #ifndef __SP_GLYPH_KERNING_H__ #define __SP_GLYPH_KERNING_H__ @@ -60,4 +59,3 @@ GType sp_glyph_kerning_h_get_type (void); GType sp_glyph_kerning_v_get_type (void); #endif //#ifndef __SP_GLYPH_KERNING_H__ -#endif //#ifdef ENABLE_SVG_FONTS diff --git a/src/sp-glyph.cpp b/src/sp-glyph.cpp index e14ef8667..0417ea8c1 100644 --- a/src/sp-glyph.cpp +++ b/src/sp-glyph.cpp @@ -2,7 +2,6 @@ # include #endif -#ifdef ENABLE_SVG_FONTS #define __SP_GLYPH_C__ /* @@ -284,7 +283,6 @@ static Inkscape::XML::Node *sp_glyph_write(SPObject *object, Inkscape::XML::Docu return repr; } -#endif //#ifdef ENABLE_SVG_FONTS /* Local Variables: mode:c++ diff --git a/src/sp-glyph.h b/src/sp-glyph.h index 316204c23..7556b0e25 100644 --- a/src/sp-glyph.h +++ b/src/sp-glyph.h @@ -2,7 +2,6 @@ # include #endif -#ifdef ENABLE_SVG_FONTS #ifndef __SP_GLYPH_H__ #define __SP_GLYPH_H__ @@ -58,4 +57,3 @@ struct SPGlyphClass { GType sp_glyph_get_type (void); #endif //#ifndef __SP_GLYPH_H__ -#endif //#ifdef ENABLE_SVG_FONTS diff --git a/src/sp-gradient.h b/src/sp-gradient.h index a21a413f4..57ffa5570 100644 --- a/src/sp-gradient.h +++ b/src/sp-gradient.h @@ -27,8 +27,8 @@ #include #include -struct SPGradientReference; -class SPStop; +class SPGradientReference; +struct SPStop; #define SP_TYPE_GRADIENT (SPGradient::getType()) #define SP_GRADIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_GRADIENT, SPGradient)) diff --git a/src/sp-image.h b/src/sp-image.h index c657d0a2f..d6fc82a59 100644 --- a/src/sp-image.h +++ b/src/sp-image.h @@ -20,9 +20,6 @@ #define SP_IS_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_IMAGE)) #define SP_IS_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_IMAGE)) -class SPImage; -class SPImageClass; - /* SPImage */ #include diff --git a/src/sp-item.h b/src/sp-item.h index a93206414..31b7ac034 100644 --- a/src/sp-item.h +++ b/src/sp-item.h @@ -28,8 +28,8 @@ #include "snap-candidate.h" class SPGuideConstraint; -struct SPClipPathReference; -struct SPMaskReference; +class SPClipPathReference; +class SPMaskReference; class SPAvoidRef; struct SPPrintContext; diff --git a/src/sp-linear-gradient-fns.h b/src/sp-linear-gradient-fns.h index 1bdf0b89e..14e575ebe 100644 --- a/src/sp-linear-gradient-fns.h +++ b/src/sp-linear-gradient-fns.h @@ -14,7 +14,7 @@ class Node; } } -class SPLinearGradient; +struct SPLinearGradient; #define SP_TYPE_LINEARGRADIENT (sp_lineargradient_get_type()) #define SP_LINEARGRADIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_LINEARGRADIENT, SPLinearGradient)) diff --git a/src/sp-mask.h b/src/sp-mask.h index e249e0c76..97cf95ae1 100644 --- a/src/sp-mask.h +++ b/src/sp-mask.h @@ -24,9 +24,7 @@ #define SP_IS_MASK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_MASK)) #define SP_IS_MASK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_MASK)) -class SPMask; -class SPMaskClass; -class SPMaskView; +struct SPMaskView; namespace Inkscape { diff --git a/src/sp-metadata.cpp b/src/sp-metadata.cpp index 9978d0a3a..79953b708 100644 --- a/src/sp-metadata.cpp +++ b/src/sp-metadata.cpp @@ -116,15 +116,17 @@ static void sp_metadata_release(SPObject *object) /** * Sets a specific value in the SPMetadata. */ -static void sp_metadata_set(SPObject *object, unsigned int key, const gchar *value) +static void +sp_metadata_set(SPObject *object, + unsigned int key, + const gchar *value) { debug("0x%08x %s(%u): '%s'",(unsigned int)object, sp_attribute_name(key),key,value); - SP_METADATA(object); // ensures the object is of the proper type. // see if any parents need this value - if (reinterpret_cast(sp_metadata_parent_class)->set) { - reinterpret_cast(sp_metadata_parent_class)->set(object, key, value); + if (SP_OBJECT_CLASS(sp_metadata_parent_class)->set) { + SP_OBJECT_CLASS(sp_metadata_parent_class)->set(object, key, value); } } diff --git a/src/sp-metadata.h b/src/sp-metadata.h index 82b7c4fc5..454fd8d18 100644 --- a/src/sp-metadata.h +++ b/src/sp-metadata.h @@ -21,9 +21,6 @@ #define SP_METADATA(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_METADATA, SPMetadata)) #define SP_IS_METADATA(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_METADATA)) -class SPMetadata; -class SPMetadataClass; - struct SPMetadata : public SPObject { }; diff --git a/src/sp-missing-glyph.cpp b/src/sp-missing-glyph.cpp index bdf993e5b..911c9be92 100644 --- a/src/sp-missing-glyph.cpp +++ b/src/sp-missing-glyph.cpp @@ -2,8 +2,6 @@ # include #endif -#ifdef ENABLE_SVG_FONTS - /* * SVG element implementation * @@ -164,7 +162,6 @@ static Inkscape::XML::Node *sp_missing_glyph_write(SPObject *object, Inkscape::X return repr; } -#endif //#ifdef ENABLE_SVG_FONTS /* Local Variables: mode:c++ diff --git a/src/sp-missing-glyph.h b/src/sp-missing-glyph.h index 0b3f74360..7930df513 100644 --- a/src/sp-missing-glyph.h +++ b/src/sp-missing-glyph.h @@ -2,7 +2,6 @@ # include #endif -#ifdef ENABLE_SVG_FONTS #ifndef __SP_MISSING_GLYPH_H__ #define __SP_MISSING_GLYPH_H__ @@ -40,4 +39,3 @@ struct SPMissingGlyphClass { GType sp_missing_glyph_get_type (void); #endif //#ifndef __SP_MISSING_GLYPH_H__ -#endif //#ifdef ENABLE_SVG_FONTS diff --git a/src/sp-object-group.cpp b/src/sp-object-group.cpp index 5158ec70a..e2b601ab9 100644 --- a/src/sp-object-group.cpp +++ b/src/sp-object-group.cpp @@ -93,8 +93,6 @@ sp_objectgroup_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) { - SP_OBJECTGROUP(object); // Ensure we have the right type of SPObject - if (flags & SP_OBJECT_WRITE_BUILD) { if (!repr) { repr = xml_doc->createElement("svg:g"); @@ -118,7 +116,7 @@ sp_objectgroup_write(SPObject *object, } if ((SP_OBJECT_CLASS(sp_objectgroup_parent_class))->write) { - (SP_OBJECT_CLASS(sp_objectgroup_parent_class))->write(object, xml_doc, repr, flags); + SP_OBJECT_CLASS(sp_objectgroup_parent_class)->write(object, xml_doc, repr, flags); } return repr; diff --git a/src/sp-object-repr.cpp b/src/sp-object-repr.cpp index cd332cd34..eba38ec67 100644 --- a/src/sp-object-repr.cpp +++ b/src/sp-object-repr.cpp @@ -48,13 +48,11 @@ #include "sp-script.h" #include "config.h" -#ifdef ENABLE_SVG_FONTS - #include "sp-font.h" - #include "sp-font-face.h" - #include "sp-glyph.h" - #include "sp-missing-glyph.h" - #include "sp-glyph-kerning.h" -#endif +#include "sp-font.h" +#include "sp-font-face.h" +#include "sp-glyph.h" +#include "sp-missing-glyph.h" +#include "sp-glyph-kerning.h" #include "sp-style-elem.h" #include "sp-switch.h" @@ -151,14 +149,12 @@ populate_dtables() { "svg:flowRegionExclude", SP_TYPE_FLOWREGIONEXCLUDE }, { "svg:flowRoot", SP_TYPE_FLOWTEXT }, { "svg:flowSpan", SP_TYPE_FLOWTSPAN }, -#ifdef ENABLE_SVG_FONTS { "svg:font", SP_TYPE_FONT }, { "svg:font-face", SP_TYPE_FONTFACE }, { "svg:glyph", SP_TYPE_GLYPH }, { "svg:missing-glyph", SP_TYPE_MISSING_GLYPH }, { "svg:hkern", SP_TYPE_HKERN }, { "svg:vkern", SP_TYPE_VKERN }, -#endif { "svg:g", SP_TYPE_GROUP }, { "svg:feBlend", SP_TYPE_FEBLEND }, { "svg:feColorMatrix", SP_TYPE_FECOLORMATRIX }, diff --git a/src/sp-offset.h b/src/sp-offset.h index 4e245f952..904f8607c 100644 --- a/src/sp-offset.h +++ b/src/sp-offset.h @@ -22,8 +22,6 @@ #define SP_IS_OFFSET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_OFFSET)) #define SP_IS_OFFSET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_OFFSET)) -class SPOffset; -class SPOffsetClass; class SPUseReference; /** diff --git a/src/sp-pattern.h b/src/sp-pattern.h index e0a7dce54..bcf8dd520 100644 --- a/src/sp-pattern.h +++ b/src/sp-pattern.h @@ -24,8 +24,7 @@ GType sp_pattern_get_type (void); -class SPPattern; -class SPPatternClass; +struct SPPattern; #include "svg/svg-length.h" #include "sp-paint-server.h" diff --git a/src/sp-polyline.cpp b/src/sp-polyline.cpp index e5d89a802..2922b66ed 100644 --- a/src/sp-polyline.cpp +++ b/src/sp-polyline.cpp @@ -116,10 +116,11 @@ sp_polyline_set(SPObject *object, unsigned int key, const gchar *value) } static Inkscape::XML::Node* -sp_polyline_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +sp_polyline_write(SPObject *object, + Inkscape::XML::Document *xml_doc, + Inkscape::XML::Node *repr, + guint flags) { - SP_POLYLINE(object); - if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:polyline"); } @@ -128,9 +129,7 @@ sp_polyline_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape:: repr->mergeFrom(object->getRepr(), "id"); } - if (((SPObjectClass *) (sp_polyline_parent_class))->write) { - ((SPObjectClass *) (sp_polyline_parent_class))->write (object, xml_doc, repr, flags); - } + SP_OBJECT_CLASS(sp_polyline_parent_class)->write (object, xml_doc, repr, flags); return repr; } diff --git a/src/sp-radial-gradient-fns.h b/src/sp-radial-gradient-fns.h index 912508a33..43ed7bf03 100644 --- a/src/sp-radial-gradient-fns.h +++ b/src/sp-radial-gradient-fns.h @@ -13,7 +13,7 @@ class Node; } } -class SPRadialGradient; +struct SPRadialGradient; #define SP_TYPE_RADIALGRADIENT (sp_radialgradient_get_type()) #define SP_RADIALGRADIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_RADIALGRADIENT, SPRadialGradient)) diff --git a/src/sp-rect.h b/src/sp-rect.h index 5e518dcd7..1127889c1 100644 --- a/src/sp-rect.h +++ b/src/sp-rect.h @@ -26,9 +26,6 @@ G_BEGIN_DECLS #define SP_IS_RECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_RECT)) #define SP_IS_RECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_RECT)) -class SPRect; -class SPRectClass; - struct SPRect : public SPShape { SVGLength x; SVGLength y; diff --git a/src/sp-spiral.h b/src/sp-spiral.h index 6da7c38a4..64cb8521b 100644 --- a/src/sp-spiral.h +++ b/src/sp-spiral.h @@ -29,9 +29,6 @@ #define SP_IS_SPIRAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_SPIRAL)) #define SP_IS_SPIRAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_SPIRAL)) -class SPSpiral; -class SPSpiralClass; - /** * A spiral Shape. * diff --git a/src/sp-star.h b/src/sp-star.h index bd271ccc0..888eeb8d2 100644 --- a/src/sp-star.h +++ b/src/sp-star.h @@ -16,17 +16,12 @@ #include "sp-polygon.h" - - #define SP_TYPE_STAR (sp_star_get_type ()) #define SP_STAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_STAR, SPStar)) #define SP_STAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_STAR, SPStarClass)) #define SP_IS_STAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_STAR)) #define SP_IS_STAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_STAR)) -class SPStar; -class SPStarClass; - typedef enum { SP_STAR_POINT_KNOT1, SP_STAR_POINT_KNOT2 diff --git a/src/sp-stop.h b/src/sp-stop.h index c3b1e2753..b82dd0b13 100644 --- a/src/sp-stop.h +++ b/src/sp-stop.h @@ -14,7 +14,6 @@ #include "color.h" class SPObjectClass; -class SPColor; struct SPStop; struct SPStopClass; diff --git a/src/sp-switch.h b/src/sp-switch.h index f0442f27b..24a204731 100644 --- a/src/sp-switch.h +++ b/src/sp-switch.h @@ -35,7 +35,7 @@ public: CSwitch(SPGroup *group); virtual ~CSwitch(); - friend class SPSwitch; + friend struct SPSwitch; virtual void onChildAdded(Inkscape::XML::Node *child); virtual void onChildRemoved(Inkscape::XML::Node *child); diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index d4db403e3..989a5b7f3 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -307,19 +307,19 @@ static void sp_symbol_update(SPObject *object, SPCtx *ctx, guint flags) } } -static void sp_symbol_modified(SPObject *object, guint flags) +static void +sp_symbol_modified(SPObject *object, + guint flags) { - SP_SYMBOL(object); - - if (((SPObjectClass *) (sp_symbol_parent_class))->modified) { - (* ((SPObjectClass *) (sp_symbol_parent_class))->modified) (object, flags); - } + SP_OBJECT_CLASS(sp_symbol_parent_class)->modified (object, flags); } -static Inkscape::XML::Node *sp_symbol_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) +static Inkscape::XML::Node * +sp_symbol_write(SPObject *object, + Inkscape::XML::Document *xml_doc, + Inkscape::XML::Node *repr, + guint flags) { - SP_SYMBOL(object); - if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:symbol"); } @@ -330,9 +330,7 @@ static Inkscape::XML::Node *sp_symbol_write(SPObject *object, Inkscape::XML::Doc //XML Tree being used directly here while it shouldn't be. repr->setAttribute("preserveAspectRatio", object->getRepr()->attribute("preserveAspectRatio")); - if (((SPObjectClass *) (sp_symbol_parent_class))->write) { - ((SPObjectClass *) (sp_symbol_parent_class))->write (object, xml_doc, repr, flags); - } + SP_OBJECT_CLASS(sp_symbol_parent_class)->write (object, xml_doc, repr, flags); return repr; } @@ -404,3 +402,14 @@ static void sp_symbol_print(SPItem *item, SPPrintContext *ctx) sp_print_release (ctx); } } + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/sp-symbol.h b/src/sp-symbol.h index 59f343285..10d642e8b 100644 --- a/src/sp-symbol.h +++ b/src/sp-symbol.h @@ -21,9 +21,6 @@ #define SP_SYMBOL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_SYMBOL, SPSymbol)) #define SP_IS_SYMBOL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_SYMBOL)) -class SPSymbol; -class SPSymbolClass; - #include <2geom/affine.h> #include "svg/svg-length.h" #include "enums.h" diff --git a/src/sp-title.h b/src/sp-title.h index a5f0a2fea..d10d58188 100644 --- a/src/sp-title.h +++ b/src/sp-title.h @@ -17,9 +17,6 @@ #define SP_TYPE_TITLE (sp_title_get_type ()) #define SP_IS_TITLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_TITLE)) -class SPTitle; -class SPTitleClass; - struct SPTitle : public SPObject { }; diff --git a/src/sp-tref.h b/src/sp-tref.h index cc80e48a8..33a8138d1 100644 --- a/src/sp-tref.h +++ b/src/sp-tref.h @@ -28,9 +28,6 @@ #define SP_IS_TREF(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_TREF)) #define SP_IS_TREF_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_TREF)) -class SPTRef; -class SPTRef; - struct SPTRef : public SPItem { // Attributes that are used in the same way they would be in a tspan TextTagAttributes attributes; diff --git a/src/sp-use.h b/src/sp-use.h index 399f30a4c..3dd0726aa 100644 --- a/src/sp-use.h +++ b/src/sp-use.h @@ -25,8 +25,6 @@ #define SP_IS_USE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_USE)) #define SP_IS_USE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_USE)) -class SPUse; -class SPUseClass; class SPUseReference; struct SPUse : public SPItem { diff --git a/src/spiral-context.h b/src/spiral-context.h index 12c0b5d68..7f696dfa2 100644 --- a/src/spiral-context.h +++ b/src/spiral-context.h @@ -27,9 +27,6 @@ #define SP_IS_SPIRAL_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_SPIRAL_CONTEXT)) #define SP_IS_SPIRAL_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_SPIRAL_CONTEXT)) -class SPSpiralContext; -class SPSpiralContextClass; - struct SPSpiralContext : public SPEventContext { SPItem * item; Geom::Point center; diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 061d32554..2015ffd27 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -1369,48 +1369,18 @@ void sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool Inkscape::XML::Node *parent = item->getRepr()->parent(); float o_width = 0; - JoinType o_join = join_straight; - ButtType o_butt = butt_straight; - float o_miter = 0; { SPStyle *i_style = item->style; - int jointype = i_style->stroke_linejoin.value; - int captype = i_style->stroke_linecap.value; o_width = i_style->stroke_width.computed; - if (jointype == SP_STROKE_LINEJOIN_MITER) - { - o_join = join_pointy; - } - else if (jointype == SP_STROKE_LINEJOIN_ROUND) - { - o_join = join_round; - } - else - { - o_join = join_straight; - } - if (captype == SP_STROKE_LINECAP_SQUARE) - { - o_butt = butt_square; - } - else if (captype == SP_STROKE_LINECAP_ROUND) - { - o_butt = butt_round; - } - else - { - o_butt = butt_straight; - } - { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); o_width = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0, "px"); } - if (o_width < 0.01) + if (o_width < 0.01){ o_width = 0.01; - o_miter = i_style->stroke_miterlimit.value * o_width; + } } Path *orig = Path_for_item(item, true, false); @@ -1508,7 +1478,7 @@ void sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool // move to the saved position repr->setPosition(pos > 0 ? pos : 0); - SPItem *nitem = (SPItem *) sp_desktop_document(desktop)->getObjectByRepr(repr); + SPItem *nitem = reinterpret_cast(sp_desktop_document(desktop)->getObjectByRepr(repr)); if ( !updating ) { // delete original, apply the transform to the offset diff --git a/src/spray-context.h b/src/spray-context.h index 64368c7a6..781bbcce8 100644 --- a/src/spray-context.h +++ b/src/spray-context.h @@ -27,9 +27,6 @@ #define SP_IS_SPRAY_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_SPRAY_CONTEXT)) #define SP_IS_SPRAY_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_SPRAY_CONTEXT)) -class SPSprayContext; -class SPSprayContextClass; - namespace Inkscape { namespace UI { namespace Dialog { diff --git a/src/star-context.h b/src/star-context.h index 7bcb26c41..4daafb3e4 100644 --- a/src/star-context.h +++ b/src/star-context.h @@ -25,9 +25,6 @@ #define SP_IS_STAR_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_STAR_CONTEXT)) #define SP_IS_STAR_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_STAR_CONTEXT)) -class SPStarContext; -class SPStarContextClass; - struct SPStarContext : public SPEventContext { SPItem *item; Geom::Point center; diff --git a/src/style.cpp b/src/style.cpp index 650b08aea..eef1c6ee5 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -63,7 +63,7 @@ using std::vector; #define SP_CSS_FONT_SIZE_DEFAULT 12.0; -class SPStyleEnum; +struct SPStyleEnum; /*######################### ## FORWARD DECLARATIONS diff --git a/src/style.h b/src/style.h index 1c8cb4774..0710f5c8e 100644 --- a/src/style.h +++ b/src/style.h @@ -134,8 +134,6 @@ struct SPILength { #define SP_STYLE_FILL_SERVER(s) ((const_cast (s))->getFillPaintServer()) #define SP_STYLE_STROKE_SERVER(s) ((const_cast (s))->getStrokePaintServer()) -class SVGICCColor; - /// Paint type internal to SPStyle. struct SPIPaint { unsigned set : 1; @@ -246,7 +244,7 @@ struct SPILengthOrNormal { float computed; }; -class SPTextStyle; +struct SPTextStyle; /// Stroke dash details. class NRVpathDash { diff --git a/src/svg-view-widget.h b/src/svg-view-widget.h index d489ccbdd..eab5be75b 100644 --- a/src/svg-view-widget.h +++ b/src/svg-view-widget.h @@ -15,8 +15,6 @@ #include "ui/view/view-widget.h" class SPDocument; -class SPSVGSPViewWidget; -class SPSVGSPViewWidgetClass; #define SP_TYPE_SVG_VIEW_WIDGET (sp_svg_view_widget_get_type ()) #define SP_SVG_VIEW_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_SVG_VIEW_WIDGET, SPSVGSPViewWidget)) diff --git a/src/svg-view.h b/src/svg-view.h index aaaa8a9a5..89f38ad34 100644 --- a/src/svg-view.h +++ b/src/svg-view.h @@ -13,7 +13,7 @@ #include "ui/view/view.h" -class SPCanvasGroup; +struct SPCanvasGroup; struct SPCanvasItem; diff --git a/src/svg/svg-color.h b/src/svg/svg-color.h index d1c7bee03..b8e317e3b 100644 --- a/src/svg/svg-color.h +++ b/src/svg/svg-color.h @@ -3,7 +3,7 @@ #include -class SVGICCColor; +struct SVGICCColor; guint32 sp_svg_read_color(gchar const *str, unsigned int dfl); guint32 sp_svg_read_color(gchar const *str, gchar const **end_ptr, guint32 def); diff --git a/src/text-context.h b/src/text-context.h index 9915583eb..a33c69e0a 100644 --- a/src/text-context.h +++ b/src/text-context.h @@ -30,8 +30,6 @@ #define SP_IS_TEXT_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_TEXT_CONTEXT)) struct SPCtrlLine; -class SPTextContext; -class SPTextContextClass; struct SPTextContext : public SPEventContext { diff --git a/src/text-editing.cpp b/src/text-editing.cpp index 47b4d35ac..401f56bb2 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -69,7 +69,7 @@ void te_update_layout_now_recursive(SPItem *item) if (SP_IS_GROUP(item)) { GSList *item_list = sp_item_group_item_list(SP_GROUP(item)); for(GSList* elem = item_list; elem; elem = elem->next) { - SPItem* list_item = (SPItem*) elem->data; + SPItem* list_item = static_cast(elem->data); te_update_layout_now_recursive(list_item); } g_slist_free(item_list); diff --git a/src/trace/siox.cpp b/src/trace/siox.cpp index 9376fad66..1a1426b83 100644 --- a/src/trace/siox.cpp +++ b/src/trace/siox.cpp @@ -591,7 +591,7 @@ bool SioxImage::writePPM(const std::string &fileName) if (!f) return false; - fprintf(f, "P6 %d %d 255\n", width, height); + fprintf(f, "P6 %u %u 255\n", width, height); for (unsigned int y=0 ; y); // registerFactory("PrintColorsPreviewDialog", &create); registerFactory("Script", &create); -#ifdef ENABLE_SVG_FONTS registerFactory("SvgFontsDialog", &create); -#endif registerFactory("Swatches", &create); registerFactory("Symbols", &create); registerFactory("TileDialog", &create); @@ -154,9 +149,7 @@ DialogManager::DialogManager() { registerFactory("ObjectProperties", &create); // registerFactory("PrintColorsPreviewDialog", &create); registerFactory("Script", &create); -#ifdef ENABLE_SVG_FONTS registerFactory("SvgFontsDialog", &create); -#endif registerFactory("Swatches", &create); registerFactory("Symbols", &create); registerFactory("TileDialog", &create); diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 045b34814..d335fb303 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -792,8 +792,6 @@ void DocumentProperties::build_scripting() _page_external_scripts->table().attach(_external_remove_btn, 2, 3, row, row + 1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0, 0, 0); #endif - row++; - //# Set up the External Scripts box _ExternalScriptsListStore = Gtk::ListStore::create(_ExternalScriptsListColumns); _ExternalScriptsList.set_model(_ExternalScriptsListStore); diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index ac039bf77..99a8c08d2 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -22,14 +22,21 @@ #include #include -#include -#include -#include +#include #include #include -#include +#include +#include #include -#include +#include +#if WITH_GTKMM_3_0 +# include +#else +# include +#endif +#include +#include + #ifdef WITH_GNOME_VFS # include // gnome_vfs_initialized #endif @@ -126,6 +133,15 @@ namespace Inkscape { namespace UI { namespace Dialog { +/** A list of strings that is used both in the preferences, and in the + data fields to describe the various values of \c selection_type. */ +static const char * selection_names[SELECTION_NUMBER_OF] = { + "page", "drawing", "selection", "custom"}; + +/** The names on the buttons for the various selection types. */ +static const char * selection_labels[SELECTION_NUMBER_OF] = { + N_("_Page"), N_("_Drawing"), N_("_Selection"), N_("_Custom")}; + Export::Export (void) : UI::Widget::Panel ("", "/dialogs/export/", SP_VERB_DIALOG_EXPORT), current_key(SELECTION_PAGE), diff --git a/src/ui/dialog/export.h b/src/ui/dialog/export.h index 5dca9cfa5..b10c98fd2 100644 --- a/src/ui/dialog/export.h +++ b/src/ui/dialog/export.h @@ -14,10 +14,12 @@ #include #include + +#include #include #include +#include #include -#include #include "desktop.h" #include "ui/dialog/desktop-tracker.h" @@ -25,11 +27,14 @@ #include "ui/widget/button.h" #include "ui/widget/entry.h" +namespace Gtk { +class Dialog; +} + namespace Inkscape { namespace UI { namespace Dialog { - /** What type of button is being pressed */ enum selection_type { SELECTION_PAGE = 0, /**< Export the whole page */ @@ -39,16 +44,6 @@ enum selection_type { SELECTION_NUMBER_OF /**< A counter for the number of these guys */ }; -/** A list of strings that is used both in the preferences, and in the - data fields to describe the various values of \c selection_type. */ -static const char * selection_names[SELECTION_NUMBER_OF] = { - "page", "drawing", "selection", "custom"}; - -/** The names on the buttons for the various selection types. */ -static const char * selection_labels[SELECTION_NUMBER_OF] = { - N_("_Page"), N_("_Drawing"), N_("_Selection"), N_("_Custom")}; - - /** * A dialog widget to export to various image formats such as bitmap and png. * diff --git a/src/ui/dialog/fill-and-stroke.cpp b/src/ui/dialog/fill-and-stroke.cpp index 8de2da18b..19b873d54 100644 --- a/src/ui/dialog/fill-and-stroke.cpp +++ b/src/ui/dialog/fill-and-stroke.cpp @@ -132,14 +132,24 @@ void FillAndStroke::_layoutPageFill() { fillWdgt = manage(sp_fill_style_widget_new()); + +#if WITH_GTKMM_3_0 _page_fill->table().attach(*fillWdgt, 0, 0, 1, 1); +#else + _page_fill->table().attach(*fillWdgt, 0, 1, 0, 1); +#endif } void FillAndStroke::_layoutPageStrokePaint() { strokeWdgt = manage(sp_stroke_style_paint_widget_new()); + +#if WITH_GTKMM_3_0 _page_stroke_paint->table().attach(*strokeWdgt, 0, 0, 1, 1); +#else + _page_stroke_paint->table().attach(*strokeWdgt, 0, 1, 0, 1); +#endif } void @@ -148,7 +158,12 @@ FillAndStroke::_layoutPageStrokeStyle() //Gtk::Widget *strokeStyleWdgt = manage(Glib::wrap(sp_stroke_style_line_widget_new())); //Gtk::Widget *strokeStyleWdgt = static_cast(sp_stroke_style_line_widget_new()); strokeStyleWdgt = sp_stroke_style_line_widget_new(); + +#if WITH_GTKMM_3_0 _page_stroke_style->table().attach(*strokeStyleWdgt, 0, 0, 1, 1); +#else + _page_stroke_style->table().attach(*strokeStyleWdgt, 0, 1, 0, 1); +#endif } void diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index d3ce99b00..def7b5bdb 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -15,7 +15,10 @@ #endif #include "find.h" + +#include #include + #include "verbs.h" #include "message-stack.h" @@ -56,6 +59,7 @@ #include "xml/attribute-record.h" #include +#include namespace Inkscape { namespace UI { diff --git a/src/ui/dialog/find.h b/src/ui/dialog/find.h index 77a6c9d02..14d54b8d4 100644 --- a/src/ui/dialog/find.h +++ b/src/ui/dialog/find.h @@ -21,7 +21,11 @@ #include "ui/widget/entry.h" #include "ui/widget/frame.h" #include -#include + +#include +#include +#include +#include #include "desktop.h" #include "ui/dialog/desktop-tracker.h" diff --git a/src/ui/dialog/glyphs.h b/src/ui/dialog/glyphs.h index 6571af0a4..3d0571244 100644 --- a/src/ui/dialog/glyphs.h +++ b/src/ui/dialog/glyphs.h @@ -20,7 +20,7 @@ class Label; class ListStore; } -class SPFontSelector; +struct SPFontSelector; class font_instance; diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index de213ca85..801ab2922 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -20,7 +20,11 @@ #include #include #include + #include +#include +#include + #include #include #include diff --git a/src/ui/dialog/input.cpp b/src/ui/dialog/input.cpp index 9c9f7faa3..82e65435d 100644 --- a/src/ui/dialog/input.cpp +++ b/src/ui/dialog/input.cpp @@ -17,7 +17,9 @@ #include #include + #include +#include #include #include #include diff --git a/src/ui/dialog/layer-properties.h b/src/ui/dialog/layer-properties.h index 9de303f89..0e2f8ed94 100644 --- a/src/ui/dialog/layer-properties.h +++ b/src/ui/dialog/layer-properties.h @@ -80,9 +80,9 @@ protected: void perform(LayerPropertiesDialog &dialog); }; - friend class Rename; - friend class Create; - friend class Move; + friend struct Rename; + friend struct Create; + friend struct Move; Strategy *_strategy; SPDesktop *_desktop; diff --git a/src/ui/dialog/object-properties.cpp b/src/ui/dialog/object-properties.cpp index 114204961..8a2b0299a 100644 --- a/src/ui/dialog/object-properties.cpp +++ b/src/ui/dialog/object-properties.cpp @@ -38,6 +38,12 @@ #include "sp-item.h" #include +#if WITH_GTKMM_3_0 +# include +#else +# include +#endif + namespace Inkscape { namespace UI { diff --git a/src/ui/dialog/object-properties.h b/src/ui/dialog/object-properties.h index b49293ea1..624a18246 100644 --- a/src/ui/dialog/object-properties.h +++ b/src/ui/dialog/object-properties.h @@ -35,6 +35,8 @@ #include "ui/widget/panel.h" #include "ui/widget/frame.h" + +#include #include #include #include @@ -46,6 +48,14 @@ class SPAttributeTable; class SPDesktop; class SPItem; +namespace Gtk { +#if WITH_GTKMM_3_0 +class Grid; +#else +class Table; +#endif +} + namespace Inkscape { namespace UI { namespace Dialog { diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index 0da39dd73..bce63093d 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -15,8 +15,6 @@ # include #endif -#ifdef ENABLE_SVG_FONTS - #include "svg-fonts-dialog.h" #include "document-private.h" #include "document-undo.h" @@ -945,8 +943,6 @@ SvgFontsDialog::~SvgFontsDialog(){} } // namespace UI } // namespace Inkscape -#endif //#ifdef ENABLE_SVG_FONTS - /* Local Variables: mode:c++ diff --git a/src/ui/dialog/svg-fonts-dialog.h b/src/ui/dialog/svg-fonts-dialog.h index 9be984820..01f70654a 100644 --- a/src/ui/dialog/svg-fonts-dialog.h +++ b/src/ui/dialog/svg-fonts-dialog.h @@ -34,8 +34,8 @@ class HScale; #endif } -class SPGlyph; -class SPGlyphKerning; +struct SPGlyph; +struct SPGlyphKerning; class SvgFont; class SvgFontDrawingArea : Gtk::DrawingArea{ diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp index 84d469750..c87e94fc6 100644 --- a/src/ui/dialog/text-edit.cpp +++ b/src/ui/dialog/text-edit.cpp @@ -57,6 +57,7 @@ extern "C" { #include "widgets/icon.h" #include "widgets/font-selector.h" #include +#include #include "unit-constants.h" diff --git a/src/ui/dialog/text-edit.h b/src/ui/dialog/text-edit.h index 3fdeea05d..f27fdfc87 100644 --- a/src/ui/dialog/text-edit.h +++ b/src/ui/dialog/text-edit.h @@ -30,7 +30,7 @@ #include "ui/dialog/desktop-tracker.h" class SPItem; -class SPFontSelector; +struct SPFontSelector; class font_instance; class SPCSSAttr; diff --git a/src/ui/dialog/tracedialog.cpp b/src/ui/dialog/tracedialog.cpp index 1ad827a56..bd467555e 100644 --- a/src/ui/dialog/tracedialog.cpp +++ b/src/ui/dialog/tracedialog.cpp @@ -20,6 +20,7 @@ #include #include "ui/widget/spinbutton.h" #include "ui/widget/frame.h" +#include #include #include //for GTK_RESPONSE* types diff --git a/src/ui/dialog/xml-tree.h b/src/ui/dialog/xml-tree.h index 0a6e3a786..58ef3aef8 100644 --- a/src/ui/dialog/xml-tree.h +++ b/src/ui/dialog/xml-tree.h @@ -29,7 +29,7 @@ #include "message.h" class SPDesktop; -struct SPObject; +class SPObject; struct SPXMLViewAttrList; struct SPXMLViewContent; struct SPXMLViewTree; diff --git a/src/ui/tool/control-point.cpp b/src/ui/tool/control-point.cpp index 8c4924f26..069dcc67b 100644 --- a/src/ui/tool/control-point.cpp +++ b/src/ui/tool/control-point.cpp @@ -7,8 +7,8 @@ */ #include +#include #include -#include #include <2geom/point.h> #include "desktop.h" #include "desktop-handles.h" diff --git a/src/ui/tool/node-tool.h b/src/ui/tool/node-tool.h index 49b1496d4..bc5267bb2 100644 --- a/src/ui/tool/node-tool.h +++ b/src/ui/tool/node-tool.h @@ -25,9 +25,6 @@ #define INK_IS_NODE_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INK_TYPE_NODE_TOOL)) #define INK_IS_NODE_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INK_TYPE_NODE_TOOL)) -class InkNodeTool; -class InkNodeToolClass; - namespace Inkscape { namespace Display { diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index 04148592b..79db1a1c1 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -22,7 +22,7 @@ struct SPCanvasItem; class SPCurve; -struct SPPath; +class SPPath; namespace Inkscape { namespace XML { class Node; } diff --git a/src/ui/widget/entry.cpp b/src/ui/widget/entry.cpp index 173e014d9..64d28119a 100644 --- a/src/ui/widget/entry.cpp +++ b/src/ui/widget/entry.cpp @@ -13,6 +13,8 @@ #include "entry.h" +#include + namespace Inkscape { namespace UI { namespace Widget { diff --git a/src/ui/widget/entry.h b/src/ui/widget/entry.h index 53b848fc9..de5cceadd 100644 --- a/src/ui/widget/entry.h +++ b/src/ui/widget/entry.h @@ -11,10 +11,10 @@ #define INKSCAPE_UI_WIDGET_ENTRY__H #include "labelled.h" -#include -#include -#include +namespace Gtk { +class Entry; +} namespace Inkscape { namespace UI { diff --git a/src/ui/widget/frame.h b/src/ui/widget/frame.h index cf736d8a1..a04666651 100644 --- a/src/ui/widget/frame.h +++ b/src/ui/widget/frame.h @@ -10,11 +10,9 @@ #ifndef INKSCAPE_UI_WIDGET_FRAME_H #define INKSCAPE_UI_WIDGET_FRAME_H -#include - -namespace Gtk { -class Frame; -} +#include +#include +#include namespace Inkscape { namespace UI { diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h index 2a7843a51..fa35b815e 100644 --- a/src/ui/widget/registered-widget.h +++ b/src/ui/widget/registered-widget.h @@ -32,7 +32,7 @@ #include -class SPUnit; +struct SPUnit; class SPDocument; namespace Gtk { diff --git a/src/ui/widget/selected-style.h b/src/ui/widget/selected-style.h index 6d5222429..9b78cb17f 100644 --- a/src/ui/widget/selected-style.h +++ b/src/ui/widget/selected-style.h @@ -40,7 +40,7 @@ #include "helper/units.h" class SPDesktop; -class SPUnit; +struct SPUnit; namespace Inkscape { namespace UI { diff --git a/src/ui/widget/style-swatch.h b/src/ui/widget/style-swatch.h index 2b9c32b2e..d7bab3732 100644 --- a/src/ui/widget/style-swatch.h +++ b/src/ui/widget/style-swatch.h @@ -26,7 +26,7 @@ #include "button.h" #include "preferences.h" -class SPUnit; +struct SPUnit; struct SPStyle; class SPCSSAttr; diff --git a/src/undo-stack-observer.h b/src/undo-stack-observer.h index f4d67e841..1057ace8f 100644 --- a/src/undo-stack-observer.h +++ b/src/undo-stack-observer.h @@ -14,7 +14,7 @@ namespace Inkscape { -class Event; +struct Event; /** * Observes changes made to the undo and redo stacks. diff --git a/src/widgets/gradient-vector.h b/src/widgets/gradient-vector.h index 1ed6c6c46..6719691d1 100644 --- a/src/widgets/gradient-vector.h +++ b/src/widgets/gradient-vector.h @@ -33,7 +33,7 @@ class SPDocument; class SPObject; class SPGradient; -class SPStop; +struct SPStop; struct SPGradientVectorSelector { GtkVBox vbox; diff --git a/src/widgets/paint-selector.h b/src/widgets/paint-selector.h index d3b3f4116..a66758434 100644 --- a/src/widgets/paint-selector.h +++ b/src/widgets/paint-selector.h @@ -22,7 +22,7 @@ class SPGradient; class SPDesktop; -class SPPattern; +struct SPPattern; struct SPStyle; #define SP_TYPE_PAINT_SELECTOR (sp_paint_selector_get_type ()) diff --git a/src/widgets/swatch-selector.h b/src/widgets/swatch-selector.h index b97aac4f1..4b7aa483f 100644 --- a/src/widgets/swatch-selector.h +++ b/src/widgets/swatch-selector.h @@ -1,14 +1,12 @@ #ifndef SEEN_SP_SWATCH_SELECTOR_H #define SEEN_SP_SWATCH_SELECTOR_H - - #include class SPDocument; class SPGradient; -class SPColorSelector; -class SPGradientSelector; +struct SPColorSelector; +struct SPGradientSelector; namespace Inkscape { diff --git a/src/xml/composite-node-observer.h b/src/xml/composite-node-observer.h index 96825d607..3e4b1673a 100644 --- a/src/xml/composite-node-observer.h +++ b/src/xml/composite-node-observer.h @@ -23,7 +23,7 @@ namespace Inkscape { namespace XML { -class NodeEventVector; +struct NodeEventVector; /** * @brief An observer that relays notifications to multiple other observers diff --git a/src/zoom-context.h b/src/zoom-context.h index e36dc3fbe..c09b5a1b3 100644 --- a/src/zoom-context.h +++ b/src/zoom-context.h @@ -19,9 +19,6 @@ #define SP_ZOOM_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_ZOOM_CONTEXT, SPZoomContext)) #define SP_IS_ZOOM_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_ZOOM_CONTEXT)) -class SPZoomContext; -class SPZoomContextClass; - struct SPZoomContext { SPEventContext event_context; SPCanvasItem *grabbed; -- cgit v1.2.3 From b887e821e03cae71b2116d58e64efb62eb9be0be Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 20 Mar 2013 01:47:49 +0100 Subject: For testing, widget added, regression fixed (bzr r11950.1.62) --- src/live_effects/lpe-bspline.cpp | 35 ++++++++++++++++++++++++----------- src/live_effects/lpe-bspline.h | 18 +++++++++--------- src/pen-context.cpp | 2 +- src/ui/tool/path-manipulator.cpp | 7 ++++++- 4 files changed, 40 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index e6461e94c..d3c64bb67 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -11,6 +11,7 @@ #include #include "sp-path.h" #include "style.h" +#include "document-private.h" #include "document.h" #include "document-undo.h" #include "desktop-handles.h" @@ -45,9 +46,9 @@ LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) : Effect(lpeobject), // initialise your parameters here: //testpointA(_("Test Point A"), _("Test A"), "ptA", &wr, this, Geom::Point(100,100)), + steps(_("Steps whith CTRL:"), _("Change number of steps whith CTRL pressed"), "steps", &wr, this, 2), ignoreCusp(_("Ignore cusp nodes:"), _("Change ignoring cusp nodes"), "ignoreCusp", &wr, this, true), - weight(_("Change weight:"), _("Change weight of the effect"), "weight", &wr, this, 33.33), - steps(_("Steps whith CTRL:"), _("Change number of steps whith CTRL pressed"), "steps", &wr, this, 2) + weight(_("Change weight:"), _("Change weight of the effect"), "weight", &wr, this, 33.33) { registerParameter( dynamic_cast(&ignoreCusp) ); registerParameter( dynamic_cast(&weight) ); @@ -64,11 +65,24 @@ LPEBSpline::~LPEBSpline() { } -void -LPEBSpline::doOnApply(SPLPEItem const* lpeitem) +void +LPEBSpline::createAndApply(const char* name, SPDocument *doc, SPItem *item) { - if (!SP_IS_SHAPE(lpeitem)) { + if (!SP_IS_SHAPE(item)) { g_warning("LPE BSpline can only be applied to shapes (not groups)."); + }else{ + // Path effect definition + Inkscape::XML::Document *xml_doc = doc->getReprDoc(); + Inkscape::XML::Node *repr = xml_doc->createElement("inkscape:path-effect"); + repr->setAttribute("effect", name); + + doc->getDefs()->getRepr()->addChild(repr, NULL); // adds to and assigns the 'id' attribute + const gchar * repr_id = repr->attribute("id"); + Inkscape::GC::release(repr); + + gchar *href = g_strdup_printf("#%s", repr_id); + sp_lpe_item_add_path_effect(SP_LPE_ITEM(item), href, true); + g_free(href); } } @@ -289,16 +303,15 @@ LPEBSpline::newWidget() void LPEBSpline::toDefaultWeight(){ -double weightValue = 0.3333; -changeWeight(weightValue); -weight.param_set_value(33.33); -gtk_widget_draw(GTK_WIDGET(LPEBSpline::newWidget()), NULL); + double weightValue = 0.3334; + weight.param_set_value(33.33); + changeWeight(weightValue); } void LPEBSpline::toWeight(){ -double weightValue = weight/100; -changeWeight(weightValue); + double weightValue = weight/100; + changeWeight(weightValue); } void diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index 10d157ac1..44c3f451c 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -15,20 +15,13 @@ namespace LivePathEffect { class LPEBSpline : public Effect { -private: - BoolParam ignoreCusp; - ScalarParam weight; - - LPEBSpline(const LPEBSpline&); - LPEBSpline& operator=(const LPEBSpline&); - public: LPEBSpline(LivePathEffectObject *lpeobject); virtual ~LPEBSpline(); - virtual LPEPathFlashType pathFlashType() const { return SUPPRESS_FLASH; } + virtual void createAndApply(const char* name, SPDocument *doc, SPItem *item); - virtual void doOnApply(SPLPEItem const* lpeitem); + virtual LPEPathFlashType pathFlashType() const { return SUPPRESS_FLASH; } virtual void doEffect(SPCurve * curve); @@ -44,6 +37,13 @@ public: ScalarParam steps; +private: + BoolParam ignoreCusp; + ScalarParam weight; + + LPEBSpline(const LPEBSpline&); + LPEBSpline& operator=(const LPEBSpline&); + }; }; //namespace LivePathEffect diff --git a/src/pen-context.cpp b/src/pen-context.cpp index b43c2ff19..6f61ceb99 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -1791,7 +1791,7 @@ static void bspline_spiro_build(SPPenContext *const pc) //We create the base curve SPCurve *curve = new SPCurve(); //If we continuate the existing curve we add it at the start - if(pc->sa && !pc->sa->curve->is_empty() &&1>2){ + if(pc->sa && !pc->sa->curve->is_empty()){ curve = pc->sa->curve->copy(); if (pc->sa->start) { curve = curve->create_reverse(); diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 853d9336a..c3ab19a4e 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1176,7 +1176,12 @@ void PathManipulator::_createControlPointsFromGeometry() bool PathManipulator::isBSpline(){ LivePathEffect::LPEBSpline *lpe_bsp = NULL; if (SP_LPE_ITEM(_path) && sp_lpe_item_has_path_effect(SP_LPE_ITEM(_path))){ - lpe_bsp = dynamic_cast(sp_lpe_item_has_path_effect_of_type(SP_LPE_ITEM(_path),Inkscape::LivePathEffect::BSPLINE)->getLPEObj()->get_lpe()); + Inkscape::LivePathEffect::Effect* thisEffect = sp_lpe_item_has_path_effect_of_type(SP_LPE_ITEM(_path),Inkscape::LivePathEffect::BSPLINE); + if(thisEffect){ + lpe_bsp = dynamic_cast(thisEffect->getLPEObj()->get_lpe()); + }else{ + lpe_bsp = NULL; + } }else{ lpe_bsp = NULL; } -- cgit v1.2.3 From 49c304e53558c96b2442c06c9beccf5082bb8fe2 Mon Sep 17 00:00:00 2001 From: jtx Date: Wed, 20 Mar 2013 18:12:37 +0100 Subject: Fixing node fault (bzr r11950.4.2) --- src/ui/tool/multi-path-manipulator.cpp | 2 +- src/ui/tool/node.cpp | 47 +++++++++++++--------------------- src/ui/tool/node.h | 8 ++++-- 3 files changed, 25 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp index 3623bb006..94860093d 100644 --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@ -307,7 +307,7 @@ void MultiPathManipulator::setNodeType(NodeType type) Node *node = dynamic_cast(*i); if (node) { retract_handles &= (node->type() == NODE_CUSP); - node->setType(type,true); + node->setType(type); } } diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index e0aec8bb5..738d98e82 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -113,6 +113,7 @@ Handle::Handle(NodeSharedData const &data, Geom::Point const &initial_pos, Node _degenerate(true),controlBsplineSteps(2) { setVisible(false); + isBSpline = _pm().isBSpline; } Handle::~Handle() @@ -143,8 +144,7 @@ void Handle::move(Geom::Point const &new_pos) double pos = 0; Handle *h = NULL; Handle *h2 = NULL; - if(_pm().isBSpline){ - isBSpline = true; + if(isBSpline){ typedef ControlPointSelection::Set Set; Set &nodes = _parent->_selection.allPoints(); for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { @@ -324,7 +324,7 @@ bool Handle::_eventHandler(SPEventContext *event_context, GdkEvent *event) //BSpline void Handle::handle_2button_press(){ - if(_pm().isBSpline){ + if(isBSpline){ Handle *h = NULL; Handle *h2 = NULL; double pos = 0; @@ -386,7 +386,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) } new_pos = result; //BSpline - if(_pm().isBSpline){ + if(isBSpline){ Handle *h = NULL; double pos = 0; h = this; @@ -398,7 +398,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) } std::vector unselected; - if (snap && ( (!held_control(*event) && _pm().isBSpline) || !_pm().isBSpline)) { + if (snap && ( (!held_control(*event) && isBSpline) || !isBSpline)) { ControlPointSelection::Set &nodes = _parent->_selection.allPoints(); for (ControlPointSelection::Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { Node *n = static_cast(*i); @@ -580,6 +580,7 @@ Node::Node(NodeSharedData const &data, Geom::Point const &initial_pos) : _handles_shown(false) { // NOTE we do not set type here, because the handles are still degenerate + isBSpline = _pm().isBSpline; } Node const *Node::_next() const @@ -625,7 +626,7 @@ void Node::move(Geom::Point const &new_pos) Node *n = this; Node * nextNode = n->nodeToward(n->front()); Node * prevNode = n->nodeToward(n->back()); - if(_pm().isBSpline){ + if(isBSpline){ if(prevNode) prevPos = _pm().BSplineHandlePosition(prevNode->front()); pos = _pm().BSplineHandlePosition(n->front()); @@ -637,7 +638,7 @@ void Node::move(Geom::Point const &new_pos) //BSpline End setPosition(new_pos); //BSpline - if(_pm().isBSpline){ + if(isBSpline){ if(prevNode) prevNode->front()->setPosition(_pm().BSplineHandleReposition(prevNode->front(),prevPos)); if(nextNode) @@ -651,7 +652,7 @@ void Node::move(Geom::Point const &new_pos) // with the segment _fixNeighbors(old_pos, new_pos); //BSpline - if(_pm().isBSpline){ + if(isBSpline){ Handle* front = &_front; Handle* back = &_back; _front.setPosition(_pm().BSplineHandleReposition(front,pos)); @@ -773,27 +774,6 @@ void Node::setType(NodeType type, bool update_handles) return; } - //BSpline - if(_pm().isBSpline){ - if (isEndNode()) return; - Handle* front = &_front; - Handle* back = &_back; - double pos = 0.3334; - switch (type) { - case NODE_CUSP: - if(update_handles) - pos = 0; - else - pos = _pm().BSplineHandlePosition(front);; - break; - default: break; - } - type = NODE_CUSP; - _front.setPosition(_pm().BSplineHandleReposition(front,pos)); - _back.setPosition(_pm().BSplineHandleReposition(back,pos)); - } - //BSpline End - // if update_handles is true, adjust handle positions to match the node type // handle degenerate handles appropriately if (update_handles) { @@ -882,6 +862,15 @@ void Node::setType(NodeType type, bool update_handles) _setControlType(nodeTypeToCtrlType(_type)); updateState(); + //BSpline + if(isBSpline){ + Handle* front = &_front; + Handle* back = &_back; + double pos = _pm().BSplineHandlePosition(front); + _front.setPosition(_pm().BSplineHandleReposition(front,pos)); + _back.setPosition(_pm().BSplineHandleReposition(back,pos)); + } + //BSpline End } void Node::pickBestType() diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h index 7152f37fd..a384db7cc 100644 --- a/src/ui/tool/node.h +++ b/src/ui/tool/node.h @@ -120,7 +120,9 @@ protected: virtual bool _hasDragTips() const { return true; } private: - + //BSpline + bool isBSpline; + //BSpline End inline PathManipulator &_pm(); Node *_parent; // the handle's lifetime does not extend beyond that of the parent node, // so a naked pointer is OK and allows setting it during Node's construction @@ -236,7 +238,9 @@ protected: virtual bool _hasDragTips() const { return true; } private: - + //BSpline + bool isBSpline; + //BSpline End Node(Node const &); void _fixNeighbors(Geom::Point const &old_pos, Geom::Point const &new_pos); void _updateAutoHandles(); -- cgit v1.2.3 From d8278200b80518c4a7c2f4fda642102ff268851d Mon Sep 17 00:00:00 2001 From: jtx Date: Wed, 20 Mar 2013 18:50:31 +0100 Subject: Fixing node fault (bzr r11950.4.3) --- src/ui/tool/node.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 738d98e82..93b45bde7 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -113,7 +113,12 @@ Handle::Handle(NodeSharedData const &data, Geom::Point const &initial_pos, Node _degenerate(true),controlBsplineSteps(2) { setVisible(false); - isBSpline = _pm().isBSpline; + std::string strPathManipulatorName = "PathManipulator"; + if(std::string(typeid(_pm()).name()) == strPathManipulatorName) + isBSpline = _pm().isBSpline; + else + //Esto no es cierto realmente pero evita que casque al crear nodos + isBSpline = false; } Handle::~Handle() @@ -580,7 +585,12 @@ Node::Node(NodeSharedData const &data, Geom::Point const &initial_pos) : _handles_shown(false) { // NOTE we do not set type here, because the handles are still degenerate - isBSpline = _pm().isBSpline; + std::string strPathManipulatorName = "PathManipulator"; + if(std::string(typeid(_pm()).name()) == strPathManipulatorName) + isBSpline = _pm().isBSpline; + else + //Esto no es cierto realmente pero evita que casque al crear nodos + isBSpline = false; } Node const *Node::_next() const -- cgit v1.2.3 From f99e35afe4c7d572a5e3a98b12571e577c1b3d14 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 21 Mar 2013 02:39:16 +0100 Subject: Fixed redraw handles at node delete (bzr r11950.1.64) --- src/ui/tool/path-manipulator.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index fc4439711..431cc2d96 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -664,12 +664,6 @@ unsigned PathManipulator::_deleteStretch(NodeList::iterator start, NodeList::ite start.prev()->front()->setPosition(result[1]); end->back()->setPosition(result[2]); - //BSpline - if(isBSpline){ - start.prev()->front()->setPosition(BSplineHandleReposition(start.prev()->front())); - end->back()->setPosition(BSplineHandleReposition(end->back())); - } - //BSpline End } // We can't use nl->erase(start, end), because it would break when the stretch @@ -680,6 +674,12 @@ unsigned PathManipulator::_deleteStretch(NodeList::iterator start, NodeList::ite nl.erase(start); start = next; } + //BSpline + if(isBSpline){ + start.prev()->front()->setPosition(BSplineHandleReposition(start.prev()->front())); + end->back()->setPosition(BSplineHandleReposition(end->back())); + } + //BSpline End return del_len; } -- cgit v1.2.3 From a60fc5880c9bab8bf471c2ef808499182201b621 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 21 Mar 2013 10:53:39 +0100 Subject: Fixing errors at delete extrewmiuns nodes (bzr r11950.1.65) --- src/ui/tool/path-manipulator.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 431cc2d96..571e6dd7a 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1197,13 +1197,19 @@ double PathManipulator::BSplineHandlePosition(Handle *h){ double pos = 0; Node *n = h->parent(); SPCurve *lineInsideNodes = new SPCurve(); - Node * nextNode = n->nodeToward(h); - Geom::Point positionH = h->position(); - positionH = Geom::Point(positionH[X] - 0.0625,positionH[Y] - 0.0625); - if(nextNode && n->position() != h->position()){ - lineInsideNodes->moveto(n->position()); - lineInsideNodes->lineto(nextNode->position()); - pos = Geom::nearest_point(positionH,*lineInsideNodes->first_segment()); + Node * nextNode = NULL; + try{ + nextNode = n->nodeToward(h); + }catch( char * str ) { + } + if(nextNode){ + Geom::Point positionH = h->position(); + positionH = Geom::Point(positionH[X] - 0.0625,positionH[Y] - 0.0625); + if(nextNode && n->position() != h->position()){ + lineInsideNodes->moveto(n->position()); + lineInsideNodes->lineto(nextNode->position()); + pos = Geom::nearest_point(positionH,*lineInsideNodes->first_segment()); + } } return pos; } @@ -1220,7 +1226,11 @@ Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){ Node *n = h->parent(); Geom::D2< Geom::SBasis > SBasisInsideNodes; SPCurve *lineInsideNodes = new SPCurve(); - Node * nextNode = n->nodeToward(h); + Node * nextNode = NULL; + try{ + nextNode = n->nodeToward(h); + }catch( char * str ) { + } if(nextNode && pos != 0){ lineInsideNodes->moveto(n->position()); lineInsideNodes->lineto(nextNode->position()); -- cgit v1.2.3 From d142ebe8740c40922c1a6aa423ca4e0e7d2335d6 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 22 Mar 2013 01:50:18 +0100 Subject: Fixed end extremium node delete fault, ready for testing (bzr r11950.1.66) --- src/live_effects/lpe-bspline.h | 1 + src/ui/tool/path-manipulator.cpp | 36 +++++++++++++++++++++++------------- src/ui/tool/path-manipulator.h | 6 +++++- src/widgets/toolbox.cpp | 6 +++--- 4 files changed, 32 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index 44c3f451c..20012f894 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -38,6 +38,7 @@ public: ScalarParam steps; private: + BoolParam ignoreCusp; ScalarParam weight; diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 571e6dd7a..8f6651dee 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -9,9 +9,7 @@ * Copyright (C) 2009 Authors * Released under GNU GPL, read the file 'COPYING' for more information */ -//BSpline -#include "live_effects/lpe-bspline.h" -//BSpline end + #include "live_effects/lpe-powerstroke.h" #include #include @@ -46,6 +44,9 @@ #include "ui/tool/multi-path-manipulator.h" #include "xml/node.h" #include "xml/node-observer.h" +//BSpline +#include "live_effects/lpe-bspline.h" +//BSpline end namespace Inkscape { namespace UI { @@ -149,8 +150,8 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, sigc::hide( sigc::mem_fun(*this, &PathManipulator::_updateOutlineOnZoomChange))); _createControlPointsFromGeometry(); - - LivePathEffect::LPEBSpline *lpe_bsp = NULL; + //BSpline + lpe_bsp = NULL; if (SP_LPE_ITEM(_path) && sp_lpe_item_has_path_effect(SP_LPE_ITEM(_path))){ Inkscape::LivePathEffect::Effect* thisEffect = sp_lpe_item_has_path_effect_of_type(SP_LPE_ITEM(_path),Inkscape::LivePathEffect::BSPLINE); if(thisEffect){ @@ -162,6 +163,7 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, isBSpline = true; controlBSplineSteps = lpe_bsp->steps+1; } + //BSpline End } PathManipulator::~PathManipulator() @@ -676,8 +678,15 @@ unsigned PathManipulator::_deleteStretch(NodeList::iterator start, NodeList::ite } //BSpline if(isBSpline){ - start.prev()->front()->setPosition(BSplineHandleReposition(start.prev()->front())); - end->back()->setPosition(BSplineHandleReposition(end->back())); + double pos = 0; + if(start.prev()){ + pos = BSplineHandlePosition(start.prev()->back()); + start.prev()->front()->setPosition(BSplineHandleReposition(start.prev()->front(),pos)); + } + if(end){ + pos = BSplineHandlePosition(end->front()); + end->back()->setPosition(BSplineHandleReposition(end->back(),pos)); + } } //BSpline End @@ -1192,16 +1201,19 @@ void PathManipulator::_createControlPointsFromGeometry() } double PathManipulator::BSplineHandlePosition(Handle *h){ + //BSpline + if(lpe_bsp){ + controlBSplineSteps = lpe_bsp->steps+1; + } + //BSpline End using Geom::X; using Geom::Y; double pos = 0; Node *n = h->parent(); SPCurve *lineInsideNodes = new SPCurve(); Node * nextNode = NULL; - try{ + if(!n->isEndNode()) nextNode = n->nodeToward(h); - }catch( char * str ) { - } if(nextNode){ Geom::Point positionH = h->position(); positionH = Geom::Point(positionH[X] - 0.0625,positionH[Y] - 0.0625); @@ -1227,10 +1239,8 @@ Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){ Geom::D2< Geom::SBasis > SBasisInsideNodes; SPCurve *lineInsideNodes = new SPCurve(); Node * nextNode = NULL; - try{ + if(!n->isEndNode()) nextNode = n->nodeToward(h); - }catch( char * str ) { - } if(nextNode && pos != 0){ lineInsideNodes->moveto(n->position()); lineInsideNodes->lineto(nextNode->position()); diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index 948d4544b..496bd957c 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -19,6 +19,9 @@ #include #include "ui/tool/node.h" #include "ui/tool/manipulator.h" +//BSpline +#include "live_effects/lpe-bspline.h" +//BSpline end struct SPCanvasItem; class SPCurve; @@ -96,6 +99,7 @@ public: bool search_unselected, bool closest); //BSpline bool isBSpline; + int controlBSplineSteps; //BSpline End // this is necessary for Tab-selection in MultiPathManipulator SubpathList &subpathList() { return _subpaths; } @@ -107,7 +111,7 @@ private: void _createControlPointsFromGeometry(); //BSpline - int controlBSplineSteps; + LivePathEffect::LPEBSpline *lpe_bsp; double BSplineHandlePosition(Handle *h); Geom::Point BSplineHandleReposition(Handle *h); Geom::Point BSplineHandleReposition(Handle *h,double pos); diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 3a7eb6b9c..99978c019 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -514,9 +514,9 @@ static gchar const * ui_descr = " " " " " " -// " " -// " " -// " " + " " + " " + " " " " " " -- cgit v1.2.3 From ce36f79a45c3ce7e520c14b6cab965c0bd9a32fa Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 22 Mar 2013 09:48:09 +0100 Subject: Enabling Mesh (bzr r11950.1.67) --- src/widgets/toolbox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 99978c019..3ffeff1fd 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -113,7 +113,7 @@ enum BarId { #define BAR_ID_KEY "BarIdValue" #define HANDLE_POS_MARK "x-inkscape-pos" - +#define WITH_MESH static GtkWidget *sp_empty_toolbox_new(SPDesktop *desktop); -- cgit v1.2.3 From c34969161a38e67408b654a8b308b45ca638811f Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 23 Mar 2013 15:57:26 +0100 Subject: Remove extra code (bzr r11950.1.69) --- src/ui/tool/path-manipulator.cpp | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'src') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 84e300306..f8c5deea2 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -841,11 +841,6 @@ void PathManipulator::scaleHandle(Node *n, int which, int dir, bool pixel) relpos *= ((rellen + length_change) / rellen); } h->setRelativePos(relpos); - - if(isBSpline){ - double pos = BSplineHandlePosition(h); - h->setPosition(BSplineHandleReposition(h,pos)); - } update(); gchar const *key = which < 0 ? "handle:scale:left" : "handle:scale:right"; _commit(_("Scale handle"), key); @@ -870,12 +865,6 @@ void PathManipulator::rotateHandle(Node *n, int which, int dir, bool pixel) } h->setRelativePos(h->relativePos() * Geom::Rotate(angle)); - - if(isBSpline){ - double pos = BSplineHandlePosition(h); - h->setPosition(BSplineHandleReposition(h,pos)); - } - update(); gchar const *key = which < 0 ? "handle:rotate:left" : "handle:rotate:right"; -- cgit v1.2.3 From 37d99686ec9b0a49c1ef07483967571da674e65e Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 23 Mar 2013 20:09:28 +0100 Subject: Fix weight 0 by widget now give a full cusp node (bzr r11950.1.70) --- src/live_effects/lpe-bspline.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 0a13c17b2..ee771a54e 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -399,20 +399,20 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue , bool ignor pointAt0 = in->first_segment()->initialPoint(); SBasisIn = in->first_segment()->toSBasis(); if(cubic){ - if(!ignoreCusp || !Geom::are_near((*cubic)[1],in->first_segment()->initialPoint())){ + if((!ignoreCusp || !Geom::are_near((*cubic)[1],in->first_segment()->initialPoint())) && weightValue !=0){ pointAt1 = SBasisIn.valueAt(weightValue); pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); }else{ pointAt1 = in->first_segment()->initialPoint(); } - if(!ignoreCusp || !Geom::are_near((*cubic)[2],in->first_segment()->finalPoint())){ + if((!ignoreCusp || !Geom::are_near((*cubic)[2],in->first_segment()->finalPoint())) && weightValue !=0){ pointAt2 = SBasisIn.valueAt(1-weightValue); pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); }else{ pointAt2 = in->first_segment()->finalPoint(); } }else{ - if(!ignoreCusp){ + if(!ignoreCusp && weightValue !=0){ pointAt1 = SBasisIn.valueAt(weightValue); pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); pointAt2 = SBasisIn.valueAt(1-weightValue); @@ -433,20 +433,20 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue , bool ignor SBasisOut = out->first_segment()->toSBasis(); cubic = dynamic_cast(&*curve_it2); if(cubic){ - if(!ignoreCusp || !Geom::are_near((*cubic)[1],out->first_segment()->initialPoint())){ + if((!ignoreCusp || !Geom::are_near((*cubic)[1],out->first_segment()->initialPoint()))&& weightValue !=0){ nextPointAt1 = SBasisOut.valueAt(weightValue); nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); }else{ nextPointAt1 = out->first_segment()->initialPoint(); } - if(!ignoreCusp || !Geom::are_near((*cubic)[2],out->first_segment()->finalPoint())){ + if((!ignoreCusp || !Geom::are_near((*cubic)[2],out->first_segment()->finalPoint()))&& weightValue !=0){ nextPointAt2 = SBasisOut.valueAt(1-weightValue); nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); }else{ nextPointAt2 = out->first_segment()->finalPoint(); } }else{ - if(!ignoreCusp){ + if(!ignoreCusp && weightValue !=0){ nextPointAt1 = SBasisOut.valueAt(weightValue); nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); nextPointAt2 = SBasisOut.valueAt(1-weightValue); -- cgit v1.2.3 From dc09bd5bbbacdf10d28ee9053ce3c74f87753f3e Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 29 Mar 2013 12:34:40 +0100 Subject: Fix bspline icon show (bzr r11950.1.77) --- src/widgets/mappings.xml | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/widgets/mappings.xml b/src/widgets/mappings.xml index 2de3ff545..089bf76ea 100644 --- a/src/widgets/mappings.xml +++ b/src/widgets/mappings.xml @@ -197,6 +197,7 @@ + -- cgit v1.2.3 From a7ced41f3fa6933d0da0151ef42e82e0862581fb Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 1 Apr 2013 01:09:52 +0200 Subject: Fix scale and rotate some nodes (bzr r11950.1.78) --- src/live_effects/lpe-bspline.cpp | 22 ++++++++++++++++++++- src/ui/tool/node.cpp | 41 ++++++++++++++++++++-------------------- src/ui/tool/node.h | 2 +- src/ui/tool/path-manipulator.cpp | 26 ++++++++++++++++--------- src/ui/tool/path-manipulator.h | 1 + 5 files changed, 60 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index ee771a54e..37d6a86a5 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -29,6 +29,7 @@ #include "ui/widget/scalar.h" #include "selection.h" #include "gtkmm/checkbutton.h" +#include "ui/tool/node.h" // For handling un-continuous paths: #include "message-stack.h" #include "inkscape.h" @@ -337,15 +338,34 @@ LPEBSpline::changeWeight(double weightValue) DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_LPE, _("Modified the weight of the BSpline")); } - +//bool +//LPEBspline::selectedPoint(Geom::Point p){ +// for (SubpathList::iterator i = NodeIterator.begin(); i != NodeIterator.end(); ++i) { +// if (i->selected() && i.ptr()->getPosition() == p) { +// return true; +// } +// } +// return false; +//} +//bool +//LPEBspline::hasNodesSelected(){ +// for (SubpathList::iterator i = NodeIterator.begin(); i != NodeIterator.end(); ++i) { +// if (i->selected() && i.ptr()->getPosition() == p) { +// return true; +// } +// } +// return false; +//} void LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue , bool ignoreCusp) { using Geom::X; using Geom::Y; + //bool hasNodesSelected = LPEBspline::hasNodesSelected(); if(curve->get_segment_count() < 2) return; // Make copy of old path as it is changed during processing + Geom::PathVector const original_pathv = curve->get_pathvector(); curve->reset(); diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index b4976bde5..dfa9c5d84 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -139,7 +139,6 @@ void Handle::move(Geom::Point const &new_pos) Handle *towards = node_towards ? node_towards->handleAwayFrom(_parent) : NULL; Handle *towards_second = node_towards ? node_towards->handleToward(_parent) : NULL; //BSpline - double pos = 0; Handle *h = NULL; Handle *h2 = NULL; if(_pm().isBSpline){ @@ -189,9 +188,9 @@ void Handle::move(Geom::Point const &new_pos) if(_pm().isBSpline){ h = this; setPosition(_pm().BSplineHandleReposition(h)); - pos = _pm().BSplineHandlePosition(h); + _parent->bsplineWeight = _pm().BSplineHandlePosition(h); h2 = this->other(); - this->other()->setPosition(_pm().BSplineHandleReposition(h2,pos)); + this->other()->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); } //BSpline End return; @@ -228,9 +227,9 @@ void Handle::move(Geom::Point const &new_pos) if(_pm().isBSpline){ h = this; setPosition(_pm().BSplineHandleReposition(h)); - pos = _pm().BSplineHandlePosition(h); + _parent->bsplineWeight = _pm().BSplineHandlePosition(h); h2 = this->other(); - this->other()->setPosition(_pm().BSplineHandleReposition(h2,pos)); + this->other()->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); } //BSpline End } @@ -325,12 +324,12 @@ void Handle::handle_2button_press(){ if(_pm().isBSpline){ Handle *h = NULL; Handle *h2 = NULL; - double pos = 0; + _parent->bsplineWeight = 0; h = this; setPosition(_pm().BSplineHandleReposition(h,0.3334)); - pos = _pm().BSplineHandlePosition(h); + _parent->bsplineWeight = _pm().BSplineHandlePosition(h); h2 = this->other(); - this->other()->setPosition(_pm().BSplineHandleReposition(h2,pos)); + this->other()->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); _pm().update(); } } @@ -386,12 +385,12 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) //BSpline if(_pm().isBSpline){ Handle *h = NULL; - double pos = 0; + _parent->bsplineWeight = 0; h = this; setPosition(new_pos); int steps = _pm().getSteps(); - pos = ceilf(_pm().BSplineHandlePosition(h)*steps)/steps; - new_pos=_pm().BSplineHandleReposition(h,pos); + _parent->bsplineWeight = ceilf(_pm().BSplineHandlePosition(h)*steps)/steps; + new_pos=_pm().BSplineHandleReposition(h,_parent->bsplineWeight); } //BSpline End } @@ -579,6 +578,7 @@ Node::Node(NodeSharedData const &data, Geom::Point const &initial_pos) : _handles_shown(false) { // NOTE we do not set type here, because the handles are still degenerate + this->bsplineWeight = 0.3334; } Node const *Node::_next() const @@ -619,7 +619,6 @@ void Node::move(Geom::Point const &new_pos) Geom::Point delta = new_pos - position(); //BSpline double prevPos = 0; - double pos = 0; double nextPos = 0; Node *n = this; Node * nextNode = n->nodeToward(n->front()); @@ -627,9 +626,9 @@ void Node::move(Geom::Point const &new_pos) if(_pm().isBSpline){ if(prevNode) prevPos = _pm().BSplineHandlePosition(prevNode->front()); - pos = _pm().BSplineHandlePosition(n->front()); - if(pos == 0) - pos = _pm().BSplineHandlePosition(n->back()); + n->bsplineWeight = _pm().BSplineHandlePosition(n->front()); + if(n->bsplineWeight == 0) + n->bsplineWeight = _pm().BSplineHandlePosition(n->back()); if(nextNode) nextPos = _pm().BSplineHandlePosition(nextNode->back()); } @@ -653,8 +652,8 @@ void Node::move(Geom::Point const &new_pos) if(_pm().isBSpline){ Handle* front = &_front; Handle* back = &_back; - _front.setPosition(_pm().BSplineHandleReposition(front,pos)); - _back.setPosition(_pm().BSplineHandleReposition(back,pos)); + _front.setPosition(_pm().BSplineHandleReposition(front,n->bsplineWeight)); + _back.setPosition(_pm().BSplineHandleReposition(back,n->bsplineWeight)); } } @@ -864,10 +863,10 @@ void Node::setType(NodeType type, bool update_handles) if(isBSpline){ Handle* front = &_front; Handle* back = &_back; - double pos = _pm().BSplineHandlePosition(front); - if(pos !=0) pos = 0.3334; - _front.setPosition(_pm().BSplineHandleReposition(front,pos)); - _back.setPosition(_pm().BSplineHandleReposition(back,pos)); + this->bsplineWeight = _pm().BSplineHandlePosition(front); + if(this->bsplineWeight !=0) this->bsplineWeight = 0.3334; + _front.setPosition(_pm().BSplineHandleReposition(front,this->bsplineWeight)); + _back.setPosition(_pm().BSplineHandleReposition(back,this->bsplineWeight)); } //BSpline End } diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h index 2b547256b..f6d5beadc 100644 --- a/src/ui/tool/node.h +++ b/src/ui/tool/node.h @@ -180,7 +180,7 @@ public: bool isEndNode() const; Handle *front() { return &_front; } Handle *back() { return &_back; } - + double bsplineWeight; /** * Gets the handle that faces the given adjacent node. * Will abort with error if the given node is not adjacent. diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 1607585c5..be5514e1f 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -862,7 +862,6 @@ void PathManipulator::rotateHandle(Node *n, int which, int dir, bool pixel) int snaps = prefs->getIntLimited("/options/rotationsnapsperpi/value", 12, 1, 1000); angle = M_PI * dir / snaps; } - h->setRelativePos(h->relativePos() * Geom::Rotate(angle)); update(); @@ -1211,14 +1210,12 @@ double PathManipulator::BSplineHandlePosition(Handle *h){ Node * nextNode = NULL; if(!n->isEndNode()) nextNode = n->nodeToward(h); - if(nextNode){ - Geom::Point positionH = h->position(); - positionH = Geom::Point(positionH[X] - 0.0625,positionH[Y] - 0.0625); - if(nextNode && n->position() != h->position()){ - lineInsideNodes->moveto(n->position()); - lineInsideNodes->lineto(nextNode->position()); - pos = Geom::nearest_point(positionH,*lineInsideNodes->first_segment()); - } + Geom::Point positionH = h->position(); + positionH = Geom::Point(positionH[X] - 0.0625,positionH[Y] - 0.0625); + if(nextNode && n->position() != h->position()){ + lineInsideNodes->moveto(n->position()); + lineInsideNodes->lineto(nextNode->position()); + pos = Geom::nearest_point(positionH,*lineInsideNodes->first_segment()); } return pos; } @@ -1250,6 +1247,11 @@ Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){ return ret; } +void PathManipulator::BSplineNodeHandlesReposition(Node *n){ + n->front()->setPosition(BSplineHandleReposition(n->front(),n->bsplineWeight)); + n->back()->setPosition(BSplineHandleReposition(n->back(),n->bsplineWeight)); +} + /** Construct the geometric representation of nodes and handles, update the outline * and display * \param alert_LPE if true, first the LPE is warned what the new path is going to be before updating it @@ -1264,8 +1266,14 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) continue; } NodeList::iterator prev = subpath->begin(); + if(isBSpline){ + BSplineNodeHandlesReposition(prev.ptr()); + } builder.moveTo(prev->position()); for (NodeList::iterator i = ++subpath->begin(); i != subpath->end(); ++i) { + if(isBSpline){ + BSplineNodeHandlesReposition(i.ptr()); + } build_segment(builder, prev.ptr(), i.ptr()); prev = i; } diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index e68cabef1..743d70b96 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -115,6 +115,7 @@ private: double BSplineHandlePosition(Handle *h); Geom::Point BSplineHandleReposition(Handle *h); Geom::Point BSplineHandleReposition(Handle *h,double pos); + void BSplineNodeHandlesReposition(Node *n); //BSpline End void _createGeometryFromControlPoints(bool alert_LPE = false); unsigned _deleteStretch(NodeList::iterator first, NodeList::iterator last, bool keep_shape); -- cgit v1.2.3 From 6ffc63f4ecd0550225a6fc752aba128575733a22 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 1 Apr 2013 10:03:19 +0200 Subject: Fixed scale-rotate isue with paths multiples (bzr r11950.1.80) --- src/ui/tool/node.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index dfa9c5d84..1f609dfa0 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -1118,6 +1118,12 @@ void Node::_setState(State state) case STATE_CLICKED: mgr.setActive(_canvas_item, true); mgr.setPrelight(_canvas_item, false); + //BSpline + if(_pm().isBSpline){ + this->bsplineWeight = _pm().BSplineHandlePosition(this->back()); + _pm().BSplineNodeHandlesReposition(this); + } + //BSpline End break; } SelectableControlPoint::_setState(state); -- cgit v1.2.3 From 0b6a723f67700368d3585fc9b8009a3db30b5473 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 4 Apr 2013 19:34:41 +0200 Subject: Changing width only to selected nodes (bzr r11950.1.81) --- src/live_effects/lpe-bspline.cpp | 282 ++++++++++++++++++++++++++++----------- src/live_effects/lpe-bspline.h | 9 +- 2 files changed, 214 insertions(+), 77 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 37d6a86a5..389c11a23 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -3,12 +3,25 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ - -#include "xml/repr.h" -#include "svg/svg.h" -#include "display/curve.h" +#include +#include +#include #include #include +#include "display/curve.h" +#include <2geom/bezier-curve.h> +#include "helper/geom-curves.h" +#include "live_effects/lpe-bspline.h" +#include "live_effects/lpeobject.h" +#include "live_effects/parameter/parameter.h" +#include "ui/widget/scalar.h" +#include "ui/tool/node.h" +#include "ui/tool/node-tool.h" +#include "ui/tool/control-point-selection.h" +#include "ui/tool/selectable-control-point.h" +#include "selection.h" +#include "xml/repr.h" +#include "svg/svg.h" #include "sp-path.h" #include "style.h" #include "document-private.h" @@ -16,20 +29,10 @@ #include "document-undo.h" #include "desktop-handles.h" #include "verbs.h" -#include "live_effects/lpe-bspline.h" -#include -#include #include "sp-lpe-item.h" -#include "live_effects/lpeobject.h" -#include "live_effects/parameter/parameter.h" #include "display/sp-canvas.h" #include -#include <2geom/bezier-curve.h> -#include "helper/geom-curves.h" -#include "ui/widget/scalar.h" -#include "selection.h" -#include "gtkmm/checkbutton.h" -#include "ui/tool/node.h" +#include // For handling un-continuous paths: #include "message-stack.h" #include "inkscape.h" @@ -49,9 +52,11 @@ LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) : //testpointA(_("Test Point A"), _("Test A"), "ptA", &wr, this, Geom::Point(100,100)), steps(_("Steps whith CTRL:"), _("Change number of steps whith CTRL pressed"), "steps", &wr, this, 2), ignoreCusp(_("Ignore cusp nodes:"), _("Change ignoring cusp nodes"), "ignoreCusp", &wr, this, true), + onlySelected(_("Change only selected nodes:"), _("Change only selected nodes"), "onlySelected", &wr, this, false), weight(_("Change weight:"), _("Change weight of the effect"), "weight", &wr, this, 0.3334) { registerParameter( dynamic_cast(&ignoreCusp) ); + registerParameter( dynamic_cast(&onlySelected) ); registerParameter( dynamic_cast(&weight) ); registerParameter( dynamic_cast(&steps) ); weight.param_set_range(0.0000, 1); @@ -279,6 +284,10 @@ LPEBSpline::newWidget() widgRegistered->signal_value_changed().connect(sigc::mem_fun (*this,&LPEBSpline::toWeight)); widg = dynamic_cast(widgRegistered); } + if(param->param_key == "onlySelected"){ + Gtk::CheckButton * widgRegistered = Gtk::manage(dynamic_cast(widg)); + widg = dynamic_cast(widgRegistered); + } if(param->param_key == "ignoreCusp"){ Gtk::CheckButton * widgRegistered = Gtk::manage(dynamic_cast(widg)); widg = dynamic_cast(widgRegistered); @@ -307,7 +316,7 @@ LPEBSpline::newWidget() void LPEBSpline::toDefaultWeight(){ - Gtk::Widget * widg = dynamic_cast(param_vector[2]->param_newWidget()); + Gtk::Widget * widg = dynamic_cast(param_vector[3]->param_newWidget()); Inkscape::UI::Widget::Scalar * widgRegistered = Gtk::manage(dynamic_cast(widg)); widgRegistered->setValue(0.3334); widgRegistered->update(); @@ -329,7 +338,7 @@ LPEBSpline::changeWeight(double weightValue) SPItem *item = (SPItem *)g_slist_nth(items,0)->data; SPPath *path = SP_PATH(item); SPCurve *curve = path->get_curve_for_edit(); - LPEBSpline::doBSplineFromWidget(curve,weightValue,ignoreCusp); + LPEBSpline::doBSplineFromWidget(curve,weightValue); gchar *str = sp_svg_write_path(curve->get_pathvector()); path->getRepr()->setAttribute("inkscape:original-d", str); g_free(str); @@ -338,34 +347,42 @@ LPEBSpline::changeWeight(double weightValue) DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_LPE, _("Modified the weight of the BSpline")); } -//bool -//LPEBspline::selectedPoint(Geom::Point p){ -// for (SubpathList::iterator i = NodeIterator.begin(); i != NodeIterator.end(); ++i) { -// if (i->selected() && i.ptr()->getPosition() == p) { -// return true; -// } -// } -// return false; -//} -//bool -//LPEBspline::hasNodesSelected(){ -// for (SubpathList::iterator i = NodeIterator.begin(); i != NodeIterator.end(); ++i) { -// if (i->selected() && i.ptr()->getPosition() == p) { -// return true; -// } -// } -// return false; -//} + +bool +LPEBSpline::nodeIsSelected(Geom::Point nodePoint, int index){ + volatile int index2 = index; + volatile Geom::Point aa = nodePoint; + volatile std::vector x2 = points; + if(points.size() > 0){ + volatile double dist = Geom::distance(points[index], nodePoint); + if(dist == 0 ){ + return true; + } + } + return false; +} + void -LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue , bool ignoreCusp) +LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) { using Geom::X; using Geom::Y; + SPDesktop *desktop = inkscape_active_desktop(); + if(INK_IS_NODE_TOOL(desktop->event_context)){ + InkNodeTool *nt = INK_NODE_TOOL(desktop->event_context); + Inkscape::UI::ControlPointSelection::Set &selection = nt->_selected_nodes->allPoints(); + points.clear(); + for (Inkscape::UI::ControlPointSelection::Set::iterator i = selection.begin(); i != selection.end(); ++i){ + if ((*i)->selected()) { + Inkscape::UI::Node *n = static_cast(*i); + points.push_back(n->position()); + } + } + } //bool hasNodesSelected = LPEBspline::hasNodesSelected(); if(curve->get_segment_count() < 2) return; // Make copy of old path as it is changed during processing - Geom::PathVector const original_pathv = curve->get_pathvector(); curve->reset(); @@ -388,12 +405,14 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue , bool ignor Geom::Point pointAt1(0,0); Geom::Point pointAt2(0,0); Geom::Point pointAt3(0,0); + Geom::Point nextPointAt0(0,0); Geom::Point nextPointAt1(0,0); Geom::Point nextPointAt2(0,0); Geom::Point nextPointAt3(0,0); Geom::D2< Geom::SBasis > SBasisIn; Geom::D2< Geom::SBasis > SBasisOut; Geom::CubicBezier const *cubic = NULL; + int i = 0; if (path_it->closed()) { // if the path is closed, maybe we have to stop a bit earlier because the closing line segment has zerolength. const Geom::Curve &closingline = path_it->back_closed(); // the closing line segment is always of type Geom::LineSegment. @@ -417,32 +436,88 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue , bool ignor in->lineto(curve_it1->finalPoint()); cubic = dynamic_cast(&*curve_it1); pointAt0 = in->first_segment()->initialPoint(); + pointAt3 = in->first_segment()->finalPoint(); SBasisIn = in->first_segment()->toSBasis(); - if(cubic){ - if((!ignoreCusp || !Geom::are_near((*cubic)[1],in->first_segment()->initialPoint())) && weightValue !=0){ - pointAt1 = SBasisIn.valueAt(weightValue); - pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); + if(!onlySelected){ + if(cubic){ + if((!ignoreCusp || !Geom::are_near((*cubic)[1],in->first_segment()->initialPoint())) && weightValue !=0){ + pointAt1 = SBasisIn.valueAt(weightValue); + pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); + }else{ + pointAt1 = in->first_segment()->initialPoint(); + } + if((!ignoreCusp || !Geom::are_near((*cubic)[2],in->first_segment()->finalPoint())) && weightValue !=0){ + pointAt2 = SBasisIn.valueAt(1-weightValue); + pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); }else{ - pointAt1 = in->first_segment()->initialPoint(); - } - if((!ignoreCusp || !Geom::are_near((*cubic)[2],in->first_segment()->finalPoint())) && weightValue !=0){ - pointAt2 = SBasisIn.valueAt(1-weightValue); - pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); - }else{ - pointAt2 = in->first_segment()->finalPoint(); + pointAt2 = in->first_segment()->finalPoint(); + } + }else{ + if(!ignoreCusp && weightValue !=0){ + pointAt1 = SBasisIn.valueAt(weightValue); + pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); + pointAt2 = SBasisIn.valueAt(1-weightValue); + pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); + }else{ + pointAt1 = in->first_segment()->initialPoint(); + pointAt2 = in->first_segment()->finalPoint(); + } } }else{ - if(!ignoreCusp && weightValue !=0){ - pointAt1 = SBasisIn.valueAt(weightValue); - pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); - pointAt2 = SBasisIn.valueAt(1-weightValue); - pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); + if(cubic){ + if((!ignoreCusp || !Geom::are_near((*cubic)[1],in->first_segment()->initialPoint())) && weightValue !=0){ + if(nodeIsSelected(pointAt0,i)){ + pointAt1 = SBasisIn.valueAt(weightValue); + pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); + }else{ + pointAt1 = (*cubic)[1]; + } + }else{ + if(nodeIsSelected(pointAt0,i)){ + pointAt1 = in->first_segment()->initialPoint(); + }else{ + pointAt1 = (*cubic)[1]; + } + } + i++; + if((!ignoreCusp || !Geom::are_near((*cubic)[2],in->first_segment()->finalPoint())) && weightValue !=0){ + if(nodeIsSelected(pointAt3,i)){ + pointAt2 = SBasisIn.valueAt(1-weightValue); + pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); + }else{ + pointAt2 = (*cubic)[2]; + i--; + } + }else{ + if(nodeIsSelected(pointAt3,i)){ + pointAt2 = in->first_segment()->finalPoint(); + }else{ + pointAt2 = (*cubic)[2]; + i--; + } + } }else{ - pointAt1 = in->first_segment()->initialPoint(); - pointAt2 = in->first_segment()->finalPoint(); + if(!ignoreCusp && weightValue !=0){ + if(nodeIsSelected(pointAt0,i)){ + pointAt1 = SBasisIn.valueAt(weightValue); + pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); + }else{ + pointAt1 = in->first_segment()->initialPoint(); + } + i++; + if(nodeIsSelected(pointAt3,i)){ + pointAt2 = SBasisIn.valueAt(weightValue); + pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); + }else{ + pointAt2 = in->first_segment()->finalPoint(); + i--; + } + }else{ + pointAt1 = in->first_segment()->initialPoint(); + pointAt2 = in->first_segment()->finalPoint(); + } } } - pointAt3 = in->first_segment()->finalPoint(); in->reset(); delete in; //Y hacemos lo propio con el path de salida @@ -451,32 +526,89 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue , bool ignor out->moveto(curve_it2->initialPoint()); out->lineto(curve_it2->finalPoint()); SBasisOut = out->first_segment()->toSBasis(); + nextPointAt0 = out->first_segment()->initialPoint(); + nextPointAt3 = out->first_segment()->finalPoint(); cubic = dynamic_cast(&*curve_it2); - if(cubic){ - if((!ignoreCusp || !Geom::are_near((*cubic)[1],out->first_segment()->initialPoint()))&& weightValue !=0){ - nextPointAt1 = SBasisOut.valueAt(weightValue); - nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); + if(!onlySelected){ + if(cubic){ + if((!ignoreCusp || !Geom::are_near((*cubic)[1],out->first_segment()->initialPoint()))&& weightValue !=0){ + nextPointAt1 = SBasisOut.valueAt(weightValue); + nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); + }else{ + nextPointAt1 = out->first_segment()->initialPoint(); + } + if((!ignoreCusp || !Geom::are_near((*cubic)[2],out->first_segment()->finalPoint()))&& weightValue !=0){ + nextPointAt2 = SBasisOut.valueAt(1-weightValue); + nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); + }else{ + nextPointAt2 = out->first_segment()->finalPoint(); + } }else{ - nextPointAt1 = out->first_segment()->initialPoint(); - } - if((!ignoreCusp || !Geom::are_near((*cubic)[2],out->first_segment()->finalPoint()))&& weightValue !=0){ - nextPointAt2 = SBasisOut.valueAt(1-weightValue); - nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); - }else{ - nextPointAt2 = out->first_segment()->finalPoint(); + if(!ignoreCusp && weightValue !=0){ + nextPointAt1 = SBasisOut.valueAt(weightValue); + nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); + nextPointAt2 = SBasisOut.valueAt(1-weightValue); + nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); + }else{ + nextPointAt1 = out->first_segment()->initialPoint(); + nextPointAt2 = out->first_segment()->finalPoint(); + } } }else{ - if(!ignoreCusp && weightValue !=0){ - nextPointAt1 = SBasisOut.valueAt(weightValue); - nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); - nextPointAt2 = SBasisOut.valueAt(1-weightValue); - nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); + if(cubic){ + if((!ignoreCusp || !Geom::are_near((*cubic)[1],out->first_segment()->initialPoint())) && weightValue !=0){ + if(nodeIsSelected(nextPointAt0,i)){ + nextPointAt1 = SBasisOut.valueAt(weightValue); + nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); + }else{ + nextPointAt1 = (*cubic)[1]; + } + }else{ + if(nodeIsSelected(nextPointAt0,i)){ + nextPointAt1 = out->first_segment()->initialPoint(); + }else{ + nextPointAt1 = (*cubic)[1]; + } + } + i++; + if((!ignoreCusp || !Geom::are_near((*cubic)[2],out->first_segment()->finalPoint())) && weightValue !=0){ + if(nodeIsSelected(nextPointAt3,i)){ + nextPointAt2 = SBasisOut.valueAt(1-weightValue); + nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); + }else{ + nextPointAt2 = (*cubic)[2]; + i--; + } + }else{ + if(nodeIsSelected(nextPointAt3,i)){ + nextPointAt2 = out->first_segment()->finalPoint(); + }else{ + nextPointAt2 = (*cubic)[2]; + i--; + } + } }else{ - nextPointAt1 = out->first_segment()->initialPoint(); - nextPointAt2 = out->first_segment()->finalPoint(); + if(!ignoreCusp && weightValue !=0){ + if(nodeIsSelected(nextPointAt0,i)){ + nextPointAt1 = SBasisOut.valueAt(weightValue); + nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); + }else{ + nextPointAt1 = out->first_segment()->initialPoint(); + } + i++; + if(nodeIsSelected(nextPointAt3,i)){ + nextPointAt2 = SBasisOut.valueAt(weightValue); + nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); + }else{ + nextPointAt2 = out->first_segment()->finalPoint(); + i--; + } + }else{ + nextPointAt1 = out->first_segment()->initialPoint(); + nextPointAt2 = out->first_segment()->finalPoint(); + } } } - nextPointAt3 = out->first_segment()->finalPoint(); out->reset(); delete out; //La curva BSpline se forma calculando el centro del segmanto de unión diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index 20012f894..2361c10d0 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -9,6 +9,8 @@ #include "live_effects/effect.h" #include "live_effects/parameter/bool.h" +#include + namespace Inkscape { namespace LivePathEffect { @@ -25,7 +27,9 @@ public: virtual void doEffect(SPCurve * curve); - virtual void doBSplineFromWidget(SPCurve * curve, double value, bool noCusp); + virtual void doBSplineFromWidget(SPCurve * curve, double value); + + virtual bool nodeIsSelected(Geom::Point nodePoint, int index); virtual Gtk::Widget * newWidget(); @@ -38,8 +42,9 @@ public: ScalarParam steps; private: - + std::vector points; BoolParam ignoreCusp; + BoolParam onlySelected; ScalarParam weight; LPEBSpline(const LPEBSpline&); -- cgit v1.2.3 From 30858428c74d1fa0f119f40b99fa5e51836d8599 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 8 Apr 2013 00:50:31 +0200 Subject: Change width only for selected nodes by widget (bzr r11950.1.83) --- src/libavoid/makefile | 17 --------------- src/live_effects/lpe-bspline.cpp | 46 ++++++++++++++++++++++------------------ src/ui/tool/node.cpp | 2 +- src/ui/tool/path-manipulator.cpp | 18 ++++++++++++++-- 4 files changed, 42 insertions(+), 41 deletions(-) delete mode 100644 src/libavoid/makefile (limited to 'src') diff --git a/src/libavoid/makefile b/src/libavoid/makefile deleted file mode 100644 index e4f83a52d..000000000 --- a/src/libavoid/makefile +++ /dev/null @@ -1,17 +0,0 @@ -# Convenience stub makefile to call the real Makefile. - - - -OBJEXT = o - -# Explicit so that it's the default rule. -all: - cd .. && $(MAKE) libavoid/all - -clean %.a %.$(OBJEXT): - cd .. && $(MAKE) libavoid/$@ - -.PHONY: all clean - -.SUFFIXES: -.SUFFIXES: .a .$(OBJEXT) diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 389c11a23..e93fd62d2 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -10,6 +10,7 @@ #include #include "display/curve.h" #include <2geom/bezier-curve.h> +#include <2geom/point.h> #include "helper/geom-curves.h" #include "live_effects/lpe-bspline.h" #include "live_effects/lpeobject.h" @@ -341,6 +342,10 @@ LPEBSpline::changeWeight(double weightValue) LPEBSpline::doBSplineFromWidget(curve,weightValue); gchar *str = sp_svg_write_path(curve->get_pathvector()); path->getRepr()->setAttribute("inkscape:original-d", str); + if(INK_IS_NODE_TOOL(desktop->event_context)){ + InkNodeTool *nt = INK_NODE_TOOL(desktop->event_context); + nt->desktop->updateNow(); + } g_free(str); curve->unref(); desktop->clearWaitingCursor(); @@ -350,12 +355,8 @@ LPEBSpline::changeWeight(double weightValue) bool LPEBSpline::nodeIsSelected(Geom::Point nodePoint, int index){ - volatile int index2 = index; - volatile Geom::Point aa = nodePoint; - volatile std::vector x2 = points; if(points.size() > 0){ - volatile double dist = Geom::distance(points[index], nodePoint); - if(dist == 0 ){ + if(Geom::are_near(points[index], nodePoint)){ return true; } } @@ -373,9 +374,12 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) Inkscape::UI::ControlPointSelection::Set &selection = nt->_selected_nodes->allPoints(); points.clear(); for (Inkscape::UI::ControlPointSelection::Set::iterator i = selection.begin(); i != selection.end(); ++i){ - if ((*i)->selected()) { - Inkscape::UI::Node *n = static_cast(*i); - points.push_back(n->position()); + if(onlySelected){ + if ((*i)->selected()) { + Inkscape::UI::Node *n = static_cast(*i); + n->bsplineWeight = weightValue; + points.insert(points.begin(),desktop->doc2dt(n->position())); + } } } } @@ -469,31 +473,30 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) if(nodeIsSelected(pointAt0,i)){ pointAt1 = SBasisIn.valueAt(weightValue); pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); + i++; }else{ pointAt1 = (*cubic)[1]; } }else{ if(nodeIsSelected(pointAt0,i)){ pointAt1 = in->first_segment()->initialPoint(); + i++; }else{ pointAt1 = (*cubic)[1]; } } - i++; if((!ignoreCusp || !Geom::are_near((*cubic)[2],in->first_segment()->finalPoint())) && weightValue !=0){ if(nodeIsSelected(pointAt3,i)){ pointAt2 = SBasisIn.valueAt(1-weightValue); pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); }else{ pointAt2 = (*cubic)[2]; - i--; } }else{ if(nodeIsSelected(pointAt3,i)){ pointAt2 = in->first_segment()->finalPoint(); }else{ pointAt2 = (*cubic)[2]; - i--; } } }else{ @@ -501,20 +504,22 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) if(nodeIsSelected(pointAt0,i)){ pointAt1 = SBasisIn.valueAt(weightValue); pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); + i++; }else{ pointAt1 = in->first_segment()->initialPoint(); } - i++; if(nodeIsSelected(pointAt3,i)){ pointAt2 = SBasisIn.valueAt(weightValue); pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); }else{ pointAt2 = in->first_segment()->finalPoint(); - i--; } }else{ pointAt1 = in->first_segment()->initialPoint(); pointAt2 = in->first_segment()->finalPoint(); + if(nodeIsSelected(pointAt0,i)){ + i++; + } } } } @@ -560,51 +565,50 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) if(nodeIsSelected(nextPointAt0,i)){ nextPointAt1 = SBasisOut.valueAt(weightValue); nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); + if (path_it->closed()) i++; }else{ nextPointAt1 = (*cubic)[1]; } }else{ if(nodeIsSelected(nextPointAt0,i)){ - nextPointAt1 = out->first_segment()->initialPoint(); + nextPointAt1 = out->first_segment()->initialPoint(); + if (path_it->closed()) i++; }else{ nextPointAt1 = (*cubic)[1]; } } - i++; if((!ignoreCusp || !Geom::are_near((*cubic)[2],out->first_segment()->finalPoint())) && weightValue !=0){ if(nodeIsSelected(nextPointAt3,i)){ nextPointAt2 = SBasisOut.valueAt(1-weightValue); nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); }else{ nextPointAt2 = (*cubic)[2]; - i--; - } + } }else{ if(nodeIsSelected(nextPointAt3,i)){ nextPointAt2 = out->first_segment()->finalPoint(); }else{ nextPointAt2 = (*cubic)[2]; - i--; - } + } } }else{ if(!ignoreCusp && weightValue !=0){ if(nodeIsSelected(nextPointAt0,i)){ nextPointAt1 = SBasisOut.valueAt(weightValue); nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); + if (path_it->closed()) i++; }else{ nextPointAt1 = out->first_segment()->initialPoint(); } - i++; if(nodeIsSelected(nextPointAt3,i)){ nextPointAt2 = SBasisOut.valueAt(weightValue); nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); }else{ nextPointAt2 = out->first_segment()->finalPoint(); - i--; } }else{ nextPointAt1 = out->first_segment()->initialPoint(); + if (path_it->closed()&&nodeIsSelected(nextPointAt0,i)) i++; nextPointAt2 = out->first_segment()->finalPoint(); } } diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 1f609dfa0..8f1c37649 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -577,8 +577,8 @@ Node::Node(NodeSharedData const &data, Geom::Point const &initial_pos) : _type(NODE_CUSP), _handles_shown(false) { - // NOTE we do not set type here, because the handles are still degenerate this->bsplineWeight = 0.3334; + // NOTE we do not set type here, because the handles are still degenerate } Node const *Node::_next() const diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index be5514e1f..6cad60fee 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1248,8 +1248,22 @@ Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){ } void PathManipulator::BSplineNodeHandlesReposition(Node *n){ - n->front()->setPosition(BSplineHandleReposition(n->front(),n->bsplineWeight)); - n->back()->setPosition(BSplineHandleReposition(n->back(),n->bsplineWeight)); + if(n->selected()){ + Node * nextNode = n->nodeToward(n->front()); + Node * prevNode = n->nodeToward(n->back()); + double prevPos = 0; + double nextPos = 0; + if(prevNode) + prevPos = BSplineHandlePosition(prevNode->front()); + if(nextNode) + nextPos = BSplineHandlePosition(nextNode->back()); + n->front()->setPosition(BSplineHandleReposition(n->front(),n->bsplineWeight)); + n->back()->setPosition(BSplineHandleReposition(n->back(),n->bsplineWeight)); + if(prevNode) + prevNode->front()->setPosition(BSplineHandleReposition(prevNode->front(),prevPos)); + if(nextNode) + nextNode->back()->setPosition(BSplineHandleReposition(nextNode->back(),nextPos)); + } } /** Construct the geometric representation of nodes and handles, update the outline -- cgit v1.2.3 From 2a873d7b420826f8d0e19d8a03f2b0efbbcac5c9 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 8 Apr 2013 00:55:28 +0200 Subject: adding fixed files from trunk (bzr r11950.1.84) --- src/libavoid/makefile | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/libavoid/makefile (limited to 'src') diff --git a/src/libavoid/makefile b/src/libavoid/makefile new file mode 100644 index 000000000..e4f83a52d --- /dev/null +++ b/src/libavoid/makefile @@ -0,0 +1,17 @@ +# Convenience stub makefile to call the real Makefile. + + + +OBJEXT = o + +# Explicit so that it's the default rule. +all: + cd .. && $(MAKE) libavoid/all + +clean %.a %.$(OBJEXT): + cd .. && $(MAKE) libavoid/$@ + +.PHONY: all clean + +.SUFFIXES: +.SUFFIXES: .a .$(OBJEXT) -- cgit v1.2.3 From d2e58f51d29c5da3f82d29883c0a07ce9573f8ca Mon Sep 17 00:00:00 2001 From: root Date: Wed, 10 Apr 2013 06:08:17 +0200 Subject: fixing error moving selected nodes (bzr r11950.1.86) --- src/libavoid/makefile | 17 ------- src/live_effects/lpe-bspline.cpp | 102 +++++++++++++++++++-------------------- 2 files changed, 50 insertions(+), 69 deletions(-) delete mode 100644 src/libavoid/makefile (limited to 'src') diff --git a/src/libavoid/makefile b/src/libavoid/makefile deleted file mode 100644 index e4f83a52d..000000000 --- a/src/libavoid/makefile +++ /dev/null @@ -1,17 +0,0 @@ -# Convenience stub makefile to call the real Makefile. - - - -OBJEXT = o - -# Explicit so that it's the default rule. -all: - cd .. && $(MAKE) libavoid/all - -clean %.a %.$(OBJEXT): - cd .. && $(MAKE) libavoid/$@ - -.PHONY: all clean - -.SUFFIXES: -.SUFFIXES: .a .$(OBJEXT) diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index e93fd62d2..657b2ded3 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -374,13 +374,10 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) Inkscape::UI::ControlPointSelection::Set &selection = nt->_selected_nodes->allPoints(); points.clear(); for (Inkscape::UI::ControlPointSelection::Set::iterator i = selection.begin(); i != selection.end(); ++i){ - if(onlySelected){ if ((*i)->selected()) { Inkscape::UI::Node *n = static_cast(*i); - n->bsplineWeight = weightValue; points.insert(points.begin(),desktop->doc2dt(n->position())); } - } } } //bool hasNodesSelected = LPEBspline::hasNodesSelected(); @@ -416,7 +413,7 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) Geom::D2< Geom::SBasis > SBasisIn; Geom::D2< Geom::SBasis > SBasisOut; Geom::CubicBezier const *cubic = NULL; - int i = 0; + int j = 0; if (path_it->closed()) { // if the path is closed, maybe we have to stop a bit earlier because the closing line segment has zerolength. const Geom::Curve &closingline = path_it->back_closed(); // the closing line segment is always of type Geom::LineSegment. @@ -470,30 +467,30 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) }else{ if(cubic){ if((!ignoreCusp || !Geom::are_near((*cubic)[1],in->first_segment()->initialPoint())) && weightValue !=0){ - if(nodeIsSelected(pointAt0,i)){ + if(nodeIsSelected(pointAt0,j)){ pointAt1 = SBasisIn.valueAt(weightValue); pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); - i++; + j++; }else{ pointAt1 = (*cubic)[1]; } }else{ - if(nodeIsSelected(pointAt0,i)){ + if(nodeIsSelected(pointAt0,j)){ pointAt1 = in->first_segment()->initialPoint(); - i++; + j++; }else{ pointAt1 = (*cubic)[1]; } } if((!ignoreCusp || !Geom::are_near((*cubic)[2],in->first_segment()->finalPoint())) && weightValue !=0){ - if(nodeIsSelected(pointAt3,i)){ + if(nodeIsSelected(pointAt3,j)){ pointAt2 = SBasisIn.valueAt(1-weightValue); pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); }else{ pointAt2 = (*cubic)[2]; } }else{ - if(nodeIsSelected(pointAt3,i)){ + if(nodeIsSelected(pointAt3,j)){ pointAt2 = in->first_segment()->finalPoint(); }else{ pointAt2 = (*cubic)[2]; @@ -501,14 +498,14 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) } }else{ if(!ignoreCusp && weightValue !=0){ - if(nodeIsSelected(pointAt0,i)){ + if(nodeIsSelected(pointAt0,j)){ pointAt1 = SBasisIn.valueAt(weightValue); pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); - i++; + j++; }else{ pointAt1 = in->first_segment()->initialPoint(); } - if(nodeIsSelected(pointAt3,i)){ + if(nodeIsSelected(pointAt3,j)){ pointAt2 = SBasisIn.valueAt(weightValue); pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); }else{ @@ -517,24 +514,42 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) }else{ pointAt1 = in->first_segment()->initialPoint(); pointAt2 = in->first_segment()->finalPoint(); - if(nodeIsSelected(pointAt0,i)){ - i++; + if(nodeIsSelected(pointAt0,j)){ + j++; } } } } in->reset(); delete in; - //Y hacemos lo propio con el path de salida - //nextPointAt0 = curveOut.valueAt(0); - SPCurve * out = new SPCurve(); - out->moveto(curve_it2->initialPoint()); - out->lineto(curve_it2->finalPoint()); - SBasisOut = out->first_segment()->toSBasis(); - nextPointAt0 = out->first_segment()->initialPoint(); - nextPointAt3 = out->first_segment()->finalPoint(); - cubic = dynamic_cast(&*curve_it2); - if(!onlySelected){ + + //La curva BSpline se forma calculando el centro del segmanto de unión + //de el punto situado en las 2/3 partes de el segmento de entrada + //con el punto situado en la posición 1/3 del segmento de salida + //Estos dos puntos ademas estan posicionados en el lugas correspondiente de + //los manejadores de la curva + SPCurve *curveHelper = new SPCurve(); + curveHelper->moveto(pointAt0); + curveHelper->curveto(pointAt1, pointAt2, pointAt3); + //añadimos la curva generada a la curva pricipal + nCurve->append_continuous(curveHelper, 0.0625); + curveHelper->reset(); + delete curveHelper; + //aumentamos los valores para el siguiente paso en el bucle + ++curve_it1; + ++curve_it2; + } + //Aberiguamos la ultima parte de la curva correspondiente al último segmento + //Y hacemos lo propio con el path de salida + //nextPointAt0 = curveOut.valueAt(0); + SPCurve * out = new SPCurve(); + out->moveto(curve_it1->initialPoint()); + out->lineto(curve_it1->finalPoint()); + SBasisOut = out->first_segment()->toSBasis(); + nextPointAt0 = out->first_segment()->initialPoint(); + nextPointAt3 = out->first_segment()->finalPoint(); + cubic = dynamic_cast(&*curve_it1); + if(!onlySelected){ if(cubic){ if((!ignoreCusp || !Geom::are_near((*cubic)[1],out->first_segment()->initialPoint()))&& weightValue !=0){ nextPointAt1 = SBasisOut.valueAt(weightValue); @@ -562,30 +577,30 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) }else{ if(cubic){ if((!ignoreCusp || !Geom::are_near((*cubic)[1],out->first_segment()->initialPoint())) && weightValue !=0){ - if(nodeIsSelected(nextPointAt0,i)){ + if(nodeIsSelected(nextPointAt0,j)){ nextPointAt1 = SBasisOut.valueAt(weightValue); nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); - if (path_it->closed()) i++; + j++; }else{ nextPointAt1 = (*cubic)[1]; } }else{ - if(nodeIsSelected(nextPointAt0,i)){ + if(nodeIsSelected(nextPointAt0,j)){ nextPointAt1 = out->first_segment()->initialPoint(); - if (path_it->closed()) i++; + j++; }else{ nextPointAt1 = (*cubic)[1]; } } if((!ignoreCusp || !Geom::are_near((*cubic)[2],out->first_segment()->finalPoint())) && weightValue !=0){ - if(nodeIsSelected(nextPointAt3,i)){ + if(nodeIsSelected(nextPointAt3,j)){ nextPointAt2 = SBasisOut.valueAt(1-weightValue); nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); }else{ nextPointAt2 = (*cubic)[2]; } }else{ - if(nodeIsSelected(nextPointAt3,i)){ + if(nodeIsSelected(nextPointAt3,j)){ nextPointAt2 = out->first_segment()->finalPoint(); }else{ nextPointAt2 = (*cubic)[2]; @@ -593,14 +608,14 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) } }else{ if(!ignoreCusp && weightValue !=0){ - if(nodeIsSelected(nextPointAt0,i)){ + if(nodeIsSelected(nextPointAt0,j)){ nextPointAt1 = SBasisOut.valueAt(weightValue); nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); - if (path_it->closed()) i++; + j++; }else{ nextPointAt1 = out->first_segment()->initialPoint(); } - if(nodeIsSelected(nextPointAt3,i)){ + if(nodeIsSelected(nextPointAt3,j)){ nextPointAt2 = SBasisOut.valueAt(weightValue); nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); }else{ @@ -608,30 +623,13 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) } }else{ nextPointAt1 = out->first_segment()->initialPoint(); - if (path_it->closed()&&nodeIsSelected(nextPointAt0,i)) i++; + if(nodeIsSelected(nextPointAt0,j)) j++; nextPointAt2 = out->first_segment()->finalPoint(); } } } out->reset(); delete out; - //La curva BSpline se forma calculando el centro del segmanto de unión - //de el punto situado en las 2/3 partes de el segmento de entrada - //con el punto situado en la posición 1/3 del segmento de salida - //Estos dos puntos ademas estan posicionados en el lugas correspondiente de - //los manejadores de la curva - SPCurve *curveHelper = new SPCurve(); - curveHelper->moveto(pointAt0); - curveHelper->curveto(pointAt1, pointAt2, pointAt3); - //añadimos la curva generada a la curva pricipal - nCurve->append_continuous(curveHelper, 0.0625); - curveHelper->reset(); - delete curveHelper; - //aumentamos los valores para el siguiente paso en el bucle - ++curve_it1; - ++curve_it2; - } - //Aberiguamos la ultima parte de la curva correspondiente al último segmento SPCurve *curveHelper = new SPCurve(); curveHelper->moveto(pointAt3); if (path_it->closed()) { -- cgit v1.2.3 From 1290320ca882992345418ce8572af053f1659628 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 10 Apr 2013 21:45:15 +0200 Subject: Fixed bug moving selected nodes (bzr r11950.1.88) --- src/live_effects/lpe-bspline.cpp | 168 ++++++++++++++------------------------- src/live_effects/lpe-bspline.h | 2 +- 2 files changed, 61 insertions(+), 109 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index e7adab071..37bf24021 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -140,7 +140,7 @@ LPEBSpline::doEffect(SPCurve * curve) //Si la curva está cerrada calculamos el punto donde //deveria estar el nodo BSpline de cierre/inicio de la curva //en posible caso de que se cierre con una linea recta creando un nodo BSPline - + nCurve->moveto(curve_it1->initialPoint()); //Recorremos todos los segmentos menos el último while ( curve_it2 != curve_endit ) { @@ -193,20 +193,11 @@ LPEBSpline::doEffect(SPCurve * curve) previousNode = node; //Y este hará de final de curva node = SBasisHelper.valueAt(0.5); - SPCurve *curveHelper = new SPCurve(); - curveHelper->moveto(previousNode); - curveHelper->curveto(pointAt1, pointAt2, node); - //añadimos la curva generada a la curva pricipal - nCurve->append_continuous(curveHelper, 0.0625); - curveHelper->reset(); - delete curveHelper; + nCurve->curveto(pointAt1, pointAt2, node); //aumentamos los valores para el siguiente paso en el bucle ++curve_it1; ++curve_it2; } - //Aberiguamos la ultima parte de la curva correspondiente al último segmento - SPCurve *curveHelper = new SPCurve(); - curveHelper->moveto(node); //Si está cerrada la curva, la cerramos sobre el valor guardado previamente //Si no finalizamos en el punto final Geom::Point startNode(0,0); @@ -242,8 +233,7 @@ LPEBSpline::doEffect(SPCurve * curve) lineHelper->reset(); delete lineHelper; startNode = SBasisHelper.valueAt(0.5); - curveHelper->curveto(nextPointAt1, nextPointAt2, startNode); - nCurve->append_continuous(curveHelper, 0.0625); + nCurve->curveto(nextPointAt1, nextPointAt2, startNode); nCurve->move_endpoints(startNode,startNode); }else{ SPCurve * start = new SPCurve(); @@ -252,12 +242,9 @@ LPEBSpline::doEffect(SPCurve * curve) startNode = start->first_segment()->initialPoint(); start->reset(); delete start; - curveHelper->curveto(nextPointAt1, nextPointAt2, nextPointAt3); - nCurve->append_continuous(curveHelper, 0.0625); + nCurve->curveto(nextPointAt1, nextPointAt2, nextPointAt3); nCurve->move_endpoints(startNode,nextPointAt3); } - curveHelper->reset(); - delete curveHelper; //y cerramos la curva if (path_it->closed()) { nCurve->closepath_current(); @@ -354,10 +341,15 @@ LPEBSpline::changeWeight(double weightValue) } bool -LPEBSpline::nodeIsSelected(Geom::Point nodePoint, int index){ +LPEBSpline::nodeIsSelected(Geom::Point nodePoint){ if(points.size() > 0){ - if(Geom::are_near(points[index], nodePoint)){ - return true; + for(std::vector::iterator i = points.begin(); i != points.end();){ + Geom::Point p = static_cast(*i); + if(Geom::are_near(p, nodePoint)){ + return true; + points.erase(i); + } + i++; } } return false; @@ -415,7 +407,6 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) Geom::D2< Geom::SBasis > SBasisIn; Geom::D2< Geom::SBasis > SBasisOut; Geom::CubicBezier const *cubic = NULL; - int j = 0; if (path_it->closed()) { // if the path is closed, maybe we have to stop a bit earlier because the closing line segment has zerolength. const Geom::Curve &closingline = path_it->back_closed(); // the closing line segment is always of type Geom::LineSegment. @@ -428,7 +419,7 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) //Si la curva está cerrada calculamos el punto donde //deveria estar el nodo BSpline de cierre/inicio de la curva //en posible caso de que se cierre con una linea recta creando un nodo BSPline - + nCurve->moveto(curve_it1->initialPoint()); //Recorremos todos los segmentos menos el último while ( curve_it2 != curve_endit ) { @@ -443,7 +434,7 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) SBasisIn = in->first_segment()->toSBasis(); if(!onlySelected){ if(cubic){ - if((!ignoreCusp || !Geom::are_near((*cubic)[1],in->first_segment()->initialPoint())) && weightValue !=0){ + if(!ignoreCusp || (!Geom::are_near((*cubic)[1],in->first_segment()->initialPoint()) && weightValue !=0)){ pointAt1 = SBasisIn.valueAt(weightValue); pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); }else{ @@ -468,46 +459,35 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) } }else{ if(cubic){ - if((!ignoreCusp || !Geom::are_near((*cubic)[1],in->first_segment()->initialPoint())) && weightValue !=0){ - if(nodeIsSelected(pointAt0,j)){ + if(!ignoreCusp || (!Geom::are_near((*cubic)[1],in->first_segment()->initialPoint())&& weightValue !=0)){ + if(nodeIsSelected(pointAt0)){ pointAt1 = SBasisIn.valueAt(weightValue); pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); - j++; }else{ pointAt1 = (*cubic)[1]; } }else{ - if(nodeIsSelected(pointAt0,j)){ pointAt1 = in->first_segment()->initialPoint(); - j++; - }else{ - pointAt1 = (*cubic)[1]; - } } - if((!ignoreCusp || !Geom::are_near((*cubic)[2],in->first_segment()->finalPoint())) && weightValue !=0){ - if(nodeIsSelected(pointAt3,j)){ + if(!ignoreCusp || (!Geom::are_near((*cubic)[2],in->first_segment()->finalPoint()) && weightValue !=0)){ + if(nodeIsSelected(pointAt3)){ pointAt2 = SBasisIn.valueAt(1-weightValue); pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); }else{ pointAt2 = (*cubic)[2]; } }else{ - if(nodeIsSelected(pointAt3,j)){ pointAt2 = in->first_segment()->finalPoint(); - }else{ - pointAt2 = (*cubic)[2]; - } } }else{ if(!ignoreCusp && weightValue !=0){ - if(nodeIsSelected(pointAt0,j)){ + if(nodeIsSelected(pointAt0)){ pointAt1 = SBasisIn.valueAt(weightValue); pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); - j++; }else{ pointAt1 = in->first_segment()->initialPoint(); } - if(nodeIsSelected(pointAt3,j)){ + if(nodeIsSelected(pointAt3)){ pointAt2 = SBasisIn.valueAt(weightValue); pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); }else{ @@ -516,34 +496,21 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) }else{ pointAt1 = in->first_segment()->initialPoint(); pointAt2 = in->first_segment()->finalPoint(); - if(nodeIsSelected(pointAt0,j)){ - j++; - } } } } in->reset(); delete in; - //La curva BSpline se forma calculando el centro del segmanto de unión //de el punto situado en las 2/3 partes de el segmento de entrada //con el punto situado en la posición 1/3 del segmento de salida //Estos dos puntos ademas estan posicionados en el lugas correspondiente de //los manejadores de la curva - SPCurve *curveHelper = new SPCurve(); - curveHelper->moveto(pointAt0); - curveHelper->curveto(pointAt1, pointAt2, pointAt3); - //añadimos la curva generada a la curva pricipal - nCurve->append_continuous(curveHelper, 0.0625); - curveHelper->reset(); - delete curveHelper; + nCurve->curveto(pointAt1, pointAt2, pointAt3); //aumentamos los valores para el siguiente paso en el bucle ++curve_it1; ++curve_it2; } - //Aberiguamos la ultima parte de la curva correspondiente al último segmento - //Y hacemos lo propio con el path de salida - //nextPointAt0 = curveOut.valueAt(0); SPCurve * out = new SPCurve(); out->moveto(curve_it1->initialPoint()); out->lineto(curve_it1->finalPoint()); @@ -576,75 +543,60 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) nextPointAt2 = out->first_segment()->finalPoint(); } } - }else{ - if(cubic){ - if((!ignoreCusp || !Geom::are_near((*cubic)[1],out->first_segment()->initialPoint())) && weightValue !=0){ - if(nodeIsSelected(nextPointAt0,j)){ - nextPointAt1 = SBasisOut.valueAt(weightValue); - nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); - j++; - }else{ - nextPointAt1 = (*cubic)[1]; - } + }else{ + if(cubic){ + if(!ignoreCusp || (!Geom::are_near((*cubic)[1],out->first_segment()->initialPoint()) && weightValue !=0)){ + if(nodeIsSelected(nextPointAt0)){ + nextPointAt1 = SBasisOut.valueAt(weightValue); + nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); }else{ - if(nodeIsSelected(nextPointAt0,j)){ - nextPointAt1 = out->first_segment()->initialPoint(); - j++; - }else{ - nextPointAt1 = (*cubic)[1]; - } + nextPointAt1 = (*cubic)[1]; } - if((!ignoreCusp || !Geom::are_near((*cubic)[2],out->first_segment()->finalPoint())) && weightValue !=0){ - if(nodeIsSelected(nextPointAt3,j)){ - nextPointAt2 = SBasisOut.valueAt(1-weightValue); - nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); - }else{ - nextPointAt2 = (*cubic)[2]; - } + }else{ + nextPointAt1 = out->first_segment()->initialPoint(); + } + if(!ignoreCusp || (!Geom::are_near((*cubic)[2],out->first_segment()->finalPoint()) && weightValue !=0)){ + if(nodeIsSelected(nextPointAt3)){ + nextPointAt2 = SBasisOut.valueAt(1-weightValue); + nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); }else{ - if(nodeIsSelected(nextPointAt3,j)){ - nextPointAt2 = out->first_segment()->finalPoint(); - }else{ - nextPointAt2 = (*cubic)[2]; - } - } + nextPointAt2 = (*cubic)[2]; + } }else{ - if(!ignoreCusp && weightValue !=0){ - if(nodeIsSelected(nextPointAt0,j)){ - nextPointAt1 = SBasisOut.valueAt(weightValue); - nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); - j++; - }else{ - nextPointAt1 = out->first_segment()->initialPoint(); - } - if(nodeIsSelected(nextPointAt3,j)){ - nextPointAt2 = SBasisOut.valueAt(weightValue); - nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); - }else{ - nextPointAt2 = out->first_segment()->finalPoint(); - } + nextPointAt2 = out->first_segment()->finalPoint(); + } + }else{ + if(!ignoreCusp && weightValue !=0){ + if(nodeIsSelected(nextPointAt0)){ + nextPointAt1 = SBasisOut.valueAt(weightValue); + nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); }else{ nextPointAt1 = out->first_segment()->initialPoint(); - if(nodeIsSelected(nextPointAt0,j)) j++; + } + if(nodeIsSelected(nextPointAt3)){ + nextPointAt2 = SBasisOut.valueAt(weightValue); + nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); + }else{ nextPointAt2 = out->first_segment()->finalPoint(); } + }else{ + nextPointAt1 = out->first_segment()->initialPoint(); + nextPointAt2 = out->first_segment()->finalPoint(); } } - out->reset(); - delete out; - SPCurve *curveHelper = new SPCurve(); - curveHelper->moveto(pointAt3); + } + out->reset(); + delete out; + //Aberiguamos la ultima parte de la curva correspondiente al último segmento + //Y hacemos lo propio con el path de salida + //nextPointAt0 = curveOut.valueAt(0); if (path_it->closed()) { - curveHelper->curveto(nextPointAt1, nextPointAt2, path_it->begin()->initialPoint()); - nCurve->append_continuous(curveHelper, 0.0625); + nCurve->curveto(nextPointAt1, nextPointAt2, path_it->begin()->initialPoint()); nCurve->move_endpoints(path_it->begin()->initialPoint(),path_it->begin()->initialPoint()); }else{ - curveHelper->curveto(nextPointAt1, nextPointAt2, nextPointAt3); - nCurve->append_continuous(curveHelper, 0.0625); + nCurve->curveto(nextPointAt1, nextPointAt2, nextPointAt3); nCurve->move_endpoints(path_it->begin()->initialPoint(),nextPointAt3); } - curveHelper->reset(); - delete curveHelper; //y cerramos la curva if (path_it->closed()) { nCurve->closepath_current(); diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index 2361c10d0..103f09338 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -29,7 +29,7 @@ public: virtual void doBSplineFromWidget(SPCurve * curve, double value); - virtual bool nodeIsSelected(Geom::Point nodePoint, int index); + virtual bool nodeIsSelected(Geom::Point nodePoint); virtual Gtk::Widget * newWidget(); -- cgit v1.2.3 From ef68a900e61298c46c079b047310558fb37a21ae Mon Sep 17 00:00:00 2001 From: jtx Date: Fri, 12 Apr 2013 18:04:58 +0200 Subject: changing colors (bzr r11950.1.89) --- src/display/canvas-bpath.cpp | 8 +++++++- src/pen-context.cpp | 36 ++++++++++++++---------------------- 2 files changed, 21 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/display/canvas-bpath.cpp b/src/display/canvas-bpath.cpp index ee9e14f10..cbc93948f 100644 --- a/src/display/canvas-bpath.cpp +++ b/src/display/canvas-bpath.cpp @@ -145,7 +145,7 @@ sp_canvas_bpath_render (SPCanvasItem *item, SPCanvasBuf *buf) bool dostroke = ((cbp->stroke_rgba & 0xff) != 0); cairo_set_tolerance(buf->ct, 0.5); - cairo_new_path(buf->ct); + //cairo_new_path(buf->ct); feed_pathvector_to_cairo (buf->ct, cbp->curve->get_pathvector(), cbp->affine, area, /* optimized_stroke = */ !dofill, 1); @@ -164,7 +164,13 @@ sp_canvas_bpath_render (SPCanvasItem *item, SPCanvasBuf *buf) if (cbp->dashes[0] != 0 && cbp->dashes[1] != 0) { cairo_set_dash (buf->ct, cbp->dashes, 2, 0); } + //cairo_t buf2 = cairo_reference(buf->ct); cairo_stroke(buf->ct); + //cairo_set_source_rgba(buf2,1,1,1,0.2); + //cairo_set_line_width(buf2, 3); + //cairo_stroke(buf2); + + } else { cairo_new_path(buf->ct); } diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 851a5f629..bcaf7c893 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -1456,34 +1456,26 @@ static void spdc_pen_set_angle_distance_status_message(SPPenContext *const pc, G //Esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro static void bspline_spiro_color(SPPenContext *const pc) { - bool remake_green_bpaths = false; if(pc->spiro){ - //If the colour is not defined as trasparent, por example when changing - //from drawing to spiro mode or when selecting the pen tool - if(pc->green_color != 0x00ff000){ - //We change the green and red colours to transparent, so this lines are not necessary - //to the drawing with spiro - pc->red_color = 0xff00000; - pc->green_color = 0x00ff000; - remake_green_bpaths = true; - } + pc->red_color = 0xae901f00; + pc->green_color = 0xae901f00; + pc->blue_color = 0x3dc29bb1; + }else if (pc->bspline){ + pc->red_color = 0xae901fce; + pc->green_color = 0xae901fce; + pc->blue_color = 0x3dc29bb1; }else{ - //If we come from working with the spiro curve and change the mode the "green_curve" colour is transparent - if(pc->green_color != 0x00ff007f){ - //since we are not im spiro mode, we assign the original colours - //to the red and the green curve, removing their transparency - pc->red_color = 0xff00007f; - pc->green_color = 0x00ff007f; - remake_green_bpaths = true; - } + pc->red_color = 0xff000098; + pc->green_color = 0x00ff0098; + pc->blue_color = 0x0000ff98; + } //we hide the spiro/bspline rests - if(!pc->bspline){ - sp_canvas_item_hide(pc->blue_bpath); - } + if(!pc->bspline){ + sp_canvas_item_hide(pc->blue_bpath); } //We erase all the "green_bpaths" to recreate them after with the colour //transparency recently modified - if (pc->green_bpaths && remake_green_bpaths) { + if (pc->green_bpaths) { // remove old piecewise green canvasitems while (pc->green_bpaths) { sp_canvas_item_destroy(SP_CANVAS_ITEM(pc->green_bpaths->data)); -- cgit v1.2.3 From 0bc8f7e103d7c2e09400fb95a695231587a1868f Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 13 Apr 2013 23:30:13 +0200 Subject: testing halo (bzr r11950.1.90) --- src/display/canvas-bpath.cpp | 16 +++++++++------- src/pen-context.cpp | 20 ++++++++++---------- 2 files changed, 19 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/display/canvas-bpath.cpp b/src/display/canvas-bpath.cpp index cbc93948f..061ff7676 100644 --- a/src/display/canvas-bpath.cpp +++ b/src/display/canvas-bpath.cpp @@ -145,10 +145,11 @@ sp_canvas_bpath_render (SPCanvasItem *item, SPCanvasBuf *buf) bool dostroke = ((cbp->stroke_rgba & 0xff) != 0); cairo_set_tolerance(buf->ct, 0.5); - //cairo_new_path(buf->ct); + cairo_new_path(buf->ct); feed_pathvector_to_cairo (buf->ct, cbp->curve->get_pathvector(), cbp->affine, area, /* optimized_stroke = */ !dofill, 1); + cairo_save(buf->ct); if (dofill) { // RGB / BGR @@ -164,13 +165,14 @@ sp_canvas_bpath_render (SPCanvasItem *item, SPCanvasBuf *buf) if (cbp->dashes[0] != 0 && cbp->dashes[1] != 0) { cairo_set_dash (buf->ct, cbp->dashes, 2, 0); } - //cairo_t buf2 = cairo_reference(buf->ct); cairo_stroke(buf->ct); - //cairo_set_source_rgba(buf2,1,1,1,0.2); - //cairo_set_line_width(buf2, 3); - //cairo_stroke(buf2); - - + cairo_restore(buf->ct); + //feed_pathvector_to_cairo (buf->ct, cbp->curve->get_pathvector(), cbp->affine, area, + ///* optimized_stroke = */ !dofill, 1); + ink_cairo_set_source_rgba32(buf->ct, 0xffffff20); + cairo_set_line_width(buf->ct, 7); + cairo_set_line_cap(buf->ct,CAIRO_LINE_CAP_ROUND); + cairo_stroke(buf->ct); } else { cairo_new_path(buf->ct); } diff --git a/src/pen-context.cpp b/src/pen-context.cpp index bcaf7c893..c5c54925e 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -1,4 +1,4 @@ -/** \file + /** \file * Pen event context implementation. */ @@ -1457,17 +1457,17 @@ static void spdc_pen_set_angle_distance_status_message(SPPenContext *const pc, G static void bspline_spiro_color(SPPenContext *const pc) { if(pc->spiro){ - pc->red_color = 0xae901f00; - pc->green_color = 0xae901f00; - pc->blue_color = 0x3dc29bb1; + pc->red_color = 0xc80000c8; + pc->green_color = 0xc80000c8; + pc->blue_color = 0x323296c8; }else if (pc->bspline){ - pc->red_color = 0xae901fce; - pc->green_color = 0xae901fce; - pc->blue_color = 0x3dc29bb1; + pc->red_color = 0x963232c8; + pc->green_color = 0x963232c8; + pc->blue_color = 0x323296c8; }else{ - pc->red_color = 0xff000098; - pc->green_color = 0x00ff0098; - pc->blue_color = 0x0000ff98; + pc->red_color = 0xff0000c8; + pc->green_color = 0x00ff00c8; + pc->blue_color = 0x0000ffc8; } //we hide the spiro/bspline rests if(!pc->bspline){ -- cgit v1.2.3 From 08acf66f4df391ff3289b59b80bc770397860343 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 14 Apr 2013 22:54:08 +0200 Subject: halo (bzr r11950.1.92) --- src/display/canvas-bpath.cpp | 42 ++++++++++++++++++-------- src/draw-context.cpp | 3 +- src/draw-context.h | 1 + src/pen-context.cpp | 70 ++++++++++++-------------------------------- 4 files changed, 52 insertions(+), 64 deletions(-) (limited to 'src') diff --git a/src/display/canvas-bpath.cpp b/src/display/canvas-bpath.cpp index 6ac69a325..defd95b45 100644 --- a/src/display/canvas-bpath.cpp +++ b/src/display/canvas-bpath.cpp @@ -16,8 +16,9 @@ #endif #include #include -#include "desktop.h" +#include "document.h" +#include <2geom/pathvector.h> #include "color.h" #include "display/sp-canvas-group.h" #include "display/sp-canvas-util.h" @@ -146,10 +147,6 @@ sp_canvas_bpath_render (SPCanvasItem *item, SPCanvasBuf *buf) cairo_set_tolerance(buf->ct, 0.5); cairo_new_path(buf->ct); - feed_pathvector_to_cairo (buf->ct, cbp->curve->get_pathvector(), cbp->affine, area, - /* optimized_stroke = */ !dofill, 1); - - if (dofill) { // RGB / BGR ink_cairo_set_source_rgba32(buf->ct, cbp->fill_rgba); @@ -159,16 +156,37 @@ sp_canvas_bpath_render (SPCanvasItem *item, SPCanvasBuf *buf) } if (dostroke) { - ink_cairo_set_source_rgba32(buf->ct, cbp->stroke_rgba); - if(cbp->stroke_rgba == 0xffffff10){ - cairo_set_line_width(buf->ct, 3); + SPCurve* orig = new SPCurve(cbp->curve->get_pathvector()); + Geom::Point origPoint(orig->first_path()->initialPoint()); + if(cbp->stroke_rgba == 0x12345678){ + cairo_save(buf->ct); + orig->moveto(origPoint[Geom::X]+1,origPoint[Geom::Y]+1); + feed_pathvector_to_cairo (buf->ct, cbp->curve->get_pathvector(), cbp->affine, area, + /* optimized_stroke = */ !dofill, 1); + ink_cairo_set_source_rgba32(buf->ct, 0x00000020); + cairo_set_line_width(buf->ct, 1); + cairo_move_to(buf->ct, origPoint[Geom::X] + 1, origPoint[Geom::Y] + 1); + cairo_stroke_preserve(buf->ct); + cairo_restore(buf->ct); + cairo_save(buf->ct); + feed_pathvector_to_cairo (buf->ct, cbp->curve->get_pathvector(), cbp->affine, area, + /* optimized_stroke = */ !dofill, 1); + ink_cairo_set_source_rgba32(buf->ct, 0xffffff20); + cairo_set_line_width(buf->ct, 1); + cairo_move_to(buf->ct, origPoint[Geom::X] - 1, origPoint[Geom::Y] - 1); + cairo_stroke_preserve(buf->ct); + cairo_restore(buf->ct); }else{ + feed_pathvector_to_cairo (buf->ct, cbp->curve->get_pathvector(), cbp->affine, area, + /* optimized_stroke = */ !dofill, 1); + ink_cairo_set_source_rgba32(buf->ct, cbp->stroke_rgba); cairo_set_line_width(buf->ct, 1); + cairo_move_to(buf->ct, origPoint[Geom::X], origPoint[Geom::Y]); + if (cbp->dashes[0] != 0 && cbp->dashes[1] != 0) { + cairo_set_dash (buf->ct, cbp->dashes, 2, 0); + } + cairo_stroke(buf->ct); } - if (cbp->dashes[0] != 0 && cbp->dashes[1] != 0) { - cairo_set_dash (buf->ct, cbp->dashes, 2, 0); - } - cairo_stroke(buf->ct); } else { cairo_new_path(buf->ct); } diff --git a/src/draw-context.cpp b/src/draw-context.cpp index 33e9b4a5d..459137cc0 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -99,7 +99,7 @@ static void sp_draw_context_init(SPDrawContext *dc) dc->red_color = 0xff00007f; dc->blue_color = 0x0000ff7f; dc->green_color = 0x00ff007f; - dc->halo_color = 0xffffff10; + dc->halo_color = 0x12345678; dc->red_curve_is_valid = false; dc->red_bpath = NULL; @@ -867,3 +867,4 @@ void spdc_create_single_dot(SPEventContext *ec, Geom::Point const &pt, char cons End: */ // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : + diff --git a/src/draw-context.h b/src/draw-context.h index 5a2db5ae0..1b4d04773 100644 --- a/src/draw-context.h +++ b/src/draw-context.h @@ -137,3 +137,4 @@ G_END_DECLS End: */ // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : + diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 70d9f8ae1..4a1384657 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -48,7 +48,7 @@ #define INKSCAPE_LPE_SPIRO_C #include "live_effects/lpe-spiro.h" -#include "display/curve.h" + #include #include <2geom/pathvector.h> #include <2geom/affine.h> @@ -964,16 +964,6 @@ static gint pen_handle_2button_press(SPPenContext *const pc, GdkEventButton cons static void pen_redraw_all (SPPenContext *const pc) { - //halo - SPCurve *halo = new SPCurve(); - if(!pc->bspline && !pc->spiro){ - if(!pc->green_curve->is_empty()) - halo->append_continuous(pc->green_curve, 0.0625); - if(!pc->red_curve->is_empty()) - halo->append_continuous(pc->red_curve, 0.0625); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->halo_bpath), halo); - sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(pc->halo_bpath), pc->halo_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); - } // green if (pc->green_bpaths) { // remove old piecewise green canvasitems @@ -1470,17 +1460,17 @@ static void spdc_pen_set_angle_distance_status_message(SPPenContext *const pc, G static void bspline_spiro_color(SPPenContext *const pc) { if(pc->spiro){ - pc->red_color = 0xc8000000; - pc->green_color = 0xc8000000; - pc->blue_color = 0x963232c8; + pc->red_color = 0xdf202000; + pc->green_color = 0x21df2100; + pc->blue_color = 0x2020dfe6; }else if (pc->bspline){ - pc->red_color = 0x323296c8; - pc->green_color = 0x323296c8; - pc->blue_color = 0x963232c8; + pc->red_color = 0xdf2020e6; + pc->green_color = 0xdf2020e6; + pc->blue_color = 0x2020dfe6; }else{ - pc->red_color = 0xff0000c8; - pc->green_color = 0x00ff00c8; - pc->blue_color = 0x0000ffc8; + pc->red_color = 0xdf2020e6; + pc->green_color = 0x21df21e6; + pc->blue_color = 0x0000ffe6; } //we hide the spiro/bspline rests if(!pc->bspline){ @@ -1792,16 +1782,8 @@ static void bspline_spiro_end_anchor_off(SPPenContext *const pc) //preparates the curves for its trasformation into BSline curves. static void bspline_spiro_build(SPPenContext *const pc) { - if(!pc->spiro && !pc->bspline){ - SPCurve *halo = new SPCurve(); - if(!pc->green_curve->is_empty()) - halo->append_continuous(pc->green_curve, 0.0625); - if(!pc->red_curve->is_empty()) - halo->append_continuous(pc->red_curve, 0.0625); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->halo_bpath), halo); - sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(pc->halo_bpath), pc->halo_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); + if(!pc->spiro && !pc->bspline) return; - } //We create the base curve SPCurve *curve = new SPCurve(); @@ -1839,21 +1821,23 @@ static void bspline_spiro_build(SPPenContext *const pc) SPCurve *halo = new SPCurve(); if(pc->bspline){ bspline_doEffect(curve); + halo = curve->copy()->create_reverse(); if(!pc->green_curve->is_empty()) halo->append_continuous(pc->green_curve, 0.0625); if(!pc->red_curve->is_empty()) halo->append_continuous(pc->red_curve, 0.0625); - halo->append(curve->copy(),false); + if(Geom::are_near(halo->first_path()->initialPoint(), halo->last_path()->finalPoint())){ + halo->closepath_current(); + } }else{ spiro_doEffect(curve); halo = curve->copy(); } + sp_canvas_item_show(pc->blue_bpath); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->halo_bpath), halo); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(pc->halo_bpath), pc->halo_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->blue_bpath), curve); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(pc->blue_bpath), pc->blue_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); - sp_canvas_item_show(pc->halo_bpath); - sp_canvas_item_show(pc->blue_bpath); curve->unref(); pc->blue_curve->reset(); //We hide the holders that doesn't contribute anything @@ -1868,7 +1852,7 @@ static void bspline_spiro_build(SPPenContext *const pc) }else{ //if the curve is empty sp_canvas_item_hide(pc->blue_bpath); - sp_canvas_item_hide(pc->halo_bpath); + } } @@ -2196,15 +2180,7 @@ static void spdc_pen_set_subsequent_point(SPPenContext *const pc, Geom::Point co is_curve = false; } } - SPCurve *halo = new SPCurve(); - if(!pc->bspline && !pc->spiro){ - if(!pc->green_curve->is_empty()) - halo->append_continuous(pc->green_curve, 0.0625); - if(!pc->red_curve->is_empty()) - halo->append_continuous(pc->red_curve, 0.0625); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->halo_bpath), halo); - sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(pc->halo_bpath), pc->halo_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); - } + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), pc->red_curve); if (statusbar) { @@ -2247,15 +2223,6 @@ static void spdc_pen_set_ctrl(SPPenContext *const pc, Geom::Point const p, guint pc->red_curve->reset(); pc->red_curve->moveto(pc->p[0]); pc->red_curve->curveto(pc->p[1], pc->p[2], pc->p[3]); - SPCurve *halo = new SPCurve(); - if(!pc->bspline && !pc->spiro){ - if(!pc->green_curve->is_empty()) - halo->append_continuous(pc->green_curve, 0.0625); - if(!pc->red_curve->is_empty()) - halo->append_continuous(pc->red_curve, 0.0625); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->halo_bpath), halo); - sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(pc->halo_bpath), pc->halo_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); - } sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), pc->red_curve); } SP_CTRL(pc->c0)->moveto(pc->p[2]); @@ -2430,3 +2397,4 @@ void pen_set_to_nearest_horiz_vert(const SPPenContext *const pc, Geom::Point &pt */ // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : + -- cgit v1.2.3 From 224bac8cddd8960f65cf08202c4f40e74c8fc1ae Mon Sep 17 00:00:00 2001 From: root Date: Sun, 14 Apr 2013 23:08:45 +0200 Subject: Go back (bzr r11950.1.93) --- src/display/canvas-bpath.cpp | 38 ++++++++------------------------------ src/draw-context.cpp | 14 -------------- src/draw-context.h | 3 --- src/pen-context.cpp | 17 ++--------------- 4 files changed, 10 insertions(+), 62 deletions(-) (limited to 'src') diff --git a/src/display/canvas-bpath.cpp b/src/display/canvas-bpath.cpp index defd95b45..8faf8947f 100644 --- a/src/display/canvas-bpath.cpp +++ b/src/display/canvas-bpath.cpp @@ -147,6 +147,9 @@ sp_canvas_bpath_render (SPCanvasItem *item, SPCanvasBuf *buf) cairo_set_tolerance(buf->ct, 0.5); cairo_new_path(buf->ct); + + feed_pathvector_to_cairo (buf->ct, cbp->curve->get_pathvector(), cbp->affine, area, + /* optimized_stroke = */ !dofill, 1); if (dofill) { // RGB / BGR ink_cairo_set_source_rgba32(buf->ct, cbp->fill_rgba); @@ -156,37 +159,12 @@ sp_canvas_bpath_render (SPCanvasItem *item, SPCanvasBuf *buf) } if (dostroke) { - SPCurve* orig = new SPCurve(cbp->curve->get_pathvector()); - Geom::Point origPoint(orig->first_path()->initialPoint()); - if(cbp->stroke_rgba == 0x12345678){ - cairo_save(buf->ct); - orig->moveto(origPoint[Geom::X]+1,origPoint[Geom::Y]+1); - feed_pathvector_to_cairo (buf->ct, cbp->curve->get_pathvector(), cbp->affine, area, - /* optimized_stroke = */ !dofill, 1); - ink_cairo_set_source_rgba32(buf->ct, 0x00000020); - cairo_set_line_width(buf->ct, 1); - cairo_move_to(buf->ct, origPoint[Geom::X] + 1, origPoint[Geom::Y] + 1); - cairo_stroke_preserve(buf->ct); - cairo_restore(buf->ct); - cairo_save(buf->ct); - feed_pathvector_to_cairo (buf->ct, cbp->curve->get_pathvector(), cbp->affine, area, - /* optimized_stroke = */ !dofill, 1); - ink_cairo_set_source_rgba32(buf->ct, 0xffffff20); - cairo_set_line_width(buf->ct, 1); - cairo_move_to(buf->ct, origPoint[Geom::X] - 1, origPoint[Geom::Y] - 1); - cairo_stroke_preserve(buf->ct); - cairo_restore(buf->ct); - }else{ - feed_pathvector_to_cairo (buf->ct, cbp->curve->get_pathvector(), cbp->affine, area, - /* optimized_stroke = */ !dofill, 1); - ink_cairo_set_source_rgba32(buf->ct, cbp->stroke_rgba); - cairo_set_line_width(buf->ct, 1); - cairo_move_to(buf->ct, origPoint[Geom::X], origPoint[Geom::Y]); - if (cbp->dashes[0] != 0 && cbp->dashes[1] != 0) { - cairo_set_dash (buf->ct, cbp->dashes, 2, 0); - } - cairo_stroke(buf->ct); + ink_cairo_set_source_rgba32(buf->ct, cbp->stroke_rgba); + cairo_set_line_width(buf->ct, 1); + if (cbp->dashes[0] != 0 && cbp->dashes[1] != 0) { + cairo_set_dash (buf->ct, cbp->dashes, 2, 0); } + cairo_stroke(buf->ct); } else { cairo_new_path(buf->ct); } diff --git a/src/draw-context.cpp b/src/draw-context.cpp index 459137cc0..69e394aaa 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -99,7 +99,6 @@ static void sp_draw_context_init(SPDrawContext *dc) dc->red_color = 0xff00007f; dc->blue_color = 0x0000ff7f; dc->green_color = 0x00ff007f; - dc->halo_color = 0x12345678; dc->red_curve_is_valid = false; dc->red_bpath = NULL; @@ -108,8 +107,6 @@ static void sp_draw_context_init(SPDrawContext *dc) dc->blue_bpath = NULL; dc->blue_curve = NULL; - dc->halo_bpath = NULL; - dc->green_bpaths = NULL; dc->green_curve = NULL; dc->green_anchor = NULL; @@ -179,10 +176,6 @@ static void sp_draw_context_setup(SPEventContext *ec) dc->blue_bpath = sp_canvas_bpath_new(sp_desktop_sketch(ec->desktop), NULL); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(dc->blue_bpath), dc->blue_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); - // Create halo bpath - dc->halo_bpath = sp_canvas_bpath_new(sp_desktop_sketch(ec->desktop), NULL); - sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(dc->halo_bpath), dc->halo_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); - // Create blue curve dc->blue_curve = new SPCurve(); @@ -539,7 +532,6 @@ void spdc_concat_colors_and_flush(SPDrawContext *dc, gboolean forceclosed) dc->red_curve->reset(); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(dc->red_bpath), NULL); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(dc->halo_bpath), NULL); if (c->is_empty()) { c->unref(); @@ -761,12 +753,6 @@ static void spdc_free_colors(SPDrawContext *dc) dc->blue_curve = dc->blue_curve->unref(); } - // Halo - if (dc->halo_bpath) { - sp_canvas_item_destroy(SP_CANVAS_ITEM(dc->halo_bpath)); - dc->halo_bpath = NULL; - } - // Green while (dc->green_bpaths) { sp_canvas_item_destroy(SP_CANVAS_ITEM(dc->green_bpaths->data)); diff --git a/src/draw-context.h b/src/draw-context.h index 1b4d04773..f930fa858 100644 --- a/src/draw-context.h +++ b/src/draw-context.h @@ -44,7 +44,6 @@ struct SPDrawContext : public SPEventContext{ guint32 red_color; guint32 blue_color; guint32 green_color; - guint32 halo_color; // Red SPCanvasItem *red_bpath; @@ -54,8 +53,6 @@ struct SPDrawContext : public SPEventContext{ SPCanvasItem *blue_bpath; SPCurve *blue_curve; - // Halo - SPCanvasItem *halo_bpath; // Green GSList *green_bpaths; diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 4a1384657..43f2fd76e 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -1401,7 +1401,6 @@ static void spdc_reset_colors(SPPenContext *pc) pc->blue_curve->reset(); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->blue_bpath), NULL); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->halo_bpath), NULL); // Green while (pc->green_bpaths) { sp_canvas_item_destroy(SP_CANVAS_ITEM(pc->green_bpaths->data)); @@ -1426,7 +1425,6 @@ static void spdc_pen_set_initial_point(SPPenContext *const pc, Geom::Point const pc->p[1] = p; pc->npoints = 2; sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), NULL); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->halo_bpath), NULL); pc->desktop->canvas->forceFullRedrawAfterInterruptions(5); } @@ -1818,26 +1816,15 @@ static void bspline_spiro_build(SPPenContext *const pc) //LivePathEffectObject *lpeobj = static_cast (curve); //Effect *spr = static_cast ( new LPEbspline(lpeobj) ); //spr->doEffect(curve); - SPCurve *halo = new SPCurve(); if(pc->bspline){ bspline_doEffect(curve); - halo = curve->copy()->create_reverse(); - if(!pc->green_curve->is_empty()) - halo->append_continuous(pc->green_curve, 0.0625); - if(!pc->red_curve->is_empty()) - halo->append_continuous(pc->red_curve, 0.0625); - if(Geom::are_near(halo->first_path()->initialPoint(), halo->last_path()->finalPoint())){ - halo->closepath_current(); - } }else{ spiro_doEffect(curve); - halo = curve->copy(); } - sp_canvas_item_show(pc->blue_bpath); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->halo_bpath), halo); - sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(pc->halo_bpath), pc->halo_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->blue_bpath), curve); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(pc->blue_bpath), pc->blue_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); + sp_canvas_item_show(pc->blue_bpath); curve->unref(); pc->blue_curve->reset(); //We hide the holders that doesn't contribute anything -- cgit v1.2.3 From 25ea29de646f639eb445a8dbef533ed3d1c35b14 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 16 Apr 2013 00:44:13 +0200 Subject: adding composite (bzr r11950.1.94) --- src/display/canvas-bpath.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/display/canvas-bpath.cpp b/src/display/canvas-bpath.cpp index 8faf8947f..9135774c1 100644 --- a/src/display/canvas-bpath.cpp +++ b/src/display/canvas-bpath.cpp @@ -133,7 +133,9 @@ sp_canvas_bpath_render (SPCanvasItem *item, SPCanvasBuf *buf) SPCanvasBPath *cbp = SP_CANVAS_BPATH (item); Geom::Rect area = buf->rect; - + double width = 0.5; + Geom::Rect viewbox = item->canvas->getViewbox(); + viewbox.expandBy (width); if ( !cbp->curve || ((cbp->stroke_rgba & 0xff) == 0 && (cbp->fill_rgba & 0xff) == 0 ) || cbp->curve->get_segment_count() < 1) @@ -144,7 +146,14 @@ sp_canvas_bpath_render (SPCanvasItem *item, SPCanvasBuf *buf) bool dofill = ((cbp->fill_rgba & 0xff) != 0); bool dostroke = ((cbp->stroke_rgba & 0xff) != 0); - + + if (dostroke) { + const cairo_rectangle_int_t *rectangle = new cairo_rectangle_int_t {viewbox.left(),viewbox.top(),viewbox.width(),viewbox.height()}; + cairo_region_create_rectangle(rectangle); + cairo_paint(buf->ct); + cairo_set_operator(buf->ct,CAIRO_OPERATOR_OVERLAY); + } + cairo_set_tolerance(buf->ct, 0.5); cairo_new_path(buf->ct); @@ -165,6 +174,7 @@ sp_canvas_bpath_render (SPCanvasItem *item, SPCanvasBuf *buf) cairo_set_dash (buf->ct, cbp->dashes, 2, 0); } cairo_stroke(buf->ct); + cairo_destroy(buf->ct); } else { cairo_new_path(buf->ct); } -- cgit v1.2.3 From 458ca2842297a5eae7e4f6fc394b227d61881c8d Mon Sep 17 00:00:00 2001 From: root Date: Wed, 17 Apr 2013 23:03:51 +0200 Subject: Update color lines overlay, with halo of 1 px matched by Gez. Fix some crash snapping. Added new button widget to make cusp node (bzr r11950.1.96) --- src/display/canvas-bpath.cpp | 2 +- src/live_effects/lpe-bspline.cpp | 95 +++++++++++++++++++++++++--------------- src/live_effects/lpe-bspline.h | 2 + src/pen-context.cpp | 62 ++++++++++++++++---------- src/pencil-context.cpp | 8 ++-- src/ui/tool/node.cpp | 17 +++++-- src/ui/tool/path-manipulator.cpp | 12 ++--- 7 files changed, 126 insertions(+), 72 deletions(-) (limited to 'src') diff --git a/src/display/canvas-bpath.cpp b/src/display/canvas-bpath.cpp index 651440512..a53b88efb 100644 --- a/src/display/canvas-bpath.cpp +++ b/src/display/canvas-bpath.cpp @@ -159,7 +159,7 @@ sp_canvas_bpath_render (SPCanvasItem *item, SPCanvasBuf *buf) } if (dostroke) { - ink_cairo_set_source_rgba32(buf->ct, 0xffffff4c); + ink_cairo_set_source_rgba32(buf->ct, 0xffffff42); cairo_set_line_width(buf->ct, 3); cairo_stroke_preserve(buf->ct); cairo_restore(buf->ct); diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 37bf24021..cc1b86e72 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -170,7 +170,7 @@ LPEBSpline::doEffect(SPCurve * curve) SBasisOut = out->first_segment()->toSBasis(); nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[1],*out->first_segment())); nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[2],*out->first_segment()));; - nextPointAt3 = (*cubic)[3]; + nextPointAt3 = out->first_segment()->finalPoint(); }else{ nextPointAt1 = out->first_segment()->initialPoint(); nextPointAt2 = out->first_segment()->finalPoint(); @@ -299,19 +299,24 @@ LPEBSpline::newWidget() defaultWeight->signal_clicked().connect(sigc::mem_fun (*this,&LPEBSpline::toDefaultWeight)); Gtk::Widget* defaultWeightWidget = dynamic_cast(defaultWeight); vbox->pack_start(*defaultWeightWidget, true, true,2); + Gtk::Button* makeCusp = Gtk::manage(new Gtk::Button(Glib::ustring(_("Make cusp")))); + makeCusp->set_alignment(0.0, 0.5); + makeCusp->signal_clicked().connect(sigc::mem_fun (*this,&LPEBSpline::toMakeCusp)); + Gtk::Widget* makeCuspWidget = dynamic_cast(makeCusp); + vbox->pack_start(*makeCuspWidget, true, true,2); return dynamic_cast(vbox); } void LPEBSpline::toDefaultWeight(){ - Gtk::Widget * widg = dynamic_cast(param_vector[3]->param_newWidget()); - Inkscape::UI::Widget::Scalar * widgRegistered = Gtk::manage(dynamic_cast(widg)); - widgRegistered->setValue(0.3334); - widgRegistered->update(); - weight.param_set_value(0.3334); changeWeight(0.3334); } +void +LPEBSpline::toMakeCusp(){ + changeWeight(0.0000); +} + void LPEBSpline::toWeight(){ changeWeight(weight); @@ -434,24 +439,32 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) SBasisIn = in->first_segment()->toSBasis(); if(!onlySelected){ if(cubic){ - if(!ignoreCusp || (!Geom::are_near((*cubic)[1],in->first_segment()->initialPoint()) && weightValue !=0)){ + if(!ignoreCusp || !Geom::are_near((*cubic)[1],pointAt0)){ pointAt1 = SBasisIn.valueAt(weightValue); - pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); + if(weightValue !=0.0000){ + pointAt1 = Geom::Point(pointAt1[X] + 0.0001,pointAt1[Y] + 0.0001); + } }else{ pointAt1 = in->first_segment()->initialPoint(); } - if((!ignoreCusp || !Geom::are_near((*cubic)[2],in->first_segment()->finalPoint())) && weightValue !=0){ + if(!ignoreCusp || !Geom::are_near((*cubic)[2],pointAt3)){ pointAt2 = SBasisIn.valueAt(1-weightValue); - pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); - }else{ + if(weightValue !=0.0000){ + pointAt2 = Geom::Point(pointAt2[X] + 0.0001,pointAt2[Y] + 0.0001); + } + }else{ pointAt2 = in->first_segment()->finalPoint(); } }else{ - if(!ignoreCusp && weightValue !=0){ + if(!ignoreCusp && weightValue !=0.0000){ pointAt1 = SBasisIn.valueAt(weightValue); - pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); + if(weightValue !=0.0000){ + pointAt1 = Geom::Point(pointAt1[X] + 0.0001,pointAt1[Y] + 0.0001); + } pointAt2 = SBasisIn.valueAt(1-weightValue); - pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); + if(weightValue !=0.0000){ + pointAt2 = Geom::Point(pointAt2[X] + 0.0001,pointAt2[Y] + 0.0001); + } }else{ pointAt1 = in->first_segment()->initialPoint(); pointAt2 = in->first_segment()->finalPoint(); @@ -459,20 +472,24 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) } }else{ if(cubic){ - if(!ignoreCusp || (!Geom::are_near((*cubic)[1],in->first_segment()->initialPoint())&& weightValue !=0)){ + if(!ignoreCusp || !Geom::are_near((*cubic)[1],pointAt0)){ if(nodeIsSelected(pointAt0)){ pointAt1 = SBasisIn.valueAt(weightValue); - pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); + if(weightValue !=0.0000){ + pointAt1 = Geom::Point(pointAt1[X] + 0.0001,pointAt1[Y] + 0.0001); + } }else{ pointAt1 = (*cubic)[1]; } }else{ pointAt1 = in->first_segment()->initialPoint(); } - if(!ignoreCusp || (!Geom::are_near((*cubic)[2],in->first_segment()->finalPoint()) && weightValue !=0)){ + if(!ignoreCusp || !Geom::are_near((*cubic)[2],pointAt3)){ if(nodeIsSelected(pointAt3)){ pointAt2 = SBasisIn.valueAt(1-weightValue); - pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); + if(weightValue !=0.0000){ + pointAt2 = Geom::Point(pointAt2[X] + 0.0001,pointAt2[Y] + 0.0001); + } }else{ pointAt2 = (*cubic)[2]; } @@ -480,16 +497,16 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) pointAt2 = in->first_segment()->finalPoint(); } }else{ - if(!ignoreCusp && weightValue !=0){ + if(!ignoreCusp && weightValue !=0.000){ if(nodeIsSelected(pointAt0)){ pointAt1 = SBasisIn.valueAt(weightValue); - pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); + pointAt1 = Geom::Point(pointAt1[X] + 0.0001,pointAt1[Y] + 0.0001); }else{ pointAt1 = in->first_segment()->initialPoint(); } if(nodeIsSelected(pointAt3)){ pointAt2 = SBasisIn.valueAt(weightValue); - pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); + pointAt2 = Geom::Point(pointAt2[X] + 0.0001,pointAt2[Y] + 0.0001); }else{ pointAt2 = in->first_segment()->finalPoint(); } @@ -520,24 +537,28 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) cubic = dynamic_cast(&*curve_it1); if(!onlySelected){ if(cubic){ - if((!ignoreCusp || !Geom::are_near((*cubic)[1],out->first_segment()->initialPoint()))&& weightValue !=0){ + if(!ignoreCusp || !Geom::are_near((*cubic)[1],nextPointAt0)){ nextPointAt1 = SBasisOut.valueAt(weightValue); - nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); + if(weightValue !=0.0000){ + nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0001,nextPointAt1[Y] + 0.0001); + } }else{ nextPointAt1 = out->first_segment()->initialPoint(); } - if((!ignoreCusp || !Geom::are_near((*cubic)[2],out->first_segment()->finalPoint()))&& weightValue !=0){ + if(!ignoreCusp || !Geom::are_near((*cubic)[2],nextPointAt3)){ nextPointAt2 = SBasisOut.valueAt(1-weightValue); - nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); + if(weightValue !=0.0000){ + nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0001,nextPointAt2[Y] + 0.0001); + } }else{ nextPointAt2 = out->first_segment()->finalPoint(); } }else{ - if(!ignoreCusp && weightValue !=0){ + if(!ignoreCusp && weightValue !=0.0000){ nextPointAt1 = SBasisOut.valueAt(weightValue); - nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); + nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0001,nextPointAt1[Y] + 0.0001); nextPointAt2 = SBasisOut.valueAt(1-weightValue); - nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); + nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0001,nextPointAt2[Y] + 0.0001); }else{ nextPointAt1 = out->first_segment()->initialPoint(); nextPointAt2 = out->first_segment()->finalPoint(); @@ -545,20 +566,24 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) } }else{ if(cubic){ - if(!ignoreCusp || (!Geom::are_near((*cubic)[1],out->first_segment()->initialPoint()) && weightValue !=0)){ + if(!ignoreCusp || !Geom::are_near((*cubic)[1],nextPointAt0)){ if(nodeIsSelected(nextPointAt0)){ nextPointAt1 = SBasisOut.valueAt(weightValue); - nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); + if(weightValue !=0.0000){ + nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0001,nextPointAt1[Y] + 0.0001); + } }else{ nextPointAt1 = (*cubic)[1]; } }else{ nextPointAt1 = out->first_segment()->initialPoint(); } - if(!ignoreCusp || (!Geom::are_near((*cubic)[2],out->first_segment()->finalPoint()) && weightValue !=0)){ + if(!ignoreCusp || !Geom::are_near((*cubic)[2],nextPointAt3)){ if(nodeIsSelected(nextPointAt3)){ nextPointAt2 = SBasisOut.valueAt(1-weightValue); - nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); + if(weightValue !=0.0000){ + nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0001,nextPointAt2[Y] + 0.0001); + } }else{ nextPointAt2 = (*cubic)[2]; } @@ -566,16 +591,16 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) nextPointAt2 = out->first_segment()->finalPoint(); } }else{ - if(!ignoreCusp && weightValue !=0){ + if(!ignoreCusp && weightValue !=0.0000){ if(nodeIsSelected(nextPointAt0)){ nextPointAt1 = SBasisOut.valueAt(weightValue); - nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); + nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0001,nextPointAt1[Y] + 0.0001); }else{ nextPointAt1 = out->first_segment()->initialPoint(); } if(nodeIsSelected(nextPointAt3)){ nextPointAt2 = SBasisOut.valueAt(weightValue); - nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); + nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0001,nextPointAt2[Y] + 0.0001); }else{ nextPointAt2 = out->first_segment()->finalPoint(); } diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index 103f09338..510f9c989 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -37,6 +37,8 @@ public: virtual void toDefaultWeight(); + virtual void toMakeCusp(); + virtual void toWeight(); ScalarParam steps; diff --git a/src/pen-context.cpp b/src/pen-context.cpp index c0fc908f0..181579fa2 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -656,7 +656,6 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gint const tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); //"spiro_color" lo ejecutamos siempre sea o no spiro - bspline_spiro_color(pc); if (pen_within_tolerance) { if ( Geom::LInfty( event_w - pen_drag_origin_w ) < tolerance) { return FALSE; // Do not drag if we're within tolerance from origin. @@ -781,6 +780,7 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons //BSpline //Lanzamos la función "bspline_spiro_motion" al moverse el ratón o cuando se para. if ( Geom::LInfty( event_w - pen_drag_origin_w ) > tolerance || mevent.time == 0) { + bspline_spiro_color(pc); bspline_spiro_motion(pc,(mevent.state & GDK_SHIFT_MASK)); pen_drag_origin_w = event_w; } @@ -1452,31 +1452,48 @@ static void spdc_pen_set_angle_distance_status_message(SPPenContext *const pc, G g_string_free(dist, FALSE); } - - //Esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro static void bspline_spiro_color(SPPenContext *const pc) { + bool remake_green_bpaths = false; if(pc->spiro){ - pc->red_color = 0xffffff00; - pc->green_color = 0xffffff00; - pc->blue_color = 0x23abcdff; - }else if (pc->bspline){ - pc->red_color = 0xe68024ff; - pc->green_color = 0xe68024ff; - pc->blue_color = 0x23abcdff; - }else{ - pc->red_color = 0xe68024ff; - pc->green_color = 0xf372ebff; - pc->blue_color = 0x23abcdff; - } + //If the colour is not defined as trasparent, por example when changing + //from drawing to spiro mode or when selecting the pen tool + if(pc->green_color != 0x00ff000){ + //We change the green and red colours to transparent, so this lines are not necessary + //to the drawing with spiro + pc->red_color = 0x00ff000; + pc->green_color = 0x00ff000; + pc->blue_color = 0x23abcdff; + remake_green_bpaths = true; + } + }else if(pc->bspline){ + //If we come from working with the spiro curve and change the mode the "green_curve" colour is transparent + if(pc->green_color != 0xe68024ff){ + //since we are not im spiro mode, we assign the original colours + //to the red and the green curve, removing their transparency + pc->red_color = 0xe68024ff; + pc->green_color = 0xe68024ff; + pc->blue_color = 0x23abcdff; + remake_green_bpaths = true; + } //we hide the spiro/bspline rests + }else{ + if(pc->green_color != 0xf372ebff){ + //since we are not im spiro mode, we assign the original colours + //to the red and the green curve, removing their transparency + pc->red_color = 0xe68024ff; + pc->green_color = 0xf372ebff; + pc->blue_color = 0x23abcdff; + remake_green_bpaths = true; + } + } if(!pc->bspline){ sp_canvas_item_hide(pc->blue_bpath); } //We erase all the "green_bpaths" to recreate them after with the colour //transparency recently modified - if (pc->green_bpaths) { + if (pc->green_bpaths && remake_green_bpaths) { // remove old piecewise green canvasitems while (pc->green_bpaths) { sp_canvas_item_destroy(SP_CANVAS_ITEM(pc->green_bpaths->data)); @@ -1491,6 +1508,7 @@ static void bspline_spiro_color(SPPenContext *const pc) sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(pc->red_bpath), pc->red_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); } + static void bspline_spiro(SPPenContext *const pc, bool shift) { if(!pc->spiro && !pc->bspline) @@ -1511,7 +1529,7 @@ static void bspline_spiro_on(SPPenContext *const pc) pc->p[0] = pc->red_curve->first_segment()->initialPoint(); pc->p[3] = pc->red_curve->first_segment()->finalPoint(); pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); - pc->p[2] = Geom::Point(pc->p[2][X] + 0.0625,pc->p[2][Y] + 0.0625); + pc->p[2] = Geom::Point(pc->p[2][X] + 0.0001,pc->p[2][Y] + 0.0001); } } @@ -1552,7 +1570,7 @@ static void bspline_spiro_start_anchor_on(SPPenContext *const pc) Geom::Point A = tmpCurve->last_segment()->initialPoint(); Geom::Point D = tmpCurve->last_segment()->finalPoint(); Geom::Point C = D + (1./3)*(A - D); - C = Geom::Point(C[X] + 0.0625,C[Y] + 0.0625); + C = Geom::Point(C[X] + 0.0001,C[Y] + 0.0001); if(cubic){ lastSeg->moveto(A); lastSeg->curveto((*cubic)[1],C,D); @@ -1637,7 +1655,7 @@ static void bspline_spiro_motion(SPPenContext *const pc, bool shift){ WPower->reset(); pc->p[1] = SBasisWPower.valueAt(WP); if(!Geom::are_near(pc->p[1],pc->p[0])) - pc->p[1] = Geom::Point(pc->p[1][X] + 0.0625,pc->p[1][Y] + 0.0625); + pc->p[1] = Geom::Point(pc->p[1][X] + 0.0001,pc->p[1][Y] + 0.0001); }else{ pc->p[1] = (*cubic)[3] + (Geom::Point)((*cubic)[3] - (*cubic)[2] ); } @@ -1662,7 +1680,7 @@ static void bspline_spiro_end_anchor_on(SPPenContext *const pc) using Geom::X; using Geom::Y; pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); - pc->p[2] = Geom::Point(pc->p[2][X] + 0.0625,pc->p[2][Y] + 0.0625); + pc->p[2] = Geom::Point(pc->p[2][X] + 0.0001,pc->p[2][Y] + 0.0001); SPCurve *tmpCurve = new SPCurve(); SPCurve *lastSeg = new SPCurve(); Geom::Point C(0,0); @@ -1671,7 +1689,7 @@ static void bspline_spiro_end_anchor_on(SPPenContext *const pc) Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); if(pc->bspline){ C = tmpCurve->last_segment()->finalPoint() + (1./3)*(tmpCurve->last_segment()->initialPoint() - tmpCurve->last_segment()->finalPoint()); - C = Geom::Point(C[X] + 0.0625,C[Y] + 0.0625); + C = Geom::Point(C[X] + 0.0001,C[Y] + 0.0001); }else{ C = pc->p[3] + (Geom::Point)(pc->p[3] - pc->p[2] ); } @@ -1700,7 +1718,7 @@ static void bspline_spiro_end_anchor_on(SPPenContext *const pc) Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); if(pc->bspline){ C = tmpCurve->last_segment()->finalPoint() + (1./3)*(tmpCurve->last_segment()->initialPoint() - tmpCurve->last_segment()->finalPoint()); - C = Geom::Point(C[X] + 0.0625,C[Y] + 0.0625); + C = Geom::Point(C[X] + 0.0001,C[Y] + 0.0001); }else{ C = pc->p[3] + (Geom::Point)(pc->p[3] - pc->p[2] ); } diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp index a7fa5e111..304f81890 100644 --- a/src/pencil-context.cpp +++ b/src/pencil-context.cpp @@ -766,9 +766,9 @@ interpolate(SPPencilContext *pc) //Si el modo es BSpline modificamos para que el trazado cree los nodos adhoc if(mode == 2){ Geom::Point BP = b[4*c+0] + (1./3)*(b[4*c+3] - b[4*c+0]); - BP = Geom::Point(BP[X] + 0.0625,BP[Y] + 0.0625); + BP = Geom::Point(BP[X] + 0.0001,BP[Y] + 0.0001); Geom::Point CP = b[4*c+3] + (1./3)*(b[4*c+0] - b[4*c+3]); - CP = Geom::Point(CP[X] + 0.0625,CP[Y] + 0.0625); + CP = Geom::Point(CP[X] + 0.0001,CP[Y] + 0.0001); pc->green_curve->curveto(BP,CP,b[4*c+3]); }else{ pc->green_curve->curveto(b[4*c+1], b[4*c+2], b[4*c+3]); @@ -922,9 +922,9 @@ fit_and_split(SPPencilContext *pc) guint mode = prefs->getInt("/tools/freehand/pencil/freehand-mode", 0); if(mode == 2){ Geom::Point B = b[0] + (1./3)*(b[3] - b[0]); - B = Geom::Point(B[X] + 0.0625,B[Y] + 0.0625); + B = Geom::Point(B[X] + 0.0001,B[Y] + 0.0001); Geom::Point C = b[3] + (1./3)*(b[0] - b[3]); - C = Geom::Point(C[X] + 0.0625,C[Y] + 0.0625); + C = Geom::Point(C[X] + 0.0001,C[Y] + 0.0001); pc->red_curve->curveto(B,C,b[3]); }else{ pc->red_curve->curveto(b[1], b[2], b[3]); diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 8f1c37649..011d0d296 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -146,10 +146,8 @@ void Handle::move(Geom::Point const &new_pos) Set &nodes = _parent->_selection.allPoints(); for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { Node *n = static_cast(*i); - if(n != _parent) - _parent->_selection.erase(n); + _parent->_selection.erase(n); } - if(!_parent->selected()) _parent->_selection.insert(_parent); } //BSpline End @@ -187,8 +185,8 @@ void Handle::move(Geom::Point const &new_pos) //BSpline if(_pm().isBSpline){ h = this; - setPosition(_pm().BSplineHandleReposition(h)); _parent->bsplineWeight = _pm().BSplineHandlePosition(h); + setPosition(_pm().BSplineHandleReposition(h,_parent->bsplineWeight)); h2 = this->other(); this->other()->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); } @@ -422,6 +420,16 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) sm.freeSnapReturnByRef(new_pos, SNAPSOURCE_NODE_HANDLE); } sm.unSetup(); + //BSpline + if(_pm().isBSpline){ + Handle *h = NULL; + _parent->bsplineWeight = 0; + h = this; + setPosition(new_pos); + _parent->bsplineWeight = _pm().BSplineHandlePosition(h); + new_pos=_pm().BSplineHandleReposition(h,_parent->bsplineWeight); + } + //BSpline End } @@ -452,6 +460,7 @@ void Handle::ungrabbed(GdkEventButton *event) Geom::Point dist = _desktop->d2w(_parent->position()) - _desktop->d2w(position()); if (dist.length() <= drag_tolerance) { move(_parent->position()); + _parent->bsplineWeight = 0; } } diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 6cad60fee..9da27e807 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1204,14 +1204,14 @@ int PathManipulator::getSteps(){ double PathManipulator::BSplineHandlePosition(Handle *h){ using Geom::X; using Geom::Y; - double pos = 0; + double pos = 0.0000; Node *n = h->parent(); SPCurve *lineInsideNodes = new SPCurve(); Node * nextNode = NULL; if(!n->isEndNode()) nextNode = n->nodeToward(h); Geom::Point positionH = h->position(); - positionH = Geom::Point(positionH[X] - 0.0625,positionH[Y] - 0.0625); + positionH = Geom::Point(positionH[X] + 0.0001,positionH[Y] + 0.0001); if(nextNode && n->position() != h->position()){ lineInsideNodes->moveto(n->position()); lineInsideNodes->lineto(nextNode->position()); @@ -1235,12 +1235,12 @@ Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){ Node * nextNode = NULL; if(!n->isEndNode()) nextNode = n->nodeToward(h); - if(nextNode && pos != 0){ + if(nextNode && pos != 0.0000){ lineInsideNodes->moveto(n->position()); lineInsideNodes->lineto(nextNode->position()); SBasisInsideNodes = lineInsideNodes->first_segment()->toSBasis(); ret = SBasisInsideNodes.valueAt(pos); - ret = Geom::Point(ret[X] + 0.0625,ret[Y] + 0.0625); + ret = Geom::Point(ret[X] + 0.0001,ret[Y] + 0.0001); }else{ ret = n->position(); } @@ -1251,8 +1251,8 @@ void PathManipulator::BSplineNodeHandlesReposition(Node *n){ if(n->selected()){ Node * nextNode = n->nodeToward(n->front()); Node * prevNode = n->nodeToward(n->back()); - double prevPos = 0; - double nextPos = 0; + double prevPos = 0.0000; + double nextPos = 0.0000; if(prevNode) prevPos = BSplineHandlePosition(prevNode->front()); if(nextNode) -- cgit v1.2.3 From 865b863409353b45ceadb317a80a75a4409e07a4 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 18 Apr 2013 20:17:28 +0200 Subject: updates to colors (bzr r11950.1.97) --- src/display/canvas-bpath.cpp | 2 +- src/sp-guide.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/display/canvas-bpath.cpp b/src/display/canvas-bpath.cpp index a53b88efb..502bf440e 100644 --- a/src/display/canvas-bpath.cpp +++ b/src/display/canvas-bpath.cpp @@ -16,7 +16,7 @@ #endif #include #include -#include "document.h" +#include "desktop.h" #include "color.h" #include "display/sp-canvas-group.h" diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 48596cbc0..3266d8819 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -95,8 +95,8 @@ static void sp_guide_init(SPGuide *guide) { guide->normal_to_line = Geom::Point(0.,1.); guide->point_on_line = Geom::Point(0.,0.); - guide->color = 0x0000ff7f; - guide->hicolor = 0xff00007f; + guide->color = 0x23abcd7f; + guide->hicolor = 0xf372eb7f; } static void sp_guide_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec */*pspec*/) -- cgit v1.2.3 From 9555c8e9051ba5b5d80912a6fd79f85cf12829d6 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 18 Apr 2013 21:55:41 +0200 Subject: Back to original colors (bzr r11950.1.99) --- src/pen-context.cpp | 25 +++++++------------------ src/sp-guide.cpp | 4 ++-- src/ui/control-manager.cpp | 6 +++--- 3 files changed, 12 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 181579fa2..7fb99e32e 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -1462,34 +1462,23 @@ static void bspline_spiro_color(SPPenContext *const pc) if(pc->green_color != 0x00ff000){ //We change the green and red colours to transparent, so this lines are not necessary //to the drawing with spiro - pc->red_color = 0x00ff000; + pc->red_color = 0xff00000; pc->green_color = 0x00ff000; - pc->blue_color = 0x23abcdff; remake_green_bpaths = true; } - }else if(pc->bspline){ + }else{ //If we come from working with the spiro curve and change the mode the "green_curve" colour is transparent - if(pc->green_color != 0xe68024ff){ + if(pc->green_color != 0x00ff007f){ //since we are not im spiro mode, we assign the original colours //to the red and the green curve, removing their transparency - pc->red_color = 0xe68024ff; - pc->green_color = 0xe68024ff; - pc->blue_color = 0x23abcdff; + pc->red_color = 0xff00007f; + pc->green_color = 0x00ff007f; remake_green_bpaths = true; } //we hide the spiro/bspline rests - }else{ - if(pc->green_color != 0xf372ebff){ - //since we are not im spiro mode, we assign the original colours - //to the red and the green curve, removing their transparency - pc->red_color = 0xe68024ff; - pc->green_color = 0xf372ebff; - pc->blue_color = 0x23abcdff; - remake_green_bpaths = true; + if(!pc->bspline){ + sp_canvas_item_hide(pc->blue_bpath); } - } - if(!pc->bspline){ - sp_canvas_item_hide(pc->blue_bpath); } //We erase all the "green_bpaths" to recreate them after with the colour //transparency recently modified diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 3266d8819..48596cbc0 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -95,8 +95,8 @@ static void sp_guide_init(SPGuide *guide) { guide->normal_to_line = Geom::Point(0.,1.); guide->point_on_line = Geom::Point(0.,0.); - guide->color = 0x23abcd7f; - guide->hicolor = 0xf372eb7f; + guide->color = 0x0000ff7f; + guide->hicolor = 0xff00007f; } static void sp_guide_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec */*pspec*/) diff --git a/src/ui/control-manager.cpp b/src/ui/control-manager.cpp index 9425bc3f0..5a3c5a496 100644 --- a/src/ui/control-manager.cpp +++ b/src/ui/control-manager.cpp @@ -59,9 +59,9 @@ ControlFlags& operator ^=(ControlFlags &lhs, ControlFlags rhs) #define FILL_COLOR_MOUSEOVER 0xff0000ff // Default color for line: -#define LINE_COLOR_PRIMARY 0x23abcdff -#define LINE_COLOR_SECONDARY 0xf372ebff -#define LINE_COLOR_TERTIARY 0xe68024ff +#define LINE_COLOR_PRIMARY 0x0000ff7f +#define LINE_COLOR_SECONDARY 0xff00007f +#define LINE_COLOR_TERTIARY 0xffff007f namespace Inkscape { -- cgit v1.2.3 From fc5f8b8694f2b583f08fc423787319193097c9ca Mon Sep 17 00:00:00 2001 From: root Date: Thu, 18 Apr 2013 22:56:50 +0200 Subject: Remove mesh tool active from source (bzr r11950.1.101) --- src/widgets/toolbox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index f9f13fa3a..88821b69b 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -110,7 +110,7 @@ enum BarId { BAR_COMMANDS, BAR_SNAP, }; -#define WITH_MESH +//#define WITH_MESH #define BAR_ID_KEY "BarIdValue" #define HANDLE_POS_MARK "x-inkscape-pos" -- cgit v1.2.3 From b61a6eab38cd9a97aebec641c4484b872ca2905b Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 19 Apr 2013 08:48:12 +0200 Subject: Adding automatic removed files, Why it? I put again becasue are in branch (bzr r11950.1.102) --- src/libavoid/makefile | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/libavoid/makefile (limited to 'src') diff --git a/src/libavoid/makefile b/src/libavoid/makefile new file mode 100644 index 000000000..e4f83a52d --- /dev/null +++ b/src/libavoid/makefile @@ -0,0 +1,17 @@ +# Convenience stub makefile to call the real Makefile. + + + +OBJEXT = o + +# Explicit so that it's the default rule. +all: + cd .. && $(MAKE) libavoid/all + +clean %.a %.$(OBJEXT): + cd .. && $(MAKE) libavoid/$@ + +.PHONY: all clean + +.SUFFIXES: +.SUFFIXES: .a .$(OBJEXT) -- cgit v1.2.3 From 56d9d0a05e24697275ebcfcbbabe46a401e8df31 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 26 Apr 2013 19:06:13 +0200 Subject: update icons (bzr r11950.1.108) --- src/widgets/icon.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 7580d9602..977b1badf 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -679,6 +679,7 @@ void IconImpl::setupLegacyNaming() { legacyNames["draw-star"] ="star_angled"; legacyNames["path-mode-bezier"] ="bezier_mode"; legacyNames["path-mode-spiro"] ="spiro_splines_mode"; + legacyNames["path-mode-bspline"] ="bspline_mode"; legacyNames["path-mode-polyline"] ="polylines_mode"; legacyNames["path-mode-polyline-paraxial"] ="paraxial_lines_mode"; legacyNames["draw-use-tilt"] ="guse_tilt"; -- cgit v1.2.3 From be4b46000a9a9f29d79b2e939c0669f6ddf0c59f Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 27 Apr 2013 02:01:11 +0200 Subject: Fixed important selection bug when changing to cusp nodes (bzr r11950.1.109) --- src/ui/tool/node.cpp | 69 +++++++++++++++++++++++----------------- src/ui/tool/path-manipulator.cpp | 6 ++-- 2 files changed, 44 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 011d0d296..d342d6c3d 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -141,17 +141,7 @@ void Handle::move(Geom::Point const &new_pos) //BSpline Handle *h = NULL; Handle *h2 = NULL; - if(_pm().isBSpline){ - typedef ControlPointSelection::Set Set; - Set &nodes = _parent->_selection.allPoints(); - for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { - Node *n = static_cast(*i); - _parent->_selection.erase(n); - } - _parent->_selection.insert(_parent); - } //BSpline End - if (Geom::are_near(new_pos, _parent->position())) { // The handle becomes degenerate. // Adjust node type as necessary. @@ -322,7 +312,7 @@ void Handle::handle_2button_press(){ if(_pm().isBSpline){ Handle *h = NULL; Handle *h2 = NULL; - _parent->bsplineWeight = 0; + _parent->bsplineWeight = 0.0000; h = this; setPosition(_pm().BSplineHandleReposition(h,0.3334)); _parent->bsplineWeight = _pm().BSplineHandlePosition(h); @@ -343,6 +333,7 @@ bool Handle::grabbed(GdkEventMotion *) void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) { + Geom::Point parent_pos = _parent->position(); Geom::Point origin = _last_drag_origin(); SnapManager &sm = _desktop->namedview->snap_manager; @@ -383,7 +374,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) //BSpline if(_pm().isBSpline){ Handle *h = NULL; - _parent->bsplineWeight = 0; + _parent->bsplineWeight = 0.0000; h = this; setPosition(new_pos); int steps = _pm().getSteps(); @@ -423,7 +414,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) //BSpline if(_pm().isBSpline){ Handle *h = NULL; - _parent->bsplineWeight = 0; + _parent->bsplineWeight = 0.0000; h = this; setPosition(new_pos); _parent->bsplineWeight = _pm().BSplineHandlePosition(h); @@ -460,7 +451,7 @@ void Handle::ungrabbed(GdkEventButton *event) Geom::Point dist = _desktop->d2w(_parent->position()) - _desktop->d2w(position()); if (dist.length() <= drag_tolerance) { move(_parent->position()); - _parent->bsplineWeight = 0; + _parent->bsplineWeight = 0.0000; } } @@ -472,11 +463,33 @@ void Handle::ungrabbed(GdkEventButton *event) _drag_out = false; _pm()._handleUngrabbed(); + //BSpline + if(_pm().isBSpline){ + typedef ControlPointSelection::Set Set; + Set &nodes = _parent->_selection.allPoints(); + for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { + Node *n = static_cast(*i); + _parent->_selection.erase(n); + } + _parent->_selection.insert(_parent); + } + //BSpline End } bool Handle::clicked(GdkEventButton *event) { _pm()._handleClicked(this, event); + //BSpline + if(_pm().isBSpline){ + typedef ControlPointSelection::Set Set; + Set &nodes = _parent->_selection.allPoints(); + for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { + Node *n = static_cast(*i); + _parent->_selection.erase(n); + } + _parent->_selection.insert(_parent); + } + //BSpline End return true; } @@ -627,8 +640,8 @@ void Node::move(Geom::Point const &new_pos) Geom::Point old_pos = position(); Geom::Point delta = new_pos - position(); //BSpline - double prevPos = 0; - double nextPos = 0; + double prevPos = 0.0000; + double nextPos = 0.0000; Node *n = this; Node * nextNode = n->nodeToward(n->front()); Node * prevNode = n->nodeToward(n->back()); @@ -636,7 +649,7 @@ void Node::move(Geom::Point const &new_pos) if(prevNode) prevPos = _pm().BSplineHandlePosition(prevNode->front()); n->bsplineWeight = _pm().BSplineHandlePosition(n->front()); - if(n->bsplineWeight == 0) + if(n->bsplineWeight == 0.0000) n->bsplineWeight = _pm().BSplineHandlePosition(n->back()); if(nextNode) nextPos = _pm().BSplineHandlePosition(nextNode->back()); @@ -770,7 +783,7 @@ void Node::updateHandles() _front._handleControlStyling(); _back._handleControlStyling(); } - + void Node::setType(NodeType type, bool update_handles) { @@ -779,7 +792,14 @@ void Node::setType(NodeType type, bool update_handles) updateState(); // The size of the control might have changed return; } - + //BSpline + bool isBSpline = false; + try { + isBSpline = nodeList().subpathList().pm().isBSpline; + } + catch( char * str ) { + } + //BSpline End // if update_handles is true, adjust handle positions to match the node type // handle degenerate handles appropriately if (update_handles) { @@ -863,28 +883,19 @@ void Node::setType(NodeType type, bool update_handles) default: break; } //BSpline - bool isBSpline = false; - try { - isBSpline = nodeList().subpathList().pm().isBSpline; - } - catch( char * str ) { - } if(isBSpline){ Handle* front = &_front; Handle* back = &_back; this->bsplineWeight = _pm().BSplineHandlePosition(front); - if(this->bsplineWeight !=0) this->bsplineWeight = 0.3334; + if(this->bsplineWeight !=0.0000) this->bsplineWeight = 0.3334; _front.setPosition(_pm().BSplineHandleReposition(front,this->bsplineWeight)); _back.setPosition(_pm().BSplineHandleReposition(back,this->bsplineWeight)); } //BSpline End } - _type = type; - _setControlType(nodeTypeToCtrlType(_type)); updateState(); - } void Node::pickBestType() diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 9da27e807..cad794860 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1239,9 +1239,11 @@ Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){ lineInsideNodes->moveto(n->position()); lineInsideNodes->lineto(nextNode->position()); SBasisInsideNodes = lineInsideNodes->first_segment()->toSBasis(); + n->bsplineWeight = pos; ret = SBasisInsideNodes.valueAt(pos); ret = Geom::Point(ret[X] + 0.0001,ret[Y] + 0.0001); }else{ + n->bsplineWeight = 0.0000; ret = n->position(); } return ret; @@ -1257,8 +1259,8 @@ void PathManipulator::BSplineNodeHandlesReposition(Node *n){ prevPos = BSplineHandlePosition(prevNode->front()); if(nextNode) nextPos = BSplineHandlePosition(nextNode->back()); - n->front()->setPosition(BSplineHandleReposition(n->front(),n->bsplineWeight)); - n->back()->setPosition(BSplineHandleReposition(n->back(),n->bsplineWeight)); + n->front()->setPosition(BSplineHandleReposition(n->front())); + n->back()->setPosition(BSplineHandleReposition(n->back())); if(prevNode) prevNode->front()->setPosition(BSplineHandleReposition(prevNode->front(),prevPos)); if(nextNode) -- cgit v1.2.3 From dd30de233b38518008030c2c0a2366332422b236 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 6 May 2013 02:54:50 +0200 Subject: Removed auto select nodes, not decide for the user. Added auto update all selected handles when drag (bzr r11950.1.111) --- src/ui/tool/node.cpp | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index d342d6c3d..1d7b5850f 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -216,8 +216,15 @@ void Handle::move(Geom::Point const &new_pos) h = this; setPosition(_pm().BSplineHandleReposition(h)); _parent->bsplineWeight = _pm().BSplineHandlePosition(h); - h2 = this->other(); - this->other()->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); + typedef ControlPointSelection::Set Set; + Set &nodes = _parent->_selection.allPoints(); + for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { + Node *n = static_cast(*i); + h = n->front(); + h2 = n->back(); + h->setPosition(_pm().BSplineHandleReposition(h,_parent->bsplineWeight)); + h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); + } } //BSpline End } @@ -463,33 +470,11 @@ void Handle::ungrabbed(GdkEventButton *event) _drag_out = false; _pm()._handleUngrabbed(); - //BSpline - if(_pm().isBSpline){ - typedef ControlPointSelection::Set Set; - Set &nodes = _parent->_selection.allPoints(); - for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { - Node *n = static_cast(*i); - _parent->_selection.erase(n); - } - _parent->_selection.insert(_parent); - } - //BSpline End } bool Handle::clicked(GdkEventButton *event) { _pm()._handleClicked(this, event); - //BSpline - if(_pm().isBSpline){ - typedef ControlPointSelection::Set Set; - Set &nodes = _parent->_selection.allPoints(); - for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { - Node *n = static_cast(*i); - _parent->_selection.erase(n); - } - _parent->_selection.insert(_parent); - } - //BSpline End return true; } -- cgit v1.2.3 From 417a1e079bbc94ac0d8c6631832e47a35098ba98 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 6 May 2013 03:36:46 +0200 Subject: Change only selected nodes (bzr r11950.1.113) --- src/ui/tool/node.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 1d7b5850f..5362a6c45 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -219,11 +219,13 @@ void Handle::move(Geom::Point const &new_pos) typedef ControlPointSelection::Set Set; Set &nodes = _parent->_selection.allPoints(); for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { - Node *n = static_cast(*i); - h = n->front(); - h2 = n->back(); - h->setPosition(_pm().BSplineHandleReposition(h,_parent->bsplineWeight)); - h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); + if((*i)->selected()){ + Node *n = static_cast(*i); + h = n->front(); + h2 = n->back(); + h->setPosition(_pm().BSplineHandleReposition(h,_parent->bsplineWeight)); + h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); + } } } //BSpline End -- cgit v1.2.3 From e17c04bd7386e2e346b7f4f760f6e6ba3c24b886 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 17 May 2013 00:53:42 +0200 Subject: Fix error with try-catch (bzr r11950.1.115) --- src/ui/tool/node.cpp | 61 ++++++++++++++++++++++++++++++++-------- src/ui/tool/path-manipulator.cpp | 2 +- src/ui/tool/path-manipulator.h | 2 +- 3 files changed, 51 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 5362a6c45..89a0f4163 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -175,10 +175,25 @@ void Handle::move(Geom::Point const &new_pos) //BSpline if(_pm().isBSpline){ h = this; + setPosition(_pm().BSplineHandleReposition(h)); _parent->bsplineWeight = _pm().BSplineHandlePosition(h); - setPosition(_pm().BSplineHandleReposition(h,_parent->bsplineWeight)); - h2 = this->other(); - this->other()->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); + typedef ControlPointSelection::Set Set; + Set &nodes = _parent->_selection.allPoints(); + for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { + if((*i)->selected()){ + Node *n = static_cast(*i); + h = n->front(); + h2 = n->back(); + h->setPosition(_pm().BSplineHandleReposition(h,_parent->bsplineWeight)); + h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); + } + } + if(!_parent->selected()){ + h = _parent->front(); + h2 = _parent->back(); + h->setPosition(_pm().BSplineHandleReposition(h,_parent->bsplineWeight)); + h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); + } } //BSpline End return; @@ -192,6 +207,30 @@ void Handle::move(Geom::Point const &new_pos) Geom::Point new_delta = (Geom::dot(delta, direction) / Geom::L2sq(direction)) * direction; setRelativePos(new_delta); + //BSpline + if(_pm().isBSpline){ + h = this; + setPosition(_pm().BSplineHandleReposition(h)); + _parent->bsplineWeight = _pm().BSplineHandlePosition(h); + typedef ControlPointSelection::Set Set; + Set &nodes = _parent->_selection.allPoints(); + for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { + if((*i)->selected()){ + Node *n = static_cast(*i); + h = n->front(); + h2 = n->back(); + h->setPosition(_pm().BSplineHandleReposition(h,_parent->bsplineWeight)); + h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); + } + } + if(!_parent->selected()){ + h = _parent->front(); + h2 = _parent->back(); + h->setPosition(_pm().BSplineHandleReposition(h,_parent->bsplineWeight)); + h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); + } + } + //BSpline End return; } @@ -227,6 +266,12 @@ void Handle::move(Geom::Point const &new_pos) h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); } } + if(!_parent->selected()){ + h = _parent->front(); + h2 = _parent->back(); + h->setPosition(_pm().BSplineHandleReposition(h,_parent->bsplineWeight)); + h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); + } } //BSpline End } @@ -779,14 +824,6 @@ void Node::setType(NodeType type, bool update_handles) updateState(); // The size of the control might have changed return; } - //BSpline - bool isBSpline = false; - try { - isBSpline = nodeList().subpathList().pm().isBSpline; - } - catch( char * str ) { - } - //BSpline End // if update_handles is true, adjust handle positions to match the node type // handle degenerate handles appropriately if (update_handles) { @@ -870,7 +907,7 @@ void Node::setType(NodeType type, bool update_handles) default: break; } //BSpline - if(isBSpline){ + if(_pm().isBSpline){ Handle* front = &_front; Handle* back = &_back; this->bsplineWeight = _pm().BSplineHandlePosition(front); diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index cad794860..7785dd685 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -110,6 +110,7 @@ void build_segment(Geom::PathBuilder &, Node *, Node *); PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, Geom::Affine const &et, guint32 outline_color, Glib::ustring lpe_key) : PointManipulator(mpm._path_data.node_data.desktop, *mpm._path_data.node_data.selection) + , isBSpline(true) , _subpaths(*this) , _multi_path_manipulator(mpm) , _path(path) @@ -157,7 +158,6 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, lpe_bsp = dynamic_cast(thisEffect->getLPEObj()->get_lpe()); } } - isBSpline = false; if(lpe_bsp){ isBSpline = true; } diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index 743d70b96..2fc0b90da 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -96,7 +96,7 @@ public: NodeList::iterator subdivideSegment(NodeList::iterator after, double t); NodeList::iterator extremeNode(NodeList::iterator origin, bool search_selected, - bool search_unselected, bool closest); + bool search_unselected, bool closest); //BSpline bool isBSpline; int getSteps(); -- cgit v1.2.3 From 9291d4e3a3ad22bef4669b74568ee6d43ba74547 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 18 May 2013 10:38:35 +0200 Subject: Fix error with envelope lpe (bzr r11950.1.117) --- src/live_effects/effect.cpp | 2 +- src/ui/tool/path-manipulator.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 8bf8bab6c..b84403495 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -8,7 +8,7 @@ //#define LPE_ENABLE_TEST_EFFECTS #ifdef HAVE_CONFIG_H -#include "config.h" +# include "config.h" #endif // include effects: diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 7785dd685..eb60abe2a 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -152,7 +152,7 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, _createControlPointsFromGeometry(); //BSpline lpe_bsp = NULL; - if (SP_LPE_ITEM(_path) && sp_lpe_item_has_path_effect(SP_LPE_ITEM(_path))){ + if (SP_IS_LPE_ITEM(_path) && sp_lpe_item_has_path_effect(SP_LPE_ITEM(_path))){ Inkscape::LivePathEffect::Effect* thisEffect = sp_lpe_item_has_path_effect_of_type(SP_LPE_ITEM(_path),Inkscape::LivePathEffect::BSPLINE); if(thisEffect){ lpe_bsp = dynamic_cast(thisEffect->getLPEObj()->get_lpe()); -- cgit v1.2.3 From d67294affd2f6b0f71c67b75cf521bfe308500f9 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 29 May 2013 01:33:43 +0200 Subject: Fixed a error that handles all kinds of pathas as bsplines (bzr r11950.1.119) --- src/ui/tool/path-manipulator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index eb60abe2a..ea007dfee 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -110,7 +110,7 @@ void build_segment(Geom::PathBuilder &, Node *, Node *); PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, Geom::Affine const &et, guint32 outline_color, Glib::ustring lpe_key) : PointManipulator(mpm._path_data.node_data.desktop, *mpm._path_data.node_data.selection) - , isBSpline(true) + , isBSpline(false) , _subpaths(*this) , _multi_path_manipulator(mpm) , _path(path) -- cgit v1.2.3 From 0bd0fa66b7825f0d4e0c9051aa527ba91e415683 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 19 Aug 2013 01:10:42 +0200 Subject: Reverted po files to master branch, now the diff of launchpad is more usable (bzr r11950.1.136) --- src/live_effects/lpe-bspline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index cc1b86e72..c2749e393 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -2,7 +2,7 @@ /* * Released under GNU GPL, read the file 'COPYING' for more information */ - + #include #include #include -- cgit v1.2.3 From 62ccb3999c5a5ec6f94de993d5b8a903f98adb5c Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 20 Sep 2013 02:29:43 +0200 Subject: Fixed ~sub advertising for a compile problem (bzr r11950.1.143) --- src/ui/tool/node-tool.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/ui/tool/node-tool.h b/src/ui/tool/node-tool.h index ce022cec6..4500c5de0 100644 --- a/src/ui/tool/node-tool.h +++ b/src/ui/tool/node-tool.h @@ -14,6 +14,7 @@ #include #include #include "event-context.h" +#include "selection.h" namespace Inkscape { namespace Display { -- cgit v1.2.3 From 987dd0e7eae4dded4049771af56b72889d05c461 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 26 Sep 2013 18:28:28 +0200 Subject: Compiling problem solved thaks to ~suv (bzr r11950.1.149) --- src/ui/tool/path-manipulator.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index e08a36e2e..dac67295a 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -152,12 +152,14 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, _createControlPointsFromGeometry(); //BSpline lpe_bsp = NULL; - if (SP_IS_LPE_ITEM(_path) && sp_lpe_item_has_path_effect(SP_LPE_ITEM(_path))){ - Inkscape::LivePathEffect::Effect* thisEffect = sp_lpe_item_has_path_effect_of_type(SP_LPE_ITEM(_path),Inkscape::LivePathEffect::BSPLINE); + + if (_path->hasPathEffect()){ + Inkscape::LivePathEffect::Effect* thisEffect = SP_LPE_ITEM(_path)->getPathEffectOfType(Inkscape::LivePathEffect::BSPLINE); if(thisEffect){ lpe_bsp = dynamic_cast(thisEffect->getLPEObj()->get_lpe()); } } + if(lpe_bsp){ isBSpline = true; } -- cgit v1.2.3 From 9737c8d04d0ad85bf6a61d36edf7d717419b30f2 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 27 Sep 2013 01:39:44 +0200 Subject: update to trunk (bzr r11950.1.152) --- src/live_effects/lpe-bendpath.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/live_effects/lpe-bendpath.h b/src/live_effects/lpe-bendpath.h index 16b8c6137..d3564bac4 100644 --- a/src/live_effects/lpe-bendpath.h +++ b/src/live_effects/lpe-bendpath.h @@ -39,9 +39,9 @@ public: virtual void resetDefaults(SPItem const* item); + PathParam bend_path; private: - PathParam bend_path; ScalarParam prop_scale; BoolParam scale_y_rel; BoolParam vertical_pattern; -- cgit v1.2.3 From f3a885546d1bd971c5bd4a6bbdbaedb59557007d Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 27 Sep 2013 01:42:10 +0200 Subject: error bend lpe (bzr r11950.1.153) --- src/live_effects/lpe-bendpath.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bendpath.h b/src/live_effects/lpe-bendpath.h index d3564bac4..38b1a1446 100644 --- a/src/live_effects/lpe-bendpath.h +++ b/src/live_effects/lpe-bendpath.h @@ -39,9 +39,8 @@ public: virtual void resetDefaults(SPItem const* item); - PathParam bend_path; - private: + PathParam bend_path; ScalarParam prop_scale; BoolParam scale_y_rel; BoolParam vertical_pattern; -- cgit v1.2.3 From debe6f792f37d4ca3acb297eea230503cc3522a4 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 27 Sep 2013 12:21:37 +0200 Subject: Fix editing paths in live effect (bzr r11950.1.154) --- src/ui/tool/path-manipulator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 1add4d176..3690efdad 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -153,7 +153,7 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, //BSpline lpe_bsp = NULL; - if (_path->hasPathEffect()){ + if (SP_IS_LPE_ITEM(_path) && _path->hasPathEffect()){ Inkscape::LivePathEffect::Effect* thisEffect = SP_LPE_ITEM(_path)->getPathEffectOfType(Inkscape::LivePathEffect::BSPLINE); if(thisEffect){ lpe_bsp = dynamic_cast(thisEffect->getLPEObj()->get_lpe()); -- cgit v1.2.3 From 514675a4b3eeb5835ad2466b692b3d00c6333c4a Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 30 Sep 2013 17:58:15 +0200 Subject: Fixed a bug editing paths in others LPE -envelope- (bzr r11950.1.157) --- src/ui/tool/path-manipulator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 3690efdad..910f75258 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1312,7 +1312,7 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) Geom::PathVector pathv = builder.peek() * (_edit_transform * _i2d_transform).inverse(); _spcurve->set_pathvector(pathv); if (alert_LPE) { - if (_path->hasPathEffect()) { + if (SP_IS_LPE_ITEM(_path) && _path->hasPathEffect()) { PathEffectList effect_list = sp_lpe_item_get_effect_list(_path); LivePathEffect::LPEPowerStroke *lpe_pwr = dynamic_cast( effect_list.front()->lpeobject->get_lpe() ); if (lpe_pwr) { -- cgit v1.2.3 From 5ef4eb74cfdec7aad437518db0ab99414bd3eae6 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 5 Oct 2013 23:20:25 +0200 Subject: Fix moving handles (bzr r11950.1.160) --- src/ui/tool/path-manipulator.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index f72313315..18ad45f72 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1268,10 +1268,12 @@ void PathManipulator::BSplineNodeHandlesReposition(Node *n){ nextPos = BSplineHandlePosition(nextNode->back()); n->front()->setPosition(BSplineHandleReposition(n->front())); n->back()->setPosition(BSplineHandleReposition(n->back())); - if(prevNode) + if(prevNode && !prevNode->isEndNode()) prevNode->front()->setPosition(BSplineHandleReposition(prevNode->front(),prevPos)); - if(nextNode) + prevNode->back()->setPosition(BSplineHandleReposition(prevNode->back(),prevPos)); + if(nextNode && !nextNode->isEndNode()) nextNode->back()->setPosition(BSplineHandleReposition(nextNode->back(),nextPos)); + nextNode->front()->setPosition(BSplineHandleReposition(nextNode->front(),prevPos)); } } -- cgit v1.2.3 From bc37c9b9c4663786b04a65ba6a27d55b2395eeb9 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 5 Oct 2013 23:56:02 +0200 Subject: fix whith bspline handles (bzr r11950.1.162) --- src/ui/tool/path-manipulator.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 18ad45f72..fd286873b 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1268,12 +1268,14 @@ void PathManipulator::BSplineNodeHandlesReposition(Node *n){ nextPos = BSplineHandlePosition(nextNode->back()); n->front()->setPosition(BSplineHandleReposition(n->front())); n->back()->setPosition(BSplineHandleReposition(n->back())); - if(prevNode && !prevNode->isEndNode()) + if(prevNode && !prevNode->isEndNode()){ prevNode->front()->setPosition(BSplineHandleReposition(prevNode->front(),prevPos)); prevNode->back()->setPosition(BSplineHandleReposition(prevNode->back(),prevPos)); - if(nextNode && !nextNode->isEndNode()) + } + if(nextNode && !nextNode->isEndNode()){ nextNode->back()->setPosition(BSplineHandleReposition(nextNode->back(),nextPos)); nextNode->front()->setPosition(BSplineHandleReposition(nextNode->front(),prevPos)); + } } } -- cgit v1.2.3 From cdc3d492add4c4bd63d96dcb53c406f9ef631ec9 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 6 Oct 2013 09:27:04 +0200 Subject: Fix in BSpline (bzr r11950.1.163) --- src/ui/tool/path-manipulator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index fd286873b..e9372aef3 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1274,7 +1274,7 @@ void PathManipulator::BSplineNodeHandlesReposition(Node *n){ } if(nextNode && !nextNode->isEndNode()){ nextNode->back()->setPosition(BSplineHandleReposition(nextNode->back(),nextPos)); - nextNode->front()->setPosition(BSplineHandleReposition(nextNode->front(),prevPos)); + nextNode->front()->setPosition(BSplineHandleReposition(nextNode->front(),nextPos)); } } } -- cgit v1.2.3 From 202528bb3f6f9e90b8651bb81bb017af46787933 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 6 Oct 2013 09:57:14 +0200 Subject: Fix in bsplines (bzr r11950.1.165) --- src/ui/tool/curve-drag-point.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/tool/curve-drag-point.cpp b/src/ui/tool/curve-drag-point.cpp index fce19f9ad..f4628fb8f 100644 --- a/src/ui/tool/curve-drag-point.cpp +++ b/src/ui/tool/curve-drag-point.cpp @@ -94,8 +94,8 @@ void CurveDragPoint::dragged(Geom::Point &new_pos, GdkEventMotion *event) if(!_pm.isBSpline){ first->front()->move(first->front()->position() + offset0); second->back()->move(second->back()->position() + offset1); - }else if(weight>=0.8)second->back()->move(new_pos); - else if(weight<=0.2)first->front()->move(new_pos); + }else if(weight>=0.8 && !second->isEndNode())second->back()->move(new_pos); + else if(weight<=0.2 && !first->isEndNode())first->front()->move(new_pos); //BSpline End _pm.update(); } -- cgit v1.2.3 From 3111608afecf747627810a6222cb7ca1eded6962 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 6 Oct 2013 12:18:59 +0200 Subject: UX improvements (bzr r11950.1.166) --- src/pen-context.cpp | 6 +++++- src/ui/tool/path-manipulator.cpp | 36 ++++++++++++++++++++---------------- 2 files changed, 25 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/pen-context.cpp b/src/pen-context.cpp index a9bd09c51..936afe4e0 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -1573,7 +1573,7 @@ static void bspline_spiro_motion(SPPenContext *const pc, bool shift){ using Geom::X; using Geom::Y; SPCurve *tmpCurve = new SPCurve(); - pc->p[2] = pc->p[3]; + pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); if(pc->green_curve->is_empty() && !pc->sa){ pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]); }else if(!pc->green_curve->is_empty()){ @@ -1601,6 +1601,10 @@ static void bspline_spiro_motion(SPPenContext *const pc, bool shift){ pc->p[1] = SBasisWPower.valueAt(WP); if(!Geom::are_near(pc->p[1],pc->p[0])) pc->p[1] = Geom::Point(pc->p[1][X] + 0.0001,pc->p[1][Y] + 0.0001); + if(shift) + pc->p[2]=pc->p[3]; + else + pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); }else{ pc->p[1] = (*cubic)[3] + (Geom::Point)((*cubic)[3] - (*cubic)[2] ); } diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index e9372aef3..809d2628f 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -683,7 +683,7 @@ unsigned PathManipulator::_deleteStretch(NodeList::iterator start, NodeList::ite } //BSpline if(isBSpline){ - double pos = 0; + double pos = 0.0000; if(start.prev()){ pos = BSplineHandlePosition(start.prev()->back()); start.prev()->front()->setPosition(BSplineHandleReposition(start.prev()->front(),pos)); @@ -1215,8 +1215,7 @@ double PathManipulator::BSplineHandlePosition(Handle *h){ Node *n = h->parent(); SPCurve *lineInsideNodes = new SPCurve(); Node * nextNode = NULL; - if(!n->isEndNode()) - nextNode = n->nodeToward(h); + nextNode = n->nodeToward(h); Geom::Point positionH = h->position(); positionH = Geom::Point(positionH[X] + 0.0001,positionH[Y] + 0.0001); if(nextNode && n->position() != h->position()){ @@ -1235,13 +1234,12 @@ Geom::Point PathManipulator::BSplineHandleReposition(Handle *h){ Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){ using Geom::X; using Geom::Y; - Geom::Point ret(0,0); + Geom::Point ret = h->position(); Node *n = h->parent(); Geom::D2< Geom::SBasis > SBasisInsideNodes; SPCurve *lineInsideNodes = new SPCurve(); Node * nextNode = NULL; - if(!n->isEndNode()) - nextNode = n->nodeToward(h); + nextNode = n->nodeToward(h); if(nextNode && pos != 0.0000){ lineInsideNodes->moveto(n->position()); lineInsideNodes->lineto(nextNode->position()); @@ -1250,8 +1248,10 @@ Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){ ret = SBasisInsideNodes.valueAt(pos); ret = Geom::Point(ret[X] + 0.0001,ret[Y] + 0.0001); }else{ - n->bsplineWeight = 0.0000; - ret = n->position(); + if(pos == 0.0000){ + n->bsplineWeight = 0.0000; + ret = n->position(); + } } return ret; } @@ -1262,19 +1262,23 @@ void PathManipulator::BSplineNodeHandlesReposition(Node *n){ Node * prevNode = n->nodeToward(n->back()); double prevPos = 0.0000; double nextPos = 0.0000; - if(prevNode) + if(prevNode){ prevPos = BSplineHandlePosition(prevNode->front()); - if(nextNode) + n->back()->setPosition(BSplineHandleReposition(n->back())); + } + if(nextNode){ nextPos = BSplineHandlePosition(nextNode->back()); - n->front()->setPosition(BSplineHandleReposition(n->front())); - n->back()->setPosition(BSplineHandleReposition(n->back())); - if(prevNode && !prevNode->isEndNode()){ + n->front()->setPosition(BSplineHandleReposition(n->front())); + } + if(prevNode){ + if(!prevNode->isEndNode()) + prevNode->back()->setPosition(BSplineHandleReposition(prevNode->back(),prevPos)); prevNode->front()->setPosition(BSplineHandleReposition(prevNode->front(),prevPos)); - prevNode->back()->setPosition(BSplineHandleReposition(prevNode->back(),prevPos)); } - if(nextNode && !nextNode->isEndNode()){ + if(nextNode){ + if(!nextNode->isEndNode()) + nextNode->front()->setPosition(BSplineHandleReposition(nextNode->front(),nextPos)); nextNode->back()->setPosition(BSplineHandleReposition(nextNode->back(),nextPos)); - nextNode->front()->setPosition(BSplineHandleReposition(nextNode->front(),nextPos)); } } } -- cgit v1.2.3 From e8e2929ccb133b015db1de73de0efbb982d455a4 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 7 Oct 2013 00:36:15 +0200 Subject: Fix bspline and strip multi node bspline power editing whith node tool because UX (bzr r11950.1.168) --- src/ui/tool/node.cpp | 102 +++++++++++++++++++++++++-------------------------- 1 file changed, 51 insertions(+), 51 deletions(-) (limited to 'src') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 5f5757a14..1151dc41b 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -176,23 +176,23 @@ void Handle::move(Geom::Point const &new_pos) h = this; setPosition(_pm().BSplineHandleReposition(h)); _parent->bsplineWeight = _pm().BSplineHandlePosition(h); - typedef ControlPointSelection::Set Set; - Set &nodes = _parent->_selection.allPoints(); - for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { - if((*i)->selected()){ - Node *n = static_cast(*i); - h = n->front(); - h2 = n->back(); - h->setPosition(_pm().BSplineHandleReposition(h,_parent->bsplineWeight)); - h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); - } - } - if(!_parent->selected()){ - h = _parent->front(); - h2 = _parent->back(); - h->setPosition(_pm().BSplineHandleReposition(h,_parent->bsplineWeight)); - h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); - } + //typedef ControlPointSelection::Set Set; + //Set &nodes = _parent->_selection.allPoints(); + //for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { + // if((*i)->selected()){ + // Node *n = static_cast(*i); + // h = n->front(); + // h2 = n->back(); + // h->setPosition(_pm().BSplineHandleReposition(h,_parent->bsplineWeight)); + // h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); + //} + //} + //if(!_parent->selected()){ + h = _parent->front(); + h2 = _parent->back(); + h->setPosition(_pm().BSplineHandleReposition(h,_parent->bsplineWeight)); + h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); + //} } //BSpline End return; @@ -211,23 +211,23 @@ void Handle::move(Geom::Point const &new_pos) h = this; setPosition(_pm().BSplineHandleReposition(h)); _parent->bsplineWeight = _pm().BSplineHandlePosition(h); - typedef ControlPointSelection::Set Set; - Set &nodes = _parent->_selection.allPoints(); - for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { - if((*i)->selected()){ - Node *n = static_cast(*i); - h = n->front(); - h2 = n->back(); - h->setPosition(_pm().BSplineHandleReposition(h,_parent->bsplineWeight)); - h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); - } - } - if(!_parent->selected()){ - h = _parent->front(); - h2 = _parent->back(); - h->setPosition(_pm().BSplineHandleReposition(h,_parent->bsplineWeight)); - h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); - } + //typedef ControlPointSelection::Set Set; + //Set &nodes = _parent->_selection.allPoints(); + //for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { + // if((*i)->selected()){ + // Node *n = static_cast(*i); + // h = n->front(); + // h2 = n->back(); + // h->setPosition(_pm().BSplineHandleReposition(h,_parent->bsplineWeight)); + // h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); + // } + //} + //if(!_parent->selected()){ + h = _parent->front(); + h2 = _parent->back(); + h->setPosition(_pm().BSplineHandleReposition(h,_parent->bsplineWeight)); + h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); + //} } //BSpline End return; @@ -254,23 +254,23 @@ void Handle::move(Geom::Point const &new_pos) h = this; setPosition(_pm().BSplineHandleReposition(h)); _parent->bsplineWeight = _pm().BSplineHandlePosition(h); - typedef ControlPointSelection::Set Set; - Set &nodes = _parent->_selection.allPoints(); - for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { - if((*i)->selected()){ - Node *n = static_cast(*i); - h = n->front(); - h2 = n->back(); - h->setPosition(_pm().BSplineHandleReposition(h,_parent->bsplineWeight)); - h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); - } - } - if(!_parent->selected()){ - h = _parent->front(); - h2 = _parent->back(); - h->setPosition(_pm().BSplineHandleReposition(h,_parent->bsplineWeight)); - h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); - } + //typedef ControlPointSelection::Set Set; + //Set &nodes = _parent->_selection.allPoints(); + //for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { + // if((*i)->selected()){ + // Node *n = static_cast(*i); + // h = n->front(); + // h2 = n->back(); + // h->setPosition(_pm().BSplineHandleReposition(h,_parent->bsplineWeight)); + // h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); + // } + //} + //if(!_parent->selected()){ + h = _parent->front(); + h2 = _parent->back(); + h->setPosition(_pm().BSplineHandleReposition(h,_parent->bsplineWeight)); + h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); + //} } //BSpline End } -- cgit v1.2.3 From f26927f8891498ca9466ea865f17a790b73ccff6 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 7 Oct 2013 01:39:48 +0200 Subject: Fix scaling handles (bzr r11950.1.170) --- src/ui/tool/path-manipulator.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 809d2628f..620c52e34 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1213,12 +1213,12 @@ double PathManipulator::BSplineHandlePosition(Handle *h){ using Geom::Y; double pos = 0.0000; Node *n = h->parent(); - SPCurve *lineInsideNodes = new SPCurve(); Node * nextNode = NULL; nextNode = n->nodeToward(h); Geom::Point positionH = h->position(); positionH = Geom::Point(positionH[X] + 0.0001,positionH[Y] + 0.0001); if(nextNode && n->position() != h->position()){ + SPCurve *lineInsideNodes = new SPCurve(); lineInsideNodes->moveto(n->position()); lineInsideNodes->lineto(nextNode->position()); pos = Geom::nearest_point(positionH,*lineInsideNodes->first_segment()); @@ -1263,11 +1263,11 @@ void PathManipulator::BSplineNodeHandlesReposition(Node *n){ double prevPos = 0.0000; double nextPos = 0.0000; if(prevNode){ - prevPos = BSplineHandlePosition(prevNode->front()); + prevPos = BSplineHandlePosition(prevNode->front(),prevNode->bsplineWeight); n->back()->setPosition(BSplineHandleReposition(n->back())); } if(nextNode){ - nextPos = BSplineHandlePosition(nextNode->back()); + nextPos = BSplineHandlePosition(nextNode->back(),nextNode->bsplineWeight); n->front()->setPosition(BSplineHandleReposition(n->front())); } if(prevNode){ -- cgit v1.2.3 From c2d73f1a14e1d461553465892bc9a3767313878a Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 7 Oct 2013 01:54:04 +0200 Subject: Fix scaling handles (bzr r11950.1.171) --- src/ui/tool/path-manipulator.cpp | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 620c52e34..27def4cb1 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1257,29 +1257,19 @@ Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){ } void PathManipulator::BSplineNodeHandlesReposition(Node *n){ - if(n->selected()){ - Node * nextNode = n->nodeToward(n->front()); - Node * prevNode = n->nodeToward(n->back()); - double prevPos = 0.0000; - double nextPos = 0.0000; - if(prevNode){ - prevPos = BSplineHandlePosition(prevNode->front(),prevNode->bsplineWeight); - n->back()->setPosition(BSplineHandleReposition(n->back())); - } - if(nextNode){ - nextPos = BSplineHandlePosition(nextNode->back(),nextNode->bsplineWeight); - n->front()->setPosition(BSplineHandleReposition(n->front())); - } - if(prevNode){ - if(!prevNode->isEndNode()) - prevNode->back()->setPosition(BSplineHandleReposition(prevNode->back(),prevPos)); - prevNode->front()->setPosition(BSplineHandleReposition(prevNode->front(),prevPos)); - } - if(nextNode){ - if(!nextNode->isEndNode()) - nextNode->front()->setPosition(BSplineHandleReposition(nextNode->front(),nextPos)); - nextNode->back()->setPosition(BSplineHandleReposition(nextNode->back(),nextPos)); - } + Node * nextNode = n->nodeToward(n->front()); + Node * prevNode = n->nodeToward(n->back()); + if(prevNode){ + n->back()->setPosition(BSplineHandleReposition(n->back())); + if(!prevNode->isEndNode()) + prevNode->back()->setPosition(BSplineHandleReposition(prevNode->back(),prevNode->bsplineWeight)); + prevNode->front()->setPosition(BSplineHandleReposition(prevNode->front(),prevNode->bsplineWeight)); + } + if(nextNode){ + n->front()->setPosition(BSplineHandleReposition(n->front())); + if(!nextNode->isEndNode()) + nextNode->front()->setPosition(BSplineHandleReposition(nextNode->front(),nextNode->bsplineWeight)); + nextNode->back()->setPosition(BSplineHandleReposition(nextNode->back(),nextNode->bsplineWeight)); } } -- cgit v1.2.3 From 6255e3bc1ad8c5c3824483e55e6f3c9de6941e5f Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 7 Oct 2013 15:42:58 +0200 Subject: fix in nodes (bzr r11950.1.172) --- src/ui/tool/node.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 1151dc41b..7506a54a8 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -635,6 +635,8 @@ Node::Node(NodeSharedData const &data, Geom::Point const &initial_pos) : _handles_shown(false) { this->bsplineWeight = 0.3334; + if(_front->position() == this->position() && _back->position() == this->position()) + this->bsplineWeight = 0.0000; // NOTE we do not set type here, because the handles are still degenerate } -- cgit v1.2.3 From 0eb0148cade3cc19d1cf85fadd5928c8c8ee1674 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 7 Oct 2013 15:47:51 +0200 Subject: update to trunk (bzr r11950.1.173) --- src/ui/tool/node.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 7506a54a8..c5ab2f316 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -635,7 +635,7 @@ Node::Node(NodeSharedData const &data, Geom::Point const &initial_pos) : _handles_shown(false) { this->bsplineWeight = 0.3334; - if(_front->position() == this->position() && _back->position() == this->position()) + if(this->front()->position() == this->position() && this->back()->position() == this->position()) this->bsplineWeight = 0.0000; // NOTE we do not set type here, because the handles are still degenerate } -- cgit v1.2.3 From f238a7004752e4e56b7e6d602f675c97c0ce4733 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 7 Oct 2013 17:09:32 +0200 Subject: Fixing BSplines (bzr r11950.1.174) --- src/ui/tool/node.cpp | 1 + src/ui/tool/path-manipulator.cpp | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index c5ab2f316..c6d4537dd 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -726,6 +726,7 @@ void Node::transform(Geom::Affine const &m) /* Affine transforms keep handle invariants for smooth and symmetric nodes, * but smooth nodes at ends of linear segments and auto nodes need special treatment */ _fixNeighbors(old_pos, position()); + _pm().BSplineNodeHandlesReposition(this); } Geom::Rect Node::bounds() const diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 27def4cb1..b90fa4ac7 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1261,12 +1261,16 @@ void PathManipulator::BSplineNodeHandlesReposition(Node *n){ Node * prevNode = n->nodeToward(n->back()); if(prevNode){ n->back()->setPosition(BSplineHandleReposition(n->back())); + if(prevNode->front()->position() == prevNode->position()) + prevNode->bsplineWeight = 0.000; if(!prevNode->isEndNode()) prevNode->back()->setPosition(BSplineHandleReposition(prevNode->back(),prevNode->bsplineWeight)); prevNode->front()->setPosition(BSplineHandleReposition(prevNode->front(),prevNode->bsplineWeight)); } if(nextNode){ n->front()->setPosition(BSplineHandleReposition(n->front())); + if(nextNode->front()->position() == nextNode->position()) + nextNode->bsplineWeight = 0.000; if(!nextNode->isEndNode()) nextNode->front()->setPosition(BSplineHandleReposition(nextNode->front(),nextNode->bsplineWeight)); nextNode->back()->setPosition(BSplineHandleReposition(nextNode->back(),nextNode->bsplineWeight)); @@ -1287,14 +1291,14 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) continue; } NodeList::iterator prev = subpath->begin(); - if(isBSpline){ - BSplineNodeHandlesReposition(prev.ptr()); - } + //if(isBSpline){ + // BSplineNodeHandlesReposition(prev.ptr()); + //} builder.moveTo(prev->position()); for (NodeList::iterator i = ++subpath->begin(); i != subpath->end(); ++i) { - if(isBSpline){ - BSplineNodeHandlesReposition(i.ptr()); - } + //if(isBSpline){ + // BSplineNodeHandlesReposition(i.ptr()); + //} build_segment(builder, prev.ptr(), i.ptr()); prev = i; } -- cgit v1.2.3 From 46699ed807e748453d6aaa054f87c0582c38d72e Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 7 Oct 2013 17:24:27 +0200 Subject: fix bsplines (bzr r11950.1.175) --- src/ui/tool/node.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index c6d4537dd..cbfd3ec0d 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -635,8 +635,6 @@ Node::Node(NodeSharedData const &data, Geom::Point const &initial_pos) : _handles_shown(false) { this->bsplineWeight = 0.3334; - if(this->front()->position() == this->position() && this->back()->position() == this->position()) - this->bsplineWeight = 0.0000; // NOTE we do not set type here, because the handles are still degenerate } -- cgit v1.2.3 From a4dcddb133064faf3f24f8f1a3f664f4d3d700b9 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 7 Oct 2013 17:46:13 +0200 Subject: fix bsplines (bzr r11950.1.176) --- src/ui/tool/node.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index cbfd3ec0d..f6d100b57 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -724,7 +724,10 @@ void Node::transform(Geom::Affine const &m) /* Affine transforms keep handle invariants for smooth and symmetric nodes, * but smooth nodes at ends of linear segments and auto nodes need special treatment */ _fixNeighbors(old_pos, position()); - _pm().BSplineNodeHandlesReposition(this); + if(_pm().isBSpline){ + this->front().setPosition(BSplineHandleReposition(this->front(),this->bsplineWeight)); + this->back().setPosition(BSplineHandleReposition(this->back(),this->bsplineWeight)); + } } Geom::Rect Node::bounds() const -- cgit v1.2.3 From db5de41dd8f09821561a14db45192a76479e2536 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 7 Oct 2013 17:50:52 +0200 Subject: fix bsplines (bzr r11950.1.177) --- src/ui/tool/node.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index f6d100b57..91f8e8a54 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -725,8 +725,8 @@ void Node::transform(Geom::Affine const &m) * but smooth nodes at ends of linear segments and auto nodes need special treatment */ _fixNeighbors(old_pos, position()); if(_pm().isBSpline){ - this->front().setPosition(BSplineHandleReposition(this->front(),this->bsplineWeight)); - this->back().setPosition(BSplineHandleReposition(this->back(),this->bsplineWeight)); + _front.setPosition(BSplineHandleReposition(_front,this->bsplineWeight)); + _back.setPosition(BSplineHandleReposition(_back,this->bsplineWeight)); } } -- cgit v1.2.3 From c868eae8e1cc980621791d982c519fc14139f906 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 7 Oct 2013 17:56:26 +0200 Subject: fix bsplines (bzr r11950.1.178) --- src/ui/tool/node.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 91f8e8a54..933bfe0ca 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -725,8 +725,8 @@ void Node::transform(Geom::Affine const &m) * but smooth nodes at ends of linear segments and auto nodes need special treatment */ _fixNeighbors(old_pos, position()); if(_pm().isBSpline){ - _front.setPosition(BSplineHandleReposition(_front,this->bsplineWeight)); - _back.setPosition(BSplineHandleReposition(_back,this->bsplineWeight)); + _front.setPosition(_pm().BSplineHandleReposition(_front,this->bsplineWeight)); + _back.setPosition(_pm().BSplineHandleReposition(_back,this->bsplineWeight)); } } -- cgit v1.2.3 From bae8160a80e84129b87846e09dee0a0aa0c08e0e Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 7 Oct 2013 18:52:27 +0200 Subject: fix bsplines (bzr r11950.1.179) --- src/ui/tool/node.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 933bfe0ca..8564f1f1a 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -725,8 +725,9 @@ void Node::transform(Geom::Affine const &m) * but smooth nodes at ends of linear segments and auto nodes need special treatment */ _fixNeighbors(old_pos, position()); if(_pm().isBSpline){ - _front.setPosition(_pm().BSplineHandleReposition(_front,this->bsplineWeight)); - _back.setPosition(_pm().BSplineHandleReposition(_back,this->bsplineWeight)); + _front.setPosition(_pm().BSplineHandleReposition(this->front(),this->bsplineWeight)); + _back.setPosition(_pm().BSplineHandleReposition(this->back(),this->bsplineWeight)); + _pm().BSplineNodeHandlesReposition(this); } } -- cgit v1.2.3 From 0aa9ccce32f60c55b35348fe14da33950ca4517f Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 16 Oct 2013 11:39:52 +0200 Subject: Update motion redraw of bsplines (bzr r11950.1.183) --- src/pen-context.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 0d4b5df7e..e251c1125 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -733,10 +733,15 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons } //BSpline //Lanzamos la función "bspline_spiro_motion" al moverse el ratón o cuando se para. - if ( Geom::LInfty( event_w - pen_drag_origin_w ) > tolerance || mevent.time == 0) { + if(pc->bspline){ bspline_spiro_color(pc); bspline_spiro_motion(pc,(mevent.state & GDK_SHIFT_MASK)); - pen_drag_origin_w = event_w; + }else{ + if ( Geom::LInfty( event_w - pen_drag_origin_w ) > tolerance || mevent.time == 0) { + bspline_spiro_color(pc); + bspline_spiro_motion(pc,(mevent.state & GDK_SHIFT_MASK)); + pen_drag_origin_w = event_w; + } } //BSpline End return ret; -- cgit v1.2.3 From cdf6320ab752de234f986031bfdd7dcb8e705e69 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 8 Nov 2013 10:13:22 +0100 Subject: Fixing bugs on update to trunk (bzr r11950.1.194) --- src/live_effects/lpe-bspline.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 84f3fbb33..ef03d8ef0 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -335,7 +335,7 @@ LPEBSpline::changeWeight(double weightValue) gchar *str = sp_svg_write_path(curve->get_pathvector()); path->getRepr()->setAttribute("inkscape:original-d", str); if(INK_IS_NODE_TOOL(desktop->event_context)){ - InkNodeTool *nt = INK_NODE_TOOL(desktop->event_context); + Inkscape::UI::Tools::NodeTool *nt = INK_NODE_TOOL(desktop->event_context); nt->desktop->updateNow(); } g_free(str); @@ -367,7 +367,7 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) using Geom::Y; SPDesktop *desktop = inkscape_active_desktop(); if(INK_IS_NODE_TOOL(desktop->event_context)){ - InkNodeTool *nt = INK_NODE_TOOL(desktop->event_context); + Inkscape::UI::Tools::NodeTool *nt = INK_NODE_TOOL(desktop->event_context); Inkscape::UI::ControlPointSelection::Set &selection = nt->_selected_nodes->allPoints(); points.clear(); std::vector::iterator pbegin; -- cgit v1.2.3 From 3ed9b4ff7ebbae3ba6446d911001688bcbbdc847 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 10 Nov 2013 12:17:23 +0100 Subject: Update to trunk (bzr r11950.1.196) --- src/live_effects/lpe-bspline.cpp | 2 +- src/ui/tools/node-tool.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index ef03d8ef0..c19eda8f0 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -17,7 +17,7 @@ #include "live_effects/parameter/parameter.h" #include "ui/widget/scalar.h" #include "ui/tool/node.h" -#include "ui/tool/node-tool.h" +#include "ui/tools/node-tool.h" #include "ui/tool/control-point-selection.h" #include "ui/tool/selectable-control-point.h" #include "selection.h" diff --git a/src/ui/tools/node-tool.h b/src/ui/tools/node-tool.h index 4d15ab70e..b3acb79ad 100644 --- a/src/ui/tools/node-tool.h +++ b/src/ui/tools/node-tool.h @@ -14,6 +14,7 @@ #include #include #include "ui/tools/tool-base.h" +#include "selection.h" namespace Inkscape { namespace Display { -- cgit v1.2.3 From ebc5ac2b758155192114ea1bec8b3d32820a18d3 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 3 Dec 2013 16:55:14 +0100 Subject: Fix a bug delete BSpline LPE from a path retain some BSpline properties (bzr r11950.1.206) --- src/ui/tool/node.cpp | 63 +++++++++++++++++++++------------------- src/ui/tool/path-manipulator.cpp | 52 +++++++++++++++++++-------------- src/ui/tool/path-manipulator.h | 16 +++++----- 3 files changed, 72 insertions(+), 59 deletions(-) (limited to 'src') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 230d39e2e..af823a787 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -28,9 +28,9 @@ #include "ui/tool/node.h" #include "ui/tool/path-manipulator.h" #include -//BSpline + #include -//BSpline End; +; namespace { @@ -137,10 +137,10 @@ void Handle::move(Geom::Point const &new_pos) Node *node_away = _parent->nodeAwayFrom(this); // node in the opposite direction Handle *towards = node_towards ? node_towards->handleAwayFrom(_parent) : NULL; Handle *towards_second = node_towards ? node_towards->handleToward(_parent) : NULL; - //BSpline + Handle *h = NULL; Handle *h2 = NULL; - //BSpline End + _pm().BSpline(); if (Geom::are_near(new_pos, _parent->position())) { // The handle becomes degenerate. // Adjust node type as necessary. @@ -171,7 +171,7 @@ void Handle::move(Geom::Point const &new_pos) } } setPosition(new_pos); - //BSpline + if(_pm().isBSpline){ h = this; setPosition(_pm().BSplineHandleReposition(h)); @@ -194,7 +194,7 @@ void Handle::move(Geom::Point const &new_pos) h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); //} } - //BSpline End + return; } @@ -206,7 +206,7 @@ void Handle::move(Geom::Point const &new_pos) Geom::Point new_delta = (Geom::dot(delta, direction) / Geom::L2sq(direction)) * direction; setRelativePos(new_delta); - //BSpline + if(_pm().isBSpline){ h = this; setPosition(_pm().BSplineHandleReposition(h)); @@ -229,7 +229,7 @@ void Handle::move(Geom::Point const &new_pos) h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); //} } - //BSpline End + return; } @@ -249,7 +249,7 @@ void Handle::move(Geom::Point const &new_pos) default: break; } setPosition(new_pos); - //BSpline + if(_pm().isBSpline){ h = this; setPosition(_pm().BSplineHandleReposition(h)); @@ -272,7 +272,7 @@ void Handle::move(Geom::Point const &new_pos) h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); //} } - //BSpline End + } void Handle::setPosition(Geom::Point const &p) @@ -349,19 +349,20 @@ bool Handle::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEven break; default: break; } - //BSpline + case GDK_2BUTTON_PRESS: handle_2button_press(); break; - //BSpline End + default: break; } return ControlPoint::_eventHandler(event_context, event); } -//BSpline + void Handle::handle_2button_press(){ + _pm().BSpline(); if(_pm().isBSpline){ Handle *h = NULL; Handle *h2 = NULL; @@ -374,7 +375,7 @@ void Handle::handle_2button_press(){ _pm().update(); } } -//BSpline End + bool Handle::grabbed(GdkEventMotion *) { @@ -392,7 +393,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) SnapManager &sm = _desktop->namedview->snap_manager; bool snap = held_shift(*event) ? false : sm.someSnapperMightSnap(); boost::optional ctrl_constraint; - + _pm().BSpline(); // with Alt, preserve length if (held_alt(*event)) { new_pos = parent_pos + Geom::unit_vector(new_pos - parent_pos) * _saved_length; @@ -424,17 +425,17 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) ctrl_constraint = Inkscape::Snapper::SnapConstraint(parent_pos, parent_pos - perp_pos); } new_pos = result; - //BSpline + if(_pm().isBSpline){ Handle *h = NULL; _parent->bsplineWeight = 0.0000; h = this; setPosition(new_pos); - int steps = _pm().getSteps(); + int steps = _pm().BSplineGetSteps(); _parent->bsplineWeight = ceilf(_pm().BSplineHandlePosition(h)*steps)/steps; new_pos=_pm().BSplineHandleReposition(h,_parent->bsplineWeight); } - //BSpline End + } std::vector unselected; @@ -464,7 +465,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) sm.freeSnapReturnByRef(new_pos, SNAPSOURCE_NODE_HANDLE); } sm.unSetup(); - //BSpline + if(_pm().isBSpline){ Handle *h = NULL; _parent->bsplineWeight = 0.0000; @@ -473,7 +474,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) _parent->bsplineWeight = _pm().BSplineHandlePosition(h); new_pos=_pm().BSplineHandleReposition(h,_parent->bsplineWeight); } - //BSpline End + } @@ -674,9 +675,10 @@ void Node::move(Geom::Point const &new_pos) // move handles when the node moves. Geom::Point old_pos = position(); Geom::Point delta = new_pos - position(); - //BSpline + double prevPos = 0.0000; double nextPos = 0.0000; + _pm().BSpline(); Node *n = this; Node * nextNode = n->nodeToward(n->front()); Node * prevNode = n->nodeToward(n->back()); @@ -689,23 +691,23 @@ void Node::move(Geom::Point const &new_pos) if(nextNode) nextPos = _pm().BSplineHandlePosition(nextNode->back()); } - //BSpline End + setPosition(new_pos); - //BSpline + if(_pm().isBSpline){ if(prevNode) prevNode->front()->setPosition(_pm().BSplineHandleReposition(prevNode->front(),prevPos)); if(nextNode) nextNode->back()->setPosition(_pm().BSplineHandleReposition(nextNode->back(),nextPos)); } - //BSpline End + _front.setPosition(_front.position() + delta); _back.setPosition(_back.position() + delta); - //BSpline End + // if the node has a smooth handle after a line segment, it should be kept colinear // with the segment _fixNeighbors(old_pos, new_pos); - //BSpline + if(_pm().isBSpline){ Handle* front = &_front; Handle* back = &_back; @@ -724,6 +726,7 @@ void Node::transform(Geom::Affine const &m) /* Affine transforms keep handle invariants for smooth and symmetric nodes, * but smooth nodes at ends of linear segments and auto nodes need special treatment */ _fixNeighbors(old_pos, position()); + _pm().BSpline(); if(_pm().isBSpline){ _front.setPosition(_pm().BSplineHandleReposition(this->front(),this->bsplineWeight)); _back.setPosition(_pm().BSplineHandleReposition(this->back(),this->bsplineWeight)); @@ -914,7 +917,7 @@ void Node::setType(NodeType type, bool update_handles) break; default: break; } - //BSpline + _pm().BSpline(); if(_pm().isBSpline){ Handle* front = &_front; Handle* back = &_back; @@ -923,7 +926,7 @@ void Node::setType(NodeType type, bool update_handles) _front.setPosition(_pm().BSplineHandleReposition(front,this->bsplineWeight)); _back.setPosition(_pm().BSplineHandleReposition(back,this->bsplineWeight)); } - //BSpline End + } _type = type; _setControlType(nodeTypeToCtrlType(_type)); @@ -1170,12 +1173,12 @@ void Node::_setState(State state) case STATE_CLICKED: mgr.setActive(_canvas_item, true); mgr.setPrelight(_canvas_item, false); - //BSpline + _pm().BSpline(); if(_pm().isBSpline){ this->bsplineWeight = _pm().BSplineHandlePosition(this->back()); _pm().BSplineNodeHandlesReposition(this); } - //BSpline End + break; } SelectableControlPoint::_setState(state); diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index e66c6a899..fd421e587 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -43,9 +43,9 @@ #include "ui/tool/multi-path-manipulator.h" #include "xml/node.h" #include "xml/node-observer.h" -//BSpline + #include "live_effects/lpe-bspline.h" -//BSpline end + namespace Inkscape { namespace UI { @@ -150,20 +150,7 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, sigc::hide( sigc::mem_fun(*this, &PathManipulator::_updateOutlineOnZoomChange))); _createControlPointsFromGeometry(); - //BSpline - lpe_bsp = NULL; - - if (SP_IS_LPE_ITEM(_path) && _path->hasPathEffect()){ - Inkscape::LivePathEffect::Effect* thisEffect = SP_LPE_ITEM(_path)->getPathEffectOfType(Inkscape::LivePathEffect::BSPLINE); - if(thisEffect){ - lpe_bsp = dynamic_cast(thisEffect->getLPEObj()->get_lpe()); - } - } - - if(lpe_bsp){ - isBSpline = true; - } - //BSpline End + BSpline(); } PathManipulator::~PathManipulator() @@ -681,7 +668,7 @@ unsigned PathManipulator::_deleteStretch(NodeList::iterator start, NodeList::ite nl.erase(start); start = next; } - //BSpline + if(isBSpline){ double pos = 0.0000; if(start.prev()){ @@ -693,7 +680,7 @@ unsigned PathManipulator::_deleteStretch(NodeList::iterator start, NodeList::ite end->back()->setPosition(BSplineHandleReposition(end->back(),pos)); } } - //BSpline End + return del_len; } @@ -928,9 +915,9 @@ void PathManipulator::showHandles(bool show) /** Set the visibility of outline. */ void PathManipulator::showOutline(bool show) { - //BSpline + if(isBSpline) show = true; - //BSpline + if (show == _show_outline) return; _show_outline = show; _updateOutline(); @@ -1204,10 +1191,33 @@ void PathManipulator::_createControlPointsFromGeometry() } } -int PathManipulator::getSteps(){ +int PathManipulator::BSplineGetSteps(){ + LivePathEffect::LPEBSpline *lpe_bsp = NULL; + + if (SP_IS_LPE_ITEM(_path) && _path->hasPathEffect()){ + Inkscape::LivePathEffect::Effect* thisEffect = SP_LPE_ITEM(_path)->getPathEffectOfType(Inkscape::LivePathEffect::BSPLINE); + if(thisEffect){ + lpe_bsp = dynamic_cast(thisEffect->getLPEObj()->get_lpe()); + } + } return lpe_bsp->steps+1; } +void PathManipulator::BSpline(){ + LivePathEffect::LPEBSpline *lpe_bsp = NULL; + + if (SP_IS_LPE_ITEM(_path) && _path->hasPathEffect()){ + Inkscape::LivePathEffect::Effect* thisEffect = SP_LPE_ITEM(_path)->getPathEffectOfType(Inkscape::LivePathEffect::BSPLINE); + if(thisEffect){ + lpe_bsp = dynamic_cast(thisEffect->getLPEObj()->get_lpe()); + } + } + isBSpline = false; + if(lpe_bsp){ + isBSpline = true; + } +} + double PathManipulator::BSplineHandlePosition(Handle *h){ using Geom::X; using Geom::Y; diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index b40a479f7..2a59df464 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -19,9 +19,9 @@ #include #include "ui/tool/node.h" #include "ui/tool/manipulator.h" -//BSpline + #include "live_effects/lpe-bspline.h" -//BSpline end + struct SPCanvasItem; class SPCurve; @@ -97,10 +97,10 @@ public: NodeList::iterator subdivideSegment(NodeList::iterator after, double t); NodeList::iterator extremeNode(NodeList::iterator origin, bool search_selected, bool search_unselected, bool closest); - //BSpline + bool isBSpline; - int getSteps(); - //BSpline End + int BSplineGetSteps(); + // this is necessary for Tab-selection in MultiPathManipulator SubpathList &subpathList() { return _subpaths; } @@ -110,13 +110,13 @@ private: typedef boost::shared_ptr SubpathPtr; void _createControlPointsFromGeometry(); - //BSpline - LivePathEffect::LPEBSpline *lpe_bsp; + + void BSpline(); double BSplineHandlePosition(Handle *h); Geom::Point BSplineHandleReposition(Handle *h); Geom::Point BSplineHandleReposition(Handle *h,double pos); void BSplineNodeHandlesReposition(Node *n); - //BSpline End + void _createGeometryFromControlPoints(bool alert_LPE = false); unsigned _deleteStretch(NodeList::iterator first, NodeList::iterator last, bool keep_shape); std::string _createTypeString(); -- cgit v1.2.3 From fb006b59b6d7b6d059dffe3389a829d2213f648d Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 28 Dec 2013 23:34:45 +0100 Subject: Fix crash bug continuing empty paths (bzr r11950.1.210) --- src/ui/tools/pen-tool.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index ebbc533b8..178a940a2 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -1648,6 +1648,7 @@ static void bspline_spiro_end_anchor_on(PenTool *const pc) Geom::Point C(0,0); if(!pc->sa || pc->sa->curve->is_empty()){ tmpCurve = pc->green_curve->create_reverse(); + if(pc->green_curve->get_segment_count()==0)return; Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); if(pc->bspline){ C = tmpCurve->last_segment()->finalPoint() + (1./3)*(tmpCurve->last_segment()->initialPoint() - tmpCurve->last_segment()->finalPoint()); @@ -1715,6 +1716,7 @@ static void bspline_spiro_end_anchor_off(PenTool *const pc) SPCurve *lastSeg = new SPCurve(); if(!pc->sa || pc->sa->curve->is_empty()){ tmpCurve = pc->green_curve->create_reverse(); + if(pc->green_curve->get_segment_count()==0)return; Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); if(cubic){ lastSeg->moveto((*cubic)[0]); -- cgit v1.2.3 From 57865cd8a96b1b5c72f44c9b97d1a828caf09f95 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 30 Dec 2013 19:45:52 +0100 Subject: Refactorizing (bzr r11950.1.211) --- src/ui/tool/curve-drag-point.cpp | 6 +- src/ui/tool/node.cpp | 210 +++++++++++++++------------------------ src/ui/tool/path-manipulator.cpp | 7 +- src/ui/tool/path-manipulator.h | 2 +- 4 files changed, 82 insertions(+), 143 deletions(-) (limited to 'src') diff --git a/src/ui/tool/curve-drag-point.cpp b/src/ui/tool/curve-drag-point.cpp index c25fa2d52..f847a6ab3 100644 --- a/src/ui/tool/curve-drag-point.cpp +++ b/src/ui/tool/curve-drag-point.cpp @@ -90,13 +90,11 @@ void CurveDragPoint::dragged(Geom::Point &new_pos, GdkEventMotion *event) Geom::Point delta = new_pos - position(); Geom::Point offset0 = ((1-weight)/(3*t*(1-t)*(1-t))) * delta; Geom::Point offset1 = (weight/(3*t*t*(1-t))) * delta; - //BSpline if(!_pm.isBSpline){ first->front()->move(first->front()->position() + offset0); second->back()->move(second->back()->position() + offset1); - }else if(weight>=0.8 && !second->isEndNode())second->back()->move(new_pos); - else if(weight<=0.2 && !first->isEndNode())first->front()->move(new_pos); - //BSpline End + }else if(weight>=0.8 && !second->isEndNode() && held_shift(*event))second->back()->move(new_pos); + else if(weight<=0.2 && !first->isEndNode() && held_shift(*event))first->front()->move(new_pos); _pm.update(); } diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index af823a787..70e374424 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -138,9 +138,6 @@ void Handle::move(Geom::Point const &new_pos) Handle *towards = node_towards ? node_towards->handleAwayFrom(_parent) : NULL; Handle *towards_second = node_towards ? node_towards->handleToward(_parent) : NULL; - Handle *h = NULL; - Handle *h2 = NULL; - _pm().BSpline(); if (Geom::are_near(new_pos, _parent->position())) { // The handle becomes degenerate. // Adjust node type as necessary. @@ -171,30 +168,13 @@ void Handle::move(Geom::Point const &new_pos) } } setPosition(new_pos); - + + //If is bspline move other handle if(_pm().isBSpline){ - h = this; - setPosition(_pm().BSplineHandleReposition(h)); - _parent->bsplineWeight = _pm().BSplineHandlePosition(h); - //typedef ControlPointSelection::Set Set; - //Set &nodes = _parent->_selection.allPoints(); - //for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { - // if((*i)->selected()){ - // Node *n = static_cast(*i); - // h = n->front(); - // h2 = n->back(); - // h->setPosition(_pm().BSplineHandleReposition(h,_parent->bsplineWeight)); - // h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); - //} - //} - //if(!_parent->selected()){ - h = _parent->front(); - h2 = _parent->back(); - h->setPosition(_pm().BSplineHandleReposition(h,_parent->bsplineWeight)); - h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); - //} + setPosition(_pm().BSplineHandleReposition(this)); + _parent->bsplineWeight = _pm().BSplineHandlePosition(this); + this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),_parent->bsplineWeight)); } - return; } @@ -206,28 +186,12 @@ void Handle::move(Geom::Point const &new_pos) Geom::Point new_delta = (Geom::dot(delta, direction) / Geom::L2sq(direction)) * direction; setRelativePos(new_delta); - + + //If is bspline move both handles if(_pm().isBSpline){ - h = this; - setPosition(_pm().BSplineHandleReposition(h)); - _parent->bsplineWeight = _pm().BSplineHandlePosition(h); - //typedef ControlPointSelection::Set Set; - //Set &nodes = _parent->_selection.allPoints(); - //for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { - // if((*i)->selected()){ - // Node *n = static_cast(*i); - // h = n->front(); - // h2 = n->back(); - // h->setPosition(_pm().BSplineHandleReposition(h,_parent->bsplineWeight)); - // h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); - // } - //} - //if(!_parent->selected()){ - h = _parent->front(); - h2 = _parent->back(); - h->setPosition(_pm().BSplineHandleReposition(h,_parent->bsplineWeight)); - h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); - //} + setPosition(_pm().BSplineHandleReposition(this)); + _parent->bsplineWeight = _pm().BSplineHandlePosition(this); + this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),_parent->bsplineWeight)); } return; @@ -249,28 +213,12 @@ void Handle::move(Geom::Point const &new_pos) default: break; } setPosition(new_pos); - + + //If is bspline move other handle if(_pm().isBSpline){ - h = this; - setPosition(_pm().BSplineHandleReposition(h)); - _parent->bsplineWeight = _pm().BSplineHandlePosition(h); - //typedef ControlPointSelection::Set Set; - //Set &nodes = _parent->_selection.allPoints(); - //for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { - // if((*i)->selected()){ - // Node *n = static_cast(*i); - // h = n->front(); - // h2 = n->back(); - // h->setPosition(_pm().BSplineHandleReposition(h,_parent->bsplineWeight)); - // h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); - // } - //} - //if(!_parent->selected()){ - h = _parent->front(); - h2 = _parent->back(); - h->setPosition(_pm().BSplineHandleReposition(h,_parent->bsplineWeight)); - h2->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); - //} + setPosition(_pm().BSplineHandleReposition(this)); + _parent->bsplineWeight = _pm().BSplineHandlePosition(this); + this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),_parent->bsplineWeight)); } } @@ -362,16 +310,10 @@ bool Handle::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEven void Handle::handle_2button_press(){ - _pm().BSpline(); if(_pm().isBSpline){ - Handle *h = NULL; - Handle *h2 = NULL; - _parent->bsplineWeight = 0.0000; - h = this; - setPosition(_pm().BSplineHandleReposition(h,0.3334)); - _parent->bsplineWeight = _pm().BSplineHandlePosition(h); - h2 = this->other(); - this->other()->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); + setPosition(_pm().BSplineHandleReposition(this,0.3334)); + _parent->bsplineWeight = 0.3334; + this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),_parent->bsplineWeight)); _pm().update(); } } @@ -393,7 +335,6 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) SnapManager &sm = _desktop->namedview->snap_manager; bool snap = held_shift(*event) ? false : sm.someSnapperMightSnap(); boost::optional ctrl_constraint; - _pm().BSpline(); // with Alt, preserve length if (held_alt(*event)) { new_pos = parent_pos + Geom::unit_vector(new_pos - parent_pos) * _saved_length; @@ -427,19 +368,18 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) new_pos = result; if(_pm().isBSpline){ - Handle *h = NULL; - _parent->bsplineWeight = 0.0000; - h = this; setPosition(new_pos); int steps = _pm().BSplineGetSteps(); - _parent->bsplineWeight = ceilf(_pm().BSplineHandlePosition(h)*steps)/steps; - new_pos=_pm().BSplineHandleReposition(h,_parent->bsplineWeight); + _parent->bsplineWeight = ceilf(_pm().BSplineHandlePosition(this)*steps)/steps; + new_pos=_pm().BSplineHandleReposition(this,_parent->bsplineWeight); } } std::vector unselected; - if (snap && ( (!held_control(*event) && _pm().isBSpline) || !_pm().isBSpline)) { + + //IF Snap and Not CTRL && BSpline or BSPLINE is false + if (snap && (((!held_control(*event) && _pm().isBSpline) && (!held_shift(*event) && _pm().isBSpline)) || !_pm().isBSpline)) { ControlPointSelection::Set &nodes = _parent->_selection.allPoints(); for (ControlPointSelection::Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { Node *n = static_cast(*i); @@ -465,16 +405,11 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) sm.freeSnapReturnByRef(new_pos, SNAPSOURCE_NODE_HANDLE); } sm.unSetup(); - if(_pm().isBSpline){ - Handle *h = NULL; - _parent->bsplineWeight = 0.0000; - h = this; setPosition(new_pos); - _parent->bsplineWeight = _pm().BSplineHandlePosition(h); - new_pos=_pm().BSplineHandleReposition(h,_parent->bsplineWeight); + _parent->bsplineWeight = _pm().BSplineHandlePosition(this); + new_pos=_pm().BSplineHandleReposition(this,_parent->bsplineWeight); } - } @@ -489,6 +424,10 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) other()->setPosition(_saved_other_pos); } } + + if(_pm().isBSpline && !held_shift(*event) && !held_control(*event)){ + new_pos=_last_drag_origin(); + } move(new_pos); // needed for correct update, even though it's redundant _pm().update(); } @@ -505,7 +444,9 @@ void Handle::ungrabbed(GdkEventButton *event) Geom::Point dist = _desktop->d2w(_parent->position()) - _desktop->d2w(position()); if (dist.length() <= drag_tolerance) { move(_parent->position()); - _parent->bsplineWeight = 0.0000; + if(_pm().isBSpline){ + _parent->bsplineWeight = 0.0000; + } } } @@ -548,13 +489,18 @@ static double snap_increment_degrees() { Glib::ustring Handle::_getTip(unsigned state) const { char const *more; + bool isBSpline = false; + if( _parent->bsplineWeight != 0.0000) + isBSpline = true; bool can_shift_rotate = _parent->type() == NODE_CUSP && !other()->isDegenerate(); - if (can_shift_rotate) { + if (can_shift_rotate && !isBSpline) { more = C_("Path handle tip", "more: Shift, Ctrl, Alt"); - } else { + } else if(isBSpline){ + more = C_("Path handle tip", "move:Shift, reset:double click, more: Ctrl"); + }else { more = C_("Path handle tip", "more: Ctrl, Alt"); } - if (state_held_alt(state)) { + if (state_held_alt(state) && !isBSpline) { if (state_held_control(state)) { if (state_held_shift(state) && can_shift_rotate) { return format_tip(C_("Path handle tip", @@ -577,18 +523,24 @@ Glib::ustring Handle::_getTip(unsigned state) const } } else { if (state_held_control(state)) { - if (state_held_shift(state) && can_shift_rotate) { + if (state_held_shift(state) && can_shift_rotate && !isBSpline) { return format_tip(C_("Path handle tip", "Shift+Ctrl: snap rotation angle to %g° increments and rotate both handles"), snap_increment_degrees()); - } else { + } else if(isBSpline){ + return format_tip(C_("Path handle tip", + "Ctrl: Move handle by his actual steps in BSpline Live Effect")); + }else{ return format_tip(C_("Path handle tip", "Ctrl: snap rotation angle to %g° increments, click to retract"), snap_increment_degrees()); } - } else if (state_held_shift(state) && can_shift_rotate) { + } else if (state_held_shift(state) && can_shift_rotate && !isBSpline) { return C_("Path hande tip", "Shift: rotate both handles by the same angle"); + } else if(state_held_shift(state) && isBSpline){ + return C_("Path hande tip", + "Shift: move handle"); } } @@ -676,31 +628,14 @@ void Node::move(Geom::Point const &new_pos) Geom::Point old_pos = position(); Geom::Point delta = new_pos - position(); - double prevPos = 0.0000; - double nextPos = 0.0000; - _pm().BSpline(); + double oldPos = 0.0000; Node *n = this; - Node * nextNode = n->nodeToward(n->front()); - Node * prevNode = n->nodeToward(n->back()); if(_pm().isBSpline){ - if(prevNode) - prevPos = _pm().BSplineHandlePosition(prevNode->front()); - n->bsplineWeight = _pm().BSplineHandlePosition(n->front()); - if(n->bsplineWeight == 0.0000) - n->bsplineWeight = _pm().BSplineHandlePosition(n->back()); - if(nextNode) - nextPos = _pm().BSplineHandlePosition(nextNode->back()); + oldPos = n->bsplineWeight; } setPosition(new_pos); - - if(_pm().isBSpline){ - if(prevNode) - prevNode->front()->setPosition(_pm().BSplineHandleReposition(prevNode->front(),prevPos)); - if(nextNode) - nextNode->back()->setPosition(_pm().BSplineHandleReposition(nextNode->back(),nextPos)); - } - + _front.setPosition(_front.position() + delta); _back.setPosition(_back.position() + delta); @@ -709,15 +644,18 @@ void Node::move(Geom::Point const &new_pos) _fixNeighbors(old_pos, new_pos); if(_pm().isBSpline){ - Handle* front = &_front; - Handle* back = &_back; - _front.setPosition(_pm().BSplineHandleReposition(front,n->bsplineWeight)); - _back.setPosition(_pm().BSplineHandleReposition(back,n->bsplineWeight)); + _front.setPosition(_pm().BSplineHandleReposition(this->front(),oldPos)); + _back.setPosition(_pm().BSplineHandleReposition(this->back(),oldPos)); + _pm().BSplineNodeHandlesReposition(this); } } void Node::transform(Geom::Affine const &m) { + double oldPos = 0.0000; + if(_pm().isBSpline){ + oldPos = this->bsplineWeight; + } Geom::Point old_pos = position(); setPosition(position() * m); _front.setPosition(_front.position() * m); @@ -726,10 +664,9 @@ void Node::transform(Geom::Affine const &m) /* Affine transforms keep handle invariants for smooth and symmetric nodes, * but smooth nodes at ends of linear segments and auto nodes need special treatment */ _fixNeighbors(old_pos, position()); - _pm().BSpline(); if(_pm().isBSpline){ - _front.setPosition(_pm().BSplineHandleReposition(this->front(),this->bsplineWeight)); - _back.setPosition(_pm().BSplineHandleReposition(this->back(),this->bsplineWeight)); + _front.setPosition(_pm().BSplineHandleReposition(this->front(),oldPos)); + _back.setPosition(_pm().BSplineHandleReposition(this->back(),oldPos)); _pm().BSplineNodeHandlesReposition(this); } } @@ -817,6 +754,8 @@ void Node::showHandles(bool v) if (!_back.isDegenerate()) { _back.setVisible(v); } + if(!_pm().isBSpline) + this->bsplineWeight = 0.0000; } void Node::updateHandles() @@ -917,14 +856,10 @@ void Node::setType(NodeType type, bool update_handles) break; default: break; } - _pm().BSpline(); if(_pm().isBSpline){ - Handle* front = &_front; - Handle* back = &_back; - this->bsplineWeight = _pm().BSplineHandlePosition(front); if(this->bsplineWeight !=0.0000) this->bsplineWeight = 0.3334; - _front.setPosition(_pm().BSplineHandleReposition(front,this->bsplineWeight)); - _back.setPosition(_pm().BSplineHandleReposition(back,this->bsplineWeight)); + _front.setPosition(_pm().BSplineHandleReposition(this->front(),this->bsplineWeight)); + _back.setPosition(_pm().BSplineHandleReposition(this->back(),this->bsplineWeight)); } } @@ -1175,8 +1110,19 @@ void Node::_setState(State state) mgr.setPrelight(_canvas_item, false); _pm().BSpline(); if(_pm().isBSpline){ - this->bsplineWeight = _pm().BSplineHandlePosition(this->back()); - _pm().BSplineNodeHandlesReposition(this); + if(!this->back()->isDegenerate()){ + this->bsplineWeight = _pm().BSplineHandlePosition(this->back()); + }else if (!this->front()->isDegenerate()){ + this->bsplineWeight = _pm().BSplineHandlePosition(this->front()); + }else{ + this->bsplineWeight = 0.0000; + } + if(!this->front()->isDegenerate()){ + this->front()->setPosition(_pm().BSplineHandleReposition(this->front(),this->bsplineWeight)); + } + if(!this->back()->isDegenerate()){ + this->back()->setPosition(_pm().BSplineHandleReposition(this->back(),this->bsplineWeight)); + } } break; diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index fd421e587..4aec42100 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1294,6 +1294,7 @@ void PathManipulator::BSplineNodeHandlesReposition(Node *n){ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) { Geom::PathBuilder builder; + BSpline(); for (std::list::iterator spi = _subpaths.begin(); spi != _subpaths.end(); ) { SubpathPtr subpath = *spi; if (subpath->empty()) { @@ -1301,14 +1302,8 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) continue; } NodeList::iterator prev = subpath->begin(); - //if(isBSpline){ - // BSplineNodeHandlesReposition(prev.ptr()); - //} builder.moveTo(prev->position()); for (NodeList::iterator i = ++subpath->begin(); i != subpath->end(); ++i) { - //if(isBSpline){ - // BSplineNodeHandlesReposition(i.ptr()); - //} build_segment(builder, prev.ptr(), i.ptr()); prev = i; } diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index 2a59df464..547e687a7 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -116,7 +116,7 @@ private: Geom::Point BSplineHandleReposition(Handle *h); Geom::Point BSplineHandleReposition(Handle *h,double pos); void BSplineNodeHandlesReposition(Node *n); - + void _createGeometryFromControlPoints(bool alert_LPE = false); unsigned _deleteStretch(NodeList::iterator first, NodeList::iterator last, bool keep_shape); std::string _createTypeString(); -- cgit v1.2.3 From 4c6918c72721a35e0347e9e087396238e72eb62e Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 30 Dec 2013 20:41:32 +0100 Subject: Refactorizing (bzr r11950.1.212) --- src/live_effects/effect-enum.h | 2 - src/live_effects/effect.cpp | 6 --- src/live_effects/lpe-bendpath.h | 1 - src/ui/tool/curve-drag-point.cpp | 2 - src/ui/tool/multi-path-manipulator.cpp | 3 -- src/ui/tool/multi-path-manipulator.h | 2 +- src/ui/tool/node.cpp | 21 ++++------ src/ui/tool/node.h | 9 ++--- src/ui/tool/path-manipulator.cpp | 11 +---- src/ui/tool/path-manipulator.h | 7 +--- src/ui/tools/freehand-base.cpp | 8 ---- src/ui/tools/freehand-base.h | 2 - src/ui/tools/node-tool.h | 1 - src/ui/tools/pen-tool.cpp | 74 ++++++---------------------------- src/ui/tools/pen-tool.h | 2 - src/ui/tools/pencil-tool.cpp | 8 ---- src/widgets/pencil-toolbar.cpp | 2 - src/widgets/toolbox.cpp | 1 - 18 files changed, 29 insertions(+), 133 deletions(-) (limited to 'src') diff --git a/src/live_effects/effect-enum.h b/src/live_effects/effect-enum.h index cf97dd87f..342a2c849 100644 --- a/src/live_effects/effect-enum.h +++ b/src/live_effects/effect-enum.h @@ -45,9 +45,7 @@ enum EffectType { PATH_LENGTH, LINE_SEGMENT, DOEFFECTSTACK_TEST, - //BSpline BSPLINE, - //BSpline End DYNASTROKE, RECURSIVE_SKELETON, EXTRUDE, diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 3289c239e..29da403e8 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -21,9 +21,7 @@ #include "live_effects/lpe-rough-hatches.h" #include "live_effects/lpe-dynastroke.h" #include "live_effects/lpe-test-doEffect-stack.h" -//BSpline #include "live_effects/lpe-bspline.h" -//BSpline End #include "live_effects/lpe-gears.h" #include "live_effects/lpe-curvestitch.h" #include "live_effects/lpe-circle_with_radius.h" @@ -125,9 +123,7 @@ const Util::EnumData LPETypeData[] = { /* 0.49 */ {POWERSTROKE, N_("Power stroke"), "powerstroke"}, {CLONE_ORIGINAL, N_("Clone original path"), "clone_original"}, - //BSpline {BSPLINE, N_("BSpline"), "bspline"}, - //BSpline End }; const Util::EnumDataConverter LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData)); @@ -236,11 +232,9 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj) case DOEFFECTSTACK_TEST: neweffect = static_cast ( new LPEdoEffectStackTest(lpeobj) ); break; - //BSpline case BSPLINE: neweffect = static_cast ( new LPEBSpline(lpeobj) ); break; - //BSpline End case DYNASTROKE: neweffect = static_cast ( new LPEDynastroke(lpeobj) ); break; diff --git a/src/live_effects/lpe-bendpath.h b/src/live_effects/lpe-bendpath.h index 38b1a1446..554f20413 100644 --- a/src/live_effects/lpe-bendpath.h +++ b/src/live_effects/lpe-bendpath.h @@ -38,7 +38,6 @@ public: virtual Geom::Piecewise > doEffect_pwd2 (Geom::Piecewise > const & pwd2_in); virtual void resetDefaults(SPItem const* item); - private: PathParam bend_path; ScalarParam prop_scale; diff --git a/src/ui/tool/curve-drag-point.cpp b/src/ui/tool/curve-drag-point.cpp index f847a6ab3..5387e597d 100644 --- a/src/ui/tool/curve-drag-point.cpp +++ b/src/ui/tool/curve-drag-point.cpp @@ -53,12 +53,10 @@ bool CurveDragPoint::grabbed(GdkEventMotion */*event*/) // delta is a vector equal 1/3 of distance from first to second Geom::Point delta = (second->position() - first->position()) / 3.0; - //BSpline if(!_pm.isBSpline){ first->front()->move(first->front()->position() + delta); second->back()->move(second->back()->position() - delta); } - //BSpline End _pm.update(); } else { _segment_was_degenerate = false; diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp index 6da8b4104..3612f9c56 100644 --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@ -298,7 +298,6 @@ void MultiPathManipulator::invertSelectionInSubpaths() invokeForAll(&PathManipulator::invertSelectionInSubpaths); } - void MultiPathManipulator::setNodeType(NodeType type) { if (_selection.empty()) return; @@ -327,7 +326,6 @@ void MultiPathManipulator::setNodeType(NodeType type) _done(retract_handles ? _("Retract handles") : _("Change node type")); } - void MultiPathManipulator::setSegmentType(SegmentType type) { if (_selection.empty()) return; @@ -691,7 +689,6 @@ bool MultiPathManipulator::event(Inkscape::UI::Tools::ToolBase *event_context, G deleteNodes(true); } else - //BSpline end deleteNodes(del_preserves_shape ^ held_control(event->key)); // Delete any selected gradient nodes as well diff --git a/src/ui/tool/multi-path-manipulator.h b/src/ui/tool/multi-path-manipulator.h index 4566a7a98..1328372c6 100644 --- a/src/ui/tool/multi-path-manipulator.h +++ b/src/ui/tool/multi-path-manipulator.h @@ -71,7 +71,7 @@ public: void setLiveObjects(bool set); void updateOutlineColors(); void updateHandles(); - + sigc::signal signal_coords_changed; /// Emitted whenever the coordinates /// shown in the status bar need updating private: diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 70e374424..7266c85bb 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -28,9 +28,7 @@ #include "ui/tool/node.h" #include "ui/tool/path-manipulator.h" #include - #include -; namespace { @@ -137,7 +135,7 @@ void Handle::move(Geom::Point const &new_pos) Node *node_away = _parent->nodeAwayFrom(this); // node in the opposite direction Handle *towards = node_towards ? node_towards->handleAwayFrom(_parent) : NULL; Handle *towards_second = node_towards ? node_towards->handleToward(_parent) : NULL; - + if (Geom::are_near(new_pos, _parent->position())) { // The handle becomes degenerate. // Adjust node type as necessary. @@ -308,7 +306,6 @@ bool Handle::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEven return ControlPoint::_eventHandler(event_context, event); } - void Handle::handle_2button_press(){ if(_pm().isBSpline){ setPosition(_pm().BSplineHandleReposition(this,0.3334)); @@ -318,7 +315,6 @@ void Handle::handle_2button_press(){ } } - bool Handle::grabbed(GdkEventMotion *) { _saved_other_pos = other()->position(); @@ -335,6 +331,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) SnapManager &sm = _desktop->namedview->snap_manager; bool snap = held_shift(*event) ? false : sm.someSnapperMightSnap(); boost::optional ctrl_constraint; + // with Alt, preserve length if (held_alt(*event)) { new_pos = parent_pos + Geom::unit_vector(new_pos - parent_pos) * _saved_length; @@ -366,14 +363,13 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) ctrl_constraint = Inkscape::Snapper::SnapConstraint(parent_pos, parent_pos - perp_pos); } new_pos = result; - + if(_pm().isBSpline){ setPosition(new_pos); int steps = _pm().BSplineGetSteps(); _parent->bsplineWeight = ceilf(_pm().BSplineHandlePosition(this)*steps)/steps; new_pos=_pm().BSplineHandleReposition(this,_parent->bsplineWeight); } - } std::vector unselected; @@ -627,22 +623,22 @@ void Node::move(Geom::Point const &new_pos) // move handles when the node moves. Geom::Point old_pos = position(); Geom::Point delta = new_pos - position(); - + double oldPos = 0.0000; Node *n = this; if(_pm().isBSpline){ oldPos = n->bsplineWeight; } - + setPosition(new_pos); _front.setPosition(_front.position() + delta); _back.setPosition(_back.position() + delta); - + // if the node has a smooth handle after a line segment, it should be kept colinear // with the segment _fixNeighbors(old_pos, new_pos); - + if(_pm().isBSpline){ _front.setPosition(_pm().BSplineHandleReposition(this->front(),oldPos)); _back.setPosition(_pm().BSplineHandleReposition(this->back(),oldPos)); @@ -774,6 +770,7 @@ void Node::setType(NodeType type, bool update_handles) updateState(); // The size of the control might have changed return; } + // if update_handles is true, adjust handle positions to match the node type // handle degenerate handles appropriately if (update_handles) { @@ -861,7 +858,6 @@ void Node::setType(NodeType type, bool update_handles) _front.setPosition(_pm().BSplineHandleReposition(this->front(),this->bsplineWeight)); _back.setPosition(_pm().BSplineHandleReposition(this->back(),this->bsplineWeight)); } - } _type = type; _setControlType(nodeTypeToCtrlType(_type)); @@ -1124,7 +1120,6 @@ void Node::_setState(State state) this->back()->setPosition(_pm().BSplineHandleReposition(this->back(),this->bsplineWeight)); } } - break; } SelectableControlPoint::_setState(state); diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h index d257db86a..01159e6a0 100644 --- a/src/ui/tool/node.h +++ b/src/ui/tool/node.h @@ -97,6 +97,7 @@ public: virtual void setVisible(bool); virtual void move(Geom::Point const &p); + virtual void setPosition(Geom::Point const &p); inline void setRelativePos(Geom::Point const &p); void setLength(double len); @@ -112,28 +113,25 @@ public: protected: Handle(NodeSharedData const &data, Geom::Point const &initial_pos, Node *parent); - //Bspline virtual void handle_2button_press(); - //BSpline End - virtual bool _eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEvent *event); - virtual void dragged(Geom::Point &new_pos, GdkEventMotion *event); virtual bool grabbed(GdkEventMotion *event); virtual void ungrabbed(GdkEventButton *event); virtual bool clicked(GdkEventButton *event); - virtual Glib::ustring _getTip(unsigned state) const; virtual Glib::ustring _getDragTip(GdkEventMotion *event) const; virtual bool _hasDragTips() const { return true; } private: + inline PathManipulator &_pm(); Node *_parent; // the handle's lifetime does not extend beyond that of the parent node, // so a naked pointer is OK and allows setting it during Node's construction SPCtrlLine *_handle_line; bool _degenerate; // True if the handle is retracted, i.e. has zero length. This is used often internally so it makes sense to cache this + /** * Control point of a cubic Bezier curve in a path. * @@ -190,6 +188,7 @@ public: Handle *front() { return &_front; } Handle *back() { return &_back; } double bsplineWeight; + /** * Gets the handle that faces the given adjacent node. * Will abort with error if the given node is not adjacent. diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 4aec42100..4cb6ce296 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -43,10 +43,8 @@ #include "ui/tool/multi-path-manipulator.h" #include "xml/node.h" #include "xml/node-observer.h" - #include "live_effects/lpe-bspline.h" - namespace Inkscape { namespace UI { @@ -668,7 +666,6 @@ unsigned PathManipulator::_deleteStretch(NodeList::iterator start, NodeList::ite nl.erase(start); start = next; } - if(isBSpline){ double pos = 0.0000; if(start.prev()){ @@ -680,7 +677,6 @@ unsigned PathManipulator::_deleteStretch(NodeList::iterator start, NodeList::ite end->back()->setPosition(BSplineHandleReposition(end->back(),pos)); } } - return del_len; } @@ -856,9 +852,9 @@ void PathManipulator::rotateHandle(Node *n, int which, int dir, bool pixel) int snaps = prefs->getIntLimited("/options/rotationsnapsperpi/value", 12, 1, 1000); angle = M_PI * dir / snaps; } + h->setRelativePos(h->relativePos() * Geom::Rotate(angle)); update(); - gchar const *key = which < 0 ? "handle:rotate:left" : "handle:rotate:right"; _commit(_("Rotate handle"), key); } @@ -915,9 +911,7 @@ void PathManipulator::showHandles(bool show) /** Set the visibility of outline. */ void PathManipulator::showOutline(bool show) { - if(isBSpline) show = true; - if (show == _show_outline) return; _show_outline = show; _updateOutline(); @@ -1307,7 +1301,6 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) build_segment(builder, prev.ptr(), i.ptr()); prev = i; } - if (subpath->closed()) { // Here we link the last and first node if the path is closed. // If the last segment is Bezier, we add it. @@ -1319,7 +1312,6 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) } ++spi; } - builder.finish(); Geom::PathVector pathv = builder.peek() * (_edit_transform * _i2d_transform).inverse(); _spcurve->set_pathvector(pathv); @@ -1380,6 +1372,7 @@ void PathManipulator::_updateOutline() sp_canvas_item_hide(_outline); return; } + Geom::PathVector pv = _spcurve->get_pathvector(); pv *= (_edit_transform * _i2d_transform); // This SPCurve thing has to be killed with extreme prejudice diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index 547e687a7..31cc0d1fd 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -19,10 +19,8 @@ #include #include "ui/tool/node.h" #include "ui/tool/manipulator.h" - #include "live_effects/lpe-bspline.h" - struct SPCanvasItem; class SPCurve; class SPPath; @@ -97,10 +95,9 @@ public: NodeList::iterator subdivideSegment(NodeList::iterator after, double t); NodeList::iterator extremeNode(NodeList::iterator origin, bool search_selected, bool search_unselected, bool closest); - + bool isBSpline; int BSplineGetSteps(); - // this is necessary for Tab-selection in MultiPathManipulator SubpathList &subpathList() { return _subpaths; } @@ -110,13 +107,11 @@ private: typedef boost::shared_ptr SubpathPtr; void _createControlPointsFromGeometry(); - void BSpline(); double BSplineHandlePosition(Handle *h); Geom::Point BSplineHandleReposition(Handle *h); Geom::Point BSplineHandleReposition(Handle *h,double pos); void BSplineNodeHandlesReposition(Node *n); - void _createGeometryFromControlPoints(bool alert_LPE = false); unsigned _deleteStretch(NodeList::iterator first, NodeList::iterator last, bool keep_shape); std::string _createTypeString(); diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 14a5b5b35..b6efaebd9 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -247,12 +247,10 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1) { Effect::createAndApply(SPIRO, dc->desktop->doc(), item); } - //BSpline //Añadimos el modo BSpline a los efectos en espera if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2) { Effect::createAndApply(BSPLINE, dc->desktop->doc(), item); } - //BSPline End int shape = prefs->getInt(tool_name(dc) + "/shape", 0); bool shape_applied = false; @@ -489,7 +487,6 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) dc->red_curve->reset(); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(dc->red_bpath), NULL); - if (c->is_empty()) { c->unref(); return; @@ -520,7 +517,6 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) dc->sa->curve->append_continuous(c, 0.0625); c->unref(); dc->sa->curve->closepath_current(); - //BSpline //Si la curva tiene un LPE del tipo BSpline ejecutamos spdc_flush_white //pasándole la curva de inicio necesaria Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -529,7 +525,6 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) dc->white_curves = g_slist_remove(dc->white_curves, dc->sa->curve); spdc_flush_white(dc, dc->sa->curve); }else - //BSpline End spdc_flush_white(dc, NULL); return; } @@ -657,7 +652,6 @@ SPDrawAnchor *spdc_test_inside(FreehandBase *dc, Geom::Point p) } } - //BSpline //Modificamos la curva del "anchor" final para que sea igual que la curva de inicio. //Esta curva fue modificada al continuar la curva y necesitamos que sea igual que la curva en //la que cerramos el trazado. @@ -670,7 +664,6 @@ SPDrawAnchor *spdc_test_inside(FreehandBase *dc, Geom::Point p) active->curve->ref(); } } - //BSpline End return active; } @@ -815,4 +808,3 @@ void spdc_create_single_dot(ToolBase *ec, Geom::Point const &pt, char const *too End: */ // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : - diff --git a/src/ui/tools/freehand-base.h b/src/ui/tools/freehand-base.h index 7d60e217f..7e53684e3 100644 --- a/src/ui/tools/freehand-base.h +++ b/src/ui/tools/freehand-base.h @@ -57,7 +57,6 @@ public: SPCanvasItem *blue_bpath; SPCurve *blue_curve; - // Green GSList *green_bpaths; SPCurve *green_curve; @@ -143,4 +142,3 @@ void spdc_create_single_dot(ToolBase *ec, Geom::Point const &pt, char const *too End: */ // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : - diff --git a/src/ui/tools/node-tool.h b/src/ui/tools/node-tool.h index b3acb79ad..4d15ab70e 100644 --- a/src/ui/tools/node-tool.h +++ b/src/ui/tools/node-tool.h @@ -14,7 +14,6 @@ #include #include #include "ui/tools/tool-base.h" -#include "selection.h" namespace Inkscape { namespace Display { diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 178a940a2..f8d8d4c90 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -1,4 +1,4 @@ - /** \file +/** \file * Pen event context implementation. */ @@ -20,7 +20,6 @@ #include #include - #include "ui/tools/pen-tool.h" #include "sp-namedview.h" #include "desktop.h" @@ -43,7 +42,6 @@ #include "context-fns.h" #include "tools-switch.h" #include "ui/control-manager.h" -//BSpline //Incluimos los archivos necesarios para las BSpline y Spiro #define INKSCAPE_LPE_SPIRO_C #include "live_effects/lpe-spiro.h" @@ -64,11 +62,9 @@ #include "live_effects/spiro.h" - #define INKSCAPE_LPE_BSPLINE_C #include "live_effects/lpe-bspline.h" #include <2geom/nearest-point.h> -//BSpline End #include "tool-factory.h" @@ -80,10 +76,6 @@ namespace UI { namespace Tools { static void spdc_pen_set_initial_point(PenTool *pc, Geom::Point const p); -/* - *BSpline - *Added functions -*/ //Añade los modos spiro y bspline static void sp_pen_context_set_mode(PenTool *const pc, guint mode); //Esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro @@ -112,7 +104,7 @@ static void bspline_spiro_build(PenTool *const pc); static void bspline_doEffect(SPCurve * curve); //function spiro cloned from lpe-spiro.cpp static void spiro_doEffect(SPCurve * curve); -//BSpline end + static void spdc_pen_set_subsequent_point(PenTool *const pc, Geom::Point const p, bool statusbar, guint status = 0); static void spdc_pen_set_ctrl(PenTool *pc, Geom::Point const p, guint state); static void spdc_pen_finish_segment(PenTool *pc, Geom::Point p, guint state); @@ -205,14 +197,11 @@ void sp_pen_context_set_polyline_mode(PenTool *const pc) { guint mode = prefs->getInt("/tools/freehand/pen/freehand-mode", 0); pc->polylines_only = (mode == 3 || mode == 4); pc->polylines_paraxial = (mode == 4); - //BSpline //we call the function which defines the Spiro modes and the BSpline //todo: merge to one function only sp_pen_context_set_mode(pc, mode); - //BSpline End } -//BSpline /* *.Set the mode of draw spiro, and bsplines */ @@ -220,7 +209,6 @@ void sp_pen_context_set_mode(PenTool *const pc, guint mode) { pc->spiro = (mode == 1); pc->bspline = (mode == 2); } -//BSpline End /** * Callback to initialize PenTool object. @@ -422,12 +410,11 @@ static gint pen_handle_button_press(PenTool *const pc, GdkEventButton const &bev if(!bevent.button == 3 && (pc->spiro || pc->bspline) && pc->npoints > 0 && pc->p[0] == pc->p[3]){ return FALSE; } - //BSpline end gint ret = FALSE; if (bevent.button == 1 && !event_context->space_panning // make sure this is not the last click for a waiting LPE (otherwise we want to finish the path) - && (pc->expecting_clicks_for_LPE != 1)) { + && pc->expecting_clicks_for_LPE != 1) { if (Inkscape::have_viable_layer(desktop, dc->message_context) == false) { return TRUE; @@ -487,12 +474,10 @@ static gint pen_handle_button_press(PenTool *const pc, GdkEventButton const &bev // Set start anchor pc->sa = anchor; - //BSpline //Continuamos una curva existente if(anchor){ bspline_spiro_start_anchor(pc,(bevent.state & GDK_SHIFT_MASK)); } - //BSpline End if (anchor && !sp_pen_context_has_waiting_LPE(pc)) { // Adjust point to anchor if needed; if we have a waiting LPE, we need // a fresh path to be created so don't continue an existing one @@ -544,10 +529,8 @@ static gint pen_handle_button_press(PenTool *const pc, GdkEventButton const &bev } } - //BSpline //Evitamos la creación de un punto de control para que se cree el nodo en el evento de soltar pc->state = (pc->spiro || pc->bspline || pc->polylines_only) ? PenTool::POINT : PenTool::CONTROL; - //BSpline End ret = TRUE; break; @@ -585,6 +568,7 @@ static gint pen_handle_button_press(PenTool *const pc, GdkEventButton const &bev if (pc->expecting_clicks_for_LPE > 0) { --pc->expecting_clicks_for_LPE; } + return ret; } @@ -609,8 +593,7 @@ static gint pen_handle_motion_notify(PenTool *const pc, GdkEventMotion const &me } Geom::Point const event_w(mevent.x, - mevent.y); - //BSpline + mevent.y); //we take out the function the const "tolerance" because we need it later Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gint const tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); @@ -620,7 +603,6 @@ static gint pen_handle_motion_notify(PenTool *const pc, GdkEventMotion const &me return FALSE; // Do not drag if we're within tolerance from origin. } } - //BSpline END // Once the user has moved farther than tolerance from the original location // (indicating they intend to move the object, not click), then always process the // motion notify coordinates as given (no snapping back to origin) @@ -736,7 +718,6 @@ static gint pen_handle_motion_notify(PenTool *const pc, GdkEventMotion const &me default: break; } - //BSpline //Lanzamos la función "bspline_spiro_motion" al moverse el ratón o cuando se para. if(pc->bspline){ bspline_spiro_color(pc); @@ -748,7 +729,7 @@ static gint pen_handle_motion_notify(PenTool *const pc, GdkEventMotion const &me pen_drag_origin_w = event_w; } } - //BSpline End + return ret; } @@ -761,7 +742,7 @@ static gint pen_handle_button_release(PenTool *const pc, GdkEventButton const &r // skip event processing if events are disabled return FALSE; } - + gint ret = FALSE; ToolBase *event_context = SP_EVENT_CONTEXT(pc); @@ -776,7 +757,6 @@ static gint pen_handle_button_release(PenTool *const pc, GdkEventButton const &r // Test whether we hit any anchor. SPDrawAnchor *anchor = spdc_test_inside(pc, event_w); - //BSpline //with this we avoid creating a new point over the existing one if(pc->spiro || pc->bspline){ //Si intentamos crear un nodo en el mismo sitio que el origen, paramos. @@ -784,7 +764,7 @@ static gint pen_handle_button_release(PenTool *const pc, GdkEventButton const &r return FALSE; } } - //BSpline End + switch (pc->mode) { case PenTool::MODE_CLICK: switch (pc->state) { @@ -795,14 +775,12 @@ static gint pen_handle_button_release(PenTool *const pc, GdkEventButton const &r p = anchor->dp; } pc->sa = anchor; - //BSpline //continuamos una curva existente if (anchor) { if(pc->bspline || pc->spiro){ bspline_spiro_start_anchor(pc,(revent.state & GDK_SHIFT_MASK)); } } - //BSpline End spdc_pen_set_initial_point(pc, p); } else { // Set end anchor here @@ -827,12 +805,10 @@ static gint pen_handle_button_release(PenTool *const pc, GdkEventButton const &r spdc_endpoint_snap(pc, p, revent.state); } spdc_pen_finish_segment(pc, p, revent.state); - //BSpline //Ocultamos la guia del penultimo nodo al cerrar la curva if(pc->spiro){ sp_canvas_item_hide(pc->c1); } - //BSpline End spdc_pen_finish(pc, TRUE); pc->state = PenTool::POINT; ret = TRUE; @@ -856,12 +832,10 @@ static gint pen_handle_button_release(PenTool *const pc, GdkEventButton const &r case PenTool::CLOSE: spdc_endpoint_snap(pc, p, revent.state); spdc_pen_finish_segment(pc, p, revent.state); - //BSpline //Ocultamos la guia del penultimo nodo al cerrar la curva if(pc->spiro){ sp_canvas_item_hide(pc->c1); } - //BSpline End if (pc->green_closed) { // finishing at the start anchor, close curve spdc_pen_finish(pc, TRUE); @@ -873,7 +847,7 @@ static gint pen_handle_button_release(PenTool *const pc, GdkEventButton const &r case PenTool::STOP: // This is allowed, if we just cancelled curve break; - default: + default: break; } pc->state = PenTool::POINT; @@ -911,6 +885,7 @@ static gint pen_handle_button_release(PenTool *const pc, GdkEventButton const &r // handled in spdc_check_for_and_apply_waiting_LPE() in draw-context.cpp } } + return ret; } @@ -938,20 +913,20 @@ static void pen_redraw_all (PenTool *const pc) SPCanvasItem *cshape = sp_canvas_bpath_new(sp_desktop_sketch(pc->desktop), pc->green_curve); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cshape), pc->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(cshape), 0, SP_WIND_RULE_NONZERO); + pc->green_bpaths = g_slist_prepend(pc->green_bpaths, cshape); } if (pc->green_anchor) SP_CTRL(pc->green_anchor->ctrl)->moveto(pc->green_anchor->dp); + pc->red_curve->reset(); pc->red_curve->moveto(pc->p[0]); pc->red_curve->curveto(pc->p[1], pc->p[2], pc->p[3]); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), pc->red_curve); // handles - //BSpline //Ocultamos los tiradores en modo BSpline y spiro if (pc->p[0] != pc->p[1] && !pc->spiro && !pc->bspline) { - //BSpline End SP_CTRL(pc->c1)->moveto(pc->p[1]); pc->cl1->setCoords(pc->p[0], pc->p[1]); sp_canvas_item_show(pc->c1); @@ -964,12 +939,10 @@ static void pen_redraw_all (PenTool *const pc) Geom::Curve const * last_seg = pc->green_curve->last_segment(); if (last_seg) { Geom::CubicBezier const * cubic = dynamic_cast( last_seg ); - //BSpline //Ocultamos los tiradores en modo BSpline y spiro if ( cubic && (*cubic)[2] != pc->p[0] && !pc->spiro && !pc->bspline ) { - //BSpline End Geom::Point p2 = (*cubic)[2]; SP_CTRL(pc->c0)->moveto(p2); pc->cl0->setCoords(p2, pc->p[0]); @@ -980,15 +953,12 @@ static void pen_redraw_all (PenTool *const pc) sp_canvas_item_hide(pc->cl0); } } - //BSpline + //Simplemente redibujamos la spiro teniendo en cuenta si el nodo es cusp o symm. //como es un redibujo simplemente no llamamos a la función global //sino al final de esta - - //BSpline //Lanzamos solamente el redibujado bspline_spiro_build(pc); - //BSpline End } static void pen_lastpoint_move (PenTool *const pc, gdouble x, gdouble y) @@ -1019,11 +989,9 @@ static void pen_lastpoint_move_screen (PenTool *const pc, gdouble x, gdouble y) static void pen_lastpoint_tocurve (PenTool *const pc) { - //BSpline //Evitamos que si la "red_curve" tiene solo dos puntos -recta- no se pare aqui. if (pc->npoints != 5 && !pc->spiro && !pc->bspline) return; - //BSpline Geom::CubicBezier const * cubic; pc->p[1] = pc->red_curve->last_segment()->initialPoint() + (1./3)* (Geom::Point)(pc->red_curve->last_segment()->finalPoint() - pc->red_curve->last_segment()->initialPoint()); //Modificamos el último segmento de la curva verde para que forme el tipo de nodo que deseamos @@ -1070,13 +1038,11 @@ static void pen_lastpoint_tocurve (PenTool *const pc) } } - //Spiro Live pen_redraw_all(pc); } static void pen_lastpoint_toline (PenTool *const pc) { - //BSpline //Evitamos que si la "red_curve" tiene solo dos puntos -recta- no se pare aqui. if (pc->npoints != 5 && !pc->bspline) return; @@ -1312,7 +1278,6 @@ static gint pen_handle_key_press(PenTool *const pc, GdkEvent *event) : pc->p[3])); pc->npoints = 2; - //BSpline //Eliminamos el último segmento de la curva verde if( pc->green_curve->get_segment_count() == 1){ pc->npoints = 5; @@ -1335,16 +1300,13 @@ static gint pen_handle_key_press(PenTool *const pc, GdkEvent *event) pc->p[1] = pc->p[0]; } } - //BSpline End sp_canvas_item_hide(pc->cl0); sp_canvas_item_hide(pc->cl1); pc->state = PenTool::POINT; spdc_pen_set_subsequent_point(pc, pt, true); pen_last_paraxial_dir = !pen_last_paraxial_dir; - //BSpline //Redibujamos bspline_spiro_build(pc); - //BSpline End ret = TRUE; } break; @@ -1358,12 +1320,10 @@ static void spdc_reset_colors(PenTool *pc) { // Red pc->red_curve->reset(); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), NULL); // Blue pc->blue_curve->reset(); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->blue_bpath), NULL); - // Green while (pc->green_bpaths) { sp_canvas_item_destroy(SP_CANVAS_ITEM(pc->green_bpaths->data)); @@ -2111,8 +2071,6 @@ static void spiro_doEffect(SPCurve * curve) g_free (path); } -//BSpline end - static void spdc_pen_set_subsequent_point(PenTool *const pc, Geom::Point const p, bool statusbar, guint status) { g_assert( pc->npoints != 0 ); @@ -2139,9 +2097,7 @@ static void spdc_pen_set_subsequent_point(PenTool *const pc, Geom::Point const p is_curve = false; } else { // one of the 'regular' modes - //SpiroLive if (pc->p[1] != pc->p[0] || pc->spiro) { - //SpiroLive End pc->red_curve->curveto(pc->p[1], p, p); is_curve = true; } else { @@ -2156,13 +2112,11 @@ static void spdc_pen_set_subsequent_point(PenTool *const pc, Geom::Point const p gchar *message = is_curve ? _("Curve segment: angle %3.2f°, distance %s; with Ctrl to snap angle, Enter to finish the path" ): _("Line segment: angle %3.2f°, distance %s; with Ctrl to snap angle, Enter to finish the path"); - //BSpline if(pc->spiro || pc->bspline){ message = is_curve ? _("Curve segment: angle %3.2f°, distance %s; with Shift to cusp node, Enter to finish the path" ): _("Line segment: angle %3.2f°, distance %s; with Shift to cusp node, Enter to finish the path"); } - //BSpline End spdc_pen_set_angle_distance_status_message(pc, p, 0, message); } } @@ -2369,5 +2323,3 @@ void pen_set_to_nearest_horiz_vert(const PenTool *const pc, Geom::Point &pt, gui End: */ // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : - - diff --git a/src/ui/tools/pen-tool.h b/src/ui/tools/pen-tool.h index 553e4c557..b0b56feb4 100644 --- a/src/ui/tools/pen-tool.h +++ b/src/ui/tools/pen-tool.h @@ -48,11 +48,9 @@ public: bool polylines_only; bool polylines_paraxial; - //SpiroLive //Propiedad que guarda si el modo Spiro está activo o no bool spiro; bool bspline; - //SpiroLIve End int num_clicks; unsigned int expecting_clicks_for_LPE; // if positive, finish the path after this many clicks diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp index c10bd15a3..2027f0981 100644 --- a/src/ui/tools/pencil-tool.cpp +++ b/src/ui/tools/pencil-tool.cpp @@ -692,10 +692,8 @@ interpolate(PencilTool *pc) return; } - //BSpline using Geom::X; using Geom::Y; - //BSpline end Inkscape::Preferences *prefs = Inkscape::Preferences::get(); double const tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0) * 0.4; @@ -727,12 +725,9 @@ interpolate(PencilTool *pc) { /* Fit and draw and reset state */ pc->green_curve->moveto(b[0]); - //BSpline Inkscape::Preferences *prefs = Inkscape::Preferences::get(); guint mode = prefs->getInt("/tools/freehand/pencil/freehand-mode", 0); - //BSpline End for (int c = 0; c < n_segs; c++) { - //BSpline //Si el modo es BSpline modificamos para que el trazado cree los nodos adhoc if(mode == 2){ Geom::Point BP = b[4*c+0] + (1./3)*(b[4*c+3] - b[4*c+0]); @@ -743,7 +738,6 @@ interpolate(PencilTool *pc) }else{ pc->green_curve->curveto(b[4*c+1], b[4*c+2], b[4*c+3]); } - //BSpline } sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), pc->green_curve); @@ -884,7 +878,6 @@ fit_and_split(PencilTool *pc) /* Fit and draw and reset state */ pc->red_curve->reset(); pc->red_curve->moveto(b[0]); - //BSpline using Geom::X; using Geom::Y; //Si el modo es BSpline modificamos para que el trazado cree los nodos adhoc @@ -899,7 +892,6 @@ fit_and_split(PencilTool *pc) }else{ pc->red_curve->curveto(b[1], b[2], b[3]); } - //BSpline End sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), pc->red_curve); pc->red_curve_is_valid = true; } else { diff --git a/src/widgets/pencil-toolbar.cpp b/src/widgets/pencil-toolbar.cpp index d9d53117c..3289ed181 100644 --- a/src/widgets/pencil-toolbar.cpp +++ b/src/widgets/pencil-toolbar.cpp @@ -133,14 +133,12 @@ static void sp_add_freehand_mode_toggle(GtkActionGroup* mainActions, GObject* ho 1, _("Create Spiro path"), 2, INKSCAPE_ICON("path-mode-spiro"), -1 ); - //BSpline gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, _("BSpline"), 1, _("Create BSpline path"), 2, INKSCAPE_ICON("path-mode-bspline"), -1 ); - //BSpline if (!tool_is_pencil) { gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 9f64f6336..901276620 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -115,7 +115,6 @@ enum BarId { BAR_COMMANDS, BAR_SNAP, }; -//#define WITH_MESH #define BAR_ID_KEY "BarIdValue" #define HANDLE_POS_MARK "x-inkscape-pos" -- cgit v1.2.3 From f2063b21523998891d43de384ef4ec4ec93c5516 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 30 Dec 2013 20:42:06 +0100 Subject: Refactorizing (bzr r11950.1.213) --- src/libavoid/makefile | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 src/libavoid/makefile (limited to 'src') diff --git a/src/libavoid/makefile b/src/libavoid/makefile deleted file mode 100644 index e4f83a52d..000000000 --- a/src/libavoid/makefile +++ /dev/null @@ -1,17 +0,0 @@ -# Convenience stub makefile to call the real Makefile. - - - -OBJEXT = o - -# Explicit so that it's the default rule. -all: - cd .. && $(MAKE) libavoid/all - -clean %.a %.$(OBJEXT): - cd .. && $(MAKE) libavoid/$@ - -.PHONY: all clean - -.SUFFIXES: -.SUFFIXES: .a .$(OBJEXT) -- cgit v1.2.3 From 8c6ae51081f4d1d63ba84f9dd339b9f530f06c87 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 30 Dec 2013 21:30:44 +0100 Subject: Start refactor, simplify node.cpp operations,general cleanup, changed brehabiour to need 'Shift' Key to move handles because it handle better operations with small zoom (bzr r11950.1.214) --- src/ui/tools/node-tool.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/ui/tools/node-tool.h b/src/ui/tools/node-tool.h index 4d15ab70e..b3acb79ad 100644 --- a/src/ui/tools/node-tool.h +++ b/src/ui/tools/node-tool.h @@ -14,6 +14,7 @@ #include #include #include "ui/tools/tool-base.h" +#include "selection.h" namespace Inkscape { namespace Display { -- cgit v1.2.3 From 8d781fb629a07fdbd828b2eeb18694bb32e88768 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 30 Dec 2013 21:45:48 +0100 Subject: Updated tip strings (bzr r11950.1.215) --- src/ui/tool/node.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 7266c85bb..305dd6798 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -492,7 +492,7 @@ Glib::ustring Handle::_getTip(unsigned state) const if (can_shift_rotate && !isBSpline) { more = C_("Path handle tip", "more: Shift, Ctrl, Alt"); } else if(isBSpline){ - more = C_("Path handle tip", "move:Shift, reset:double click, more: Ctrl"); + more = C_("Path handle tip", "more: Ctrl"); }else { more = C_("Path handle tip", "more: Ctrl, Alt"); } @@ -545,9 +545,13 @@ Glib::ustring Handle::_getTip(unsigned state) const return format_tip(C_("Path handle tip", "Auto node handle: drag to convert to smooth node (%s)"), more); default: - return format_tip(C_("Path handle tip", - "%s: drag to shape the segment (%s)"), - handle_type_to_localized_string(_parent->type()), more); + if(!isBSpline){ + return format_tip(C_("Path handle tip", + "Auto node handle: drag to convert to smooth node (%s)"), more); + }else{ + return format_tip(C_("Path handle tip", + "BSpline node handle: Shift to drag, double click to reset (%s)"), more); + } } } -- cgit v1.2.3 From 140267c64cd9d19e372328d6f30c072102c2dd33 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 30 Dec 2013 22:04:13 +0100 Subject: Refact (bzr r11950.1.216) --- src/ui/tool/node.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 305dd6798..85a407384 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -974,6 +974,7 @@ bool Node::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEvent _selection.spatialGrow(this, dir); } return true; + default: break; } -- cgit v1.2.3 From 1abfd51451a3df8a46ec9e23332aff72208ac942 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 30 Dec 2013 23:19:31 +0100 Subject: Spanish comment of node.cpp (bzr r11950.1.217) --- src/ui/tool/node.cpp | 53 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 85a407384..9eab1d7dc 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -167,7 +167,7 @@ void Handle::move(Geom::Point const &new_pos) } setPosition(new_pos); - //If is bspline move other handle + //spanish: mueve el tirador y su opuesto la misma proporción if(_pm().isBSpline){ setPosition(_pm().BSplineHandleReposition(this)); _parent->bsplineWeight = _pm().BSplineHandlePosition(this); @@ -185,7 +185,7 @@ void Handle::move(Geom::Point const &new_pos) / Geom::L2sq(direction)) * direction; setRelativePos(new_delta); - //If is bspline move both handles + //spanish: mueve el tirador y su opuesto la misma proporción if(_pm().isBSpline){ setPosition(_pm().BSplineHandleReposition(this)); _parent->bsplineWeight = _pm().BSplineHandlePosition(this); @@ -212,7 +212,7 @@ void Handle::move(Geom::Point const &new_pos) } setPosition(new_pos); - //If is bspline move other handle + //spanish: mueve el tirador y su opuesto la misma proporción if(_pm().isBSpline){ setPosition(_pm().BSplineHandleReposition(this)); _parent->bsplineWeight = _pm().BSplineHandlePosition(this); @@ -295,7 +295,7 @@ bool Handle::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEven break; default: break; } - + //spanish: nuevo evento de doble click para resetear a la proporción por defecto, 0.3334%, los tiradores de un nodo case GDK_2BUTTON_PRESS: handle_2button_press(); break; @@ -306,6 +306,7 @@ bool Handle::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEven return ControlPoint::_eventHandler(event_context, event); } +//spanish: función que mueve el tirador y su opuesto a la proporción por defecto de 0.3334 void Handle::handle_2button_press(){ if(_pm().isBSpline){ setPosition(_pm().BSplineHandleReposition(this,0.3334)); @@ -363,7 +364,8 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) ctrl_constraint = Inkscape::Snapper::SnapConstraint(parent_pos, parent_pos - perp_pos); } new_pos = result; - + //spanish: mueve el tirador y su opuesto en X posiciones fijas depenfiendo de la configuración de el + //parametro "steps whith control" del efecto en vivo BSpline if(_pm().isBSpline){ setPosition(new_pos); int steps = _pm().BSplineGetSteps(); @@ -373,9 +375,8 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) } std::vector unselected; - - //IF Snap and Not CTRL && BSpline or BSPLINE is false - if (snap && (((!held_control(*event) && _pm().isBSpline) && (!held_shift(*event) && _pm().isBSpline)) || !_pm().isBSpline)) { + //spanish: si está activado el ajuste (snap) y no es bspline + if (snap && !_pm().isBSpline) { ControlPointSelection::Set &nodes = _parent->_selection.allPoints(); for (ControlPointSelection::Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { Node *n = static_cast(*i); @@ -401,11 +402,6 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) sm.freeSnapReturnByRef(new_pos, SNAPSOURCE_NODE_HANDLE); } sm.unSetup(); - if(_pm().isBSpline){ - setPosition(new_pos); - _parent->bsplineWeight = _pm().BSplineHandlePosition(this); - new_pos=_pm().BSplineHandleReposition(this,_parent->bsplineWeight); - } } @@ -420,7 +416,8 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) other()->setPosition(_saved_other_pos); } } - + //spanish: si es bspline pero no está presionado SHIFT o CONTROL + //lo fija en la posición original if(_pm().isBSpline && !held_shift(*event) && !held_control(*event)){ new_pos=_last_drag_origin(); } @@ -440,6 +437,7 @@ void Handle::ungrabbed(GdkEventButton *event) Geom::Point dist = _desktop->d2w(_parent->position()) - _desktop->d2w(position()); if (dist.length() <= drag_tolerance) { move(_parent->position()); + //spanish: marca la fuerza del bspline como 0.0000 if(_pm().isBSpline){ _parent->bsplineWeight = 0.0000; } @@ -485,6 +483,9 @@ static double snap_increment_degrees() { Glib::ustring Handle::_getTip(unsigned state) const { char const *more; + //spanish: un truco par, si el nodo tiene fuerza, nos marca que es + //del tipo bspline, lo utilizaremos despues para mostras los mensajes apropiados + //no lo podemos hacer de otra forma al ser constante la funcion bool isBSpline = false; if( _parent->bsplineWeight != 0.0000) isBSpline = true; @@ -587,7 +588,6 @@ Node::Node(NodeSharedData const &data, Geom::Point const &initial_pos) : _type(NODE_CUSP), _handles_shown(false) { - this->bsplineWeight = 0.3334; // NOTE we do not set type here, because the handles are still degenerate } @@ -627,7 +627,8 @@ void Node::move(Geom::Point const &new_pos) // move handles when the node moves. Geom::Point old_pos = position(); Geom::Point delta = new_pos - position(); - + //spanish: guardamos la fuerza anterior del nodo para reaplicarsela + //de nuevo una vez sea movido el nodo double oldPos = 0.0000; Node *n = this; if(_pm().isBSpline){ @@ -642,7 +643,8 @@ void Node::move(Geom::Point const &new_pos) // if the node has a smooth handle after a line segment, it should be kept colinear // with the segment _fixNeighbors(old_pos, new_pos); - + //spanish: movemos los tiradores involucrados, primero los del nodo en cuestión + //y despues los de los nodos colindantes if(_pm().isBSpline){ _front.setPosition(_pm().BSplineHandleReposition(this->front(),oldPos)); _back.setPosition(_pm().BSplineHandleReposition(this->back(),oldPos)); @@ -652,6 +654,8 @@ void Node::move(Geom::Point const &new_pos) void Node::transform(Geom::Affine const &m) { + //spanish: guardamos la fuerza anterior del nodo para reaplicarsela + //de nuevo una vez sea movido el nodo double oldPos = 0.0000; if(_pm().isBSpline){ oldPos = this->bsplineWeight; @@ -664,6 +668,8 @@ void Node::transform(Geom::Affine const &m) /* Affine transforms keep handle invariants for smooth and symmetric nodes, * but smooth nodes at ends of linear segments and auto nodes need special treatment */ _fixNeighbors(old_pos, position()); + //spanish: movemos los tiradores involucrados, primero los del nodo en cuestión + //y despues los de los nodos colindantes if(_pm().isBSpline){ _front.setPosition(_pm().BSplineHandleReposition(this->front(),oldPos)); _back.setPosition(_pm().BSplineHandleReposition(this->back(),oldPos)); @@ -754,8 +760,12 @@ void Node::showHandles(bool v) if (!_back.isDegenerate()) { _back.setVisible(v); } - if(!_pm().isBSpline) - this->bsplineWeight = 0.0000; + //spanish: definimos la fuerza de los nodos,según sea o no trazado bspline. + //Cada vez que actuemos sobre dichos tiradores en un trazado + //bspline esta fuerza se tiene que actualizar + this->bsplineWeight = 0.0000; + if(_pm().isBSpline) + this->bsplineWeight = 0.3334; } void Node::updateHandles() @@ -857,6 +867,9 @@ void Node::setType(NodeType type, bool update_handles) break; default: break; } + //spanish: en los cambios de tipo de nodo, sobre trazados bspline, + //o bien los mantenemos con potencia 0.0000 en modo esquina + //o les damos la potencia por defecto en modo de curva if(_pm().isBSpline){ if(this->bsplineWeight !=0.0000) this->bsplineWeight = 0.3334; _front.setPosition(_pm().BSplineHandleReposition(this->front(),this->bsplineWeight)); @@ -1109,7 +1122,7 @@ void Node::_setState(State state) case STATE_CLICKED: mgr.setActive(_canvas_item, true); mgr.setPrelight(_canvas_item, false); - _pm().BSpline(); + //spanish: esto muestra los tiradores al seleccionar los nodos if(_pm().isBSpline){ if(!this->back()->isDegenerate()){ this->bsplineWeight = _pm().BSplineHandlePosition(this->back()); -- cgit v1.2.3 From 1866742fce895e2306c4e0bc032f9b73bfce2925 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 30 Dec 2013 23:23:56 +0100 Subject: Spanish comment of node.h (bzr r11950.1.218) --- src/ui/tool/node.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h index 01159e6a0..b7d6951d0 100644 --- a/src/ui/tool/node.h +++ b/src/ui/tool/node.h @@ -187,6 +187,7 @@ public: bool isEndNode() const; Handle *front() { return &_front; } Handle *back() { return &_back; } + //spanish: creamos valor de potencia bspline asociado a cada nodo double bsplineWeight; /** -- cgit v1.2.3 From df2cf6584407ae3744aac917039681fb3a04a678 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 30 Dec 2013 23:32:51 +0100 Subject: refactor, fixing some diff diferences (bzr r11950.1.219) --- src/live_effects/lpe-bendpath.h | 2 ++ src/seltrans.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/live_effects/lpe-bendpath.h b/src/live_effects/lpe-bendpath.h index 554f20413..16b8c6137 100644 --- a/src/live_effects/lpe-bendpath.h +++ b/src/live_effects/lpe-bendpath.h @@ -38,6 +38,8 @@ public: virtual Geom::Piecewise > doEffect_pwd2 (Geom::Piecewise > const & pwd2_in); virtual void resetDefaults(SPItem const* item); + + private: PathParam bend_path; ScalarParam prop_scale; diff --git a/src/seltrans.cpp b/src/seltrans.cpp index d1d39532c..4d0a09c6d 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -1461,7 +1461,7 @@ Geom::Point Inkscape::SelTrans::_getGeomHandlePos(Geom::Point const &visual_hand Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool transform_stroke = prefs->getBool("/options/transform/stroke", true); bool preserve = prefs->getBool("/options/preservetransform/value", false); - Geom::Affine abs_affine = get_scale_transform_for_uniform_stroke (*_bbox, _strokewidth, transform_stroke, preserve, + Geom::Affine abs_affine = get_scale_transform_for_uniform_stroke (*_bbox, _strokewidth, _strokewidth, transform_stroke, preserve, new_bbox.min()[Geom::X], new_bbox.min()[Geom::Y], new_bbox.max()[Geom::X], new_bbox.max()[Geom::Y]); // Calculate the scaled geometrical bbox -- cgit v1.2.3 From 58638901bd9d7408c4bd053673e3f7934adcb668 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 30 Dec 2013 23:41:04 +0100 Subject: Spanish comment of curve-drag-point-cpp (bzr r11950.1.221) --- src/ui/tool/curve-drag-point.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/ui/tool/curve-drag-point.cpp b/src/ui/tool/curve-drag-point.cpp index 5387e597d..0ee848f15 100644 --- a/src/ui/tool/curve-drag-point.cpp +++ b/src/ui/tool/curve-drag-point.cpp @@ -53,6 +53,7 @@ bool CurveDragPoint::grabbed(GdkEventMotion */*event*/) // delta is a vector equal 1/3 of distance from first to second Geom::Point delta = (second->position() - first->position()) / 3.0; + //spanish: solo actualizamos los nodos si no es bspline if(!_pm.isBSpline){ first->front()->move(first->front()->position() + delta); second->back()->move(second->back()->position() - delta); @@ -88,6 +89,7 @@ void CurveDragPoint::dragged(Geom::Point &new_pos, GdkEventMotion *event) Geom::Point delta = new_pos - position(); Geom::Point offset0 = ((1-weight)/(3*t*(1-t)*(1-t))) * delta; Geom::Point offset1 = (weight/(3*t*t*(1-t))) * delta; + //spanish: modificado para que, si el trazado es bspline solo actue si está presionada la tecla SHIFT if(!_pm.isBSpline){ first->front()->move(first->front()->position() + offset0); second->back()->move(second->back()->position() + offset1); -- cgit v1.2.3 From 118a1dbf3b1b7145928aeb106d94b77f7f1cdfda Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 30 Dec 2013 23:50:51 +0100 Subject: Spanish comment of multi-path-manipulator-cpp (bzr r11950.1.222) --- src/ui/tool/multi-path-manipulator.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp index 3612f9c56..c77d2d795 100644 --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@ -682,7 +682,9 @@ bool MultiPathManipulator::event(Inkscape::UI::Tools::ToolBase *event_context, G // b) ctrl+del preserves shape (del_preserves_shape is false), and control is pressed // Hence xor guint mode = prefs->getInt("/tools/freehand/pen/freehand-mode", 0); + //spanish: si es trazado bspline (mode 2) if(mode==2){ + //spanish: ¿correcto? if(del_preserves_shape ^ held_control(event->key)) deleteNodes(false); else -- cgit v1.2.3 From bfc330ddc8564d132f885378f428fab10692edbb Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 31 Dec 2013 00:21:57 +0100 Subject: Spanish comment of path-manipulator-cpp (bzr r11950.1.223) --- src/ui/tool/path-manipulator.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 4cb6ce296..47f736fcb 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -33,7 +33,6 @@ #include "live_effects/lpeobject-reference.h" #include "live_effects/parameter/path.h" #include "sp-path.h" -#include "sp-lpe-item.h" #include "helper/geom.h" #include "preferences.h" #include "style.h" @@ -43,6 +42,7 @@ #include "ui/tool/multi-path-manipulator.h" #include "xml/node.h" #include "xml/node-observer.h" +#include "sp-lpe-item.h" #include "live_effects/lpe-bspline.h" namespace Inkscape { @@ -104,7 +104,7 @@ private: }; void build_segment(Geom::PathBuilder &, Node *, Node *); - +//spanish: una propiedad isBSpline, por defecto falsa y una función al final de la función (BSpline()) que la define realmente PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, Geom::Affine const &et, guint32 outline_color, Glib::ustring lpe_key) : PointManipulator(mpm._path_data.node_data.desktop, *mpm._path_data.node_data.selection) @@ -666,6 +666,7 @@ unsigned PathManipulator::_deleteStretch(NodeList::iterator start, NodeList::ite nl.erase(start); start = next; } + //spanish: si se borra, reajustamos los tiradores if(isBSpline){ double pos = 0.0000; if(start.prev()){ @@ -1185,7 +1186,9 @@ void PathManipulator::_createControlPointsFromGeometry() } } +//spanish: determina si el trazado tiene efecto bspline y el numero de pasos que realiza int PathManipulator::BSplineGetSteps(){ + LivePathEffect::LPEBSpline *lpe_bsp = NULL; if (SP_IS_LPE_ITEM(_path) && _path->hasPathEffect()){ @@ -1194,24 +1197,22 @@ int PathManipulator::BSplineGetSteps(){ lpe_bsp = dynamic_cast(thisEffect->getLPEObj()->get_lpe()); } } - return lpe_bsp->steps+1; + int steps = 0; + if(lpe_bsp){ + steps = lpe_bsp->steps+1; + } + return steps; } +//spanish: determina si el trazado tiene efecto bspline void PathManipulator::BSpline(){ - LivePathEffect::LPEBSpline *lpe_bsp = NULL; - - if (SP_IS_LPE_ITEM(_path) && _path->hasPathEffect()){ - Inkscape::LivePathEffect::Effect* thisEffect = SP_LPE_ITEM(_path)->getPathEffectOfType(Inkscape::LivePathEffect::BSPLINE); - if(thisEffect){ - lpe_bsp = dynamic_cast(thisEffect->getLPEObj()->get_lpe()); - } - } isBSpline = false; - if(lpe_bsp){ + if(this->BSplineGetSteps()>0){ isBSpline = true; } } +//spanish: devuelve la fuerza que le corresponderia a la posicón de un tirador double PathManipulator::BSplineHandlePosition(Handle *h){ using Geom::X; using Geom::Y; @@ -1230,11 +1231,13 @@ double PathManipulator::BSplineHandlePosition(Handle *h){ return pos; } +//spanish: mueve el tirador a la posición que le corresponda Geom::Point PathManipulator::BSplineHandleReposition(Handle *h){ double pos = this->BSplineHandlePosition(h); return BSplineHandleReposition(h,pos); } +//spanish: mueve el tirador a una posición específica Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){ using Geom::X; using Geom::Y; @@ -1260,11 +1263,12 @@ Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){ return ret; } +//spanish: mueve los tiradores del nodo y sus tiradores opuestos a la potencia de sus nodos void PathManipulator::BSplineNodeHandlesReposition(Node *n){ Node * nextNode = n->nodeToward(n->front()); Node * prevNode = n->nodeToward(n->back()); if(prevNode){ - n->back()->setPosition(BSplineHandleReposition(n->back())); + n->back()->setPosition(BSplineHandleReposition(n->back(),n->bsplineWeight)); if(prevNode->front()->position() == prevNode->position()) prevNode->bsplineWeight = 0.000; if(!prevNode->isEndNode()) @@ -1272,7 +1276,7 @@ void PathManipulator::BSplineNodeHandlesReposition(Node *n){ prevNode->front()->setPosition(BSplineHandleReposition(prevNode->front(),prevNode->bsplineWeight)); } if(nextNode){ - n->front()->setPosition(BSplineHandleReposition(n->front())); + n->front()->setPosition(BSplineHandleReposition(n->front(),n->bsplineWeight)); if(nextNode->front()->position() == nextNode->position()) nextNode->bsplineWeight = 0.000; if(!nextNode->isEndNode()) -- cgit v1.2.3 From c288aa062e611031f54f6ad8e5e3ee2f581cc783 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 31 Dec 2013 00:29:07 +0100 Subject: Spanish comment of freehand-base.cpp (bzr r11950.1.224) --- src/ui/tool/path-manipulator.cpp | 1 - src/ui/tool/path-manipulator.h | 2 +- src/ui/tools/freehand-base.cpp | 8 ++++---- 3 files changed, 5 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 47f736fcb..e70717728 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -42,7 +42,6 @@ #include "ui/tool/multi-path-manipulator.h" #include "xml/node.h" #include "xml/node-observer.h" -#include "sp-lpe-item.h" #include "live_effects/lpe-bspline.h" namespace Inkscape { diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index 31cc0d1fd..5f075834e 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -94,7 +94,7 @@ public: NodeList::iterator subdivideSegment(NodeList::iterator after, double t); NodeList::iterator extremeNode(NodeList::iterator origin, bool search_selected, - bool search_unselected, bool closest); + bool search_unselected, bool closest); bool isBSpline; int BSplineGetSteps(); diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index b6efaebd9..5825a149c 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -247,7 +247,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1) { Effect::createAndApply(SPIRO, dc->desktop->doc(), item); } - //Añadimos el modo BSpline a los efectos en espera + //spanish: añadimos el modo bspline a los efectos en espera if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2) { Effect::createAndApply(BSPLINE, dc->desktop->doc(), item); } @@ -517,7 +517,7 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) dc->sa->curve->append_continuous(c, 0.0625); c->unref(); dc->sa->curve->closepath_current(); - //Si la curva tiene un LPE del tipo BSpline ejecutamos spdc_flush_white + //spanish: Si la curva tiene un LPE del tipo bspline o spiro ejecutamos spdc_flush_white //pasándole la curva de inicio necesaria Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || @@ -652,8 +652,8 @@ SPDrawAnchor *spdc_test_inside(FreehandBase *dc, Geom::Point p) } } - //Modificamos la curva del "anchor" final para que sea igual que la curva de inicio. - //Esta curva fue modificada al continuar la curva y necesitamos que sea igual que la curva en + //spanish: modificamos la curva de anclaje para que sea igual que la curva de inicio. + //esta curva fue modificada al continuar la curva y necesitamos que sea igual que la curva en //la que cerramos el trazado. Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if((prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || -- cgit v1.2.3 From cb0d2fad1fa3b8055b86f8d7e911b295e09cf27a Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 31 Dec 2013 00:31:15 +0100 Subject: Spanish comment of node-tool.cpp (bzr r11950.1.225) --- src/ui/tools/node-tool.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/ui/tools/node-tool.h b/src/ui/tools/node-tool.h index b3acb79ad..168ec995a 100644 --- a/src/ui/tools/node-tool.h +++ b/src/ui/tools/node-tool.h @@ -14,6 +14,7 @@ #include #include #include "ui/tools/tool-base.h" +//spanish: lo necesitamos para llamarlo desde el Live Effect #include "selection.h" namespace Inkscape { -- cgit v1.2.3 From 14a50ad8c16b1d840e7a68ba8a75e2cec174a0a5 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 31 Dec 2013 01:02:40 +0100 Subject: Spanish comment of pencil-tool.cpp/.h (bzr r11950.1.226) --- src/ui/tools/pen-tool.cpp | 150 ++++++++++++++++------------------------------ src/ui/tools/pen-tool.h | 2 +- 2 files changed, 54 insertions(+), 98 deletions(-) (limited to 'src') diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index f8d8d4c90..9b5acb6cc 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -42,7 +42,7 @@ #include "context-fns.h" #include "tools-switch.h" #include "ui/control-manager.h" -//Incluimos los archivos necesarios para las BSpline y Spiro +//spanish: incluimos los archivos necesarios para las BSpline y Spiro #define INKSCAPE_LPE_SPIRO_C #include "live_effects/lpe-spiro.h" @@ -76,29 +76,29 @@ namespace UI { namespace Tools { static void spdc_pen_set_initial_point(PenTool *pc, Geom::Point const p); -//Añade los modos spiro y bspline +//spanish: añade los modos spiro y bspline static void sp_pen_context_set_mode(PenTool *const pc, guint mode); -//Esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro +//spanish: esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro static void bspline_spiro_color(PenTool *const pc); -//Crea un nodo en modo bspline o spiro +//spanish: crea un nodo en modo bspline o spiro static void bspline_spiro(PenTool *const pc,bool shift); -//Crea un nodo de modo spiro o bspline +//spanish: crea un nodo de modo spiro o bspline static void bspline_spiro_on(PenTool *const pc); -//Crea un nodo de tipo CUSP +//spanish: crea un nodo de tipo CUSP static void bspline_spiro_off(PenTool *const pc); -//Continua una curva existente en modo bspline o spiro +//spanish: continua una curva existente en modo bspline o spiro static void bspline_spiro_start_anchor(PenTool *const pc,bool shift); -//Continua una curva exsitente con el nodo de union en modo bspline o spiro +//spanish: continua una curva exsitente con el nodo de union en modo bspline o spiro static void bspline_spiro_start_anchor_on(PenTool *const pc); -//Continua una curva existente con el nodo de union en modo CUSP +//spanish: continua una curva existente con el nodo de union en modo CUSP static void bspline_spiro_start_anchor_off(PenTool *const pc); -//Modifica la "red_curve" cuando se detecta movimiento +//spanish: modifica la "red_curve" cuando se detecta movimiento static void bspline_spiro_motion(PenTool *const pc,bool shift); -//Cierra la curva con el último nodo en modo bspline o spiro +//spanish: cierra la curva con el último nodo en modo bspline o spiro static void bspline_spiro_end_anchor_on(PenTool *const pc); -//Cierra la curva con el último nodo en modo CUSP +//spanish: cierra la curva con el último nodo en modo CUSP static void bspline_spiro_end_anchor_off(PenTool *const pc); -//Unimos todas las curvas en juego y llamamos a la función doEffect. +//spanish: unimos todas las curvas en juego y llamamos a la función doEffect. static void bspline_spiro_build(PenTool *const pc); //function bspline cloned from lpe-bspline.cpp static void bspline_doEffect(SPCurve * curve); @@ -195,6 +195,7 @@ PenTool::~PenTool() { void sp_pen_context_set_polyline_mode(PenTool *const pc) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); guint mode = prefs->getInt("/tools/freehand/pen/freehand-mode", 0); + //spanish: cambiamos los modos para dar cabida al modo bspline pc->polylines_only = (mode == 3 || mode == 4); pc->polylines_paraxial = (mode == 4); //we call the function which defines the Spiro modes and the BSpline @@ -206,6 +207,7 @@ void sp_pen_context_set_polyline_mode(PenTool *const pc) { *.Set the mode of draw spiro, and bsplines */ void sp_pen_context_set_mode(PenTool *const pc, guint mode) { + //spanish: definimos los modos pc->spiro = (mode == 1); pc->bspline = (mode == 2); } @@ -474,7 +476,7 @@ static gint pen_handle_button_press(PenTool *const pc, GdkEventButton const &bev // Set start anchor pc->sa = anchor; - //Continuamos una curva existente + //spanish: continuamos una curva existente if(anchor){ bspline_spiro_start_anchor(pc,(bevent.state & GDK_SHIFT_MASK)); } @@ -529,7 +531,7 @@ static gint pen_handle_button_press(PenTool *const pc, GdkEventButton const &bev } } - //Evitamos la creación de un punto de control para que se cree el nodo en el evento de soltar + //spanish: evitamos la creación de un punto de control para que se cree el nodo en el evento de soltar pc->state = (pc->spiro || pc->bspline || pc->polylines_only) ? PenTool::POINT : PenTool::CONTROL; ret = TRUE; @@ -597,9 +599,8 @@ static gint pen_handle_motion_notify(PenTool *const pc, GdkEventMotion const &me //we take out the function the const "tolerance" because we need it later Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gint const tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); - //"spiro_color" lo ejecutamos siempre sea o no spiro if (pen_within_tolerance) { - if ( Geom::LInfty( event_w - pen_drag_origin_w ) < tolerance) { + if ( Geom::LInfty( event_w - pen_drag_origin_w ) < tolerance ) { return FALSE; // Do not drag if we're within tolerance from origin. } } @@ -610,8 +611,10 @@ static gint pen_handle_motion_notify(PenTool *const pc, GdkEventMotion const &me // Find desktop coordinates Geom::Point p = dt->w2d(event_w); + // Test, whether we hit any anchor SPDrawAnchor *anchor = spdc_test_inside(pc, event_w); + switch (pc->mode) { case PenTool::MODE_CLICK: switch (pc->state) { @@ -691,7 +694,9 @@ static gint pen_handle_motion_notify(PenTool *const pc, GdkEventMotion const &me case PenTool::CONTROL: case PenTool::CLOSE: // Placing controls is last operation in CLOSE state + // snap the handle + spdc_endpoint_snap_handle(pc, p, mevent.state); if (!pc->polylines_only) { spdc_pen_set_ctrl(pc, p, mevent.state); @@ -718,7 +723,7 @@ static gint pen_handle_motion_notify(PenTool *const pc, GdkEventMotion const &me default: break; } - //Lanzamos la función "bspline_spiro_motion" al moverse el ratón o cuando se para. + //spanish: lanzamos la función "bspline_spiro_motion" al moverse el ratón o cuando se para. if(pc->bspline){ bspline_spiro_color(pc); bspline_spiro_motion(pc,(mevent.state & GDK_SHIFT_MASK)); @@ -759,7 +764,7 @@ static gint pen_handle_button_release(PenTool *const pc, GdkEventButton const &r SPDrawAnchor *anchor = spdc_test_inside(pc, event_w); //with this we avoid creating a new point over the existing one if(pc->spiro || pc->bspline){ - //Si intentamos crear un nodo en el mismo sitio que el origen, paramos. + //spanish: si intentamos crear un nodo en el mismo sitio que el origen, paramos. if(pc->npoints > 0 && pc->p[0] == pc->p[3]){ return FALSE; } @@ -775,7 +780,7 @@ static gint pen_handle_button_release(PenTool *const pc, GdkEventButton const &r p = anchor->dp; } pc->sa = anchor; - //continuamos una curva existente + //spanish: continuamos una curva existente if (anchor) { if(pc->bspline || pc->spiro){ bspline_spiro_start_anchor(pc,(revent.state & GDK_SHIFT_MASK)); @@ -805,7 +810,7 @@ static gint pen_handle_button_release(PenTool *const pc, GdkEventButton const &r spdc_endpoint_snap(pc, p, revent.state); } spdc_pen_finish_segment(pc, p, revent.state); - //Ocultamos la guia del penultimo nodo al cerrar la curva + //spanish: ocultamos la guia del penultimo nodo al cerrar la curva if(pc->spiro){ sp_canvas_item_hide(pc->c1); } @@ -832,7 +837,7 @@ static gint pen_handle_button_release(PenTool *const pc, GdkEventButton const &r case PenTool::CLOSE: spdc_endpoint_snap(pc, p, revent.state); spdc_pen_finish_segment(pc, p, revent.state); - //Ocultamos la guia del penultimo nodo al cerrar la curva + //spanish: ocultamos la guia del penultimo nodo al cerrar la curva if(pc->spiro){ sp_canvas_item_hide(pc->c1); } @@ -925,7 +930,7 @@ static void pen_redraw_all (PenTool *const pc) sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), pc->red_curve); // handles - //Ocultamos los tiradores en modo BSpline y spiro + //spanish: ocultamos los tiradores en modo bspline y spiro if (pc->p[0] != pc->p[1] && !pc->spiro && !pc->bspline) { SP_CTRL(pc->c1)->moveto(pc->p[1]); pc->cl1->setCoords(pc->p[0], pc->p[1]); @@ -939,7 +944,7 @@ static void pen_redraw_all (PenTool *const pc) Geom::Curve const * last_seg = pc->green_curve->last_segment(); if (last_seg) { Geom::CubicBezier const * cubic = dynamic_cast( last_seg ); - //Ocultamos los tiradores en modo BSpline y spiro + //spanish: ocultamos los tiradores en modo bspline y spiro if ( cubic && (*cubic)[2] != pc->p[0] && !pc->spiro && !pc->bspline ) { @@ -954,9 +959,8 @@ static void pen_redraw_all (PenTool *const pc) } } - //Simplemente redibujamos la spiro teniendo en cuenta si el nodo es cusp o symm. - //como es un redibujo simplemente no llamamos a la función global - //sino al final de esta + //spanish: simplemente redibujamos la spiro teniendo en cuenta si el nodo es cusp o symm. + //como es un redibujo simplemente no llamamos a la función global sino al final de esta //Lanzamos solamente el redibujado bspline_spiro_build(pc); } @@ -989,12 +993,12 @@ static void pen_lastpoint_move_screen (PenTool *const pc, gdouble x, gdouble y) static void pen_lastpoint_tocurve (PenTool *const pc) { - //Evitamos que si la "red_curve" tiene solo dos puntos -recta- no se pare aqui. + //spanish: evitamos que si la "red_curve" tiene solo dos puntos -recta- no se pare aqui. if (pc->npoints != 5 && !pc->spiro && !pc->bspline) return; Geom::CubicBezier const * cubic; pc->p[1] = pc->red_curve->last_segment()->initialPoint() + (1./3)* (Geom::Point)(pc->red_curve->last_segment()->finalPoint() - pc->red_curve->last_segment()->initialPoint()); - //Modificamos el último segmento de la curva verde para que forme el tipo de nodo que deseamos + //spanish: modificamos el último segmento de la curva verde para que forme el tipo de nodo que deseamos if(pc->spiro||pc->bspline){ if(!pc->green_curve->is_empty()){ Geom::Point A(0,0); @@ -1032,7 +1036,7 @@ static void pen_lastpoint_tocurve (PenTool *const pc) pc->green_curve->append_continuous(previous, 0.0625); } } - //Si el último nodo es una union con otra curva + //spanish: si el último nodo es una union con otra curva if(pc->green_curve->is_empty() && pc->sa && !pc->sa->curve->is_empty()){ bspline_spiro_start_anchor(pc, false); } @@ -1043,11 +1047,11 @@ static void pen_lastpoint_tocurve (PenTool *const pc) static void pen_lastpoint_toline (PenTool *const pc) { - //Evitamos que si la "red_curve" tiene solo dos puntos -recta- no se pare aqui. + //spanish: evitamos que si la "red_curve" tiene solo dos puntos -recta- no se pare aqui. if (pc->npoints != 5 && !pc->bspline) return; - //Modificamos el último segmento de la curva verde para que forme el tipo de nodo que deseamos + //spanish: modificamos el último segmento de la curva verde para que forme el tipo de nodo que deseamos if(pc->spiro || pc->bspline){ if(!pc->green_curve->is_empty()){ Geom::Point A(0,0); @@ -1079,7 +1083,7 @@ static void pen_lastpoint_toline (PenTool *const pc) pc->green_curve->append_continuous(previous, 0.0625); } } - //Si el último nodo es una union con otra curva + //spanish: si el último nodo es una union con otra curva if(pc->green_curve->is_empty() && pc->sa && !pc->sa->curve->is_empty()){ bspline_spiro_start_anchor(pc, true); } @@ -1268,7 +1272,7 @@ static gint pen_handle_key_press(PenTool *const pc, GdkEvent *event) } else { pc->p[1] = pc->p[0]; } - //Asignamos el valor a un tercio de distancia del último segmento. + //spanish: asignamos el valor a un tercio de distancia del último segmento. if(pc->bspline){ pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]); } @@ -1278,7 +1282,7 @@ static gint pen_handle_key_press(PenTool *const pc, GdkEvent *event) : pc->p[3])); pc->npoints = 2; - //Eliminamos el último segmento de la curva verde + //spanish: eliminamos el último segmento de la curva verde if( pc->green_curve->get_segment_count() == 1){ pc->npoints = 5; if (pc->green_bpaths) { @@ -1290,7 +1294,7 @@ static gint pen_handle_key_press(PenTool *const pc, GdkEvent *event) }else{ pc->green_curve->backspace(); } - //Asignamos el valor de pc->p[1] a el opuesto de el ultimo segmento de la línea verde + //spanish: asignamos el valor de pc->p[1] a el opuesto de el ultimo segmento de la línea verde if(pc->spiro){ cubic = dynamic_cast(pc->green_curve->last_segment()); if ( cubic ) { @@ -1305,7 +1309,7 @@ static gint pen_handle_key_press(PenTool *const pc, GdkEvent *event) pc->state = PenTool::POINT; spdc_pen_set_subsequent_point(pc, pt, true); pen_last_paraxial_dir = !pen_last_paraxial_dir; - //Redibujamos + //spanish: redibujamos bspline_spiro_build(pc); ret = TRUE; } @@ -1381,7 +1385,7 @@ static void spdc_pen_set_angle_distance_status_message(PenTool *const pc, Geom:: } -//Esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro +//spanish: esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro static void bspline_spiro_color(PenTool *const pc) { bool remake_green_bpaths = false; @@ -1719,7 +1723,7 @@ static void bspline_spiro_end_anchor_off(PenTool *const pc) } -//preparates the curves for its trasformation into BSline curves. +//spanish: preparates the curves for its trasformation into BSline curves. static void bspline_spiro_build(PenTool *const pc) { if(!pc->spiro && !pc->bspline) @@ -1748,7 +1752,7 @@ static void bspline_spiro_build(PenTool *const pc) } if(!curve->is_empty()){ - //cerramos la curva si estan cerca los puntos finales de la curva spiro + //spanish: cerramos la curva si estan cerca los puntos finales de la curva spiro if(Geom::are_near(curve->first_path()->initialPoint(), curve->last_path()->finalPoint())){ curve->closepath_current(); } @@ -1787,26 +1791,19 @@ static void bspline_spiro_build(PenTool *const pc) static void bspline_doEffect(SPCurve * curve) { + //spanish: comentado en funcion "doEffect" de src/live_effects/lpe-bspline.cpp if(curve->get_segment_count() < 2) return; - // Make copy of old path as it is changed during processing Geom::PathVector const original_pathv = curve->get_pathvector(); curve->reset(); - //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { - //Si está vacío... if (path_it->empty()) continue; - //Itreadores - + Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop - //Creamos las lineas rectas que unen todos los puntos del trazado y donde se calcularán - //los puntos clave para los manejadores. - //Esto hace que la curva BSpline no pierda su condición aunque se trasladen - //dichos manejadores SPCurve *nCurve = new SPCurve(); Geom::Point previousNode(0,0); Geom::Point node(0,0); @@ -1820,23 +1817,13 @@ static void bspline_doEffect(SPCurve * curve) Geom::D2< Geom::SBasis > SBasisHelper; Geom::CubicBezier const *cubic = NULL; if (path_it->closed()) { - // if the path is closed, maybe we have to stop a bit earlier because the closing line segment has zerolength. const Geom::Curve &closingline = path_it->back_closed(); // the closing line segment is always of type Geom::LineSegment. if (are_near(closingline.initialPoint(), closingline.finalPoint())) { - // closingline.isDegenerate() did not work, because it only checks for *exact* zero length, which goes wrong for relative coordinates and rounding errors... - // the closing line segment has zero-length. So stop before that one! curve_endit = path_it->end_open(); } } - //Si la curva está cerrada calculamos el punto donde - //deveria estar el nodo BSpline de cierre/inicio de la curva - //en posible caso de que se cierre con una linea recta creando un nodo BSPline - - //Recorremos todos los segmentos menos el último while ( curve_it2 != curve_endit ) { - //previousPointAt3 = pointAt3; - //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida SPCurve * in = new SPCurve(); in->moveto(curve_it1->initialPoint()); in->lineto(curve_it1->finalPoint()); @@ -1851,8 +1838,6 @@ static void bspline_doEffect(SPCurve * curve) } in->reset(); delete in; - //Y hacemos lo propio con el path de salida - //nextPointAt0 = curveOut.valueAt(0); SPCurve * out = new SPCurve(); out->moveto(curve_it2->initialPoint()); out->lineto(curve_it2->finalPoint()); @@ -1869,37 +1854,25 @@ static void bspline_doEffect(SPCurve * curve) } out->reset(); delete out; - //La curva BSpline se forma calculando el centro del segmanto de unión - //de el punto situado en las 2/3 partes de el segmento de entrada - //con el punto situado en la posición 1/3 del segmento de salida - //Estos dos puntos ademas estan posicionados en el lugas correspondiente de - //los manejadores de la curva SPCurve *lineHelper = new SPCurve(); lineHelper->moveto(pointAt2); lineHelper->lineto(nextPointAt1); SBasisHelper = lineHelper->first_segment()->toSBasis(); lineHelper->reset(); delete lineHelper; - //almacenamos el punto del anterior bucle -o el de cierre- que nos hara de principio de curva previousNode = node; - //Y este hará de final de curva node = SBasisHelper.valueAt(0.5); SPCurve *curveHelper = new SPCurve(); curveHelper->moveto(previousNode); curveHelper->curveto(pointAt1, pointAt2, node); - //añadimos la curva generada a la curva pricipal nCurve->append_continuous(curveHelper, 0.0625); curveHelper->reset(); delete curveHelper; - //aumentamos los valores para el siguiente paso en el bucle ++curve_it1; ++curve_it2; } - //Aberiguamos la ultima parte de la curva correspondiente al último segmento SPCurve *curveHelper = new SPCurve(); curveHelper->moveto(node); - //Si está cerrada la curva, la cerramos sobre el valor guardado previamente - //Si no finalizamos en el punto final Geom::Point startNode(0,0); if (path_it->closed()) { SPCurve * start = new SPCurve(); @@ -1920,7 +1893,6 @@ static void bspline_doEffect(SPCurve * curve) end->moveto(curve_it1->initialPoint()); end->lineto(curve_it1->finalPoint()); Geom::D2< Geom::SBasis > SBasisEnd = end->first_segment()->toSBasis(); - //Geom::BezierCurve const *bezier = dynamic_cast(&*curve_endit); cubic = dynamic_cast(&*curve_it1); if(cubic){ lineHelper->lineto(SBasisEnd.valueAt(Geom::nearest_point((*cubic)[2],*end->first_segment()))); @@ -1932,7 +1904,6 @@ static void bspline_doEffect(SPCurve * curve) SBasisHelper = lineHelper->first_segment()->toSBasis(); lineHelper->reset(); delete lineHelper; - //Guardamos el principio de la curva startNode = SBasisHelper.valueAt(0.5); curveHelper->curveto(nextPointAt1, nextPointAt2, startNode); nCurve->append_continuous(curveHelper, 0.0625); @@ -1950,7 +1921,6 @@ static void bspline_doEffect(SPCurve * curve) } curveHelper->reset(); delete curveHelper; - //y cerramos la curva if (path_it->closed()) { nCurve->closepath_current(); } @@ -1961,12 +1931,12 @@ static void bspline_doEffect(SPCurve * curve) } //Spiro function cloned from lpe-spiro.cpp +//spanish: comentado en funcion "doEffect" de src/live_effects/lpe-spiro.cpp static void spiro_doEffect(SPCurve * curve) { using Geom::X; using Geom::Y; - // Make copy of old path as it is changed during processing Geom::PathVector const original_pathv = curve->get_pathvector(); guint len = curve->get_segment_count() + 2; @@ -1978,41 +1948,31 @@ static void spiro_doEffect(SPCurve * curve) if (path_it->empty()) continue; - // start of path { Geom::Point p = path_it->front().pointAt(0); path[ip].x = p[X]; path[ip].y = p[Y]; - path[ip].ty = '{' ; // for closed paths, this is overwritten + path[ip].ty = '{' ; ip++; } - // midpoints - Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve - Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve + Geom::Path::const_iterator curve_it1 = path_it->begin(); + Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); - Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop + Geom::Path::const_iterator curve_endit = path_it->end_default(); if (path_it->closed()) { - // if the path is closed, maybe we have to stop a bit earlier because the closing line segment has zerolength. - const Geom::Curve &closingline = path_it->back_closed(); // the closing line segment is always of type Geom::LineSegment. + const Geom::Curve &closingline = path_it->back_closed(); if (are_near(closingline.initialPoint(), closingline.finalPoint())) { - // closingline.isDegenerate() did not work, because it only checks for *exact* zero length, which goes wrong for relative coordinates and rounding errors... - // the closing line segment has zero-length. So stop before that one! curve_endit = path_it->end_open(); } } while ( curve_it2 != curve_endit ) { - /* This deals with the node between curve_it1 and curve_it2. - * Loop to end_default (so without last segment), loop ends when curve_it2 hits the end - * and then curve_it1 points to end or closing segment */ Geom::Point p = curve_it1->finalPoint(); path[ip].x = p[X]; path[ip].y = p[Y]; - // Determine type of spiro node this is, determined by the tangents (angles) of the curves - // TODO: see if this can be simplified by using /helpers/geom-nodetype.cpp:get_nodetype bool this_is_line = is_straight_curve(*curve_it1); bool next_is_line = is_straight_curve(*curve_it2); @@ -2036,15 +1996,13 @@ static void spiro_doEffect(SPCurve * curve) ip++; } - // add last point to the spiropath Geom::Point p = curve_it1->finalPoint(); path[ip].x = p[X]; path[ip].y = p[Y]; if (path_it->closed()) { - // curve_it1 points to the (visually) closing segment. determine the match between first and this last segment (the closing node) Geom::NodeType nodetype = Geom::get_nodetype(*curve_it1, path_it->front()); switch (nodetype) { - case Geom::NODE_NONE: // can't happen! but if it does, it means the path isn't closed :-) + case Geom::NODE_NONE: path[ip].ty = '}'; ip++; break; @@ -2057,12 +2015,10 @@ static void spiro_doEffect(SPCurve * curve) break; } } else { - // set type to path closer path[ip].ty = '}'; ip++; } - // run subpath through spiro int sp_len = ip; Spiro::spiro_run(path, sp_len, *curve); ip = 0; diff --git a/src/ui/tools/pen-tool.h b/src/ui/tools/pen-tool.h index b0b56feb4..4f87429f4 100644 --- a/src/ui/tools/pen-tool.h +++ b/src/ui/tools/pen-tool.h @@ -48,7 +48,7 @@ public: bool polylines_only; bool polylines_paraxial; - //Propiedad que guarda si el modo Spiro está activo o no + //spanish: propiedad que guarda si el modo Spiro está activo o no bool spiro; bool bspline; int num_clicks; -- cgit v1.2.3 From d8a7188e7a73050e329103b79e769b8fa498ede5 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 31 Dec 2013 01:04:31 +0100 Subject: Spanish comment of pencil-tool.cpp (bzr r11950.1.227) --- src/ui/tools/pencil-tool.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp index 2027f0981..883b3fa36 100644 --- a/src/ui/tools/pencil-tool.cpp +++ b/src/ui/tools/pencil-tool.cpp @@ -728,7 +728,7 @@ interpolate(PencilTool *pc) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); guint mode = prefs->getInt("/tools/freehand/pencil/freehand-mode", 0); for (int c = 0; c < n_segs; c++) { - //Si el modo es BSpline modificamos para que el trazado cree los nodos adhoc + //spanish: si el modo es BSpline modificamos para que el trazado cree los nodos adhoc if(mode == 2){ Geom::Point BP = b[4*c+0] + (1./3)*(b[4*c+3] - b[4*c+0]); BP = Geom::Point(BP[X] + 0.0001,BP[Y] + 0.0001); @@ -880,7 +880,7 @@ fit_and_split(PencilTool *pc) pc->red_curve->moveto(b[0]); using Geom::X; using Geom::Y; - //Si el modo es BSpline modificamos para que el trazado cree los nodos adhoc + //spanish: si el modo es BSpline modificamos para que el trazado cree los nodos adhoc Inkscape::Preferences *prefs = Inkscape::Preferences::get(); guint mode = prefs->getInt("/tools/freehand/pencil/freehand-mode", 0); if(mode == 2){ -- cgit v1.2.3 From b28d4dbc9e7ad573973f557afcec89dd005c9d96 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 31 Dec 2013 01:06:03 +0100 Subject: refactor, fixing some diff diferences (bzr r11950.1.228) --- src/widgets/toolbox.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 901276620..02da805bf 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -115,6 +115,7 @@ enum BarId { BAR_COMMANDS, BAR_SNAP, }; + #define BAR_ID_KEY "BarIdValue" #define HANDLE_POS_MARK "x-inkscape-pos" -- cgit v1.2.3 From 3e2698fd64dbf8c63b1efc758be5b3a1c30fe1fc Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 31 Dec 2013 01:42:32 +0100 Subject: fix a bug whith degenerate handles (bzr r11950.1.229) --- src/ui/tool/node.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 9eab1d7dc..a932e5b7b 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -764,7 +764,7 @@ void Node::showHandles(bool v) //Cada vez que actuemos sobre dichos tiradores en un trazado //bspline esta fuerza se tiene que actualizar this->bsplineWeight = 0.0000; - if(_pm().isBSpline) + if(_pm().isBSpline && (!_front.isDegenerate() || !_back.isDegenerate())) this->bsplineWeight = 0.3334; } -- cgit v1.2.3 From c08c28e9a22f0fe5f06e9dc34430c3acb16f3c13 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 2 Jan 2014 16:15:27 +0100 Subject: Fixed a boring bug sometimes curves be converted to lines, increasing a bit the distance from the handle to the line (bzr r11950.1.230) --- src/ui/tool/node.cpp | 21 ++++++++++++++++++--- src/ui/tool/path-manipulator.cpp | 6 ++---- src/ui/tools/pen-tool.cpp | 29 +++++++++++++++++------------ 3 files changed, 37 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index a932e5b7b..39b21ae6d 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -1388,6 +1388,12 @@ Node *Node::nodeAwayFrom(Handle *h) Glib::ustring Node::_getTip(unsigned state) const { + //spanish: un truco par, si el nodo tiene fuerza, nos marca que es + //del tipo bspline, lo utilizaremos despues para mostras los mensajes apropiados + //no lo podemos hacer de otra forma al ser constante la funcion + bool isBSpline = false; + if( this->bsplineWeight != 0.0000) + isBSpline = true; if (state_held_shift(state)) { bool can_drag_out = (_next() && _front.isDegenerate()) || (_prev() && _back.isDegenerate()); if (can_drag_out) { @@ -1417,15 +1423,24 @@ Glib::ustring Node::_getTip(unsigned state) const // No modifiers: assemble tip from node type char const *nodetype = node_type_to_localized_string(_type); if (_selection.transformHandlesEnabled() && selected()) { - if (_selection.size() == 1) { + if (_selection.size() == 1 && !isBSpline) { return format_tip(C_("Path node tip", "%s: drag to shape the path (more: Shift, Ctrl, Alt)"), nodetype); + }else if(_selection.size() == 1){ + return format_tip(C_("Path node tip", + "BSpline node: %g weight, drag to shape the path (more: Shift, Ctrl, Alt)"),this->bsplineWeight); } return format_tip(C_("Path node tip", "%s: drag to shape the path, click to toggle scale/rotation handles (more: Shift, Ctrl, Alt)"), nodetype); } - return format_tip(C_("Path node tip", - "%s: drag to shape the path, click to select only this node (more: Shift, Ctrl, Alt)"), nodetype); + if (!isBSpline) { + return format_tip(C_("Path node tip", + "%s: drag to shape the path, click to select only this node (more: Shift, Ctrl, Alt)"), nodetype); + }else{ + return format_tip(C_("Path node tip", + "BSpline node: drag to shape the path, click to select only this node (more: Shift, Ctrl, Alt)")); + + } } Glib::ustring Node::_getDragTip(GdkEventMotion */*event*/) const diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index e70717728..cda8374c5 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1219,13 +1219,11 @@ double PathManipulator::BSplineHandlePosition(Handle *h){ Node *n = h->parent(); Node * nextNode = NULL; nextNode = n->nodeToward(h); - Geom::Point positionH = h->position(); - positionH = Geom::Point(positionH[X] + 0.0001,positionH[Y] + 0.0001); if(nextNode && n->position() != h->position()){ SPCurve *lineInsideNodes = new SPCurve(); lineInsideNodes->moveto(n->position()); lineInsideNodes->lineto(nextNode->position()); - pos = Geom::nearest_point(positionH,*lineInsideNodes->first_segment()); + pos = Geom::nearest_point(h->position(),*lineInsideNodes->first_segment()); } return pos; } @@ -1252,7 +1250,7 @@ Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){ SBasisInsideNodes = lineInsideNodes->first_segment()->toSBasis(); n->bsplineWeight = pos; ret = SBasisInsideNodes.valueAt(pos); - ret = Geom::Point(ret[X] + 0.0001,ret[Y] + 0.0001); + ret = Geom::Point(ret[X] + 0.005,ret[Y] + 0.005); }else{ if(pos == 0.0000){ n->bsplineWeight = 0.0000; diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 9b5acb6cc..a48f8911a 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -959,7 +959,7 @@ static void pen_redraw_all (PenTool *const pc) } } - //spanish: simplemente redibujamos la spiro teniendo en cuenta si el nodo es cusp o symm. + //spanish: simplemente redibujamos la spiro. //como es un redibujo simplemente no llamamos a la función global sino al final de esta //Lanzamos solamente el redibujado bspline_spiro_build(pc); @@ -1451,7 +1451,7 @@ static void bspline_spiro_on(PenTool *const pc) pc->p[0] = pc->red_curve->first_segment()->initialPoint(); pc->p[3] = pc->red_curve->first_segment()->finalPoint(); pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); - pc->p[2] = Geom::Point(pc->p[2][X] + 0.0001,pc->p[2][Y] + 0.0001); + pc->p[2] = Geom::Point(pc->p[2][X] + 0.005,pc->p[2][Y] + 0.005); } } @@ -1492,7 +1492,7 @@ static void bspline_spiro_start_anchor_on(PenTool *const pc) Geom::Point A = tmpCurve->last_segment()->initialPoint(); Geom::Point D = tmpCurve->last_segment()->finalPoint(); Geom::Point C = D + (1./3)*(A - D); - C = Geom::Point(C[X] + 0.0001,C[Y] + 0.0001); + C = Geom::Point(C[X] + 0.005,C[Y] + 0.005); if(cubic){ lastSeg->moveto(A); lastSeg->curveto((*cubic)[1],C,D); @@ -1549,19 +1549,23 @@ static void bspline_spiro_motion(PenTool *const pc, bool shift){ using Geom::X; using Geom::Y; + if(pc->red_curve->is_empty()) return; + pc->npoints = 5; SPCurve *tmpCurve = new SPCurve(); pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); + pc->p[2] = Geom::Point(pc->p[2][X] + 0.005,pc->p[2][Y] + 0.005); if(pc->green_curve->is_empty() && !pc->sa){ pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]); + pc->p[1] = Geom::Point(pc->p[1][X] + 0.005,pc->p[1][Y] + 0.005); }else if(!pc->green_curve->is_empty()){ tmpCurve = pc->green_curve->copy(); }else{ tmpCurve = pc->sa->curve->copy(); if(pc->sa->start) tmpCurve = tmpCurve->create_reverse(); - } - if(!tmpCurve->is_empty() && !pc->red_curve->is_empty()){ + + if(!tmpCurve->is_empty()){ Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); if(cubic){ if(pc->bspline){ @@ -1577,16 +1581,17 @@ static void bspline_spiro_motion(PenTool *const pc, bool shift){ WPower->reset(); pc->p[1] = SBasisWPower.valueAt(WP); if(!Geom::are_near(pc->p[1],pc->p[0])) - pc->p[1] = Geom::Point(pc->p[1][X] + 0.0001,pc->p[1][Y] + 0.0001); + pc->p[1] = Geom::Point(pc->p[1][X] + 0.005,pc->p[1][Y] + 0.005); if(shift) - pc->p[2]=pc->p[3]; - else - pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); + pc->p[2] = pc->p[3]; }else{ pc->p[1] = (*cubic)[3] + (Geom::Point)((*cubic)[3] - (*cubic)[2] ); + pc->p[1] = Geom::Point(pc->p[1][X] + 0.005,pc->p[1][Y] + 0.005); } }else{ pc->p[1] = pc->p[0]; + if(shift) + pc->p[2] = pc->p[3]; } } @@ -1606,7 +1611,7 @@ static void bspline_spiro_end_anchor_on(PenTool *const pc) using Geom::X; using Geom::Y; pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]); - pc->p[2] = Geom::Point(pc->p[2][X] + 0.0001,pc->p[2][Y] + 0.0001); + pc->p[2] = Geom::Point(pc->p[2][X] + 0.005,pc->p[2][Y] + 0.005); SPCurve *tmpCurve = new SPCurve(); SPCurve *lastSeg = new SPCurve(); Geom::Point C(0,0); @@ -1616,7 +1621,7 @@ static void bspline_spiro_end_anchor_on(PenTool *const pc) Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); if(pc->bspline){ C = tmpCurve->last_segment()->finalPoint() + (1./3)*(tmpCurve->last_segment()->initialPoint() - tmpCurve->last_segment()->finalPoint()); - C = Geom::Point(C[X] + 0.0001,C[Y] + 0.0001); + C = Geom::Point(C[X] + 0.005,C[Y] + 0.005); }else{ C = pc->p[3] + (Geom::Point)(pc->p[3] - pc->p[2] ); } @@ -1645,7 +1650,7 @@ static void bspline_spiro_end_anchor_on(PenTool *const pc) Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); if(pc->bspline){ C = tmpCurve->last_segment()->finalPoint() + (1./3)*(tmpCurve->last_segment()->initialPoint() - tmpCurve->last_segment()->finalPoint()); - C = Geom::Point(C[X] + 0.0001,C[Y] + 0.0001); + C = Geom::Point(C[X] + 0.005,C[Y] + 0.005); }else{ C = pc->p[3] + (Geom::Point)(pc->p[3] - pc->p[2] ); } -- cgit v1.2.3 From 0b15b05d641661e6b1d5cb73520c7cdead1cfc89 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 9 Jan 2014 17:46:40 +0100 Subject: Fix a bug whith oposite handles on node move,and a little cleanup (bzr r11950.1.232) --- src/ui/tool/node.cpp | 18 ++++++++++-------- src/ui/tool/path-manipulator.cpp | 7 +------ 2 files changed, 11 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 39b21ae6d..63556e499 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -170,7 +170,6 @@ void Handle::move(Geom::Point const &new_pos) //spanish: mueve el tirador y su opuesto la misma proporción if(_pm().isBSpline){ setPosition(_pm().BSplineHandleReposition(this)); - _parent->bsplineWeight = _pm().BSplineHandlePosition(this); this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),_parent->bsplineWeight)); } return; @@ -188,7 +187,6 @@ void Handle::move(Geom::Point const &new_pos) //spanish: mueve el tirador y su opuesto la misma proporción if(_pm().isBSpline){ setPosition(_pm().BSplineHandleReposition(this)); - _parent->bsplineWeight = _pm().BSplineHandlePosition(this); this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),_parent->bsplineWeight)); } @@ -215,7 +213,6 @@ void Handle::move(Geom::Point const &new_pos) //spanish: mueve el tirador y su opuesto la misma proporción if(_pm().isBSpline){ setPosition(_pm().BSplineHandleReposition(this)); - _parent->bsplineWeight = _pm().BSplineHandlePosition(this); this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),_parent->bsplineWeight)); } @@ -310,7 +307,6 @@ bool Handle::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEven void Handle::handle_2button_press(){ if(_pm().isBSpline){ setPosition(_pm().BSplineHandleReposition(this,0.3334)); - _parent->bsplineWeight = 0.3334; this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),_parent->bsplineWeight)); _pm().update(); } @@ -764,8 +760,14 @@ void Node::showHandles(bool v) //Cada vez que actuemos sobre dichos tiradores en un trazado //bspline esta fuerza se tiene que actualizar this->bsplineWeight = 0.0000; - if(_pm().isBSpline && (!_front.isDegenerate() || !_back.isDegenerate())) - this->bsplineWeight = 0.3334; + if(_pm().isBSpline && (!_front.isDegenerate() || !_back.isDegenerate())){ + if (!_front.isDegenerate()) { + _pm().BSplineHandlePosition(&_front); + } + if (!_back.isDegenerate()) { + _pm().BSplineHandlePosition(&_back); + } + } } void Node::updateHandles() @@ -1125,9 +1127,9 @@ void Node::_setState(State state) //spanish: esto muestra los tiradores al seleccionar los nodos if(_pm().isBSpline){ if(!this->back()->isDegenerate()){ - this->bsplineWeight = _pm().BSplineHandlePosition(this->back()); + _pm().BSplineHandlePosition(this->back()); }else if (!this->front()->isDegenerate()){ - this->bsplineWeight = _pm().BSplineHandlePosition(this->front()); + _pm().BSplineHandlePosition(this->front()); }else{ this->bsplineWeight = 0.0000; } diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index cda8374c5..8a0568fbd 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1225,6 +1225,7 @@ double PathManipulator::BSplineHandlePosition(Handle *h){ lineInsideNodes->lineto(nextNode->position()); pos = Geom::nearest_point(h->position(),*lineInsideNodes->first_segment()); } + n->bsplineWeight = pos; return pos; } @@ -1265,17 +1266,11 @@ void PathManipulator::BSplineNodeHandlesReposition(Node *n){ Node * nextNode = n->nodeToward(n->front()); Node * prevNode = n->nodeToward(n->back()); if(prevNode){ - n->back()->setPosition(BSplineHandleReposition(n->back(),n->bsplineWeight)); - if(prevNode->front()->position() == prevNode->position()) - prevNode->bsplineWeight = 0.000; if(!prevNode->isEndNode()) prevNode->back()->setPosition(BSplineHandleReposition(prevNode->back(),prevNode->bsplineWeight)); prevNode->front()->setPosition(BSplineHandleReposition(prevNode->front(),prevNode->bsplineWeight)); } if(nextNode){ - n->front()->setPosition(BSplineHandleReposition(n->front(),n->bsplineWeight)); - if(nextNode->front()->position() == nextNode->position()) - nextNode->bsplineWeight = 0.000; if(!nextNode->isEndNode()) nextNode->front()->setPosition(BSplineHandleReposition(nextNode->front(),nextNode->bsplineWeight)); nextNode->back()->setPosition(BSplineHandleReposition(nextNode->back(),nextNode->bsplineWeight)); -- cgit v1.2.3 From 7af8d4e83411f23c762da6bfbd2130e76923df7f Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 30 Jan 2014 19:34:23 +0100 Subject: show outline like normal paths, by good su_v suggestion (bzr r11950.1.239) --- src/ui/tool/path-manipulator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 7bbe39f8d..654e1fa5d 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -911,8 +911,8 @@ void PathManipulator::showHandles(bool show) /** Set the visibility of outline. */ void PathManipulator::showOutline(bool show) { - if(isBSpline) show = true; - if (show == _show_outline) return; + //if(isBSpline) show = true; + //if (show == _show_outline) return; _show_outline = show; _updateOutline(); } -- cgit v1.2.3 From 2563a8cae7411cfee682cbd306f43d5721908c42 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 30 Jan 2014 19:45:02 +0100 Subject: show outline by default in bspline, tnx to su_v suggestion (bzr r11950.1.241) --- src/ui/tool/path-manipulator.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 654e1fa5d..da364926a 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -148,6 +148,9 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, _createControlPointsFromGeometry(); BSpline(); + if(isBSpline){ + _show_outline(true); + } } PathManipulator::~PathManipulator() -- cgit v1.2.3 From e582ac68a9ebeca19cc10c47fb6b57a514937278 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 30 Jan 2014 19:52:10 +0100 Subject: fix bug compiling (bzr r11950.1.242) --- src/ui/tool/path-manipulator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index da364926a..83af89732 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -149,7 +149,7 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, _createControlPointsFromGeometry(); BSpline(); if(isBSpline){ - _show_outline(true); + _show_outline = true; } } -- cgit v1.2.3 From 2cb207295847d68e22aab2e8adb967819ff8feaa Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 30 Jan 2014 22:16:10 +0100 Subject: Hack to can show/hide bspline lines (bzr r11950.1.243) --- src/ui/tool/path-manipulator.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 83af89732..9cda94097 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -150,6 +150,8 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, BSpline(); if(isBSpline){ _show_outline = true; + _updateOutline(); + _show_outline = false; } } @@ -914,8 +916,7 @@ void PathManipulator::showHandles(bool show) /** Set the visibility of outline. */ void PathManipulator::showOutline(bool show) { - //if(isBSpline) show = true; - //if (show == _show_outline) return; + if (show == _show_outline) return; _show_outline = show; _updateOutline(); } -- cgit v1.2.3 From 210d60046203fad93e65f049c5c6a7516d967f07 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 30 Jan 2014 23:40:40 +0100 Subject: add comment to bspline red outline hack (bzr r11950.1.244) --- src/ui/tool/path-manipulator.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 9cda94097..4092cd22b 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -148,6 +148,8 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, _createControlPointsFromGeometry(); BSpline(); + //Small Hack to default show red path in bspline on select, independent of the state of toogle button + //it become some inconsistent behaviour in the show_path toogle button if(isBSpline){ _show_outline = true; _updateOutline(); -- cgit v1.2.3 From 1e8014478b4185861ec348250a88d8476140b35f Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 1 Feb 2014 12:33:03 +0100 Subject: Add correct preview for coninuing paths whith pencil and draw modes (bzr r11950.1.245) --- src/ui/tools/pen-tool.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src') diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index a48f8911a..8c13a0584 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -43,6 +43,10 @@ #include "tools-switch.h" #include "ui/control-manager.h" //spanish: incluimos los archivos necesarios para las BSpline y Spiro +#include "live_effects/effect.h" +#include "live_effects/lpeobject.h" +#include "live_effects/lpeobject-reference.h" +#include "live_effects/parameter/path.h" #define INKSCAPE_LPE_SPIRO_C #include "live_effects/lpe-spiro.h" @@ -68,6 +72,8 @@ #include "tool-factory.h" +#include "live_effects/effect.h" + using Inkscape::ControlManager; @@ -1467,6 +1473,32 @@ static void bspline_spiro_off(PenTool *const pc) static void bspline_spiro_start_anchor(PenTool *const pc, bool shift) { + LivePathEffect::LPEBSpline *lpe_bsp = NULL; + + if (SP_IS_LPE_ITEM(pc->white_item) && SP_LPE_ITEM(pc->white_item)->hasPathEffect()){ + Inkscape::LivePathEffect::Effect* thisEffect = SP_LPE_ITEM(pc->white_item)->getPathEffectOfType(Inkscape::LivePathEffect::BSPLINE); + if(thisEffect){ + lpe_bsp = dynamic_cast(thisEffect->getLPEObj()->get_lpe()); + } + } + if(lpe_bsp){ + pc->bspline = true; + }else{ + pc->bspline = false; + } + LivePathEffect::LPESpiro *lpe_spi = NULL; + + if (SP_IS_LPE_ITEM(pc->white_item) && SP_LPE_ITEM(pc->white_item)->hasPathEffect()){ + Inkscape::LivePathEffect::Effect* thisEffect = SP_LPE_ITEM(pc->white_item)->getPathEffectOfType(Inkscape::LivePathEffect::SPIRO); + if(thisEffect){ + lpe_spi = dynamic_cast(thisEffect->getLPEObj()->get_lpe()); + } + } + if(lpe_spi){ + pc->spiro = true; + }else{ + pc->spiro = false; + } if(!pc->spiro && !pc->bspline) return; -- cgit v1.2.3 From b9f1c85c61ce91fedca5486ef371bf6301e76128 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 5 Feb 2014 17:31:55 +0100 Subject: fixing su_v advertising memory bug (bzr r11950.1.247) --- src/ui/tools/freehand-base.cpp | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 5825a149c..6561a0c2f 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -531,22 +531,33 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) // Step C - test start if (dc->sa) { - SPCurve *s = dc->sa->curve; - dc->white_curves = g_slist_remove(dc->white_curves, s); - if (dc->sa->start) { - s = reverse_then_unref(s); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) != 1 && + prefs->getInt(tool_name(dc) + "/freehand-mode", 0) != 2){ + dc->sa->curve->unref() + }else{ + SPCurve *s = dc->sa->curve; + dc->white_curves = g_slist_remove(dc->white_curves, s); + if (dc->sa->start) { + s = reverse_then_unref(s); + } + s->append_continuous(c, 0.0625); + c->unref(); + c = s; } - s->append_continuous(c, 0.0625); - c->unref(); - c = s; } else /* Step D - test end */ if (dc->ea) { - SPCurve *e = dc->ea->curve; - dc->white_curves = g_slist_remove(dc->white_curves, e); - if (!dc->ea->start) { - e = reverse_then_unref(e); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) != 1 && + prefs->getInt(tool_name(dc) + "/freehand-mode", 0) != 2){ + dc->ea->curve->unref() + SPCurve *e = dc->ea->curve; + dc->white_curves = g_slist_remove(dc->white_curves, e); + if (!dc->ea->start) { + e = reverse_then_unref(e); + } + c->append_continuous(e, 0.0625); + e->unref(); } - c->append_continuous(e, 0.0625); - e->unref(); } -- cgit v1.2.3 From 46c24197ff9e17b30d97cab8893d5017b9b99dc3 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 8 Feb 2014 20:10:00 +0100 Subject: update to trunk (bzr r11950.1.249) --- src/ui/tools/freehand-base.cpp | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 6561a0c2f..5825a149c 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -531,33 +531,22 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) // Step C - test start if (dc->sa) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) != 1 && - prefs->getInt(tool_name(dc) + "/freehand-mode", 0) != 2){ - dc->sa->curve->unref() - }else{ - SPCurve *s = dc->sa->curve; - dc->white_curves = g_slist_remove(dc->white_curves, s); - if (dc->sa->start) { - s = reverse_then_unref(s); - } - s->append_continuous(c, 0.0625); - c->unref(); - c = s; + SPCurve *s = dc->sa->curve; + dc->white_curves = g_slist_remove(dc->white_curves, s); + if (dc->sa->start) { + s = reverse_then_unref(s); } + s->append_continuous(c, 0.0625); + c->unref(); + c = s; } else /* Step D - test end */ if (dc->ea) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) != 1 && - prefs->getInt(tool_name(dc) + "/freehand-mode", 0) != 2){ - dc->ea->curve->unref() - SPCurve *e = dc->ea->curve; - dc->white_curves = g_slist_remove(dc->white_curves, e); - if (!dc->ea->start) { - e = reverse_then_unref(e); - } - c->append_continuous(e, 0.0625); - e->unref(); + SPCurve *e = dc->ea->curve; + dc->white_curves = g_slist_remove(dc->white_curves, e); + if (!dc->ea->start) { + e = reverse_then_unref(e); } + c->append_continuous(e, 0.0625); + e->unref(); } -- cgit v1.2.3 From 215e1988378008820be9bfb7d948d8b6e33eb0a1 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 8 Feb 2014 22:16:43 +0100 Subject: Removing hack for force show red lines in bspline mode (bzr r11950.1.251) --- src/ui/tool/path-manipulator.cpp | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 4092cd22b..bad07daee 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -148,13 +148,6 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, _createControlPointsFromGeometry(); BSpline(); - //Small Hack to default show red path in bspline on select, independent of the state of toogle button - //it become some inconsistent behaviour in the show_path toogle button - if(isBSpline){ - _show_outline = true; - _updateOutline(); - _show_outline = false; - } } PathManipulator::~PathManipulator() -- cgit v1.2.3 From be22cb94d23816986838e9636ce44ee8537a8570 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 26 Feb 2014 22:29:31 +0100 Subject: Fixed some/all bugs related to continuing bspline/spiro curves advertaising by suv (bzr r11950.1.257) --- src/ui/tools/freehand-base.cpp | 37 +++++++++++++++++++++---------- src/ui/tools/pen-tool.cpp | 50 +++++++++++++++++++++++------------------- 2 files changed, 52 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 5e406a0d4..d8a8e901a 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -469,7 +469,7 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) { // Concat RBG SPCurve *c = dc->green_curve; - + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); // Green dc->green_curve = new SPCurve(); while (dc->green_bpaths) { @@ -490,12 +490,16 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(dc->red_bpath), NULL); if (c->is_empty()) { + if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ + SPDesktop *desktop = dc->desktop; + spdc_selection_modified(sp_desktop_selection(desktop), 0, dc); + } c->unref(); return; } // Step A - test, whether we ended on green anchor - if ( forceclosed || ( dc->green_anchor && dc->green_anchor->active ) ) { + if ( forceclosed || (dc->green_anchor && dc->green_anchor->active) ) { // We hit green anchor, closing Green-Blue-Red dc->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Path is closed.")); c->closepath_current(); @@ -513,21 +517,33 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) { // We hit bot start and end of single curve, closing paths dc->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Closing path.")); - if (dc->sa->start && !(dc->sa->curve->is_closed()) ) { - c = reverse_then_unref(c); + if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || + prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ + if (dc->sa->start && !(dc->sa->curve->is_closed()) ) { + dc->sa->curve = reverse_then_unref(dc->sa->curve); + } + dc->sa->curve->append_continuous(c, 0.0625); + c->unref(); + if(Geom::are_near(dc->sa->curve->first_path()->initialPoint(), dc->ea->dp)){ + dc->sa->curve->closepath_current(); + } + }else{ + if (dc->sa->start && !(dc->sa->curve->is_closed()) ) { + c = reverse_then_unref(c); + } + dc->sa->curve->append_continuous(c, 0.0625); + c->unref(); + dc->sa->curve->closepath_current(); } - dc->sa->curve->append_continuous(c, 0.0625); - c->unref(); - dc->sa->curve->closepath_current(); //spanish: Si la curva tiene un LPE del tipo bspline o spiro ejecutamos spdc_flush_white //pasándole la curva de inicio necesaria - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ dc->white_curves = g_slist_remove(dc->white_curves, dc->sa->curve); spdc_flush_white(dc, dc->sa->curve); - }else + }else{ spdc_flush_white(dc, NULL); + } return; } @@ -550,10 +566,7 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) c->append_continuous(e, 0.0625); e->unref(); } - - spdc_flush_white(dc, c); - c->unref(); } diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 8c13a0584..a344dc7a6 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -414,11 +414,18 @@ static gint pen_handle_button_press(PenTool *const pc, GdkEventButton const &bev ToolBase *event_context = SP_EVENT_CONTEXT(pc); //Test whether we hit any anchor. SPDrawAnchor * const anchor = spdc_test_inside(pc, event_w); + //with this we avoid creating a new point over the existing one - if(!bevent.button == 3 && (pc->spiro || pc->bspline) && pc->npoints > 0 && pc->p[0] == pc->p[3]){ + if(bevent.button != 3 && (pc->spiro || pc->bspline) && pc->npoints > 0 && pc->p[0] == pc->p[3]){ + pc->state = PenTool::STOP; + if( anchor && anchor == pc->sa && pc->green_curve->is_empty()){ + //spanish Borrar siguiente linea para evitar un nodo encima de otro + spdc_pen_finish_segment(pc, event_dt, bevent.state); + spdc_pen_finish(pc, FALSE); + return TRUE; + } return FALSE; } - gint ret = FALSE; if (bevent.button == 1 && !event_context->space_panning // make sure this is not the last click for a waiting LPE (otherwise we want to finish the path) @@ -486,7 +493,7 @@ static gint pen_handle_button_press(PenTool *const pc, GdkEventButton const &bev if(anchor){ bspline_spiro_start_anchor(pc,(bevent.state & GDK_SHIFT_MASK)); } - if (anchor && !sp_pen_context_has_waiting_LPE(pc)) { + if (anchor && (!sp_pen_context_has_waiting_LPE(pc) || pc->bspline || pc->spiro)) { // Adjust point to anchor if needed; if we have a waiting LPE, we need // a fresh path to be created so don't continue an existing one p = anchor->dp; @@ -755,7 +762,6 @@ static gint pen_handle_button_release(PenTool *const pc, GdkEventButton const &r } gint ret = FALSE; - ToolBase *event_context = SP_EVENT_CONTEXT(pc); if ( revent.button == 1 && !event_context->space_panning) { @@ -769,11 +775,10 @@ static gint pen_handle_button_release(PenTool *const pc, GdkEventButton const &r // Test whether we hit any anchor. SPDrawAnchor *anchor = spdc_test_inside(pc, event_w); //with this we avoid creating a new point over the existing one - if(pc->spiro || pc->bspline){ - //spanish: si intentamos crear un nodo en el mismo sitio que el origen, paramos. - if(pc->npoints > 0 && pc->p[0] == pc->p[3]){ - return FALSE; - } + //spanish: si intentamos crear un nodo en el mismo sitio que el origen, paramos. + + if((!anchor || anchor == pc->sa) && (pc->spiro || pc->bspline) && pc->npoints > 0 && pc->p[0] == pc->p[3]){ + return TRUE; } switch (pc->mode) { @@ -1442,9 +1447,7 @@ static void bspline_spiro(PenTool *const pc, bool shift) if(!pc->spiro && !pc->bspline) return; - if(!pc->anchor_statusbar) - shift?bspline_spiro_off(pc):bspline_spiro_on(pc); - + shift?bspline_spiro_off(pc):bspline_spiro_on(pc); bspline_spiro_build(pc); } @@ -1628,10 +1631,11 @@ static void bspline_spiro_motion(PenTool *const pc, bool shift){ } if(pc->anchor_statusbar && !pc->red_curve->is_empty()){ - if(shift) + if(shift){ bspline_spiro_end_anchor_off(pc); - else + }else{ bspline_spiro_end_anchor_on(pc); + } } bspline_spiro_build(pc); @@ -1675,10 +1679,9 @@ static void bspline_spiro_end_anchor_on(PenTool *const pc) tmpCurve = tmpCurve->create_reverse(); pc->green_curve->reset(); pc->green_curve = tmpCurve; - }else{ + }else { tmpCurve = pc->sa->curve->copy(); - if(!pc->sa->start) - tmpCurve = tmpCurve->create_reverse(); + if(!pc->sa->start) tmpCurve = tmpCurve->create_reverse(); Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); if(pc->bspline){ C = tmpCurve->last_segment()->finalPoint() + (1./3)*(tmpCurve->last_segment()->initialPoint() - tmpCurve->last_segment()->finalPoint()); @@ -1712,10 +1715,11 @@ static void bspline_spiro_end_anchor_on(PenTool *const pc) static void bspline_spiro_end_anchor_off(PenTool *const pc) { - pc->p[2] = pc->p[3]; SPCurve *tmpCurve = new SPCurve(); SPCurve *lastSeg = new SPCurve(); + pc->p[2] = pc->p[3]; if(!pc->sa || pc->sa->curve->is_empty()){ + tmpCurve = pc->green_curve->create_reverse(); if(pc->green_curve->get_segment_count()==0)return; Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); @@ -1734,10 +1738,9 @@ static void bspline_spiro_end_anchor_off(PenTool *const pc) pc->green_curve->reset(); pc->green_curve = tmpCurve; } - }else{ + }else { tmpCurve = pc->sa->curve->copy(); - if(!pc->sa->start) - tmpCurve = tmpCurve->create_reverse(); + if(!pc->sa->start) tmpCurve = tmpCurve->create_reverse(); Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); if(cubic){ lastSeg->moveto((*cubic)[0]); @@ -1789,7 +1792,7 @@ static void bspline_spiro_build(PenTool *const pc) } if(!curve->is_empty()){ - //spanish: cerramos la curva si estan cerca los puntos finales de la curva spiro + //spanish: cerramos la curva si estan cerca los puntos finales de la curva if(Geom::are_near(curve->first_path()->initialPoint(), curve->last_path()->finalPoint())){ curve->closepath_current(); } @@ -2194,7 +2197,8 @@ static void spdc_pen_finish(PenTool *const pc, gboolean const closed) SPDesktop *const desktop = pc->desktop; pc->message_context->clear(); desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Drawing finished")); - + if(pc->spiro || pc->bspline) pc->blue_curve->reset(); + //spanish para cancelar linea sin un segmento creado pc->red_curve->reset(); spdc_concat_colors_and_flush(pc, closed); pc->sa = NULL; -- cgit v1.2.3 From 1f76e96f90e3badb3b9693d477e6e75fbaaa1bd1 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 28 Feb 2014 20:12:44 +0100 Subject: adding some comments (bzr r11950.1.260) --- src/ui/tool/node.cpp | 3 +-- src/ui/tools/freehand-base.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 63556e499..69f4a8e82 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -322,7 +322,6 @@ bool Handle::grabbed(GdkEventMotion *) void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) { - Geom::Point parent_pos = _parent->position(); Geom::Point origin = _last_drag_origin(); SnapManager &sm = _desktop->namedview->snap_manager; @@ -479,7 +478,7 @@ static double snap_increment_degrees() { Glib::ustring Handle::_getTip(unsigned state) const { char const *more; - //spanish: un truco par, si el nodo tiene fuerza, nos marca que es + //spanish: un truco para, si el nodo tiene fuerza, nos marca que es //del tipo bspline, lo utilizaremos despues para mostras los mensajes apropiados //no lo podemos hacer de otra forma al ser constante la funcion bool isBSpline = false; diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index c65d8133b..861ea0503 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -483,6 +483,9 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) dc->red_curve->reset(); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(dc->red_bpath), NULL); + //spanish: si c esta vacio, puede ser que se haya tratado de contnuar una curva existente + //y se haya cancelado. Si es asi y el modo es bspline o spirolive la curva previa necesita volver a ser seleccionada + //porque la modificamos al continuar por un anchor if (c->is_empty()) { if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ SPDesktop *desktop = dc->desktop; @@ -493,7 +496,7 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) } // Step A - test, whether we ended on green anchor - if ( forceclosed || (dc->green_anchor && dc->green_anchor->active) ) { + if ( forceclosed || ( dc->green_anchor && dc->green_anchor->active ) ) { // We hit green anchor, closing Green-Blue-Red dc->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Path is closed.")); c->closepath_current(); @@ -511,6 +514,8 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) { // We hit bot start and end of single curve, closing paths dc->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Closing path.")); + //spanish: si estamos en modo bspline o spirolive, la curva de continuación y finalización es actualizada al continuar o finalizar la curva en un anchor + //esto proboca que la función original no detecte si es la misma curva en el caso de curvas con multiples partes -shift- y cierre de manera erronea una de las partes if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ if (dc->sa->start && !(dc->sa->curve->is_closed()) ) { -- cgit v1.2.3 From 616ae6e54d98f03dc1ff3ce7d3c528521fd7e233 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 1 Mar 2014 16:28:13 +0100 Subject: Substitute isBSpline property by a cached function isBSpline(bool) (bzr r11950.1.261) --- src/ui/tool/curve-drag-point.cpp | 4 ++-- src/ui/tool/node.cpp | 30 +++++++++++++++--------------- src/ui/tool/path-manipulator.cpp | 19 +++++++++++-------- src/ui/tool/path-manipulator.h | 3 +-- 4 files changed, 29 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/ui/tool/curve-drag-point.cpp b/src/ui/tool/curve-drag-point.cpp index 0ee848f15..e5412fdc2 100644 --- a/src/ui/tool/curve-drag-point.cpp +++ b/src/ui/tool/curve-drag-point.cpp @@ -54,7 +54,7 @@ bool CurveDragPoint::grabbed(GdkEventMotion */*event*/) // delta is a vector equal 1/3 of distance from first to second Geom::Point delta = (second->position() - first->position()) / 3.0; //spanish: solo actualizamos los nodos si no es bspline - if(!_pm.isBSpline){ + if(!_pm.isBSpline(false)){ first->front()->move(first->front()->position() + delta); second->back()->move(second->back()->position() - delta); } @@ -90,7 +90,7 @@ void CurveDragPoint::dragged(Geom::Point &new_pos, GdkEventMotion *event) Geom::Point offset0 = ((1-weight)/(3*t*(1-t)*(1-t))) * delta; Geom::Point offset1 = (weight/(3*t*t*(1-t))) * delta; //spanish: modificado para que, si el trazado es bspline solo actue si está presionada la tecla SHIFT - if(!_pm.isBSpline){ + if(!_pm.isBSpline(false)){ first->front()->move(first->front()->position() + offset0); second->back()->move(second->back()->position() + offset1); }else if(weight>=0.8 && !second->isEndNode() && held_shift(*event))second->back()->move(new_pos); diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 69f4a8e82..78d8fe833 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -168,7 +168,7 @@ void Handle::move(Geom::Point const &new_pos) setPosition(new_pos); //spanish: mueve el tirador y su opuesto la misma proporción - if(_pm().isBSpline){ + if(_pm().isBSpline(false)){ setPosition(_pm().BSplineHandleReposition(this)); this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),_parent->bsplineWeight)); } @@ -185,7 +185,7 @@ void Handle::move(Geom::Point const &new_pos) setRelativePos(new_delta); //spanish: mueve el tirador y su opuesto la misma proporción - if(_pm().isBSpline){ + if(_pm().isBSpline(false)){ setPosition(_pm().BSplineHandleReposition(this)); this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),_parent->bsplineWeight)); } @@ -211,7 +211,7 @@ void Handle::move(Geom::Point const &new_pos) setPosition(new_pos); //spanish: mueve el tirador y su opuesto la misma proporción - if(_pm().isBSpline){ + if(_pm().isBSpline(false)){ setPosition(_pm().BSplineHandleReposition(this)); this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),_parent->bsplineWeight)); } @@ -305,7 +305,7 @@ bool Handle::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEven //spanish: función que mueve el tirador y su opuesto a la proporción por defecto de 0.3334 void Handle::handle_2button_press(){ - if(_pm().isBSpline){ + if(_pm().isBSpline(false)){ setPosition(_pm().BSplineHandleReposition(this,0.3334)); this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),_parent->bsplineWeight)); _pm().update(); @@ -361,7 +361,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) new_pos = result; //spanish: mueve el tirador y su opuesto en X posiciones fijas depenfiendo de la configuración de el //parametro "steps whith control" del efecto en vivo BSpline - if(_pm().isBSpline){ + if(_pm().isBSpline(false)){ setPosition(new_pos); int steps = _pm().BSplineGetSteps(); _parent->bsplineWeight = ceilf(_pm().BSplineHandlePosition(this)*steps)/steps; @@ -371,7 +371,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) std::vector unselected; //spanish: si está activado el ajuste (snap) y no es bspline - if (snap && !_pm().isBSpline) { + if (snap && !_pm().isBSpline(false)) { ControlPointSelection::Set &nodes = _parent->_selection.allPoints(); for (ControlPointSelection::Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { Node *n = static_cast(*i); @@ -413,7 +413,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) } //spanish: si es bspline pero no está presionado SHIFT o CONTROL //lo fija en la posición original - if(_pm().isBSpline && !held_shift(*event) && !held_control(*event)){ + if(_pm().isBSpline(false) && !held_shift(*event) && !held_control(*event)){ new_pos=_last_drag_origin(); } move(new_pos); // needed for correct update, even though it's redundant @@ -433,7 +433,7 @@ void Handle::ungrabbed(GdkEventButton *event) if (dist.length() <= drag_tolerance) { move(_parent->position()); //spanish: marca la fuerza del bspline como 0.0000 - if(_pm().isBSpline){ + if(_pm().isBSpline(false)){ _parent->bsplineWeight = 0.0000; } } @@ -626,7 +626,7 @@ void Node::move(Geom::Point const &new_pos) //de nuevo una vez sea movido el nodo double oldPos = 0.0000; Node *n = this; - if(_pm().isBSpline){ + if(_pm().isBSpline(false)){ oldPos = n->bsplineWeight; } @@ -640,7 +640,7 @@ void Node::move(Geom::Point const &new_pos) _fixNeighbors(old_pos, new_pos); //spanish: movemos los tiradores involucrados, primero los del nodo en cuestión //y despues los de los nodos colindantes - if(_pm().isBSpline){ + if(_pm().isBSpline(false)){ _front.setPosition(_pm().BSplineHandleReposition(this->front(),oldPos)); _back.setPosition(_pm().BSplineHandleReposition(this->back(),oldPos)); _pm().BSplineNodeHandlesReposition(this); @@ -652,7 +652,7 @@ void Node::transform(Geom::Affine const &m) //spanish: guardamos la fuerza anterior del nodo para reaplicarsela //de nuevo una vez sea movido el nodo double oldPos = 0.0000; - if(_pm().isBSpline){ + if(_pm().isBSpline(false)){ oldPos = this->bsplineWeight; } Geom::Point old_pos = position(); @@ -665,7 +665,7 @@ void Node::transform(Geom::Affine const &m) _fixNeighbors(old_pos, position()); //spanish: movemos los tiradores involucrados, primero los del nodo en cuestión //y despues los de los nodos colindantes - if(_pm().isBSpline){ + if(_pm().isBSpline(false)){ _front.setPosition(_pm().BSplineHandleReposition(this->front(),oldPos)); _back.setPosition(_pm().BSplineHandleReposition(this->back(),oldPos)); _pm().BSplineNodeHandlesReposition(this); @@ -759,7 +759,7 @@ void Node::showHandles(bool v) //Cada vez que actuemos sobre dichos tiradores en un trazado //bspline esta fuerza se tiene que actualizar this->bsplineWeight = 0.0000; - if(_pm().isBSpline && (!_front.isDegenerate() || !_back.isDegenerate())){ + if(_pm().isBSpline(false) && (!_front.isDegenerate() || !_back.isDegenerate())){ if (!_front.isDegenerate()) { _pm().BSplineHandlePosition(&_front); } @@ -871,7 +871,7 @@ void Node::setType(NodeType type, bool update_handles) //spanish: en los cambios de tipo de nodo, sobre trazados bspline, //o bien los mantenemos con potencia 0.0000 en modo esquina //o les damos la potencia por defecto en modo de curva - if(_pm().isBSpline){ + if(_pm().isBSpline(false)){ if(this->bsplineWeight !=0.0000) this->bsplineWeight = 0.3334; _front.setPosition(_pm().BSplineHandleReposition(this->front(),this->bsplineWeight)); _back.setPosition(_pm().BSplineHandleReposition(this->back(),this->bsplineWeight)); @@ -1124,7 +1124,7 @@ void Node::_setState(State state) mgr.setActive(_canvas_item, true); mgr.setPrelight(_canvas_item, false); //spanish: esto muestra los tiradores al seleccionar los nodos - if(_pm().isBSpline){ + if(_pm().isBSpline(false)){ if(!this->back()->isDegenerate()){ _pm().BSplineHandlePosition(this->back()); }else if (!this->front()->isDegenerate()){ diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index bad07daee..a6689d93d 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -103,11 +103,9 @@ private: }; void build_segment(Geom::PathBuilder &, Node *, Node *); -//spanish: una propiedad isBSpline, por defecto falsa y una función al final de la función (BSpline()) que la define realmente PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, Geom::Affine const &et, guint32 outline_color, Glib::ustring lpe_key) : PointManipulator(mpm._path_data.node_data.desktop, *mpm._path_data.node_data.selection) - , isBSpline(false) , _subpaths(*this) , _multi_path_manipulator(mpm) , _path(path) @@ -147,7 +145,7 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, sigc::hide( sigc::mem_fun(*this, &PathManipulator::_updateOutlineOnZoomChange))); _createControlPointsFromGeometry(); - BSpline(); + isBSpline(true); } PathManipulator::~PathManipulator() @@ -666,7 +664,7 @@ unsigned PathManipulator::_deleteStretch(NodeList::iterator start, NodeList::ite start = next; } //spanish: si se borra, reajustamos los tiradores - if(isBSpline){ + if(isBSpline(false)){ double pos = 0.0000; if(start.prev()){ pos = BSplineHandlePosition(start.prev()->back()); @@ -1203,11 +1201,16 @@ int PathManipulator::BSplineGetSteps(){ } //spanish: determina si el trazado tiene efecto bspline -void PathManipulator::BSpline(){ - isBSpline = false; - if(this->BSplineGetSteps()>0){ +bool PathManipulator::isBSpline(bool recalculate){ + static int BSplineSteps = this->BSplineGetSteps(); + if(recalculate){ + BSplineSteps = this->BSplineGetSteps(); + } + bool isBSpline = false; + if(BSplineSteps>0){ isBSpline = true; } + return isBSpline; } //spanish: devuelve la fuerza que le corresponderia a la posicón de un tirador @@ -1283,7 +1286,7 @@ void PathManipulator::BSplineNodeHandlesReposition(Node *n){ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) { Geom::PathBuilder builder; - BSpline(); + isBSpline(true); for (std::list::iterator spi = _subpaths.begin(); spi != _subpaths.end(); ) { SubpathPtr subpath = *spi; if (subpath->empty()) { diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index 5f075834e..5186bfc95 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -96,7 +96,6 @@ public: NodeList::iterator extremeNode(NodeList::iterator origin, bool search_selected, bool search_unselected, bool closest); - bool isBSpline; int BSplineGetSteps(); // this is necessary for Tab-selection in MultiPathManipulator SubpathList &subpathList() { return _subpaths; } @@ -107,7 +106,7 @@ private: typedef boost::shared_ptr SubpathPtr; void _createControlPointsFromGeometry(); - void BSpline(); + bool isBSpline(bool recalculate); double BSplineHandlePosition(Handle *h); Geom::Point BSplineHandleReposition(Handle *h); Geom::Point BSplineHandleReposition(Handle *h,double pos); -- cgit v1.2.3 From 9f066846c116c7a963bfaa805282b9b8d4c014e4 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 2 Mar 2014 03:07:44 +0100 Subject: =?UTF-8?q?Fixed=20update=20to=20trunk,=20lot=20of=20changes=20vin?= =?UTF-8?q?=C3=ADcius?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (bzr r11950.1.265) --- src/ui/tools/pen-tool.cpp | 122 +++++++++++++++------------------------------- src/ui/tools/pen-tool.h | 29 ++++++++++- 2 files changed, 66 insertions(+), 85 deletions(-) (limited to 'src') diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index c6d87e2d8..65823b642 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -81,52 +81,6 @@ namespace Inkscape { namespace UI { namespace Tools { -static void spdc_pen_set_initial_point(PenTool *pc, Geom::Point const p); -//spanish: añade los modos spiro y bspline -static void sp_pen_context_set_mode(PenTool *const pc, guint mode); -//spanish: esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro -static void bspline_spiro_color(PenTool *const pc); -//spanish: crea un nodo en modo bspline o spiro -static void bspline_spiro(PenTool *const pc,bool shift); -//spanish: crea un nodo de modo spiro o bspline -static void bspline_spiro_on(PenTool *const pc); -//spanish: crea un nodo de tipo CUSP -static void bspline_spiro_off(PenTool *const pc); -//spanish: continua una curva existente en modo bspline o spiro -static void bspline_spiro_start_anchor(PenTool *const pc,bool shift); -//spanish: continua una curva exsitente con el nodo de union en modo bspline o spiro -static void bspline_spiro_start_anchor_on(PenTool *const pc); -//spanish: continua una curva existente con el nodo de union en modo CUSP -static void bspline_spiro_start_anchor_off(PenTool *const pc); -//spanish: modifica la "red_curve" cuando se detecta movimiento -static void bspline_spiro_motion(PenTool *const pc,bool shift); -//spanish: cierra la curva con el último nodo en modo bspline o spiro -static void bspline_spiro_end_anchor_on(PenTool *const pc); -//spanish: cierra la curva con el último nodo en modo CUSP -static void bspline_spiro_end_anchor_off(PenTool *const pc); -//spanish: unimos todas las curvas en juego y llamamos a la función doEffect. -static void bspline_spiro_build(PenTool *const pc); -//function bspline cloned from lpe-bspline.cpp -static void bspline_doEffect(SPCurve * curve); -//function spiro cloned from lpe-spiro.cpp -static void spiro_doEffect(SPCurve * curve); - -static void spdc_pen_set_subsequent_point(PenTool *const pc, Geom::Point const p, bool statusbar, guint status = 0); -static void spdc_pen_set_ctrl(PenTool *pc, Geom::Point const p, guint state); -static void spdc_pen_finish_segment(PenTool *pc, Geom::Point p, guint state); - -static void spdc_pen_finish(PenTool *pc, gboolean closed); - -static gint pen_handle_button_press(PenTool *const pc, GdkEventButton const &bevent); -static gint pen_handle_motion_notify(PenTool *const pc, GdkEventMotion const &mevent); -static gint pen_handle_button_release(PenTool *const pc, GdkEventButton const &revent); -static gint pen_handle_2button_press(PenTool *const pc, GdkEventButton const &bevent); -static gint pen_handle_key_press(PenTool *const pc, GdkEvent *event); -static void spdc_reset_colors(PenTool *pc); - -static void pen_disable_events(PenTool *const pc); -static void pen_enable_events(PenTool *const pc); - static Geom::Point pen_drag_origin_w(0, 0); static bool pen_within_tolerance = false; static int pen_last_paraxial_dir = 0; // last used direction in horizontal/vertical mode; 0 = horizontal, 1 = vertical @@ -217,13 +171,13 @@ void PenTool::setPolylineMode() { this->polylines_paraxial = (mode == 4); //we call the function which defines the Spiro modes and the BSpline //todo: merge to one function only - sp_pen_context_set_mode(this, mode); + this->_pen_context_set_mode(mode); } /* *.Set the mode of draw spiro, and bsplines */ -void sp_pen_context_set_mode(PenTool *const pc, guint mode) { +void PenTool::_pen_context_set_mode(guint mode) { //spanish: definimos los modos this->spiro = (mode == 1); this->bspline = (mode == 2); @@ -425,7 +379,7 @@ gint PenTool::_handleButtonPress(GdkEventButton const &bevent) { Geom::Point const event_w(bevent.x, bevent.y); Geom::Point event_dt(desktop->w2d(event_w)); //Test whether we hit any anchor. - SPDrawAnchor * const anchor = spdc_test_inside(pc, event_w); + SPDrawAnchor * const anchor = spdc_test_inside(this, event_w); ToolBase *event_context = SP_EVENT_CONTEXT(this); //with this we avoid creating a new point over the existing one @@ -433,8 +387,8 @@ gint PenTool::_handleButtonPress(GdkEventButton const &bevent) { this->state = PenTool::STOP; if( anchor && anchor == this->sa && this->green_curve->is_empty()){ //spanish Borrar siguiente linea para evitar un nodo encima de otro - spdc_pen_finish_segment(pc, event_dt, bevent.state); - spdc_pen_finish(pc, FALSE); + _finishSegment(event_dt, bevent.state); + _finish( FALSE); return TRUE; } return FALSE; @@ -505,7 +459,7 @@ gint PenTool::_handleButtonPress(GdkEventButton const &bevent) { this->sa = anchor; if(anchor){ - bspline_spiro_start_anchor(pc,(bevent.state & GDK_SHIFT_MASK)); + this->_bspline_spiro_start_anchor(bevent.state & GDK_SHIFT_MASK); } if (anchor && (!this->hasWaitingLPE()|| this->bspline || this->spiro)) { // Adjust point to anchor if needed; if we have a waiting LPE, we need @@ -753,12 +707,12 @@ gint PenTool::_handleMotionNotify(GdkEventMotion const &mevent) { } //spanish: lanzamos la función "bspline_spiro_motion" al moverse el ratón o cuando se para. if(this->bspline){ - bspline_spiro_color(pc); - bspline_spiro_motion(pc,(mevent.state & GDK_SHIFT_MASK)); + this->_bspline_spiro_color(); + this->_bspline_spiro_motion(mevent.state & GDK_SHIFT_MASK); }else{ if ( Geom::LInfty( event_w - pen_drag_origin_w ) > tolerance || mevent.time == 0) { - bspline_spiro_color(pc); - bspline_spiro_motion(pc,(mevent.state & GDK_SHIFT_MASK)); + this->_bspline_spiro_color(); + this->_bspline_spiro_motion(mevent.state & GDK_SHIFT_MASK); pen_drag_origin_w = event_w; } } @@ -809,7 +763,7 @@ gint PenTool::_handleButtonRelease(GdkEventButton const &revent) { //spanish: continuamos una curva existente if (anchor) { if(this->bspline || this->spiro){ - bspline_spiro_start_anchor(pc,(revent.state & GDK_SHIFT_MASK)); + this->_bspline_spiro_start_anchor(revent.state & GDK_SHIFT_MASK);; } } this->_setInitialPoint(p); @@ -986,7 +940,7 @@ void PenTool::_redrawAll() { //spanish: simplemente redibujamos la spiro. //como es un redibujo simplemente no llamamos a la función global sino al final de esta //Lanzamos solamente el redibujado - bspline_spiro_build(pc); + this->_bspline_spiro_build(); } void PenTool::_lastpointMove(gdouble x, gdouble y) { @@ -1060,7 +1014,7 @@ void PenTool::_lastpointToCurve() { } //spanish: si el último nodo es una union con otra curva if(this->green_curve->is_empty() && this->sa && !this->sa->curve->is_empty()){ - bspline_spiro_start_anchor(pc, false); + this->_bspline_spiro_start_anchor(false); } } @@ -1107,7 +1061,7 @@ void PenTool::_lastpointToLine() { } //spanish: si el último nodo es una union con otra curva if(this->green_curve->is_empty() && this->sa && !this->sa->curve->is_empty()){ - bspline_spiro_start_anchor(pc, true); + this->_bspline_spiro_start_anchor(true); } } @@ -1332,7 +1286,7 @@ gint PenTool::_handleKeyPress(GdkEvent *event) { this->_setSubsequentPoint(pt, true); pen_last_paraxial_dir = !pen_last_paraxial_dir; //spanish: redibujamos - bspline_spiro_build(pc); + this->_bspline_spiro_build(); ret = TRUE; } break; @@ -1406,7 +1360,7 @@ void PenTool::_setAngleDistanceStatusMessage(Geom::Point const p, int pc_point_t //spanish: esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro -static void bspline_spiro_color(PenTool *const pc) +void PenTool::_bspline_spiro_color() { bool remake_green_bpaths = false; if(this->spiro){ @@ -1451,16 +1405,16 @@ static void bspline_spiro_color(PenTool *const pc) } -static void bspline_spiro(PenTool *const pc, bool shift) +void PenTool::_bspline_spiro(bool shift) { if(!this->spiro && !this->bspline) return; - shift?bspline_spiro_off(pc):bspline_spiro_on(pc); - bspline_spiro_build(pc); + shift?this->_bspline_spiro_off():this->_bspline_spiro_on(); + this->_bspline_spiro_build(); } -static void bspline_spiro_on(PenTool *const pc) +void PenTool::_bspline_spiro_on() { if(!this->red_curve->is_empty()){ using Geom::X; @@ -1473,7 +1427,7 @@ static void bspline_spiro_on(PenTool *const pc) } } -static void bspline_spiro_off(PenTool *const pc) +void PenTool::_bspline_spiro_off() { if(!this->red_curve->is_empty()){ this->npoints = 5; @@ -1483,7 +1437,7 @@ static void bspline_spiro_off(PenTool *const pc) } } -static void bspline_spiro_start_anchor(PenTool *const pc, bool shift) +void PenTool::_bspline_spiro_start_anchor(bool shift) { LivePathEffect::LPEBSpline *lpe_bsp = NULL; @@ -1518,12 +1472,12 @@ static void bspline_spiro_start_anchor(PenTool *const pc, bool shift) return; if(shift) - bspline_spiro_start_anchor_off(pc); + this->_bspline_spiro_start_anchor_off(); else - bspline_spiro_start_anchor_on(pc); + this->_bspline_spiro_start_anchor_on(); } -static void bspline_spiro_start_anchor_on(PenTool *const pc) +void PenTool::_bspline_spiro_start_anchor_on() { using Geom::X; using Geom::Y; @@ -1559,7 +1513,7 @@ static void bspline_spiro_start_anchor_on(PenTool *const pc) this->sa->curve = tmpCurve; } -static void bspline_spiro_start_anchor_off(PenTool *const pc) +void PenTool::_bspline_spiro_start_anchor_off() { SPCurve *tmpCurve = new SPCurve(); tmpCurve = this->sa->curve->copy(); @@ -1587,7 +1541,7 @@ static void bspline_spiro_start_anchor_off(PenTool *const pc) } -static void bspline_spiro_motion(PenTool *const pc, bool shift){ +void PenTool::_bspline_spiro_motion(bool shift){ if(!this->spiro && !this->bspline) return; @@ -1641,16 +1595,16 @@ static void bspline_spiro_motion(PenTool *const pc, bool shift){ if(this->anchor_statusbar && !this->red_curve->is_empty()){ if(shift){ - bspline_spiro_end_anchor_off(pc); + this->_bspline_spiro_end_anchor_off(); }else{ - bspline_spiro_end_anchor_on(pc); + this->_bspline_spiro_end_anchor_on(); } } - bspline_spiro_build(pc); + this->_bspline_spiro_build(); } -static void bspline_spiro_end_anchor_on(PenTool *const pc) +void PenTool::_bspline_spiro_end_anchor_on() { using Geom::X; @@ -1721,7 +1675,7 @@ static void bspline_spiro_end_anchor_on(PenTool *const pc) } } -static void bspline_spiro_end_anchor_off(PenTool *const pc) +void PenTool::_bspline_spiro_end_anchor_off() { SPCurve *tmpCurve = new SPCurve(); @@ -1773,7 +1727,7 @@ static void bspline_spiro_end_anchor_off(PenTool *const pc) //spanish: preparates the curves for its trasformation into BSline curves. -static void bspline_spiro_build(PenTool *const pc) +void PenTool::_bspline_spiro_build() { if(!this->spiro && !this->bspline) return; @@ -1812,9 +1766,9 @@ static void bspline_spiro_build(PenTool *const pc) //Effect *spr = static_cast ( new LPEbspline(lpeobj) ); //spr->doEffect(curve); if(this->bspline){ - bspline_doEffect(curve); + this->_bspline_doEffect(curve); }else{ - spiro_doEffect(curve); + this->_spiro_doEffect(curve); } sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->blue_bpath), curve); @@ -1838,7 +1792,7 @@ static void bspline_spiro_build(PenTool *const pc) } } -static void bspline_doEffect(SPCurve * curve) +void PenTool::_bspline_doEffect(SPCurve * curve) { //spanish: comentado en funcion "doEffect" de src/live_effects/lpe-bspline.cpp if(curve->get_segment_count() < 2) @@ -1981,7 +1935,7 @@ static void bspline_doEffect(SPCurve * curve) //Spiro function cloned from lpe-spiro.cpp //spanish: comentado en funcion "doEffect" de src/live_effects/lpe-spiro.cpp -static void spiro_doEffect(SPCurve * curve) +void PenTool::_spiro_doEffect(SPCurve * curve) { using Geom::X; using Geom::Y; @@ -2178,7 +2132,7 @@ void PenTool::_finishSegment(Geom::Point const p, guint const state) { if (!this->red_curve->is_empty()) { - bspline_spiro(pc,(state & GDK_SHIFT_MASK)); + this->_bspline_spiro(state & GDK_SHIFT_MASK); this->green_curve->append_continuous(this->red_curve, 0.0625); SPCurve *curve = this->red_curve->copy(); diff --git a/src/ui/tools/pen-tool.h b/src/ui/tools/pen-tool.h index 07fc037be..88e528b22 100644 --- a/src/ui/tools/pen-tool.h +++ b/src/ui/tools/pen-tool.h @@ -88,7 +88,34 @@ private: gint _handleButtonRelease(GdkEventButton const &revent); gint _handle2ButtonPress(GdkEventButton const &bevent); gint _handleKeyPress(GdkEvent *event); - + //spanish: añade los modos spiro y bspline + void _pen_context_set_mode(guint mode); + //spanish: esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro + void _bspline_spiro_color(); + //spanish: crea un nodo en modo bspline o spiro + void _bspline_spiro(bool shift); + //spanish: crea un nodo de modo spiro o bspline + void _bspline_spiro_on(); + //spanish: crea un nodo de tipo CUSP + void _bspline_spiro_off(); + //spanish: continua una curva existente en modo bspline o spiro + void _bspline_spiro_start_anchor(bool shift); + //spanish: continua una curva exsitente con el nodo de union en modo bspline o spiro + void _bspline_spiro_start_anchor_on(); + //spanish: continua una curva existente con el nodo de union en modo CUSP + void _bspline_spiro_start_anchor_off(); + //spanish: modifica la "red_curve" cuando se detecta movimiento + void _bspline_spiro_motion(bool shift); + //spanish: cierra la curva con el último nodo en modo bspline o spiro + void _bspline_spiro_end_anchor_on(); + //spanish: cierra la curva con el último nodo en modo CUSP + void _bspline_spiro_end_anchor_off(); + //spanish: unimos todas las curvas en juego y llamamos a la función doEffect. + void _bspline_spiro_build(); + //function bspline cloned from lpe-bspline.cpp + void _bspline_doEffect(SPCurve * curve); + //function spiro cloned from lpe-spiro.cpp + void _spiro_doEffect(SPCurve * curve); void _setInitialPoint(Geom::Point const p); void _setSubsequentPoint(Geom::Point const p, bool statusbar, guint status = 0); void _setCtrl(Geom::Point const p, guint state); -- cgit v1.2.3 From fef7175272bbed79c874496c71092d3ba6e38d98 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 2 Mar 2014 23:50:04 +0100 Subject: Add new curve structure to show temporay item while draw on bspline and spiro, maybe the previous usage of the blue_curve give the strange errors in mac noticed by suv (bzr r11950.1.266) --- src/ui/tools/freehand-base.cpp | 22 ++++++++++++++++++++++ src/ui/tools/freehand-base.h | 4 ++++ src/ui/tools/pen-tool.cpp | 28 +++++++++++++++++++--------- 3 files changed, 45 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 31d2f6191..cb6111bd5 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -82,6 +82,8 @@ FreehandBase::FreehandBase(gchar const *const *cursor_shape, gint hot_x, gint ho , red_curve(NULL) , blue_bpath(NULL) , blue_curve(NULL) + , blue2_bpath(NULL) + , blue2_curve(NULL) , green_bpaths(NULL) , green_curve(NULL) , green_anchor(NULL) @@ -137,6 +139,13 @@ void FreehandBase::setup() { // Create blue curve this->blue_curve = new SPCurve(); + // Create blue2 bpath + this->blue2_bpath = sp_canvas_bpath_new(sp_desktop_sketch(this->desktop), NULL); + sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(this->blue2_bpath), this->blue_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); + + // Create blue2 curve + this->blue2_curve = new SPCurve(); + // Create green curve this->green_curve = new SPCurve(); @@ -483,6 +492,10 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) dc->red_curve->reset(); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(dc->red_bpath), NULL); + // Blue2 + dc->blue2_curve->reset(); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(dc->blue2_bpath), NULL); + //spanish: si c esta vacio, puede ser que se haya tratado de contnuar una curva existente //y se haya cancelado. Si es asi y el modo es bspline o spirolive la curva previa necesita volver a ser seleccionada //porque la modificamos al continuar por un anchor @@ -718,6 +731,15 @@ static void spdc_free_colors(FreehandBase *dc) dc->blue_curve = dc->blue_curve->unref(); } + // Blue2 + if (dc->blue2_bpath) { + sp_canvas_item_destroy(SP_CANVAS_ITEM(dc->blue2_bpath)); + dc->blue2_bpath = NULL; + } + if (dc->blue2_curve) { + dc->blue2_curve = dc->blue2_curve->unref(); + } + // Green while (dc->green_bpaths) { sp_canvas_item_destroy(SP_CANVAS_ITEM(dc->green_bpaths->data)); diff --git a/src/ui/tools/freehand-base.h b/src/ui/tools/freehand-base.h index c8da9faed..d5c2fc9ba 100644 --- a/src/ui/tools/freehand-base.h +++ b/src/ui/tools/freehand-base.h @@ -57,6 +57,10 @@ public: SPCanvasItem *blue_bpath; SPCurve *blue_curve; + // Blue2 + SPCanvasItem *blue2_bpath; + SPCurve *blue2_curve; + // Green GSList *green_bpaths; SPCurve *green_curve; diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 65823b642..5846c3cec 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -1303,6 +1303,9 @@ void PenTool::_resetColors() { // Blue this->blue_curve->reset(); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->blue_bpath), NULL); + // Blue2 + this->blue2_curve->reset(); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->blue2_bpath), NULL); // Green while (this->green_bpaths) { sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data)); @@ -1373,6 +1376,16 @@ void PenTool::_bspline_spiro_color() this->green_color = 0x00ff000; remake_green_bpaths = true; } + }else if(this->bspline){ + //If we come from working with the spiro curve and change the mode the "green_curve" colour is transparent + if(this->green_color != 0xff00007f){ + //since we are not im spiro mode, we assign the original colours + //to the red and the green curve, removing their transparency + this->red_color = 0xff00007f; + //Damos color rojo a la linea verde + this->green_color = 0xff00007f; + remake_green_bpaths = true; + } }else{ //If we come from working with the spiro curve and change the mode the "green_curve" colour is transparent if(this->green_color != 0x00ff007f){ @@ -1383,9 +1396,7 @@ void PenTool::_bspline_spiro_color() remake_green_bpaths = true; } //we hide the spiro/bspline rests - if(!this->bspline){ - sp_canvas_item_hide(this->blue_bpath); - } + sp_canvas_item_hide(this->blue2_bpath); } //We erase all the "green_bpaths" to recreate them after with the colour //transparency recently modified @@ -1771,11 +1782,11 @@ void PenTool::_bspline_spiro_build() this->_spiro_doEffect(curve); } - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->blue_bpath), curve); - sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(this->blue_bpath), this->blue_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); - sp_canvas_item_show(this->blue_bpath); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->blue2_bpath), curve); + sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(this->blue2_bpath), this->blue_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); + sp_canvas_item_show(this->blue2_bpath); curve->unref(); - this->blue_curve->reset(); + this->blue2_curve->reset(); //We hide the holders that doesn't contribute anything if(this->spiro){ sp_canvas_item_show(this->c1); @@ -1787,7 +1798,7 @@ void PenTool::_bspline_spiro_build() sp_canvas_item_hide(this->cl0); }else{ //if the curve is empty - sp_canvas_item_hide(this->blue_bpath); + sp_canvas_item_hide(this->blue2_bpath); } } @@ -2167,7 +2178,6 @@ void PenTool::_finish(gboolean const closed) { desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Drawing finished")); - if(this->spiro || this->bspline) this->blue_curve->reset(); //spanish para cancelar linea sin un segmento creado this->red_curve->reset(); spdc_concat_colors_and_flush(this, closed); -- cgit v1.2.3 From 224de42669ff754155838d37c48a56fa70c9bc94 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 4 Mar 2014 12:38:20 +0100 Subject: Reduce a half the spiro distance to redraw (bzr r11950.1.273) --- src/ui/tools/pen-tool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 5846c3cec..0c97bd445 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -710,7 +710,7 @@ gint PenTool::_handleMotionNotify(GdkEventMotion const &mevent) { this->_bspline_spiro_color(); this->_bspline_spiro_motion(mevent.state & GDK_SHIFT_MASK); }else{ - if ( Geom::LInfty( event_w - pen_drag_origin_w ) > tolerance || mevent.time == 0) { + if ( Geom::LInfty( event_w - pen_drag_origin_w ) > (tolerance/2) || mevent.time == 0) { this->_bspline_spiro_color(); this->_bspline_spiro_motion(mevent.state & GDK_SHIFT_MASK); pen_drag_origin_w = event_w; -- cgit v1.2.3 From 3d7f15d8b4adc83c04a2ba5c654529beeeec0c3b Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 4 Mar 2014 20:23:58 +0100 Subject: Change tooltip to one more explicit to make cusp nodes (bzr r11950.1.275) --- src/ui/tools/pen-tool.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 0c97bd445..ad77fcb53 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -642,7 +642,7 @@ gint PenTool::_handleMotionNotify(GdkEventMotion const &mevent) { if(!this->spiro && !this->bspline){ this->message_context->set(Inkscape::NORMAL_MESSAGE, _("Click or click and drag to close and finish the path.")); }else{ - this->message_context->set(Inkscape::NORMAL_MESSAGE, _("Click or click and drag to close and finish the path. Shift to cusp node")); + this->message_context->set(Inkscape::NORMAL_MESSAGE, _("Click or click and drag to close and finish the path. Shift+Click make a cusp node")); } this->anchor_statusbar = true; } else if (!anchor && this->anchor_statusbar) { @@ -656,7 +656,7 @@ gint PenTool::_handleMotionNotify(GdkEventMotion const &mevent) { if(!this->spiro && !this->bspline){ this->message_context->set(Inkscape::NORMAL_MESSAGE, _("Click or click and drag to continue the path from this point.")); }else{ - this->message_context->set(Inkscape::NORMAL_MESSAGE, _("Click or click and drag to continue the path from this point. Shift to cusp node")); + this->message_context->set(Inkscape::NORMAL_MESSAGE, _("Click or click and drag to continue the path from this point. Shift+Click make a cusp node")); } this->anchor_statusbar = true; } else if (!anchor && this->anchor_statusbar) { @@ -2084,8 +2084,8 @@ void PenTool::_setSubsequentPoint(Geom::Point const p, bool statusbar, guint sta _("Line segment: angle %3.2f°, distance %s; with Ctrl to snap angle, Enter to finish the path"); if(this->spiro || this->bspline){ message = is_curve ? - _("Curve segment: angle %3.2f°, distance %s; with Shift to cusp node, Enter to finish the path" ): - _("Line segment: angle %3.2f°, distance %s; with Shift to cusp node, Enter to finish the path"); + _("Curve segment: angle %3.2f°, distance %s; with Shift+Click make a cusp node, Enter to finish the path" ): + _("Line segment: angle %3.2f°, distance %s; with Shift+Click make a cusp node, Enter to finish the path"); } this->_setAngleDistanceStatusMessage(p, 0, message); } -- cgit v1.2.3 From 9ae7e81723f4ea4e2640ed01d55d94e73874804f Mon Sep 17 00:00:00 2001 From: Guiu Rocafort Date: Wed, 5 Mar 2014 12:37:27 +0100 Subject: translations from spanish to english done, it might need a little review, but everything seems ok (bzr r11950.5.1) --- src/ui/tool/curve-drag-point.cpp | 5 ++- src/ui/tool/multi-path-manipulator.cpp | 5 ++- src/ui/tool/node.cpp | 64 ++++++++++++++++---------------- src/ui/tool/node.h | 2 +- src/ui/tool/path-manipulator.cpp | 14 +++---- src/ui/tools/freehand-base.cpp | 23 ++++++------ src/ui/tools/node-tool.h | 3 +- src/ui/tools/pen-tool.cpp | 67 ++++++++++++++++------------------ src/ui/tools/pen-tool.h | 26 ++++++------- src/ui/tools/pencil-tool.cpp | 4 +- 10 files changed, 106 insertions(+), 107 deletions(-) (limited to 'src') diff --git a/src/ui/tool/curve-drag-point.cpp b/src/ui/tool/curve-drag-point.cpp index e5412fdc2..ad03cf75d 100644 --- a/src/ui/tool/curve-drag-point.cpp +++ b/src/ui/tool/curve-drag-point.cpp @@ -53,7 +53,7 @@ bool CurveDragPoint::grabbed(GdkEventMotion */*event*/) // delta is a vector equal 1/3 of distance from first to second Geom::Point delta = (second->position() - first->position()) / 3.0; - //spanish: solo actualizamos los nodos si no es bspline + // only update the nodes if the mode is bspline if(!_pm.isBSpline(false)){ first->front()->move(first->front()->position() + delta); second->back()->move(second->back()->position() - delta); @@ -89,7 +89,8 @@ void CurveDragPoint::dragged(Geom::Point &new_pos, GdkEventMotion *event) Geom::Point delta = new_pos - position(); Geom::Point offset0 = ((1-weight)/(3*t*(1-t)*(1-t))) * delta; Geom::Point offset1 = (weight/(3*t*t*(1-t))) * delta; - //spanish: modificado para que, si el trazado es bspline solo actue si está presionada la tecla SHIFT + + //modified so that, if the trace is bspline, it only acts if the SHIFT key is pressed if(!_pm.isBSpline(false)){ first->front()->move(first->front()->position() + offset0); second->back()->move(second->back()->position() + offset1); diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp index b7f3ac29b..68aaa77a5 100644 --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@ -671,9 +671,10 @@ bool MultiPathManipulator::event(Inkscape::UI::Tools::ToolBase *event_context, G // b) ctrl+del preserves shape (del_preserves_shape is false), and control is pressed // Hence xor guint mode = prefs->getInt("/tools/freehand/pen/freehand-mode", 0); - //spanish: si es trazado bspline (mode 2) + + //if the trace is bspline ( mode 2) if(mode==2){ - //spanish: ¿correcto? + // is this correct ? if(del_preserves_shape ^ held_control(event->key)) deleteNodes(false); else diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 78d8fe833..73460a313 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -167,7 +167,7 @@ void Handle::move(Geom::Point const &new_pos) } setPosition(new_pos); - //spanish: mueve el tirador y su opuesto la misma proporción + //move the handler and its oposite the same proportion if(_pm().isBSpline(false)){ setPosition(_pm().BSplineHandleReposition(this)); this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),_parent->bsplineWeight)); @@ -184,7 +184,7 @@ void Handle::move(Geom::Point const &new_pos) / Geom::L2sq(direction)) * direction; setRelativePos(new_delta); - //spanish: mueve el tirador y su opuesto la misma proporción + //move the handler and its oposite the same proportion if(_pm().isBSpline(false)){ setPosition(_pm().BSplineHandleReposition(this)); this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),_parent->bsplineWeight)); @@ -210,7 +210,7 @@ void Handle::move(Geom::Point const &new_pos) } setPosition(new_pos); - //spanish: mueve el tirador y su opuesto la misma proporción + // moves the handler and its oposite the same proportion if(_pm().isBSpline(false)){ setPosition(_pm().BSplineHandleReposition(this)); this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),_parent->bsplineWeight)); @@ -292,7 +292,7 @@ bool Handle::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEven break; default: break; } - //spanish: nuevo evento de doble click para resetear a la proporción por defecto, 0.3334%, los tiradores de un nodo + // new double click event to set the handlers of a node to the default proportion, 0.3334% case GDK_2BUTTON_PRESS: handle_2button_press(); break; @@ -303,7 +303,7 @@ bool Handle::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEven return ControlPoint::_eventHandler(event_context, event); } -//spanish: función que mueve el tirador y su opuesto a la proporción por defecto de 0.3334 +//this function moves the handler and its oposite to the default proportion of 0.3334 void Handle::handle_2button_press(){ if(_pm().isBSpline(false)){ setPosition(_pm().BSplineHandleReposition(this,0.3334)); @@ -359,8 +359,8 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) ctrl_constraint = Inkscape::Snapper::SnapConstraint(parent_pos, parent_pos - perp_pos); } new_pos = result; - //spanish: mueve el tirador y su opuesto en X posiciones fijas depenfiendo de la configuración de el - //parametro "steps whith control" del efecto en vivo BSpline + // moves the handler and its oposite in X fixed positions depending on parameter "steps with control" + // by default in live BSpline if(_pm().isBSpline(false)){ setPosition(new_pos); int steps = _pm().BSplineGetSteps(); @@ -370,7 +370,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) } std::vector unselected; - //spanish: si está activado el ajuste (snap) y no es bspline + //if the snap adjustment is activated and it is not bspline if (snap && !_pm().isBSpline(false)) { ControlPointSelection::Set &nodes = _parent->_selection.allPoints(); for (ControlPointSelection::Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { @@ -411,8 +411,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) other()->setPosition(_saved_other_pos); } } - //spanish: si es bspline pero no está presionado SHIFT o CONTROL - //lo fija en la posición original + //if it is bspline but SHIFT or CONTROL are not pressed it fixes it in the original position if(_pm().isBSpline(false) && !held_shift(*event) && !held_control(*event)){ new_pos=_last_drag_origin(); } @@ -432,7 +431,7 @@ void Handle::ungrabbed(GdkEventButton *event) Geom::Point dist = _desktop->d2w(_parent->position()) - _desktop->d2w(position()); if (dist.length() <= drag_tolerance) { move(_parent->position()); - //spanish: marca la fuerza del bspline como 0.0000 + //sets the bspline strength to 0.0000 if(_pm().isBSpline(false)){ _parent->bsplineWeight = 0.0000; } @@ -478,9 +477,9 @@ static double snap_increment_degrees() { Glib::ustring Handle::_getTip(unsigned state) const { char const *more; - //spanish: un truco para, si el nodo tiene fuerza, nos marca que es - //del tipo bspline, lo utilizaremos despues para mostras los mensajes apropiados - //no lo podemos hacer de otra forma al ser constante la funcion + // a trick to mark as bspline if the node has no strength, we are going to use it later + // to show the appropiate messages. We cannot do it in any different way becasue the function is constant + bool isBSpline = false; if( _parent->bsplineWeight != 0.0000) isBSpline = true; @@ -622,8 +621,8 @@ void Node::move(Geom::Point const &new_pos) // move handles when the node moves. Geom::Point old_pos = position(); Geom::Point delta = new_pos - position(); - //spanish: guardamos la fuerza anterior del nodo para reaplicarsela - //de nuevo una vez sea movido el nodo + + // save the previous node strength to apply it again once the node is moved double oldPos = 0.0000; Node *n = this; if(_pm().isBSpline(false)){ @@ -638,8 +637,8 @@ void Node::move(Geom::Point const &new_pos) // if the node has a smooth handle after a line segment, it should be kept colinear // with the segment _fixNeighbors(old_pos, new_pos); - //spanish: movemos los tiradores involucrados, primero los del nodo en cuestión - //y despues los de los nodos colindantes + + // move the affected handlers. First the node ones, later the adjoining ones. if(_pm().isBSpline(false)){ _front.setPosition(_pm().BSplineHandleReposition(this->front(),oldPos)); _back.setPosition(_pm().BSplineHandleReposition(this->back(),oldPos)); @@ -649,8 +648,7 @@ void Node::move(Geom::Point const &new_pos) void Node::transform(Geom::Affine const &m) { - //spanish: guardamos la fuerza anterior del nodo para reaplicarsela - //de nuevo una vez sea movido el nodo + // save the previous node strength to apply it again later when the node is moved double oldPos = 0.0000; if(_pm().isBSpline(false)){ oldPos = this->bsplineWeight; @@ -663,8 +661,8 @@ void Node::transform(Geom::Affine const &m) /* Affine transforms keep handle invariants for smooth and symmetric nodes, * but smooth nodes at ends of linear segments and auto nodes need special treatment */ _fixNeighbors(old_pos, position()); - //spanish: movemos los tiradores involucrados, primero los del nodo en cuestión - //y despues los de los nodos colindantes + + // move the involved handlers, first the node ones, later the adjoining ones if(_pm().isBSpline(false)){ _front.setPosition(_pm().BSplineHandleReposition(this->front(),oldPos)); _back.setPosition(_pm().BSplineHandleReposition(this->back(),oldPos)); @@ -755,9 +753,11 @@ void Node::showHandles(bool v) if (!_back.isDegenerate()) { _back.setVisible(v); } - //spanish: definimos la fuerza de los nodos,según sea o no trazado bspline. - //Cada vez que actuemos sobre dichos tiradores en un trazado - //bspline esta fuerza se tiene que actualizar + + // define the node strength, depending on being or not bspline traced. + // every time we operate over these handlers in a trace bspline + // that strength needs to be updated. + this->bsplineWeight = 0.0000; if(_pm().isBSpline(false) && (!_front.isDegenerate() || !_back.isDegenerate())){ if (!_front.isDegenerate()) { @@ -868,9 +868,8 @@ void Node::setType(NodeType type, bool update_handles) break; default: break; } - //spanish: en los cambios de tipo de nodo, sobre trazados bspline, - //o bien los mantenemos con potencia 0.0000 en modo esquina - //o les damos la potencia por defecto en modo de curva + /* in node type changes, about bspline traces, we can mantain them with 0.0000 power in border mode, + or we give them the default power in curve mode */ if(_pm().isBSpline(false)){ if(this->bsplineWeight !=0.0000) this->bsplineWeight = 0.3334; _front.setPosition(_pm().BSplineHandleReposition(this->front(),this->bsplineWeight)); @@ -1123,7 +1122,7 @@ void Node::_setState(State state) case STATE_CLICKED: mgr.setActive(_canvas_item, true); mgr.setPrelight(_canvas_item, false); - //spanish: esto muestra los tiradores al seleccionar los nodos + //this shows the handlers when selecting the nodes if(_pm().isBSpline(false)){ if(!this->back()->isDegenerate()){ _pm().BSplineHandlePosition(this->back()); @@ -1389,9 +1388,10 @@ Node *Node::nodeAwayFrom(Handle *h) Glib::ustring Node::_getTip(unsigned state) const { - //spanish: un truco par, si el nodo tiene fuerza, nos marca que es - //del tipo bspline, lo utilizaremos despues para mostras los mensajes apropiados - //no lo podemos hacer de otra forma al ser constante la funcion + + /* if the node doesnt have strength, it marks it as bspline, we'll use it later + to show the appropiate messages. We cannot do it in any other way, because the + function is constant */ bool isBSpline = false; if( this->bsplineWeight != 0.0000) isBSpline = true; diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h index b7d6951d0..4393446d9 100644 --- a/src/ui/tool/node.h +++ b/src/ui/tool/node.h @@ -187,7 +187,7 @@ public: bool isEndNode() const; Handle *front() { return &_front; } Handle *back() { return &_back; } - //spanish: creamos valor de potencia bspline asociado a cada nodo + //strength value for each node double bsplineWeight; /** diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index a6689d93d..1cc075603 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -663,7 +663,7 @@ unsigned PathManipulator::_deleteStretch(NodeList::iterator start, NodeList::ite nl.erase(start); start = next; } - //spanish: si se borra, reajustamos los tiradores + // if we are removing, we readjust the handlers if(isBSpline(false)){ double pos = 0.0000; if(start.prev()){ @@ -1182,7 +1182,7 @@ void PathManipulator::_createControlPointsFromGeometry() } } -//spanish: determina si el trazado tiene efecto bspline y el numero de pasos que realiza +//determines if the trace has a bspline effect and the number of steps that it takes int PathManipulator::BSplineGetSteps(){ LivePathEffect::LPEBSpline *lpe_bsp = NULL; @@ -1200,7 +1200,7 @@ int PathManipulator::BSplineGetSteps(){ return steps; } -//spanish: determina si el trazado tiene efecto bspline +// determines if the trace has bspline effect bool PathManipulator::isBSpline(bool recalculate){ static int BSplineSteps = this->BSplineGetSteps(); if(recalculate){ @@ -1213,7 +1213,7 @@ bool PathManipulator::isBSpline(bool recalculate){ return isBSpline; } -//spanish: devuelve la fuerza que le corresponderia a la posicón de un tirador +// returns the corresponding strength to the position of a handler double PathManipulator::BSplineHandlePosition(Handle *h){ using Geom::X; using Geom::Y; @@ -1231,13 +1231,13 @@ double PathManipulator::BSplineHandlePosition(Handle *h){ return pos; } -//spanish: mueve el tirador a la posición que le corresponda +// moves the handler to the corresponding position Geom::Point PathManipulator::BSplineHandleReposition(Handle *h){ double pos = this->BSplineHandlePosition(h); return BSplineHandleReposition(h,pos); } -//spanish: mueve el tirador a una posición específica +// moves the handler to the specified position Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){ using Geom::X; using Geom::Y; @@ -1263,7 +1263,7 @@ Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){ return ret; } -//spanish: mueve los tiradores del nodo y sus tiradores opuestos a la potencia de sus nodos +//moves the node handlers and its oposite handlers to the strength of its nodes void PathManipulator::BSplineNodeHandlesReposition(Node *n){ Node * nextNode = n->nodeToward(n->front()); Node * prevNode = n->nodeToward(n->back()); diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index cb6111bd5..40a257de9 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -252,7 +252,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1) { Effect::createAndApply(SPIRO, dc->desktop->doc(), item); } - //spanish: añadimos el modo bspline a los efectos en espera + //add the bspline node in the waiting effects if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2) { Effect::createAndApply(BSPLINE, dc->desktop->doc(), item); } @@ -496,9 +496,9 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) dc->blue2_curve->reset(); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(dc->blue2_bpath), NULL); - //spanish: si c esta vacio, puede ser que se haya tratado de contnuar una curva existente - //y se haya cancelado. Si es asi y el modo es bspline o spirolive la curva previa necesita volver a ser seleccionada - //porque la modificamos al continuar por un anchor + /* if c is empty, it might be that the user was trying to continue an existing curve and cancelled. + if this is the case and we are in bspline or spirolive the previous curve needs to be selected again because + we modify it when continuing through an anchor. */ if (c->is_empty()) { if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ SPDesktop *desktop = dc->desktop; @@ -527,8 +527,10 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) { // We hit bot start and end of single curve, closing paths dc->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Closing path.")); - //spanish: si estamos en modo bspline o spirolive, la curva de continuación y finalización es actualizada al continuar o finalizar la curva en un anchor - //esto proboca que la función original no detecte si es la misma curva en el caso de curvas con multiples partes -shift- y cierre de manera erronea una de las partes + + /* if we are in bspline or spirolive mode, the continuation and ending curve are updated when continuing or ending the curve in an anchor. + this causes that the original function doesn't detect if it's the same curve in case the curves have multiples parts -shift- and + close incorrectly one of the parts */ if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ if (dc->sa->start && !(dc->sa->curve->is_closed()) ) { @@ -547,8 +549,8 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) c->unref(); dc->sa->curve->closepath_current(); } - //spanish: Si la curva tiene un LPE del tipo bspline o spiro ejecutamos spdc_flush_white - //pasándole la curva de inicio necesaria + + //if the curve has an bspline or spiro LPE, we execute spdc_flush_white, passing the necessary starting curve. if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ dc->white_curves = g_slist_remove(dc->white_curves, dc->sa->curve); @@ -679,9 +681,8 @@ SPDrawAnchor *spdc_test_inside(FreehandBase *dc, Geom::Point p) } } - //spanish: modificamos la curva de anclaje para que sea igual que la curva de inicio. - //esta curva fue modificada al continuar la curva y necesitamos que sea igual que la curva en - //la que cerramos el trazado. + /* modify the anchoring curve so it is equal to the starting curve. + this curve is modified when it's modified and we need them to be equal to the closing curve */ Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if((prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2) && diff --git a/src/ui/tools/node-tool.h b/src/ui/tools/node-tool.h index 168ec995a..42f89cd1c 100644 --- a/src/ui/tools/node-tool.h +++ b/src/ui/tools/node-tool.h @@ -14,7 +14,8 @@ #include #include #include "ui/tools/tool-base.h" -//spanish: lo necesitamos para llamarlo desde el Live Effect + +// we need it to call it from Live Effect #include "selection.h" namespace Inkscape { diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 5846c3cec..bb1a03b7c 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -42,7 +42,7 @@ #include "context-fns.h" #include "tools-switch.h" #include "ui/control-manager.h" -//spanish: incluimos los archivos necesarios para las BSpline y Spiro +// we include the necessary files for BSpline & Spiro #include "live_effects/effect.h" #include "live_effects/lpeobject.h" #include "live_effects/lpeobject-reference.h" @@ -166,7 +166,7 @@ PenTool::~PenTool() { void PenTool::setPolylineMode() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); guint mode = prefs->getInt("/tools/freehand/pen/freehand-mode", 0); - //spanish: cambiamos los modos para dar cabida al modo bspline + // change the nodes to make space for bspline mode this->polylines_only = (mode == 3 || mode == 4); this->polylines_paraxial = (mode == 4); //we call the function which defines the Spiro modes and the BSpline @@ -178,7 +178,7 @@ void PenTool::setPolylineMode() { *.Set the mode of draw spiro, and bsplines */ void PenTool::_pen_context_set_mode(guint mode) { - //spanish: definimos los modos + // define the nodes this->spiro = (mode == 1); this->bspline = (mode == 2); } @@ -386,7 +386,7 @@ gint PenTool::_handleButtonPress(GdkEventButton const &bevent) { if(bevent.button != 3 && (this->spiro || this->bspline) && this->npoints > 0 && this->p[0] == this->p[3]){ this->state = PenTool::STOP; if( anchor && anchor == this->sa && this->green_curve->is_empty()){ - //spanish Borrar siguiente linea para evitar un nodo encima de otro + //remove the following line to avoid having one node on top of another _finishSegment(event_dt, bevent.state); _finish( FALSE); return TRUE; @@ -512,7 +512,7 @@ gint PenTool::_handleButtonPress(GdkEventButton const &bevent) { } } - //spanish: evitamos la creación de un punto de control para que se cree el nodo en el evento de soltar + // avoid the creation of a control point so a node is created in the release event this->state = (this->spiro || this->bspline || this->polylines_only) ? PenTool::POINT : PenTool::CONTROL; ret = TRUE; @@ -705,7 +705,7 @@ gint PenTool::_handleMotionNotify(GdkEventMotion const &mevent) { default: break; } - //spanish: lanzamos la función "bspline_spiro_motion" al moverse el ratón o cuando se para. + // calls the function "bspline_spiro_motion" when the mouse starts or stops moving if(this->bspline){ this->_bspline_spiro_color(); this->_bspline_spiro_motion(mevent.state & GDK_SHIFT_MASK); @@ -743,9 +743,7 @@ gint PenTool::_handleButtonRelease(GdkEventButton const &revent) { // Test whether we hit any anchor. SPDrawAnchor *anchor = spdc_test_inside(this, event_w); - //with this we avoid creating a new point over the existing one - //spanish: si intentamos crear un nodo en el mismo sitio que el origen, paramos. - + // if we try to create a node in the same place as another node, we skip if((!anchor || anchor == this->sa) && (this->spiro || this->bspline) && this->npoints > 0 && this->p[0] == this->p[3]){ return TRUE; } @@ -760,7 +758,7 @@ gint PenTool::_handleButtonRelease(GdkEventButton const &revent) { p = anchor->dp; } this->sa = anchor; - //spanish: continuamos una curva existente + // continue the existing curve if (anchor) { if(this->bspline || this->spiro){ this->_bspline_spiro_start_anchor(revent.state & GDK_SHIFT_MASK);; @@ -790,7 +788,7 @@ gint PenTool::_handleButtonRelease(GdkEventButton const &revent) { this->_endpointSnap(p, revent.state); } this->_finishSegment(p, revent.state); - //spanish: ocultamos la guia del penultimo nodo al cerrar la curva + // hude the guide of the penultimate node when closing the curve if(this->spiro){ sp_canvas_item_hide(this->c1); } @@ -817,7 +815,7 @@ gint PenTool::_handleButtonRelease(GdkEventButton const &revent) { case PenTool::CLOSE: this->_endpointSnap(p, revent.state); this->_finishSegment(p, revent.state); - //spanish: ocultamos la guia del penultimo nodo al cerrar la curva + // hide the penultimate node guide when closing the curve if(this->spiro){ sp_canvas_item_hide(this->c1); } @@ -908,7 +906,7 @@ void PenTool::_redrawAll() { sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve); // handles - //spanish: ocultamos los tiradores en modo bspline y spiro + // hide the handlers in bspline and spiro modes if (this->p[0] != this->p[1] && !this->spiro && !this->bspline) { SP_CTRL(this->c1)->moveto(this->p[1]); this->cl1->setCoords(this->p[0], this->p[1]); @@ -922,7 +920,7 @@ void PenTool::_redrawAll() { Geom::Curve const * last_seg = this->green_curve->last_segment(); if (last_seg) { Geom::CubicBezier const * cubic = dynamic_cast( last_seg ); - //spanish: ocultamos los tiradores en modo bspline y spiro + // hide the handlers in bspline and spiro modes if ( cubic && (*cubic)[2] != this->p[0] && !this->spiro && !this->bspline ) { @@ -937,9 +935,8 @@ void PenTool::_redrawAll() { } } - //spanish: simplemente redibujamos la spiro. - //como es un redibujo simplemente no llamamos a la función global sino al final de esta - //Lanzamos solamente el redibujado + // simply redraw the spiro. because its a redrawing, we don't call the global function, + // but we call the redrawing at the ending. this->_bspline_spiro_build(); } @@ -969,12 +966,12 @@ void PenTool::_lastpointMoveScreen(gdouble x, gdouble y) { } void PenTool::_lastpointToCurve() { - //spanish: evitamos que si la "red_curve" tiene solo dos puntos -recta- no se pare aqui. + // avoid that if the "red_curve" contains only two points ( rect ), it doesn't stop here. if (this->npoints != 5 && !this->spiro && !this->bspline) return; Geom::CubicBezier const * cubic; this->p[1] = this->red_curve->last_segment()->initialPoint() + (1./3)* (Geom::Point)(this->red_curve->last_segment()->finalPoint() - this->red_curve->last_segment()->initialPoint()); - //spanish: modificamos el último segmento de la curva verde para que forme el tipo de nodo que deseamos + //modificate the last segment of the green curve so it creates the type of node we need if(this->spiro||this->bspline){ if(!this->green_curve->is_empty()){ Geom::Point A(0,0); @@ -1012,7 +1009,7 @@ void PenTool::_lastpointToCurve() { this->green_curve->append_continuous(previous, 0.0625); } } - //spanish: si el último nodo es una union con otra curva + //if the last node is an union with another curve if(this->green_curve->is_empty() && this->sa && !this->sa->curve->is_empty()){ this->_bspline_spiro_start_anchor(false); } @@ -1023,11 +1020,11 @@ void PenTool::_lastpointToCurve() { void PenTool::_lastpointToLine() { - //spanish: evitamos que si la "red_curve" tiene solo dos puntos -recta- no se pare aqui. + // avoid that if the "red_curve" contains only two points ( rect) it doesn't stop here. if (this->npoints != 5 && !this->bspline) return; - //spanish: modificamos el último segmento de la curva verde para que forme el tipo de nodo que deseamos + // modify the last segment of the green curve so the type of node we want is created. if(this->spiro || this->bspline){ if(!this->green_curve->is_empty()){ Geom::Point A(0,0); @@ -1059,7 +1056,7 @@ void PenTool::_lastpointToLine() { this->green_curve->append_continuous(previous, 0.0625); } } - //spanish: si el último nodo es una union con otra curva + // if the last node is an union with another curve if(this->green_curve->is_empty() && this->sa && !this->sa->curve->is_empty()){ this->_bspline_spiro_start_anchor(true); } @@ -1248,7 +1245,7 @@ gint PenTool::_handleKeyPress(GdkEvent *event) { this->p[1] = this->p[0]; } - //spanish: asignamos el valor a un tercio de distancia del último segmento. + // asign the value in a third of the distance of the last segment. if(this->bspline){ this->p[1] = this->p[0] + (1./3)*(this->p[3] - this->p[0]); } @@ -1258,7 +1255,7 @@ gint PenTool::_handleKeyPress(GdkEvent *event) { : this->p[3])); this->npoints = 2; - //spanish: eliminamos el último segmento de la curva verde + // delete the last segment of the green curve if( this->green_curve->get_segment_count() == 1){ this->npoints = 5; if (this->green_bpaths) { @@ -1270,7 +1267,7 @@ gint PenTool::_handleKeyPress(GdkEvent *event) { }else{ this->green_curve->backspace(); } - //spanish: asignamos el valor de this->p[1] a el opuesto de el ultimo segmento de la línea verde + // assign the value of this->p[1] to the oposite of the green line last segment if(this->spiro){ cubic = dynamic_cast(this->green_curve->last_segment()); if ( cubic ) { @@ -1285,7 +1282,8 @@ gint PenTool::_handleKeyPress(GdkEvent *event) { this->state = PenTool::POINT; this->_setSubsequentPoint(pt, true); pen_last_paraxial_dir = !pen_last_paraxial_dir; - //spanish: redibujamos + + //redraw this->_bspline_spiro_build(); ret = TRUE; } @@ -1360,9 +1358,7 @@ void PenTool::_setAngleDistanceStatusMessage(Geom::Point const p, int pc_point_t g_string_free(dist, FALSE); } - - -//spanish: esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro +// this function changes the colors red, green and blue making them transparent or not, depending on if spiro is being used. void PenTool::_bspline_spiro_color() { bool remake_green_bpaths = false; @@ -1736,8 +1732,7 @@ void PenTool::_bspline_spiro_end_anchor_off() } } - -//spanish: preparates the curves for its trasformation into BSline curves. +//prepares the curves for its transformation into BSpline curve. void PenTool::_bspline_spiro_build() { if(!this->spiro && !this->bspline) @@ -1766,7 +1761,7 @@ void PenTool::_bspline_spiro_build() } if(!curve->is_empty()){ - //spanish: cerramos la curva si estan cerca los puntos finales de la curva + // close the curve if the final points of the curve are close enough if(Geom::are_near(curve->first_path()->initialPoint(), curve->last_path()->finalPoint())){ curve->closepath_current(); } @@ -1805,7 +1800,7 @@ void PenTool::_bspline_spiro_build() void PenTool::_bspline_doEffect(SPCurve * curve) { - //spanish: comentado en funcion "doEffect" de src/live_effects/lpe-bspline.cpp + // commenting the function doEffect in src/live_effects/lpe-bspline.cpp if(curve->get_segment_count() < 2) return; Geom::PathVector const original_pathv = curve->get_pathvector(); @@ -1945,7 +1940,7 @@ void PenTool::_bspline_doEffect(SPCurve * curve) } //Spiro function cloned from lpe-spiro.cpp -//spanish: comentado en funcion "doEffect" de src/live_effects/lpe-spiro.cpp +// commenting the function "doEffect" from src/live_effects/lpe-spiro.cpp void PenTool::_spiro_doEffect(SPCurve * curve) { using Geom::X; @@ -2178,7 +2173,7 @@ void PenTool::_finish(gboolean const closed) { desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Drawing finished")); - //spanish para cancelar linea sin un segmento creado + // cancelate line without a created segment this->red_curve->reset(); spdc_concat_colors_and_flush(this, closed); this->sa = NULL; diff --git a/src/ui/tools/pen-tool.h b/src/ui/tools/pen-tool.h index 88e528b22..95565abc9 100644 --- a/src/ui/tools/pen-tool.h +++ b/src/ui/tools/pen-tool.h @@ -49,7 +49,7 @@ public: bool polylines_only; bool polylines_paraxial; - //spanish: propiedad que guarda si el modo Spiro está activo o no + // propiety which saves if Spiro mode is active or not bool spiro; bool bspline; int num_clicks; @@ -88,29 +88,29 @@ private: gint _handleButtonRelease(GdkEventButton const &revent); gint _handle2ButtonPress(GdkEventButton const &bevent); gint _handleKeyPress(GdkEvent *event); - //spanish: añade los modos spiro y bspline + //adds spiro & bspline modes void _pen_context_set_mode(guint mode); - //spanish: esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro + //this function changes the colors red, green and blue making them transparent or not depending on if the function uses spiro void _bspline_spiro_color(); - //spanish: crea un nodo en modo bspline o spiro + //creates a node in bspline or spiro modes void _bspline_spiro(bool shift); - //spanish: crea un nodo de modo spiro o bspline + //creates a node in bspline or spiro modes void _bspline_spiro_on(); - //spanish: crea un nodo de tipo CUSP + //creates a CUSP node void _bspline_spiro_off(); - //spanish: continua una curva existente en modo bspline o spiro + //continues the existing curve in bspline or spiro mode void _bspline_spiro_start_anchor(bool shift); - //spanish: continua una curva exsitente con el nodo de union en modo bspline o spiro + //continues the existing curve with the union node in bspline or spiro modes void _bspline_spiro_start_anchor_on(); - //spanish: continua una curva existente con el nodo de union en modo CUSP + //continues an existing curve with the union node in CUSP mode void _bspline_spiro_start_anchor_off(); - //spanish: modifica la "red_curve" cuando se detecta movimiento + //modifies the "red_curve" when it detects movement void _bspline_spiro_motion(bool shift); - //spanish: cierra la curva con el último nodo en modo bspline o spiro + //closes the curve with the last node in bspline or spiro mode void _bspline_spiro_end_anchor_on(); - //spanish: cierra la curva con el último nodo en modo CUSP + //closes the curve with the last node in CUSP mode void _bspline_spiro_end_anchor_off(); - //spanish: unimos todas las curvas en juego y llamamos a la función doEffect. + //CHECK: join all the curves "in game" and we call doEffect function void _bspline_spiro_build(); //function bspline cloned from lpe-bspline.cpp void _bspline_doEffect(SPCurve * curve); diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp index bd50672af..1ccdee637 100644 --- a/src/ui/tools/pencil-tool.cpp +++ b/src/ui/tools/pencil-tool.cpp @@ -685,7 +685,7 @@ void PencilTool::_interpolate() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); guint mode = prefs->getInt("/tools/freehand/pencil/freehand-mode", 0); for (int c = 0; c < n_segs; c++) { - //spanish: si el modo es BSpline modificamos para que el trazado cree los nodos adhoc + // if we are in BSpline we modify the trace to create adhoc nodes if(mode == 2){ Geom::Point BP = b[4*c+0] + (1./3)*(b[4*c+3] - b[4*c+0]); BP = Geom::Point(BP[X] + 0.0001,BP[Y] + 0.0001); @@ -835,7 +835,7 @@ void PencilTool::_fitAndSplit() { this->red_curve->moveto(b[0]); using Geom::X; using Geom::Y; - //spanish: si el modo es BSpline modificamos para que el trazado cree los nodos adhoc + // if we are in BSpline we modify the trace to create adhoc nodes Inkscape::Preferences *prefs = Inkscape::Preferences::get(); guint mode = prefs->getInt("/tools/freehand/pencil/freehand-mode", 0); if(mode == 2){ -- cgit v1.2.3 From a9eea1cea2a13f129bcb30f175cea82ffcbcee29 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 5 Mar 2014 20:03:46 +0100 Subject: Translations (bzr r11950.1.279) --- src/ui/tool/curve-drag-point.cpp | 5 +-- src/ui/tool/multi-path-manipulator.cpp | 5 +-- src/ui/tool/node.cpp | 64 ++++++++++++++++---------------- src/ui/tool/node.h | 2 +- src/ui/tool/path-manipulator.cpp | 14 +++---- src/ui/tools/freehand-base.cpp | 23 ++++++------ src/ui/tools/node-tool.h | 3 +- src/ui/tools/pen-tool.cpp | 67 ++++++++++++++++++---------------- src/ui/tools/pen-tool.h | 26 ++++++------- src/ui/tools/pencil-tool.cpp | 4 +- 10 files changed, 107 insertions(+), 106 deletions(-) (limited to 'src') diff --git a/src/ui/tool/curve-drag-point.cpp b/src/ui/tool/curve-drag-point.cpp index ad03cf75d..e5412fdc2 100644 --- a/src/ui/tool/curve-drag-point.cpp +++ b/src/ui/tool/curve-drag-point.cpp @@ -53,7 +53,7 @@ bool CurveDragPoint::grabbed(GdkEventMotion */*event*/) // delta is a vector equal 1/3 of distance from first to second Geom::Point delta = (second->position() - first->position()) / 3.0; - // only update the nodes if the mode is bspline + //spanish: solo actualizamos los nodos si no es bspline if(!_pm.isBSpline(false)){ first->front()->move(first->front()->position() + delta); second->back()->move(second->back()->position() - delta); @@ -89,8 +89,7 @@ void CurveDragPoint::dragged(Geom::Point &new_pos, GdkEventMotion *event) Geom::Point delta = new_pos - position(); Geom::Point offset0 = ((1-weight)/(3*t*(1-t)*(1-t))) * delta; Geom::Point offset1 = (weight/(3*t*t*(1-t))) * delta; - - //modified so that, if the trace is bspline, it only acts if the SHIFT key is pressed + //spanish: modificado para que, si el trazado es bspline solo actue si está presionada la tecla SHIFT if(!_pm.isBSpline(false)){ first->front()->move(first->front()->position() + offset0); second->back()->move(second->back()->position() + offset1); diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp index 68aaa77a5..b7f3ac29b 100644 --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@ -671,10 +671,9 @@ bool MultiPathManipulator::event(Inkscape::UI::Tools::ToolBase *event_context, G // b) ctrl+del preserves shape (del_preserves_shape is false), and control is pressed // Hence xor guint mode = prefs->getInt("/tools/freehand/pen/freehand-mode", 0); - - //if the trace is bspline ( mode 2) + //spanish: si es trazado bspline (mode 2) if(mode==2){ - // is this correct ? + //spanish: ¿correcto? if(del_preserves_shape ^ held_control(event->key)) deleteNodes(false); else diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 73460a313..78d8fe833 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -167,7 +167,7 @@ void Handle::move(Geom::Point const &new_pos) } setPosition(new_pos); - //move the handler and its oposite the same proportion + //spanish: mueve el tirador y su opuesto la misma proporción if(_pm().isBSpline(false)){ setPosition(_pm().BSplineHandleReposition(this)); this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),_parent->bsplineWeight)); @@ -184,7 +184,7 @@ void Handle::move(Geom::Point const &new_pos) / Geom::L2sq(direction)) * direction; setRelativePos(new_delta); - //move the handler and its oposite the same proportion + //spanish: mueve el tirador y su opuesto la misma proporción if(_pm().isBSpline(false)){ setPosition(_pm().BSplineHandleReposition(this)); this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),_parent->bsplineWeight)); @@ -210,7 +210,7 @@ void Handle::move(Geom::Point const &new_pos) } setPosition(new_pos); - // moves the handler and its oposite the same proportion + //spanish: mueve el tirador y su opuesto la misma proporción if(_pm().isBSpline(false)){ setPosition(_pm().BSplineHandleReposition(this)); this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),_parent->bsplineWeight)); @@ -292,7 +292,7 @@ bool Handle::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEven break; default: break; } - // new double click event to set the handlers of a node to the default proportion, 0.3334% + //spanish: nuevo evento de doble click para resetear a la proporción por defecto, 0.3334%, los tiradores de un nodo case GDK_2BUTTON_PRESS: handle_2button_press(); break; @@ -303,7 +303,7 @@ bool Handle::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEven return ControlPoint::_eventHandler(event_context, event); } -//this function moves the handler and its oposite to the default proportion of 0.3334 +//spanish: función que mueve el tirador y su opuesto a la proporción por defecto de 0.3334 void Handle::handle_2button_press(){ if(_pm().isBSpline(false)){ setPosition(_pm().BSplineHandleReposition(this,0.3334)); @@ -359,8 +359,8 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) ctrl_constraint = Inkscape::Snapper::SnapConstraint(parent_pos, parent_pos - perp_pos); } new_pos = result; - // moves the handler and its oposite in X fixed positions depending on parameter "steps with control" - // by default in live BSpline + //spanish: mueve el tirador y su opuesto en X posiciones fijas depenfiendo de la configuración de el + //parametro "steps whith control" del efecto en vivo BSpline if(_pm().isBSpline(false)){ setPosition(new_pos); int steps = _pm().BSplineGetSteps(); @@ -370,7 +370,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) } std::vector unselected; - //if the snap adjustment is activated and it is not bspline + //spanish: si está activado el ajuste (snap) y no es bspline if (snap && !_pm().isBSpline(false)) { ControlPointSelection::Set &nodes = _parent->_selection.allPoints(); for (ControlPointSelection::Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { @@ -411,7 +411,8 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) other()->setPosition(_saved_other_pos); } } - //if it is bspline but SHIFT or CONTROL are not pressed it fixes it in the original position + //spanish: si es bspline pero no está presionado SHIFT o CONTROL + //lo fija en la posición original if(_pm().isBSpline(false) && !held_shift(*event) && !held_control(*event)){ new_pos=_last_drag_origin(); } @@ -431,7 +432,7 @@ void Handle::ungrabbed(GdkEventButton *event) Geom::Point dist = _desktop->d2w(_parent->position()) - _desktop->d2w(position()); if (dist.length() <= drag_tolerance) { move(_parent->position()); - //sets the bspline strength to 0.0000 + //spanish: marca la fuerza del bspline como 0.0000 if(_pm().isBSpline(false)){ _parent->bsplineWeight = 0.0000; } @@ -477,9 +478,9 @@ static double snap_increment_degrees() { Glib::ustring Handle::_getTip(unsigned state) const { char const *more; - // a trick to mark as bspline if the node has no strength, we are going to use it later - // to show the appropiate messages. We cannot do it in any different way becasue the function is constant - + //spanish: un truco para, si el nodo tiene fuerza, nos marca que es + //del tipo bspline, lo utilizaremos despues para mostras los mensajes apropiados + //no lo podemos hacer de otra forma al ser constante la funcion bool isBSpline = false; if( _parent->bsplineWeight != 0.0000) isBSpline = true; @@ -621,8 +622,8 @@ void Node::move(Geom::Point const &new_pos) // move handles when the node moves. Geom::Point old_pos = position(); Geom::Point delta = new_pos - position(); - - // save the previous node strength to apply it again once the node is moved + //spanish: guardamos la fuerza anterior del nodo para reaplicarsela + //de nuevo una vez sea movido el nodo double oldPos = 0.0000; Node *n = this; if(_pm().isBSpline(false)){ @@ -637,8 +638,8 @@ void Node::move(Geom::Point const &new_pos) // if the node has a smooth handle after a line segment, it should be kept colinear // with the segment _fixNeighbors(old_pos, new_pos); - - // move the affected handlers. First the node ones, later the adjoining ones. + //spanish: movemos los tiradores involucrados, primero los del nodo en cuestión + //y despues los de los nodos colindantes if(_pm().isBSpline(false)){ _front.setPosition(_pm().BSplineHandleReposition(this->front(),oldPos)); _back.setPosition(_pm().BSplineHandleReposition(this->back(),oldPos)); @@ -648,7 +649,8 @@ void Node::move(Geom::Point const &new_pos) void Node::transform(Geom::Affine const &m) { - // save the previous node strength to apply it again later when the node is moved + //spanish: guardamos la fuerza anterior del nodo para reaplicarsela + //de nuevo una vez sea movido el nodo double oldPos = 0.0000; if(_pm().isBSpline(false)){ oldPos = this->bsplineWeight; @@ -661,8 +663,8 @@ void Node::transform(Geom::Affine const &m) /* Affine transforms keep handle invariants for smooth and symmetric nodes, * but smooth nodes at ends of linear segments and auto nodes need special treatment */ _fixNeighbors(old_pos, position()); - - // move the involved handlers, first the node ones, later the adjoining ones + //spanish: movemos los tiradores involucrados, primero los del nodo en cuestión + //y despues los de los nodos colindantes if(_pm().isBSpline(false)){ _front.setPosition(_pm().BSplineHandleReposition(this->front(),oldPos)); _back.setPosition(_pm().BSplineHandleReposition(this->back(),oldPos)); @@ -753,11 +755,9 @@ void Node::showHandles(bool v) if (!_back.isDegenerate()) { _back.setVisible(v); } - - // define the node strength, depending on being or not bspline traced. - // every time we operate over these handlers in a trace bspline - // that strength needs to be updated. - + //spanish: definimos la fuerza de los nodos,según sea o no trazado bspline. + //Cada vez que actuemos sobre dichos tiradores en un trazado + //bspline esta fuerza se tiene que actualizar this->bsplineWeight = 0.0000; if(_pm().isBSpline(false) && (!_front.isDegenerate() || !_back.isDegenerate())){ if (!_front.isDegenerate()) { @@ -868,8 +868,9 @@ void Node::setType(NodeType type, bool update_handles) break; default: break; } - /* in node type changes, about bspline traces, we can mantain them with 0.0000 power in border mode, - or we give them the default power in curve mode */ + //spanish: en los cambios de tipo de nodo, sobre trazados bspline, + //o bien los mantenemos con potencia 0.0000 en modo esquina + //o les damos la potencia por defecto en modo de curva if(_pm().isBSpline(false)){ if(this->bsplineWeight !=0.0000) this->bsplineWeight = 0.3334; _front.setPosition(_pm().BSplineHandleReposition(this->front(),this->bsplineWeight)); @@ -1122,7 +1123,7 @@ void Node::_setState(State state) case STATE_CLICKED: mgr.setActive(_canvas_item, true); mgr.setPrelight(_canvas_item, false); - //this shows the handlers when selecting the nodes + //spanish: esto muestra los tiradores al seleccionar los nodos if(_pm().isBSpline(false)){ if(!this->back()->isDegenerate()){ _pm().BSplineHandlePosition(this->back()); @@ -1388,10 +1389,9 @@ Node *Node::nodeAwayFrom(Handle *h) Glib::ustring Node::_getTip(unsigned state) const { - - /* if the node doesnt have strength, it marks it as bspline, we'll use it later - to show the appropiate messages. We cannot do it in any other way, because the - function is constant */ + //spanish: un truco par, si el nodo tiene fuerza, nos marca que es + //del tipo bspline, lo utilizaremos despues para mostras los mensajes apropiados + //no lo podemos hacer de otra forma al ser constante la funcion bool isBSpline = false; if( this->bsplineWeight != 0.0000) isBSpline = true; diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h index 4393446d9..b7d6951d0 100644 --- a/src/ui/tool/node.h +++ b/src/ui/tool/node.h @@ -187,7 +187,7 @@ public: bool isEndNode() const; Handle *front() { return &_front; } Handle *back() { return &_back; } - //strength value for each node + //spanish: creamos valor de potencia bspline asociado a cada nodo double bsplineWeight; /** diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 1cc075603..a6689d93d 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -663,7 +663,7 @@ unsigned PathManipulator::_deleteStretch(NodeList::iterator start, NodeList::ite nl.erase(start); start = next; } - // if we are removing, we readjust the handlers + //spanish: si se borra, reajustamos los tiradores if(isBSpline(false)){ double pos = 0.0000; if(start.prev()){ @@ -1182,7 +1182,7 @@ void PathManipulator::_createControlPointsFromGeometry() } } -//determines if the trace has a bspline effect and the number of steps that it takes +//spanish: determina si el trazado tiene efecto bspline y el numero de pasos que realiza int PathManipulator::BSplineGetSteps(){ LivePathEffect::LPEBSpline *lpe_bsp = NULL; @@ -1200,7 +1200,7 @@ int PathManipulator::BSplineGetSteps(){ return steps; } -// determines if the trace has bspline effect +//spanish: determina si el trazado tiene efecto bspline bool PathManipulator::isBSpline(bool recalculate){ static int BSplineSteps = this->BSplineGetSteps(); if(recalculate){ @@ -1213,7 +1213,7 @@ bool PathManipulator::isBSpline(bool recalculate){ return isBSpline; } -// returns the corresponding strength to the position of a handler +//spanish: devuelve la fuerza que le corresponderia a la posicón de un tirador double PathManipulator::BSplineHandlePosition(Handle *h){ using Geom::X; using Geom::Y; @@ -1231,13 +1231,13 @@ double PathManipulator::BSplineHandlePosition(Handle *h){ return pos; } -// moves the handler to the corresponding position +//spanish: mueve el tirador a la posición que le corresponda Geom::Point PathManipulator::BSplineHandleReposition(Handle *h){ double pos = this->BSplineHandlePosition(h); return BSplineHandleReposition(h,pos); } -// moves the handler to the specified position +//spanish: mueve el tirador a una posición específica Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){ using Geom::X; using Geom::Y; @@ -1263,7 +1263,7 @@ Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){ return ret; } -//moves the node handlers and its oposite handlers to the strength of its nodes +//spanish: mueve los tiradores del nodo y sus tiradores opuestos a la potencia de sus nodos void PathManipulator::BSplineNodeHandlesReposition(Node *n){ Node * nextNode = n->nodeToward(n->front()); Node * prevNode = n->nodeToward(n->back()); diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 40a257de9..cb6111bd5 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -252,7 +252,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1) { Effect::createAndApply(SPIRO, dc->desktop->doc(), item); } - //add the bspline node in the waiting effects + //spanish: añadimos el modo bspline a los efectos en espera if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2) { Effect::createAndApply(BSPLINE, dc->desktop->doc(), item); } @@ -496,9 +496,9 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) dc->blue2_curve->reset(); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(dc->blue2_bpath), NULL); - /* if c is empty, it might be that the user was trying to continue an existing curve and cancelled. - if this is the case and we are in bspline or spirolive the previous curve needs to be selected again because - we modify it when continuing through an anchor. */ + //spanish: si c esta vacio, puede ser que se haya tratado de contnuar una curva existente + //y se haya cancelado. Si es asi y el modo es bspline o spirolive la curva previa necesita volver a ser seleccionada + //porque la modificamos al continuar por un anchor if (c->is_empty()) { if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ SPDesktop *desktop = dc->desktop; @@ -527,10 +527,8 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) { // We hit bot start and end of single curve, closing paths dc->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Closing path.")); - - /* if we are in bspline or spirolive mode, the continuation and ending curve are updated when continuing or ending the curve in an anchor. - this causes that the original function doesn't detect if it's the same curve in case the curves have multiples parts -shift- and - close incorrectly one of the parts */ + //spanish: si estamos en modo bspline o spirolive, la curva de continuación y finalización es actualizada al continuar o finalizar la curva en un anchor + //esto proboca que la función original no detecte si es la misma curva en el caso de curvas con multiples partes -shift- y cierre de manera erronea una de las partes if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ if (dc->sa->start && !(dc->sa->curve->is_closed()) ) { @@ -549,8 +547,8 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) c->unref(); dc->sa->curve->closepath_current(); } - - //if the curve has an bspline or spiro LPE, we execute spdc_flush_white, passing the necessary starting curve. + //spanish: Si la curva tiene un LPE del tipo bspline o spiro ejecutamos spdc_flush_white + //pasándole la curva de inicio necesaria if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ dc->white_curves = g_slist_remove(dc->white_curves, dc->sa->curve); @@ -681,8 +679,9 @@ SPDrawAnchor *spdc_test_inside(FreehandBase *dc, Geom::Point p) } } - /* modify the anchoring curve so it is equal to the starting curve. - this curve is modified when it's modified and we need them to be equal to the closing curve */ + //spanish: modificamos la curva de anclaje para que sea igual que la curva de inicio. + //esta curva fue modificada al continuar la curva y necesitamos que sea igual que la curva en + //la que cerramos el trazado. Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if((prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2) && diff --git a/src/ui/tools/node-tool.h b/src/ui/tools/node-tool.h index 42f89cd1c..168ec995a 100644 --- a/src/ui/tools/node-tool.h +++ b/src/ui/tools/node-tool.h @@ -14,8 +14,7 @@ #include #include #include "ui/tools/tool-base.h" - -// we need it to call it from Live Effect +//spanish: lo necesitamos para llamarlo desde el Live Effect #include "selection.h" namespace Inkscape { diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index e3bbc72b1..ad77fcb53 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -42,7 +42,7 @@ #include "context-fns.h" #include "tools-switch.h" #include "ui/control-manager.h" -// we include the necessary files for BSpline & Spiro +//spanish: incluimos los archivos necesarios para las BSpline y Spiro #include "live_effects/effect.h" #include "live_effects/lpeobject.h" #include "live_effects/lpeobject-reference.h" @@ -166,7 +166,7 @@ PenTool::~PenTool() { void PenTool::setPolylineMode() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); guint mode = prefs->getInt("/tools/freehand/pen/freehand-mode", 0); - // change the nodes to make space for bspline mode + //spanish: cambiamos los modos para dar cabida al modo bspline this->polylines_only = (mode == 3 || mode == 4); this->polylines_paraxial = (mode == 4); //we call the function which defines the Spiro modes and the BSpline @@ -178,7 +178,7 @@ void PenTool::setPolylineMode() { *.Set the mode of draw spiro, and bsplines */ void PenTool::_pen_context_set_mode(guint mode) { - // define the nodes + //spanish: definimos los modos this->spiro = (mode == 1); this->bspline = (mode == 2); } @@ -386,7 +386,7 @@ gint PenTool::_handleButtonPress(GdkEventButton const &bevent) { if(bevent.button != 3 && (this->spiro || this->bspline) && this->npoints > 0 && this->p[0] == this->p[3]){ this->state = PenTool::STOP; if( anchor && anchor == this->sa && this->green_curve->is_empty()){ - //remove the following line to avoid having one node on top of another + //spanish Borrar siguiente linea para evitar un nodo encima de otro _finishSegment(event_dt, bevent.state); _finish( FALSE); return TRUE; @@ -512,7 +512,7 @@ gint PenTool::_handleButtonPress(GdkEventButton const &bevent) { } } - // avoid the creation of a control point so a node is created in the release event + //spanish: evitamos la creación de un punto de control para que se cree el nodo en el evento de soltar this->state = (this->spiro || this->bspline || this->polylines_only) ? PenTool::POINT : PenTool::CONTROL; ret = TRUE; @@ -705,7 +705,7 @@ gint PenTool::_handleMotionNotify(GdkEventMotion const &mevent) { default: break; } - // calls the function "bspline_spiro_motion" when the mouse starts or stops moving + //spanish: lanzamos la función "bspline_spiro_motion" al moverse el ratón o cuando se para. if(this->bspline){ this->_bspline_spiro_color(); this->_bspline_spiro_motion(mevent.state & GDK_SHIFT_MASK); @@ -743,7 +743,9 @@ gint PenTool::_handleButtonRelease(GdkEventButton const &revent) { // Test whether we hit any anchor. SPDrawAnchor *anchor = spdc_test_inside(this, event_w); - // if we try to create a node in the same place as another node, we skip + //with this we avoid creating a new point over the existing one + //spanish: si intentamos crear un nodo en el mismo sitio que el origen, paramos. + if((!anchor || anchor == this->sa) && (this->spiro || this->bspline) && this->npoints > 0 && this->p[0] == this->p[3]){ return TRUE; } @@ -758,7 +760,7 @@ gint PenTool::_handleButtonRelease(GdkEventButton const &revent) { p = anchor->dp; } this->sa = anchor; - // continue the existing curve + //spanish: continuamos una curva existente if (anchor) { if(this->bspline || this->spiro){ this->_bspline_spiro_start_anchor(revent.state & GDK_SHIFT_MASK);; @@ -788,7 +790,7 @@ gint PenTool::_handleButtonRelease(GdkEventButton const &revent) { this->_endpointSnap(p, revent.state); } this->_finishSegment(p, revent.state); - // hude the guide of the penultimate node when closing the curve + //spanish: ocultamos la guia del penultimo nodo al cerrar la curva if(this->spiro){ sp_canvas_item_hide(this->c1); } @@ -815,7 +817,7 @@ gint PenTool::_handleButtonRelease(GdkEventButton const &revent) { case PenTool::CLOSE: this->_endpointSnap(p, revent.state); this->_finishSegment(p, revent.state); - // hide the penultimate node guide when closing the curve + //spanish: ocultamos la guia del penultimo nodo al cerrar la curva if(this->spiro){ sp_canvas_item_hide(this->c1); } @@ -906,7 +908,7 @@ void PenTool::_redrawAll() { sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve); // handles - // hide the handlers in bspline and spiro modes + //spanish: ocultamos los tiradores en modo bspline y spiro if (this->p[0] != this->p[1] && !this->spiro && !this->bspline) { SP_CTRL(this->c1)->moveto(this->p[1]); this->cl1->setCoords(this->p[0], this->p[1]); @@ -920,7 +922,7 @@ void PenTool::_redrawAll() { Geom::Curve const * last_seg = this->green_curve->last_segment(); if (last_seg) { Geom::CubicBezier const * cubic = dynamic_cast( last_seg ); - // hide the handlers in bspline and spiro modes + //spanish: ocultamos los tiradores en modo bspline y spiro if ( cubic && (*cubic)[2] != this->p[0] && !this->spiro && !this->bspline ) { @@ -935,8 +937,9 @@ void PenTool::_redrawAll() { } } - // simply redraw the spiro. because its a redrawing, we don't call the global function, - // but we call the redrawing at the ending. + //spanish: simplemente redibujamos la spiro. + //como es un redibujo simplemente no llamamos a la función global sino al final de esta + //Lanzamos solamente el redibujado this->_bspline_spiro_build(); } @@ -966,12 +969,12 @@ void PenTool::_lastpointMoveScreen(gdouble x, gdouble y) { } void PenTool::_lastpointToCurve() { - // avoid that if the "red_curve" contains only two points ( rect ), it doesn't stop here. + //spanish: evitamos que si la "red_curve" tiene solo dos puntos -recta- no se pare aqui. if (this->npoints != 5 && !this->spiro && !this->bspline) return; Geom::CubicBezier const * cubic; this->p[1] = this->red_curve->last_segment()->initialPoint() + (1./3)* (Geom::Point)(this->red_curve->last_segment()->finalPoint() - this->red_curve->last_segment()->initialPoint()); - //modificate the last segment of the green curve so it creates the type of node we need + //spanish: modificamos el último segmento de la curva verde para que forme el tipo de nodo que deseamos if(this->spiro||this->bspline){ if(!this->green_curve->is_empty()){ Geom::Point A(0,0); @@ -1009,7 +1012,7 @@ void PenTool::_lastpointToCurve() { this->green_curve->append_continuous(previous, 0.0625); } } - //if the last node is an union with another curve + //spanish: si el último nodo es una union con otra curva if(this->green_curve->is_empty() && this->sa && !this->sa->curve->is_empty()){ this->_bspline_spiro_start_anchor(false); } @@ -1020,11 +1023,11 @@ void PenTool::_lastpointToCurve() { void PenTool::_lastpointToLine() { - // avoid that if the "red_curve" contains only two points ( rect) it doesn't stop here. + //spanish: evitamos que si la "red_curve" tiene solo dos puntos -recta- no se pare aqui. if (this->npoints != 5 && !this->bspline) return; - // modify the last segment of the green curve so the type of node we want is created. + //spanish: modificamos el último segmento de la curva verde para que forme el tipo de nodo que deseamos if(this->spiro || this->bspline){ if(!this->green_curve->is_empty()){ Geom::Point A(0,0); @@ -1056,7 +1059,7 @@ void PenTool::_lastpointToLine() { this->green_curve->append_continuous(previous, 0.0625); } } - // if the last node is an union with another curve + //spanish: si el último nodo es una union con otra curva if(this->green_curve->is_empty() && this->sa && !this->sa->curve->is_empty()){ this->_bspline_spiro_start_anchor(true); } @@ -1245,7 +1248,7 @@ gint PenTool::_handleKeyPress(GdkEvent *event) { this->p[1] = this->p[0]; } - // asign the value in a third of the distance of the last segment. + //spanish: asignamos el valor a un tercio de distancia del último segmento. if(this->bspline){ this->p[1] = this->p[0] + (1./3)*(this->p[3] - this->p[0]); } @@ -1255,7 +1258,7 @@ gint PenTool::_handleKeyPress(GdkEvent *event) { : this->p[3])); this->npoints = 2; - // delete the last segment of the green curve + //spanish: eliminamos el último segmento de la curva verde if( this->green_curve->get_segment_count() == 1){ this->npoints = 5; if (this->green_bpaths) { @@ -1267,7 +1270,7 @@ gint PenTool::_handleKeyPress(GdkEvent *event) { }else{ this->green_curve->backspace(); } - // assign the value of this->p[1] to the oposite of the green line last segment + //spanish: asignamos el valor de this->p[1] a el opuesto de el ultimo segmento de la línea verde if(this->spiro){ cubic = dynamic_cast(this->green_curve->last_segment()); if ( cubic ) { @@ -1282,8 +1285,7 @@ gint PenTool::_handleKeyPress(GdkEvent *event) { this->state = PenTool::POINT; this->_setSubsequentPoint(pt, true); pen_last_paraxial_dir = !pen_last_paraxial_dir; - - //redraw + //spanish: redibujamos this->_bspline_spiro_build(); ret = TRUE; } @@ -1358,7 +1360,9 @@ void PenTool::_setAngleDistanceStatusMessage(Geom::Point const p, int pc_point_t g_string_free(dist, FALSE); } -// this function changes the colors red, green and blue making them transparent or not, depending on if spiro is being used. + + +//spanish: esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro void PenTool::_bspline_spiro_color() { bool remake_green_bpaths = false; @@ -1732,7 +1736,8 @@ void PenTool::_bspline_spiro_end_anchor_off() } } -//prepares the curves for its transformation into BSpline curve. + +//spanish: preparates the curves for its trasformation into BSline curves. void PenTool::_bspline_spiro_build() { if(!this->spiro && !this->bspline) @@ -1761,7 +1766,7 @@ void PenTool::_bspline_spiro_build() } if(!curve->is_empty()){ - // close the curve if the final points of the curve are close enough + //spanish: cerramos la curva si estan cerca los puntos finales de la curva if(Geom::are_near(curve->first_path()->initialPoint(), curve->last_path()->finalPoint())){ curve->closepath_current(); } @@ -1800,7 +1805,7 @@ void PenTool::_bspline_spiro_build() void PenTool::_bspline_doEffect(SPCurve * curve) { - // commenting the function doEffect in src/live_effects/lpe-bspline.cpp + //spanish: comentado en funcion "doEffect" de src/live_effects/lpe-bspline.cpp if(curve->get_segment_count() < 2) return; Geom::PathVector const original_pathv = curve->get_pathvector(); @@ -1940,7 +1945,7 @@ void PenTool::_bspline_doEffect(SPCurve * curve) } //Spiro function cloned from lpe-spiro.cpp -// commenting the function "doEffect" from src/live_effects/lpe-spiro.cpp +//spanish: comentado en funcion "doEffect" de src/live_effects/lpe-spiro.cpp void PenTool::_spiro_doEffect(SPCurve * curve) { using Geom::X; @@ -2173,7 +2178,7 @@ void PenTool::_finish(gboolean const closed) { desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Drawing finished")); - // cancelate line without a created segment + //spanish para cancelar linea sin un segmento creado this->red_curve->reset(); spdc_concat_colors_and_flush(this, closed); this->sa = NULL; diff --git a/src/ui/tools/pen-tool.h b/src/ui/tools/pen-tool.h index 95565abc9..88e528b22 100644 --- a/src/ui/tools/pen-tool.h +++ b/src/ui/tools/pen-tool.h @@ -49,7 +49,7 @@ public: bool polylines_only; bool polylines_paraxial; - // propiety which saves if Spiro mode is active or not + //spanish: propiedad que guarda si el modo Spiro está activo o no bool spiro; bool bspline; int num_clicks; @@ -88,29 +88,29 @@ private: gint _handleButtonRelease(GdkEventButton const &revent); gint _handle2ButtonPress(GdkEventButton const &bevent); gint _handleKeyPress(GdkEvent *event); - //adds spiro & bspline modes + //spanish: añade los modos spiro y bspline void _pen_context_set_mode(guint mode); - //this function changes the colors red, green and blue making them transparent or not depending on if the function uses spiro + //spanish: esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro void _bspline_spiro_color(); - //creates a node in bspline or spiro modes + //spanish: crea un nodo en modo bspline o spiro void _bspline_spiro(bool shift); - //creates a node in bspline or spiro modes + //spanish: crea un nodo de modo spiro o bspline void _bspline_spiro_on(); - //creates a CUSP node + //spanish: crea un nodo de tipo CUSP void _bspline_spiro_off(); - //continues the existing curve in bspline or spiro mode + //spanish: continua una curva existente en modo bspline o spiro void _bspline_spiro_start_anchor(bool shift); - //continues the existing curve with the union node in bspline or spiro modes + //spanish: continua una curva exsitente con el nodo de union en modo bspline o spiro void _bspline_spiro_start_anchor_on(); - //continues an existing curve with the union node in CUSP mode + //spanish: continua una curva existente con el nodo de union en modo CUSP void _bspline_spiro_start_anchor_off(); - //modifies the "red_curve" when it detects movement + //spanish: modifica la "red_curve" cuando se detecta movimiento void _bspline_spiro_motion(bool shift); - //closes the curve with the last node in bspline or spiro mode + //spanish: cierra la curva con el último nodo en modo bspline o spiro void _bspline_spiro_end_anchor_on(); - //closes the curve with the last node in CUSP mode + //spanish: cierra la curva con el último nodo en modo CUSP void _bspline_spiro_end_anchor_off(); - //CHECK: join all the curves "in game" and we call doEffect function + //spanish: unimos todas las curvas en juego y llamamos a la función doEffect. void _bspline_spiro_build(); //function bspline cloned from lpe-bspline.cpp void _bspline_doEffect(SPCurve * curve); diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp index 1ccdee637..bd50672af 100644 --- a/src/ui/tools/pencil-tool.cpp +++ b/src/ui/tools/pencil-tool.cpp @@ -685,7 +685,7 @@ void PencilTool::_interpolate() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); guint mode = prefs->getInt("/tools/freehand/pencil/freehand-mode", 0); for (int c = 0; c < n_segs; c++) { - // if we are in BSpline we modify the trace to create adhoc nodes + //spanish: si el modo es BSpline modificamos para que el trazado cree los nodos adhoc if(mode == 2){ Geom::Point BP = b[4*c+0] + (1./3)*(b[4*c+3] - b[4*c+0]); BP = Geom::Point(BP[X] + 0.0001,BP[Y] + 0.0001); @@ -835,7 +835,7 @@ void PencilTool::_fitAndSplit() { this->red_curve->moveto(b[0]); using Geom::X; using Geom::Y; - // if we are in BSpline we modify the trace to create adhoc nodes + //spanish: si el modo es BSpline modificamos para que el trazado cree los nodos adhoc Inkscape::Preferences *prefs = Inkscape::Preferences::get(); guint mode = prefs->getInt("/tools/freehand/pencil/freehand-mode", 0); if(mode == 2){ -- cgit v1.2.3 From 2aca4771b38314e62530f398222f02d4b9c17be5 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 5 Mar 2014 20:09:26 +0100 Subject: Fixing branch problems (bzr r11950.1.280) --- src/ui/dialog/export.cpp | 502 ++++++++++++++++++++++++----------------------- src/ui/dialog/export.h | 48 +++-- 2 files changed, 282 insertions(+), 268 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 340a3dad0..f0a5f1bf5 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -144,11 +144,13 @@ namespace Dialog { /** A list of strings that is used both in the preferences, and in the data fields to describe the various values of \c selection_type. */ static const char * selection_names[SELECTION_NUMBER_OF] = { - "page", "drawing", "selection", "custom"}; + "page", "drawing", "selection", "custom" +}; /** The names on the buttons for the various selection types. */ static const char * selection_labels[SELECTION_NUMBER_OF] = { - N_("_Page"), N_("_Drawing"), N_("_Selection"), N_("_Custom")}; + N_("_Page"), N_("_Drawing"), N_("_Selection"), N_("_Custom") +}; Export::Export (void) : UI::Widget::Panel ("", "/dialogs/export/", SP_VERB_DIALOG_EXPORT), @@ -201,7 +203,7 @@ Export::Export (void) : /* gets added to the vbox later, but the unit selector is needed earlier than that */ unit_selector.setUnitType(Inkscape::Util::UNIT_TYPE_LINEAR); - + SPDesktop *desktop = SP_ACTIVE_DESKTOP; if (desktop) { unit_selector.setUnit(sp_desktop_namedview(desktop)->doc_units->abbr); @@ -232,28 +234,28 @@ Export::Export (void) : #endif x0_adj = createSpinbutton ( "x0", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, - t, 0, 0, _("_x0:"), "", EXPORT_COORD_PRECISION, 1, - &Export::onAreaX0Change); + t, 0, 0, _("_x0:"), "", EXPORT_COORD_PRECISION, 1, + &Export::onAreaX0Change); x1_adj = createSpinbutton ( "x1", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, - t, 0, 1, _("x_1:"), "", EXPORT_COORD_PRECISION, 1, - &Export::onAreaX1Change); + t, 0, 1, _("x_1:"), "", EXPORT_COORD_PRECISION, 1, + &Export::onAreaX1Change); width_adj = createSpinbutton ( "width", 0.0, 0.0, PNG_UINT_31_MAX, 0.1, 1.0, - t, 0, 2, _("Wid_th:"), "", EXPORT_COORD_PRECISION, 1, - &Export::onAreaWidthChange); + t, 0, 2, _("Wid_th:"), "", EXPORT_COORD_PRECISION, 1, + &Export::onAreaWidthChange); y0_adj = createSpinbutton ( "y0", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, - t, 2, 0, _("_y0:"), "", EXPORT_COORD_PRECISION, 1, - &Export::onAreaY0Change); + t, 2, 0, _("_y0:"), "", EXPORT_COORD_PRECISION, 1, + &Export::onAreaY0Change); y1_adj = createSpinbutton ( "y1", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, - t, 2, 1, _("y_1:"), "", EXPORT_COORD_PRECISION, 1, - &Export::onAreaY1Change); + t, 2, 1, _("y_1:"), "", EXPORT_COORD_PRECISION, 1, + &Export::onAreaY1Change); height_adj = createSpinbutton ( "height", 0.0, 0.0, PNG_UINT_31_MAX, 0.1, 1.0, - t, 2, 2, _("Hei_ght:"), "", EXPORT_COORD_PRECISION, 1, - &Export::onAreaHeightChange); + t, 2, 2, _("Hei_ght:"), "", EXPORT_COORD_PRECISION, 1, + &Export::onAreaHeightChange); area_box.pack_start(togglebox, false, false, 3); area_box.pack_start(*t, false, false, 0); @@ -284,27 +286,27 @@ Export::Export (void) : size_box.pack_start(*t); bmwidth_adj = createSpinbutton ( "bmwidth", 16.0, 1.0, 1000000.0, 1.0, 10.0, - t, 0, 0, - _("_Width:"), _("pixels at"), 0, 1, - &Export::onBitmapWidthChange); + t, 0, 0, + _("_Width:"), _("pixels at"), 0, 1, + &Export::onBitmapWidthChange); xdpi_adj = createSpinbutton ( "xdpi", - prefs->getDouble("/dialogs/export/defaultxdpi/value", DPI_BASE), - 0.01, 100000.0, 0.1, 1.0, t, 3, 0, - "", _("dp_i"), 2, 1, - &Export::onExportXdpiChange); + prefs->getDouble("/dialogs/export/defaultxdpi/value", DPI_BASE), + 0.01, 100000.0, 0.1, 1.0, t, 3, 0, + "", _("dp_i"), 2, 1, + &Export::onExportXdpiChange); bmheight_adj = createSpinbutton ( "bmheight", 16.0, 1.0, 1000000.0, 1.0, 10.0, - t, 0, 1, - _("_Height:"), _("pixels at"), 0, 1, - &Export::onBitmapHeightChange); + t, 0, 1, + _("_Height:"), _("pixels at"), 0, 1, + &Export::onBitmapHeightChange); /** TODO * There's no way to set ydpi currently, so we use the defaultxdpi value here, too... */ ydpi_adj = createSpinbutton ( "ydpi", prefs->getDouble("/dialogs/export/defaultxdpi/value", DPI_BASE), - 0.01, 100000.0, 0.1, 1.0, t, 3, 1, - "", _("dpi"), 2, 0, NULL ); + 0.01, 100000.0, 0.1, 1.0, t, 3, 1, + "", _("dpi"), 2, 0, NULL ); singleexport_box.pack_start(size_box); } @@ -482,18 +484,18 @@ void Export::set_default_filename () { #if WITH_GTKMM_3_0 Glib::RefPtr Export::createSpinbutton( gchar const * /*key*/, float val, float min, float max, - float step, float page, - Gtk::Grid *t, int x, int y, - const Glib::ustring ll, const Glib::ustring lr, - int digits, unsigned int sensitive, - void (Export::*cb)() ) + float step, float page, + Gtk::Grid *t, int x, int y, + const Glib::ustring& ll, const Glib::ustring& lr, + int digits, unsigned int sensitive, + void (Export::*cb)() ) #else Gtk::Adjustment * Export::createSpinbutton( gchar const * /*key*/, float val, float min, float max, - float step, float page, - Gtk::Table *t, int x, int y, - const Glib::ustring ll, const Glib::ustring lr, - int digits, unsigned int sensitive, - void (Export::*cb)() ) + float step, float page, + Gtk::Table *t, int x, int y, + const Glib::ustring& ll, const Glib::ustring& lr, + int digits, unsigned int sensitive, + void (Export::*cb)() ) #endif { #if WITH_GTKMM_3_0 @@ -535,7 +537,9 @@ Gtk::Adjustment * Export::createSpinbutton( gchar const * /*key*/, float val, fl sb->set_sensitive (sensitive); pos++; - if (!ll.empty()) { l->set_mnemonic_widget(*sb);} + if (!ll.empty()) { + l->set_mnemonic_widget(*sb); + } if (!lr.empty()) { l = new Gtk::Label(lr,true); @@ -565,7 +569,7 @@ Gtk::Adjustment * Export::createSpinbutton( gchar const * /*key*/, float val, fl Glib::ustring Export::create_filepath_from_id (Glib::ustring id, const Glib::ustring &file_entry_text) { if (id.empty()) - { /* This should never happen */ + { /* This should never happen */ id = "bitmap"; } @@ -678,35 +682,35 @@ void Export::onSelectionModified ( guint /*flags*/ ) { Inkscape::Selection * Sel; switch (current_key) { - case SELECTION_DRAWING: - if ( SP_ACTIVE_DESKTOP ) { - SPDocument *doc; - doc = sp_desktop_document (SP_ACTIVE_DESKTOP); - Geom::OptRect bbox = doc->getRoot()->desktopVisualBounds(); - if (bbox) { - setArea ( bbox->left(), - bbox->top(), - bbox->right(), - bbox->bottom()); - } + case SELECTION_DRAWING: + if ( SP_ACTIVE_DESKTOP ) { + SPDocument *doc; + doc = sp_desktop_document (SP_ACTIVE_DESKTOP); + Geom::OptRect bbox = doc->getRoot()->desktopVisualBounds(); + if (bbox) { + setArea ( bbox->left(), + bbox->top(), + bbox->right(), + bbox->bottom()); } - break; - case SELECTION_SELECTION: - Sel = sp_desktop_selection(SP_ACTIVE_DESKTOP); - if (Sel->isEmpty() == false) { - Geom::OptRect bbox = Sel->visualBounds(); - if (bbox) - { - setArea ( bbox->left(), - bbox->top(), - bbox->right(), - bbox->bottom()); - } + } + break; + case SELECTION_SELECTION: + Sel = sp_desktop_selection(SP_ACTIVE_DESKTOP); + if (Sel->isEmpty() == false) { + Geom::OptRect bbox = Sel->visualBounds(); + if (bbox) + { + setArea ( bbox->left(), + bbox->top(), + bbox->right(), + bbox->bottom()); } - break; - default: - /* Do nothing for page or for custom */ - break; + } + break; + default: + /* Do nothing for page or for custom */ + break; } return; @@ -738,39 +742,39 @@ void Export::onAreaToggled () various backups. If you modify this without noticing you'll probabaly screw something up. */ switch (key) { - case SELECTION_SELECTION: - if ((sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false) - { - bbox = sp_desktop_selection (SP_ACTIVE_DESKTOP)->visualBounds(); - /* Only if there is a selection that we can set - do we break, otherwise we fall through to the - drawing */ - // std::cout << "Using selection: SELECTION" << std::endl; - key = SELECTION_SELECTION; - break; - } - case SELECTION_DRAWING: - /** \todo - * This returns wrong values if the document has a viewBox. - */ - bbox = doc->getRoot()->desktopVisualBounds(); - /* If the drawing is valid, then we'll use it and break - otherwise we drop through to the page settings */ - if (bbox) { - // std::cout << "Using selection: DRAWING" << std::endl; - key = SELECTION_DRAWING; - break; - } - case SELECTION_PAGE: - bbox = Geom::Rect(Geom::Point(0.0, 0.0), - Geom::Point(doc->getWidth().value("px"), doc->getHeight().value("px"))); - - // std::cout << "Using selection: PAGE" << std::endl; - key = SELECTION_PAGE; + case SELECTION_SELECTION: + if ((sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false) + { + bbox = sp_desktop_selection (SP_ACTIVE_DESKTOP)->visualBounds(); + /* Only if there is a selection that we can set + do we break, otherwise we fall through to the + drawing */ + // std::cout << "Using selection: SELECTION" << std::endl; + key = SELECTION_SELECTION; break; - case SELECTION_CUSTOM: - default: + } + case SELECTION_DRAWING: + /** \todo + * This returns wrong values if the document has a viewBox. + */ + bbox = doc->getRoot()->desktopVisualBounds(); + /* If the drawing is valid, then we'll use it and break + otherwise we drop through to the page settings */ + if (bbox) { + // std::cout << "Using selection: DRAWING" << std::endl; + key = SELECTION_DRAWING; break; + } + case SELECTION_PAGE: + bbox = Geom::Rect(Geom::Point(0.0, 0.0), + Geom::Point(doc->getWidth().value("px"), doc->getHeight().value("px"))); + + // std::cout << "Using selection: PAGE" << std::endl; + key = SELECTION_PAGE; + break; + case SELECTION_CUSTOM: + default: + break; } // switch current_key = key; @@ -780,9 +784,9 @@ void Export::onAreaToggled () if ( key != SELECTION_CUSTOM && bbox ) { setArea ( bbox->min()[Geom::X], - bbox->min()[Geom::Y], - bbox->max()[Geom::X], - bbox->max()[Geom::Y]); + bbox->min()[Geom::Y], + bbox->max()[Geom::X], + bbox->max()[Geom::Y]); } } // end of if ( SP_ACTIVE_DESKTOP ) @@ -793,43 +797,43 @@ void Export::onAreaToggled () float xdpi = 0.0, ydpi = 0.0; switch (key) { - case SELECTION_PAGE: - case SELECTION_DRAWING: { - SPDocument * doc = SP_ACTIVE_DOCUMENT; - sp_document_get_export_hints (doc, filename, &xdpi, &ydpi); - - if (filename.empty()) { - if (!doc_export_name.empty()) { - filename = doc_export_name; - } + case SELECTION_PAGE: + case SELECTION_DRAWING: { + SPDocument * doc = SP_ACTIVE_DOCUMENT; + sp_document_get_export_hints (doc, filename, &xdpi, &ydpi); + + if (filename.empty()) { + if (!doc_export_name.empty()) { + filename = doc_export_name; } - break; } - case SELECTION_SELECTION: - if ((sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false) { - - sp_selection_get_export_hints (sp_desktop_selection(SP_ACTIVE_DESKTOP), filename, &xdpi, &ydpi); - - /* If we still don't have a filename -- let's build - one that's nice */ - if (filename.empty()) { - const gchar * id = "object"; - const GSList * reprlst = sp_desktop_selection(SP_ACTIVE_DESKTOP)->reprList(); - for(; reprlst != NULL; reprlst = reprlst->next) { - Inkscape::XML::Node * repr = (Inkscape::XML::Node *)reprlst->data; - if (repr->attribute("id")) { - id = repr->attribute("id"); - break; - } - } + break; + } + case SELECTION_SELECTION: + if ((sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false) { - filename = create_filepath_from_id (id, filename_entry.get_text()); + sp_selection_get_export_hints (sp_desktop_selection(SP_ACTIVE_DESKTOP), filename, &xdpi, &ydpi); + + /* If we still don't have a filename -- let's build + one that's nice */ + if (filename.empty()) { + const gchar * id = "object"; + const GSList * reprlst = sp_desktop_selection(SP_ACTIVE_DESKTOP)->reprList(); + for(; reprlst != NULL; reprlst = reprlst->next) { + Inkscape::XML::Node * repr = (Inkscape::XML::Node *)reprlst->data; + if (repr->attribute("id")) { + id = repr->attribute("id"); + break; + } } + + filename = create_filepath_from_id (id, filename_entry.get_text()); } - break; - case SELECTION_CUSTOM: - default: - break; + } + break; + case SELECTION_CUSTOM: + default: + break; } if (!filename.empty()) { @@ -895,8 +899,8 @@ unsigned int Export::onProgressCallback(float value, void *dlg) int evtcount = 0; while ((evtcount < 16) && gdk_events_pending()) { - gtk_main_iteration_do(FALSE); - evtcount += 1; + gtk_main_iteration_do(FALSE); + evtcount += 1; } gtk_main_iteration_do(FALSE); @@ -960,7 +964,7 @@ Glib::ustring Export::filename_add_extension (Glib::ustring filename, Glib::ustr } else { - return filename = filename + "." + extension; + return filename = filename + "." + extension; } } } @@ -1057,9 +1061,9 @@ void Export::onExport () // Do export gchar * safeFile = Inkscape::IO::sanitizeString(path.c_str()); MessageCleaner msgCleanup(desktop->messageStack()->pushF(Inkscape::IMMEDIATE_MESSAGE, - _("Exporting file %s..."), safeFile), desktop); + _("Exporting file %s..."), safeFile), desktop); MessageCleaner msgFlashCleanup(desktop->messageStack()->flashF(Inkscape::IMMEDIATE_MESSAGE, - _("Exporting file %s..."), safeFile), desktop); + _("Exporting file %s..."), safeFile), desktop); if (!sp_export_png_file (doc, path.c_str(), *area, width, height, dpi, dpi, @@ -1067,7 +1071,7 @@ void Export::onExport () onProgressCallback, (void*)prog_dlg, TRUE, // overwrite without asking hide ? const_cast(sp_desktop_selection(desktop)->itemList()) : NULL - )) { + )) { gchar * error = g_strdup_printf(_("Could not export to filename %s.\n"), safeFile); desktop->messageStack()->flashF(Inkscape::ERROR_MESSAGE, @@ -1096,7 +1100,7 @@ void Export::onExport () } else { Glib::ustring filename = filename_entry.get_text(); - if (filename.empty()){ + if (filename.empty()) { desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("You have to enter a filename.")); sp_ui_error_dialog(_("You have to enter a filename")); return; @@ -1125,7 +1129,7 @@ void Export::onExport () Glib::ustring dirname = Glib::path_get_dirname(path); if ( dirname.empty() - || !Inkscape::IO::file_test(dirname.c_str(), (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) ) + || !Inkscape::IO::file_test(dirname.c_str(), (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) ) { gchar *safeDir = Inkscape::IO::sanitizeString(dirname.c_str()); gchar *error = g_strdup_printf(_("Directory %s does not exist or is not a directory.\n"), @@ -1151,12 +1155,12 @@ void Export::onExport () /* Do export */ ExportResult status = sp_export_png_file(sp_desktop_document(desktop), path.c_str(), - Geom::Rect(Geom::Point(x0, y0), Geom::Point(x1, y1)), width, height, xdpi, ydpi, - nv->pagecolor, - onProgressCallback, (void*)prog_dlg, - FALSE, - hide ? const_cast(sp_desktop_selection(desktop)->itemList()) : NULL - ); + Geom::Rect(Geom::Point(x0, y0), Geom::Point(x1, y1)), width, height, xdpi, ydpi, + nv->pagecolor, + onProgressCallback, (void*)prog_dlg, + FALSE, + hide ? const_cast(sp_desktop_selection(desktop)->itemList()) : NULL + ); if (status == EXPORT_ERROR) { gchar * safeFile = Inkscape::IO::sanitizeString(path.c_str()); gchar * error = g_strdup_printf(_("Could not export to filename %s.\n"), safeFile); @@ -1189,19 +1193,65 @@ void Export::onExport () /* Setup the values in the document */ switch (current_key) { - case SELECTION_PAGE: - case SELECTION_DRAWING: { - SPDocument * doc = SP_ACTIVE_DOCUMENT; - Inkscape::XML::Node * repr = doc->getReprRoot(); - bool modified = false; - - bool saved = DocumentUndo::getUndoSensitive(doc); - DocumentUndo::setUndoSensitive(doc, false); - - gchar const *temp_string = repr->attribute("inkscape:export-filename"); - if (temp_string == NULL || (filename_ext != temp_string)) { - repr->setAttribute("inkscape:export-filename", filename_ext.c_str()); - modified = true; + case SELECTION_PAGE: + case SELECTION_DRAWING: { + SPDocument * doc = SP_ACTIVE_DOCUMENT; + Inkscape::XML::Node * repr = doc->getReprRoot(); + bool modified = false; + + bool saved = DocumentUndo::getUndoSensitive(doc); + DocumentUndo::setUndoSensitive(doc, false); + + gchar const *temp_string = repr->attribute("inkscape:export-filename"); + if (temp_string == NULL || (filename_ext != temp_string)) { + repr->setAttribute("inkscape:export-filename", filename_ext.c_str()); + modified = true; + } + temp_string = repr->attribute("inkscape:export-xdpi"); + if (temp_string == NULL || xdpi != atof(temp_string)) { + sp_repr_set_svg_double(repr, "inkscape:export-xdpi", xdpi); + modified = true; + } + temp_string = repr->attribute("inkscape:export-ydpi"); + if (temp_string == NULL || ydpi != atof(temp_string)) { + sp_repr_set_svg_double(repr, "inkscape:export-ydpi", ydpi); + modified = true; + } + DocumentUndo::setUndoSensitive(doc, saved); + + if (modified) { + doc->setModifiedSinceSave(); + } + break; + } + case SELECTION_SELECTION: { + const GSList * reprlst; + SPDocument * doc = SP_ACTIVE_DOCUMENT; + bool modified = false; + + bool saved = DocumentUndo::getUndoSensitive(doc); + DocumentUndo::setUndoSensitive(doc, false); + reprlst = sp_desktop_selection(desktop)->reprList(); + + for(; reprlst != NULL; reprlst = reprlst->next) { + Inkscape::XML::Node * repr = static_cast(reprlst->data); + const gchar * temp_string; + Glib::ustring dir = Glib::path_get_dirname(filename.c_str()); + const gchar* docURI=SP_ACTIVE_DOCUMENT->getURI(); + Glib::ustring docdir; + if (docURI) + { + docdir = Glib::path_get_dirname(docURI); + } + if (repr->attribute("id") == NULL || + !(filename_ext.find_last_of(repr->attribute("id")) && + ( !docURI || + (dir == docdir)))) { + temp_string = repr->attribute("inkscape:export-filename"); + if (temp_string == NULL || (filename_ext != temp_string)) { + repr->setAttribute("inkscape:export-filename", filename_ext.c_str()); + modified = true; + } } temp_string = repr->attribute("inkscape:export-xdpi"); if (temp_string == NULL || xdpi != atof(temp_string)) { @@ -1213,62 +1263,16 @@ void Export::onExport () sp_repr_set_svg_double(repr, "inkscape:export-ydpi", ydpi); modified = true; } - DocumentUndo::setUndoSensitive(doc, saved); - - if (modified) { - doc->setModifiedSinceSave(); - } - break; } - case SELECTION_SELECTION: { - const GSList * reprlst; - SPDocument * doc = SP_ACTIVE_DOCUMENT; - bool modified = false; - - bool saved = DocumentUndo::getUndoSensitive(doc); - DocumentUndo::setUndoSensitive(doc, false); - reprlst = sp_desktop_selection(desktop)->reprList(); - - for(; reprlst != NULL; reprlst = reprlst->next) { - Inkscape::XML::Node * repr = static_cast(reprlst->data); - const gchar * temp_string; - Glib::ustring dir = Glib::path_get_dirname(filename.c_str()); - const gchar* docURI=SP_ACTIVE_DOCUMENT->getURI(); - Glib::ustring docdir; - if (docURI) - { - docdir = Glib::path_get_dirname(docURI); - } - if (repr->attribute("id") == NULL || - !(filename_ext.find_last_of(repr->attribute("id")) && - ( !docURI || - (dir == docdir)))) { - temp_string = repr->attribute("inkscape:export-filename"); - if (temp_string == NULL || (filename_ext != temp_string)) { - repr->setAttribute("inkscape:export-filename", filename_ext.c_str()); - modified = true; - } - } - temp_string = repr->attribute("inkscape:export-xdpi"); - if (temp_string == NULL || xdpi != atof(temp_string)) { - sp_repr_set_svg_double(repr, "inkscape:export-xdpi", xdpi); - modified = true; - } - temp_string = repr->attribute("inkscape:export-ydpi"); - if (temp_string == NULL || ydpi != atof(temp_string)) { - sp_repr_set_svg_double(repr, "inkscape:export-ydpi", ydpi); - modified = true; - } - } - DocumentUndo::setUndoSensitive(doc, saved); + DocumentUndo::setUndoSensitive(doc, saved); - if (modified) { - doc->setModifiedSinceSave(); - } - break; + if (modified) { + doc->setModifiedSinceSave(); } - default: - break; + break; + } + default: + break; } } @@ -1331,8 +1335,8 @@ void Export::onBrowse () // Copy the selected file name, converting from UTF-8 to UTF-16 std::string dirname = Glib::path_get_dirname(filename.raw()); if ( !Glib::file_test(dirname, Glib::FILE_TEST_EXISTS) || - Glib::file_test(filename, Glib::FILE_TEST_IS_DIR) || - dirname.empty() ) + Glib::file_test(filename, Glib::FILE_TEST_IS_DIR) || + dirname.empty() ) { Glib::ustring tmp; filename = create_filepath_from_id(tmp, tmp); @@ -1407,11 +1411,11 @@ bool Export::bbox_equal(Geom::Rect const &one, Geom::Rect const &two) { double const epsilon = pow(10.0, -EXPORT_COORD_PRECISION); return ( - (fabs(one.min()[Geom::X] - two.min()[Geom::X]) < epsilon) && - (fabs(one.min()[Geom::Y] - two.min()[Geom::Y]) < epsilon) && - (fabs(one.max()[Geom::X] - two.max()[Geom::X]) < epsilon) && - (fabs(one.max()[Geom::Y] - two.max()[Geom::Y]) < epsilon) - ); + (fabs(one.min()[Geom::X] - two.min()[Geom::X]) < epsilon) && + (fabs(one.min()[Geom::Y] - two.min()[Geom::Y]) < epsilon) && + (fabs(one.max()[Geom::X] - two.max()[Geom::X]) < epsilon) && + (fabs(one.max()[Geom::Y] - two.max()[Geom::Y]) < epsilon) + ); } /** @@ -1454,48 +1458,48 @@ void Export::detectSize() { for (int i = 0; i < SELECTION_NUMBER_OF + 1 && - key == SELECTION_NUMBER_OF && - SP_ACTIVE_DESKTOP != NULL; + key == SELECTION_NUMBER_OF && + SP_ACTIVE_DESKTOP != NULL; i++) { switch (this_test[i]) { - case SELECTION_SELECTION: - if ((sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false) { - Geom::OptRect bbox = (sp_desktop_selection (SP_ACTIVE_DESKTOP))->bounds(SPItem::VISUAL_BBOX); + case SELECTION_SELECTION: + if ((sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false) { + Geom::OptRect bbox = (sp_desktop_selection (SP_ACTIVE_DESKTOP))->bounds(SPItem::VISUAL_BBOX); - if ( bbox && bbox_equal(*bbox,current_bbox)) { - key = SELECTION_SELECTION; - } + if ( bbox && bbox_equal(*bbox,current_bbox)) { + key = SELECTION_SELECTION; } - break; - case SELECTION_DRAWING: { - SPDocument *doc = sp_desktop_document (SP_ACTIVE_DESKTOP); + } + break; + case SELECTION_DRAWING: { + SPDocument *doc = sp_desktop_document (SP_ACTIVE_DESKTOP); - Geom::OptRect bbox = doc->getRoot()->desktopVisualBounds(); + Geom::OptRect bbox = doc->getRoot()->desktopVisualBounds(); - if ( bbox && bbox_equal(*bbox,current_bbox) ) { - key = SELECTION_DRAWING; - } - break; + if ( bbox && bbox_equal(*bbox,current_bbox) ) { + key = SELECTION_DRAWING; } + break; + } - case SELECTION_PAGE: { - SPDocument *doc; + case SELECTION_PAGE: { + SPDocument *doc; - doc = sp_desktop_document (SP_ACTIVE_DESKTOP); + doc = sp_desktop_document (SP_ACTIVE_DESKTOP); - Geom::Point x(0.0, 0.0); - Geom::Point y(doc->getWidth().value("px"), - doc->getHeight().value("px")); - Geom::Rect bbox(x, y); + Geom::Point x(0.0, 0.0); + Geom::Point y(doc->getWidth().value("px"), + doc->getHeight().value("px")); + Geom::Rect bbox(x, y); - if (bbox_equal(bbox,current_bbox)) { - key = SELECTION_PAGE; - } + if (bbox_equal(bbox,current_bbox)) { + key = SELECTION_PAGE; + } - break; - } + break; + } default: - break; + break; } } // std::cout << std::endl; @@ -1579,7 +1583,7 @@ void Export::areaYChange (Gtk::Adjustment *adj) height = SP_EXPORT_MIN_SIZE; //key = (const gchar *)g_object_get_data(G_OBJECT (adj), "key"); if (adj == y1_adj) { - //if (!strcmp (key, "y0")) { + //if (!strcmp (key, "y0")) { y1 = y0 + height * DPI_BASE / ydpi; setValuePx(y1_adj, y1); } else { diff --git a/src/ui/dialog/export.h b/src/ui/dialog/export.h index 79e597414..6f3c0dfac 100644 --- a/src/ui/dialog/export.h +++ b/src/ui/dialog/export.h @@ -56,7 +56,9 @@ public: Export (); ~Export (); - static Export &getInstance() { return *new Export(); } + static Export &getInstance() { + return *new Export(); + } private: @@ -97,7 +99,7 @@ private: float getValue (Gtk::Adjustment *adj); float getValuePx (Gtk::Adjustment *adj); #endif - + /** * Helper function to create, style and pack spinbuttons for the export dialog. * @@ -121,20 +123,20 @@ private: */ #if WITH_GTKMM_3_0 Glib::RefPtr createSpinbutton( gchar const *key, float val, float min, float max, - float step, float page, - Gtk::Grid *t, int x, int y, - const Glib::ustring ll, const Glib::ustring lr, - int digits, unsigned int sensitive, - void (Export::*cb)() ); + float step, float page, + Gtk::Grid *t, int x, int y, + const Glib::ustring& ll, const Glib::ustring& lr, + int digits, unsigned int sensitive, + void (Export::*cb)() ); #else Gtk::Adjustment * createSpinbutton( gchar const *key, float val, float min, float max, - float step, float page, - Gtk::Table *t, int x, int y, - const Glib::ustring ll, const Glib::ustring lr, - int digits, unsigned int sensitive, - void (Export::*cb)() ); + float step, float page, + Gtk::Table *t, int x, int y, + const Glib::ustring& ll, const Glib::ustring& lr, + int digits, unsigned int sensitive, + void (Export::*cb)() ); #endif - + /** * One of the area select radio buttons was pressed */ @@ -153,8 +155,12 @@ private: /** * Area X value changed callback */ - void onAreaX0Change() {areaXChange(x0_adj);} ; - void onAreaX1Change() {areaXChange(x1_adj);} ; + void onAreaX0Change() { + areaXChange(x0_adj); + } ; + void onAreaX1Change() { + areaXChange(x1_adj); + } ; #if WITH_GTKMM_3_0 void areaXChange(Glib::RefPtr& adj); #else @@ -164,8 +170,12 @@ private: /** * Area Y value changed callback */ - void onAreaY0Change() {areaYChange(y0_adj);} ; - void onAreaY1Change() {areaYChange(y1_adj);} ; + void onAreaY0Change() { + areaYChange(y0_adj); + } ; + void onAreaY1Change() { + areaYChange(y1_adj); + } ; #if WITH_GTKMM_3_0 void areaYChange(Glib::RefPtr& adj); #else @@ -235,14 +245,14 @@ private: /** * Creates progress dialog for batch exporting. - * + * * @param progress_text Text to be shown in the progress bar */ Gtk::Dialog * create_progress_dialog (Glib::ustring progress_text); /** * Callback to be used in for loop to update the progress bar. - * + * * @param value number between 0 and 1 indicating the fraction of progress (0.17 = 17 % progress) * @param dlg void pointer to the Gtk::Dialog progress dialog */ -- cgit v1.2.3 From c15e77cc2670408ab725ba60c064743a9b61a375 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 5 Mar 2014 20:18:54 +0100 Subject: Fixing branch problems (bzr r11950.1.281) --- src/ui/tool/curve-drag-point.cpp | 5 ++- src/ui/tool/multi-path-manipulator.cpp | 5 ++- src/ui/tool/node.cpp | 64 ++++++++++++++++---------------- src/ui/tool/node.h | 2 +- src/ui/tool/path-manipulator.cpp | 14 +++---- src/ui/tools/freehand-base.cpp | 23 ++++++------ src/ui/tools/node-tool.h | 3 +- src/ui/tools/pen-tool.cpp | 67 ++++++++++++++++------------------ src/ui/tools/pen-tool.h | 26 ++++++------- src/ui/tools/pencil-tool.cpp | 4 +- 10 files changed, 106 insertions(+), 107 deletions(-) (limited to 'src') diff --git a/src/ui/tool/curve-drag-point.cpp b/src/ui/tool/curve-drag-point.cpp index e5412fdc2..ad03cf75d 100644 --- a/src/ui/tool/curve-drag-point.cpp +++ b/src/ui/tool/curve-drag-point.cpp @@ -53,7 +53,7 @@ bool CurveDragPoint::grabbed(GdkEventMotion */*event*/) // delta is a vector equal 1/3 of distance from first to second Geom::Point delta = (second->position() - first->position()) / 3.0; - //spanish: solo actualizamos los nodos si no es bspline + // only update the nodes if the mode is bspline if(!_pm.isBSpline(false)){ first->front()->move(first->front()->position() + delta); second->back()->move(second->back()->position() - delta); @@ -89,7 +89,8 @@ void CurveDragPoint::dragged(Geom::Point &new_pos, GdkEventMotion *event) Geom::Point delta = new_pos - position(); Geom::Point offset0 = ((1-weight)/(3*t*(1-t)*(1-t))) * delta; Geom::Point offset1 = (weight/(3*t*t*(1-t))) * delta; - //spanish: modificado para que, si el trazado es bspline solo actue si está presionada la tecla SHIFT + + //modified so that, if the trace is bspline, it only acts if the SHIFT key is pressed if(!_pm.isBSpline(false)){ first->front()->move(first->front()->position() + offset0); second->back()->move(second->back()->position() + offset1); diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp index b7f3ac29b..68aaa77a5 100644 --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@ -671,9 +671,10 @@ bool MultiPathManipulator::event(Inkscape::UI::Tools::ToolBase *event_context, G // b) ctrl+del preserves shape (del_preserves_shape is false), and control is pressed // Hence xor guint mode = prefs->getInt("/tools/freehand/pen/freehand-mode", 0); - //spanish: si es trazado bspline (mode 2) + + //if the trace is bspline ( mode 2) if(mode==2){ - //spanish: ¿correcto? + // is this correct ? if(del_preserves_shape ^ held_control(event->key)) deleteNodes(false); else diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 78d8fe833..73460a313 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -167,7 +167,7 @@ void Handle::move(Geom::Point const &new_pos) } setPosition(new_pos); - //spanish: mueve el tirador y su opuesto la misma proporción + //move the handler and its oposite the same proportion if(_pm().isBSpline(false)){ setPosition(_pm().BSplineHandleReposition(this)); this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),_parent->bsplineWeight)); @@ -184,7 +184,7 @@ void Handle::move(Geom::Point const &new_pos) / Geom::L2sq(direction)) * direction; setRelativePos(new_delta); - //spanish: mueve el tirador y su opuesto la misma proporción + //move the handler and its oposite the same proportion if(_pm().isBSpline(false)){ setPosition(_pm().BSplineHandleReposition(this)); this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),_parent->bsplineWeight)); @@ -210,7 +210,7 @@ void Handle::move(Geom::Point const &new_pos) } setPosition(new_pos); - //spanish: mueve el tirador y su opuesto la misma proporción + // moves the handler and its oposite the same proportion if(_pm().isBSpline(false)){ setPosition(_pm().BSplineHandleReposition(this)); this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),_parent->bsplineWeight)); @@ -292,7 +292,7 @@ bool Handle::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEven break; default: break; } - //spanish: nuevo evento de doble click para resetear a la proporción por defecto, 0.3334%, los tiradores de un nodo + // new double click event to set the handlers of a node to the default proportion, 0.3334% case GDK_2BUTTON_PRESS: handle_2button_press(); break; @@ -303,7 +303,7 @@ bool Handle::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEven return ControlPoint::_eventHandler(event_context, event); } -//spanish: función que mueve el tirador y su opuesto a la proporción por defecto de 0.3334 +//this function moves the handler and its oposite to the default proportion of 0.3334 void Handle::handle_2button_press(){ if(_pm().isBSpline(false)){ setPosition(_pm().BSplineHandleReposition(this,0.3334)); @@ -359,8 +359,8 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) ctrl_constraint = Inkscape::Snapper::SnapConstraint(parent_pos, parent_pos - perp_pos); } new_pos = result; - //spanish: mueve el tirador y su opuesto en X posiciones fijas depenfiendo de la configuración de el - //parametro "steps whith control" del efecto en vivo BSpline + // moves the handler and its oposite in X fixed positions depending on parameter "steps with control" + // by default in live BSpline if(_pm().isBSpline(false)){ setPosition(new_pos); int steps = _pm().BSplineGetSteps(); @@ -370,7 +370,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) } std::vector unselected; - //spanish: si está activado el ajuste (snap) y no es bspline + //if the snap adjustment is activated and it is not bspline if (snap && !_pm().isBSpline(false)) { ControlPointSelection::Set &nodes = _parent->_selection.allPoints(); for (ControlPointSelection::Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { @@ -411,8 +411,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) other()->setPosition(_saved_other_pos); } } - //spanish: si es bspline pero no está presionado SHIFT o CONTROL - //lo fija en la posición original + //if it is bspline but SHIFT or CONTROL are not pressed it fixes it in the original position if(_pm().isBSpline(false) && !held_shift(*event) && !held_control(*event)){ new_pos=_last_drag_origin(); } @@ -432,7 +431,7 @@ void Handle::ungrabbed(GdkEventButton *event) Geom::Point dist = _desktop->d2w(_parent->position()) - _desktop->d2w(position()); if (dist.length() <= drag_tolerance) { move(_parent->position()); - //spanish: marca la fuerza del bspline como 0.0000 + //sets the bspline strength to 0.0000 if(_pm().isBSpline(false)){ _parent->bsplineWeight = 0.0000; } @@ -478,9 +477,9 @@ static double snap_increment_degrees() { Glib::ustring Handle::_getTip(unsigned state) const { char const *more; - //spanish: un truco para, si el nodo tiene fuerza, nos marca que es - //del tipo bspline, lo utilizaremos despues para mostras los mensajes apropiados - //no lo podemos hacer de otra forma al ser constante la funcion + // a trick to mark as bspline if the node has no strength, we are going to use it later + // to show the appropiate messages. We cannot do it in any different way becasue the function is constant + bool isBSpline = false; if( _parent->bsplineWeight != 0.0000) isBSpline = true; @@ -622,8 +621,8 @@ void Node::move(Geom::Point const &new_pos) // move handles when the node moves. Geom::Point old_pos = position(); Geom::Point delta = new_pos - position(); - //spanish: guardamos la fuerza anterior del nodo para reaplicarsela - //de nuevo una vez sea movido el nodo + + // save the previous node strength to apply it again once the node is moved double oldPos = 0.0000; Node *n = this; if(_pm().isBSpline(false)){ @@ -638,8 +637,8 @@ void Node::move(Geom::Point const &new_pos) // if the node has a smooth handle after a line segment, it should be kept colinear // with the segment _fixNeighbors(old_pos, new_pos); - //spanish: movemos los tiradores involucrados, primero los del nodo en cuestión - //y despues los de los nodos colindantes + + // move the affected handlers. First the node ones, later the adjoining ones. if(_pm().isBSpline(false)){ _front.setPosition(_pm().BSplineHandleReposition(this->front(),oldPos)); _back.setPosition(_pm().BSplineHandleReposition(this->back(),oldPos)); @@ -649,8 +648,7 @@ void Node::move(Geom::Point const &new_pos) void Node::transform(Geom::Affine const &m) { - //spanish: guardamos la fuerza anterior del nodo para reaplicarsela - //de nuevo una vez sea movido el nodo + // save the previous node strength to apply it again later when the node is moved double oldPos = 0.0000; if(_pm().isBSpline(false)){ oldPos = this->bsplineWeight; @@ -663,8 +661,8 @@ void Node::transform(Geom::Affine const &m) /* Affine transforms keep handle invariants for smooth and symmetric nodes, * but smooth nodes at ends of linear segments and auto nodes need special treatment */ _fixNeighbors(old_pos, position()); - //spanish: movemos los tiradores involucrados, primero los del nodo en cuestión - //y despues los de los nodos colindantes + + // move the involved handlers, first the node ones, later the adjoining ones if(_pm().isBSpline(false)){ _front.setPosition(_pm().BSplineHandleReposition(this->front(),oldPos)); _back.setPosition(_pm().BSplineHandleReposition(this->back(),oldPos)); @@ -755,9 +753,11 @@ void Node::showHandles(bool v) if (!_back.isDegenerate()) { _back.setVisible(v); } - //spanish: definimos la fuerza de los nodos,según sea o no trazado bspline. - //Cada vez que actuemos sobre dichos tiradores en un trazado - //bspline esta fuerza se tiene que actualizar + + // define the node strength, depending on being or not bspline traced. + // every time we operate over these handlers in a trace bspline + // that strength needs to be updated. + this->bsplineWeight = 0.0000; if(_pm().isBSpline(false) && (!_front.isDegenerate() || !_back.isDegenerate())){ if (!_front.isDegenerate()) { @@ -868,9 +868,8 @@ void Node::setType(NodeType type, bool update_handles) break; default: break; } - //spanish: en los cambios de tipo de nodo, sobre trazados bspline, - //o bien los mantenemos con potencia 0.0000 en modo esquina - //o les damos la potencia por defecto en modo de curva + /* in node type changes, about bspline traces, we can mantain them with 0.0000 power in border mode, + or we give them the default power in curve mode */ if(_pm().isBSpline(false)){ if(this->bsplineWeight !=0.0000) this->bsplineWeight = 0.3334; _front.setPosition(_pm().BSplineHandleReposition(this->front(),this->bsplineWeight)); @@ -1123,7 +1122,7 @@ void Node::_setState(State state) case STATE_CLICKED: mgr.setActive(_canvas_item, true); mgr.setPrelight(_canvas_item, false); - //spanish: esto muestra los tiradores al seleccionar los nodos + //this shows the handlers when selecting the nodes if(_pm().isBSpline(false)){ if(!this->back()->isDegenerate()){ _pm().BSplineHandlePosition(this->back()); @@ -1389,9 +1388,10 @@ Node *Node::nodeAwayFrom(Handle *h) Glib::ustring Node::_getTip(unsigned state) const { - //spanish: un truco par, si el nodo tiene fuerza, nos marca que es - //del tipo bspline, lo utilizaremos despues para mostras los mensajes apropiados - //no lo podemos hacer de otra forma al ser constante la funcion + + /* if the node doesnt have strength, it marks it as bspline, we'll use it later + to show the appropiate messages. We cannot do it in any other way, because the + function is constant */ bool isBSpline = false; if( this->bsplineWeight != 0.0000) isBSpline = true; diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h index b7d6951d0..4393446d9 100644 --- a/src/ui/tool/node.h +++ b/src/ui/tool/node.h @@ -187,7 +187,7 @@ public: bool isEndNode() const; Handle *front() { return &_front; } Handle *back() { return &_back; } - //spanish: creamos valor de potencia bspline asociado a cada nodo + //strength value for each node double bsplineWeight; /** diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index a6689d93d..1cc075603 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -663,7 +663,7 @@ unsigned PathManipulator::_deleteStretch(NodeList::iterator start, NodeList::ite nl.erase(start); start = next; } - //spanish: si se borra, reajustamos los tiradores + // if we are removing, we readjust the handlers if(isBSpline(false)){ double pos = 0.0000; if(start.prev()){ @@ -1182,7 +1182,7 @@ void PathManipulator::_createControlPointsFromGeometry() } } -//spanish: determina si el trazado tiene efecto bspline y el numero de pasos que realiza +//determines if the trace has a bspline effect and the number of steps that it takes int PathManipulator::BSplineGetSteps(){ LivePathEffect::LPEBSpline *lpe_bsp = NULL; @@ -1200,7 +1200,7 @@ int PathManipulator::BSplineGetSteps(){ return steps; } -//spanish: determina si el trazado tiene efecto bspline +// determines if the trace has bspline effect bool PathManipulator::isBSpline(bool recalculate){ static int BSplineSteps = this->BSplineGetSteps(); if(recalculate){ @@ -1213,7 +1213,7 @@ bool PathManipulator::isBSpline(bool recalculate){ return isBSpline; } -//spanish: devuelve la fuerza que le corresponderia a la posicón de un tirador +// returns the corresponding strength to the position of a handler double PathManipulator::BSplineHandlePosition(Handle *h){ using Geom::X; using Geom::Y; @@ -1231,13 +1231,13 @@ double PathManipulator::BSplineHandlePosition(Handle *h){ return pos; } -//spanish: mueve el tirador a la posición que le corresponda +// moves the handler to the corresponding position Geom::Point PathManipulator::BSplineHandleReposition(Handle *h){ double pos = this->BSplineHandlePosition(h); return BSplineHandleReposition(h,pos); } -//spanish: mueve el tirador a una posición específica +// moves the handler to the specified position Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){ using Geom::X; using Geom::Y; @@ -1263,7 +1263,7 @@ Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){ return ret; } -//spanish: mueve los tiradores del nodo y sus tiradores opuestos a la potencia de sus nodos +//moves the node handlers and its oposite handlers to the strength of its nodes void PathManipulator::BSplineNodeHandlesReposition(Node *n){ Node * nextNode = n->nodeToward(n->front()); Node * prevNode = n->nodeToward(n->back()); diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index cb6111bd5..40a257de9 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -252,7 +252,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1) { Effect::createAndApply(SPIRO, dc->desktop->doc(), item); } - //spanish: añadimos el modo bspline a los efectos en espera + //add the bspline node in the waiting effects if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2) { Effect::createAndApply(BSPLINE, dc->desktop->doc(), item); } @@ -496,9 +496,9 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) dc->blue2_curve->reset(); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(dc->blue2_bpath), NULL); - //spanish: si c esta vacio, puede ser que se haya tratado de contnuar una curva existente - //y se haya cancelado. Si es asi y el modo es bspline o spirolive la curva previa necesita volver a ser seleccionada - //porque la modificamos al continuar por un anchor + /* if c is empty, it might be that the user was trying to continue an existing curve and cancelled. + if this is the case and we are in bspline or spirolive the previous curve needs to be selected again because + we modify it when continuing through an anchor. */ if (c->is_empty()) { if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ SPDesktop *desktop = dc->desktop; @@ -527,8 +527,10 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) { // We hit bot start and end of single curve, closing paths dc->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Closing path.")); - //spanish: si estamos en modo bspline o spirolive, la curva de continuación y finalización es actualizada al continuar o finalizar la curva en un anchor - //esto proboca que la función original no detecte si es la misma curva en el caso de curvas con multiples partes -shift- y cierre de manera erronea una de las partes + + /* if we are in bspline or spirolive mode, the continuation and ending curve are updated when continuing or ending the curve in an anchor. + this causes that the original function doesn't detect if it's the same curve in case the curves have multiples parts -shift- and + close incorrectly one of the parts */ if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ if (dc->sa->start && !(dc->sa->curve->is_closed()) ) { @@ -547,8 +549,8 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) c->unref(); dc->sa->curve->closepath_current(); } - //spanish: Si la curva tiene un LPE del tipo bspline o spiro ejecutamos spdc_flush_white - //pasándole la curva de inicio necesaria + + //if the curve has an bspline or spiro LPE, we execute spdc_flush_white, passing the necessary starting curve. if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ dc->white_curves = g_slist_remove(dc->white_curves, dc->sa->curve); @@ -679,9 +681,8 @@ SPDrawAnchor *spdc_test_inside(FreehandBase *dc, Geom::Point p) } } - //spanish: modificamos la curva de anclaje para que sea igual que la curva de inicio. - //esta curva fue modificada al continuar la curva y necesitamos que sea igual que la curva en - //la que cerramos el trazado. + /* modify the anchoring curve so it is equal to the starting curve. + this curve is modified when it's modified and we need them to be equal to the closing curve */ Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if((prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2) && diff --git a/src/ui/tools/node-tool.h b/src/ui/tools/node-tool.h index 168ec995a..42f89cd1c 100644 --- a/src/ui/tools/node-tool.h +++ b/src/ui/tools/node-tool.h @@ -14,7 +14,8 @@ #include #include #include "ui/tools/tool-base.h" -//spanish: lo necesitamos para llamarlo desde el Live Effect + +// we need it to call it from Live Effect #include "selection.h" namespace Inkscape { diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index ad77fcb53..e3bbc72b1 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -42,7 +42,7 @@ #include "context-fns.h" #include "tools-switch.h" #include "ui/control-manager.h" -//spanish: incluimos los archivos necesarios para las BSpline y Spiro +// we include the necessary files for BSpline & Spiro #include "live_effects/effect.h" #include "live_effects/lpeobject.h" #include "live_effects/lpeobject-reference.h" @@ -166,7 +166,7 @@ PenTool::~PenTool() { void PenTool::setPolylineMode() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); guint mode = prefs->getInt("/tools/freehand/pen/freehand-mode", 0); - //spanish: cambiamos los modos para dar cabida al modo bspline + // change the nodes to make space for bspline mode this->polylines_only = (mode == 3 || mode == 4); this->polylines_paraxial = (mode == 4); //we call the function which defines the Spiro modes and the BSpline @@ -178,7 +178,7 @@ void PenTool::setPolylineMode() { *.Set the mode of draw spiro, and bsplines */ void PenTool::_pen_context_set_mode(guint mode) { - //spanish: definimos los modos + // define the nodes this->spiro = (mode == 1); this->bspline = (mode == 2); } @@ -386,7 +386,7 @@ gint PenTool::_handleButtonPress(GdkEventButton const &bevent) { if(bevent.button != 3 && (this->spiro || this->bspline) && this->npoints > 0 && this->p[0] == this->p[3]){ this->state = PenTool::STOP; if( anchor && anchor == this->sa && this->green_curve->is_empty()){ - //spanish Borrar siguiente linea para evitar un nodo encima de otro + //remove the following line to avoid having one node on top of another _finishSegment(event_dt, bevent.state); _finish( FALSE); return TRUE; @@ -512,7 +512,7 @@ gint PenTool::_handleButtonPress(GdkEventButton const &bevent) { } } - //spanish: evitamos la creación de un punto de control para que se cree el nodo en el evento de soltar + // avoid the creation of a control point so a node is created in the release event this->state = (this->spiro || this->bspline || this->polylines_only) ? PenTool::POINT : PenTool::CONTROL; ret = TRUE; @@ -705,7 +705,7 @@ gint PenTool::_handleMotionNotify(GdkEventMotion const &mevent) { default: break; } - //spanish: lanzamos la función "bspline_spiro_motion" al moverse el ratón o cuando se para. + // calls the function "bspline_spiro_motion" when the mouse starts or stops moving if(this->bspline){ this->_bspline_spiro_color(); this->_bspline_spiro_motion(mevent.state & GDK_SHIFT_MASK); @@ -743,9 +743,7 @@ gint PenTool::_handleButtonRelease(GdkEventButton const &revent) { // Test whether we hit any anchor. SPDrawAnchor *anchor = spdc_test_inside(this, event_w); - //with this we avoid creating a new point over the existing one - //spanish: si intentamos crear un nodo en el mismo sitio que el origen, paramos. - + // if we try to create a node in the same place as another node, we skip if((!anchor || anchor == this->sa) && (this->spiro || this->bspline) && this->npoints > 0 && this->p[0] == this->p[3]){ return TRUE; } @@ -760,7 +758,7 @@ gint PenTool::_handleButtonRelease(GdkEventButton const &revent) { p = anchor->dp; } this->sa = anchor; - //spanish: continuamos una curva existente + // continue the existing curve if (anchor) { if(this->bspline || this->spiro){ this->_bspline_spiro_start_anchor(revent.state & GDK_SHIFT_MASK);; @@ -790,7 +788,7 @@ gint PenTool::_handleButtonRelease(GdkEventButton const &revent) { this->_endpointSnap(p, revent.state); } this->_finishSegment(p, revent.state); - //spanish: ocultamos la guia del penultimo nodo al cerrar la curva + // hude the guide of the penultimate node when closing the curve if(this->spiro){ sp_canvas_item_hide(this->c1); } @@ -817,7 +815,7 @@ gint PenTool::_handleButtonRelease(GdkEventButton const &revent) { case PenTool::CLOSE: this->_endpointSnap(p, revent.state); this->_finishSegment(p, revent.state); - //spanish: ocultamos la guia del penultimo nodo al cerrar la curva + // hide the penultimate node guide when closing the curve if(this->spiro){ sp_canvas_item_hide(this->c1); } @@ -908,7 +906,7 @@ void PenTool::_redrawAll() { sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve); // handles - //spanish: ocultamos los tiradores en modo bspline y spiro + // hide the handlers in bspline and spiro modes if (this->p[0] != this->p[1] && !this->spiro && !this->bspline) { SP_CTRL(this->c1)->moveto(this->p[1]); this->cl1->setCoords(this->p[0], this->p[1]); @@ -922,7 +920,7 @@ void PenTool::_redrawAll() { Geom::Curve const * last_seg = this->green_curve->last_segment(); if (last_seg) { Geom::CubicBezier const * cubic = dynamic_cast( last_seg ); - //spanish: ocultamos los tiradores en modo bspline y spiro + // hide the handlers in bspline and spiro modes if ( cubic && (*cubic)[2] != this->p[0] && !this->spiro && !this->bspline ) { @@ -937,9 +935,8 @@ void PenTool::_redrawAll() { } } - //spanish: simplemente redibujamos la spiro. - //como es un redibujo simplemente no llamamos a la función global sino al final de esta - //Lanzamos solamente el redibujado + // simply redraw the spiro. because its a redrawing, we don't call the global function, + // but we call the redrawing at the ending. this->_bspline_spiro_build(); } @@ -969,12 +966,12 @@ void PenTool::_lastpointMoveScreen(gdouble x, gdouble y) { } void PenTool::_lastpointToCurve() { - //spanish: evitamos que si la "red_curve" tiene solo dos puntos -recta- no se pare aqui. + // avoid that if the "red_curve" contains only two points ( rect ), it doesn't stop here. if (this->npoints != 5 && !this->spiro && !this->bspline) return; Geom::CubicBezier const * cubic; this->p[1] = this->red_curve->last_segment()->initialPoint() + (1./3)* (Geom::Point)(this->red_curve->last_segment()->finalPoint() - this->red_curve->last_segment()->initialPoint()); - //spanish: modificamos el último segmento de la curva verde para que forme el tipo de nodo que deseamos + //modificate the last segment of the green curve so it creates the type of node we need if(this->spiro||this->bspline){ if(!this->green_curve->is_empty()){ Geom::Point A(0,0); @@ -1012,7 +1009,7 @@ void PenTool::_lastpointToCurve() { this->green_curve->append_continuous(previous, 0.0625); } } - //spanish: si el último nodo es una union con otra curva + //if the last node is an union with another curve if(this->green_curve->is_empty() && this->sa && !this->sa->curve->is_empty()){ this->_bspline_spiro_start_anchor(false); } @@ -1023,11 +1020,11 @@ void PenTool::_lastpointToCurve() { void PenTool::_lastpointToLine() { - //spanish: evitamos que si la "red_curve" tiene solo dos puntos -recta- no se pare aqui. + // avoid that if the "red_curve" contains only two points ( rect) it doesn't stop here. if (this->npoints != 5 && !this->bspline) return; - //spanish: modificamos el último segmento de la curva verde para que forme el tipo de nodo que deseamos + // modify the last segment of the green curve so the type of node we want is created. if(this->spiro || this->bspline){ if(!this->green_curve->is_empty()){ Geom::Point A(0,0); @@ -1059,7 +1056,7 @@ void PenTool::_lastpointToLine() { this->green_curve->append_continuous(previous, 0.0625); } } - //spanish: si el último nodo es una union con otra curva + // if the last node is an union with another curve if(this->green_curve->is_empty() && this->sa && !this->sa->curve->is_empty()){ this->_bspline_spiro_start_anchor(true); } @@ -1248,7 +1245,7 @@ gint PenTool::_handleKeyPress(GdkEvent *event) { this->p[1] = this->p[0]; } - //spanish: asignamos el valor a un tercio de distancia del último segmento. + // asign the value in a third of the distance of the last segment. if(this->bspline){ this->p[1] = this->p[0] + (1./3)*(this->p[3] - this->p[0]); } @@ -1258,7 +1255,7 @@ gint PenTool::_handleKeyPress(GdkEvent *event) { : this->p[3])); this->npoints = 2; - //spanish: eliminamos el último segmento de la curva verde + // delete the last segment of the green curve if( this->green_curve->get_segment_count() == 1){ this->npoints = 5; if (this->green_bpaths) { @@ -1270,7 +1267,7 @@ gint PenTool::_handleKeyPress(GdkEvent *event) { }else{ this->green_curve->backspace(); } - //spanish: asignamos el valor de this->p[1] a el opuesto de el ultimo segmento de la línea verde + // assign the value of this->p[1] to the oposite of the green line last segment if(this->spiro){ cubic = dynamic_cast(this->green_curve->last_segment()); if ( cubic ) { @@ -1285,7 +1282,8 @@ gint PenTool::_handleKeyPress(GdkEvent *event) { this->state = PenTool::POINT; this->_setSubsequentPoint(pt, true); pen_last_paraxial_dir = !pen_last_paraxial_dir; - //spanish: redibujamos + + //redraw this->_bspline_spiro_build(); ret = TRUE; } @@ -1360,9 +1358,7 @@ void PenTool::_setAngleDistanceStatusMessage(Geom::Point const p, int pc_point_t g_string_free(dist, FALSE); } - - -//spanish: esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro +// this function changes the colors red, green and blue making them transparent or not, depending on if spiro is being used. void PenTool::_bspline_spiro_color() { bool remake_green_bpaths = false; @@ -1736,8 +1732,7 @@ void PenTool::_bspline_spiro_end_anchor_off() } } - -//spanish: preparates the curves for its trasformation into BSline curves. +//prepares the curves for its transformation into BSpline curve. void PenTool::_bspline_spiro_build() { if(!this->spiro && !this->bspline) @@ -1766,7 +1761,7 @@ void PenTool::_bspline_spiro_build() } if(!curve->is_empty()){ - //spanish: cerramos la curva si estan cerca los puntos finales de la curva + // close the curve if the final points of the curve are close enough if(Geom::are_near(curve->first_path()->initialPoint(), curve->last_path()->finalPoint())){ curve->closepath_current(); } @@ -1805,7 +1800,7 @@ void PenTool::_bspline_spiro_build() void PenTool::_bspline_doEffect(SPCurve * curve) { - //spanish: comentado en funcion "doEffect" de src/live_effects/lpe-bspline.cpp + // commenting the function doEffect in src/live_effects/lpe-bspline.cpp if(curve->get_segment_count() < 2) return; Geom::PathVector const original_pathv = curve->get_pathvector(); @@ -1945,7 +1940,7 @@ void PenTool::_bspline_doEffect(SPCurve * curve) } //Spiro function cloned from lpe-spiro.cpp -//spanish: comentado en funcion "doEffect" de src/live_effects/lpe-spiro.cpp +// commenting the function "doEffect" from src/live_effects/lpe-spiro.cpp void PenTool::_spiro_doEffect(SPCurve * curve) { using Geom::X; @@ -2178,7 +2173,7 @@ void PenTool::_finish(gboolean const closed) { desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Drawing finished")); - //spanish para cancelar linea sin un segmento creado + // cancelate line without a created segment this->red_curve->reset(); spdc_concat_colors_and_flush(this, closed); this->sa = NULL; diff --git a/src/ui/tools/pen-tool.h b/src/ui/tools/pen-tool.h index 88e528b22..95565abc9 100644 --- a/src/ui/tools/pen-tool.h +++ b/src/ui/tools/pen-tool.h @@ -49,7 +49,7 @@ public: bool polylines_only; bool polylines_paraxial; - //spanish: propiedad que guarda si el modo Spiro está activo o no + // propiety which saves if Spiro mode is active or not bool spiro; bool bspline; int num_clicks; @@ -88,29 +88,29 @@ private: gint _handleButtonRelease(GdkEventButton const &revent); gint _handle2ButtonPress(GdkEventButton const &bevent); gint _handleKeyPress(GdkEvent *event); - //spanish: añade los modos spiro y bspline + //adds spiro & bspline modes void _pen_context_set_mode(guint mode); - //spanish: esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro + //this function changes the colors red, green and blue making them transparent or not depending on if the function uses spiro void _bspline_spiro_color(); - //spanish: crea un nodo en modo bspline o spiro + //creates a node in bspline or spiro modes void _bspline_spiro(bool shift); - //spanish: crea un nodo de modo spiro o bspline + //creates a node in bspline or spiro modes void _bspline_spiro_on(); - //spanish: crea un nodo de tipo CUSP + //creates a CUSP node void _bspline_spiro_off(); - //spanish: continua una curva existente en modo bspline o spiro + //continues the existing curve in bspline or spiro mode void _bspline_spiro_start_anchor(bool shift); - //spanish: continua una curva exsitente con el nodo de union en modo bspline o spiro + //continues the existing curve with the union node in bspline or spiro modes void _bspline_spiro_start_anchor_on(); - //spanish: continua una curva existente con el nodo de union en modo CUSP + //continues an existing curve with the union node in CUSP mode void _bspline_spiro_start_anchor_off(); - //spanish: modifica la "red_curve" cuando se detecta movimiento + //modifies the "red_curve" when it detects movement void _bspline_spiro_motion(bool shift); - //spanish: cierra la curva con el último nodo en modo bspline o spiro + //closes the curve with the last node in bspline or spiro mode void _bspline_spiro_end_anchor_on(); - //spanish: cierra la curva con el último nodo en modo CUSP + //closes the curve with the last node in CUSP mode void _bspline_spiro_end_anchor_off(); - //spanish: unimos todas las curvas en juego y llamamos a la función doEffect. + //CHECK: join all the curves "in game" and we call doEffect function void _bspline_spiro_build(); //function bspline cloned from lpe-bspline.cpp void _bspline_doEffect(SPCurve * curve); diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp index bd50672af..1ccdee637 100644 --- a/src/ui/tools/pencil-tool.cpp +++ b/src/ui/tools/pencil-tool.cpp @@ -685,7 +685,7 @@ void PencilTool::_interpolate() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); guint mode = prefs->getInt("/tools/freehand/pencil/freehand-mode", 0); for (int c = 0; c < n_segs; c++) { - //spanish: si el modo es BSpline modificamos para que el trazado cree los nodos adhoc + // if we are in BSpline we modify the trace to create adhoc nodes if(mode == 2){ Geom::Point BP = b[4*c+0] + (1./3)*(b[4*c+3] - b[4*c+0]); BP = Geom::Point(BP[X] + 0.0001,BP[Y] + 0.0001); @@ -835,7 +835,7 @@ void PencilTool::_fitAndSplit() { this->red_curve->moveto(b[0]); using Geom::X; using Geom::Y; - //spanish: si el modo es BSpline modificamos para que el trazado cree los nodos adhoc + // if we are in BSpline we modify the trace to create adhoc nodes Inkscape::Preferences *prefs = Inkscape::Preferences::get(); guint mode = prefs->getInt("/tools/freehand/pencil/freehand-mode", 0); if(mode == 2){ -- cgit v1.2.3 From eb7c3f5dc2737bb22388b040f857117c3a25da6f Mon Sep 17 00:00:00 2001 From: root Date: Thu, 6 Mar 2014 15:21:30 +0100 Subject: Fixed a bug when click over the previuos node in bspline/spiro mode (bzr r11950.1.285) --- src/ui/tools/pen-tool.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index e3bbc72b1..d79803644 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -384,7 +384,6 @@ gint PenTool::_handleButtonPress(GdkEventButton const &bevent) { //with this we avoid creating a new point over the existing one if(bevent.button != 3 && (this->spiro || this->bspline) && this->npoints > 0 && this->p[0] == this->p[3]){ - this->state = PenTool::STOP; if( anchor && anchor == this->sa && this->green_curve->is_empty()){ //remove the following line to avoid having one node on top of another _finishSegment(event_dt, bevent.state); -- cgit v1.2.3 From 9e33a22a12381e538c26580798934eb418f62bbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20dos=20Santos=20Oliveira?= Date: Sun, 9 Mar 2014 22:06:46 -0300 Subject: Shortening code through removal of variable declaration used only at one place. (bzr r11950.6.1) --- src/ui/tools/freehand-base.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 40a257de9..4b7a310e3 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -501,8 +501,7 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) we modify it when continuing through an anchor. */ if (c->is_empty()) { if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ - SPDesktop *desktop = dc->desktop; - spdc_selection_modified(sp_desktop_selection(desktop), 0, dc); + spdc_selection_modified(sp_desktop_selection(dc->desktop), 0, dc); } c->unref(); return; -- cgit v1.2.3 From 4b8c6b64ba7ac54955cc68aa6ad18c67b57ef5fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20dos=20Santos=20Oliveira?= Date: Sun, 9 Mar 2014 23:20:18 -0300 Subject: Removing repeated condition logical test to make the code more readable and easier to follow. (bzr r11950.6.2) --- src/ui/tools/freehand-base.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 4b7a310e3..3f74a5147 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -540,6 +540,11 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) if(Geom::are_near(dc->sa->curve->first_path()->initialPoint(), dc->ea->dp)){ dc->sa->curve->closepath_current(); } + + // if the curve has an bspline or spiro LPE, we execute + // spdc_flush_white, passing the necessary starting curve. + dc->white_curves = g_slist_remove(dc->white_curves, dc->sa->curve); + spdc_flush_white(dc, dc->sa->curve); }else{ if (dc->sa->start && !(dc->sa->curve->is_closed()) ) { c = reverse_then_unref(c); @@ -547,16 +552,9 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) dc->sa->curve->append_continuous(c, 0.0625); c->unref(); dc->sa->curve->closepath_current(); - } - - //if the curve has an bspline or spiro LPE, we execute spdc_flush_white, passing the necessary starting curve. - if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || - prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ - dc->white_curves = g_slist_remove(dc->white_curves, dc->sa->curve); - spdc_flush_white(dc, dc->sa->curve); - }else{ spdc_flush_white(dc, NULL); } + return; } -- cgit v1.2.3 From 232d5c9f3cda7f24f4c3019c3c312f81f8797011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20dos=20Santos=20Oliveira?= Date: Fri, 14 Mar 2014 01:20:33 -0300 Subject: Small code simplification (bzr r11950.7.1) --- src/ui/tool/path-manipulator.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 1cc075603..f8cc58e3b 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1206,11 +1206,7 @@ bool PathManipulator::isBSpline(bool recalculate){ if(recalculate){ BSplineSteps = this->BSplineGetSteps(); } - bool isBSpline = false; - if(BSplineSteps>0){ - isBSpline = true; - } - return isBSpline; + return BSplineSteps > 0; } // returns the corresponding strength to the position of a handler -- cgit v1.2.3 From ed6364b83dafb3d1b9cbedfa6675817833e9fdeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20dos=20Santos=20Oliveira?= Date: Fri, 14 Mar 2014 01:21:08 -0300 Subject: Adding default argument to PathManipulator::isBSpline. Default argument is used when function is called with missing arguments. The default was chosen to 'true', because it is the safest value in this context. From now on, the function can be called like "_pm.isBSpline()", which is more intuitive. Still, I haven't studied the code enough to determine if this cache behaviour (force the user to think if cache is correct) is appropriate. (bzr r11950.7.2) --- src/ui/tool/path-manipulator.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index 5186bfc95..594f56ff9 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -106,7 +106,7 @@ private: typedef boost::shared_ptr SubpathPtr; void _createControlPointsFromGeometry(); - bool isBSpline(bool recalculate); + bool isBSpline(bool recalculate = true); double BSplineHandlePosition(Handle *h); Geom::Point BSplineHandleReposition(Handle *h); Geom::Point BSplineHandleReposition(Handle *h,double pos); -- cgit v1.2.3 From f9d1d1a8a33eee7fd7977361d2d559697f0fb56d Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 14 Mar 2014 18:35:31 +0100 Subject: =?UTF-8?q?disabling=20cache=20approach=20for=20isBSpline=20functi?= =?UTF-8?q?on,=20pointed=20by=20Vin=C3=ADcius?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (bzr r11950.1.296) --- src/ui/tool/path-manipulator.cpp | 15 ++++++++------- src/ui/tool/path-manipulator.h | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index f8cc58e3b..adc70bc38 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -145,7 +145,7 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, sigc::hide( sigc::mem_fun(*this, &PathManipulator::_updateOutlineOnZoomChange))); _createControlPointsFromGeometry(); - isBSpline(true); + isBSpline(/*true*/); } PathManipulator::~PathManipulator() @@ -1201,11 +1201,12 @@ int PathManipulator::BSplineGetSteps(){ } // determines if the trace has bspline effect -bool PathManipulator::isBSpline(bool recalculate){ - static int BSplineSteps = this->BSplineGetSteps(); - if(recalculate){ - BSplineSteps = this->BSplineGetSteps(); - } +bool PathManipulator::isBSpline(/*bool recalculate*/){ + /*static*/ int BSplineSteps = this->BSplineGetSteps(); + // Taking out the static dont need this part + //if(recalculate){ + // BSplineSteps = this->BSplineGetSteps(); + //} return BSplineSteps > 0; } @@ -1282,7 +1283,7 @@ void PathManipulator::BSplineNodeHandlesReposition(Node *n){ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) { Geom::PathBuilder builder; - isBSpline(true); + isBSpline(/*true*/); for (std::list::iterator spi = _subpaths.begin(); spi != _subpaths.end(); ) { SubpathPtr subpath = *spi; if (subpath->empty()) { diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index 594f56ff9..67590832d 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -106,7 +106,7 @@ private: typedef boost::shared_ptr SubpathPtr; void _createControlPointsFromGeometry(); - bool isBSpline(bool recalculate = true); + bool isBSpline(/*bool recalculate = true*/); double BSplineHandlePosition(Handle *h); Geom::Point BSplineHandleReposition(Handle *h); Geom::Point BSplineHandleReposition(Handle *h,double pos); -- cgit v1.2.3 From eb3102790b3c0eb1ce7131d2c4edceab5978ce88 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 14 Mar 2014 18:38:27 +0100 Subject: simplify the code in isBSpline (bzr r11950.1.297) --- src/ui/tool/path-manipulator.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index adc70bc38..3e54acddf 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1202,12 +1202,13 @@ int PathManipulator::BSplineGetSteps(){ // determines if the trace has bspline effect bool PathManipulator::isBSpline(/*bool recalculate*/){ - /*static*/ int BSplineSteps = this->BSplineGetSteps(); // Taking out the static dont need this part + // static int BSplineSteps = this->BSplineGetSteps(); //if(recalculate){ // BSplineSteps = this->BSplineGetSteps(); //} - return BSplineSteps > 0; + //return BSplineSteps > 0; + return this->BSplineGetSteps() > 0; } // returns the corresponding strength to the position of a handler -- cgit v1.2.3 From acc3de4356672491bcdd795fbac6b80ee2faf27d Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 17 Mar 2014 00:57:12 +0100 Subject: Fix to solve static var in isBSpline function (bzr r11950.1.298) --- src/ui/tool/path-manipulator.cpp | 21 ++++++++++----------- src/ui/tool/path-manipulator.h | 3 ++- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 3e54acddf..841ab659a 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -145,7 +145,8 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, sigc::hide( sigc::mem_fun(*this, &PathManipulator::_updateOutlineOnZoomChange))); _createControlPointsFromGeometry(); - isBSpline(/*true*/); + //Define if the path is BSpline on construction + isBSpline(true); } PathManipulator::~PathManipulator() @@ -664,7 +665,7 @@ unsigned PathManipulator::_deleteStretch(NodeList::iterator start, NodeList::ite start = next; } // if we are removing, we readjust the handlers - if(isBSpline(false)){ + if(isBSpline()){ double pos = 0.0000; if(start.prev()){ pos = BSplineHandlePosition(start.prev()->back()); @@ -1201,14 +1202,11 @@ int PathManipulator::BSplineGetSteps(){ } // determines if the trace has bspline effect -bool PathManipulator::isBSpline(/*bool recalculate*/){ - // Taking out the static dont need this part - // static int BSplineSteps = this->BSplineGetSteps(); - //if(recalculate){ - // BSplineSteps = this->BSplineGetSteps(); - //} - //return BSplineSteps > 0; - return this->BSplineGetSteps() > 0; +bool PathManipulator::isBSpline(bool recalculate){ + if(recalculate){ + _is_bspline = this->BSplineGetSteps() > 0; + } + return _is_bspline; } // returns the corresponding strength to the position of a handler @@ -1284,7 +1282,8 @@ void PathManipulator::BSplineNodeHandlesReposition(Node *n){ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) { Geom::PathBuilder builder; - isBSpline(/*true*/); + //Refresh if is bspline some times -think on path change selection, this value get lost + isBSpline(true); for (std::list::iterator spi = _subpaths.begin(); spi != _subpaths.end(); ) { SubpathPtr subpath = *spi; if (subpath->empty()) { diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index 67590832d..f15533021 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -106,7 +106,7 @@ private: typedef boost::shared_ptr SubpathPtr; void _createControlPointsFromGeometry(); - bool isBSpline(/*bool recalculate = true*/); + bool isBSpline(bool recalculate = true); double BSplineHandlePosition(Handle *h); Geom::Point BSplineHandleReposition(Handle *h); Geom::Point BSplineHandleReposition(Handle *h,double pos); @@ -152,6 +152,7 @@ private: bool _show_path_direction; bool _live_outline; bool _live_objects; + bool _is_bspline; Glib::ustring _lpe_key; friend class PathManipulatorObserver; -- cgit v1.2.3 From c1c76126846e36fab78a51e5acec475b4de5ea44 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 19 Mar 2014 21:54:30 +0100 Subject: This think fix su_v related bug on continuous paths in BSpline or Spiro mode (bzr r11950.1.301) --- src/ui/tools/freehand-base.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 3f74a5147..67b603ab0 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -495,7 +495,7 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) // Blue2 dc->blue2_curve->reset(); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(dc->blue2_bpath), NULL); - + /* if c is empty, it might be that the user was trying to continue an existing curve and cancelled. if this is the case and we are in bspline or spirolive the previous curve needs to be selected again because we modify it when continuing through an anchor. */ @@ -614,6 +614,18 @@ static void spdc_flush_white(FreehandBase *dc, SPCurve *gc) bool has_lpe = false; Inkscape::XML::Node *repr; + + /* if we are in bspline or spirolive the anchors curves, if exist, needs to be selected again because + we modify it when continuing through an anchor. */ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if ( ((dc->sa && !dc->sa->curve->is_empty()) || + (dc->ea && !dc->ea->curve->is_empty())) && + (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || + prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2) + ) { + spdc_selection_modified(sp_desktop_selection(dc->desktop), 0, dc); + } + if (dc->white_item) { repr = dc->white_item->getRepr(); has_lpe = SP_LPE_ITEM(dc->white_item)->hasPathEffectRecursive(); -- cgit v1.2.3 From c6e50a519c55220ccd4efdd6a7a7dbe51cf9fa04 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 19 Mar 2014 22:49:07 +0100 Subject: Fixing suv mac bug continuing existing bsplines/spiro paths (bzr r11950.1.303) --- src/ui/tools/freehand-base.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 67b603ab0..d34ca2142 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -566,7 +566,7 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) s = reverse_then_unref(s); } s->append_continuous(c, 0.0625); - c->unref(); + c->reset(); c = s; } else /* Step D - test end */ if (dc->ea) { SPCurve *e = dc->ea->curve; -- cgit v1.2.3 From 988c4a1639ca097634e336d49ad92eb1eb576f31 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 19 Mar 2014 23:05:50 +0100 Subject: Fix a bug when starting path with change from bspline to spiro and inverse (bzr r11950.1.304) --- src/ui/tools/pen-tool.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index d79803644..75dd6a32b 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -1445,6 +1445,10 @@ void PenTool::_bspline_spiro_off() void PenTool::_bspline_spiro_start_anchor(bool shift) { + if(this->sa->curve->is_empty()){ + return; + } + LivePathEffect::LPEBSpline *lpe_bsp = NULL; if (SP_IS_LPE_ITEM(this->white_item) && SP_LPE_ITEM(this->white_item)->hasPathEffect()){ @@ -1474,9 +1478,6 @@ void PenTool::_bspline_spiro_start_anchor(bool shift) if(!this->spiro && !this->bspline) return; - if(this->sa->curve->is_empty()) - return; - if(shift) this->_bspline_spiro_start_anchor_off(); else -- cgit v1.2.3 From 67a180fdd31fd8dd06be4df75356509001295458 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 20 Mar 2014 01:48:37 +0100 Subject: Refactor of anchors (bzr r11950.1.306) --- src/ui/tools/freehand-base.cpp | 97 +++++++++++++++++------------------------- src/ui/tools/freehand-base.h | 2 + src/ui/tools/pen-tool.cpp | 18 ++++---- 3 files changed, 50 insertions(+), 67 deletions(-) (limited to 'src') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index d34ca2142..5897ce0ee 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -492,17 +492,7 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) dc->red_curve->reset(); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(dc->red_bpath), NULL); - // Blue2 - dc->blue2_curve->reset(); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(dc->blue2_bpath), NULL); - - /* if c is empty, it might be that the user was trying to continue an existing curve and cancelled. - if this is the case and we are in bspline or spirolive the previous curve needs to be selected again because - we modify it when continuing through an anchor. */ if (c->is_empty()) { - if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ - spdc_selection_modified(sp_desktop_selection(dc->desktop), 0, dc); - } c->unref(); return; } @@ -526,50 +516,43 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) { // We hit bot start and end of single curve, closing paths dc->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Closing path.")); - - /* if we are in bspline or spirolive mode, the continuation and ending curve are updated when continuing or ending the curve in an anchor. - this causes that the original function doesn't detect if it's the same curve in case the curves have multiples parts -shift- and - close incorrectly one of the parts */ + if (dc->sa->start && !(dc->sa->curve->is_closed()) ) { + c = reverse_then_unref(c); + } if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || - prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ - if (dc->sa->start && !(dc->sa->curve->is_closed()) ) { - dc->sa->curve = reverse_then_unref(dc->sa->curve); - } - dc->sa->curve->append_continuous(c, 0.0625); + prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ + dc->sc->append_continuous(c, 0.0625); c->unref(); - if(Geom::are_near(dc->sa->curve->first_path()->initialPoint(), dc->ea->dp)){ - dc->sa->curve->closepath_current(); - } - - // if the curve has an bspline or spiro LPE, we execute - // spdc_flush_white, passing the necessary starting curve. - dc->white_curves = g_slist_remove(dc->white_curves, dc->sa->curve); - spdc_flush_white(dc, dc->sa->curve); + dc->sc->closepath_current(); }else{ - if (dc->sa->start && !(dc->sa->curve->is_closed()) ) { - c = reverse_then_unref(c); - } dc->sa->curve->append_continuous(c, 0.0625); c->unref(); dc->sa->curve->closepath_current(); - spdc_flush_white(dc, NULL); } - + spdc_flush_white(dc, NULL); return; } // Step C - test start if (dc->sa) { SPCurve *s = dc->sa->curve; + if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || + prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ + s = dc->sc; + } dc->white_curves = g_slist_remove(dc->white_curves, s); if (dc->sa->start) { s = reverse_then_unref(s); } s->append_continuous(c, 0.0625); - c->reset(); + c->unref(); c = s; } else /* Step D - test end */ if (dc->ea) { SPCurve *e = dc->ea->curve; + if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || + prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ + e = dc->ec; + } dc->white_curves = g_slist_remove(dc->white_curves, e); if (!dc->ea->start) { e = reverse_then_unref(e); @@ -577,16 +560,30 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) c->append_continuous(e, 0.0625); e->unref(); } + + spdc_flush_white(dc, c); + c->unref(); } static void spdc_flush_white(FreehandBase *dc, SPCurve *gc) { SPCurve *c; - + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (dc->white_curves) { g_assert(dc->white_item); + if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || + prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ + if(dc->sa){ + dc->white_curves = g_slist_remove(dc->white_curves, dc->sa->curve); + dc->white_curves = g_slist_append(dc->white_curves, dc->sc); + } + if(dc->ea){ + dc->white_curves = g_slist_remove(dc->white_curves, dc->ea->curve); + dc->white_curves = g_slist_append(dc->white_curves, dc->ec); + } + } c = SPCurve::concat(dc->white_curves); g_slist_free(dc->white_curves); dc->white_curves = NULL; @@ -615,17 +612,6 @@ static void spdc_flush_white(FreehandBase *dc, SPCurve *gc) bool has_lpe = false; Inkscape::XML::Node *repr; - /* if we are in bspline or spirolive the anchors curves, if exist, needs to be selected again because - we modify it when continuing through an anchor. */ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if ( ((dc->sa && !dc->sa->curve->is_empty()) || - (dc->ea && !dc->ea->curve->is_empty())) && - (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || - prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2) - ) { - spdc_selection_modified(sp_desktop_selection(dc->desktop), 0, dc); - } - if (dc->white_item) { repr = dc->white_item->getRepr(); has_lpe = SP_LPE_ITEM(dc->white_item)->hasPathEffectRecursive(); @@ -689,19 +675,6 @@ SPDrawAnchor *spdc_test_inside(FreehandBase *dc, Geom::Point p) active = na; } } - - /* modify the anchoring curve so it is equal to the starting curve. - this curve is modified when it's modified and we need them to be equal to the closing curve */ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if((prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || - prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2) && - dc->sa && !dc->red_curve->is_empty() && !dc->green_anchor){ - if(active){ - active->curve = dc->sa->curve; - active->curve->ref(); - } - } - return active; } @@ -750,6 +723,14 @@ static void spdc_free_colors(FreehandBase *dc) dc->blue2_curve = dc->blue2_curve->unref(); } + if (dc->sc) { + dc->sc = dc->sc->unref(); + } + + if (dc->ec) { + dc->ec = dc->ec->unref(); + } + // Green while (dc->green_bpaths) { sp_canvas_item_destroy(SP_CANVAS_ITEM(dc->green_bpaths->data)); diff --git a/src/ui/tools/freehand-base.h b/src/ui/tools/freehand-base.h index d5c2fc9ba..266e22783 100644 --- a/src/ui/tools/freehand-base.h +++ b/src/ui/tools/freehand-base.h @@ -74,9 +74,11 @@ public: // Start anchor SPDrawAnchor *sa; + SPCurve * sc; // End anchor SPDrawAnchor *ea; + SPCurve * ec; /* type of the LPE that is to be applied automatically to a finished path (if any) */ Inkscape::LivePathEffect::EffectType waiting_LPE_type; diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 75dd6a32b..1701cf5d9 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -1516,8 +1516,8 @@ void PenTool::_bspline_spiro_start_anchor_on() if (this->sa->start) { tmpCurve = tmpCurve->create_reverse(); } - this->sa->curve->reset(); - this->sa->curve = tmpCurve; + this->sc->reset(); + this->sc = tmpCurve; } void PenTool::_bspline_spiro_start_anchor_off() @@ -1542,8 +1542,8 @@ void PenTool::_bspline_spiro_start_anchor_off() if (this->sa->start) { tmpCurve = tmpCurve->create_reverse(); } - this->sa->curve->reset(); - this->sa->curve = tmpCurve; + this->sc->reset(); + this->sc = tmpCurve; } } @@ -1677,8 +1677,8 @@ void PenTool::_bspline_spiro_end_anchor_on() if (!this->sa->start) { tmpCurve = tmpCurve->create_reverse(); } - this->sa->curve->reset(); - this->sa->curve = tmpCurve; + this->sc->reset(); + this->sc = tmpCurve; } } @@ -1726,8 +1726,8 @@ void PenTool::_bspline_spiro_end_anchor_off() if (!this->sa->start) { tmpCurve = tmpCurve->create_reverse(); } - this->sa->curve->reset(); - this->sa->curve = tmpCurve; + this->sc->reset(); + this->sc = tmpCurve; } } } @@ -1742,7 +1742,7 @@ void PenTool::_bspline_spiro_build() SPCurve *curve = new SPCurve(); //If we continuate the existing curve we add it at the start if(this->sa && !this->sa->curve->is_empty()){ - curve = this->sa->curve->copy(); + curve = this->sc->copy(); if (this->sa->start) { curve = curve->create_reverse(); } -- cgit v1.2.3 From 9c0d852d84da8af9cbb07ee2ed0488390225f126 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 20 Mar 2014 03:27:13 +0100 Subject: Full refactor of path continuations in bspline-spirolive mode, I think no more suv mac crashes, but need to be full tested again because a lot of things changed. (bzr r11950.1.308) --- src/ui/tools/freehand-base.cpp | 37 +++++++++++++++---------------------- src/ui/tools/freehand-base.h | 4 ++-- src/ui/tools/pen-tool.cpp | 5 ++--- src/ui/tools/pencil-tool.cpp | 3 +++ 4 files changed, 22 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 5897ce0ee..cecf0c0ca 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -92,7 +92,9 @@ FreehandBase::FreehandBase(gchar const *const *cursor_shape, gint hot_x, gint ho , white_curves(NULL) , white_anchors(NULL) , sa(NULL) + , sc(NULL) , ea(NULL) + , ec(NULL) , waiting_LPE_type(Inkscape::LivePathEffect::INVALID_LPE) , red_curve_is_valid(false) , anchor_statusbar(false) @@ -153,6 +155,12 @@ void FreehandBase::setup() { this->green_anchor = NULL; this->green_closed = FALSE; + // Create start anchor alternative curve + this->sc = new SPCurve(); + + // Create end anchor alternative curve + this->ec = new SPCurve(); + this->attach = TRUE; spdc_attach_selection(this, this->selection); } @@ -524,6 +532,10 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) dc->sc->append_continuous(c, 0.0625); c->unref(); dc->sc->closepath_current(); + if(dc->sa){ + dc->white_curves = g_slist_remove(dc->white_curves, dc->sa->curve); + dc->white_curves = g_slist_append(dc->white_curves, dc->sc); + } }else{ dc->sa->curve->append_continuous(c, 0.0625); c->unref(); @@ -536,11 +548,11 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) // Step C - test start if (dc->sa) { SPCurve *s = dc->sa->curve; + dc->white_curves = g_slist_remove(dc->white_curves, s); if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ s = dc->sc; } - dc->white_curves = g_slist_remove(dc->white_curves, s); if (dc->sa->start) { s = reverse_then_unref(s); } @@ -549,11 +561,11 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) c = s; } else /* Step D - test end */ if (dc->ea) { SPCurve *e = dc->ea->curve; + dc->white_curves = g_slist_remove(dc->white_curves, e); if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ e = dc->ec; } - dc->white_curves = g_slist_remove(dc->white_curves, e); if (!dc->ea->start) { e = reverse_then_unref(e); } @@ -570,20 +582,9 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) static void spdc_flush_white(FreehandBase *dc, SPCurve *gc) { SPCurve *c; - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (dc->white_curves) { g_assert(dc->white_item); - if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || - prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ - if(dc->sa){ - dc->white_curves = g_slist_remove(dc->white_curves, dc->sa->curve); - dc->white_curves = g_slist_append(dc->white_curves, dc->sc); - } - if(dc->ea){ - dc->white_curves = g_slist_remove(dc->white_curves, dc->ea->curve); - dc->white_curves = g_slist_append(dc->white_curves, dc->ec); - } - } c = SPCurve::concat(dc->white_curves); g_slist_free(dc->white_curves); dc->white_curves = NULL; @@ -723,14 +724,6 @@ static void spdc_free_colors(FreehandBase *dc) dc->blue2_curve = dc->blue2_curve->unref(); } - if (dc->sc) { - dc->sc = dc->sc->unref(); - } - - if (dc->ec) { - dc->ec = dc->ec->unref(); - } - // Green while (dc->green_bpaths) { sp_canvas_item_destroy(SP_CANVAS_ITEM(dc->green_bpaths->data)); diff --git a/src/ui/tools/freehand-base.h b/src/ui/tools/freehand-base.h index 266e22783..c134c5352 100644 --- a/src/ui/tools/freehand-base.h +++ b/src/ui/tools/freehand-base.h @@ -74,11 +74,11 @@ public: // Start anchor SPDrawAnchor *sa; - SPCurve * sc; + SPCurve *sc; // End anchor SPDrawAnchor *ea; - SPCurve * ec; + SPCurve *ec; /* type of the LPE that is to be applied automatically to a finished path (if any) */ Inkscape::LivePathEffect::EffectType waiting_LPE_type; diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 1701cf5d9..3ef9b96af 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -1516,7 +1516,6 @@ void PenTool::_bspline_spiro_start_anchor_on() if (this->sa->start) { tmpCurve = tmpCurve->create_reverse(); } - this->sc->reset(); this->sc = tmpCurve; } @@ -1542,7 +1541,6 @@ void PenTool::_bspline_spiro_start_anchor_off() if (this->sa->start) { tmpCurve = tmpCurve->create_reverse(); } - this->sc->reset(); this->sc = tmpCurve; } @@ -1677,7 +1675,6 @@ void PenTool::_bspline_spiro_end_anchor_on() if (!this->sa->start) { tmpCurve = tmpCurve->create_reverse(); } - this->sc->reset(); this->sc = tmpCurve; } } @@ -2176,6 +2173,8 @@ void PenTool::_finish(gboolean const closed) { // cancelate line without a created segment this->red_curve->reset(); spdc_concat_colors_and_flush(this, closed); + this->sc = NULL; + this->ec = NULL; this->sa = NULL; this->ea = NULL; diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp index 1ccdee637..8fe01a852 100644 --- a/src/ui/tools/pencil-tool.cpp +++ b/src/ui/tools/pencil-tool.cpp @@ -203,6 +203,7 @@ gint PencilTool::_handleButtonPress(GdkEventButton const &bevent) { } if (anchor) { p = anchor->dp; + this->sc = anchor->curve; desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Continuing selected path")); } else { m.setup(desktop); @@ -380,6 +381,7 @@ gint PencilTool::_handleButtonRelease(GdkEventButton const &revent) { /* Finish segment now */ if (anchor) { p = anchor->dp; + this->ec = anchor->curve; } else { this->_endpointSnap(p, revent.state); } @@ -406,6 +408,7 @@ gint PencilTool::_handleButtonRelease(GdkEventButton const &revent) { /// \todo fixme: Clean up what follows (Lauris) if (anchor) { p = anchor->dp; + this->ec = anchor->curve; } else { Geom::Point p_end = p; this->_endpointSnap(p_end, revent.state); -- cgit v1.2.3 From 8dee559ebb54fa7e1ef995b71713c0685b333d60 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 20 Mar 2014 03:35:35 +0100 Subject: Removed persistent blue line (bzr r11950.1.309) --- src/ui/tools/freehand-base.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index cecf0c0ca..ac98be2cf 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -493,6 +493,10 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) dc->blue_curve->reset(); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(dc->blue_bpath), NULL); + // Blue2 + dc->blue2_curve->reset(); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(dc->blue2_bpath), NULL); + // Red if (dc->red_curve_is_valid) { c->append_continuous(dc->red_curve, 0.0625); -- cgit v1.2.3 From 1ee8c21b5cfe9efa827eed7ab5e31fe28a9b4ae1 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 20 Mar 2014 03:39:27 +0100 Subject: Fixed bug continuing cusp nodes (bzr r11950.1.310) --- src/ui/tools/pen-tool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 3ef9b96af..cea8e67e6 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -1563,7 +1563,7 @@ void PenTool::_bspline_spiro_motion(bool shift){ }else if(!this->green_curve->is_empty()){ tmpCurve = this->green_curve->copy(); }else{ - tmpCurve = this->sa->curve->copy(); + tmpCurve = this->sc->copy(); if(this->sa->start) tmpCurve = tmpCurve->create_reverse(); } -- cgit v1.2.3 From f7943d80067732ec4a0565077b26b32562a150d3 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 27 Mar 2014 01:31:58 +0100 Subject: Adding cout << output to check bug in Geom::are_near (bzr r11950.1.314) --- src/live_effects/lpe-bspline.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index c19eda8f0..df98f0897 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -39,6 +39,7 @@ #include "inkscape.h" #include "desktop.h" +#include using Inkscape::DocumentUndo; @@ -347,14 +348,24 @@ LPEBSpline::changeWeight(double weightValue) bool LPEBSpline::nodeIsSelected(Geom::Point nodePoint){ + using Geom::X; + using Geom::Y; + std::cout << "\n"; + std::cout << ":: Executed -> nodeIsSelected(Geom::Point nodePoint) ::\n"; + std::cout << "Want to check the argument -nodePoint- is in points vector \n"; + std::cout << "nodePoint::X=" << nodePoint[X] << ";Y=" << nodePoint[Y] << "\n"; + std::cout << "Checking points std::vector\n"; if(points.size() > 0){ - for(std::vector::iterator i = points.begin(); i != points.end();){ - Geom::Point p = static_cast(*i); + for(std::vector::iterator i = points.begin(); i != points.end(); ++i){ + Geom::Point p = *i; + std::cout << "p::X=" << p[X] << ";Y=" << p[Y] << "\n"; + std::cout << "Are near? "; if(Geom::are_near(p, nodePoint)){ + std::cout << "YES\n"; return true; - points.erase(i); + }else{ + std::cout << "NO\n"; } - i++; } } return false; @@ -367,17 +378,21 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) using Geom::Y; SPDesktop *desktop = inkscape_active_desktop(); if(INK_IS_NODE_TOOL(desktop->event_context)){ + std::cout << ":: Start -> doBSplineFromWidget(SPCurve * curve, double weightValue) ::\n"; + std::cout << "Inserting nodes selected into std::vector 'points'\n"; Inkscape::UI::Tools::NodeTool *nt = INK_NODE_TOOL(desktop->event_context); Inkscape::UI::ControlPointSelection::Set &selection = nt->_selected_nodes->allPoints(); points.clear(); std::vector::iterator pbegin; for (Inkscape::UI::ControlPointSelection::Set::iterator i = selection.begin(); i != selection.end(); ++i){ if ((*i)->selected()) { - Inkscape::UI::Node *n = static_cast(*i); + Inkscape::UI::Node *n = dynamic_cast(*i); pbegin = points.begin(); points.insert(pbegin,desktop->doc2dt(n->position())); + std::cout << "inserting point::X=" << desktop->doc2dt(n->position())[X] << ";Y=" << desktop->doc2dt(n->position())[Y] << "\n"; } } + std::cout << "End inserting selected nodes into vector\n"; } //bool hasNodesSelected = LPEBspline::hasNodesSelected(); if(curve->get_segment_count() < 2) @@ -629,6 +644,7 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) curve->append(nCurve,false); nCurve->reset(); delete nCurve; + std::cout << ":: End ::\n"; } } -- cgit v1.2.3 From 9d5889926c9752867b244e9247843dd012cefdda Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 30 Mar 2014 23:53:17 +0200 Subject: clang-format bspline lpe files (bzr r11950.1.316) --- src/live_effects/lpe-bspline.cpp | 1182 ++++++++++++++++++++------------------ src/live_effects/lpe-bspline.h | 39 +- 2 files changed, 636 insertions(+), 585 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index df98f0897..09e71d833 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -2,7 +2,7 @@ /* * Released under GNU GPL, read the file 'COPYING' for more information */ - + #include #include #include @@ -46,606 +46,658 @@ using Inkscape::DocumentUndo; namespace Inkscape { namespace LivePathEffect { - - -LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) : - Effect(lpeobject), - // initialise your parameters here: - //testpointA(_("Test Point A"), _("Test A"), "ptA", &wr, this, Geom::Point(100,100)), - steps(_("Steps whith CTRL:"), _("Change number of steps whith CTRL pressed"), "steps", &wr, this, 2), - ignoreCusp(_("Ignore cusp nodes:"), _("Change ignoring cusp nodes"), "ignoreCusp", &wr, this, true), - onlySelected(_("Change only selected nodes:"), _("Change only selected nodes"), "onlySelected", &wr, this, false), - weight(_("Change weight:"), _("Change weight of the effect"), "weight", &wr, this, 0.3334) -{ - registerParameter( dynamic_cast(&ignoreCusp) ); - registerParameter( dynamic_cast(&onlySelected) ); - registerParameter( dynamic_cast(&weight) ); - registerParameter( dynamic_cast(&steps) ); - weight.param_set_range(0.0000, 1); - weight.param_set_increments(0.1, 0.1); - weight.param_set_digits(4); - steps.param_set_range(1, 10); - steps.param_set_increments(1, 1); - steps.param_set_digits(0); +LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) + : Effect(lpeobject), + // initialise your parameters here: + //testpointA(_("Test Point A"), _("Test A"), "ptA", &wr, this, + //Geom::Point(100,100)), + steps(_("Steps whith CTRL:"), + _("Change number of steps whith CTRL pressed"), "steps", &wr, this, + 2), + ignoreCusp(_("Ignore cusp nodes:"), _("Change ignoring cusp nodes"), + "ignoreCusp", &wr, this, true), + onlySelected(_("Change only selected nodes:"), + _("Change only selected nodes"), "onlySelected", &wr, this, + false), + weight(_("Change weight:"), _("Change weight of the effect"), "weight", + &wr, this, 0.3334) { + registerParameter(dynamic_cast(&ignoreCusp)); + registerParameter(dynamic_cast(&onlySelected)); + registerParameter(dynamic_cast(&weight)); + registerParameter(dynamic_cast(&steps)); + weight.param_set_range(0.0000, 1); + weight.param_set_increments(0.1, 0.1); + weight.param_set_digits(4); + steps.param_set_range(1, 10); + steps.param_set_increments(1, 1); + steps.param_set_digits(0); } -LPEBSpline::~LPEBSpline() -{ -} +LPEBSpline::~LPEBSpline() {} -void -LPEBSpline::createAndApply(const char* name, SPDocument *doc, SPItem *item) -{ - if (!SP_IS_SHAPE(item)) { - g_warning("LPE BSpline can only be applied to shapes (not groups)."); - }else{ - // Path effect definition - Inkscape::XML::Document *xml_doc = doc->getReprDoc(); - Inkscape::XML::Node *repr = xml_doc->createElement("inkscape:path-effect"); - repr->setAttribute("effect", name); +void LPEBSpline::createAndApply(const char *name, SPDocument *doc, + SPItem *item) { + if (!SP_IS_SHAPE(item)) { + g_warning("LPE BSpline can only be applied to shapes (not groups)."); + } else { + // Path effect definition + Inkscape::XML::Document *xml_doc = doc->getReprDoc(); + Inkscape::XML::Node *repr = xml_doc->createElement("inkscape:path-effect"); + repr->setAttribute("effect", name); - doc->getDefs()->getRepr()->addChild(repr, NULL); // adds to and assigns the 'id' attribute - const gchar * repr_id = repr->attribute("id"); - Inkscape::GC::release(repr); + doc->getDefs()->getRepr() + ->addChild(repr, NULL); // adds to and assigns the 'id' attribute + const gchar *repr_id = repr->attribute("id"); + Inkscape::GC::release(repr); - gchar *href = g_strdup_printf("#%s", repr_id); - SP_LPE_ITEM(item)->addPathEffect( href, true); - g_free(href); - } + gchar *href = g_strdup_printf("#%s", repr_id); + SP_LPE_ITEM(item)->addPathEffect(href, true); + g_free(href); + } } -void -LPEBSpline::doEffect(SPCurve * curve) -{ - if(curve->get_segment_count() < 2) - return; - // Make copy of old path as it is changed during processing - Geom::PathVector const original_pathv = curve->get_pathvector(); - curve->reset(); +void LPEBSpline::doEffect(SPCurve *curve) { + if (curve->get_segment_count() < 2) + return; + // Make copy of old path as it is changed during processing + Geom::PathVector const original_pathv = curve->get_pathvector(); + curve->reset(); - //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo - for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { - //Si está vacío... - if (path_it->empty()) - continue; - //Itreadores - - Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve - Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve - Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop - //Creamos las lineas rectas que unen todos los puntos del trazado y donde se calcularán - //los puntos clave para los manejadores. - //Esto hace que la curva BSpline no pierda su condición aunque se trasladen - //dichos manejadores - SPCurve *nCurve = new SPCurve(); - Geom::Point previousNode(0,0); - Geom::Point node(0,0); - Geom::Point pointAt1(0,0); - Geom::Point pointAt2(0,0); - Geom::Point nextPointAt1(0,0); - Geom::Point nextPointAt2(0,0); - Geom::Point nextPointAt3(0,0); - Geom::D2< Geom::SBasis > SBasisIn; - Geom::D2< Geom::SBasis > SBasisOut; - Geom::D2< Geom::SBasis > SBasisHelper; - Geom::CubicBezier const *cubic = NULL; - if (path_it->closed()) { - // if the path is closed, maybe we have to stop a bit earlier because the closing line segment has zerolength. - const Geom::Curve &closingline = path_it->back_closed(); // the closing line segment is always of type Geom::LineSegment. - if (are_near(closingline.initialPoint(), closingline.finalPoint())) { - // closingline.isDegenerate() did not work, because it only checks for *exact* zero length, which goes wrong for relative coordinates and rounding errors... - // the closing line segment has zero-length. So stop before that one! - curve_endit = path_it->end_open(); - } - } - //Si la curva está cerrada calculamos el punto donde - //deveria estar el nodo BSpline de cierre/inicio de la curva - //en posible caso de que se cierre con una linea recta creando un nodo BSPline - nCurve->moveto(curve_it1->initialPoint()); - //Recorremos todos los segmentos menos el último - while ( curve_it2 != curve_endit ) - { - //previousPointAt3 = pointAt3; - //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida - SPCurve * in = new SPCurve(); - in->moveto(curve_it1->initialPoint()); - in->lineto(curve_it1->finalPoint()); - cubic = dynamic_cast(&*curve_it1); - if(cubic){ - SBasisIn = in->first_segment()->toSBasis(); - pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[1],*in->first_segment())); - pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[2],*in->first_segment())); - }else{ - pointAt1 = in->first_segment()->initialPoint(); - pointAt2 = in->first_segment()->finalPoint(); - } - in->reset(); - delete in; - //Y hacemos lo propio con el path de salida - //nextPointAt0 = curveOut.valueAt(0); - SPCurve * out = new SPCurve(); - out->moveto(curve_it2->initialPoint()); - out->lineto(curve_it2->finalPoint()); - cubic = dynamic_cast(&*curve_it2); - if(cubic){ - SBasisOut = out->first_segment()->toSBasis(); - nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[1],*out->first_segment())); - nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[2],*out->first_segment()));; - nextPointAt3 = out->first_segment()->finalPoint(); - }else{ - nextPointAt1 = out->first_segment()->initialPoint(); - nextPointAt2 = out->first_segment()->finalPoint(); - nextPointAt3 = out->first_segment()->finalPoint(); - } - out->reset(); - delete out; - //La curva BSpline se forma calculando el centro del segmanto de unión - //de el punto situado en las 2/3 partes de el segmento de entrada - //con el punto situado en la posición 1/3 del segmento de salida - //Estos dos puntos ademas estan posicionados en el lugas correspondiente de - //los manejadores de la curva - SPCurve *lineHelper = new SPCurve(); - lineHelper->moveto(pointAt2); - lineHelper->lineto(nextPointAt1); - SBasisHelper = lineHelper->first_segment()->toSBasis(); - lineHelper->reset(); - delete lineHelper; - //almacenamos el punto del anterior bucle -o el de cierre- que nos hara de principio de curva - previousNode = node; - //Y este hará de final de curva - node = SBasisHelper.valueAt(0.5); - nCurve->curveto(pointAt1, pointAt2, node); - //aumentamos los valores para el siguiente paso en el bucle - ++curve_it1; - ++curve_it2; - } - //Si está cerrada la curva, la cerramos sobre el valor guardado previamente - //Si no finalizamos en el punto final - Geom::Point startNode(0,0); - if (path_it->closed()) { - SPCurve * start = new SPCurve(); - start->moveto(path_it->begin()->initialPoint()); - start->lineto(path_it->begin()->finalPoint()); - Geom::D2< Geom::SBasis > SBasisStart = start->first_segment()->toSBasis(); - SPCurve *lineHelper = new SPCurve(); - cubic = dynamic_cast(&*path_it->begin()); - if(cubic){ - lineHelper->moveto(SBasisStart.valueAt(Geom::nearest_point((*cubic)[1],*start->first_segment()))); - }else{ - lineHelper->moveto(start->first_segment()->initialPoint()); - } - start->reset(); - delete start; + //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el + //penúltimo + for (Geom::PathVector::const_iterator path_it = original_pathv.begin(); + path_it != original_pathv.end(); ++path_it) { + //Si está vacío... + if (path_it->empty()) + continue; + //Itreadores - SPCurve * end = new SPCurve(); - end->moveto(curve_it1->initialPoint()); - end->lineto(curve_it1->finalPoint()); - Geom::D2< Geom::SBasis > SBasisEnd = end->first_segment()->toSBasis(); - //Geom::BezierCurve const *bezier = dynamic_cast(&*curve_endit); - cubic = dynamic_cast(&*curve_it1); - if(cubic){ - lineHelper->lineto(SBasisEnd.valueAt(Geom::nearest_point((*cubic)[2],*end->first_segment()))); - }else{ - lineHelper->lineto(end->first_segment()->finalPoint()); - } - end->reset(); - delete end; - SBasisHelper = lineHelper->first_segment()->toSBasis(); - lineHelper->reset(); - delete lineHelper; - startNode = SBasisHelper.valueAt(0.5); - nCurve->curveto(nextPointAt1, nextPointAt2, startNode); - nCurve->move_endpoints(startNode,startNode); - }else{ - SPCurve * start = new SPCurve(); - start->moveto(path_it->begin()->initialPoint()); - start->lineto(path_it->begin()->finalPoint()); - startNode = start->first_segment()->initialPoint(); - start->reset(); - delete start; - nCurve->curveto(nextPointAt1, nextPointAt2, nextPointAt3); - nCurve->move_endpoints(startNode,nextPointAt3); - } - //y cerramos la curva - if (path_it->closed()) { - nCurve->closepath_current(); - } - curve->append(nCurve,false); - nCurve->reset(); - delete nCurve; + Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve + Geom::Path::const_iterator curve_it2 = + ++(path_it->begin()); // outgoing curve + Geom::Path::const_iterator curve_endit = + path_it->end_default(); // this determines when the loop has to stop + //Creamos las lineas rectas que unen todos los puntos del trazado y donde se + //calcularán + //los puntos clave para los manejadores. + //Esto hace que la curva BSpline no pierda su condición aunque se trasladen + //dichos manejadores + SPCurve *nCurve = new SPCurve(); + Geom::Point previousNode(0, 0); + Geom::Point node(0, 0); + Geom::Point pointAt1(0, 0); + Geom::Point pointAt2(0, 0); + Geom::Point nextPointAt1(0, 0); + Geom::Point nextPointAt2(0, 0); + Geom::Point nextPointAt3(0, 0); + Geom::D2 SBasisIn; + Geom::D2 SBasisOut; + Geom::D2 SBasisHelper; + Geom::CubicBezier const *cubic = NULL; + if (path_it->closed()) { + // if the path is closed, maybe we have to stop a bit earlier because the + // closing line segment has zerolength. + const Geom::Curve &closingline = + path_it->back_closed(); // the closing line segment is always of type + // Geom::LineSegment. + if (are_near(closingline.initialPoint(), closingline.finalPoint())) { + // closingline.isDegenerate() did not work, because it only checks for + // *exact* zero length, which goes wrong for relative coordinates and + // rounding errors... + // the closing line segment has zero-length. So stop before that one! + curve_endit = path_it->end_open(); + } + } + //Si la curva está cerrada calculamos el punto donde + //deveria estar el nodo BSpline de cierre/inicio de la curva + //en posible caso de que se cierre con una linea recta creando un nodo + //BSPline + nCurve->moveto(curve_it1->initialPoint()); + //Recorremos todos los segmentos menos el último + while (curve_it2 != curve_endit) { + //previousPointAt3 = pointAt3; + //Calculamos los puntos que dividirían en tres segmentos iguales el path + //recto de entrada y de salida + SPCurve *in = new SPCurve(); + in->moveto(curve_it1->initialPoint()); + in->lineto(curve_it1->finalPoint()); + cubic = dynamic_cast(&*curve_it1); + if (cubic) { + SBasisIn = in->first_segment()->toSBasis(); + pointAt1 = SBasisIn.valueAt( + Geom::nearest_point((*cubic)[1], *in->first_segment())); + pointAt2 = SBasisIn.valueAt( + Geom::nearest_point((*cubic)[2], *in->first_segment())); + } else { + pointAt1 = in->first_segment()->initialPoint(); + pointAt2 = in->first_segment()->finalPoint(); + } + in->reset(); + delete in; + //Y hacemos lo propio con el path de salida + //nextPointAt0 = curveOut.valueAt(0); + SPCurve *out = new SPCurve(); + out->moveto(curve_it2->initialPoint()); + out->lineto(curve_it2->finalPoint()); + cubic = dynamic_cast(&*curve_it2); + if (cubic) { + SBasisOut = out->first_segment()->toSBasis(); + nextPointAt1 = SBasisOut.valueAt( + Geom::nearest_point((*cubic)[1], *out->first_segment())); + nextPointAt2 = SBasisOut.valueAt( + Geom::nearest_point((*cubic)[2], *out->first_segment())); + ; + nextPointAt3 = out->first_segment()->finalPoint(); + } else { + nextPointAt1 = out->first_segment()->initialPoint(); + nextPointAt2 = out->first_segment()->finalPoint(); + nextPointAt3 = out->first_segment()->finalPoint(); + } + out->reset(); + delete out; + //La curva BSpline se forma calculando el centro del segmanto de unión + //de el punto situado en las 2/3 partes de el segmento de entrada + //con el punto situado en la posición 1/3 del segmento de salida + //Estos dos puntos ademas estan posicionados en el lugas correspondiente + //de + //los manejadores de la curva + SPCurve *lineHelper = new SPCurve(); + lineHelper->moveto(pointAt2); + lineHelper->lineto(nextPointAt1); + SBasisHelper = lineHelper->first_segment()->toSBasis(); + lineHelper->reset(); + delete lineHelper; + //almacenamos el punto del anterior bucle -o el de cierre- que nos hara de + //principio de curva + previousNode = node; + //Y este hará de final de curva + node = SBasisHelper.valueAt(0.5); + nCurve->curveto(pointAt1, pointAt2, node); + //aumentamos los valores para el siguiente paso en el bucle + ++curve_it1; + ++curve_it2; + } + //Si está cerrada la curva, la cerramos sobre el valor guardado + //previamente + //Si no finalizamos en el punto final + Geom::Point startNode(0, 0); + if (path_it->closed()) { + SPCurve *start = new SPCurve(); + start->moveto(path_it->begin()->initialPoint()); + start->lineto(path_it->begin()->finalPoint()); + Geom::D2 SBasisStart = start->first_segment()->toSBasis(); + SPCurve *lineHelper = new SPCurve(); + cubic = dynamic_cast(&*path_it->begin()); + if (cubic) { + lineHelper->moveto(SBasisStart.valueAt( + Geom::nearest_point((*cubic)[1], *start->first_segment()))); + } else { + lineHelper->moveto(start->first_segment()->initialPoint()); + } + start->reset(); + delete start; + + SPCurve *end = new SPCurve(); + end->moveto(curve_it1->initialPoint()); + end->lineto(curve_it1->finalPoint()); + Geom::D2 SBasisEnd = end->first_segment()->toSBasis(); + //Geom::BezierCurve const *bezier = dynamic_cast(&*curve_endit); + cubic = dynamic_cast(&*curve_it1); + if (cubic) { + lineHelper->lineto(SBasisEnd.valueAt( + Geom::nearest_point((*cubic)[2], *end->first_segment()))); + } else { + lineHelper->lineto(end->first_segment()->finalPoint()); + } + end->reset(); + delete end; + SBasisHelper = lineHelper->first_segment()->toSBasis(); + lineHelper->reset(); + delete lineHelper; + startNode = SBasisHelper.valueAt(0.5); + nCurve->curveto(nextPointAt1, nextPointAt2, startNode); + nCurve->move_endpoints(startNode, startNode); + } else { + SPCurve *start = new SPCurve(); + start->moveto(path_it->begin()->initialPoint()); + start->lineto(path_it->begin()->finalPoint()); + startNode = start->first_segment()->initialPoint(); + start->reset(); + delete start; + nCurve->curveto(nextPointAt1, nextPointAt2, nextPointAt3); + nCurve->move_endpoints(startNode, nextPointAt3); } + //y cerramos la curva + if (path_it->closed()) { + nCurve->closepath_current(); + } + curve->append(nCurve, false); + nCurve->reset(); + delete nCurve; + } } -Gtk::Widget * -LPEBSpline::newWidget() -{ - // use manage here, because after deletion of Effect object, others might still be pointing to this widget. - Gtk::VBox * vbox = Gtk::manage( new Gtk::VBox(Effect::newWidget()) ); +Gtk::Widget *LPEBSpline::newWidget() { + // use manage here, because after deletion of Effect object, others might + // still be pointing to this widget. + Gtk::VBox *vbox = Gtk::manage(new Gtk::VBox(Effect::newWidget())); - vbox->set_border_width(5); - std::vector::iterator it = param_vector.begin(); - while (it != param_vector.end()) { - if ((*it)->widget_is_visible) { - Parameter * param = *it; - Gtk::Widget * widg = dynamic_cast(param->param_newWidget()); - if(param->param_key == "weight"||param->param_key == "steps"){ - Inkscape::UI::Widget::Scalar * widgRegistered = Gtk::manage(dynamic_cast(widg)); - widgRegistered->signal_value_changed().connect(sigc::mem_fun (*this,&LPEBSpline::toWeight)); - widg = dynamic_cast(widgRegistered); - } - if(param->param_key == "onlySelected"){ - Gtk::CheckButton * widgRegistered = Gtk::manage(dynamic_cast(widg)); - widg = dynamic_cast(widgRegistered); - } - if(param->param_key == "ignoreCusp"){ - Gtk::CheckButton * widgRegistered = Gtk::manage(dynamic_cast(widg)); - widg = dynamic_cast(widgRegistered); - } - Glib::ustring * tip = param->param_getTooltip(); - if (widg) { - vbox->pack_start(*widg, true, true, 2); - if (tip) { - widg->set_tooltip_text(*tip); - } else { - widg->set_tooltip_text(""); - widg->set_has_tooltip(false); - } - } + vbox->set_border_width(5); + std::vector::iterator it = param_vector.begin(); + while (it != param_vector.end()) { + if ((*it)->widget_is_visible) { + Parameter *param = *it; + Gtk::Widget *widg = dynamic_cast(param->param_newWidget()); + if (param->param_key == "weight" || param->param_key == "steps") { + Inkscape::UI::Widget::Scalar *widgRegistered = + Gtk::manage(dynamic_cast(widg)); + widgRegistered->signal_value_changed() + .connect(sigc::mem_fun(*this, &LPEBSpline::toWeight)); + widg = dynamic_cast(widgRegistered); + } + if (param->param_key == "onlySelected") { + Gtk::CheckButton *widgRegistered = + Gtk::manage(dynamic_cast(widg)); + widg = dynamic_cast(widgRegistered); + } + if (param->param_key == "ignoreCusp") { + Gtk::CheckButton *widgRegistered = + Gtk::manage(dynamic_cast(widg)); + widg = dynamic_cast(widgRegistered); + } + Glib::ustring *tip = param->param_getTooltip(); + if (widg) { + vbox->pack_start(*widg, true, true, 2); + if (tip) { + widg->set_tooltip_text(*tip); + } else { + widg->set_tooltip_text(""); + widg->set_has_tooltip(false); } - - ++it; + } } - Gtk::Button* defaultWeight = Gtk::manage(new Gtk::Button(Glib::ustring(_("Default weight 0.3334")))); - defaultWeight->set_alignment(0.0, 0.5); - defaultWeight->signal_clicked().connect(sigc::mem_fun (*this,&LPEBSpline::toDefaultWeight)); - Gtk::Widget* defaultWeightWidget = dynamic_cast(defaultWeight); - vbox->pack_start(*defaultWeightWidget, true, true,2); - Gtk::Button* makeCusp = Gtk::manage(new Gtk::Button(Glib::ustring(_("Make cusp")))); - makeCusp->set_alignment(0.0, 0.5); - makeCusp->signal_clicked().connect(sigc::mem_fun (*this,&LPEBSpline::toMakeCusp)); - Gtk::Widget* makeCuspWidget = dynamic_cast(makeCusp); - vbox->pack_start(*makeCuspWidget, true, true,2); - return dynamic_cast(vbox); -} -void -LPEBSpline::toDefaultWeight(){ - changeWeight(0.3334); + ++it; + } + Gtk::Button *defaultWeight = + Gtk::manage(new Gtk::Button(Glib::ustring(_("Default weight 0.3334")))); + defaultWeight->set_alignment(0.0, 0.5); + defaultWeight->signal_clicked() + .connect(sigc::mem_fun(*this, &LPEBSpline::toDefaultWeight)); + Gtk::Widget *defaultWeightWidget = dynamic_cast(defaultWeight); + vbox->pack_start(*defaultWeightWidget, true, true, 2); + Gtk::Button *makeCusp = + Gtk::manage(new Gtk::Button(Glib::ustring(_("Make cusp")))); + makeCusp->set_alignment(0.0, 0.5); + makeCusp->signal_clicked() + .connect(sigc::mem_fun(*this, &LPEBSpline::toMakeCusp)); + Gtk::Widget *makeCuspWidget = dynamic_cast(makeCusp); + vbox->pack_start(*makeCuspWidget, true, true, 2); + return dynamic_cast(vbox); } -void -LPEBSpline::toMakeCusp(){ - changeWeight(0.0000); -} +void LPEBSpline::toDefaultWeight() { changeWeight(0.3334); } -void -LPEBSpline::toWeight(){ - changeWeight(weight); -} +void LPEBSpline::toMakeCusp() { changeWeight(0.0000); } -void -LPEBSpline::changeWeight(double weightValue) -{ - SPDesktop *desktop = inkscape_active_desktop(); - Inkscape::Selection *selection = sp_desktop_selection(desktop); - GSList *items = (GSList *) selection->itemList(); - SPItem *item = (SPItem *)g_slist_nth(items,0)->data; - SPPath *path = SP_PATH(item); - SPCurve *curve = path->get_curve_for_edit(); - LPEBSpline::doBSplineFromWidget(curve,weightValue); - gchar *str = sp_svg_write_path(curve->get_pathvector()); - path->getRepr()->setAttribute("inkscape:original-d", str); - if(INK_IS_NODE_TOOL(desktop->event_context)){ - Inkscape::UI::Tools::NodeTool *nt = INK_NODE_TOOL(desktop->event_context); - nt->desktop->updateNow(); - } - g_free(str); - curve->unref(); - desktop->clearWaitingCursor(); - DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_LPE, - _("Modified the weight of the BSpline")); +void LPEBSpline::toWeight() { changeWeight(weight); } + +void LPEBSpline::changeWeight(double weightValue) { + SPDesktop *desktop = inkscape_active_desktop(); + Inkscape::Selection *selection = sp_desktop_selection(desktop); + GSList *items = (GSList *)selection->itemList(); + SPItem *item = (SPItem *)g_slist_nth(items, 0)->data; + SPPath *path = SP_PATH(item); + SPCurve *curve = path->get_curve_for_edit(); + LPEBSpline::doBSplineFromWidget(curve, weightValue); + gchar *str = sp_svg_write_path(curve->get_pathvector()); + path->getRepr()->setAttribute("inkscape:original-d", str); + if (INK_IS_NODE_TOOL(desktop->event_context)) { + Inkscape::UI::Tools::NodeTool *nt = INK_NODE_TOOL(desktop->event_context); + nt->desktop->updateNow(); + } + g_free(str); + curve->unref(); + desktop->clearWaitingCursor(); + DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_LPE, + _("Modified the weight of the BSpline")); } -bool -LPEBSpline::nodeIsSelected(Geom::Point nodePoint){ - using Geom::X; - using Geom::Y; - std::cout << "\n"; - std::cout << ":: Executed -> nodeIsSelected(Geom::Point nodePoint) ::\n"; - std::cout << "Want to check the argument -nodePoint- is in points vector \n"; - std::cout << "nodePoint::X=" << nodePoint[X] << ";Y=" << nodePoint[Y] << "\n"; - std::cout << "Checking points std::vector\n"; - if(points.size() > 0){ - for(std::vector::iterator i = points.begin(); i != points.end(); ++i){ - Geom::Point p = *i; - std::cout << "p::X=" << p[X] << ";Y=" << p[Y] << "\n"; - std::cout << "Are near? "; - if(Geom::are_near(p, nodePoint)){ - std::cout << "YES\n"; - return true; - }else{ - std::cout << "NO\n"; - } - } +bool LPEBSpline::nodeIsSelected(Geom::Point nodePoint) { + using Geom::X; + using Geom::Y; + std::cout << "\n"; + std::cout << ":: Executed -> nodeIsSelected(Geom::Point nodePoint) ::\n"; + std::cout << "Want to check the argument -nodePoint- is in points vector \n"; + std::cout << "nodePoint::X=" << nodePoint[X] << ";Y=" << nodePoint[Y] << "\n"; + std::cout << "Checking points std::vector\n"; + if (points.size() > 0) { + for (std::vector::iterator i = points.begin(); + i != points.end(); ++i) { + Geom::Point p = *i; + std::cout << "p::X=" << p[X] << ";Y=" << p[Y] << "\n"; + std::cout << "Are near? "; + if (Geom::are_near(p, nodePoint)) { + std::cout << "YES\n"; + return true; + } else { + std::cout << "NO\n"; + } } - return false; + } + return false; } -void -LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) -{ - using Geom::X; - using Geom::Y; - SPDesktop *desktop = inkscape_active_desktop(); - if(INK_IS_NODE_TOOL(desktop->event_context)){ - std::cout << ":: Start -> doBSplineFromWidget(SPCurve * curve, double weightValue) ::\n"; - std::cout << "Inserting nodes selected into std::vector 'points'\n"; - Inkscape::UI::Tools::NodeTool *nt = INK_NODE_TOOL(desktop->event_context); - Inkscape::UI::ControlPointSelection::Set &selection = nt->_selected_nodes->allPoints(); - points.clear(); - std::vector::iterator pbegin; - for (Inkscape::UI::ControlPointSelection::Set::iterator i = selection.begin(); i != selection.end(); ++i){ - if ((*i)->selected()) { - Inkscape::UI::Node *n = dynamic_cast(*i); - pbegin = points.begin(); - points.insert(pbegin,desktop->doc2dt(n->position())); - std::cout << "inserting point::X=" << desktop->doc2dt(n->position())[X] << ";Y=" << desktop->doc2dt(n->position())[Y] << "\n"; - } - } - std::cout << "End inserting selected nodes into vector\n"; +void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weightValue) { + using Geom::X; + using Geom::Y; + SPDesktop *desktop = inkscape_active_desktop(); + if (INK_IS_NODE_TOOL(desktop->event_context)) { + std::cout << ":: Start -> doBSplineFromWidget(SPCurve * curve, double " + "weightValue) ::\n"; + std::cout << "Inserting nodes selected into std::vector 'points'\n"; + Inkscape::UI::Tools::NodeTool *nt = INK_NODE_TOOL(desktop->event_context); + Inkscape::UI::ControlPointSelection::Set &selection = + nt->_selected_nodes->allPoints(); + points.clear(); + std::vector::iterator pbegin; + for (Inkscape::UI::ControlPointSelection::Set::iterator i = + selection.begin(); + i != selection.end(); ++i) { + if ((*i)->selected()) { + Inkscape::UI::Node *n = dynamic_cast(*i); + pbegin = points.begin(); + points.insert(pbegin, desktop->doc2dt(n->position())); + std::cout << "inserting point::X=" << desktop->doc2dt(n->position())[X] + << ";Y=" << desktop->doc2dt(n->position())[Y] << "\n"; + } } - //bool hasNodesSelected = LPEBspline::hasNodesSelected(); - if(curve->get_segment_count() < 2) - return; - // Make copy of old path as it is changed during processing - Geom::PathVector const original_pathv = curve->get_pathvector(); - curve->reset(); + std::cout << "End inserting selected nodes into vector\n"; + } + //bool hasNodesSelected = LPEBspline::hasNodesSelected(); + if (curve->get_segment_count() < 2) + return; + // Make copy of old path as it is changed during processing + Geom::PathVector const original_pathv = curve->get_pathvector(); + curve->reset(); + + //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el + //penúltimo + for (Geom::PathVector::const_iterator path_it = original_pathv.begin(); + path_it != original_pathv.end(); ++path_it) { + //Si está vacío... + if (path_it->empty()) + continue; + //Itreadores - //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo - for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { - //Si está vacío... - if (path_it->empty()) - continue; - //Itreadores - - Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve - Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve - Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop - //Creamos las lineas rectas que unen todos los puntos del trazado y donde se calcularán - //los puntos clave para los manejadores. - //Esto hace que la curva BSpline no pierda su condición aunque se trasladen - //dichos manejadores - SPCurve *nCurve = new SPCurve(); - Geom::Point pointAt0(0,0); - Geom::Point pointAt1(0,0); - Geom::Point pointAt2(0,0); - Geom::Point pointAt3(0,0); - Geom::Point nextPointAt0(0,0); - Geom::Point nextPointAt1(0,0); - Geom::Point nextPointAt2(0,0); - Geom::Point nextPointAt3(0,0); - Geom::D2< Geom::SBasis > SBasisIn; - Geom::D2< Geom::SBasis > SBasisOut; - Geom::CubicBezier const *cubic = NULL; - if (path_it->closed()) { - // if the path is closed, maybe we have to stop a bit earlier because the closing line segment has zerolength. - const Geom::Curve &closingline = path_it->back_closed(); // the closing line segment is always of type Geom::LineSegment. - if (are_near(closingline.initialPoint(), closingline.finalPoint())) { - // closingline.isDegenerate() did not work, because it only checks for *exact* zero length, which goes wrong for relative coordinates and rounding errors... - // the closing line segment has zero-length. So stop before that one! - curve_endit = path_it->end_open(); + Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve + Geom::Path::const_iterator curve_it2 = + ++(path_it->begin()); // outgoing curve + Geom::Path::const_iterator curve_endit = + path_it->end_default(); // this determines when the loop has to stop + //Creamos las lineas rectas que unen todos los puntos del trazado y donde se + //calcularán + //los puntos clave para los manejadores. + //Esto hace que la curva BSpline no pierda su condición aunque se trasladen + //dichos manejadores + SPCurve *nCurve = new SPCurve(); + Geom::Point pointAt0(0, 0); + Geom::Point pointAt1(0, 0); + Geom::Point pointAt2(0, 0); + Geom::Point pointAt3(0, 0); + Geom::Point nextPointAt0(0, 0); + Geom::Point nextPointAt1(0, 0); + Geom::Point nextPointAt2(0, 0); + Geom::Point nextPointAt3(0, 0); + Geom::D2 SBasisIn; + Geom::D2 SBasisOut; + Geom::CubicBezier const *cubic = NULL; + if (path_it->closed()) { + // if the path is closed, maybe we have to stop a bit earlier because the + // closing line segment has zerolength. + const Geom::Curve &closingline = + path_it->back_closed(); // the closing line segment is always of type + // Geom::LineSegment. + if (are_near(closingline.initialPoint(), closingline.finalPoint())) { + // closingline.isDegenerate() did not work, because it only checks for + // *exact* zero length, which goes wrong for relative coordinates and + // rounding errors... + // the closing line segment has zero-length. So stop before that one! + curve_endit = path_it->end_open(); + } + } + //Si la curva está cerrada calculamos el punto donde + //deveria estar el nodo BSpline de cierre/inicio de la curva + //en posible caso de que se cierre con una linea recta creando un nodo + //BSPline + nCurve->moveto(curve_it1->initialPoint()); + //Recorremos todos los segmentos menos el último + while (curve_it2 != curve_endit) { + //previousPointAt3 = pointAt3; + //Calculamos los puntos que dividirían en tres segmentos iguales el path + //recto de entrada y de salida + SPCurve *in = new SPCurve(); + in->moveto(curve_it1->initialPoint()); + in->lineto(curve_it1->finalPoint()); + cubic = dynamic_cast(&*curve_it1); + pointAt0 = in->first_segment()->initialPoint(); + pointAt3 = in->first_segment()->finalPoint(); + SBasisIn = in->first_segment()->toSBasis(); + if (!onlySelected) { + if (cubic) { + if (!ignoreCusp || !Geom::are_near((*cubic)[1], pointAt0)) { + pointAt1 = SBasisIn.valueAt(weightValue); + if (weightValue != 0.0000) { + pointAt1 = + Geom::Point(pointAt1[X] + 0.0001, pointAt1[Y] + 0.0001); + } + } else { + pointAt1 = in->first_segment()->initialPoint(); + } + if (!ignoreCusp || !Geom::are_near((*cubic)[2], pointAt3)) { + pointAt2 = SBasisIn.valueAt(1 - weightValue); + if (weightValue != 0.0000) { + pointAt2 = + Geom::Point(pointAt2[X] + 0.0001, pointAt2[Y] + 0.0001); + } + } else { + pointAt2 = in->first_segment()->finalPoint(); + } + } else { + if (!ignoreCusp && weightValue != 0.0000) { + pointAt1 = SBasisIn.valueAt(weightValue); + if (weightValue != 0.0000) { + pointAt1 = + Geom::Point(pointAt1[X] + 0.0001, pointAt1[Y] + 0.0001); + } + pointAt2 = SBasisIn.valueAt(1 - weightValue); + if (weightValue != 0.0000) { + pointAt2 = + Geom::Point(pointAt2[X] + 0.0001, pointAt2[Y] + 0.0001); } + } else { + pointAt1 = in->first_segment()->initialPoint(); + pointAt2 = in->first_segment()->finalPoint(); + } } - //Si la curva está cerrada calculamos el punto donde - //deveria estar el nodo BSpline de cierre/inicio de la curva - //en posible caso de que se cierre con una linea recta creando un nodo BSPline - nCurve->moveto(curve_it1->initialPoint()); - //Recorremos todos los segmentos menos el último - while ( curve_it2 != curve_endit ) - { - //previousPointAt3 = pointAt3; - //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida - SPCurve * in = new SPCurve(); - in->moveto(curve_it1->initialPoint()); - in->lineto(curve_it1->finalPoint()); - cubic = dynamic_cast(&*curve_it1); - pointAt0 = in->first_segment()->initialPoint(); - pointAt3 = in->first_segment()->finalPoint(); - SBasisIn = in->first_segment()->toSBasis(); - if(!onlySelected){ - if(cubic){ - if(!ignoreCusp || !Geom::are_near((*cubic)[1],pointAt0)){ - pointAt1 = SBasisIn.valueAt(weightValue); - if(weightValue !=0.0000){ - pointAt1 = Geom::Point(pointAt1[X] + 0.0001,pointAt1[Y] + 0.0001); - } - }else{ - pointAt1 = in->first_segment()->initialPoint(); - } - if(!ignoreCusp || !Geom::are_near((*cubic)[2],pointAt3)){ - pointAt2 = SBasisIn.valueAt(1-weightValue); - if(weightValue !=0.0000){ - pointAt2 = Geom::Point(pointAt2[X] + 0.0001,pointAt2[Y] + 0.0001); - } - }else{ - pointAt2 = in->first_segment()->finalPoint(); - } - }else{ - if(!ignoreCusp && weightValue !=0.0000){ - pointAt1 = SBasisIn.valueAt(weightValue); - if(weightValue !=0.0000){ - pointAt1 = Geom::Point(pointAt1[X] + 0.0001,pointAt1[Y] + 0.0001); - } - pointAt2 = SBasisIn.valueAt(1-weightValue); - if(weightValue !=0.0000){ - pointAt2 = Geom::Point(pointAt2[X] + 0.0001,pointAt2[Y] + 0.0001); - } - }else{ - pointAt1 = in->first_segment()->initialPoint(); - pointAt2 = in->first_segment()->finalPoint(); - } - } - }else{ - if(cubic){ - if(!ignoreCusp || !Geom::are_near((*cubic)[1],pointAt0)){ - if(nodeIsSelected(pointAt0)){ - pointAt1 = SBasisIn.valueAt(weightValue); - if(weightValue !=0.0000){ - pointAt1 = Geom::Point(pointAt1[X] + 0.0001,pointAt1[Y] + 0.0001); - } - }else{ - pointAt1 = (*cubic)[1]; - } - }else{ - pointAt1 = in->first_segment()->initialPoint(); - } - if(!ignoreCusp || !Geom::are_near((*cubic)[2],pointAt3)){ - if(nodeIsSelected(pointAt3)){ - pointAt2 = SBasisIn.valueAt(1-weightValue); - if(weightValue !=0.0000){ - pointAt2 = Geom::Point(pointAt2[X] + 0.0001,pointAt2[Y] + 0.0001); - } - }else{ - pointAt2 = (*cubic)[2]; - } - }else{ - pointAt2 = in->first_segment()->finalPoint(); - } - }else{ - if(!ignoreCusp && weightValue !=0.000){ - if(nodeIsSelected(pointAt0)){ - pointAt1 = SBasisIn.valueAt(weightValue); - pointAt1 = Geom::Point(pointAt1[X] + 0.0001,pointAt1[Y] + 0.0001); - }else{ - pointAt1 = in->first_segment()->initialPoint(); - } - if(nodeIsSelected(pointAt3)){ - pointAt2 = SBasisIn.valueAt(weightValue); - pointAt2 = Geom::Point(pointAt2[X] + 0.0001,pointAt2[Y] + 0.0001); - }else{ - pointAt2 = in->first_segment()->finalPoint(); - } - }else{ - pointAt1 = in->first_segment()->initialPoint(); - pointAt2 = in->first_segment()->finalPoint(); - } - } + } else { + if (cubic) { + if (!ignoreCusp || !Geom::are_near((*cubic)[1], pointAt0)) { + if (nodeIsSelected(pointAt0)) { + pointAt1 = SBasisIn.valueAt(weightValue); + if (weightValue != 0.0000) { + pointAt1 = + Geom::Point(pointAt1[X] + 0.0001, pointAt1[Y] + 0.0001); + } + } else { + pointAt1 = (*cubic)[1]; } - in->reset(); - delete in; - //La curva BSpline se forma calculando el centro del segmanto de unión - //de el punto situado en las 2/3 partes de el segmento de entrada - //con el punto situado en la posición 1/3 del segmento de salida - //Estos dos puntos ademas estan posicionados en el lugas correspondiente de - //los manejadores de la curva - nCurve->curveto(pointAt1, pointAt2, pointAt3); - //aumentamos los valores para el siguiente paso en el bucle - ++curve_it1; - ++curve_it2; + } else { + pointAt1 = in->first_segment()->initialPoint(); + } + if (!ignoreCusp || !Geom::are_near((*cubic)[2], pointAt3)) { + if (nodeIsSelected(pointAt3)) { + pointAt2 = SBasisIn.valueAt(1 - weightValue); + if (weightValue != 0.0000) { + pointAt2 = + Geom::Point(pointAt2[X] + 0.0001, pointAt2[Y] + 0.0001); + } + } else { + pointAt2 = (*cubic)[2]; + } + } else { + pointAt2 = in->first_segment()->finalPoint(); + } + } else { + if (!ignoreCusp && weightValue != 0.000) { + if (nodeIsSelected(pointAt0)) { + pointAt1 = SBasisIn.valueAt(weightValue); + pointAt1 = + Geom::Point(pointAt1[X] + 0.0001, pointAt1[Y] + 0.0001); + } else { + pointAt1 = in->first_segment()->initialPoint(); + } + if (nodeIsSelected(pointAt3)) { + pointAt2 = SBasisIn.valueAt(weightValue); + pointAt2 = + Geom::Point(pointAt2[X] + 0.0001, pointAt2[Y] + 0.0001); + } else { + pointAt2 = in->first_segment()->finalPoint(); + } + } else { + pointAt1 = in->first_segment()->initialPoint(); + pointAt2 = in->first_segment()->finalPoint(); + } } - SPCurve * out = new SPCurve(); - out->moveto(curve_it1->initialPoint()); - out->lineto(curve_it1->finalPoint()); - SBasisOut = out->first_segment()->toSBasis(); - nextPointAt0 = out->first_segment()->initialPoint(); - nextPointAt3 = out->first_segment()->finalPoint(); - cubic = dynamic_cast(&*curve_it1); - if(!onlySelected){ - if(cubic){ - if(!ignoreCusp || !Geom::are_near((*cubic)[1],nextPointAt0)){ - nextPointAt1 = SBasisOut.valueAt(weightValue); - if(weightValue !=0.0000){ - nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0001,nextPointAt1[Y] + 0.0001); - } - }else{ - nextPointAt1 = out->first_segment()->initialPoint(); - } - if(!ignoreCusp || !Geom::are_near((*cubic)[2],nextPointAt3)){ - nextPointAt2 = SBasisOut.valueAt(1-weightValue); - if(weightValue !=0.0000){ - nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0001,nextPointAt2[Y] + 0.0001); - } - }else{ - nextPointAt2 = out->first_segment()->finalPoint(); - } - }else{ - if(!ignoreCusp && weightValue !=0.0000){ - nextPointAt1 = SBasisOut.valueAt(weightValue); - nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0001,nextPointAt1[Y] + 0.0001); - nextPointAt2 = SBasisOut.valueAt(1-weightValue); - nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0001,nextPointAt2[Y] + 0.0001); - }else{ - nextPointAt1 = out->first_segment()->initialPoint(); - nextPointAt2 = out->first_segment()->finalPoint(); - } - } - }else{ - if(cubic){ - if(!ignoreCusp || !Geom::are_near((*cubic)[1],nextPointAt0)){ - if(nodeIsSelected(nextPointAt0)){ - nextPointAt1 = SBasisOut.valueAt(weightValue); - if(weightValue !=0.0000){ - nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0001,nextPointAt1[Y] + 0.0001); - } - }else{ - nextPointAt1 = (*cubic)[1]; - } - }else{ - nextPointAt1 = out->first_segment()->initialPoint(); - } - if(!ignoreCusp || !Geom::are_near((*cubic)[2],nextPointAt3)){ - if(nodeIsSelected(nextPointAt3)){ - nextPointAt2 = SBasisOut.valueAt(1-weightValue); - if(weightValue !=0.0000){ - nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0001,nextPointAt2[Y] + 0.0001); - } - }else{ - nextPointAt2 = (*cubic)[2]; - } - }else{ - nextPointAt2 = out->first_segment()->finalPoint(); - } - }else{ - if(!ignoreCusp && weightValue !=0.0000){ - if(nodeIsSelected(nextPointAt0)){ - nextPointAt1 = SBasisOut.valueAt(weightValue); - nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0001,nextPointAt1[Y] + 0.0001); - }else{ - nextPointAt1 = out->first_segment()->initialPoint(); - } - if(nodeIsSelected(nextPointAt3)){ - nextPointAt2 = SBasisOut.valueAt(weightValue); - nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0001,nextPointAt2[Y] + 0.0001); - }else{ - nextPointAt2 = out->first_segment()->finalPoint(); - } - }else{ - nextPointAt1 = out->first_segment()->initialPoint(); - nextPointAt2 = out->first_segment()->finalPoint(); - } + } + in->reset(); + delete in; + //La curva BSpline se forma calculando el centro del segmanto de unión + //de el punto situado en las 2/3 partes de el segmento de entrada + //con el punto situado en la posición 1/3 del segmento de salida + //Estos dos puntos ademas estan posicionados en el lugas correspondiente + //de + //los manejadores de la curva + nCurve->curveto(pointAt1, pointAt2, pointAt3); + //aumentamos los valores para el siguiente paso en el bucle + ++curve_it1; + ++curve_it2; + } + SPCurve *out = new SPCurve(); + out->moveto(curve_it1->initialPoint()); + out->lineto(curve_it1->finalPoint()); + SBasisOut = out->first_segment()->toSBasis(); + nextPointAt0 = out->first_segment()->initialPoint(); + nextPointAt3 = out->first_segment()->finalPoint(); + cubic = dynamic_cast(&*curve_it1); + if (!onlySelected) { + if (cubic) { + if (!ignoreCusp || !Geom::are_near((*cubic)[1], nextPointAt0)) { + nextPointAt1 = SBasisOut.valueAt(weightValue); + if (weightValue != 0.0000) { + nextPointAt1 = + Geom::Point(nextPointAt1[X] + 0.0001, nextPointAt1[Y] + 0.0001); + } + } else { + nextPointAt1 = out->first_segment()->initialPoint(); + } + if (!ignoreCusp || !Geom::are_near((*cubic)[2], nextPointAt3)) { + nextPointAt2 = SBasisOut.valueAt(1 - weightValue); + if (weightValue != 0.0000) { + nextPointAt2 = + Geom::Point(nextPointAt2[X] + 0.0001, nextPointAt2[Y] + 0.0001); + } + } else { + nextPointAt2 = out->first_segment()->finalPoint(); + } + } else { + if (!ignoreCusp && weightValue != 0.0000) { + nextPointAt1 = SBasisOut.valueAt(weightValue); + nextPointAt1 = + Geom::Point(nextPointAt1[X] + 0.0001, nextPointAt1[Y] + 0.0001); + nextPointAt2 = SBasisOut.valueAt(1 - weightValue); + nextPointAt2 = + Geom::Point(nextPointAt2[X] + 0.0001, nextPointAt2[Y] + 0.0001); + } else { + nextPointAt1 = out->first_segment()->initialPoint(); + nextPointAt2 = out->first_segment()->finalPoint(); + } + } + } else { + if (cubic) { + if (!ignoreCusp || !Geom::are_near((*cubic)[1], nextPointAt0)) { + if (nodeIsSelected(nextPointAt0)) { + nextPointAt1 = SBasisOut.valueAt(weightValue); + if (weightValue != 0.0000) { + nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0001, + nextPointAt1[Y] + 0.0001); } + } else { + nextPointAt1 = (*cubic)[1]; + } + } else { + nextPointAt1 = out->first_segment()->initialPoint(); } - out->reset(); - delete out; - //Aberiguamos la ultima parte de la curva correspondiente al último segmento - //Y hacemos lo propio con el path de salida - //nextPointAt0 = curveOut.valueAt(0); - if (path_it->closed()) { - nCurve->curveto(nextPointAt1, nextPointAt2, path_it->begin()->initialPoint()); - nCurve->move_endpoints(path_it->begin()->initialPoint(),path_it->begin()->initialPoint()); - }else{ - nCurve->curveto(nextPointAt1, nextPointAt2, nextPointAt3); - nCurve->move_endpoints(path_it->begin()->initialPoint(),nextPointAt3); + if (!ignoreCusp || !Geom::are_near((*cubic)[2], nextPointAt3)) { + if (nodeIsSelected(nextPointAt3)) { + nextPointAt2 = SBasisOut.valueAt(1 - weightValue); + if (weightValue != 0.0000) { + nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0001, + nextPointAt2[Y] + 0.0001); + } + } else { + nextPointAt2 = (*cubic)[2]; + } + } else { + nextPointAt2 = out->first_segment()->finalPoint(); } - //y cerramos la curva - if (path_it->closed()) { - nCurve->closepath_current(); + } else { + if (!ignoreCusp && weightValue != 0.0000) { + if (nodeIsSelected(nextPointAt0)) { + nextPointAt1 = SBasisOut.valueAt(weightValue); + nextPointAt1 = + Geom::Point(nextPointAt1[X] + 0.0001, nextPointAt1[Y] + 0.0001); + } else { + nextPointAt1 = out->first_segment()->initialPoint(); + } + if (nodeIsSelected(nextPointAt3)) { + nextPointAt2 = SBasisOut.valueAt(weightValue); + nextPointAt2 = + Geom::Point(nextPointAt2[X] + 0.0001, nextPointAt2[Y] + 0.0001); + } else { + nextPointAt2 = out->first_segment()->finalPoint(); + } + } else { + nextPointAt1 = out->first_segment()->initialPoint(); + nextPointAt2 = out->first_segment()->finalPoint(); } - curve->append(nCurve,false); - nCurve->reset(); - delete nCurve; - std::cout << ":: End ::\n"; + } + } + out->reset(); + delete out; + //Aberiguamos la ultima parte de la curva correspondiente al último + //segmento + //Y hacemos lo propio con el path de salida + //nextPointAt0 = curveOut.valueAt(0); + if (path_it->closed()) { + nCurve->curveto(nextPointAt1, nextPointAt2, + path_it->begin()->initialPoint()); + nCurve->move_endpoints(path_it->begin()->initialPoint(), + path_it->begin()->initialPoint()); + } else { + nCurve->curveto(nextPointAt1, nextPointAt2, nextPointAt3); + nCurve->move_endpoints(path_it->begin()->initialPoint(), nextPointAt3); + } + //y cerramos la curva + if (path_it->closed()) { + nCurve->closepath_current(); } + curve->append(nCurve, false); + nCurve->reset(); + delete nCurve; + std::cout << ":: End ::\n"; + } } }; //namespace LivePathEffect diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index 510f9c989..167810c49 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -11,46 +11,45 @@ #include "live_effects/parameter/bool.h" #include - namespace Inkscape { namespace LivePathEffect { class LPEBSpline : public Effect { public: - LPEBSpline(LivePathEffectObject *lpeobject); - virtual ~LPEBSpline(); + LPEBSpline(LivePathEffectObject *lpeobject); + virtual ~LPEBSpline(); - virtual void createAndApply(const char* name, SPDocument *doc, SPItem *item); + virtual void createAndApply(const char *name, SPDocument *doc, SPItem *item); - virtual LPEPathFlashType pathFlashType() const { return SUPPRESS_FLASH; } + virtual LPEPathFlashType pathFlashType() const { return SUPPRESS_FLASH; } - virtual void doEffect(SPCurve * curve); + virtual void doEffect(SPCurve *curve); - virtual void doBSplineFromWidget(SPCurve * curve, double value); + virtual void doBSplineFromWidget(SPCurve *curve, double value); - virtual bool nodeIsSelected(Geom::Point nodePoint); + virtual bool nodeIsSelected(Geom::Point nodePoint); - virtual Gtk::Widget * newWidget(); + virtual Gtk::Widget *newWidget(); - virtual void changeWeight(double weightValue); + virtual void changeWeight(double weightValue); - virtual void toDefaultWeight(); + virtual void toDefaultWeight(); - virtual void toMakeCusp(); + virtual void toMakeCusp(); - virtual void toWeight(); + virtual void toWeight(); - ScalarParam steps; + ScalarParam steps; private: - std::vector points; - BoolParam ignoreCusp; - BoolParam onlySelected; - ScalarParam weight; + std::vector points; + BoolParam ignoreCusp; + BoolParam onlySelected; + ScalarParam weight; - LPEBSpline(const LPEBSpline&); - LPEBSpline& operator=(const LPEBSpline&); + LPEBSpline(const LPEBSpline &); + LPEBSpline &operator=(const LPEBSpline &); }; -- cgit v1.2.3 From 10fcc833d8d5d02bc8b77b87c812fd9e723193a0 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 31 Mar 2014 14:10:57 +0200 Subject: Fixed bug in LPE Bspline widget, on apply selected nodes, because a rounding problem. Thanks very much to Johan Engelen for point me to the correct direction. maybe is better round it previously to the are_near function, not sure (bzr r11950.1.318) --- src/live_effects/lpe-bspline.cpp | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 09e71d833..8254a13b6 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -39,8 +39,6 @@ #include "inkscape.h" #include "desktop.h" -#include - using Inkscape::DocumentUndo; namespace Inkscape { @@ -367,22 +365,14 @@ void LPEBSpline::changeWeight(double weightValue) { bool LPEBSpline::nodeIsSelected(Geom::Point nodePoint) { using Geom::X; using Geom::Y; - std::cout << "\n"; - std::cout << ":: Executed -> nodeIsSelected(Geom::Point nodePoint) ::\n"; - std::cout << "Want to check the argument -nodePoint- is in points vector \n"; - std::cout << "nodePoint::X=" << nodePoint[X] << ";Y=" << nodePoint[Y] << "\n"; - std::cout << "Checking points std::vector\n"; + if (points.size() > 0) { for (std::vector::iterator i = points.begin(); i != points.end(); ++i) { Geom::Point p = *i; - std::cout << "p::X=" << p[X] << ";Y=" << p[Y] << "\n"; - std::cout << "Are near? "; - if (Geom::are_near(p, nodePoint)) { - std::cout << "YES\n"; + if (Geom::are_near(p, nodePoint, 0.0001)) { return true; } else { - std::cout << "NO\n"; } } } @@ -394,9 +384,6 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weightValue) { using Geom::Y; SPDesktop *desktop = inkscape_active_desktop(); if (INK_IS_NODE_TOOL(desktop->event_context)) { - std::cout << ":: Start -> doBSplineFromWidget(SPCurve * curve, double " - "weightValue) ::\n"; - std::cout << "Inserting nodes selected into std::vector 'points'\n"; Inkscape::UI::Tools::NodeTool *nt = INK_NODE_TOOL(desktop->event_context); Inkscape::UI::ControlPointSelection::Set &selection = nt->_selected_nodes->allPoints(); @@ -409,11 +396,8 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weightValue) { Inkscape::UI::Node *n = dynamic_cast(*i); pbegin = points.begin(); points.insert(pbegin, desktop->doc2dt(n->position())); - std::cout << "inserting point::X=" << desktop->doc2dt(n->position())[X] - << ";Y=" << desktop->doc2dt(n->position())[Y] << "\n"; } } - std::cout << "End inserting selected nodes into vector\n"; } //bool hasNodesSelected = LPEBspline::hasNodesSelected(); if (curve->get_segment_count() < 2) @@ -696,7 +680,6 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weightValue) { curve->append(nCurve, false); nCurve->reset(); delete nCurve; - std::cout << ":: End ::\n"; } } -- cgit v1.2.3 From e65f0ccd07f3b1278ba389025af29df498a3b3ab Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 31 Mar 2014 16:38:26 +0200 Subject: =?UTF-8?q?clarify=20the=20'sc'=20and=20'ec'=20SPCurve,=20by=20poi?= =?UTF-8?q?nt=20of=20Vin=C3=ADcius,=20whith=20the=20result=20of=20one=20cu?= =?UTF-8?q?rve=20less=20in=20the=20header?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (bzr r11950.1.320) --- src/ui/tools/freehand-base.cpp | 20 ++++++-------------- src/ui/tools/freehand-base.h | 7 +++++-- src/ui/tools/pen-tool.cpp | 18 ++++++++---------- src/ui/tools/pencil-tool.cpp | 4 +--- 4 files changed, 20 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index ac98be2cf..04796c2a6 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -91,10 +91,9 @@ FreehandBase::FreehandBase(gchar const *const *cursor_shape, gint hot_x, gint ho , white_item(NULL) , white_curves(NULL) , white_anchors(NULL) + , overwriteCurve(NULL) , sa(NULL) - , sc(NULL) , ea(NULL) - , ec(NULL) , waiting_LPE_type(Inkscape::LivePathEffect::INVALID_LPE) , red_curve_is_valid(false) , anchor_statusbar(false) @@ -156,10 +155,7 @@ void FreehandBase::setup() { this->green_closed = FALSE; // Create start anchor alternative curve - this->sc = new SPCurve(); - - // Create end anchor alternative curve - this->ec = new SPCurve(); + this->overwriteCurve = new SPCurve(); this->attach = TRUE; spdc_attach_selection(this, this->selection); @@ -533,12 +529,12 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) } if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ - dc->sc->append_continuous(c, 0.0625); + dc->overwriteCurve->append_continuous(c, 0.0625); c->unref(); - dc->sc->closepath_current(); + dc->overwriteCurve->closepath_current(); if(dc->sa){ dc->white_curves = g_slist_remove(dc->white_curves, dc->sa->curve); - dc->white_curves = g_slist_append(dc->white_curves, dc->sc); + dc->white_curves = g_slist_append(dc->white_curves, dc->overwriteCurve); } }else{ dc->sa->curve->append_continuous(c, 0.0625); @@ -555,7 +551,7 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) dc->white_curves = g_slist_remove(dc->white_curves, s); if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ - s = dc->sc; + s = dc->overwriteCurve; } if (dc->sa->start) { s = reverse_then_unref(s); @@ -566,10 +562,6 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) } else /* Step D - test end */ if (dc->ea) { SPCurve *e = dc->ea->curve; dc->white_curves = g_slist_remove(dc->white_curves, e); - if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || - prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ - e = dc->ec; - } if (!dc->ea->start) { e = reverse_then_unref(e); } diff --git a/src/ui/tools/freehand-base.h b/src/ui/tools/freehand-base.h index 2422c3563..6e04e03b7 100644 --- a/src/ui/tools/freehand-base.h +++ b/src/ui/tools/freehand-base.h @@ -79,13 +79,16 @@ public: GSList *white_curves; GSList *white_anchors; + //ALternative curve to use on continuing exisiting curve in case of bspline or spirolive + //because usigh anchor curves give memory and random bugs, - and obscure code- in some plataform reported by su_v in mac + SPCurve *overwriteCurve; + // Start anchor SPDrawAnchor *sa; - SPCurve *sc; // End anchor SPDrawAnchor *ea; - SPCurve *ec; + /* type of the LPE that is to be applied automatically to a finished path (if any) */ Inkscape::LivePathEffect::EffectType waiting_LPE_type; diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 053f1ac3d..1c0394e15 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -378,7 +378,6 @@ bool PenTool::_handleButtonPress(GdkEventButton const &bevent) { Geom::Point event_dt(desktop->w2d(event_w)); //Test whether we hit any anchor. SPDrawAnchor * const anchor = spdc_test_inside(this, event_w); - ToolBase *event_context = SP_EVENT_CONTEXT(this); //with this we avoid creating a new point over the existing one if(bevent.button != 3 && (this->spiro || this->bspline) && this->npoints > 0 && this->p[0] == this->p[3]){ @@ -1535,7 +1534,7 @@ void PenTool::_bspline_spiro_start_anchor_on() if (this->sa->start) { tmpCurve = tmpCurve->create_reverse(); } - this->sc = tmpCurve; + this->overwriteCurve = tmpCurve; } void PenTool::_bspline_spiro_start_anchor_off() @@ -1560,7 +1559,7 @@ void PenTool::_bspline_spiro_start_anchor_off() if (this->sa->start) { tmpCurve = tmpCurve->create_reverse(); } - this->sc = tmpCurve; + this->overwriteCurve = tmpCurve; } } @@ -1582,7 +1581,7 @@ void PenTool::_bspline_spiro_motion(bool shift){ }else if(!this->green_curve->is_empty()){ tmpCurve = this->green_curve->copy(); }else{ - tmpCurve = this->sc->copy(); + tmpCurve = this->overwriteCurve->copy(); if(this->sa->start) tmpCurve = tmpCurve->create_reverse(); } @@ -1694,7 +1693,7 @@ void PenTool::_bspline_spiro_end_anchor_on() if (!this->sa->start) { tmpCurve = tmpCurve->create_reverse(); } - this->sc = tmpCurve; + this->overwriteCurve = tmpCurve; } } @@ -1742,8 +1741,8 @@ void PenTool::_bspline_spiro_end_anchor_off() if (!this->sa->start) { tmpCurve = tmpCurve->create_reverse(); } - this->sc->reset(); - this->sc = tmpCurve; + this->overwriteCurve->reset(); + this->overwriteCurve = tmpCurve; } } } @@ -1758,7 +1757,7 @@ void PenTool::_bspline_spiro_build() SPCurve *curve = new SPCurve(); //If we continuate the existing curve we add it at the start if(this->sa && !this->sa->curve->is_empty()){ - curve = this->sc->copy(); + curve = this->overwriteCurve->copy(); if (this->sa->start) { curve = curve->create_reverse(); } @@ -2191,8 +2190,7 @@ void PenTool::_finish(gboolean const closed) { // cancelate line without a created segment this->red_curve->reset(); spdc_concat_colors_and_flush(this, closed); - this->sc = NULL; - this->ec = NULL; + this->overwriteCurve = NULL; this->sa = NULL; this->ea = NULL; diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp index 6f55d361f..0e8660248 100644 --- a/src/ui/tools/pencil-tool.cpp +++ b/src/ui/tools/pencil-tool.cpp @@ -200,7 +200,7 @@ bool PencilTool::_handleButtonPress(GdkEventButton const &bevent) { } if (anchor) { p = anchor->dp; - this->sc = anchor->curve; + this->overwriteCurve = anchor->curve; desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Continuing selected path")); } else { m.setup(desktop); @@ -372,7 +372,6 @@ bool PencilTool::_handleButtonRelease(GdkEventButton const &revent) { /* Finish segment now */ if (anchor) { p = anchor->dp; - this->ec = anchor->curve; } else { this->_endpointSnap(p, revent.state); } @@ -398,7 +397,6 @@ bool PencilTool::_handleButtonRelease(GdkEventButton const &revent) { /// \todo fixme: Clean up what follows (Lauris) if (anchor) { p = anchor->dp; - this->ec = anchor->curve; } else { Geom::Point p_end = p; this->_endpointSnap(p_end, revent.state); -- cgit v1.2.3 From ac61d9ff74ea5ee53ad39e95c22348da35ef5cf0 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 31 Mar 2014 16:41:27 +0200 Subject: =?UTF-8?q?use=20=20instead=20=20by=20point=20of=20?= =?UTF-8?q?Vin=C3=ADcius?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (bzr r11950.1.321) --- src/ui/tool/node.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 4824e13fb..3be3a89a7 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -28,7 +28,7 @@ #include "ui/tool/node.h" #include "ui/tool/path-manipulator.h" #include -#include +#include namespace { -- cgit v1.2.3 From 2b19c5f6508b7a59766d89f315f9f4fbc364f288 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 1 Apr 2014 00:48:28 +0200 Subject: Some node.cpp/h work moved to path_manipulator. Header variable bsplineWeight removed from all. Simplification of code with less functions in path_manipulator. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To fix: tips stop working because is handled by two static functions and couldent call to path_manipulator from here. Vinícius, any work arround? lines 480,481,1426,1427,1462 of node.cpp. gez: ¿Puedes probar si notas algun bug o problema? principalmente con la herramienta nodo, gracias. (bzr r11950.1.322) --- src/ui/tool/curve-drag-point.cpp | 4 +- src/ui/tool/node.cpp | 166 ++++++++++++++++++++++----------------- src/ui/tool/node.h | 2 - src/ui/tool/path-manipulator.cpp | 46 ++++------- src/ui/tool/path-manipulator.h | 10 +-- 5 files changed, 118 insertions(+), 110 deletions(-) (limited to 'src') diff --git a/src/ui/tool/curve-drag-point.cpp b/src/ui/tool/curve-drag-point.cpp index ad03cf75d..013553410 100644 --- a/src/ui/tool/curve-drag-point.cpp +++ b/src/ui/tool/curve-drag-point.cpp @@ -94,8 +94,8 @@ void CurveDragPoint::dragged(Geom::Point &new_pos, GdkEventMotion *event) if(!_pm.isBSpline(false)){ first->front()->move(first->front()->position() + offset0); second->back()->move(second->back()->position() + offset1); - }else if(weight>=0.8 && !second->isEndNode() && held_shift(*event))second->back()->move(new_pos); - else if(weight<=0.2 && !first->isEndNode() && held_shift(*event))first->front()->move(new_pos); + }else if(weight>=0.8 && held_shift(*event))second->back()->move(new_pos); + else if(weight<=0.2 && held_shift(*event))first->front()->move(new_pos); _pm.update(); } diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 3be3a89a7..1eaf0afa7 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -30,6 +30,7 @@ #include #include + namespace { Inkscape::ControlType nodeTypeToCtrlType(Inkscape::UI::NodeType type) @@ -168,9 +169,9 @@ void Handle::move(Geom::Point const &new_pos) setPosition(new_pos); //move the handler and its oposite the same proportion - if(_pm().isBSpline(false)){ + if(_pm().isBSpline()){ setPosition(_pm().BSplineHandleReposition(this)); - this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),_parent->bsplineWeight)); + this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),true)); } return; } @@ -185,9 +186,9 @@ void Handle::move(Geom::Point const &new_pos) setRelativePos(new_delta); //move the handler and its oposite the same proportion - if(_pm().isBSpline(false)){ + if(_pm().isBSpline()){ setPosition(_pm().BSplineHandleReposition(this)); - this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),_parent->bsplineWeight)); + this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),true)); } return; @@ -211,9 +212,9 @@ void Handle::move(Geom::Point const &new_pos) setPosition(new_pos); // moves the handler and its oposite the same proportion - if(_pm().isBSpline(false)){ + if(_pm().isBSpline()){ setPosition(_pm().BSplineHandleReposition(this)); - this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),_parent->bsplineWeight)); + this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),true)); } } @@ -305,9 +306,9 @@ bool Handle::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEven //this function moves the handler and its oposite to the default proportion of 0.3334 void Handle::handle_2button_press(){ - if(_pm().isBSpline(false)){ + if(_pm().isBSpline()){ setPosition(_pm().BSplineHandleReposition(this,0.3334)); - this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),_parent->bsplineWeight)); + this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),0.3334)); _pm().update(); } } @@ -361,17 +362,16 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) new_pos = result; // moves the handler and its oposite in X fixed positions depending on parameter "steps with control" // by default in live BSpline - if(_pm().isBSpline(false)){ + if(_pm().isBSpline()){ setPosition(new_pos); int steps = _pm().BSplineGetSteps(); - _parent->bsplineWeight = ceilf(_pm().BSplineHandlePosition(this)*steps)/steps; - new_pos=_pm().BSplineHandleReposition(this,_parent->bsplineWeight); + new_pos=_pm().BSplineHandleReposition(this,ceilf(_pm().BSplineHandlePosition(this)*steps)/steps); } } std::vector unselected; //if the snap adjustment is activated and it is not bspline - if (snap && !_pm().isBSpline(false)) { + if (snap && !_pm().isBSpline()) { ControlPointSelection::Set &nodes = _parent->_selection.allPoints(); for (ControlPointSelection::Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { Node *n = static_cast(*i); @@ -412,7 +412,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) } } //if it is bspline but SHIFT or CONTROL are not pressed it fixes it in the original position - if(_pm().isBSpline(false) && !held_shift(*event) && !held_control(*event)){ + if(_pm().isBSpline() && !held_shift(*event) && !held_control(*event)){ new_pos=_last_drag_origin(); } move(new_pos); // needed for correct update, even though it's redundant @@ -431,10 +431,6 @@ void Handle::ungrabbed(GdkEventButton *event) Geom::Point dist = _desktop->d2w(_parent->position()) - _desktop->d2w(position()); if (dist.length() <= drag_tolerance) { move(_parent->position()); - //sets the bspline strength to 0.0000 - if(_pm().isBSpline(false)){ - _parent->bsplineWeight = 0.0000; - } } } @@ -481,8 +477,8 @@ Glib::ustring Handle::_getTip(unsigned state) const // to show the appropiate messages. We cannot do it in any different way becasue the function is constant bool isBSpline = false; - if( _parent->bsplineWeight != 0.0000) - isBSpline = true; + //if( _parent->bsplineWeight != 0.0000) + // isBSpline = true; bool can_shift_rotate = _parent->type() == NODE_CUSP && !other()->isDegenerate(); if (can_shift_rotate && !isBSpline) { more = C_("Path handle tip", "more: Shift, Ctrl, Alt"); @@ -622,11 +618,21 @@ void Node::move(Geom::Point const &new_pos) Geom::Point old_pos = position(); Geom::Point delta = new_pos - position(); - // save the previous node strength to apply it again once the node is moved - double oldPos = 0.0000; + // save the previous nodes strength to apply it again once the node is moved + double nodeWeight = 0.0000; + double nextNodeWeight = 0.0000; + double prevNodeWeight = 0.0000; Node *n = this; - if(_pm().isBSpline(false)){ - oldPos = n->bsplineWeight; + Node * nextNode = n->nodeToward(n->front()); + Node * prevNode = n->nodeToward(n->back()); + if(_pm().isBSpline()){ + nodeWeight = _pm().BSplineHandlePosition(n->front()); + if(nextNode){ + nextNodeWeight = _pm().BSplineHandlePosition(nextNode->front()); + } + if(prevNode){ + prevNodeWeight = _pm().BSplineHandlePosition(prevNode->front()); + } } setPosition(new_pos); @@ -639,21 +645,49 @@ void Node::move(Geom::Point const &new_pos) _fixNeighbors(old_pos, new_pos); // move the affected handlers. First the node ones, later the adjoining ones. - if(_pm().isBSpline(false)){ - _front.setPosition(_pm().BSplineHandleReposition(this->front(),oldPos)); - _back.setPosition(_pm().BSplineHandleReposition(this->back(),oldPos)); - _pm().BSplineNodeHandlesReposition(this); + if(_pm().isBSpline()){ + _front.setPosition(_pm().BSplineHandleReposition(this->front(),nodeWeight)); + _back.setPosition(_pm().BSplineHandleReposition(this->back(),nodeWeight)); + if(prevNode){ + if(prevNode->front()->isDegenerate()){ + prevNode->front()->setPosition(_pm().BSplineHandleReposition(prevNode->front(),prevNodeWeight)); + }else{ + prevNode->front()->setPosition(_pm().BSplineHandleReposition(prevNode->front(),true)); + } + } + if(nextNode){ + if(nextNode->back()->isDegenerate()){ + nextNode->back()->setPosition(_pm().BSplineHandleReposition(nextNode->back(),nextNodeWeight)); + }else{ + nextNode->back()->setPosition(_pm().BSplineHandleReposition(nextNode->back(),true)); + } + } } } void Node::transform(Geom::Affine const &m) { - // save the previous node strength to apply it again later when the node is moved - double oldPos = 0.0000; - if(_pm().isBSpline(false)){ - oldPos = this->bsplineWeight; - } + Geom::Point old_pos = position(); + + // save the previous nodes strength to apply it again once the node is moved + double nodeWeight = 0.0000; + double nextNodeWeight = 0.0000; + double prevNodeWeight = 0.0000; + + Node *n = this; + Node * nextNode = n->nodeToward(n->front()); + Node * prevNode = n->nodeToward(n->back()); + if(_pm().isBSpline()){ + nodeWeight = _pm().BSplineHandlePosition(n->front()); + if(nextNode){ + nextNodeWeight = _pm().BSplineHandlePosition(nextNode->front()); + } + if(prevNode){ + prevNodeWeight = _pm().BSplineHandlePosition(prevNode->front()); + } + } + setPosition(position() * m); _front.setPosition(_front.position() * m); _back.setPosition(_back.position() * m); @@ -663,10 +697,23 @@ void Node::transform(Geom::Affine const &m) _fixNeighbors(old_pos, position()); // move the involved handlers, first the node ones, later the adjoining ones - if(_pm().isBSpline(false)){ - _front.setPosition(_pm().BSplineHandleReposition(this->front(),oldPos)); - _back.setPosition(_pm().BSplineHandleReposition(this->back(),oldPos)); - _pm().BSplineNodeHandlesReposition(this); + if(_pm().isBSpline()){ + _front.setPosition(_pm().BSplineHandleReposition(this->front(),nodeWeight)); + _back.setPosition(_pm().BSplineHandleReposition(this->back(),nodeWeight)); + if(prevNode){ + if(prevNode->front()->isDegenerate()){ + prevNode->front()->setPosition(_pm().BSplineHandleReposition(prevNode->front(),prevNodeWeight)); + }else{ + prevNode->front()->setPosition(_pm().BSplineHandleReposition(prevNode->front(),true)); + } + } + if(nextNode){ + if(nextNode->back()->isDegenerate()){ + nextNode->back()->setPosition(_pm().BSplineHandleReposition(nextNode->back(),nextNodeWeight)); + }else{ + nextNode->back()->setPosition(_pm().BSplineHandleReposition(nextNode->back(),true)); + } + } } } @@ -754,19 +801,6 @@ void Node::showHandles(bool v) _back.setVisible(v); } - // define the node strength, depending on being or not bspline traced. - // every time we operate over these handlers in a trace bspline - // that strength needs to be updated. - - this->bsplineWeight = 0.0000; - if(_pm().isBSpline(false) && (!_front.isDegenerate() || !_back.isDegenerate())){ - if (!_front.isDegenerate()) { - _pm().BSplineHandlePosition(&_front); - } - if (!_back.isDegenerate()) { - _pm().BSplineHandlePosition(&_back); - } - } } void Node::updateHandles() @@ -870,10 +904,13 @@ void Node::setType(NodeType type, bool update_handles) } /* in node type changes, about bspline traces, we can mantain them with 0.0000 power in border mode, or we give them the default power in curve mode */ - if(_pm().isBSpline(false)){ - if(this->bsplineWeight !=0.0000) this->bsplineWeight = 0.3334; - _front.setPosition(_pm().BSplineHandleReposition(this->front(),this->bsplineWeight)); - _back.setPosition(_pm().BSplineHandleReposition(this->back(),this->bsplineWeight)); + if(_pm().isBSpline()){ + double weight = 0.0000; + if(_pm().BSplineHandlePosition(this->front()) != 0.0000){ + weight = 0.3334; + } + _front.setPosition(_pm().BSplineHandleReposition(this->front(),weight)); + _back.setPosition(_pm().BSplineHandleReposition(this->back(),weight)); } } _type = type; @@ -1123,20 +1160,9 @@ void Node::_setState(State state) mgr.setActive(_canvas_item, true); mgr.setPrelight(_canvas_item, false); //this shows the handlers when selecting the nodes - if(_pm().isBSpline(false)){ - if(!this->back()->isDegenerate()){ - _pm().BSplineHandlePosition(this->back()); - }else if (!this->front()->isDegenerate()){ - _pm().BSplineHandlePosition(this->front()); - }else{ - this->bsplineWeight = 0.0000; - } - if(!this->front()->isDegenerate()){ - this->front()->setPosition(_pm().BSplineHandleReposition(this->front(),this->bsplineWeight)); - } - if(!this->back()->isDegenerate()){ - this->back()->setPosition(_pm().BSplineHandleReposition(this->back(),this->bsplineWeight)); - } + if(_pm().isBSpline()){ + this->front()->setPosition(_pm().BSplineHandleReposition(this->front())); + this->back()->setPosition(_pm().BSplineHandleReposition(this->back())); } break; } @@ -1397,8 +1423,8 @@ Glib::ustring Node::_getTip(unsigned state) const to show the appropiate messages. We cannot do it in any other way, because the function is constant */ bool isBSpline = false; - if( this->bsplineWeight != 0.0000) - isBSpline = true; + //if( this->bsplineWeight != 0.0000) + // isBSpline = true; if (state_held_shift(state)) { bool can_drag_out = (_next() && _front.isDegenerate()) || (_prev() && _back.isDegenerate()); if (can_drag_out) { @@ -1433,7 +1459,7 @@ Glib::ustring Node::_getTip(unsigned state) const "%s: drag to shape the path (more: Shift, Ctrl, Alt)"), nodetype); }else if(_selection.size() == 1){ return format_tip(C_("Path node tip", - "BSpline node: %g weight, drag to shape the path (more: Shift, Ctrl, Alt)"),this->bsplineWeight); + "BSpline node: %g weight, drag to shape the path (more: Shift, Ctrl, Alt)"),0.0000/*this->bsplineWeight*/); } return format_tip(C_("Path node tip", "%s: drag to shape the path, click to toggle scale/rotation handles (more: Shift, Ctrl, Alt)"), nodetype); diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h index fc36502a5..202dbb3cd 100644 --- a/src/ui/tool/node.h +++ b/src/ui/tool/node.h @@ -191,8 +191,6 @@ public: bool isEndNode() const; Handle *front() { return &_front; } Handle *back() { return &_back; } - //strength value for each node - double bsplineWeight; /** * Gets the handle that faces the given adjacent node. diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 841ab659a..905df61f4 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -666,14 +666,11 @@ unsigned PathManipulator::_deleteStretch(NodeList::iterator start, NodeList::ite } // if we are removing, we readjust the handlers if(isBSpline()){ - double pos = 0.0000; if(start.prev()){ - pos = BSplineHandlePosition(start.prev()->back()); - start.prev()->front()->setPosition(BSplineHandleReposition(start.prev()->front(),pos)); + start.prev()->front()->setPosition(BSplineHandleReposition(start.prev()->front(),true)); } if(end){ - pos = BSplineHandlePosition(end->front()); - end->back()->setPosition(BSplineHandleReposition(end->back(),pos)); + end->back()->setPosition(BSplineHandleReposition(end->back(),true)); } } @@ -1209,31 +1206,36 @@ bool PathManipulator::isBSpline(bool recalculate){ return _is_bspline; } -// returns the corresponding strength to the position of a handler -double PathManipulator::BSplineHandlePosition(Handle *h){ +// returns the corresponding strength to the position of the handlers +double PathManipulator::BSplineHandlePosition(Handle *h, bool other){ using Geom::X; using Geom::Y; double pos = 0.0000; Node *n = h->parent(); Node * nextNode = NULL; + if(other){ + h = h->other(); + } nextNode = n->nodeToward(h); - if(nextNode && n->position() != h->position()){ + if(nextNode && !Geom::are_near(n->position(), h->position())){ SPCurve *lineInsideNodes = new SPCurve(); lineInsideNodes->moveto(n->position()); lineInsideNodes->lineto(nextNode->position()); pos = Geom::nearest_point(h->position(),*lineInsideNodes->first_segment()); } - n->bsplineWeight = pos; + if ((pos == 0.0000 || pos == 1.0000) && other == false){ + return BSplineHandlePosition(h, true); + } return pos; } -// moves the handler to the corresponding position -Geom::Point PathManipulator::BSplineHandleReposition(Handle *h){ - double pos = this->BSplineHandlePosition(h); +// give the location for the handler in the corresponding position +Geom::Point PathManipulator::BSplineHandleReposition(Handle *h, bool other){ + double pos = this->BSplineHandlePosition(h, other); return BSplineHandleReposition(h,pos); } -// moves the handler to the specified position +// give the location for the handler to the specified position Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){ using Geom::X; using Geom::Y; @@ -1247,34 +1249,16 @@ Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){ lineInsideNodes->moveto(n->position()); lineInsideNodes->lineto(nextNode->position()); SBasisInsideNodes = lineInsideNodes->first_segment()->toSBasis(); - n->bsplineWeight = pos; ret = SBasisInsideNodes.valueAt(pos); ret = Geom::Point(ret[X] + 0.005,ret[Y] + 0.005); }else{ if(pos == 0.0000){ - n->bsplineWeight = 0.0000; ret = n->position(); } } return ret; } -//moves the node handlers and its oposite handlers to the strength of its nodes -void PathManipulator::BSplineNodeHandlesReposition(Node *n){ - Node * nextNode = n->nodeToward(n->front()); - Node * prevNode = n->nodeToward(n->back()); - if(prevNode){ - if(!prevNode->isEndNode()) - prevNode->back()->setPosition(BSplineHandleReposition(prevNode->back(),prevNode->bsplineWeight)); - prevNode->front()->setPosition(BSplineHandleReposition(prevNode->front(),prevNode->bsplineWeight)); - } - if(nextNode){ - if(!nextNode->isEndNode()) - nextNode->front()->setPosition(BSplineHandleReposition(nextNode->front(),nextNode->bsplineWeight)); - nextNode->back()->setPosition(BSplineHandleReposition(nextNode->back(),nextNode->bsplineWeight)); - } -} - /** Construct the geometric representation of nodes and handles, update the outline * and display * \param alert_LPE if true, first the LPE is warned what the new path is going to be before updating it diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index f15533021..cba029b68 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -106,11 +106,11 @@ private: typedef boost::shared_ptr SubpathPtr; void _createControlPointsFromGeometry(); - bool isBSpline(bool recalculate = true); - double BSplineHandlePosition(Handle *h); - Geom::Point BSplineHandleReposition(Handle *h); - Geom::Point BSplineHandleReposition(Handle *h,double pos); - void BSplineNodeHandlesReposition(Node *n); + + bool isBSpline(bool recalculate = false); + double BSplineHandlePosition(Handle *h, bool other = false); + Geom::Point BSplineHandleReposition(Handle *h, bool other = false); + Geom::Point BSplineHandleReposition(Handle *h, double pos); void _createGeometryFromControlPoints(bool alert_LPE = false); unsigned _deleteStretch(NodeList::iterator first, NodeList::iterator last, bool keep_shape); std::string _createTypeString(); -- cgit v1.2.3 From 0f78c1425e814758c0a0d7f0c2578eae88fe3ab6 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 1 Apr 2014 14:02:22 +0200 Subject: =?UTF-8?q?A=20refactor=20for=20fixing=20some=20issues.=20Pending?= =?UTF-8?q?=20how=20to=20handle=20static=20functions=20Vin=C3=ADcius=20for?= =?UTF-8?q?=20handle=20tips=20in=20his=20static=20functions=20i=20know=20t?= =?UTF-8?q?wo=20ways:=20A:=20A=20bool=20property=20in=20node=20class=20of?= =?UTF-8?q?=20node.h=20to=20handle=20if=20curve=20is=20bspline=20B:=20Call?= =?UTF-8?q?=20another=20non=20static=20function=20from=20the=20static=20ti?= =?UTF-8?q?ps=20one=20-not=20tested-?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (bzr r11950.1.323) --- src/ui/tool/node.cpp | 61 +++++++++++++++++++++------------------- src/ui/tool/path-manipulator.cpp | 22 +++++++-------- src/ui/tool/path-manipulator.h | 4 +-- 3 files changed, 45 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 1eaf0afa7..7ba69b039 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -170,8 +170,8 @@ void Handle::move(Geom::Point const &new_pos) //move the handler and its oposite the same proportion if(_pm().isBSpline()){ - setPosition(_pm().BSplineHandleReposition(this)); - this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),true)); + setPosition(_pm().BSplineHandleReposition(this,this)); + this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),this)); } return; } @@ -187,8 +187,8 @@ void Handle::move(Geom::Point const &new_pos) //move the handler and its oposite the same proportion if(_pm().isBSpline()){ - setPosition(_pm().BSplineHandleReposition(this)); - this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),true)); + setPosition(_pm().BSplineHandleReposition(this,this)); + this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),this)); } return; @@ -213,8 +213,8 @@ void Handle::move(Geom::Point const &new_pos) // moves the handler and its oposite the same proportion if(_pm().isBSpline()){ - setPosition(_pm().BSplineHandleReposition(this)); - this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),true)); + setPosition(_pm().BSplineHandleReposition(this,this)); + this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),this)); } } @@ -365,7 +365,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) if(_pm().isBSpline()){ setPosition(new_pos); int steps = _pm().BSplineGetSteps(); - new_pos=_pm().BSplineHandleReposition(this,ceilf(_pm().BSplineHandlePosition(this)*steps)/steps); + new_pos=_pm().BSplineHandleReposition(this,ceilf(_pm().BSplineHandlePosition(this,this)*steps)/steps); } } @@ -625,13 +625,15 @@ void Node::move(Geom::Point const &new_pos) Node *n = this; Node * nextNode = n->nodeToward(n->front()); Node * prevNode = n->nodeToward(n->back()); - if(_pm().isBSpline()){ - nodeWeight = _pm().BSplineHandlePosition(n->front()); - if(nextNode){ - nextNodeWeight = _pm().BSplineHandlePosition(nextNode->front()); + nodeWeight = _pm().BSplineHandlePosition(n->front()); + if(prevNode){ + if(prevNode->isEndNode()){ + prevNodeWeight = _pm().BSplineHandlePosition(prevNode->front(),prevNode->front()); } - if(prevNode){ - prevNodeWeight = _pm().BSplineHandlePosition(prevNode->front()); + } + if(nextNode){ + if(nextNode->isEndNode()){ + nextNodeWeight = _pm().BSplineHandlePosition(nextNode->back(),nextNode->back()); } } @@ -649,17 +651,17 @@ void Node::move(Geom::Point const &new_pos) _front.setPosition(_pm().BSplineHandleReposition(this->front(),nodeWeight)); _back.setPosition(_pm().BSplineHandleReposition(this->back(),nodeWeight)); if(prevNode){ - if(prevNode->front()->isDegenerate()){ + if(prevNode->isEndNode()){ prevNode->front()->setPosition(_pm().BSplineHandleReposition(prevNode->front(),prevNodeWeight)); }else{ - prevNode->front()->setPosition(_pm().BSplineHandleReposition(prevNode->front(),true)); + prevNode->front()->setPosition(_pm().BSplineHandleReposition(prevNode->front(),prevNode->back())); } } if(nextNode){ - if(nextNode->back()->isDegenerate()){ + if(nextNode->isEndNode()){ nextNode->back()->setPosition(_pm().BSplineHandleReposition(nextNode->back(),nextNodeWeight)); }else{ - nextNode->back()->setPosition(_pm().BSplineHandleReposition(nextNode->back(),true)); + nextNode->back()->setPosition(_pm().BSplineHandleReposition(nextNode->back(),nextNode->back())); } } } @@ -674,17 +676,18 @@ void Node::transform(Geom::Affine const &m) double nodeWeight = 0.0000; double nextNodeWeight = 0.0000; double prevNodeWeight = 0.0000; - Node *n = this; Node * nextNode = n->nodeToward(n->front()); Node * prevNode = n->nodeToward(n->back()); - if(_pm().isBSpline()){ - nodeWeight = _pm().BSplineHandlePosition(n->front()); - if(nextNode){ - nextNodeWeight = _pm().BSplineHandlePosition(nextNode->front()); + nodeWeight = _pm().BSplineHandlePosition(n->front()); + if(prevNode){ + if(prevNode->isEndNode()){ + prevNodeWeight = _pm().BSplineHandlePosition(prevNode->front(),prevNode->front()); } - if(prevNode){ - prevNodeWeight = _pm().BSplineHandlePosition(prevNode->front()); + } + if(nextNode){ + if(nextNode->isEndNode()){ + nextNodeWeight = _pm().BSplineHandlePosition(nextNode->back(),nextNode->back()); } } @@ -701,17 +704,17 @@ void Node::transform(Geom::Affine const &m) _front.setPosition(_pm().BSplineHandleReposition(this->front(),nodeWeight)); _back.setPosition(_pm().BSplineHandleReposition(this->back(),nodeWeight)); if(prevNode){ - if(prevNode->front()->isDegenerate()){ + if(prevNode->isEndNode()){ prevNode->front()->setPosition(_pm().BSplineHandleReposition(prevNode->front(),prevNodeWeight)); }else{ - prevNode->front()->setPosition(_pm().BSplineHandleReposition(prevNode->front(),true)); + prevNode->front()->setPosition(_pm().BSplineHandleReposition(prevNode->front(),prevNode->back())); } } if(nextNode){ - if(nextNode->back()->isDegenerate()){ + if(nextNode->isEndNode()){ nextNode->back()->setPosition(_pm().BSplineHandleReposition(nextNode->back(),nextNodeWeight)); }else{ - nextNode->back()->setPosition(_pm().BSplineHandleReposition(nextNode->back(),true)); + nextNode->back()->setPosition(_pm().BSplineHandleReposition(nextNode->back(),nextNode->front())); } } } @@ -906,7 +909,7 @@ void Node::setType(NodeType type, bool update_handles) or we give them the default power in curve mode */ if(_pm().isBSpline()){ double weight = 0.0000; - if(_pm().BSplineHandlePosition(this->front()) != 0.0000){ + if(_pm().BSplineHandlePosition(this->front()) != 0.0000 ){ weight = 0.3334; } _front.setPosition(_pm().BSplineHandleReposition(this->front(),weight)); diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 905df61f4..487c31b10 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -667,10 +667,10 @@ unsigned PathManipulator::_deleteStretch(NodeList::iterator start, NodeList::ite // if we are removing, we readjust the handlers if(isBSpline()){ if(start.prev()){ - start.prev()->front()->setPosition(BSplineHandleReposition(start.prev()->front(),true)); + start.prev()->front()->setPosition(BSplineHandleReposition(start.prev()->front(),start.prev()->back())); } if(end){ - end->back()->setPosition(BSplineHandleReposition(end->back(),true)); + end->back()->setPosition(BSplineHandleReposition(end->back(),end->front())); } } @@ -1207,31 +1207,31 @@ bool PathManipulator::isBSpline(bool recalculate){ } // returns the corresponding strength to the position of the handlers -double PathManipulator::BSplineHandlePosition(Handle *h, bool other){ +double PathManipulator::BSplineHandlePosition(Handle *h, Handle *h2){ using Geom::X; using Geom::Y; + if(h2){ + h = h2; + } double pos = 0.0000; Node *n = h->parent(); Node * nextNode = NULL; - if(other){ - h = h->other(); - } nextNode = n->nodeToward(h); - if(nextNode && !Geom::are_near(n->position(), h->position())){ + if(nextNode){ SPCurve *lineInsideNodes = new SPCurve(); lineInsideNodes->moveto(n->position()); lineInsideNodes->lineto(nextNode->position()); pos = Geom::nearest_point(h->position(),*lineInsideNodes->first_segment()); } - if ((pos == 0.0000 || pos == 1.0000) && other == false){ - return BSplineHandlePosition(h, true); + if (pos == 0.0000 && !h2){ + return BSplineHandlePosition(h, h->other()); } return pos; } // give the location for the handler in the corresponding position -Geom::Point PathManipulator::BSplineHandleReposition(Handle *h, bool other){ - double pos = this->BSplineHandlePosition(h, other); +Geom::Point PathManipulator::BSplineHandleReposition(Handle *h, Handle *h2){ + double pos = this->BSplineHandlePosition(h, h2); return BSplineHandleReposition(h,pos); } diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index cba029b68..a85664ddf 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -108,8 +108,8 @@ private: void _createControlPointsFromGeometry(); bool isBSpline(bool recalculate = false); - double BSplineHandlePosition(Handle *h, bool other = false); - Geom::Point BSplineHandleReposition(Handle *h, bool other = false); + double BSplineHandlePosition(Handle *h, Handle *h2 = NULL); + Geom::Point BSplineHandleReposition(Handle *h, Handle *h2 = NULL); Geom::Point BSplineHandleReposition(Handle *h, double pos); void _createGeometryFromControlPoints(bool alert_LPE = false); unsigned _deleteStretch(NodeList::iterator first, NodeList::iterator last, bool keep_shape); -- cgit v1.2.3 From 064e0f756b7525d4af0b8a34b3ef6fe89c007064 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 2 Apr 2014 01:56:31 +0200 Subject: Refactor of end anchors. (bzr r11950.1.325) --- src/ui/tools/freehand-base.cpp | 19 +++++ src/ui/tools/pen-tool.cpp | 169 ++++++++++++++++++++--------------------- 2 files changed, 101 insertions(+), 87 deletions(-) (limited to 'src') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 04796c2a6..1c5b7b8e3 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -565,6 +565,25 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) if (!dc->ea->start) { e = reverse_then_unref(e); } + if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || + prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ + e = reverse_then_unref(e); + Geom::CubicBezier const * cubic = dynamic_cast(&*e->last_segment()); + SPCurve *lastSeg = new SPCurve(); + if(cubic){ + lastSeg->moveto((*cubic)[0]); + lastSeg->curveto((*cubic)[1],(*cubic)[3],(*cubic)[3]); + if( e->get_segment_count() == 1){ + e = lastSeg; + }else{ + //we eliminate the last segment + e->backspace(); + //and we add it again with the recreation + e->append_continuous(lastSeg, 0.0625); + } + } + e = reverse_then_unref(e); + } c->append_continuous(e, 0.0625); e->unref(); } diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 1c0394e15..9e4df5031 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -1637,62 +1637,53 @@ void PenTool::_bspline_spiro_end_anchor_on() SPCurve *tmpCurve = new SPCurve(); SPCurve *lastSeg = new SPCurve(); Geom::Point C(0,0); - if(!this->sa || this->sa->curve->is_empty()){ + bool reverse = false; + if( this->green_anchor && this->green_anchor->active ){ tmpCurve = this->green_curve->create_reverse(); - if(this->green_curve->get_segment_count()==0)return; - Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); - if(this->bspline){ - C = tmpCurve->last_segment()->finalPoint() + (1./3)*(tmpCurve->last_segment()->initialPoint() - tmpCurve->last_segment()->finalPoint()); - C = Geom::Point(C[X] + 0.005,C[Y] + 0.005); - }else{ - C = this->p[3] + (Geom::Point)(this->p[3] - this->p[2] ); - } - if(cubic){ - lastSeg->moveto((*cubic)[0]); - lastSeg->curveto((*cubic)[1],C,(*cubic)[3]); - }else{ - lastSeg->moveto(tmpCurve->last_segment()->initialPoint()); - lastSeg->curveto(tmpCurve->last_segment()->initialPoint(),C,tmpCurve->last_segment()->finalPoint()); + if(this->green_curve->get_segment_count()==0){ + return; } - if( tmpCurve->get_segment_count() == 1){ - tmpCurve = lastSeg; - }else{ - //we eliminate the last segment - tmpCurve->backspace(); - //and we add it again with the recreation - tmpCurve->append_continuous(lastSeg, 0.0625); + reverse = true; + } else if(this->sa){ + tmpCurve = this->overwriteCurve; + if(!this->sa->start){ + tmpCurve = tmpCurve->create_reverse(); + reverse = true; } + }else{ + return; + } + Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); + if(this->bspline){ + C = tmpCurve->last_segment()->finalPoint() + (1./3)*(tmpCurve->last_segment()->initialPoint() - tmpCurve->last_segment()->finalPoint()); + C = Geom::Point(C[X] + 0.005,C[Y] + 0.005); + }else{ + C = this->p[3] + (Geom::Point)(this->p[3] - this->p[2] ); + } + if(cubic){ + lastSeg->moveto((*cubic)[0]); + lastSeg->curveto((*cubic)[1],C,(*cubic)[3]); + }else{ + lastSeg->moveto(tmpCurve->last_segment()->initialPoint()); + lastSeg->curveto(tmpCurve->last_segment()->initialPoint(),C,tmpCurve->last_segment()->finalPoint()); + } + if( tmpCurve->get_segment_count() == 1){ + tmpCurve = lastSeg; + }else{ + //we eliminate the last segment + tmpCurve->backspace(); + //and we add it again with the recreation + tmpCurve->append_continuous(lastSeg, 0.0625); + } + if (reverse) { tmpCurve = tmpCurve->create_reverse(); + } + if( this->green_anchor && this->green_anchor->active ) + { this->green_curve->reset(); this->green_curve = tmpCurve; - }else { - tmpCurve = this->sa->curve->copy(); - if(!this->sa->start) tmpCurve = tmpCurve->create_reverse(); - Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); - if(this->bspline){ - C = tmpCurve->last_segment()->finalPoint() + (1./3)*(tmpCurve->last_segment()->initialPoint() - tmpCurve->last_segment()->finalPoint()); - C = Geom::Point(C[X] + 0.005,C[Y] + 0.005); - }else{ - C = this->p[3] + (Geom::Point)(this->p[3] - this->p[2] ); - } - if(cubic){ - lastSeg->moveto((*cubic)[0]); - lastSeg->curveto((*cubic)[1],C,(*cubic)[3]); - }else{ - lastSeg->moveto(tmpCurve->last_segment()->initialPoint()); - lastSeg->curveto(tmpCurve->last_segment()->initialPoint(),C,tmpCurve->last_segment()->finalPoint()); - } - if( tmpCurve->get_segment_count() == 1){ - tmpCurve = lastSeg; - }else{ - //we eliminate the last segment - tmpCurve->backspace(); - //and we add it again with the recreation - tmpCurve->append_continuous(lastSeg, 0.0625); - } - if (!this->sa->start) { - tmpCurve = tmpCurve->create_reverse(); - } + }else{ + this->overwriteCurve->reset(); this->overwriteCurve = tmpCurve; } } @@ -1702,45 +1693,43 @@ void PenTool::_bspline_spiro_end_anchor_off() SPCurve *tmpCurve = new SPCurve(); SPCurve *lastSeg = new SPCurve(); + bool reverse = false; this->p[2] = this->p[3]; - if(!this->sa || this->sa->curve->is_empty()){ - + if( this->green_anchor && this->green_anchor->active ){ tmpCurve = this->green_curve->create_reverse(); - if(this->green_curve->get_segment_count()==0)return; - Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); - if(cubic){ - lastSeg->moveto((*cubic)[0]); - lastSeg->curveto((*cubic)[1],(*cubic)[3],(*cubic)[3]); - if( tmpCurve->get_segment_count() == 1){ - tmpCurve = lastSeg; - }else{ - //we eliminate the last segment - tmpCurve->backspace(); - //and we add it again with the recreation - tmpCurve->append_continuous(lastSeg, 0.0625); - } + if(this->green_curve->get_segment_count()==0){ + return; + } + reverse = true; + } else if(this->sa){ + tmpCurve = this->overwriteCurve; + if(!this->sa->start){ + tmpCurve = tmpCurve->create_reverse(); + reverse = true; + } + }else{ + return; + } + Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); + if(cubic){ + lastSeg->moveto((*cubic)[0]); + lastSeg->curveto((*cubic)[1],(*cubic)[3],(*cubic)[3]); + if( tmpCurve->get_segment_count() == 1){ + tmpCurve = lastSeg; + }else{ + //we eliminate the last segment + tmpCurve->backspace(); + //and we add it again with the recreation + tmpCurve->append_continuous(lastSeg, 0.0625); + } + if (reverse) { tmpCurve = tmpCurve->create_reverse(); + } + if( this->green_anchor && this->green_anchor->active ) + { this->green_curve->reset(); this->green_curve = tmpCurve; - } - }else { - tmpCurve = this->sa->curve->copy(); - if(!this->sa->start) tmpCurve = tmpCurve->create_reverse(); - Geom::CubicBezier const * cubic = dynamic_cast(&*tmpCurve->last_segment()); - if(cubic){ - lastSeg->moveto((*cubic)[0]); - lastSeg->curveto((*cubic)[1],(*cubic)[3],(*cubic)[3]); - if( tmpCurve->get_segment_count() == 1){ - tmpCurve = lastSeg; - }else{ - //we eliminate the last segment - tmpCurve->backspace(); - //and we add it again with the recreation - tmpCurve->append_continuous(lastSeg, 0.0625); - } - if (!this->sa->start) { - tmpCurve = tmpCurve->create_reverse(); - } + }else{ this->overwriteCurve->reset(); this->overwriteCurve = tmpCurve; } @@ -1750,8 +1739,9 @@ void PenTool::_bspline_spiro_end_anchor_off() //prepares the curves for its transformation into BSpline curve. void PenTool::_bspline_spiro_build() { - if(!this->spiro && !this->bspline) + if(!this->spiro && !this->bspline){ return; + } //We create the base curve SPCurve *curve = new SPCurve(); @@ -1763,14 +1753,19 @@ void PenTool::_bspline_spiro_build() } } - if (!this->green_curve->is_empty()) + if (!this->green_curve->is_empty()){ curve->append_continuous(this->green_curve, 0.0625); + } //and the red one if (!this->red_curve->is_empty()){ this->red_curve->reset(); this->red_curve->moveto(this->p[0]); - this->red_curve->curveto(this->p[1],this->p[2],this->p[3]); + if(this->anchor_statusbar && !this->sa && !(this->green_anchor && this->green_anchor->active)){ + this->red_curve->curveto(this->p[1],this->p[3],this->p[3]); + }else{ + this->red_curve->curveto(this->p[1],this->p[2],this->p[3]); + } sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve); curve->append_continuous(this->red_curve, 0.0625); } -- cgit v1.2.3 From 0f91c5cd6a3a8a07185e107da881ff4da71f7081 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 22 Apr 2014 19:03:36 +0200 Subject: align two buttons in LPE widget (bzr r11950.1.334) --- src/live_effects/lpe-bspline.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 8254a13b6..00ebcd9ba 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -318,20 +318,18 @@ Gtk::Widget *LPEBSpline::newWidget() { ++it; } + Gtk::HBox * buttons = Gtk::manage(new Gtk::HBox(true,0)); Gtk::Button *defaultWeight = Gtk::manage(new Gtk::Button(Glib::ustring(_("Default weight 0.3334")))); - defaultWeight->set_alignment(0.0, 0.5); defaultWeight->signal_clicked() .connect(sigc::mem_fun(*this, &LPEBSpline::toDefaultWeight)); - Gtk::Widget *defaultWeightWidget = dynamic_cast(defaultWeight); - vbox->pack_start(*defaultWeightWidget, true, true, 2); + buttons->pack_start(*defaultWeight, true, true, 2); Gtk::Button *makeCusp = Gtk::manage(new Gtk::Button(Glib::ustring(_("Make cusp")))); - makeCusp->set_alignment(0.0, 0.5); makeCusp->signal_clicked() .connect(sigc::mem_fun(*this, &LPEBSpline::toMakeCusp)); - Gtk::Widget *makeCuspWidget = dynamic_cast(makeCusp); - vbox->pack_start(*makeCuspWidget, true, true, 2); + buttons->pack_start(*makeCusp, true, true, 2); + vbox->pack_start(*buttons, true, true, 2); return dynamic_cast(vbox); } -- cgit v1.2.3 From bb9297f7e0a297c85b5d40eab49677293effc88f Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 22 Apr 2014 21:44:02 +0200 Subject: Redesign of the BSpline LPE widgets (bzr r11950.1.335) --- src/live_effects/lpe-bspline.cpp | 57 ++++++++++++++++++++++++++++------------ src/live_effects/lpe-bspline.h | 4 +-- 2 files changed, 42 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 00ebcd9ba..edf19d1e5 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -2,7 +2,8 @@ /* * Released under GNU GPL, read the file 'COPYING' for more information */ - +#include +#include #include #include #include @@ -59,10 +60,10 @@ LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) false), weight(_("Change weight:"), _("Change weight of the effect"), "weight", &wr, this, 0.3334) { - registerParameter(dynamic_cast(&ignoreCusp)); - registerParameter(dynamic_cast(&onlySelected)); registerParameter(dynamic_cast(&weight)); registerParameter(dynamic_cast(&steps)); + registerParameter(dynamic_cast(&ignoreCusp)); + registerParameter(dynamic_cast(&onlySelected)); weight.param_set_range(0.0000, 1); weight.param_set_increments(0.1, 0.1); weight.param_set_digits(4); @@ -287,12 +288,32 @@ Gtk::Widget *LPEBSpline::newWidget() { if ((*it)->widget_is_visible) { Parameter *param = *it; Gtk::Widget *widg = dynamic_cast(param->param_newWidget()); + if (param->param_key == "weight"){ + Gtk::HBox * buttons = Gtk::manage(new Gtk::HBox(true,0)); + Gtk::Button *defaultWeight = + Gtk::manage(new Gtk::Button(Glib::ustring(_("Default weight")))); + defaultWeight->signal_clicked() + .connect(sigc::bind(sigc::mem_fun(*this, &LPEBSpline::toDefaultWeight), widg)); + buttons->pack_start(*defaultWeight, true, true, 2); + Gtk::Button *makeCusp = + Gtk::manage(new Gtk::Button(Glib::ustring(_("Make cusp")))); + makeCusp->signal_clicked() + .connect(sigc::bind(sigc::mem_fun(*this, &LPEBSpline::toMakeCusp), widg)); + buttons->pack_start(*makeCusp, true, true, 2); + vbox->pack_start(*buttons, true, true, 2); + } if (param->param_key == "weight" || param->param_key == "steps") { Inkscape::UI::Widget::Scalar *widgRegistered = Gtk::manage(dynamic_cast(widg)); widgRegistered->signal_value_changed() .connect(sigc::mem_fun(*this, &LPEBSpline::toWeight)); widg = dynamic_cast(widgRegistered); + if (widg){ + Gtk::HBox * scalarParameter = dynamic_cast(widg); + std::vector< Gtk::Widget* > childList = scalarParameter->get_children(); + Gtk::Entry* entryWidg = dynamic_cast(childList[1]); + entryWidg->set_width_chars(6); + } } if (param->param_key == "onlySelected") { Gtk::CheckButton *widgRegistered = @@ -318,24 +339,26 @@ Gtk::Widget *LPEBSpline::newWidget() { ++it; } - Gtk::HBox * buttons = Gtk::manage(new Gtk::HBox(true,0)); - Gtk::Button *defaultWeight = - Gtk::manage(new Gtk::Button(Glib::ustring(_("Default weight 0.3334")))); - defaultWeight->signal_clicked() - .connect(sigc::mem_fun(*this, &LPEBSpline::toDefaultWeight)); - buttons->pack_start(*defaultWeight, true, true, 2); - Gtk::Button *makeCusp = - Gtk::manage(new Gtk::Button(Glib::ustring(_("Make cusp")))); - makeCusp->signal_clicked() - .connect(sigc::mem_fun(*this, &LPEBSpline::toMakeCusp)); - buttons->pack_start(*makeCusp, true, true, 2); - vbox->pack_start(*buttons, true, true, 2); return dynamic_cast(vbox); } -void LPEBSpline::toDefaultWeight() { changeWeight(0.3334); } +void LPEBSpline::toDefaultWeight(Gtk::Widget *widgWeight) { + weight.param_set_value(0.3334); + changeWeight(0.3334); + Gtk::HBox * scalarParameter = dynamic_cast(widgWeight); + std::vector< Gtk::Widget* > childList = scalarParameter->get_children(); + Gtk::Entry* entryWidg = dynamic_cast(childList[1]); + entryWidg->set_text("0.3334"); +} -void LPEBSpline::toMakeCusp() { changeWeight(0.0000); } +void LPEBSpline::toMakeCusp(Gtk::Widget *widgWeight) { + weight.param_set_value(0.0000); + changeWeight(0.0000); + Gtk::HBox * scalarParameter = dynamic_cast(widgWeight); + std::vector< Gtk::Widget* > childList = scalarParameter->get_children(); + Gtk::Entry* entryWidg = dynamic_cast(childList[1]); + entryWidg->set_text("0.0000"); +} void LPEBSpline::toWeight() { changeWeight(weight); } diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index 167810c49..aff4ce812 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -34,9 +34,9 @@ public: virtual void changeWeight(double weightValue); - virtual void toDefaultWeight(); + virtual void toDefaultWeight(Gtk::Widget *widgWeight); - virtual void toMakeCusp(); + virtual void toMakeCusp(Gtk::Widget *widgWeight); virtual void toWeight(); -- cgit v1.2.3 From 5a8b00f027b9eb3d4abb290d2ddf26d36d71cf80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20dos=20Santos=20Oliveira?= Date: Mon, 5 May 2014 04:13:35 -0300 Subject: Enabling path manipulator to comunicate if paths are bspline when accessing const objects. This change was required to correctly show on the GUI whether or not a node was a bspline. (bzr r11950.8.1) --- src/live_effects/effect.h | 1 + src/sp-lpe-item.cpp | 16 ++++++++++++++++ src/sp-lpe-item.h | 1 + src/ui/tool/node.cpp | 8 +------- src/ui/tool/node.h | 6 ++++++ src/ui/tool/path-manipulator.cpp | 12 ++++++++---- src/ui/tool/path-manipulator.h | 3 ++- 7 files changed, 35 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index 1da9b4cc9..940770616 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -101,6 +101,7 @@ public: Inkscape::XML::Node * getRepr(); SPDocument * getSPDoc(); LivePathEffectObject * getLPEObj() {return lpeobj;}; + LivePathEffectObject const * getLPEObj() const {return lpeobj;}; Parameter * getParameter(const char * key); void readallParameters(Inkscape::XML::Node const* repr); diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index f59bc33ee..33359727a 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -606,6 +606,22 @@ SPLPEItem::getPathEffectOfType(int type) return NULL; } +Inkscape::LivePathEffect::Effect const* +SPLPEItem::getPathEffectOfType(int type) const +{ + std::list::const_iterator i; + for (i = path_effect_list->begin(); i != path_effect_list->end(); ++i) { + LivePathEffectObject const *lpeobj = (*i)->lpeobject; + if (lpeobj) { + Inkscape::LivePathEffect::Effect const *lpe = lpeobj->get_lpe(); + if (lpe && (lpe->effectType() == type)) { + return lpe; + } + } + } + return NULL; +} + void SPLPEItem::editNextParamOncanvas(SPDesktop *dt) { Inkscape::LivePathEffect::LPEObjectReference *lperef = this->getCurrentLPEReference(); diff --git a/src/sp-lpe-item.h b/src/sp-lpe-item.h index cd72ac55b..85878a95b 100644 --- a/src/sp-lpe-item.h +++ b/src/sp-lpe-item.h @@ -77,6 +77,7 @@ public: bool hasPathEffectOfType(int const type) const; bool hasPathEffectRecursive() const; Inkscape::LivePathEffect::Effect* getPathEffectOfType(int type); + Inkscape::LivePathEffect::Effect const* getPathEffectOfType(int type) const; bool hasBrokenPathEffect() const; PathEffectList getEffectList(); diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 7ba69b039..6cb254b7f 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -1421,13 +1421,7 @@ Node *Node::nodeAwayFrom(Handle *h) Glib::ustring Node::_getTip(unsigned state) const { - - /* if the node doesnt have strength, it marks it as bspline, we'll use it later - to show the appropiate messages. We cannot do it in any other way, because the - function is constant */ - bool isBSpline = false; - //if( this->bsplineWeight != 0.0000) - // isBSpline = true; + bool isBSpline = _pm().isBSpline(); if (state_held_shift(state)) { bool can_drag_out = (_next() && _front.isDegenerate()) || (_prev() && _back.isDegenerate()); if (can_drag_out) { diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h index 202dbb3cd..415563a7d 100644 --- a/src/ui/tool/node.h +++ b/src/ui/tool/node.h @@ -217,6 +217,7 @@ public: Node *nodeAwayFrom(Handle *h); NodeList &nodeList() { return *(static_cast(this)->ln_list); } + NodeList &nodeList() const { return *(static_cast(this)->ln_list); } /** * Move the node to the bottom of its canvas group. @@ -263,6 +264,7 @@ private: Inkscape::SnapSourceType _snapSourceType() const; Inkscape::SnapTargetType _snapTargetType() const; inline PathManipulator &_pm(); + inline PathManipulator &_pm() const; /** Determine whether two nodes are joined by a linear segment. */ static bool _is_line_segment(Node *first, Node *second); @@ -494,6 +496,10 @@ inline PathManipulator &Node::_pm() { return nodeList().subpathList().pm(); } +inline PathManipulator &Node::_pm() const { + return nodeList().subpathList().pm(); +} + // definitions for node iterator template NodeIterator::operator bool() const { diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 487c31b10..3beeed049 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1181,14 +1181,14 @@ void PathManipulator::_createControlPointsFromGeometry() } //determines if the trace has a bspline effect and the number of steps that it takes -int PathManipulator::BSplineGetSteps(){ +int PathManipulator::BSplineGetSteps() const { - LivePathEffect::LPEBSpline *lpe_bsp = NULL; + LivePathEffect::LPEBSpline const *lpe_bsp = NULL; if (SP_IS_LPE_ITEM(_path) && _path->hasPathEffect()){ - Inkscape::LivePathEffect::Effect* thisEffect = SP_LPE_ITEM(_path)->getPathEffectOfType(Inkscape::LivePathEffect::BSPLINE); + Inkscape::LivePathEffect::Effect const *thisEffect = SP_LPE_ITEM(_path)->getPathEffectOfType(Inkscape::LivePathEffect::BSPLINE); if(thisEffect){ - lpe_bsp = dynamic_cast(thisEffect->getLPEObj()->get_lpe()); + lpe_bsp = dynamic_cast(thisEffect->getLPEObj()->get_lpe()); } } int steps = 0; @@ -1206,6 +1206,10 @@ bool PathManipulator::isBSpline(bool recalculate){ return _is_bspline; } +bool PathManipulator::isBSpline() const { + return BSplineGetSteps() > 0; +} + // returns the corresponding strength to the position of the handlers double PathManipulator::BSplineHandlePosition(Handle *h, Handle *h2){ using Geom::X; diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index a85664ddf..151805c83 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -96,7 +96,7 @@ public: NodeList::iterator extremeNode(NodeList::iterator origin, bool search_selected, bool search_unselected, bool closest); - int BSplineGetSteps(); + int BSplineGetSteps() const; // this is necessary for Tab-selection in MultiPathManipulator SubpathList &subpathList() { return _subpaths; } @@ -108,6 +108,7 @@ private: void _createControlPointsFromGeometry(); bool isBSpline(bool recalculate = false); + bool isBSpline() const; double BSplineHandlePosition(Handle *h, Handle *h2 = NULL); Geom::Point BSplineHandleReposition(Handle *h, Handle *h2 = NULL); Geom::Point BSplineHandleReposition(Handle *h, double pos); -- cgit v1.2.3 From 77ec197912229a64495bda39ac0b0943580baaaf Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 5 May 2014 11:50:39 +0200 Subject: adding const _pathmanipulatos staff to handles (handles also have tips) (bzr r11950.1.341) --- src/ui/tool/node.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h index 415563a7d..5971956e1 100644 --- a/src/ui/tool/node.h +++ b/src/ui/tool/node.h @@ -131,6 +131,7 @@ protected: private: inline PathManipulator &_pm(); + inline PathManipulator &_pm() const; Node *_parent; // the handle's lifetime does not extend beyond that of the parent node, // so a naked pointer is OK and allows setting it during Node's construction SPCtrlLine *_handle_line; @@ -492,6 +493,9 @@ inline double Handle::length() const { inline PathManipulator &Handle::_pm() { return _parent->_pm(); } +inline PathManipulator &Handle::_pm() const { + return _parent->_pm(); +} inline PathManipulator &Node::_pm() { return nodeList().subpathList().pm(); } -- cgit v1.2.3