diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2015-04-06 22:22:14 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2015-04-06 22:22:14 +0000 |
| commit | 1a4fb1c5b0c91ed84f3a98bc78cfc725d043e629 (patch) | |
| tree | 62bfc4f11a05cfbe8fdf64e15e967e505258bbd7 /src | |
| parent | rename pathinfo function (diff) | |
| download | inkscape-1a4fb1c5b0c91ed84f3a98bc78cfc725d043e629.tar.gz inkscape-1a4fb1c5b0c91ed84f3a98bc78cfc725d043e629.zip | |
Adding and renaming methofs to pathinfo
(bzr r13645.1.79)
Diffstat (limited to 'src')
| -rw-r--r-- | src/helper/geom-pathinfo.cpp | 5 | ||||
| -rw-r--r-- | src/helper/geom-pathinfo.h | 1 | ||||
| -rw-r--r-- | src/helper/geom-pointwise.cpp | 40 | ||||
| -rw-r--r-- | src/helper/geom-pointwise.h | 6 | ||||
| -rw-r--r-- | src/live_effects/lpe-fillet-chamfer.cpp | 11 |
5 files changed, 30 insertions, 33 deletions
diff --git a/src/helper/geom-pathinfo.cpp b/src/helper/geom-pathinfo.cpp index 0cb7c64dd..8144564cb 100644 --- a/src/helper/geom-pathinfo.cpp +++ b/src/helper/geom-pathinfo.cpp @@ -85,6 +85,11 @@ size_t Pathinfo::size() const return data.back().first + 1; } +size_t Pathinfo::subPathSize(size_t index) const +{ + return data[index].first + 1; +} + size_t Pathinfo::subPathIndex(size_t index) const { for (size_t i = 0; i < data.size(); i++) { diff --git a/src/helper/geom-pathinfo.h b/src/helper/geom-pathinfo.h index 73220b959..85c4ca6fa 100644 --- a/src/helper/geom-pathinfo.h +++ b/src/helper/geom-pathinfo.h @@ -28,6 +28,7 @@ public: void setPwd2(Piecewise<D2<SBasis> > pwd2); void setPathVector(Geom::PathVector path_vector, bool skip_degenerate = false); size_t size() const; + size_t subPathSize(size_t index) const; size_t subPathIndex(size_t index) const; size_t last(size_t index) const; size_t first(size_t index) const; diff --git a/src/helper/geom-pointwise.cpp b/src/helper/geom-pointwise.cpp index 54cfbb45d..5b153841b 100644 --- a/src/helper/geom-pointwise.cpp +++ b/src/helper/geom-pointwise.cpp @@ -78,14 +78,14 @@ void Pointwise::setStart() /** Fired when a path is modified. */ -void Pointwise::recalculateForNewPwd2(Piecewise<D2<SBasis> > A, Geom::PathVector B) +void Pointwise::recalculateForNewPwd2(Piecewise<D2<SBasis> > A, Geom::PathVector B, Satellite S) { if (_pwd2.size() > A.size()) { pwd2Sustract(A); } else if (_pwd2.size() < A.size()) { - pwd2Append(A); + pwd2Append(A, S); } else { - insertDegenerateSatellites(A,B); + insertDegenerateSatellites(A, B, S); } } @@ -110,11 +110,10 @@ void Pointwise::pwd2Sustract(Piecewise<D2<SBasis> > A) /** Append nodes/subpaths to current pointwise */ -void Pointwise::pwd2Append(Piecewise<D2<SBasis> > A) +void Pointwise::pwd2Append(Piecewise<D2<SBasis> > A, Satellite S) { size_t counter = 0; std::vector<Satellite> sats; - bool reversed = false; bool reorder = false; for (size_t i = 0; i < A.size(); i++) { size_t first = _path_info.first(i - counter); @@ -130,6 +129,7 @@ void Pointwise::pwd2Append(Piecewise<D2<SBasis> > A) } else { subpath_is_changed = new_subpath_index != _path_info.subPathIndex(i - counter); } + if (!reorder && first == i - counter && !are_near(_pwd2[i - counter].at0(), A[i].at0()) && !subpath_is_changed) { //Send the modified subpath to back subpathToBack(_path_info.subPathIndex(first)); @@ -137,23 +137,14 @@ void Pointwise::pwd2Append(Piecewise<D2<SBasis> > A) i--; continue; } - if (!reversed && first == i - counter && !are_near(_pwd2[i - counter].at0(), A[i].at0()) && !subpath_is_changed) { + + if (first == i - counter && !are_near(_pwd2[i - counter].at0(), A[i].at0()) && !subpath_is_changed) { subpathReverse(first, last); - reversed = true; } if (_pwd2.size() <= i - counter || !are_near(_pwd2[i - counter].at0(), A[i].at0())){ counter++; - bool active = true; - bool hidden = false; - bool is_time = _satellites[0].isTime; - bool mirror_knots = _satellites[0].hasMirror; - double amount = 0.0; - double degrees = 0.0; - int steps = 0; - Satellite sat(_satellites[0].satelliteType, is_time, active, mirror_knots, - hidden, amount, degrees, steps); - sats.push_back(sat); + sats.push_back(S); } else { sats.push_back(_satellites[i - counter]); } @@ -205,7 +196,7 @@ void Pointwise::subpathReverse(size_t start, size_t end) { start++; for (size_t i = end; i >= start; i--) { - _satellites.push_back(_satellites[i]); + _satellites.insert(_satellites.begin() + end + 1, _satellites[i]); _satellites.erase(_satellites.begin() + i); } std::vector<Geom::Path> path_in = @@ -234,7 +225,7 @@ void Pointwise::subpathReverse(size_t start, size_t end) /** Fired when a path is modified duplicating a node. Piecewise ignore degenerated curves. */ -void Pointwise::insertDegenerateSatellites(Piecewise<D2<SBasis> > A, Geom::PathVector B) +void Pointwise::insertDegenerateSatellites(Piecewise<D2<SBasis> > A, Geom::PathVector B, Satellite S) { size_t size_A = A.size(); _path_info.setPathVector(B); @@ -261,16 +252,7 @@ void Pointwise::insertDegenerateSatellites(Piecewise<D2<SBasis> > A, Geom::PathV while (curve_it1 != curve_endit) { if ((*curve_it1).isDegenerate() && counter_added < satellite_gap){ counter_added++; - bool active = true; - bool hidden = false; - bool is_time = _satellites[0].isTime; - bool mirror_knots = _satellites[0].hasMirror; - double amount = 0.0; - double degrees = 0.0; - int steps = 0; - Satellite sat(_satellites[0].satelliteType, is_time, active, mirror_knots, - hidden, amount, degrees, steps); - _satellites.insert(_satellites.begin() + counter + 1 ,sat); + _satellites.insert(_satellites.begin() + counter + 1 ,S); } ++curve_it1; counter++; diff --git a/src/helper/geom-pointwise.h b/src/helper/geom-pointwise.h index 48ee36255..e4b9f2b05 100644 --- a/src/helper/geom-pointwise.h +++ b/src/helper/geom-pointwise.h @@ -48,12 +48,12 @@ public: void setStart(); - void recalculateForNewPwd2(Piecewise<D2<SBasis> > A, Geom::PathVector B); + void recalculateForNewPwd2(Piecewise<D2<SBasis> > A, Geom::PathVector B, Satellite S); void pwd2Sustract(Piecewise<D2<SBasis> > A); - void pwd2Append(Piecewise<D2<SBasis> > A); + void pwd2Append(Piecewise<D2<SBasis> > A, Satellite S); void subpathToBack(size_t subpath); void subpathReverse(size_t start, size_t end); - void insertDegenerateSatellites(Piecewise<D2<SBasis> > A, Geom::PathVector B); + void insertDegenerateSatellites(Piecewise<D2<SBasis> > A, Geom::PathVector B, Satellite S); private: Piecewise<D2<SBasis> > _pwd2; diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp index cad67cea9..a846e4bad 100644 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ b/src/live_effects/lpe-fillet-chamfer.cpp @@ -429,7 +429,16 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem) Pathinfo path_info(original_pathv); size_t number_curves = path_info.size(); if (pointwise && number_curves != sats.size()) { - pointwise->recalculateForNewPwd2(pwd2_in, original_pathv); + bool active = true; + bool hidden = false; + bool is_time = sats[0].isTime; + bool mirror_knots = sats[0].hasMirror; + double amount = 0.0; + double degrees = 0.0; + int steps = 0; + Satellite sat(sats[0].satelliteType, is_time, active, mirror_knots, + hidden, amount, degrees, steps); + pointwise->recalculateForNewPwd2(pwd2_in, original_pathv, sat); } else { pointwise = new Pointwise(pwd2_in, sats); } |
