diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2014-01-18 09:11:04 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2014-01-18 09:11:04 +0000 |
| commit | f12d6a57fe5cc18be5afd164061578d8e00d75ce (patch) | |
| tree | 7fd1a501a8a545fbf2326ead48cd041928699c5e /src/live_effects | |
| parent | update to trunk (diff) | |
| parent | Fix missing embeded image condition, kindly caught by suv in bug #1270334 (diff) | |
| download | inkscape-f12d6a57fe5cc18be5afd164061578d8e00d75ce.tar.gz inkscape-f12d6a57fe5cc18be5afd164061578d8e00d75ce.zip | |
update to trunk
(bzr r11950.1.235)
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-knot.cpp | 71 | ||||
| -rw-r--r-- | src/live_effects/lpe-powerstroke.cpp | 4 |
4 files changed, 47 insertions, 50 deletions
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 29da403e8..5f584f92d 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -491,11 +491,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; @@ -504,18 +506,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-knot.cpp b/src/live_effects/lpe-knot.cpp index 8fec69958..e91677e18 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); @@ -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-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 0533c1ed6..acf8ab6a5 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> @@ -537,7 +537,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(); } |
