diff options
Diffstat (limited to 'src/ui/tools/pen-tool.cpp')
| -rw-r--r-- | src/ui/tools/pen-tool.cpp | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index daffc7032..827dbf5c3 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -57,8 +57,7 @@ #include <typeinfo> #include <2geom/pathvector.h> #include <2geom/affine.h> -#include <2geom/bezier-curve.h> -#include <2geom/hvlinesegment.h> +#include <2geom/curves.h> #include "helper/geom-nodetype.h" #include "helper/geom-curves.h" @@ -71,7 +70,7 @@ #define INKSCAPE_LPE_BSPLINE_C #include "live_effects/lpe-bspline.h" -#include <2geom/nearest-point.h> +#include <2geom/nearest-time.h> #include "live_effects/effect.h" @@ -762,14 +761,12 @@ bool PenTool::_handleButtonRelease(GdkEventButton const &revent) { } } this->state = PenTool::CONTROL; - ret = true; break; case PenTool::CONTROL: // End current segment this->_endpointSnap(p, revent.state); this->_finishSegment(p, revent.state); this->state = PenTool::POINT; - ret = true; break; case PenTool::CLOSE: // End current segment @@ -783,12 +780,10 @@ bool PenTool::_handleButtonRelease(GdkEventButton const &revent) { } this->_finish(true); this->state = PenTool::POINT; - ret = true; break; case PenTool::STOP: // This is allowed, if we just canceled curve this->state = PenTool::POINT; - ret = true; break; default: break; @@ -823,7 +818,6 @@ bool PenTool::_handleButtonRelease(GdkEventButton const &revent) { break; } this->state = PenTool::POINT; - ret = true; break; default: break; @@ -1357,8 +1351,9 @@ void PenTool::_bsplineSpiroColor() void PenTool::_bsplineSpiro(bool shift) { - if(!this->spiro && !this->bspline) + if(!this->spiro && !this->bspline){ return; + } shift?this->_bsplineSpiroOff():this->_bsplineSpiroOn(); this->_bsplineSpiroBuild(); @@ -1419,21 +1414,26 @@ void PenTool::_bsplineSpiroStartAnchor(bool shift) }else{ this->spiro = false; } - if(!this->spiro && !this->bspline) + if(!this->spiro && !this->bspline){ + SPCurve *tmp_curve = this->sa->curve->copy(); + if (this->sa->start) { + tmp_curve = tmp_curve ->create_reverse(); + } + this->overwrite_curve = tmp_curve ; return; - - if(shift) + } + if(shift){ this->_bsplineSpiroStartAnchorOff(); - else + } else { this->_bsplineSpiroStartAnchorOn(); + } } void PenTool::_bsplineSpiroStartAnchorOn() { using Geom::X; using Geom::Y; - SPCurve *tmp_curve = new SPCurve(); - tmp_curve = this->sa->curve->copy(); + SPCurve *tmp_curve = this->sa->curve->copy(); if(this->sa->start) tmp_curve = tmp_curve ->create_reverse(); Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*tmp_curve ->last_segment()); @@ -1465,8 +1465,7 @@ void PenTool::_bsplineSpiroStartAnchorOn() void PenTool::_bsplineSpiroStartAnchorOff() { - SPCurve *tmp_curve = new SPCurve(); - tmp_curve = this->sa->curve->copy(); + SPCurve *tmp_curve = this->sa->curve->copy(); if(this->sa->start) tmp_curve = tmp_curve ->create_reverse(); Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*tmp_curve ->last_segment()); @@ -1490,9 +1489,9 @@ void PenTool::_bsplineSpiroStartAnchorOff() } void PenTool::_bsplineSpiroMotion(bool shift){ - if(!this->spiro && !this->bspline) + if(!this->spiro && !this->bspline){ return; - + } using Geom::X; using Geom::Y; if(this->red_curve->is_empty()) return; @@ -1522,7 +1521,7 @@ void PenTool::_bsplineSpiroMotion(bool shift){ Geom::D2< Geom::SBasis > SBasisweight_power; weight_power->moveto(tmp_curve ->last_segment()->finalPoint()); weight_power->lineto(tmp_curve ->last_segment()->initialPoint()); - float WP = Geom::nearest_point((*cubic)[2],*weight_power->first_segment()); + float WP = Geom::nearest_time((*cubic)[2],*weight_power->first_segment()); weight_power->reset(); weight_power->moveto(this->red_curve->last_segment()->initialPoint()); weight_power->lineto(this->red_curve->last_segment()->finalPoint()); @@ -1564,7 +1563,7 @@ void PenTool::_bsplineSpiroEndAnchorOn() 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] + HANDLE_CUBIC_GAP,this->p[2][Y] + HANDLE_CUBIC_GAP); - SPCurve *tmp_curve = new SPCurve(); + SPCurve *tmp_curve; SPCurve *last_segment = new SPCurve(); Geom::Point point_c(0,0); bool reverse = false; @@ -1621,7 +1620,7 @@ void PenTool::_bsplineSpiroEndAnchorOn() void PenTool::_bsplineSpiroEndAnchorOff() { - SPCurve *tmp_curve = new SPCurve(); + SPCurve *tmp_curve; SPCurve *last_segment = new SPCurve(); bool reverse = false; this->p[2] = this->p[3]; @@ -1744,7 +1743,7 @@ void PenTool::_bsplineSpiroBuild() //from LPE BSPLINE: void PenTool::_bsplineDoEffect(SPCurve * curve) { - const double NO_POWER = 0.0; + //const double NO_POWER = 0.0; const double DEFAULT_START_POWER = 0.3334; const double DEFAULT_END_POWER = 0.6667; if (curve->get_segment_count() < 1) { @@ -1798,12 +1797,12 @@ void PenTool::_bsplineDoEffect(SPCurve * curve) if(are_near((*cubic)[1],(*cubic)[0]) && !are_near((*cubic)[2],(*cubic)[3])) { point_at1 = sbasis_in.valueAt(DEFAULT_START_POWER); } else { - point_at1 = sbasis_in.valueAt(Geom::nearest_point((*cubic)[1], *in->first_segment())); + point_at1 = sbasis_in.valueAt(Geom::nearest_time((*cubic)[1], *in->first_segment())); } if(are_near((*cubic)[2],(*cubic)[3]) && !are_near((*cubic)[1],(*cubic)[0])) { point_at2 = sbasis_in.valueAt(DEFAULT_END_POWER); } else { - point_at2 = sbasis_in.valueAt(Geom::nearest_point((*cubic)[2], *in->first_segment())); + point_at2 = sbasis_in.valueAt(Geom::nearest_time((*cubic)[2], *in->first_segment())); } } else { point_at1 = in->first_segment()->initialPoint(); @@ -1821,7 +1820,7 @@ void PenTool::_bsplineDoEffect(SPCurve * curve) if(are_near((*cubic)[1],(*cubic)[0]) && !are_near((*cubic)[2],(*cubic)[3])) { next_point_at1 = sbasis_in.valueAt(DEFAULT_START_POWER); } else { - next_point_at1 = sbasis_out.valueAt(Geom::nearest_point((*cubic)[1], *out->first_segment())); + next_point_at1 = sbasis_out.valueAt(Geom::nearest_time((*cubic)[1], *out->first_segment())); } } else { next_point_at1 = out->first_segment()->initialPoint(); @@ -1838,7 +1837,7 @@ void PenTool::_bsplineDoEffect(SPCurve * curve) cubic = dynamic_cast<Geom::CubicBezier const *>(&*path_it->begin()); if (cubic) { line_helper->moveto(sbasis_start.valueAt( - Geom::nearest_point((*cubic)[1], *start->first_segment()))); + Geom::nearest_time((*cubic)[1], *start->first_segment()))); } else { line_helper->moveto(start->first_segment()->initialPoint()); } @@ -1852,7 +1851,7 @@ void PenTool::_bsplineDoEffect(SPCurve * curve) cubic = dynamic_cast<Geom::CubicBezier const *>(&*curve_it1); if (cubic) { line_helper->lineto(sbasis_end.valueAt( - Geom::nearest_point((*cubic)[2], *end->first_segment()))); + Geom::nearest_time((*cubic)[2], *end->first_segment()))); } else { line_helper->lineto(end->first_segment()->finalPoint()); } |
