diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2015-03-22 17:27:17 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2015-03-22 17:27:17 +0000 |
| commit | 8bd246d8b59749e15de4d5d0d78e9b82fa8a601a (patch) | |
| tree | 5f9792fbade2d276210c43a904d59d7e7a689681 /src | |
| parent | update to trunk (diff) | |
| download | inkscape-8bd246d8b59749e15de4d5d0d78e9b82fa8a601a.tar.gz inkscape-8bd246d8b59749e15de4d5d0d78e9b82fa8a601a.zip | |
Fixed bug when deleting nodes
(bzr r13645.1.51)
Diffstat (limited to 'src')
| -rw-r--r-- | src/2geom/pointwise.cpp | 131 | ||||
| -rw-r--r-- | src/2geom/pointwise.h | 34 | ||||
| -rw-r--r-- | src/2geom/satellite.cpp | 2 | ||||
| -rw-r--r-- | src/2geom/satellite.h | 4 | ||||
| -rw-r--r-- | src/live_effects/lpe-fillet-chamfer.cpp | 56 | ||||
| -rw-r--r-- | src/live_effects/parameter/array.cpp | 10 | ||||
| -rw-r--r-- | src/live_effects/parameter/array.h | 4 | ||||
| -rw-r--r-- | src/live_effects/parameter/satellitepairarray.cpp | 37 | ||||
| -rw-r--r-- | src/live_effects/parameter/satellitepairarray.h | 8 | ||||
| -rw-r--r-- | src/ui/dialog/lpe-fillet-chamfer-properties.cpp | 2 |
10 files changed, 152 insertions, 136 deletions
diff --git a/src/2geom/pointwise.cpp b/src/2geom/pointwise.cpp index 733bd6496..9669c20b8 100644 --- a/src/2geom/pointwise.cpp +++ b/src/2geom/pointwise.cpp @@ -36,7 +36,7 @@ namespace Geom { -Pointwise::Pointwise(Piecewise<D2<SBasis> > pwd2, std::vector<std::pair<unsigned int,Satellite> > satellites) +Pointwise::Pointwise(Piecewise<D2<SBasis> > pwd2, std::vector<std::pair<size_t,Satellite> > satellites) : _pwd2(pwd2),_satellites(satellites),_pathInfo() { setPathInfo(); @@ -57,14 +57,14 @@ Pointwise::setPwd2(Piecewise<D2<SBasis> > pwd2_in) setPathInfo(); } -std::vector<std::pair<unsigned int,Satellite> > +std::vector<std::pair<size_t,Satellite> > Pointwise::getSatellites() const { return _satellites; } void -Pointwise::setSatellites(std::vector<std::pair<unsigned int,Satellite> > sats) +Pointwise::setSatellites(std::vector<std::pair<size_t,Satellite> > sats) { _satellites = sats; } @@ -81,7 +81,7 @@ Pointwise::setPathInfo(Piecewise<D2<SBasis> > pwd2) { _pathInfo.clear(); std::vector<Geom::Path> path_in = path_from_piecewise(remove_short_cuts(pwd2,0.1), 0.001); - unsigned int counter = 0; + size_t counter = 0; for (PathVector::const_iterator path_it = path_in.begin(); path_it != path_in.end(); ++path_it) { if (path_it->empty()){ continue; @@ -106,10 +106,10 @@ Pointwise::setPathInfo(Piecewise<D2<SBasis> > pwd2) } } -unsigned int -Pointwise::getSubPathIndex(unsigned int index) const +size_t +Pointwise::getSubPathIndex(size_t index) const { - for(unsigned int i = 0; i < _pathInfo.size(); i++){ + for(size_t i = 0; i < _pathInfo.size(); i++){ if(index <= _pathInfo[i].first){ return i; } @@ -117,10 +117,10 @@ Pointwise::getSubPathIndex(unsigned int index) const return 0; } -unsigned int -Pointwise::getLast(unsigned int index) const +size_t +Pointwise::getLast(size_t index) const { - for(unsigned int i = 0; i < _pathInfo.size(); i++){ + for(size_t i = 0; i < _pathInfo.size(); i++){ if(index <= _pathInfo[i].first){ return _pathInfo[i].first; } @@ -128,10 +128,10 @@ Pointwise::getLast(unsigned int index) const return 0; } -unsigned int -Pointwise::getFirst(unsigned int index) const +size_t +Pointwise::getFirst(size_t index) const { - for(unsigned int i = 0; i < _pathInfo.size(); i++){ + for(size_t i = 0; i < _pathInfo.size(); i++){ if(index <= _pathInfo[i].first){ if(i==0){ return 0; @@ -143,8 +143,8 @@ Pointwise::getFirst(unsigned int index) const return 0; } -boost::optional<unsigned int> -Pointwise::getPrevious(unsigned int index) const +boost::optional<size_t> +Pointwise::getPrevious(size_t index) const { if(getFirst(index) == index && getIsClosed(index)){ return getLast(index); @@ -155,8 +155,8 @@ Pointwise::getPrevious(unsigned int index) const return index - 1; } -boost::optional<unsigned int> -Pointwise::getNext(unsigned int index) const +boost::optional<size_t> +Pointwise::getNext(size_t index) const { if(getLast(index) == index && getIsClosed(index)){ return getFirst(index); @@ -168,9 +168,9 @@ Pointwise::getNext(unsigned int index) const } bool -Pointwise::getIsClosed(unsigned int index) const +Pointwise::getIsClosed(size_t index) const { - for(unsigned int i = 0; i < _pathInfo.size(); i++){ + for(size_t i = 0; i < _pathInfo.size(); i++){ if(index <= _pathInfo[i].first){ return _pathInfo[i].second; } @@ -192,14 +192,14 @@ Pointwise::recalculate_for_new_pwd2(Piecewise<D2<SBasis> > A) void Pointwise::new_pwd_append(Piecewise<D2<SBasis> > A) { - unsigned int counter = 0; - std::vector<std::pair<unsigned int,Satellite> > sats; - for(unsigned i = 0; i < _satellites.size(); i++){ + size_t counter = 0; + std::vector<std::pair<size_t,Satellite> > sats; + for(size_t i = 0; i < _satellites.size(); i++){ if(_satellites[i].second.getIsEndOpen()){ _satellites.erase(_satellites.begin() + i); } } - for(unsigned i = 0; i < A.size(); i++){ + for(size_t i = 0; i < A.size(); i++){ if(!are_near(_pwd2[i-counter].at0(),A[i].at0(),0.001)){ counter++; bool isEndOpen = false; @@ -223,16 +223,16 @@ Pointwise::new_pwd_append(Piecewise<D2<SBasis> > A) void Pointwise::new_pwd_sustract(Piecewise<D2<SBasis> > A) { - int counter = 0; - std::vector<std::pair<unsigned int,Satellite> > sats; - Piecewise<D2<SBasis> > pwd2 = _pwd2; - setPwd2(A); - for(unsigned i = 0; i < _satellites.size(); i++){ + size_t counter = 0; + std::vector<std::pair<size_t,Satellite> > sats; + for(size_t i = 0; i < _satellites.size(); i++){ if(_satellites[i].second.getIsEndOpen()){ _satellites.erase(_satellites.begin() + i); } } - for(unsigned i = 0; i < _satellites.size(); i++){ + Piecewise<D2<SBasis> > pwd2 = _pwd2; + setPwd2(A); + for(size_t i = 0; i < _satellites.size(); i++){ if(getLast(_satellites[i].first-counter) < _satellites[i].first-counter || !are_near(pwd2[_satellites[i].first].at0(),A[_satellites[i].first-counter].at0(),0.001)){ counter++; } else { @@ -243,48 +243,59 @@ Pointwise::new_pwd_sustract(Piecewise<D2<SBasis> > A) } void -Pointwise::set_extremes(bool active, bool hidden, double amount, double angle) +Pointwise::set_extremes(bool endOpenSat,bool active, bool hidden, double amount, double angle) { - for(unsigned int i = 0; i < _pathInfo.size(); i++){ - unsigned int firstNode = getFirst(_pathInfo[i].first); - unsigned int lastNode = getLast(_pathInfo[i].first); + for(size_t i = 0; i < _pathInfo.size(); i++){ + size_t firstNode = getFirst(_pathInfo[i].first); + size_t lastNode = getLast(_pathInfo[i].first); if(!getIsClosed(lastNode)){ - unsigned int lastIndex = 0; - for(unsigned j = 0; j < _satellites.size();j++){ - _satellites[j].second.setIsEndOpen(false); - if(_satellites[j].first > lastNode){ - break; + long lastIndex = -1; + for(size_t j = 0; j < _satellites.size(); j++){ + if(_satellites[j].first < firstNode || _satellites[j].first > lastNode){ + continue; } + _satellites[j].second.setIsEndOpen(false); if(_satellites[j].first == firstNode){ _satellites[j].second.setActive(active); _satellites[j].second.setHidden(hidden); - _satellites[j].second.setAmount(amount); - _satellites[j].second.setAngle(angle); + if(amount >= 0){ + _satellites[j].second.setAmount(amount); + } + if(angle >= 0){ + _satellites[j].second.setAngle(angle); + } + } + + if(_satellites[j].first == lastNode && lastIndex != -1){ + _satellites[j].second.setIsEndOpen(true); } - if(_satellites[j].first == lastNode){ + + if(_satellites[j].first == lastNode && lastIndex == -1){ lastIndex = j; } } - Satellite sat(_satellites[0].second.getSatelliteType(), _satellites[0].second.getIsTime(), true, active, _satellites[0].second.getHasMirror(), hidden, amount, angle, _satellites[0].second.getSteps()); - _satellites.insert(_satellites.begin() + lastIndex,std::make_pair(lastNode,sat)); + if(endOpenSat){ + Satellite sat(_satellites[0].second.getSatelliteType(), _satellites[0].second.getIsTime(), true, active, _satellites[0].second.getHasMirror(), hidden, 0.0, 0.0, _satellites[0].second.getSteps()); + _satellites.insert(_satellites.begin() + lastIndex + 1, std::make_pair(lastNode,sat)); + } } } } void -Pointwise::reverse(unsigned int start,unsigned int end){ - for(unsigned int i = start; i < end / 2; i++){ - std::pair<unsigned int,Satellite> tmp = _satellites[i]; +Pointwise::reverse(size_t start,size_t end){ + for(size_t i = start; i < end / 2; i++){ + std::pair<size_t,Satellite> tmp = _satellites[i]; _satellites[i] = _satellites[end - start - i - 1]; _satellites[end - start - i - 1] = tmp; } } double -Pointwise::rad_to_len(double A, std::pair<unsigned int,Geom::Satellite> sat) const +Pointwise::rad_to_len(double A, std::pair<size_t,Geom::Satellite> sat) const { double len = 0; - boost::optional<unsigned int> d2_prev_index = getPrevious(sat.first); + boost::optional<size_t> d2_prev_index = getPrevious(sat.first); if(d2_prev_index){ Geom::D2<Geom::SBasis> d2_in = _pwd2[*d2_prev_index]; Geom::D2<Geom::SBasis> d2_out = _pwd2[sat.first]; @@ -307,9 +318,9 @@ Pointwise::rad_to_len(double A, std::pair<unsigned int,Geom::Satellite> sat) co } double -Pointwise::len_to_rad(double A, std::pair<unsigned int,Geom::Satellite> sat) const +Pointwise::len_to_rad(double A, std::pair<size_t,Geom::Satellite> sat) const { - boost::optional<unsigned int> d2_prev_index = getPrevious(sat.first); + boost::optional<size_t> d2_prev_index = getPrevious(sat.first); if(d2_prev_index){ Geom::D2<Geom::SBasis> d2_in = _pwd2[*d2_prev_index]; Geom::D2<Geom::SBasis> d2_out = _pwd2[sat.first]; @@ -348,14 +359,14 @@ Pointwise::len_to_rad(double A, std::pair<unsigned int,Geom::Satellite> sat) co return 0; } -std::vector<unsigned int> -Pointwise::findSatellites(unsigned int A, int B) const +std::vector<size_t> +Pointwise::findSatellites(size_t A, long B) const { - std::vector<unsigned int> ret; - int counter = 0; - for(unsigned i = 0; i < _satellites.size(); i++){ + std::vector<size_t> ret; + long counter = 0; + for(size_t i = 0; i < _satellites.size(); i++){ if(_satellites[i].first == A){ - if(counter >= B && B != -1){ + if(counter >= B && B != (long)-1){ return ret; } ret.push_back(i); @@ -365,11 +376,11 @@ Pointwise::findSatellites(unsigned int A, int B) const return ret; } -std::vector<unsigned int > -Pointwise::findPeviousSatellites(unsigned int A, int B) const +std::vector<size_t > +Pointwise::findPeviousSatellites(size_t A, long B) const { - boost::optional<unsigned int> previous = getPrevious(A); - std::vector<unsigned int> ret; + boost::optional<size_t> previous = getPrevious(A); + std::vector<size_t> ret; if(previous){ ret = findSatellites(*previous,B); } diff --git a/src/2geom/pointwise.h b/src/2geom/pointwise.h index f9dc2e47a..a7cbcfec4 100644 --- a/src/2geom/pointwise.h +++ b/src/2geom/pointwise.h @@ -63,34 +63,34 @@ namespace Geom { class Pointwise { public: - Pointwise(Piecewise<D2<SBasis> > pwd2, std::vector<std::pair<unsigned int,Satellite> > satellites); + Pointwise(Piecewise<D2<SBasis> > pwd2, std::vector<std::pair<size_t,Satellite> > satellites); virtual ~Pointwise(); - std::vector<unsigned int> findSatellites(unsigned int A, int B = -1) const; - std::vector<unsigned int> findPeviousSatellites(unsigned int A, int B) const; - double rad_to_len(double A, std::pair<unsigned int,Geom::Satellite> sat) const; - double len_to_rad(double A, std::pair<unsigned int,Geom::Satellite> sat) const; - std::vector<std::pair<unsigned int,Satellite> > getSatellites() const; - void setSatellites(std::vector<std::pair<unsigned int,Satellite> > sats); + std::vector<size_t> findSatellites(size_t A, long B = -1) const; + std::vector<size_t> findPeviousSatellites(size_t A, long B) const; + double rad_to_len(double A, std::pair<size_t,Geom::Satellite> sat) const; + double len_to_rad(double A, std::pair<size_t,Geom::Satellite> sat) const; + std::vector<std::pair<size_t,Satellite> > getSatellites() const; + void setSatellites(std::vector<std::pair<size_t,Satellite> > sats); Piecewise<D2<SBasis> > getPwd2() const; void setPwd2(Piecewise<D2<SBasis> > pwd2_in); void recalculate_for_new_pwd2(Piecewise<D2<SBasis> > A); void new_pwd_append(Piecewise<D2<SBasis> > A); void new_pwd_sustract(Piecewise<D2<SBasis> > A); - void set_extremes(bool active, bool hidden, double amount, double angle); - void reverse(unsigned int start,unsigned int end); + void set_extremes(bool endOpenSat, bool active, bool hidden, double amount = -1, double angle = -1); + void reverse(size_t start,size_t end); void setPathInfo(); void setPathInfo(Piecewise<D2<SBasis> >); - unsigned int getSubPathIndex(unsigned int index) const; - unsigned int getLast(unsigned int index) const; - unsigned int getFirst(unsigned int index) const; - boost::optional<unsigned int> getPrevious(unsigned int index) const; - boost::optional<unsigned int> getNext(unsigned int index) const; - bool getIsClosed(unsigned int index) const; + size_t getSubPathIndex(size_t index) const; + size_t getLast(size_t index) const; + size_t getFirst(size_t index) const; + boost::optional<size_t> getPrevious(size_t index) const; + boost::optional<size_t> getNext(size_t index) const; + bool getIsClosed(size_t index) const; private: Piecewise<D2<SBasis> > _pwd2; - std::vector<std::pair<unsigned int,Satellite> > _satellites; - std::vector<std::pair<unsigned int, bool> > _pathInfo; + std::vector<std::pair<size_t,Satellite> > _satellites; + std::vector<std::pair<size_t, bool> > _pathInfo; }; } // end namespace Geom diff --git a/src/2geom/satellite.cpp b/src/2geom/satellite.cpp index 509c0e074..d1420b20c 100644 --- a/src/2geom/satellite.cpp +++ b/src/2geom/satellite.cpp @@ -40,7 +40,7 @@ namespace Geom { Satellite::Satellite(){}; -Satellite::Satellite(SatelliteType satellitetype, bool isTime, bool isEndOpen, bool active, bool hasMirror, bool hidden, double amount, double angle, unsigned int steps) +Satellite::Satellite(SatelliteType satellitetype, bool isTime, bool isEndOpen, bool active, bool hasMirror, bool hidden, double amount, double angle, size_t steps) : _satellitetype(satellitetype), _isTime(isTime), _isEndOpen(isEndOpen), _active(active), _hasMirror(hasMirror), _hidden(hidden), _amount(amount), _angle(angle), _steps(steps){}; Satellite::~Satellite() {}; diff --git a/src/2geom/satellite.h b/src/2geom/satellite.h index 43863d71f..42ed9c291 100644 --- a/src/2geom/satellite.h +++ b/src/2geom/satellite.h @@ -45,7 +45,7 @@ class Satellite public: Satellite(); - Satellite(SatelliteType satellitetype, bool isTime, bool isEndOpen, bool active, bool hasMirror, bool hidden, double amount, double angle, unsigned int steps); + Satellite(SatelliteType satellitetype, bool isTime, bool isEndOpen, bool active, bool hasMirror, bool hidden, double amount, double angle, size_t steps); virtual ~Satellite(); @@ -169,7 +169,7 @@ class Satellite bool _hidden; double _amount; double _angle; - unsigned int _steps; + size_t _steps; }; } // end namespace Geom diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp index 93c21469a..6b388b0f6 100644 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ b/src/live_effects/lpe-fillet-chamfer.cpp @@ -51,7 +51,7 @@ LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject) : unit(_("Unit:"), _("Unit"), "unit", &wr, this), method(_("Method:"), _("Fillets methods"), "method", FMConverter, &wr, this, FM_AUTO), radius(_("Radius (unit or %):"), _("Radius, in unit or %"), "radius", &wr, this, 0.), - chamfer_steps(_("Chamfer steps:"), _("Chamfer steps"), "chamfer_steps", &wr, this, 3), + chamfer_steps(_("Chamfer steps:"), _("Chamfer steps"), "chamfer_steps", &wr, this, 1), flexible(_("Flexible radius size (%)"), _("Flexible radius size (%)"), "flexible", &wr, this, false), mirror_knots(_("Mirror Knots"), _("Mirror Knots"), "mirror_knots", &wr, this, true), only_selected(_("Change only selected nodes"), _("Change only selected nodes"), "only_selected", &wr, this, false), @@ -97,7 +97,7 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem) Piecewise<D2<SBasis> > pwd2_in = paths_to_pw(original_pathv); pwd2_in = remove_short_cuts(pwd2_in, 0.01); int counterTotal = 0; - std::vector<std::pair<unsigned int,Geom::Satellite> > satellites; + std::vector<std::pair<size_t,Geom::Satellite> > satellites; for (PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { if (path_it->empty()){ continue; @@ -119,7 +119,7 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem) Geom::Path::const_iterator curve_end = curve_endit; --curve_end; int counter = 0; - unsigned int steps = chamfer_steps; + size_t steps = chamfer_steps; while (curve_it1 != curve_endit) { if((*curve_it1).isDegenerate() || (*curve_it1).isDegenerate()){ g_warning("LPE Fillet not handle degenerate curves."); @@ -274,9 +274,9 @@ void LPEFilletChamfer::updateAmount() } else { power = radius/100; } - std::vector<std::pair<unsigned int,Geom::Satellite> > satellites = pointwise->getSatellites(); + std::vector<std::pair<size_t,Geom::Satellite> > satellites = pointwise->getSatellites(); Piecewise<D2<SBasis> > pwd2 = pointwise->getPwd2(); - for (std::vector<std::pair<unsigned int,Geom::Satellite> >::iterator it = satellites.begin(); it != satellites.end(); ++it) { + for (std::vector<std::pair<size_t,Geom::Satellite> >::iterator it = satellites.begin(); it != satellites.end(); ++it) { if(!pointwise->getIsClosed(it->first) && pointwise->getFirst(it->first) == it->first){ it->second.setAmount(0); continue; @@ -311,9 +311,9 @@ void LPEFilletChamfer::updateAmount() void LPEFilletChamfer::updateChamferSteps() { - std::vector<std::pair<unsigned int,Geom::Satellite> > satellites = pointwise->getSatellites(); + std::vector<std::pair<size_t,Geom::Satellite> > satellites = pointwise->getSatellites(); Piecewise<D2<SBasis> > pwd2 = pointwise->getPwd2(); - for (std::vector<std::pair<unsigned int,Geom::Satellite> >::iterator it = satellites.begin(); it != satellites.end(); ++it) { + for (std::vector<std::pair<size_t,Geom::Satellite> >::iterator it = satellites.begin(); it != satellites.end(); ++it) { if(ignore_radius_0 && it->second.getAmount() == 0){ continue; } @@ -332,9 +332,9 @@ void LPEFilletChamfer::updateChamferSteps() void LPEFilletChamfer::updateSatelliteType(Geom::SatelliteType satellitetype) { - std::vector<std::pair<unsigned int,Geom::Satellite> > satellites = pointwise->getSatellites(); + std::vector<std::pair<size_t,Geom::Satellite> > satellites = pointwise->getSatellites(); Piecewise<D2<SBasis> > pwd2 = pointwise->getPwd2(); - for (std::vector<std::pair<unsigned int,Geom::Satellite> >::iterator it = satellites.begin(); it != satellites.end(); ++it) { + for (std::vector<std::pair<size_t,Geom::Satellite> >::iterator it = satellites.begin(); it != satellites.end(); ++it) { if(ignore_radius_0 && it->second.getAmount() == 0){ continue; } @@ -371,12 +371,8 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem) PathVector const &original_pathv = pathv_to_linear_and_cubic_beziers(c->get_pathvector()); Piecewise<D2<SBasis> > pwd2_in = paths_to_pw(original_pathv); pwd2_in = remove_short_cuts(pwd2_in, 0.01); - std::vector<std::pair<unsigned int,Geom::Satellite> > sats; - if(!pointwise){ - sats = satellitepairarrayparam_values.data(); - } else { - sats = pointwise->getSatellites(); - } + std::vector<std::pair<size_t,Geom::Satellite> > sats = satellitepairarrayparam_values.data(); + //optional call if(hide_knots){ satellitepairarrayparam_values.set_helper_size(0); @@ -384,6 +380,7 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem) satellitepairarrayparam_values.set_helper_size(helper_size); } bool refresh = false; + bool hide = true; for(unsigned i = 0; i < sats.size(); i++){ if(sats[i].second.getIsTime() != flexible){ sats[i].second.setIsTime(flexible); @@ -401,13 +398,17 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem) sats[i].second.setHasMirror(mirror_knots); refresh = true; } - if(sats[i].second.getHidden() != hide_knots){ - sats[i].second.setHidden(hide_knots); - refresh = true; + if(sats[i].second.getHidden() == false){ + hide = false; } + sats[i].second.setHidden(hide_knots); + } + if(hide != hide_knots){ + refresh = true; } pointwise = new Pointwise(pwd2_in, sats); //mandatory call + pointwise->set_extremes(false, false, true); satellitepairarrayparam_values.set_pointwise(pointwise); if(refresh){ refreshKnots(); @@ -421,8 +422,9 @@ void LPEFilletChamfer::adjustForNewPath(std::vector<Geom::Path> const &path_in) { if (!path_in.empty() && pointwise) { - pointwise->recalculate_for_new_pwd2(paths_to_pw(pathv_to_linear_and_cubic_beziers(path_in))); - pointwise->set_extremes(false,true,0.0,0.0); + pointwise->recalculate_for_new_pwd2(remove_short_cuts(paths_to_pw(pathv_to_linear_and_cubic_beziers(path_in)),0.01)); + pointwise->set_extremes(true, false, true, 0.0, 0.0); + satellitepairarrayparam_values.set_pointwise(pointwise); } } @@ -431,7 +433,7 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in) { const double gapHelper = 0.00001; std::vector<Geom::Path> pathvector_out; - unsigned int counter = 0; + size_t counter = 0; const double K = (4.0 / 3.0) * (sqrt(2.0) - 1.0); std::vector<Geom::Path> path_in_processed = pathv_to_linear_and_cubic_beziers(path_in); for (PathVector::const_iterator path_it = path_in_processed.begin(); @@ -462,15 +464,15 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in) curve_endit = path_it->end_open(); } } - unsigned int counterCurves = 0; - unsigned int first = counter; + size_t counterCurves = 0; + size_t first = counter; double time0 = 0; while (curve_it1 != curve_endit) { if((*curve_it1).isDegenerate() || (*curve_it1).isDegenerate()){ g_warning("LPE Fillet not handle degenerate curves."); return path_in; } - std::vector<unsigned int> satIndexes; + std::vector<size_t> satIndexes; Satellite satellite; Curve *curve_it2Fixed = path_it->begin()->duplicate(); if(!path_it->closed()){ @@ -602,7 +604,7 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in) } } SatelliteType type = satellite.getSatelliteType(); - unsigned int steps = satellite.getSteps(); + size_t steps = satellite.getSteps(); if(steps < 1){ steps = 1; } @@ -615,7 +617,7 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in) path_chamfer.appendNew<Geom::CubicBezier>(handle1, handle2, endArcPoint); } double chamfer_stepsTime = 1.0/steps; - for(unsigned int i = 1; i < steps; i++){ + for(size_t i = 1; i < steps; i++){ Geom::Point chamferStep = path_chamfer.pointAt(chamfer_stepsTime * i); path_out.appendNew<Geom::LineSegment>(chamferStep); } @@ -630,7 +632,7 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in) path_chamfer.appendNew<Geom::CubicBezier>(inverseHandle1, inverseHandle2, endArcPoint); } double chamfer_stepsTime = 1.0/steps; - for(unsigned int i = 1; i < steps; i++){ + for(size_t i = 1; i < steps; i++){ Geom::Point chamferStep = path_chamfer.pointAt(chamfer_stepsTime * i); path_out.appendNew<Geom::LineSegment>(chamferStep); } diff --git a/src/live_effects/parameter/array.cpp b/src/live_effects/parameter/array.cpp index d8b2388da..33cb53f4e 100644 --- a/src/live_effects/parameter/array.cpp +++ b/src/live_effects/parameter/array.cpp @@ -78,20 +78,20 @@ sp_svg_satellite_read_d(gchar const *str, Geom::Satellite *sat){ } template <> -std::pair<unsigned int, Geom::Satellite> -ArrayParam<std::pair<unsigned int, Geom::Satellite> >::readsvg(const gchar * str) +std::pair<size_t, Geom::Satellite> +ArrayParam<std::pair<size_t, Geom::Satellite> >::readsvg(const gchar * str) { gchar ** strarray = g_strsplit(str, ",", 2); double index; - std::pair<unsigned int, Geom::Satellite> result; + std::pair<size_t, Geom::Satellite> result; unsigned int success = (int)sp_svg_number_read_d(strarray[0], &index); Geom::Satellite sat; success += sp_svg_satellite_read_d(strarray[1], &sat); g_strfreev (strarray); if (success == 2) { - return std::make_pair(index, sat); + return std::make_pair((size_t)index, sat); } - return std::make_pair((int)Geom::infinity(),sat); + return std::make_pair((size_t)0,sat); } } /* namespace LivePathEffect */ diff --git a/src/live_effects/parameter/array.h b/src/live_effects/parameter/array.h index 7ff477ffb..4fb053dbb 100644 --- a/src/live_effects/parameter/array.h +++ b/src/live_effects/parameter/array.h @@ -90,7 +90,7 @@ protected: size_t _default_size; void writesvg(SVGOStringStream &str, std::vector<StorageType> const &vector) const { - for (unsigned int i = 0; i < vector.size(); ++i) { + for (size_t i = 0; i < vector.size(); ++i) { if (i != 0) { // separate items with pipe symbol str << " | "; @@ -111,7 +111,7 @@ protected: str << nVector; } - void writesvgData(SVGOStringStream &str, std::pair<unsigned int, Geom::Satellite> const &nVector) const { + void writesvgData(SVGOStringStream &str, std::pair<size_t, Geom::Satellite> const &nVector) const { str << nVector.first; str << ","; str << nVector.second.getSatelliteTypeGchar(); diff --git a/src/live_effects/parameter/satellitepairarray.cpp b/src/live_effects/parameter/satellitepairarray.cpp index 47f023c29..8102edf9b 100644 --- a/src/live_effects/parameter/satellitepairarray.cpp +++ b/src/live_effects/parameter/satellitepairarray.cpp @@ -11,6 +11,7 @@ #include "knotholder.h" #include "ui/dialog/lpe-fillet-chamfer-properties.h" #include "live_effects/parameter/satellitepairarray.h" +#include "live_effects/effect.h" #include "sp-lpe-item.h" // TODO due to internal breakage in glibmm headers, // this has to be included last. @@ -27,7 +28,7 @@ SatellitePairArrayParam::SatellitePairArrayParam( const Glib::ustring &label, const Glib::ustring &tip, const Glib::ustring &key, Inkscape::UI::Widget::Registry *wr, Effect *effect) - : ArrayParam<std::pair<unsigned int,Geom::Satellite> >(label, tip, key, wr, effect, 0) + : ArrayParam<std::pair<size_t,Geom::Satellite> >(label, tip, key, wr, effect, 0) { knot_shape = SP_KNOT_SHAPE_DIAMOND; knot_mode = SP_KNOT_MODE_XOR; @@ -90,7 +91,7 @@ void SatellitePairArrayParam::updateCanvasIndicators(bool mirror) if( mirror == true){ hp.clear(); } - for (unsigned int i = 0; i < _vector.size(); ++i) { + for (size_t i = 0; i < _vector.size(); ++i) { if(!_vector[i].second.getActive() || _vector[i].second.getHidden()){ continue; } @@ -106,7 +107,7 @@ void SatellitePairArrayParam::updateCanvasIndicators(bool mirror) double size_out = _vector[i].second.getSize(pwd2[_vector[i].first]); double lenght_out = Geom::length(pwd2[_vector[i].first], Geom::EPSILON); double lenght_in = 0; - boost::optional<unsigned int> d2_prev_index = last_pointwise->getPrevious(_vector[i].first); + boost::optional<size_t> d2_prev_index = last_pointwise->getPrevious(_vector[i].first); if(d2_prev_index){ lenght_in = Geom::length(pwd2[*d2_prev_index], Geom::EPSILON); } @@ -191,8 +192,7 @@ void SatellitePairArrayParam::addCanvasIndicators( void SatellitePairArrayParam::recalculate_knots() { if(last_pointwise){ - _vector = last_pointwise->getSatellites(); - write_to_SVG(); + //_vector = last_pointwise->getSatellites(); } } @@ -202,8 +202,8 @@ void SatellitePairArrayParam::addKnotHolderEntities(KnotHolder *knotholder, bool mirror) { recalculate_knots(); - for (unsigned int i = 0; i < _vector.size(); ++i) { - int iPlus = i; + for (size_t i = 0; i < _vector.size(); ++i) { + size_t iPlus = i; if( mirror == true){ iPlus = i + _vector.size(); } @@ -254,7 +254,7 @@ void SatellitePairArrayParam::addKnotHolderEntities(KnotHolder *knotholder, addKnotHolderEntities(knotholder, desktop, item, true); } -FilletChamferKnotHolderEntity::FilletChamferKnotHolderEntity(SatellitePairArrayParam *p, unsigned int index) +FilletChamferKnotHolderEntity::FilletChamferKnotHolderEntity(SatellitePairArrayParam *p, size_t index) : _pparam(p), _index(index) { @@ -267,7 +267,7 @@ void FilletChamferKnotHolderEntity::knot_set(Point const &p, guint state) { Geom::Point s = snap_knot_position(p, state); - int index = _index; + size_t index = _index; if( _index >= _pparam->_vector.size()){ index = _index-_pparam->_vector.size(); } @@ -286,12 +286,12 @@ void FilletChamferKnotHolderEntity::knot_set(Point const &p, Geom::Pointwise* pointwise = _pparam->last_pointwise; Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = pointwise->getPwd2(); if(_pparam->_vector.size() <= _index){ - boost::optional<unsigned int> d2_prev_index = pointwise->getPrevious(satellite.first); + boost::optional<size_t> d2_prev_index = pointwise->getPrevious(satellite.first); if(d2_prev_index){ Geom::D2<Geom::SBasis> d2_in = pwd2[*d2_prev_index]; double mirrorTime = Geom::nearest_point(s, d2_in); double timeStart = 0; - std::vector<unsigned int> satIndexes = pointwise->findPeviousSatellites(satellite.first,1); + std::vector<size_t> satIndexes = pointwise->findPeviousSatellites(satellite.first,1); if(satIndexes.size()>0){ timeStart = pointwise->getSatellites()[satIndexes[0]].second.getTime(d2_in); } @@ -319,7 +319,7 @@ Geom::Point FilletChamferKnotHolderEntity::knot_get() const { Geom::Point tmpPoint; - int index = _index; + size_t index = _index; if( _index >= _pparam->_vector.size()){ index = _index-_pparam->_vector.size(); } @@ -335,9 +335,12 @@ FilletChamferKnotHolderEntity::knot_get() const } Geom::Pointwise* pointwise = _pparam->last_pointwise; Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = pointwise->getPwd2(); + if(pwd2.size() <= (unsigned)satellite.first){ + return Point(infinity(), infinity()); + } if( _index >= _pparam->_vector.size()){ tmpPoint = satellite.second.getPosition(pwd2[satellite.first]); - boost::optional<unsigned int> d2_prev_index = pointwise->getPrevious(satellite.first); + boost::optional<size_t> d2_prev_index = pointwise->getPrevious(satellite.first); if(d2_prev_index){ Geom::D2<Geom::SBasis> d2_in = pwd2[*d2_prev_index]; double s = satellite.second.getSize(pwd2[satellite.first]); @@ -349,7 +352,7 @@ FilletChamferKnotHolderEntity::knot_get() const t = 0; } double timeStart = 0; - std::vector<unsigned int> satIndexes = pointwise->findPeviousSatellites(satellite.first,1); + std::vector<size_t> satIndexes = pointwise->findPeviousSatellites(satellite.first,1); if(satIndexes.size()>0){ timeStart = pointwise->getSatellites()[satIndexes[0]].second.getTime(d2_in); } @@ -371,7 +374,7 @@ void FilletChamferKnotHolderEntity::knot_click(guint state) return; } - int index = _index; + size_t index = _index; if( _index >= _pparam->_vector.size()){ index = _index-_pparam->_vector.size(); } @@ -428,7 +431,7 @@ void FilletChamferKnotHolderEntity::knot_click(guint state) } bool aprox = false; D2<SBasis> d2_out = _pparam->last_pointwise->getPwd2()[index]; - boost::optional<unsigned int> d2_prev_index = _pparam->last_pointwise->getPrevious(_pparam->_vector.at(index).first); + boost::optional<size_t> d2_prev_index = _pparam->last_pointwise->getPrevious(_pparam->_vector.at(index).first); if(d2_prev_index){ Geom::D2<Geom::SBasis> d2_in = _pparam->last_pointwise->getPwd2()[*d2_prev_index]; aprox = ((d2_in)[0].degreesOfFreedom() != 2 || d2_out[0].degreesOfFreedom() != 2) && !_pparam->use_distance?true:false; @@ -444,7 +447,7 @@ void FilletChamferKnotHolderEntity::knot_set_offset(Geom::Satellite satellite) if( !_pparam->last_pointwise){ return; } - int index = _index; + size_t index = _index; if( _index >= _pparam->_vector.size()){ index = _index-_pparam->_vector.size(); } diff --git a/src/live_effects/parameter/satellitepairarray.h b/src/live_effects/parameter/satellitepairarray.h index 9b22a386b..a85e3f83f 100644 --- a/src/live_effects/parameter/satellitepairarray.h +++ b/src/live_effects/parameter/satellitepairarray.h @@ -30,7 +30,7 @@ namespace LivePathEffect { class FilletChamferKnotHolderEntity; -class SatellitePairArrayParam : public ArrayParam<std::pair<unsigned int, Geom::Satellite> > { +class SatellitePairArrayParam : public ArrayParam<std::pair<size_t, Geom::Satellite> > { public: SatellitePairArrayParam(const Glib::ustring &label, const Glib::ustring &tip, @@ -81,7 +81,7 @@ private: class FilletChamferKnotHolderEntity : public KnotHolderEntity { public: - FilletChamferKnotHolderEntity(SatellitePairArrayParam *p, unsigned int index); + FilletChamferKnotHolderEntity(SatellitePairArrayParam *p, size_t index); virtual ~FilletChamferKnotHolderEntity() {} virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); @@ -89,13 +89,13 @@ public: virtual void knot_click(guint state); void knot_set_offset(Geom::Satellite); /** Checks whether the index falls within the size of the parameter's vector */ - bool valid_index(unsigned int index) const { + bool valid_index(size_t index) const { return (_pparam->_vector.size() > index); }; private: SatellitePairArrayParam *_pparam; - unsigned int _index; + size_t _index; }; } //namespace LivePathEffect diff --git a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp index aa27a1414..6875799f8 100644 --- a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp +++ b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp @@ -177,7 +177,7 @@ void FilletChamferPropertiesDialog::_apply() d_pos = Inkscape::Util::Quantity::convert(d_pos, unit, document_unit); } _satellite.setAmount( d_pos); - unsigned int steps = (unsigned int)_fillet_chamfer_chamfer_subdivisions.get_value(); + size_t steps = (size_t)_fillet_chamfer_chamfer_subdivisions.get_value(); if(steps < 1){ steps = 1; } |
