diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2014-02-26 21:29:31 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2014-02-26 21:29:31 +0000 |
| commit | be22cb94d23816986838e9636ce44ee8537a8570 (patch) | |
| tree | b0652ef814d25a5b65450978aa42cd6f0100fb2e /src/ui | |
| parent | update to trunk (diff) | |
| download | inkscape-be22cb94d23816986838e9636ce44ee8537a8570.tar.gz inkscape-be22cb94d23816986838e9636ce44ee8537a8570.zip | |
Fixed some/all bugs related to continuing bspline/spiro curves advertaising by suv
(bzr r11950.1.257)
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/tools/freehand-base.cpp | 37 | ||||
| -rw-r--r-- | src/ui/tools/pen-tool.cpp | 50 |
2 files changed, 52 insertions, 35 deletions
diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 5e406a0d4..d8a8e901a 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -469,7 +469,7 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) { // Concat RBG SPCurve *c = dc->green_curve; - + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); // Green dc->green_curve = new SPCurve(); while (dc->green_bpaths) { @@ -490,12 +490,16 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(dc->red_bpath), NULL); if (c->is_empty()) { + if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ + SPDesktop *desktop = dc->desktop; + spdc_selection_modified(sp_desktop_selection(desktop), 0, dc); + } c->unref(); return; } // Step A - test, whether we ended on green anchor - if ( forceclosed || ( dc->green_anchor && dc->green_anchor->active ) ) { + if ( forceclosed || (dc->green_anchor && dc->green_anchor->active) ) { // We hit green anchor, closing Green-Blue-Red dc->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Path is closed.")); c->closepath_current(); @@ -513,21 +517,33 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) { // We hit bot start and end of single curve, closing paths dc->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Closing path.")); - if (dc->sa->start && !(dc->sa->curve->is_closed()) ) { - c = reverse_then_unref(c); + if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || + prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ + if (dc->sa->start && !(dc->sa->curve->is_closed()) ) { + dc->sa->curve = reverse_then_unref(dc->sa->curve); + } + dc->sa->curve->append_continuous(c, 0.0625); + c->unref(); + if(Geom::are_near(dc->sa->curve->first_path()->initialPoint(), dc->ea->dp)){ + dc->sa->curve->closepath_current(); + } + }else{ + if (dc->sa->start && !(dc->sa->curve->is_closed()) ) { + c = reverse_then_unref(c); + } + dc->sa->curve->append_continuous(c, 0.0625); + c->unref(); + dc->sa->curve->closepath_current(); } - dc->sa->curve->append_continuous(c, 0.0625); - c->unref(); - dc->sa->curve->closepath_current(); //spanish: Si la curva tiene un LPE del tipo bspline o spiro ejecutamos spdc_flush_white //pasándole la curva de inicio necesaria - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ dc->white_curves = g_slist_remove(dc->white_curves, dc->sa->curve); spdc_flush_white(dc, dc->sa->curve); - }else + }else{ spdc_flush_white(dc, NULL); + } return; } @@ -550,10 +566,7 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) c->append_continuous(e, 0.0625); e->unref(); } - - spdc_flush_white(dc, c); - c->unref(); } diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 8c13a0584..a344dc7a6 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -414,11 +414,18 @@ static gint pen_handle_button_press(PenTool *const pc, GdkEventButton const &bev ToolBase *event_context = SP_EVENT_CONTEXT(pc); //Test whether we hit any anchor. SPDrawAnchor * const anchor = spdc_test_inside(pc, event_w); + //with this we avoid creating a new point over the existing one - if(!bevent.button == 3 && (pc->spiro || pc->bspline) && pc->npoints > 0 && pc->p[0] == pc->p[3]){ + if(bevent.button != 3 && (pc->spiro || pc->bspline) && pc->npoints > 0 && pc->p[0] == pc->p[3]){ + pc->state = PenTool::STOP; + if( anchor && anchor == pc->sa && pc->green_curve->is_empty()){ + //spanish Borrar siguiente linea para evitar un nodo encima de otro + spdc_pen_finish_segment(pc, event_dt, bevent.state); + spdc_pen_finish(pc, FALSE); + return TRUE; + } return FALSE; } - gint ret = FALSE; if (bevent.button == 1 && !event_context->space_panning // make sure this is not the last click for a waiting LPE (otherwise we want to finish the path) @@ -486,7 +493,7 @@ static gint pen_handle_button_press(PenTool *const pc, GdkEventButton const &bev if(anchor){ bspline_spiro_start_anchor(pc,(bevent.state & GDK_SHIFT_MASK)); } - if (anchor && !sp_pen_context_has_waiting_LPE(pc)) { + if (anchor && (!sp_pen_context_has_waiting_LPE(pc) || pc->bspline || pc->spiro)) { // Adjust point to anchor if needed; if we have a waiting LPE, we need // a fresh path to be created so don't continue an existing one p = anchor->dp; @@ -755,7 +762,6 @@ static gint pen_handle_button_release(PenTool *const pc, GdkEventButton const &r } gint ret = FALSE; - ToolBase *event_context = SP_EVENT_CONTEXT(pc); if ( revent.button == 1 && !event_context->space_panning) { @@ -769,11 +775,10 @@ static gint pen_handle_button_release(PenTool *const pc, GdkEventButton const &r // Test whether we hit any anchor. SPDrawAnchor *anchor = spdc_test_inside(pc, event_w); //with this we avoid creating a new point over the existing one - if(pc->spiro || pc->bspline){ - //spanish: si intentamos crear un nodo en el mismo sitio que el origen, paramos. - if(pc->npoints > 0 && pc->p[0] == pc->p[3]){ - return FALSE; - } + //spanish: si intentamos crear un nodo en el mismo sitio que el origen, paramos. + + if((!anchor || anchor == pc->sa) && (pc->spiro || pc->bspline) && pc->npoints > 0 && pc->p[0] == pc->p[3]){ + return TRUE; } switch (pc->mode) { @@ -1442,9 +1447,7 @@ static void bspline_spiro(PenTool *const pc, bool shift) if(!pc->spiro && !pc->bspline) return; - if(!pc->anchor_statusbar) - shift?bspline_spiro_off(pc):bspline_spiro_on(pc); - + shift?bspline_spiro_off(pc):bspline_spiro_on(pc); bspline_spiro_build(pc); } @@ -1628,10 +1631,11 @@ static void bspline_spiro_motion(PenTool *const pc, bool shift){ } if(pc->anchor_statusbar && !pc->red_curve->is_empty()){ - if(shift) + if(shift){ bspline_spiro_end_anchor_off(pc); - else + }else{ bspline_spiro_end_anchor_on(pc); + } } bspline_spiro_build(pc); @@ -1675,10 +1679,9 @@ static void bspline_spiro_end_anchor_on(PenTool *const pc) tmpCurve = tmpCurve->create_reverse(); pc->green_curve->reset(); pc->green_curve = tmpCurve; - }else{ + }else { tmpCurve = pc->sa->curve->copy(); - if(!pc->sa->start) - tmpCurve = tmpCurve->create_reverse(); + if(!pc->sa->start) tmpCurve = tmpCurve->create_reverse(); Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*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<Geom::CubicBezier const*>(&*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<Geom::CubicBezier const*>(&*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; |
