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/ui/tools/pen-tool.cpp') 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 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/ui/tools/pen-tool.cpp | 74 +++++++++-------------------------------------- 1 file changed, 13 insertions(+), 61 deletions(-) (limited to 'src/ui/tools/pen-tool.cpp') 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 : - - -- 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 ++++++++++++++++------------------------------ 1 file changed, 53 insertions(+), 97 deletions(-) (limited to 'src/ui/tools/pen-tool.cpp') 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; -- 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/tools/pen-tool.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'src/ui/tools/pen-tool.cpp') 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 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/ui/tools/pen-tool.cpp') 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 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/pen-tool.cpp | 50 +++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 23 deletions(-) (limited to 'src/ui/tools/pen-tool.cpp') 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 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 +++++++++++++++------------------------------- 1 file changed, 38 insertions(+), 84 deletions(-) (limited to 'src/ui/tools/pen-tool.cpp') 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(); -- 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/pen-tool.cpp | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'src/ui/tools/pen-tool.cpp') 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/ui/tools/pen-tool.cpp') 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/ui/tools/pen-tool.cpp') 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/tools/pen-tool.cpp | 67 ++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 36 deletions(-) (limited to 'src/ui/tools/pen-tool.cpp') 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; -- 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/tools/pen-tool.cpp | 67 +++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 31 deletions(-) (limited to 'src/ui/tools/pen-tool.cpp') 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; -- 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/tools/pen-tool.cpp | 67 ++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 36 deletions(-) (limited to 'src/ui/tools/pen-tool.cpp') 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; -- 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/ui/tools/pen-tool.cpp') 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 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/ui/tools/pen-tool.cpp') 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/pen-tool.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/ui/tools/pen-tool.cpp') 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/pen-tool.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/ui/tools/pen-tool.cpp') 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; -- 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/ui/tools/pen-tool.cpp') 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 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/pen-tool.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/ui/tools/pen-tool.cpp') 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; -- 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/pen-tool.cpp | 169 ++++++++++++++++++++++------------------------ 1 file changed, 82 insertions(+), 87 deletions(-) (limited to 'src/ui/tools/pen-tool.cpp') 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 8dbf7bd73db6bb549b3e0be3fba91cddfcb589b8 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 13 May 2014 07:35:50 +0200 Subject: Fixed a bug in bspline with snaps and 1 sice segments. Pointed by LiamW (bzr r13341.1.12) --- src/ui/tools/pen-tool.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'src/ui/tools/pen-tool.cpp') diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 9e4df5031..386dc43e9 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -1811,9 +1811,9 @@ void PenTool::_bspline_spiro_build() void PenTool::_bspline_doEffect(SPCurve * curve) { // 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(); + if (curve->get_segment_count() < 1) + return; curve->reset(); for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { @@ -1890,9 +1890,25 @@ void PenTool::_bspline_doEffect(SPCurve * curve) ++curve_it1; ++curve_it2; } + SPCurve *out = new SPCurve(); + out->moveto(curve_it1->initialPoint()); + out->lineto(curve_it1->finalPoint()); + cubic = dynamic_cast(&*curve_it1); + 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; SPCurve *curveHelper = new SPCurve(); curveHelper->moveto(node); - Geom::Point startNode(0,0); + Geom::Point startNode = path_it->begin()->initialPoint(); if (path_it->closed()) { SPCurve * start = new SPCurve(); start->moveto(path_it->begin()->initialPoint()); -- cgit v1.2.3 From 1fbcbe105b22951f565dd6ddecce3ceeb9e55a36 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 10 Jun 2014 00:12:02 +0200 Subject: fix a bug on spirolive close path (bzr r13341.1.55) --- src/ui/tools/pen-tool.cpp | 56 ++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 27 deletions(-) (limited to 'src/ui/tools/pen-tool.cpp') diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 386dc43e9..f8243fb7f 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -1556,12 +1556,11 @@ void PenTool::_bspline_spiro_start_anchor_off() //and we add it again with the recreation tmpCurve->append_continuous(lastSeg, 0.0625); } - if (this->sa->start) { - tmpCurve = tmpCurve->create_reverse(); - } - this->overwriteCurve = tmpCurve; } - + if (this->sa->start) { + tmpCurve = tmpCurve->create_reverse(); + } + this->overwriteCurve = tmpCurve; } void PenTool::_bspline_spiro_motion(bool shift){ @@ -1645,7 +1644,7 @@ void PenTool::_bspline_spiro_end_anchor_on() } reverse = true; } else if(this->sa){ - tmpCurve = this->overwriteCurve; + tmpCurve = this->overwriteCurve->copy(); if(!this->sa->start){ tmpCurve = tmpCurve->create_reverse(); reverse = true; @@ -1665,7 +1664,7 @@ void PenTool::_bspline_spiro_end_anchor_on() 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()); + lastSeg->lineto(tmpCurve->last_segment()->finalPoint()); } if( tmpCurve->get_segment_count() == 1){ tmpCurve = lastSeg; @@ -1702,7 +1701,7 @@ void PenTool::_bspline_spiro_end_anchor_off() } reverse = true; } else if(this->sa){ - tmpCurve = this->overwriteCurve; + tmpCurve = this->overwriteCurve->copy(); if(!this->sa->start){ tmpCurve = tmpCurve->create_reverse(); reverse = true; @@ -1714,25 +1713,28 @@ void PenTool::_bspline_spiro_end_anchor_off() 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{ - this->overwriteCurve->reset(); - this->overwriteCurve = tmpCurve; - } + }else{ + lastSeg->moveto(tmpCurve->last_segment()->initialPoint()); + lastSeg->lineto(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{ + this->overwriteCurve->reset(); + this->overwriteCurve = tmpCurve; } } -- cgit v1.2.3 From b2ae5212d7df04a0b973571748d402d5663312d6 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Wed, 11 Jun 2014 23:53:17 +0200 Subject: pen tool: fix crash when finishing path with right-click or enter while dragging from path's startnode (otherwise closing the path) Fixed bugs: - https://launchpad.net/bugs/1326652 (bzr r13422) --- src/ui/tools/pen-tool.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/ui/tools/pen-tool.cpp') diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 09c0a2a4f..b089065e8 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -481,6 +481,7 @@ bool PenTool::_handleButtonPress(GdkEventButton const &bevent) { ret = true; } else if (bevent.button == 3 && this->npoints != 0) { // right click - finish path + this->ea = NULL; // unset end anchor if set (otherwise crashes) this->_finish(false); ret = true; } @@ -1018,6 +1019,7 @@ bool PenTool::_handleKeyPress(GdkEvent *event) { case GDK_KEY_Return: case GDK_KEY_KP_Enter: if (this->npoints != 0) { + this->ea = NULL; // unset end anchor if set (otherwise crashes) this->_finish(false); ret = true; } -- cgit v1.2.3 From 6351d4ea2ea398e0096c14b3ba57ca28dfd2f8a3 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Tue, 1 Jul 2014 23:58:08 +0200 Subject: Fix pentool backspace bug. Thanks Jabier Fixed bugs: - https://launchpad.net/bugs/1336561 (bzr r13445) --- src/ui/tools/pen-tool.cpp | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'src/ui/tools/pen-tool.cpp') diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index b089065e8..70cbcaf0d 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -55,15 +55,15 @@ static bool pen_within_tolerance = false; static int pen_last_paraxial_dir = 0; // last used direction in horizontal/vertical mode; 0 = horizontal, 1 = vertical namespace { - ToolBase* createPenContext() { - return new PenTool(); - } + ToolBase* createPenContext() { + return new PenTool(); + } - bool penContextRegistered = ToolFactory::instance().registerObject("/tools/freehand/pen", createPenContext); + bool penContextRegistered = ToolFactory::instance().registerObject("/tools/freehand/pen", createPenContext); } const std::string& PenTool::getPrefsPath() { - return PenTool::prefsPath; + return PenTool::prefsPath; } const std::string PenTool::prefsPath = "/tools/freehand/pen"; @@ -277,7 +277,7 @@ bool PenTool::item_handler(SPItem* item, GdkEvent* event) { } if (!ret) { - ret = FreehandBase::item_handler(item, event); + ret = FreehandBase::item_handler(item, event); } return ret; @@ -315,7 +315,7 @@ bool PenTool::root_handler(GdkEvent* event) { } if (!ret) { - ret = FreehandBase::root_handler(event); + ret = FreehandBase::root_handler(event); } return ret; @@ -1061,8 +1061,9 @@ bool PenTool::_handleKeyPress(GdkEvent *event) { this->red_curve->reset(); // Destroy topmost green bpath if (this->green_bpaths) { - if (this->green_bpaths->data) + if (this->green_bpaths->data) { sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data)); + } this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data); } // Get last segment @@ -1078,11 +1079,21 @@ bool PenTool::_handleKeyPress(GdkEvent *event) { } else { this->p[1] = this->p[0]; } - Geom::Point const pt(( this->npoints < 4 - ? (Geom::Point)(crv->finalPoint()) - : this->p[3] )); + Geom::Point const pt( (this->npoints < 4) ? crv->finalPoint() : this->p[3] ); this->npoints = 2; - this->green_curve->backspace(); + // delete the last segment of the green curve + if (this->green_curve->get_segment_count() == 1) { + this->npoints = 5; + if (this->green_bpaths) { + if (this->green_bpaths->data) { + sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data)); + } + this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data); + } + this->green_curve->reset(); + } else { + this->green_curve->backspace(); + } sp_canvas_item_hide(this->c0); sp_canvas_item_hide(this->c1); sp_canvas_item_hide(this->cl0); -- cgit v1.2.3 From 77934815e32b73477fc5e7b19e61de702a303fd5 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Wed, 2 Jul 2014 00:13:46 +0200 Subject: pen tool: add back removal of curvature handle when backspace-deleting a node while drawing many code improvements: unnecessary casts, whitespace, { }, reduce variable scope. should all be noops. (bzr r13341.1.73) --- src/ui/tools/pen-tool.cpp | 61 +++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 29 deletions(-) (limited to 'src/ui/tools/pen-tool.cpp') diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 0d8a2668b..aead3ebc0 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -958,40 +958,42 @@ void PenTool::_lastpointToCurve() { // 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()); + + this->p[1] = this->red_curve->last_segment()->initialPoint() + (1./3.)*(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 - if(this->spiro||this->bspline){ - if(!this->green_curve->is_empty()){ + if (this->spiro||this->bspline) { + if (!this->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( this->green_curve->last_segment() ); + Geom::CubicBezier const *cubic = dynamic_cast( this->green_curve->last_segment() ); //We obtain the last segment 4 points in the previous curve if ( cubic ){ A = (*cubic)[0]; B = (*cubic)[1]; - if(this->spiro){ - C = this->p[0] + (Geom::Point)(this->p[0] - this->p[1]); - }else - C = this->green_curve->last_segment()->finalPoint() + (1./3)* (Geom::Point)(this->green_curve->last_segment()->initialPoint() - this->green_curve->last_segment()->finalPoint()); + if (this->spiro) { + C = this->p[0] + (this->p[0] - this->p[1]); + } else { + C = this->green_curve->last_segment()->finalPoint() + (1./3.)*(this->green_curve->last_segment()->initialPoint() - this->green_curve->last_segment()->finalPoint()); + } D = (*cubic)[3]; - }else{ + } else { A = this->green_curve->last_segment()->initialPoint(); B = this->green_curve->last_segment()->initialPoint(); - if(this->spiro) - C = this->p[0] + (Geom::Point)(this->p[0] - this->p[1]); - else - C = this->green_curve->last_segment()->finalPoint() + (1./3)* (Geom::Point)(this->green_curve->last_segment()->initialPoint() - this->green_curve->last_segment()->finalPoint()); + if (this->spiro) { + C = this->p[0] + (this->p[0] - this->p[1]); + } else { + C = this->green_curve->last_segment()->finalPoint() + (1./3.)*(this->green_curve->last_segment()->initialPoint() - this->green_curve->last_segment()->finalPoint()); + } D = this->green_curve->last_segment()->finalPoint(); } + SPCurve *previous = new SPCurve(); previous->moveto(A); previous->curveto(B, C, D); - if( this->green_curve->get_segment_count() == 1){ + if ( this->green_curve->get_segment_count() == 1) { this->green_curve = previous; - }else{ + } else { //we eliminate the last segment this->green_curve->backspace(); //and we add it again with the recreation @@ -999,7 +1001,7 @@ void PenTool::_lastpointToCurve() { } } //if the last node is an union with another curve - if(this->green_curve->is_empty() && this->sa && !this->sa->curve->is_empty()){ + if (this->green_curve->is_empty() && this->sa && !this->sa->curve->is_empty()) { this->_bspline_spiro_start_anchor(false); } } @@ -1242,12 +1244,12 @@ bool PenTool::_handleKeyPress(GdkEvent *event) { } } else { // Reset red curve - Geom::CubicBezier const * cubic = NULL; this->red_curve->reset(); // Destroy topmost green bpath if (this->green_bpaths) { - if (this->green_bpaths->data) + if (this->green_bpaths->data) { sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data)); + } this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data); } // Get last segment @@ -1270,17 +1272,16 @@ bool PenTool::_handleKeyPress(GdkEvent *event) { this->p[1] = this->p[0] + (1./3)*(this->p[3] - this->p[0]); } - Geom::Point const pt((this->npoints < 4 - ? (Geom::Point)(crv->finalPoint()) - : this->p[3])); + Geom::Point const pt( (this->npoints < 4) ? crv->finalPoint() : this->p[3] ); this->npoints = 2; // delete the last segment of the green curve if( this->green_curve->get_segment_count() == 1){ this->npoints = 5; if (this->green_bpaths) { - if (this->green_bpaths->data) + if (this->green_bpaths->data) { sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data)); + } this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data); } this->green_curve->reset(); @@ -1289,14 +1290,16 @@ bool PenTool::_handleKeyPress(GdkEvent *event) { } // 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()); + Geom::CubicBezier const *cubic = dynamic_cast(this->green_curve->last_segment()); if ( cubic ) { - this->p[1] = (*cubic)[3] + (Geom::Point)((*cubic)[3] - (*cubic)[2]); + this->p[1] = (*cubic)[3] + (*cubic)[3] - (*cubic)[2]; SP_CTRL(this->c1)->moveto(this->p[0]); } else { this->p[1] = this->p[0]; } } + sp_canvas_item_hide(this->c0); + sp_canvas_item_hide(this->c1); sp_canvas_item_hide(this->cl0); sp_canvas_item_hide(this->cl1); this->state = PenTool::POINT; @@ -1607,7 +1610,7 @@ void PenTool::_bspline_spiro_motion(bool shift){ if(shift) this->p[2] = this->p[3]; }else{ - this->p[1] = (*cubic)[3] + (Geom::Point)((*cubic)[3] - (*cubic)[2] ); + this->p[1] = (*cubic)[3] + ((*cubic)[3] - (*cubic)[2] ); this->p[1] = Geom::Point(this->p[1][X] + 0.005,this->p[1][Y] + 0.005); } }else{ @@ -1659,7 +1662,7 @@ void PenTool::_bspline_spiro_end_anchor_on() 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] ); + C = this->p[3] + this->p[3] - this->p[2]; } if(cubic){ lastSeg->moveto((*cubic)[0]); @@ -2164,7 +2167,7 @@ void PenTool::_finishSegment(Geom::Point const p, guint const state) { pen_last_paraxial_dir = this->nextParaxialDirection(p, this->p[0], state); } - ++this->num_clicks; + ++num_clicks; if (!this->red_curve->is_empty()) { -- cgit v1.2.3 From 9b1d9867e9cfbf56b44e8a996a4ccf2e7f288b87 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 22 Jul 2014 02:29:52 +0200 Subject: fix bug pointed by LiamW in Spirolive (bzr r13341.1.94) --- src/ui/tools/pen-tool.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/ui/tools/pen-tool.cpp') diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index aead3ebc0..56bcbef0d 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -1611,7 +1611,6 @@ void PenTool::_bspline_spiro_motion(bool shift){ this->p[2] = this->p[3]; }else{ this->p[1] = (*cubic)[3] + ((*cubic)[3] - (*cubic)[2] ); - this->p[1] = Geom::Point(this->p[1][X] + 0.005,this->p[1][Y] + 0.005); } }else{ this->p[1] = this->p[0]; -- cgit v1.2.3 From b178124078314b78baca08fb65e12cc894242d3a Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 22 Jul 2014 21:16:13 +0200 Subject: Replaced some abs/fabs with std::abs. (bzr r13459) --- src/ui/tools/pen-tool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/tools/pen-tool.cpp') diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 70cbcaf0d..649c64034 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -1185,7 +1185,7 @@ void PenTool::_setSubsequentPoint(Geom::Point const p, bool statusbar, guint sta // we are drawing horizontal/vertical lines and hit an anchor; Geom::Point const origin = this->p[0]; // if the previous point and the anchor are not aligned either horizontally or vertically... - if ((abs(p[Geom::X] - origin[Geom::X]) > 1e-9) && (abs(p[Geom::Y] - origin[Geom::Y]) > 1e-9)) { + if ((std::abs(p[Geom::X] - origin[Geom::X]) > 1e-9) && (std::abs(p[Geom::Y] - origin[Geom::Y]) > 1e-9)) { // ...then we should draw an L-shaped path, consisting of two paraxial segments Geom::Point intermed = p; this->_setToNearestHorizVert(intermed, status, false); -- cgit v1.2.3 From b2842360758b2333a651ef9932c1e438e90628e3 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 4 Aug 2014 11:21:54 +0200 Subject: Fixed some redraw problems moving nodes in bspline mode (bzr r13341.1.115) --- src/ui/tools/pen-tool.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/ui/tools/pen-tool.cpp') diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index d826eaf48..9a73d497f 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -84,7 +84,7 @@ namespace Tools { 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 - +const double handleCubicGap = 0.01; namespace { ToolBase* createPenContext() { return new PenTool(); @@ -1454,7 +1454,7 @@ void PenTool::_bspline_spiro_on() this->p[0] = this->red_curve->first_segment()->initialPoint(); this->p[3] = this->red_curve->first_segment()->finalPoint(); this->p[2] = this->p[3] + (1./3)*(this->p[0] - this->p[3]); - this->p[2] = Geom::Point(this->p[2][X] + 0.005,this->p[2][Y] + 0.005); + this->p[2] = Geom::Point(this->p[2][X] + handleCubicGap,this->p[2][Y] + handleCubicGap); } } @@ -1522,7 +1522,7 @@ void PenTool::_bspline_spiro_start_anchor_on() 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.005,C[Y] + 0.005); + C = Geom::Point(C[X] + handleCubicGap,C[Y] + handleCubicGap); if(cubic){ lastSeg->moveto(A); lastSeg->curveto((*cubic)[1],C,D); @@ -1580,10 +1580,10 @@ void PenTool::_bspline_spiro_motion(bool shift){ this->npoints = 5; SPCurve *tmpCurve = new SPCurve(); this->p[2] = this->p[3] + (1./3)*(this->p[0] - this->p[3]); - this->p[2] = Geom::Point(this->p[2][X] + 0.005,this->p[2][Y] + 0.005); + this->p[2] = Geom::Point(this->p[2][X] + handleCubicGap,this->p[2][Y] + handleCubicGap); if(this->green_curve->is_empty() && !this->sa){ this->p[1] = this->p[0] + (1./3)*(this->p[3] - this->p[0]); - this->p[1] = Geom::Point(this->p[1][X] + 0.005,this->p[1][Y] + 0.005); + this->p[1] = Geom::Point(this->p[1][X] + handleCubicGap,this->p[1][Y] + handleCubicGap); }else if(!this->green_curve->is_empty()){ tmpCurve = this->green_curve->copy(); }else{ @@ -1608,7 +1608,7 @@ void PenTool::_bspline_spiro_motion(bool shift){ WPower->reset(); this->p[1] = SBasisWPower.valueAt(WP); if(!Geom::are_near(this->p[1],this->p[0])) - this->p[1] = Geom::Point(this->p[1][X] + 0.005,this->p[1][Y] + 0.005); + this->p[1] = Geom::Point(this->p[1][X] + handleCubicGap,this->p[1][Y] + handleCubicGap); if(shift) this->p[2] = this->p[3]; }else{ @@ -1638,7 +1638,7 @@ void PenTool::_bspline_spiro_end_anchor_on() using Geom::X; using Geom::Y; this->p[2] = this->p[3] + (1./3)*(this->p[0] - this->p[3]); - this->p[2] = Geom::Point(this->p[2][X] + 0.005,this->p[2][Y] + 0.005); + this->p[2] = Geom::Point(this->p[2][X] + handleCubicGap,this->p[2][Y] + handleCubicGap); SPCurve *tmpCurve = new SPCurve(); SPCurve *lastSeg = new SPCurve(); Geom::Point C(0,0); @@ -1661,7 +1661,7 @@ void PenTool::_bspline_spiro_end_anchor_on() 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); + C = Geom::Point(C[X] + handleCubicGap,C[Y] + handleCubicGap); }else{ C = this->p[3] + this->p[3] - this->p[2]; } -- cgit v1.2.3 From d59ab0cc036239f5e2f6040b2f439ba7b55af4c3 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Fri, 8 Aug 2014 09:47:46 -0400 Subject: Ponyscape feature: finish pen drawing on context switch (bzr r13090.1.101) --- src/ui/tools/pen-tool.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/ui/tools/pen-tool.cpp') diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 9a73d497f..318591df5 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -239,7 +239,9 @@ void PenTool::finish() { sp_event_context_discard_delayed_snap_event(this); if (this->npoints != 0) { - this->_cancel(); + // switching context - finish path + this->ea = NULL; // unset end anchor if set (otherwise crashes) + this->_finish(false); } FreehandBase::finish(); -- cgit v1.2.3 From 0403ae2f0f76e56b31e369160648968671324d13 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 16 Sep 2014 01:07:32 +0200 Subject: fixing cusp node bug on bspline -problems moving nodes because tiny handles (bzr r13341.1.209) --- src/ui/tools/pen-tool.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/ui/tools/pen-tool.cpp') diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 318591df5..b68231e10 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -1586,6 +1586,9 @@ void PenTool::_bspline_spiro_motion(bool shift){ if(this->green_curve->is_empty() && !this->sa){ this->p[1] = this->p[0] + (1./3)*(this->p[3] - this->p[0]); this->p[1] = Geom::Point(this->p[1][X] + handleCubicGap,this->p[1][Y] + handleCubicGap); + if(shift){ + this->p[2] = this->p[3]; + } }else if(!this->green_curve->is_empty()){ tmpCurve = this->green_curve->copy(); }else{ @@ -1609,8 +1612,11 @@ void PenTool::_bspline_spiro_motion(bool shift){ SBasisWPower = WPower->first_segment()->toSBasis(); WPower->reset(); this->p[1] = SBasisWPower.valueAt(WP); - if(!Geom::are_near(this->p[1],this->p[0])) + if(!Geom::are_near(this->p[1],this->p[0])){ this->p[1] = Geom::Point(this->p[1][X] + handleCubicGap,this->p[1][Y] + handleCubicGap); + } else { + this->p[1] = this->p[0]; + } if(shift) this->p[2] = this->p[3]; }else{ -- cgit v1.2.3 From fb4d4b30b50b7b4505d63772c0aeca4c05c2c5c6 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 22 Sep 2014 21:15:47 +0200 Subject: Fix for strange gap at shift to cusp in bspline Now curves with cusp noden in bspline mode looks better, more smooth. Remove some duplicate code from outside for loops Fix a bug continuing shapes in bspline-spiro mode. Style code formating (bzr r13341.1.215) --- src/ui/tools/pen-tool.cpp | 232 ++++++++++++++++++++++------------------------ 1 file changed, 111 insertions(+), 121 deletions(-) (limited to 'src/ui/tools/pen-tool.cpp') diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index b68231e10..a72934ae3 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -1827,155 +1827,145 @@ void PenTool::_bspline_spiro_build() void PenTool::_bspline_doEffect(SPCurve * curve) { // commenting the function doEffect in src/live_effects/lpe-bspline.cpp - Geom::PathVector const original_pathv = curve->get_pathvector(); - if (curve->get_segment_count() < 1) + if (curve->get_segment_count() < 1){ return; + } + // Make copy of old path as it is changed during processing + Geom::PathVector const original_pathv = curve->get_pathvector(); curve->reset(); - for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { + //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 + 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(); 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::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::D2 SBasisIn; + Geom::D2 SBasisOut; + Geom::D2 SBasisHelper; Geom::CubicBezier const *cubic = NULL; if (path_it->closed()) { - 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(); // the closing line segment is always of type if (are_near(closingline.initialPoint(), closingline.finalPoint())) { curve_endit = path_it->end_open(); } } - while ( curve_it2 != curve_endit ) - { - SPCurve * in = new SPCurve(); + nCurve->moveto(curve_it1->initialPoint()); + while (curve_it1 != curve_endit) { + SPCurve *in = new SPCurve(); in->moveto(curve_it1->initialPoint()); in->lineto(curve_it1->finalPoint()); - cubic = dynamic_cast(&*curve_it1); - if(cubic){ + 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{ + if(are_near((*cubic)[1],(*cubic)[0]) && !are_near((*cubic)[2],(*cubic)[3])) { + pointAt1 = SBasisIn.valueAt(0.3334); + } else { + pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[1], *in->first_segment())); + } + if(are_near((*cubic)[2],(*cubic)[3]) && !are_near((*cubic)[1],(*cubic)[0])) { + pointAt2 = SBasisIn.valueAt(0.6667); + } else { + 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; - 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 = (*cubic)[3]; - }else{ - nextPointAt1 = out->first_segment()->initialPoint(); - nextPointAt2 = out->first_segment()->finalPoint(); - nextPointAt3 = out->first_segment()->finalPoint(); + if ( curve_it2 != curve_endit ) { + 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(); + if(are_near((*cubic)[1],(*cubic)[0]) && !are_near((*cubic)[2],(*cubic)[3])) { + nextPointAt1 = SBasisIn.valueAt(0.3334); + } else { + nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[1], *out->first_segment())); + } + } else { + nextPointAt1 = out->first_segment()->initialPoint(); + } + out->reset(); + delete out; + } + Geom::Point startNode = path_it->begin()->initialPoint(); + if (path_it->closed() && curve_it2 == curve_endit) { + 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(); + 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(pointAt1, pointAt2, startNode); + nCurve->move_endpoints(startNode, startNode); + } else if ( curve_it2 == curve_endit) { + nCurve->curveto(pointAt1, pointAt2, curve_it1->finalPoint()); + nCurve->move_endpoints(path_it->begin()->initialPoint(), curve_it1->finalPoint()); + } else { + SPCurve *lineHelper = new SPCurve(); + lineHelper->moveto(pointAt2); + lineHelper->lineto(nextPointAt1); + SBasisHelper = lineHelper->first_segment()->toSBasis(); + lineHelper->reset(); + delete lineHelper; + previousNode = node; + node = SBasisHelper.valueAt(0.5); + Geom::CubicBezier const *cubic2 = dynamic_cast(&*curve_it1); + if((cubic && are_near((*cubic)[0],(*cubic)[1])) || (cubic2 && are_near((*cubic2)[2],(*cubic2)[3]))) { + node = curve_it1->finalPoint(); + } + nCurve->curveto(pointAt1, pointAt2, node); } - out->reset(); - delete out; - SPCurve *lineHelper = new SPCurve(); - lineHelper->moveto(pointAt2); - lineHelper->lineto(nextPointAt1); - SBasisHelper = lineHelper->first_segment()->toSBasis(); - lineHelper->reset(); - delete lineHelper; - previousNode = node; - node = SBasisHelper.valueAt(0.5); - SPCurve *curveHelper = new SPCurve(); - curveHelper->moveto(previousNode); - curveHelper->curveto(pointAt1, pointAt2, node); - nCurve->append_continuous(curveHelper, 0.0625); - curveHelper->reset(); - delete curveHelper; ++curve_it1; ++curve_it2; } - SPCurve *out = new SPCurve(); - out->moveto(curve_it1->initialPoint()); - out->lineto(curve_it1->finalPoint()); - cubic = dynamic_cast(&*curve_it1); - 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; - SPCurve *curveHelper = new SPCurve(); - curveHelper->moveto(node); - Geom::Point startNode = path_it->begin()->initialPoint(); - 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; - - SPCurve * end = new SPCurve(); - end->moveto(curve_it1->initialPoint()); - end->lineto(curve_it1->finalPoint()); - Geom::D2< Geom::SBasis > SBasisEnd = end->first_segment()->toSBasis(); - 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); - curveHelper->curveto(nextPointAt1, nextPointAt2, startNode); - nCurve->append_continuous(curveHelper, 0.0625); - 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; - curveHelper->curveto(nextPointAt1, nextPointAt2, nextPointAt3); - nCurve->append_continuous(curveHelper, 0.0625); - nCurve->move_endpoints(startNode,nextPointAt3); - } - curveHelper->reset(); - delete curveHelper; if (path_it->closed()) { nCurve->closepath_current(); } - curve->append(nCurve,false); + curve->append(nCurve, false); nCurve->reset(); delete nCurve; } -- cgit v1.2.3 From f692482d773d75799712e8bd3c48d1da3d752a03 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 24 Sep 2014 03:27:47 +0200 Subject: Show the helper curves in pen tool with the color of the current layer defined in objects dialog (bzr r13341.1.220) --- src/ui/tools/pen-tool.cpp | 46 +++++++++++++++++----------------------------- 1 file changed, 17 insertions(+), 29 deletions(-) (limited to 'src/ui/tools/pen-tool.cpp') diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index a72934ae3..9a86dfe2c 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -188,7 +188,6 @@ void PenTool::_pen_context_set_mode(guint mode) { */ void PenTool::setup() { FreehandBase::setup(); - ControlManager &mgr = ControlManager::getManager(); // Pen indicators @@ -435,7 +434,7 @@ bool PenTool::_handleButtonPress(GdkEventButton const &bevent) { // This is allowed, if we just canceled curve case PenTool::POINT: if (this->npoints == 0) { - + this->_bspline_spiro_color(); Geom::Point p; if ((bevent.state & GDK_CONTROL_MASK) && (this->polylines_only || this->polylines_paraxial)) { p = event_dt; @@ -702,11 +701,9 @@ bool PenTool::_handleMotionNotify(GdkEventMotion const &mevent) { } // 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); }else{ 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; } @@ -746,6 +743,7 @@ bool PenTool::_handleButtonRelease(GdkEventButton const &revent) { case PenTool::POINT: if ( this->npoints == 0 ) { // Start new thread only with button release + this->_bspline_spiro_color(); if (anchor) { p = anchor->dp; } @@ -1387,42 +1385,32 @@ void PenTool::_setAngleDistanceStatusMessage(Geom::Point const p, int pc_point_t // 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; + static Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if(this->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(this->green_color != 0x00ff000){ - //We change the green and red colours to transparent, so this lines are not necessary - //to the drawing with spiro - this->red_color = 0xff00000; - this->green_color = 0x00ff000; - remake_green_bpaths = true; - } + this->red_color = 0xff00000; + this->green_color = 0x00ff000; }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->highlight_color = SP_ITEM(this->desktop->currentLayer())->highlight_color(); + if((unsigned int)prefs->getInt("/tools/nodes/highlight_color", 0xff0000ff) == this->highlight_color){ this->green_color = 0xff00007f; - remake_green_bpaths = true; + this->red_color = 0xff00007f; + } else { + this->green_color = this->highlight_color; + this->red_color = this->highlight_color; } }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){ - //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; + this->highlight_color = SP_ITEM(this->desktop->currentLayer())->highlight_color(); + this->red_color = 0xff00007f; + if((unsigned int)prefs->getInt("/tools/nodes/highlight_color", 0xff0000ff) == this->highlight_color){ this->green_color = 0x00ff007f; - remake_green_bpaths = true; + } else { + this->green_color = this->highlight_color; } - //we hide the spiro/bspline rests sp_canvas_item_hide(this->blue2_bpath); } //We erase all the "green_bpaths" to recreate them after with the colour //transparency recently modified - if (this->green_bpaths && remake_green_bpaths) { + if (this->green_bpaths) { // remove old piecewise green canvasitems while (this->green_bpaths) { sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data)); -- cgit v1.2.3 From 128c104aa13184648dbe91de0a2d1d4a71062938 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 24 Sep 2014 04:01:09 +0200 Subject: Change colors of helper paths also in middle draw when change the mode -spiro, bspline...- (bzr r13341.1.222) --- src/ui/tools/pen-tool.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/ui/tools/pen-tool.cpp') diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 9a86dfe2c..ecd10b068 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -181,6 +181,7 @@ void PenTool::_pen_context_set_mode(guint mode) { // define the nodes this->spiro = (mode == 1); this->bspline = (mode == 2); + this->_bspline_spiro_color(); } /** -- cgit v1.2.3 From 9cf38f99fc246131a2f2d9c3c55617488003b3b4 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 24 Sep 2014 04:56:55 +0200 Subject: A bit refactor, remove some old vars (bzr r13341.1.223) --- src/ui/tools/pen-tool.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/ui/tools/pen-tool.cpp') diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index ecd10b068..2c5ffc182 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -1327,9 +1327,6 @@ 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)); @@ -1407,7 +1404,7 @@ void PenTool::_bspline_spiro_color() } else { this->green_color = this->highlight_color; } - sp_canvas_item_hide(this->blue2_bpath); + sp_canvas_item_hide(this->blue_bpath); } //We erase all the "green_bpaths" to recreate them after with the colour //transparency recently modified @@ -1792,11 +1789,11 @@ void PenTool::_bspline_spiro_build() this->_spiro_doEffect(curve); } - 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); + 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); curve->unref(); - this->blue2_curve->reset(); + this->blue_curve->reset(); //We hide the holders that doesn't contribute anything if(this->spiro){ sp_canvas_item_show(this->c1); @@ -1808,7 +1805,7 @@ void PenTool::_bspline_spiro_build() sp_canvas_item_hide(this->cl0); }else{ //if the curve is empty - sp_canvas_item_hide(this->blue2_bpath); + sp_canvas_item_hide(this->blue_bpath); } } -- cgit v1.2.3 From 156cf3323a936c7dfccd9e09458cd8b5d174b7fe Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Sun, 5 Oct 2014 19:24:27 -0400 Subject: Move more UI code into ui/ (bzr r13341.1.253) --- src/ui/tools/pen-tool.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/ui/tools/pen-tool.cpp') diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 2c5ffc182..92937a135 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -26,7 +26,7 @@ #include "desktop-handles.h" #include "selection.h" #include "selection-chemistry.h" -#include "draw-anchor.h" +#include "ui/draw-anchor.h" #include "message-stack.h" #include "message-context.h" #include "preferences.h" @@ -40,7 +40,7 @@ #include #include "macros.h" #include "context-fns.h" -#include "tools-switch.h" +#include "ui/tools-switch.h" #include "ui/control-manager.h" // we include the necessary files for BSpline & Spiro #include "live_effects/effect.h" @@ -70,7 +70,7 @@ #include "live_effects/lpe-bspline.h" #include <2geom/nearest-point.h> -#include "tool-factory.h" +#include "ui/tool-factory.h" #include "live_effects/effect.h" -- cgit v1.2.3