diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2015-05-10 20:36:27 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2015-05-10 20:36:27 +0000 |
| commit | c7925bda67f038dd5054329c43936658ca2cae76 (patch) | |
| tree | 60fbe1aab9418446cd40ab32495747034a0b65a9 /src | |
| parent | Added some comments (diff) | |
| download | inkscape-c7925bda67f038dd5054329c43936658ca2cae76.tar.gz inkscape-c7925bda67f038dd5054329c43936658ca2cae76.zip | |
some comments and pointwise related refactor
(bzr r13645.1.91)
Diffstat (limited to 'src')
| -rw-r--r-- | src/helper/geom-pathinfo.cpp | 11 | ||||
| -rw-r--r-- | src/helper/geom-pathinfo.h | 3 | ||||
| -rw-r--r-- | src/helper/geom-pointwise.cpp | 23 | ||||
| -rw-r--r-- | src/helper/geom-pointwise.h | 14 | ||||
| -rw-r--r-- | src/helper/geom-satellite.cpp | 2 | ||||
| -rw-r--r-- | src/live_effects/lpe-fillet-chamfer.cpp | 25 | ||||
| -rw-r--r-- | src/live_effects/parameter/satellitearray.cpp | 27 |
7 files changed, 57 insertions, 48 deletions
diff --git a/src/helper/geom-pathinfo.cpp b/src/helper/geom-pathinfo.cpp index d37b8b6da..d73f8f707 100644 --- a/src/helper/geom-pathinfo.cpp +++ b/src/helper/geom-pathinfo.cpp @@ -17,16 +17,7 @@ * @brief Pathinfo store the _data of a Geom::PathVector and allow get info about it * */ -Pathinfo::Pathinfo(Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2) -{ - set(pwd2); -} - -Pathinfo::Pathinfo(Geom::PathVector path_vector, bool skip_degenerate) -{ - set(path_vector, skip_degenerate); -} - +Pathinfo::Pathinfo() {} Pathinfo::~Pathinfo() {} diff --git a/src/helper/geom-pathinfo.h b/src/helper/geom-pathinfo.h index cd3a3b2b8..41753c68f 100644 --- a/src/helper/geom-pathinfo.h +++ b/src/helper/geom-pathinfo.h @@ -22,8 +22,7 @@ class Pathinfo { public: - Pathinfo(Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2); - Pathinfo(Geom::PathVector path_vector, bool skip_degenerate = false); + Pathinfo(); virtual ~Pathinfo(); void set(Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2); void set(Geom::PathVector path_vector, bool skip_degenerate = false); diff --git a/src/helper/geom-pointwise.cpp b/src/helper/geom-pointwise.cpp index 3041c60ea..5f6c0d29e 100644 --- a/src/helper/geom-pointwise.cpp +++ b/src/helper/geom-pointwise.cpp @@ -3,8 +3,14 @@ * \brief Pointwise a class to manage a vector of satellites per piecewise curve */ /* * Authors: - * 2015 Jabier Arraiza Cenoz<jabier.arraiza@marker.es> - * + * Jabiertxof + * Johan Engelen + * Josh Andler + * suv + * Mc- + * Liam P. White + * Nathan Hurst + * Krzysztof Kosiński * This code is in public domain */ @@ -23,12 +29,7 @@ * optional satellites, and remove the active variable in satellites. * */ -Pointwise::Pointwise(Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2, - std::vector<Satellite> satellites) - : _pwd2(pwd2), _satellites(satellites), _path_info(pwd2) -{ - setStart(); -} +Pointwise::Pointwise() {} Pointwise::~Pointwise() {} @@ -48,7 +49,6 @@ void Pointwise::setPwd2(Geom::Piecewise<Geom::D2<Geom::SBasis> > const pwd2_in) void Pointwise::setPathInfo(Geom::PathVector const pv) { _path_info.set(pv); - setStart(); } std::vector<Satellite> Pointwise::getSatellites() const @@ -59,10 +59,9 @@ std::vector<Satellite> Pointwise::getSatellites() const void Pointwise::setSatellites(std::vector<Satellite> const sats) { _satellites = sats; - setStart(); } -/** Update the start satellite on ope/closed paths. +/** Update the start satellite on open/closed paths. */ void Pointwise::setStart() { @@ -137,7 +136,6 @@ void Pointwise::pwd2Append(Geom::Piecewise<Geom::D2<Geom::SBasis> > const A, Sat if (!reorder && first == i - counter && !are_near(_pwd2[i - counter].at0(), A[i].at0()) && !subpath_is_changed) { //Send the modified subpath to back - //TODO: change subpathToBack to subpath move for the case of multiple subpath reverse subpathToBack(_path_info.subPathIndex(first)); reorder = true; i--; @@ -145,6 +143,7 @@ void Pointwise::pwd2Append(Geom::Piecewise<Geom::D2<Geom::SBasis> > const A, Sat } if (first == i - counter && !are_near(_pwd2[i - counter].at0(), A[i].at0()) && !subpath_is_changed) { + //reverse subpath subpathReverse(first, last); } diff --git a/src/helper/geom-pointwise.h b/src/helper/geom-pointwise.h index 3cb4ff136..d83b54b79 100644 --- a/src/helper/geom-pointwise.h +++ b/src/helper/geom-pointwise.h @@ -1,10 +1,16 @@ /** * \file - * \brief Pointwise a class to manage a vector of satellites, once per piecewise curve + * \brief Pointwise a class to manage a vector of satellites per piecewise curve */ /* * Authors: - * 2015 Jabier Arraiza Cenoz<jabier.arraiza@marker.es> - * + * Jabiertxof + * Johan Engelen + * Josh Andler + * suv + * Mc- + * Liam P. White + * Nathan Hurst + * Krzysztof Kosiński * This code is in public domain */ @@ -36,7 +42,7 @@ class Pointwise { public: - Pointwise(Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2, std::vector<Satellite> satellites); + Pointwise(); virtual ~Pointwise(); Geom::Piecewise<Geom::D2<Geom::SBasis> > getPwd2() const; diff --git a/src/helper/geom-satellite.cpp b/src/helper/geom-satellite.cpp index d03839875..cd3f65f68 100644 --- a/src/helper/geom-satellite.cpp +++ b/src/helper/geom-satellite.cpp @@ -80,7 +80,7 @@ double arcLengthAt(double A, Geom::D2<Geom::SBasis> const d2_in) } /** - * Convert a arc radius of a fillet/chamfer to his satellite length -point position where fillet/chamferknot be on original curve + * Convert a arc radius of a fillet/chamfer to his satellite length -point position where fillet/chamfer knot be on original curve */ double Satellite::radToLen( double A, Geom::D2<Geom::SBasis> const d2_in, diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp index 16bef6a99..3e7c1d0e1 100644 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ b/src/live_effects/lpe-fillet-chamfer.cpp @@ -139,8 +139,11 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem) global_counter++; } } - pointwise = new Pointwise(pwd2_in, satellites); + pointwise = new Pointwise(); + pointwise->setPwd2(pwd2_in); + pointwise->setSatellites(satellites); pointwise->setPathInfo(original_pathv); + pointwise->setStart(); satellites_param.setPointwise(pointwise); } else { g_warning("LPE Fillet/Chamfer can only be applied to shapes (not groups)."); @@ -278,12 +281,13 @@ void LPEFilletChamfer::updateAmount() } std::vector<Satellite> satellites = pointwise->getSatellites(); Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = pointwise->getPwd2(); - Pathinfo path_info(pwd2); + Pathinfo* path_info = new Pathinfo(); + path_info->set(pwd2); for (std::vector<Satellite>::iterator it = satellites.begin(); it != satellites.end(); ++it) { - if (!path_info.closed(it - satellites.begin()) && - path_info.first(it - satellites.begin()) == + if (!path_info->closed(it - satellites.begin()) && + path_info->first(it - satellites.begin()) == (unsigned)(it - satellites.begin())) { it->amount = 0; @@ -293,7 +297,7 @@ void LPEFilletChamfer::updateAmount() continue; } boost::optional<size_t> previous = - path_info.previous(it - satellites.begin()); + path_info->previous(it - satellites.begin()); if (only_selected) { Geom::Point satellite_point = pwd2.valueAt(it - satellites.begin()); if (isNodePointSelected(satellite_point)) { @@ -421,8 +425,10 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem) it->hidden = hide_knots; ++it; } - Pathinfo path_info(original_pathv); - size_t number_curves = path_info.size(); + Pathinfo* path_info = new Pathinfo(); + path_info->set(original_pathv); + size_t number_curves = path_info->size(); + //if are diferent sizes call to poinwise recalculate if (pointwise && number_curves != sats.size()) { Satellite sat(sats[0].satellite_type); sat.setIsTime(sats[0].is_time); @@ -434,9 +440,12 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem) sat.setSteps(0); pointwise->recalculateForNewPwd2(pwd2_in, original_pathv, sat); } else { - pointwise = new Pointwise(pwd2_in, sats); + pointwise = new Pointwise(); + pointwise->setPwd2(pwd2_in); + pointwise->setSatellites(sats); } pointwise->setPathInfo(original_pathv); + pointwise->setStart(); satellites_param.setPointwise(pointwise); refreshKnots(); } else { diff --git a/src/live_effects/parameter/satellitearray.cpp b/src/live_effects/parameter/satellitearray.cpp index 7df849c24..4eefea0b0 100644 --- a/src/live_effects/parameter/satellitearray.cpp +++ b/src/live_effects/parameter/satellitearray.cpp @@ -76,7 +76,8 @@ void SatelliteArrayParam::updateCanvasIndicators(bool mirror) return; } Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = _last_pointwise->getPwd2(); - Pathinfo path_info(pwd2); + Pathinfo* path_info = new Pathinfo(); + path_info->set(pwd2); if (mirror == true) { _hp.clear(); } @@ -96,7 +97,7 @@ void SatelliteArrayParam::updateCanvasIndicators(bool mirror) double size_out = _vector[i].arcDistance(pwd2[i]); double lenght_out = Geom::length(pwd2[i], Geom::EPSILON); double lenght_in = 0; - boost::optional<size_t> d2_prev_index = path_info.previous(i); + boost::optional<size_t> d2_prev_index = path_info->previous(i); if (d2_prev_index) { lenght_in = Geom::length(pwd2[*d2_prev_index], Geom::EPSILON); } @@ -282,9 +283,10 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p, } Pointwise *pointwise = _pparam->_last_pointwise; Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = pointwise->getPwd2(); - Pathinfo path_info(pwd2); + Pathinfo* path_info = new Pathinfo(); + path_info->set(pwd2); if (_pparam->_vector.size() <= _index) { - boost::optional<size_t> d2_prev_index = path_info.previous(index); + boost::optional<size_t> d2_prev_index = path_info->previous(index); if (d2_prev_index) { Geom::D2<Geom::SBasis> d2_in = pwd2[*d2_prev_index]; double mirror_time = Geom::nearest_point(s, d2_in); @@ -330,14 +332,15 @@ Geom::Point FilletChamferKnotHolderEntity::knot_get() const } Pointwise *pointwise = _pparam->_last_pointwise; Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = pointwise->getPwd2(); - Pathinfo path_info(pwd2); + Pathinfo* path_info = new Pathinfo(); + path_info->set(pwd2); if (pwd2.size() <= index) { return Geom::Point(Geom::infinity(), Geom::infinity()); } this->knot->show(); if (_index >= _pparam->_vector.size()) { tmp_point = satellite.getPosition(pwd2[index]); - boost::optional<size_t> d2_prev_index = path_info.previous(index); + boost::optional<size_t> d2_prev_index = path_info->previous(index); if (d2_prev_index) { Geom::D2<Geom::SBasis> d2_in = pwd2[*d2_prev_index]; double s = satellite.arcDistance(pwd2[index]); @@ -420,10 +423,11 @@ void FilletChamferKnotHolderEntity::knot_click(guint state) } } else if (state & GDK_SHIFT_MASK) { Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = _pparam->_last_pointwise->getPwd2(); - Pathinfo path_info(pwd2); + Pathinfo* path_info = new Pathinfo(); + path_info->set(pwd2); double amount = _pparam->_vector.at(index).amount; if (!_pparam->_use_distance && !_pparam->_vector.at(index).is_time) { - boost::optional<size_t> prev = path_info.previous(index); + boost::optional<size_t> prev = path_info->previous(index); if (prev) { amount = _pparam->_vector.at(index).lenToRad(amount, pwd2[*prev], pwd2[index],_pparam->_vector.at(*prev)); } else { @@ -432,7 +436,7 @@ void FilletChamferKnotHolderEntity::knot_click(guint state) } bool aprox = false; Geom::D2<Geom::SBasis> d2_out = _pparam->_last_pointwise->getPwd2()[index]; - boost::optional<size_t> d2_prev_index = path_info.previous(index); + boost::optional<size_t> d2_prev_index = path_info->previous(index); if (d2_prev_index) { Geom::D2<Geom::SBasis> d2_in = _pparam->_last_pointwise->getPwd2()[*d2_prev_index]; @@ -462,8 +466,9 @@ void FilletChamferKnotHolderEntity::knot_set_offset(Satellite satellite) double max_amount = amount; if (!_pparam->_use_distance && !satellite.is_time) { Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = _pparam->_last_pointwise->getPwd2(); - Pathinfo path_info(pwd2); - boost::optional<size_t> prev = path_info.previous(index); + Pathinfo* path_info = new Pathinfo(); + path_info->set(pwd2); + boost::optional<size_t> prev = path_info->previous(index); if (prev) { amount = _pparam->_vector.at(index).radToLen(amount, pwd2[*prev], pwd2[index], _pparam->_vector.at(*prev)); } else { |
