diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2014-04-01 17:00:00 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2014-04-01 17:00:00 +0000 |
| commit | 208ccdf9782984702f79b8ba416e67dd1e2c2dfa (patch) | |
| tree | 79d15123aa526c49c6386db6245fbfc6b7a63eaf /src/live_effects | |
| parent | update to trunk (diff) | |
| parent | partial 2geom update: (diff) | |
| download | inkscape-208ccdf9782984702f79b8ba416e67dd1e2c2dfa.tar.gz inkscape-208ccdf9782984702f79b8ba416e67dd1e2c2dfa.zip | |
update to trunk
(bzr r12588.1.32)
Diffstat (limited to 'src/live_effects')
| -rw-r--r-- | src/live_effects/effect.cpp | 20 | ||||
| -rw-r--r-- | src/live_effects/effect.h | 2 | ||||
| -rw-r--r-- | src/live_effects/lpe-angle_bisector.cpp | 2 | ||||
| -rw-r--r-- | src/live_effects/lpe-knot.cpp | 73 | ||||
| -rw-r--r-- | src/live_effects/lpe-perp_bisector.cpp | 4 | ||||
| -rw-r--r-- | src/live_effects/lpe-powerstroke.cpp | 7 | ||||
| -rw-r--r-- | src/live_effects/lpe-rough-hatches.cpp | 4 |
7 files changed, 54 insertions, 58 deletions
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 70ce1e89d..12990ee24 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -486,11 +486,13 @@ Effect::addHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) { } /** - * Return a vector of PathVectors which contain all helperpaths that should be drawn by the effect. - * This is the function called by external code like SPLPEItem. + * Return a vector of PathVectors which contain all canvas indicators for this effect. + * This is the function called by external code to get all canvas indicators (effect and its parameters) + * lpeitem = the item onto which this effect is applied + * @todo change return type to one pathvector, add all paths to one pathvector instead of maintaining a vector of pathvectors */ std::vector<Geom::PathVector> -Effect::getHelperPaths(SPLPEItem const* lpeitem) +Effect::getCanvasIndicators(SPLPEItem const* lpeitem) { std::vector<Geom::PathVector> hp_vec; @@ -499,18 +501,10 @@ Effect::getHelperPaths(SPLPEItem const* lpeitem) return hp_vec; } - // TODO: we can probably optimize this by using a lot more references - // rather than copying PathVectors all over the place - if (show_orig_path) { - // add original path to helperpaths - SPCurve* curve = SP_SHAPE(lpeitem)->getCurve (); - hp_vec.push_back(curve->get_pathvector()); - } - - // add other helperpaths provided by the effect itself + // add indicators provided by the effect itself addCanvasIndicators(lpeitem, hp_vec); - // add helperpaths provided by the effect's parameters + // add indicators provided by the effect's parameters for (std::vector<Parameter *>::iterator p = param_vector.begin(); p != param_vector.end(); ++p) { (*p)->addCanvasIndicators(lpeitem, hp_vec); } diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index b9d86628f..1da9b4cc9 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -90,7 +90,7 @@ public: // (but spiro lpe still needs it!) virtual LPEPathFlashType pathFlashType() const { return DEFAULT; } void addHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); - std::vector<Geom::PathVector> getHelperPaths(SPLPEItem const* lpeitem); + std::vector<Geom::PathVector> getCanvasIndicators(SPLPEItem const* lpeitem); inline bool providesOwnFlashPaths() const { return provides_own_flash_paths || show_orig_path; diff --git a/src/live_effects/lpe-angle_bisector.cpp b/src/live_effects/lpe-angle_bisector.cpp index 2f57b710b..1acf9605f 100644 --- a/src/live_effects/lpe-angle_bisector.cpp +++ b/src/live_effects/lpe-angle_bisector.cpp @@ -89,7 +89,7 @@ LPEAngleBisector::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *deskt { KnotHolderEntity *e = new AB::KnotHolderEntityRightEnd(this); e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, - _("Adjust the \"right\" of the bisector") ); + _("Adjust the \"right\" end of the bisector") ); knotholder->add(e); } }; diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index 8fec69958..581c632f5 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -161,14 +161,14 @@ CrossingPoints::CrossingPoints(std::vector<Geom::Path> const &paths) : std::vect for( unsigned j=i; j<paths.size(); j++){ for( unsigned jj=(i==j?ii:0); jj < size_nondegenerate(paths[j]); jj++){ std::vector<std::pair<double,double> > times; - if ( i==j && ii==jj){ + if ( (i==j) && (ii==jj) ) { // std::cout<<"--(self int)\n"; // std::cout << paths[i][ii].toSBasis()[Geom::X] <<"\n"; // std::cout << paths[i][ii].toSBasis()[Geom::Y] <<"\n"; find_self_intersections( times, paths[i][ii].toSBasis() ); - }else{ + } else { // std::cout<<"--(pair int)\n"; // std::cout << paths[i][ii].toSBasis()[Geom::X] <<"\n"; // std::cout << paths[i][ii].toSBasis()[Geom::Y] <<"\n"; @@ -180,15 +180,17 @@ CrossingPoints::CrossingPoints(std::vector<Geom::Path> const &paths) : std::vect } for (unsigned k=0; k<times.size(); k++){ //std::cout<<"intersection "<<i<<"["<<ii<<"]("<<times[k].first<<")= "<<j<<"["<<jj<<"]("<<times[k].second<<")\n"; - if (times[k].first == times[k].first && times[k].second == times[k].second ){//is this the way to test NaN? + if ( !IS_NAN(times[k].first) && !IS_NAN(times[k].second) ){ double zero = 1e-4; - if ( i==j && fabs(times[k].first+ii - times[k].second-jj)<=zero ){//this is just end=start of successive curves in a path. + if ( (i==j) && (fabs(times[k].first+ii - times[k].second-jj) <= zero) ) + { //this is just end=start of successive curves in a path. continue; } - if ( i==j && ii == 0 && jj == size_nondegenerate(paths[i])-1 && - paths[i].closed() && - fabs(times[k].first) <= zero && - fabs(times[k].second - 1) <= zero ){//this is just end=start of a closed path. + if ( (i==j) && (ii == 0) && (jj == size_nondegenerate(paths[i])-1) + && paths[i].closed() + && (fabs(times[k].first) <= zero) + && (fabs(times[k].second - 1) <= zero) ) + {//this is just end=start of a closed path. continue; } CrossingPoint cp; @@ -218,7 +220,7 @@ CrossingPoints::CrossingPoints(std::vector<Geom::Path> const &paths) : std::vect } unsigned count = 0; for ( std::map < double, unsigned >::iterator m=cuts.begin(); m!=cuts.end(); ++m ){ - if ( (*this)[m->second].i == i && (*this)[m->second].ti == m->first ){ + if ( ((*this)[m->second].i == i) && ((*this)[m->second].ti == m->first) ){ (*this)[m->second].ni = count; }else{ (*this)[m->second].nj = count; @@ -230,7 +232,7 @@ CrossingPoints::CrossingPoints(std::vector<Geom::Path> const &paths) : std::vect CrossingPoints::CrossingPoints(std::vector<double> const &input) : std::vector<CrossingPoint>() { - if (input.size()>0 && input.size()%9 ==0){ + if ( (input.size() > 0) && (input.size()%9 == 0) ){ using namespace Geom; for( unsigned n=0; n<input.size(); ){ CrossingPoint cp; @@ -273,10 +275,11 @@ CrossingPoint CrossingPoints::get(unsigned const i, unsigned const ni) { for (unsigned k=0; k<size(); k++){ - if ( - ((*this)[k].i==i && (*this)[k].ni==ni) || - ((*this)[k].j==i && (*this)[k].nj==ni) - ) return (*this)[k]; + if ( ( ((*this)[k].i==i) && ((*this)[k].ni==ni) ) + || ( ((*this)[k].j==i) && ((*this)[k].nj==ni) ) ) + { + return (*this)[k]; + } } g_warning("LPEKnotNS::CrossingPoints::get error. %uth crossing along string %u not found.",ni,i); assert(false);//debug purpose... @@ -290,7 +293,7 @@ idx_of_nearest(CrossingPoints const &cpts, Geom::Point const &p) unsigned result = cpts.size(); for (unsigned k=0; k<cpts.size(); k++){ double dist_k = Geom::L2(p-cpts[k].pt); - if (dist<0 || dist>dist_k){ + if ( (dist < 0) || (dist > dist_k) ) { result = k; dist = dist_k; } @@ -304,28 +307,28 @@ void CrossingPoints::inherit_signs(CrossingPoints const &other, int default_value) { bool topo_changed = false; - for (unsigned n=0; n<size(); n++){ - if ( n<other.size() && - other[n].i == (*this)[n].i && - other[n].j == (*this)[n].j && - other[n].ni == (*this)[n].ni && - other[n].nj == (*this)[n].nj ) + for (unsigned n=0; n < size(); n++){ + if ( (n < other.size()) + && (other[n].i == (*this)[n].i) + && (other[n].j == (*this)[n].j) + && (other[n].ni == (*this)[n].ni) + && (other[n].nj == (*this)[n].nj) ) { (*this)[n].sign = other[n].sign; - }else{ + } else { topo_changed = true; break; } } - if (topo_changed){ + if (topo_changed) { //TODO: Find a way to warn the user!! // std::cout<<"knot topolgy changed!\n"; - for (unsigned n=0; n<size(); n++){ + for (unsigned n=0; n < size(); n++){ Geom::Point p = (*this)[n].pt; unsigned idx = idx_of_nearest(other,p); - if (idx<other.size()){ + if (idx < other.size()) { (*this)[n].sign = other[idx].sign; - }else{ + } else { (*this)[n].sign = default_value; } } @@ -412,7 +415,7 @@ LPEKnot::doEffect_path (std::vector<Geom::Path> const &path_in) std::vector<Interval> dom; dom.push_back(Interval(0., size_nondegenerate(gpaths[i0]))); for (unsigned p = 0; p < crossing_points.size(); p++){ - if (crossing_points[p].i == i0 || crossing_points[p].j == i0){ + if ( (crossing_points[p].i == i0) || (crossing_points[p].j == i0) ) { unsigned i = crossing_points[p].i; unsigned j = crossing_points[p].j; double ti = crossing_points[p].ti; @@ -475,14 +478,14 @@ LPEKnot::doEffect_path (std::vector<Geom::Path> const &path_in) //If the current path is closed and the last/first point is still there, glue first and last piece. unsigned beg_comp = 0, end_comp = dom.size(); - if ( gpaths[i0].closed() && dom.front().min() == 0 && dom.back().max() == size_nondegenerate(gpaths[i0]) ){ + if ( gpaths[i0].closed() && (dom.front().min() == 0) && (dom.back().max() == size_nondegenerate(gpaths[i0])) ) { if ( dom.size() == 1){ path_out.push_back(gpaths[i0]); continue; }else{ // std::cout<<"fusing first and last component\n"; - beg_comp++; - end_comp--; + ++beg_comp; + --end_comp; Path first = gpaths[i0].portion(dom.back()); //FIXME: STITCH_DISCONTINUOUS should not be necessary (?!?) first.append(gpaths[i0].portion(dom.front()), Path::STITCH_DISCONTINUOUS); @@ -490,7 +493,7 @@ LPEKnot::doEffect_path (std::vector<Geom::Path> const &path_in) } } for (unsigned comp = beg_comp; comp < end_comp; comp++){ - assert(dom.at(comp).min() >=0 and dom.at(comp).max() <= size_nondegenerate(gpaths.at(i0))); + assert(dom.at(comp).min() >=0 && dom.at(comp).max() <= size_nondegenerate(gpaths.at(i0))); path_out.push_back(gpaths[i0].portion(dom.at(comp))); } } @@ -594,19 +597,19 @@ LPEKnot::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::Pat double r = switcher_size*.1; char const * svgd; //TODO: use a nice path! - if (selectedCrossing >= crossing_points.size()||crossing_points[selectedCrossing].sign > 0){ + if ( (selectedCrossing >= crossing_points.size()) || (crossing_points[selectedCrossing].sign > 0) ) { //svgd = "M -10,0 A 10 10 0 1 0 0,-10 l 5,-1 -1,2"; svgd = "m -7.07,7.07 c 3.9,3.91 10.24,3.91 14.14,0 3.91,-3.9 3.91,-10.24 0,-14.14 -3.9,-3.91 -10.24,-3.91 -14.14,0 l 2.83,-4.24 0.7,2.12"; - }else if (crossing_points[selectedCrossing].sign < 0){ + } else if (crossing_points[selectedCrossing].sign < 0) { //svgd = "M 10,0 A 10 10 0 1 1 0,-10 l -5,-1 1,2"; svgd = "m 7.07,7.07 c -3.9,3.91 -10.24,3.91 -14.14,0 -3.91,-3.9 -3.91,-10.24 0,-14.14 3.9,-3.91 10.24,-3.91 14.14,0 l -2.83,-4.24 -0.7,2.12"; - }else{ + } else { //svgd = "M 10,0 A 10 10 0 1 0 -10,0 A 10 10 0 1 0 10,0 "; svgd = "M 10,0 C 10,5.52 5.52,10 0,10 -5.52,10 -10,5.52 -10,0 c 0,-5.52 4.48,-10 10,-10 5.52,0 10,4.48 10,10 z"; } PathVector pathv = sp_svg_read_pathv(svgd); pathv *= Affine(r,0,0,r,0,0); - pathv+=switcher; + pathv += switcher; hp_vec.push_back(pathv); } diff --git a/src/live_effects/lpe-perp_bisector.cpp b/src/live_effects/lpe-perp_bisector.cpp index c2a25a187..feed55b26 100644 --- a/src/live_effects/lpe-perp_bisector.cpp +++ b/src/live_effects/lpe-perp_bisector.cpp @@ -156,13 +156,13 @@ LPEPerpBisector::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *deskto { KnotHolderEntity *e = new PB::KnotHolderEntityLeftEnd(this); e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, - _("Adjust the bisector's \"left\" end") ); + _("Adjust the \"left\" end of the bisector") ); knotholder->add(e); } { KnotHolderEntity *e = new PB::KnotHolderEntityRightEnd(this); e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, - _("Adjust the bisector's \"right\" end") ); + _("Adjust the \"right\" end of the bisector") ); knotholder->add(e); } }; diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 0533c1ed6..90b01aaa4 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -24,7 +24,7 @@ #include <2geom/bezier-utils.h> #include <2geom/svg-elliptical-arc.h> #include <2geom/sbasis-to-bezier.h> -#include <2geom/svg-path.h> +#include <2geom/path-sink.h> #include <2geom/path-intersection.h> #include <2geom/crossing.h> #include <2geom/ellipse.h> @@ -305,7 +305,6 @@ static Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise<Geom::D2<Geom:: Geom::Piecewise<Geom::SBasis> const & y, // width path LineJoinType jointype, double miter_limit, - bool /*forward_direction*/, double tol=Geom::EPSILON) { /* per definition, each discontinuity should be fixed with a join-ending, as defined by linejoin_type @@ -537,7 +536,7 @@ static Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise<Geom::D2<Geom:: prev_i = i; } - pb.finish(); + pb.flush(); return pb.peek().front(); } @@ -608,7 +607,7 @@ LPEPowerStroke::doEffect_path (std::vector<Geom::Path> const & path_in) Piecewise<D2<SBasis> > pwd2_out = compose(pwd2_in,x) + y*compose(n,x); Piecewise<D2<SBasis> > mirrorpath = reverse(compose(pwd2_in,x) - y*compose(n,x)); - Geom::Path fixed_path = path_from_piecewise_fix_cusps( pwd2_out, y, jointype, miter_limit, LPE_CONVERSION_TOLERANCE); + Geom::Path fixed_path = path_from_piecewise_fix_cusps( pwd2_out, y, jointype, miter_limit, LPE_CONVERSION_TOLERANCE); Geom::Path fixed_mirrorpath = path_from_piecewise_fix_cusps( mirrorpath, reverse(y), jointype, miter_limit, LPE_CONVERSION_TOLERANCE); if (path_in[0].closed()) { diff --git a/src/live_effects/lpe-rough-hatches.cpp b/src/live_effects/lpe-rough-hatches.cpp index 6ffb913bd..455653e46 100644 --- a/src/live_effects/lpe-rough-hatches.cpp +++ b/src/live_effects/lpe-rough-hatches.cpp @@ -319,7 +319,7 @@ LPERoughHatches::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & transformed_pwd2_in = transformed_pwd2_in * bend_mat; tilter = Piecewise<SBasis>(shift(Linear(-bend_amount),1)); OptRect bbox = bounds_exact( transformed_pwd2_in ); - if (not(bbox)) return pwd2_in; + if (!(bbox)) return pwd2_in; tilter.setDomain((*bbox)[Y]); transformed_pwd2_in = bend(transformed_pwd2_in, tilter); transformed_pwd2_in = transformed_pwd2_in * bend_mat.inverse(); @@ -381,7 +381,7 @@ LPERoughHatches::linearSnake(Piecewise<D2<SBasis> > const &f, Point const &org){ Piecewise<SBasis> dx = derivative(x); OptInterval range = bounds_exact(x); - if (not range) return result; + if (!range) return result; std::vector<double> levels = generateLevels(*range, org[X]); std::vector<std::vector<double> > times; times = multi_roots(x,levels); |
