diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2015-04-01 15:54:35 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2015-04-01 15:54:35 +0000 |
| commit | f3965759e52107c1cdcd8b7e248e5538fdaa11b6 (patch) | |
| tree | efa7e5eb155b812903d14e76244e462dd84f47d8 /src | |
| parent | add documentation (diff) | |
| download | inkscape-f3965759e52107c1cdcd8b7e248e5538fdaa11b6.tar.gz inkscape-f3965759e52107c1cdcd8b7e248e5538fdaa11b6.zip | |
Added documentation and fix to coding style.
(bzr r13645.1.66)
Diffstat (limited to 'src')
| -rw-r--r-- | src/helper/geom-pathinfo.cpp | 119 | ||||
| -rw-r--r-- | src/helper/geom-pathinfo.h | 52 | ||||
| -rw-r--r-- | src/helper/geom-pointwise.cpp | 185 | ||||
| -rw-r--r-- | src/helper/geom-pointwise.h | 55 | ||||
| -rw-r--r-- | src/helper/geom-satellite-enum.h | 22 | ||||
| -rw-r--r-- | src/helper/geom-satellite.cpp | 153 | ||||
| -rw-r--r-- | src/helper/geom-satellite.h | 47 | ||||
| -rw-r--r-- | src/live_effects/lpe-fillet-chamfer.cpp | 656 | ||||
| -rw-r--r-- | src/live_effects/lpe-fillet-chamfer.h | 12 | ||||
| -rw-r--r-- | src/live_effects/parameter/satellitearray.cpp | 403 | ||||
| -rw-r--r-- | src/live_effects/parameter/satellitearray.h | 89 | ||||
| -rw-r--r-- | src/ui/dialog/lpe-fillet-chamfer-properties.cpp | 80 | ||||
| -rw-r--r-- | src/ui/dialog/lpe-fillet-chamfer-properties.h | 54 |
13 files changed, 1011 insertions, 916 deletions
diff --git a/src/helper/geom-pathinfo.cpp b/src/helper/geom-pathinfo.cpp index 19991e879..f12004535 100644 --- a/src/helper/geom-pathinfo.cpp +++ b/src/helper/geom-pathinfo.cpp @@ -1,12 +1,12 @@ /** * \file * \brief Pathinfo store the data of a pathvector and allow get info about it - *//* - * Authors: - * 2015 Jabier Arraiza Cenoz<jabier.arraiza@marker.es> - * - * This code is in public domain - */ + */ /* + * Authors: + * 2015 Jabier Arraiza Cenoz<jabier.arraiza@marker.es> + * + * This code is in public domain + */ #include <helper/geom-pathinfo.h> #include <2geom/sbasis-to-bezier.h> @@ -17,131 +17,120 @@ namespace Geom { * @brief Pathinfo store the data of a pathvector and allow get info about it * */ -Pathinfo::Pathinfo(Piecewise<D2<SBasis> > pwd2) - : _pwd2(pwd2) +Pathinfo::Pathinfo(Piecewise<D2<SBasis> > pwd2) : _pwd2(pwd2) { - setPathInfo(); -}; + _setPathInfo(); +} +; -Pathinfo::~Pathinfo(){}; +Pathinfo::~Pathinfo() {} +; -void -Pathinfo::setPwd2(Piecewise<D2<SBasis> > pwd2_in) +void Pathinfo::setPwd2(Piecewise<D2<SBasis> > pwd2_in) { _pwd2 = pwd2_in; - setPathInfo(); + _setPathInfo(); } /** Store the base path data */ -void -Pathinfo::setPathInfo() +void Pathinfo::_setPathInfo() { - _pathInfo.clear(); - std::vector<Geom::Path> path_in = path_from_piecewise(remove_short_cuts(_pwd2,0.1), 0.001); + data.clear(); + std::vector<Geom::Path> path_in = + path_from_piecewise(remove_short_cuts(_pwd2, 0.1), 0.001); size_t counter = 0; - for (PathVector::const_iterator path_it = path_in.begin(); path_it != path_in.end(); ++path_it) { - if (path_it->empty()){ + for (PathVector::const_iterator path_it = path_in.begin(); + path_it != path_in.end(); ++path_it) { + if (path_it->empty()) { continue; } Geom::Path::const_iterator curve_it1 = path_it->begin(); Geom::Path::const_iterator curve_endit = path_it->end_default(); if (path_it->closed()) { - const Curve &closingline = path_it->back_closed(); - if (are_near(closingline.initialPoint(), closingline.finalPoint())) { - curve_endit = path_it->end_open(); - } + const Curve &closingline = path_it->back_closed(); + if (are_near(closingline.initialPoint(), closingline.finalPoint())) { + curve_endit = path_it->end_open(); + } } while (curve_it1 != curve_endit) { ++curve_it1; counter++; } - if(path_it->closed()){ - _pathInfo.push_back(std::make_pair(counter-1,true)); + if (path_it->closed()) { + data.push_back(std::make_pair(counter - 1, true)); } else { - _pathInfo.push_back(std::make_pair(counter-1,false)); + data.push_back(std::make_pair(counter - 1, false)); } } } -size_t -Pathinfo::getSubPathIndex(size_t index) const +size_t Pathinfo::subPathIndex(size_t index) const { - for(size_t i = 0; i < _pathInfo.size(); i++){ - if(index <= _pathInfo[i].first){ + for (size_t i = 0; i < data.size(); i++) { + if (index <= data[i].first) { return i; } } return 0; } -size_t -Pathinfo::getLast(size_t index) const +size_t Pathinfo::last(size_t index) const { - for(size_t i = 0; i < _pathInfo.size(); i++){ - if(index <= _pathInfo[i].first){ - return _pathInfo[i].first; + for (size_t i = 0; i < data.size(); i++) { + if (index <= data[i].first) { + return data[i].first; } } return 0; } -size_t -Pathinfo::getFirst(size_t index) const +size_t Pathinfo::first(size_t index) const { - for(size_t i = 0; i < _pathInfo.size(); i++){ - if(index <= _pathInfo[i].first){ - if(i==0){ + for (size_t i = 0; i < data.size(); i++) { + if (index <= data[i].first) { + if (i == 0) { return 0; } else { - return _pathInfo[i-1].first + 1; + return data[i - 1].first + 1; } } } return 0; } -boost::optional<size_t> -Pathinfo::getPrevious(size_t index) const +boost::optional<size_t> Pathinfo::previous(size_t index) const { - if(getFirst(index) == index && getIsClosed(index)){ - return getLast(index); + if (first(index) == index && isClosed(index)) { + return last(index); } - if(getFirst(index) == index && !getIsClosed(index)){ + if (first(index) == index && !isClosed(index)) { return boost::none; } return index - 1; } -boost::optional<size_t> -Pathinfo::getNext(size_t index) const +boost::optional<size_t> Pathinfo::next(size_t index) const { - if(getLast(index) == index && getIsClosed(index)){ - return getFirst(index); + if (last(index) == index && isClosed(index)) { + return first(index); } - if(getLast(index) == index && !getIsClosed(index)){ + if (last(index) == index && !isClosed(index)) { return boost::none; } return index + 1; } -bool -Pathinfo::getIsClosed(size_t index) const +bool Pathinfo::isClosed(size_t index) const { - for(size_t i = 0; i < _pathInfo.size(); i++){ - if(index <= _pathInfo[i].first){ - return _pathInfo[i].second; + for (size_t i = 0; i < data.size(); i++) { + if (index <= data[i].first) { + return data[i].second; } } return false; } -std::vector<std::pair<size_t, bool> > -Pathinfo::getPathInfo() const -{ - return _pathInfo; -} - }; // namespace Geom /* @@ -153,4 +142,6 @@ Pathinfo::getPathInfo() const fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: +// filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 +// : diff --git a/src/helper/geom-pathinfo.h b/src/helper/geom-pathinfo.h index 9a40a4f20..c9d8e2862 100644 --- a/src/helper/geom-pathinfo.h +++ b/src/helper/geom-pathinfo.h @@ -1,12 +1,12 @@ /** * \file * \brief Pathinfo store the data of a pathvector and allow get info about it - *//* - * Authors: - * 2015 Jabier Arraiza Cenoz<jabier.arraiza@marker.es> - * - * This code is in public domain - */ + */ /* + * Authors: + * 2015 Jabier Arraiza Cenoz<jabier.arraiza@marker.es> + * + * This code is in public domain + */ #ifndef SEEN_GEOM_PATHINFO_H #define SEEN_GEOM_PATHINFO_H @@ -20,29 +20,27 @@ namespace Geom { * @brief Pathinfo store the data of a pathvector and allow get info about it * */ -class Pathinfo -{ - public: - Pathinfo(Piecewise<D2<SBasis> > pwd2); - virtual ~Pathinfo(); - void setPwd2(Piecewise<D2<SBasis> > pwd2_in); - 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; - std::vector<std::pair<size_t, bool> > getPathInfo() const; - - private: - void setPathInfo(); - Piecewise<D2<SBasis> > _pwd2; - std::vector<std::pair<size_t, bool> > _pathInfo; +class Pathinfo { +public: + Pathinfo(Piecewise<D2<SBasis> > pwd2); + virtual ~Pathinfo(); + void setPwd2(Piecewise<D2<SBasis> > pwd2_in); + size_t subPathIndex(size_t index) const; + size_t last(size_t index) const; + size_t first(size_t index) const; + boost::optional<size_t> previous(size_t index) const; + boost::optional<size_t> next(size_t index) const; + bool isClosed(size_t index) const; + std::vector<std::pair<size_t, bool> > pathInfo() const; + std::vector<std::pair<size_t, bool> > data; + +private: + void _setPathInfo(); + Piecewise<D2<SBasis> > _pwd2; }; } //namespace Geom - #endif //SEEN_GEOM_PATHINFO_H /* Local Variables: @@ -53,4 +51,6 @@ class Pathinfo fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: +// filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 +// : diff --git a/src/helper/geom-pointwise.cpp b/src/helper/geom-pointwise.cpp index 9e65685ae..cfe93311c 100644 --- a/src/helper/geom-pointwise.cpp +++ b/src/helper/geom-pointwise.cpp @@ -1,23 +1,22 @@ /** * \file * \brief Pointwise a class to manage a vector of satellites per piecewise curve - *//* - * Authors: - * 2015 Jabier Arraiza Cenoz<jabier.arraiza@marker.es> - * - * This code is in public domain - */ + */ /* + * Authors: + * 2015 Jabier Arraiza Cenoz<jabier.arraiza@marker.es> + * + * This code is in public domain + */ #include <helper/geom-pointwise.h> - namespace Geom { /** * @brief Pointwise a class to manage a vector of satellites per piecewise curve * * For the moment is a per curve satellite holder not per node. This is ok for - * much cases but not a real node satellite on open paths + * much cases but not a real node satellite on open paths * To implement this we can: * add extra satellite in open paths, and take notice of current open paths * or put extra satellites on back for each open subpath @@ -26,35 +25,34 @@ namespace Geom { * optional satellites, and remove the active variable in satellites. * */ -Pointwise::Pointwise(Piecewise<D2<SBasis> > pwd2, std::vector<Satellite> satellites) - : _pwd2(pwd2), _satellites(satellites), _pathInfo(pwd2) +Pointwise::Pointwise(Piecewise<D2<SBasis> > pwd2, + std::vector<Satellite> satellites) + : _pwd2(pwd2), _satellites(satellites), _path_info(pwd2) { setStart(); -}; +} +; -Pointwise::~Pointwise(){}; +Pointwise::~Pointwise() {} +; -Piecewise<D2<SBasis> > -Pointwise::getPwd2() const +Piecewise<D2<SBasis> > Pointwise::getPwd2() const { return _pwd2; } -void -Pointwise::setPwd2(Piecewise<D2<SBasis> > pwd2_in) +void Pointwise::setPwd2(Piecewise<D2<SBasis> > pwd2_in) { _pwd2 = pwd2_in; - _pathInfo.setPwd2(_pwd2); + _path_info.setPwd2(_pwd2); } -std::vector<Satellite> -Pointwise::getSatellites() const +std::vector<Satellite> Pointwise::getSatellites() const { return _satellites; } -void -Pointwise::setSatellites(std::vector<Satellite> sats) +void Pointwise::setSatellites(std::vector<Satellite> sats) { _satellites = sats; setStart(); @@ -62,14 +60,13 @@ Pointwise::setSatellites(std::vector<Satellite> sats) /** Update the start satellite on ope/closed paths. */ -void -Pointwise::setStart() +void Pointwise::setStart() { - std::vector<std::pair<size_t, bool> > pathInfo = _pathInfo.getPathInfo(); - for(size_t i = 0; i < pathInfo.size(); i++){ - size_t firstNode = _pathInfo.getFirst(pathInfo[i].first); - size_t lastNode = _pathInfo.getLast(pathInfo[i].first); - if(!_pathInfo.getIsClosed(lastNode)){ + std::vector<std::pair<size_t, bool> > path_info = _path_info.data; + for (size_t i = 0; i < path_info.size(); i++) { + size_t firstNode = _path_info.first(path_info[i].first); + size_t lastNode = _path_info.last(path_info[i].first); + if (!_path_info.isClosed(lastNode)) { _satellites[firstNode].hidden = true; _satellites[firstNode].active = false; } else { @@ -81,30 +78,29 @@ Pointwise::setStart() /** Fired when a path is modified. */ -void -Pointwise::recalculate_for_new_pwd2(Piecewise<D2<SBasis> > A) +void Pointwise::recalculateForNewPwd2(Piecewise<D2<SBasis> > A) { - if( _pwd2.size() > A.size()){ - pwd2_sustract(A); - } else if (_pwd2.size() < A.size()){ - pwd2_append(A); + if (_pwd2.size() > A.size()) { + pwd2Sustract(A); + } else if (_pwd2.size() < A.size()) { + pwd2Append(A); } } /** Some nodes/subpaths are removed. */ -void -Pointwise::pwd2_sustract(Piecewise<D2<SBasis> > A) +void Pointwise::pwd2Sustract(Piecewise<D2<SBasis> > A) { size_t counter = 0; std::vector<Satellite> sats; Piecewise<D2<SBasis> > pwd2 = _pwd2; setPwd2(A); - for(size_t i = 0; i < _satellites.size(); i++){ - if(_pathInfo.getLast(i-counter) < i-counter || !are_near(pwd2[i].at0(),A[i-counter].at0(),0.001)){ + for (size_t i = 0; i < _satellites.size(); i++) { + if (_path_info.last(i - counter) < i - counter || + !are_near(pwd2[i].at0(), A[i - counter].at0(), 0.001)) { counter++; } else { - sats.push_back(_satellites[i-counter]); + sats.push_back(_satellites[i - counter]); } } setSatellites(sats); @@ -112,76 +108,83 @@ Pointwise::pwd2_sustract(Piecewise<D2<SBasis> > A) /** Append nodes/subpaths to current pointwise */ -void -Pointwise::pwd2_append(Piecewise<D2<SBasis> > A) +void Pointwise::pwd2Append(Piecewise<D2<SBasis> > A) { 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 = _pathInfo.getFirst(i-counter); - size_t last = _pathInfo.getLast(i-counter); - //Check for subpath closed. If a subpath is closed, is not reversed or moved to back - _pathInfo.setPwd2(A); - size_t subpathAIndex = _pathInfo.getSubPathIndex(i); - _pathInfo.setPwd2(_pwd2); - bool changedSubpath = false; - if(_pwd2.size() <= i-counter){ - changedSubpath = false; + for (size_t i = 0; i < A.size(); i++) { + size_t first = _path_info.first(i - counter); + size_t last = _path_info.last(i - counter); + //Check for subpath closed. If a subpath is closed, is not reversed or moved + //to back + _path_info.setPwd2(A); + size_t new_subpath_index = _path_info.subPathIndex(i); + _path_info.setPwd2(_pwd2); + bool subpath_is_changed = false; + if (_pwd2.size() <= i - counter) { + subpath_is_changed = false; } else { - changedSubpath = subpathAIndex != _pathInfo.getSubPathIndex(i-counter); + 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(),0.001) && !changedSubpath){ + if (!reorder && first == i - counter && + !are_near(_pwd2[i - counter].at0(), A[i].at0(), 0.001) && + !subpath_is_changed) { //Send the modified subpath to back - subpath_to_back(_pathInfo.getSubPathIndex(first)); + subpathToBack(_path_info.subPathIndex(first)); reorder = true; i--; continue; } - if(!reversed && first == i-counter && !are_near(_pwd2[i-counter].at0(),A[i].at0(),0.001) && !changedSubpath){ - subpath_reverse(first, last); + if (!reversed && first == i - counter && + !are_near(_pwd2[i - counter].at0(), A[i].at0(), 0.001) && + !subpath_is_changed) { + subpathReverse(first, last); reversed = true; } - if(_pwd2.size() <= i-counter || !are_near(_pwd2[i-counter].at0(),A[i].at0(),0.001)){ + if (_pwd2.size() <= i - counter || + !are_near(_pwd2[i - counter].at0(), A[i].at0(), 0.001)) { counter++; bool active = true; bool hidden = false; - bool isTime = _satellites[0].isTime; + 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, isTime, active, mirror_knots, hidden, amount, degrees, steps); + Satellite sat(_satellites[0].satelliteType, is_time, active, mirror_knots, + hidden, amount, degrees, steps); sats.push_back(sat); } else { - sats.push_back(_satellites[i-counter]); + sats.push_back(_satellites[i - counter]); } } setPwd2(A); setSatellites(sats); } - -void -Pointwise::subpath_to_back(size_t subpath){ - std::vector<Geom::Path> path_in = path_from_piecewise(remove_short_cuts(_pwd2,0.1), 0.001); - size_t nSubpath = 0; +void Pointwise::subpathToBack(size_t subpath) +{ + std::vector<Geom::Path> path_in = + path_from_piecewise(remove_short_cuts(_pwd2, 0.1), 0.001); + size_t subpath_counter = 0; size_t counter = 0; std::vector<Geom::Path> tmp_path; - Geom::Path rev; - for (PathVector::const_iterator path_it = path_in.begin(); path_it != path_in.end(); ++path_it) { - if (path_it->empty()){ + Geom::Path to_back; + for (PathVector::const_iterator path_it = path_in.begin(); + path_it != path_in.end(); ++path_it) { + if (path_it->empty()) { continue; } Geom::Path::const_iterator curve_it1 = path_it->begin(); Geom::Path::const_iterator curve_endit = path_it->end_default(); - const Curve &closingline = path_it->back_closed(); + const Curve &closingline = path_it->back_closed(); if (are_near(closingline.initialPoint(), closingline.finalPoint())) { curve_endit = path_it->end_open(); } while (curve_it1 != curve_endit) { - if(nSubpath == subpath){ + if (subpath_counter == subpath) { _satellites.push_back(_satellites[counter]); _satellites.erase(_satellites.begin() + counter); } else { @@ -189,43 +192,45 @@ Pointwise::subpath_to_back(size_t subpath){ } ++curve_it1; } - if(nSubpath == subpath){ - rev = *path_it; + if (subpath_counter == subpath) { + to_back = *path_it; } else { tmp_path.push_back(*path_it); } - nSubpath++; + subpath_counter++; } - tmp_path.push_back(rev); - setPwd2(remove_short_cuts(paths_to_pw(tmp_path),0.01)); + tmp_path.push_back(to_back); + setPwd2(remove_short_cuts(paths_to_pw(tmp_path), 0.01)); } -void -Pointwise::subpath_reverse(size_t start,size_t end){ - start ++; - for(size_t i = end; i >= start; i--){ +void Pointwise::subpathReverse(size_t start, size_t end) +{ + start++; + for (size_t i = end; i >= start; i--) { _satellites.push_back(_satellites[i]); _satellites.erase(_satellites.begin() + i); } - std::vector<Geom::Path> path_in = path_from_piecewise(remove_short_cuts(_pwd2,0.1), 0.001); + std::vector<Geom::Path> path_in = + path_from_piecewise(remove_short_cuts(_pwd2, 0.1), 0.001); size_t counter = 0; - size_t nSubpath = 0; - size_t subpath = _pathInfo.getSubPathIndex(start); + size_t subpath_counter = 0; + size_t subpath = _path_info.subPathIndex(start); std::vector<Geom::Path> tmp_path; Geom::Path rev; - for (PathVector::const_iterator path_it = path_in.begin(); path_it != path_in.end(); ++path_it) { - if (path_it->empty()){ + for (PathVector::const_iterator path_it = path_in.begin(); + path_it != path_in.end(); ++path_it) { + if (path_it->empty()) { continue; } - counter ++; - if(nSubpath == subpath){ + counter++; + if (subpath_counter == subpath) { tmp_path.push_back(path_it->reverse()); } else { tmp_path.push_back(*path_it); } - nSubpath++; + subpath_counter++; } - setPwd2(remove_short_cuts(paths_to_pw(tmp_path),0.01)); + setPwd2(remove_short_cuts(paths_to_pw(tmp_path), 0.01)); } } // namespace Geom @@ -238,4 +243,6 @@ Pointwise::subpath_reverse(size_t start,size_t end){ fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: +// filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 +// : diff --git a/src/helper/geom-pointwise.h b/src/helper/geom-pointwise.h index 59ed4d1aa..3ce1ca75a 100644 --- a/src/helper/geom-pointwise.h +++ b/src/helper/geom-pointwise.h @@ -1,12 +1,12 @@ /** * \file * \brief Pointwise a class to manage a vector of satellites per piecewise curve - *//* - * Authors: - * 2015 Jabier Arraiza Cenoz<jabier.arraiza@marker.es> - * - * This code is in public domain - */ + */ /* + * Authors: + * 2015 Jabier Arraiza Cenoz<jabier.arraiza@marker.es> + * + * This code is in public domain + */ #ifndef SEEN_GEOM_POINTWISE_H #define SEEN_GEOM_POINTWISE_H @@ -26,7 +26,7 @@ namespace Geom { * @brief Pointwise a class to manage a vector of satellites per piecewise curve * * For the moment is a per curve satellite holder not per node. This is ok for - * much cases but not a real node satellite on open paths + * much cases but not a real node satellite on open paths * To implement this we can: * add extra satellite in open paths, and take notice of current open paths * or put extra satellites on back for each open subpath @@ -35,30 +35,29 @@ namespace Geom { * optional satellites, and remove the active variable in satellites. * */ -class Pointwise -{ - public: - Pointwise(Piecewise<D2<SBasis> > pwd2, std::vector<Satellite> satellites); - virtual ~Pointwise(); +class Pointwise { +public: + Pointwise(Piecewise<D2<SBasis> > pwd2, std::vector<Satellite> satellites); + virtual ~Pointwise(); - Piecewise<D2<SBasis> > getPwd2() const; - void setPwd2(Piecewise<D2<SBasis> > pwd2_in); + Piecewise<D2<SBasis> > getPwd2() const; + void setPwd2(Piecewise<D2<SBasis> > pwd2_in); - std::vector<Satellite> getSatellites() const; - void setSatellites(std::vector<Satellite> sats); + std::vector<Satellite> getSatellites() const; + void setSatellites(std::vector<Satellite> sats); - void setStart(); + void setStart(); - void recalculate_for_new_pwd2(Piecewise<D2<SBasis> > A); - void pwd2_sustract(Piecewise<D2<SBasis> > A); - void pwd2_append(Piecewise<D2<SBasis> > A); - void subpath_to_back(size_t subpath); - void subpath_reverse(size_t start,size_t end); + void recalculateForNewPwd2(Piecewise<D2<SBasis> > A); + void pwd2Sustract(Piecewise<D2<SBasis> > A); + void pwd2Append(Piecewise<D2<SBasis> > A); + void subpathToBack(size_t subpath); + void subpathReverse(size_t start, size_t end); - private: - Piecewise<D2<SBasis> > _pwd2; - std::vector<Satellite> _satellites; - Pathinfo _pathInfo; +private: + Piecewise<D2<SBasis> > _pwd2; + std::vector<Satellite> _satellites; + Pathinfo _path_info; }; } // end namespace Geom @@ -73,4 +72,6 @@ class Pointwise fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: +// filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 +// : diff --git a/src/helper/geom-satellite-enum.h b/src/helper/geom-satellite-enum.h index 4680ce2f6..d82cdabe0 100644 --- a/src/helper/geom-satellite-enum.h +++ b/src/helper/geom-satellite-enum.h @@ -4,23 +4,23 @@ /** * \file * \brief Satellite types enum - *//* - * Authors: - * 2015 Jabier Arraiza Cenoz<jabier.arraiza@marker.es> - * - * This code is in public domain - */ + */ /* + * Authors: + * 2015 Jabier Arraiza Cenoz<jabier.arraiza@marker.es> + * + * This code is in public domain + */ #include "util/enums.h" namespace Geom { enum SatelliteType { - F=0, //Fillet - IF, //Inverse Fillet - C, //Chamfer - IC, //Inverse Chamfer - KO // Invalid Satellite) + F = 0, //Fillet + IF, //Inverse Fillet + C, //Chamfer + IC, //Inverse Chamfer + KO // Invalid Satellite) }; } //namespace Geom diff --git a/src/helper/geom-satellite.cpp b/src/helper/geom-satellite.cpp index 6304b4148..efe6bb37a 100644 --- a/src/helper/geom-satellite.cpp +++ b/src/helper/geom-satellite.cpp @@ -1,12 +1,12 @@ /** * \file * \brief Satellite a per ?node/curve holder of data. - *//* - * Authors: - * 2015 Jabier Arraiza Cenoz<jabier.arraiza@marker.es> - * - * This code is in public domain - */ + */ /* + * Authors: + * 2015 Jabier Arraiza Cenoz<jabier.arraiza@marker.es> + * + * This code is in public domain + */ #include <helper/geom-satellite.h> #include <2geom/curve.h> @@ -17,26 +17,31 @@ #include <2geom/ray.h> #include <boost/optional.hpp> - namespace Geom { /** * @brief Satellite a per ?node/curve holder of data. */ -Satellite::Satellite(){}; +Satellite::Satellite() {} +; -Satellite::Satellite(SatelliteType satelliteType, bool isTime, bool active, bool hasMirror, bool hidden, double amount, double angle, size_t steps) - : satelliteType(satelliteType), isTime(isTime), active(active), hasMirror(hasMirror), hidden(hidden), amount(amount), angle(angle), steps(steps){}; +Satellite::Satellite(SatelliteType satelliteType, bool isTime, bool active, + bool hasMirror, bool hidden, double amount, double angle, + size_t steps) + : satelliteType(satelliteType), isTime(isTime), active(active), + hasMirror(hasMirror), hidden(hidden), amount(amount), angle(angle), + steps(steps) {} +; -Satellite::~Satellite() {}; +Satellite::~Satellite() {} +; /** * Calculate the time in d2_in with a size of A */ -double -Satellite::toTime(double A,Geom::D2<Geom::SBasis> d2_in) const +double Satellite::toTime(double A, Geom::D2<Geom::SBasis> d2_in) const { - if(!d2_in.isFinite() || d2_in.isZero() || A == 0){ + if (!d2_in.isFinite() || d2_in.isZero() || A == 0) { return 0; } double t = 0; @@ -61,10 +66,9 @@ Satellite::toTime(double A,Geom::D2<Geom::SBasis> d2_in) const /** * Calculate the size in d2_in with a point at A */ -double -Satellite::toSize(double A,Geom::D2<Geom::SBasis> d2_in) const +double Satellite::toSize(double A, Geom::D2<Geom::SBasis> d2_in) const { - if(!d2_in.isFinite() || d2_in.isZero() || A == 0){ + if (!d2_in.isFinite() || d2_in.isZero() || A == 0) { return 0; } double s = 0; @@ -84,66 +88,78 @@ Satellite::toSize(double A,Geom::D2<Geom::SBasis> d2_in) const /** * Calculate the lenght of a satellite from a radious A input. */ -double -Satellite::rad_to_len(double A, boost::optional<Geom::D2<Geom::SBasis> > d2_in, Geom::D2<Geom::SBasis> d2_out, boost::optional<Geom::Satellite> previousSatellite) const +double Satellite::radToLen( + double A, boost::optional<Geom::D2<Geom::SBasis> > d2_in, + Geom::D2<Geom::SBasis> d2_out, + boost::optional<Geom::Satellite> previousSatellite) const { double len = 0; - if(d2_in && previousSatellite){ - Piecewise<D2<SBasis> > offset_curve0 = Piecewise<D2<SBasis> >(*d2_in)+rot90(unitVector(derivative(*d2_in)))*(A); - Piecewise<D2<SBasis> > offset_curve1 = Piecewise<D2<SBasis> >(d2_out)+rot90(unitVector(derivative(d2_out)))*(A); + if (d2_in && previousSatellite) { + Piecewise<D2<SBasis> > offset_curve0 = + Piecewise<D2<SBasis> >(*d2_in) + + rot90(unitVector(derivative(*d2_in))) * (A); + Piecewise<D2<SBasis> > offset_curve1 = + Piecewise<D2<SBasis> >(d2_out) + + rot90(unitVector(derivative(d2_out))) * (A); Geom::Path p0 = path_from_piecewise(offset_curve0, 0.1)[0]; Geom::Path p1 = path_from_piecewise(offset_curve1, 0.1)[0]; Geom::Crossings cs = Geom::crossings(p0, p1); - if(cs.size() > 0){ - Point cp =p0(cs[0].ta); + if (cs.size() > 0) { + Point cp = p0(cs[0].ta); double p0pt = nearest_point(cp, d2_out); - len = (*previousSatellite).toSize(p0pt,d2_out); + len = (*previousSatellite).toSize(p0pt, d2_out); } else { - if(A > 0){ - len = rad_to_len(A * -1, *d2_in, d2_out, previousSatellite); + if (A > 0) { + len = radToLen(A * -1, *d2_in, d2_out, previousSatellite); } } } return len; } - /** - * Calculate the radious of a satellite from a lenght A input. - */ -double -Satellite::len_to_rad(double A, boost::optional<Geom::D2<Geom::SBasis> > d2_in, Geom::D2<Geom::SBasis> d2_out, boost::optional<Geom::Satellite> previousSatellite) const +/** +* Calculate the radious of a satellite from a lenght A input. +*/ +double Satellite::lenToRad( + double A, boost::optional<Geom::D2<Geom::SBasis> > d2_in, + Geom::D2<Geom::SBasis> d2_out, + boost::optional<Geom::Satellite> previousSatellite) const { - if(d2_in && previousSatellite){ - double time_in = (*previousSatellite).getOpositeTime(A, *d2_in); - double time_out = (*previousSatellite).toTime(A,d2_out); + if (d2_in && previousSatellite) { + double time_in = (*previousSatellite).time(A, true, *d2_in); + double time_out = (*previousSatellite).toTime(A, d2_out); Geom::Point startArcPoint = (*d2_in).valueAt(time_in); Geom::Point endArcPoint = d2_out.valueAt(time_out); Piecewise<D2<SBasis> > u; u.push_cut(0); u.push(*d2_in, 1); - Geom::Curve * C = path_from_piecewise(u, 0.1)[0][0].duplicate(); + Geom::Curve *C = path_from_piecewise(u, 0.1)[0][0].duplicate(); Piecewise<D2<SBasis> > u2; u2.push_cut(0); u2.push(d2_out, 1); - Geom::Curve * D = path_from_piecewise(u2, 0.1)[0][0].duplicate(); + Geom::Curve *D = path_from_piecewise(u2, 0.1)[0][0].duplicate(); Curve *knotCurve1 = C->portion(0, time_in); Curve *knotCurve2 = D->portion(time_out, 1); - Geom::CubicBezier const *cubic1 = dynamic_cast<Geom::CubicBezier const *>(&*knotCurve1); + Geom::CubicBezier const *cubic1 = + dynamic_cast<Geom::CubicBezier const *>(&*knotCurve1); Ray ray1(startArcPoint, (*d2_in).valueAt(1)); if (cubic1) { ray1.setPoints((*cubic1)[2], startArcPoint); } - Geom::CubicBezier const *cubic2 = dynamic_cast<Geom::CubicBezier const *>(&*knotCurve2); + Geom::CubicBezier const *cubic2 = + dynamic_cast<Geom::CubicBezier const *>(&*knotCurve2); Ray ray2(d2_out.valueAt(0), endArcPoint); if (cubic2) { ray2.setPoints(endArcPoint, (*cubic2)[1]); } - bool ccwToggle = cross((*d2_in).valueAt(1) - startArcPoint, endArcPoint - startArcPoint) < 0; - double distanceArc = Geom::distance(startArcPoint,middle_point(startArcPoint,endArcPoint)); + bool ccwToggle = cross((*d2_in).valueAt(1) - startArcPoint, + endArcPoint - startArcPoint) < 0; + double distanceArc = + Geom::distance(startArcPoint, middle_point(startArcPoint, endArcPoint)); double angleBetween = angle_between(ray1, ray2, ccwToggle); - double divisor = std::sin(angleBetween/2.0); - if(divisor > 0){ - return distanceArc/divisor; + double divisor = std::sin(angleBetween / 2.0); + if (divisor > 0) { + return distanceArc / divisor; } } return 0; @@ -152,14 +168,13 @@ Satellite::len_to_rad(double A, boost::optional<Geom::D2<Geom::SBasis> > d2_in, /** * Get the time position of the satellite in d2_in */ -double -Satellite::getTime(Geom::D2<Geom::SBasis> d2_in) const +double Satellite::time(Geom::D2<Geom::SBasis> d2_in) const { double t = amount; - if(!isTime){ + if (!isTime) { t = toTime(t, d2_in); } - if(t > 1){ + if (t > 1) { t = 1; } return t; @@ -168,16 +183,16 @@ Satellite::getTime(Geom::D2<Geom::SBasis> d2_in) const /**. * Get the time from a lenght A in other curve, a bolean I gived to reverse time */ -double -Satellite::getTime(double A, bool I, Geom::D2<Geom::SBasis> d2_in) const +double Satellite::time(double A, bool I, + Geom::D2<Geom::SBasis> d2_in) const { - if(A == 0 && I){ + if (A == 0 && I) { return 1; } - if(A == 0 && !I){ + if (A == 0 && !I) { return 0; } - if(!I){ + if (!I) { return toTime(A, d2_in); } double lenghtPart = Geom::length(d2_in, Geom::EPSILON); @@ -188,11 +203,10 @@ Satellite::getTime(double A, bool I, Geom::D2<Geom::SBasis> d2_in) const /** * Get the lenght of the satellite in d2_in */ -double -Satellite::getSize(Geom::D2<Geom::SBasis> d2_in) const +double Satellite::size(Geom::D2<Geom::SBasis> d2_in) const { double s = amount; - if(isTime){ + if (isTime) { s = toSize(s, d2_in); } return s; @@ -201,21 +215,19 @@ Satellite::getSize(Geom::D2<Geom::SBasis> d2_in) const /** * Get the point position of the satellite */ -Geom::Point -Satellite::getPosition(Geom::D2<Geom::SBasis> d2_in) const +Geom::Point Satellite::getPosition(Geom::D2<Geom::SBasis> d2_in) const { - double t = getTime(d2_in); + double t = time(d2_in); return d2_in.valueAt(t); } /** * Set the position of the satellite from a gived point P */ -void -Satellite::setPosition(Geom::Point p, Geom::D2<Geom::SBasis> d2_in) +void Satellite::setPosition(Geom::Point p, Geom::D2<Geom::SBasis> d2_in) { double A = Geom::nearest_point(p, d2_in); - if(!isTime){ + if (!isTime) { A = toSize(A, d2_in); } amount = A; @@ -224,21 +236,20 @@ Satellite::setPosition(Geom::Point p, Geom::D2<Geom::SBasis> d2_in) /** * Map a satellite type with gchar */ -void -Satellite::setSatelliteType(gchar const * A) +void Satellite::setSatelliteType(gchar const *A) { - std::map<std::string,SatelliteType> GcharMapToSatelliteType = boost::assign::map_list_of("F", F)("IF", IF)("C",C)("IC",IC)("KO",KO); + std::map<std::string, SatelliteType> GcharMapToSatelliteType = + boost::assign::map_list_of("F", F)("IF", IF)("C", C)("IC", IC)("KO", KO); satelliteType = GcharMapToSatelliteType.find(std::string(A))->second; } - /** * Map a gchar with satelliteType */ -gchar const * -Satellite::getSatelliteTypeGchar() const +gchar const *Satellite::getSatelliteTypeGchar() const { - std::map<SatelliteType,gchar const *> SatelliteTypeToGcharMap = boost::assign::map_list_of(F, "F")(IF, "IF")(C,"C")(IC,"IC")(KO,"KO"); + std::map<SatelliteType, gchar const *> SatelliteTypeToGcharMap = + boost::assign::map_list_of(F, "F")(IF, "IF")(C, "C")(IC, "IC")(KO, "KO"); return SatelliteTypeToGcharMap.at(satelliteType); } @@ -253,4 +264,6 @@ Satellite::getSatelliteTypeGchar() const fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: +// filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 +// : diff --git a/src/helper/geom-satellite.h b/src/helper/geom-satellite.h index d4550b922..df54819fd 100644 --- a/src/helper/geom-satellite.h +++ b/src/helper/geom-satellite.h @@ -1,12 +1,12 @@ /** * \file * \brief Satellite a per ?node/curve holder of data. - *//* - * Authors: - * 2015 Jabier Arraiza Cenoz<jabier.arraiza@marker.es> - * - * This code is in public domain - */ + */ /* + * Authors: + * 2015 Jabier Arraiza Cenoz<jabier.arraiza@marker.es> + * + * This code is in public domain + */ #ifndef LIB2GEOM_SEEN_SATELLITE_H #define LIB2GEOM_SEEN_SATELLITE_H @@ -21,29 +21,34 @@ namespace Geom { /** * @brief Satellite a per ?node/curve holder of data. */ -class Satellite -{ - public: +class Satellite { +public: Satellite(); - Satellite(SatelliteType satelliteType, bool isTime, bool active, bool hasMirror, bool hidden, double amount, double angle, size_t steps); + Satellite(SatelliteType satelliteType, bool isTime, bool active, + bool hasMirror, bool hidden, double amount, double angle, + size_t steps); virtual ~Satellite(); - double toSize(double A,Geom::D2<Geom::SBasis> d2_in) const; - double toTime(double A,Geom::D2<Geom::SBasis> d2_in) const; - double len_to_rad(double A, boost::optional<Geom::D2<Geom::SBasis> > d2_in, Geom::D2<Geom::SBasis> d2_out, boost::optional<Geom::Satellite> previousSatellite) const; - double rad_to_len(double A, boost::optional<Geom::D2<Geom::SBasis> > d2_in, Geom::D2<Geom::SBasis> d2_out, boost::optional<Geom::Satellite> previousSatellite) const; + double toSize(double A, Geom::D2<Geom::SBasis> d2_in) const; + double toTime(double A, Geom::D2<Geom::SBasis> d2_in) const; + double lenToRad(double A, boost::optional<Geom::D2<Geom::SBasis> > d2_in, + Geom::D2<Geom::SBasis> d2_out, + boost::optional<Geom::Satellite> previousSatellite) const; + double radToLen(double A, boost::optional<Geom::D2<Geom::SBasis> > d2_in, + Geom::D2<Geom::SBasis> d2_out, + boost::optional<Geom::Satellite> previousSatellite) const; - double getTime(Geom::D2<Geom::SBasis> d2_in) const; - double getTime(double A, bool I, Geom::D2<Geom::SBasis> d2_in) const; - double getSize(Geom::D2<Geom::SBasis> d2_in) const; + double time(Geom::D2<Geom::SBasis> d2_in) const; + double time(double A, bool I, Geom::D2<Geom::SBasis> d2_in) const; + double size(Geom::D2<Geom::SBasis> d2_in) const; void setPosition(Geom::Point p, Geom::D2<Geom::SBasis> d2_in); Geom::Point getPosition(Geom::D2<Geom::SBasis> d2_in) const; - void setSatelliteType(gchar const * A); - gchar const * getSatelliteTypeGchar() const; + void setSatelliteType(gchar const *A); + gchar const *getSatelliteTypeGchar() const; //TODO: maybe make after variables protected? SatelliteType satelliteType; bool isTime; @@ -68,4 +73,6 @@ class Satellite fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: +// filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 +// : diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp index e873bebf9..6e026550a 100644 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ b/src/live_effects/lpe-fillet-chamfer.cpp @@ -9,12 +9,12 @@ * Also su_v for his construvtive feedback and time * Also to Mc- (IRC nick) for his important contribution to find real time * values based on - * and finaly to Liam P. White for his big help on coding, that save me a lot of hours + * and finaly to Liam P. White for his big help on coding, that save me a lot of + * hours * * Released under GNU GPL, read the file 'COPYING' for more information */ - #include "live_effects/lpe-fillet-chamfer.h" #include "helper/geom.h" #include "display/curve.h" @@ -33,29 +33,40 @@ namespace Inkscape { namespace LivePathEffect { static const Util::EnumData<FilletMethod> FilletMethodData[FM_END] = { - { FM_AUTO, N_("Auto"), "auto" }, - { FM_ARC, N_("Force arc"), "arc" }, + { FM_AUTO, N_("Auto"), "auto" }, { FM_ARC, N_("Force arc"), "arc" }, { FM_BEZIER, N_("Force bezier"), "bezier" } }; -static const Util::EnumDataConverter<FilletMethod> -FMConverter(FilletMethodData, FM_END); - -LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject) : - Effect(lpeobject), - satellitearrayparam_values(_("pair_array_param"), _("pair_array_param"), "satellitearrayparam_values", &wr, this), - unit(_("Unit:"), _("Unit"), "unit", &wr, this), - method(_("Method:"), _("Methods to calculate the fillet or chamfer"), "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, 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), - use_knot_distance(_("Use knots distance instead radius"), _("Use knots distance instead radius"), "use_knot_distance", &wr, this, false), - hide_knots(_("Hide knots"), _("Hide knots"), "hide_knots", &wr, this, false), - ignore_radius_0(_("Ignore 0 radius knots"), _("Ignore 0 radius knots"), "ignore_radius_0", &wr, this, false), - helper_size(_("Helper size with direction:"), _("Helper size with direction"), "helper_size", &wr, this, 0), - pointwise(NULL), - segCount(0) +static const Util::EnumDataConverter<FilletMethod> FMConverter(FilletMethodData, + FM_END); + +LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject) + : Effect(lpeobject), + satellitearrayparam_values(_("pair_array_param"), _("pair_array_param"), + "satellitearrayparam_values", &wr, this), + unit(_("Unit:"), _("Unit"), "unit", &wr, this), + method(_("Method:"), _("Methods to calculate the fillet or chamfer"), + "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, 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), + use_knot_distance(_("Use knots distance instead radius"), + _("Use knots distance instead radius"), + "use_knot_distance", &wr, this, false), + hide_knots(_("Hide knots"), _("Hide knots"), "hide_knots", &wr, this, + false), + ignore_radius_0(_("Ignore 0 radius knots"), _("Ignore 0 radius knots"), + "ignore_radius_0", &wr, this, false), + helper_size(_("Helper size with direction:"), + _("Helper size with direction"), "helper_size", &wr, this, 0), + pointwise(NULL), segment_size(0) { registerParameter(&satellitearrayparam_values); registerParameter(&unit); @@ -83,65 +94,67 @@ LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject) : LPEFilletChamfer::~LPEFilletChamfer() {} - void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem) { - SPLPEItem * splpeitem = const_cast<SPLPEItem *>(lpeItem); - SPShape * shape = dynamic_cast<SPShape *>(splpeitem); + SPLPEItem *splpeitem = const_cast<SPLPEItem *>(lpeItem); + SPShape *shape = dynamic_cast<SPShape *>(splpeitem); if (shape) { - PathVector const &original_pathv = pathv_to_linear_and_cubic_beziers(shape->getCurve()->get_pathvector()); + PathVector const &original_pathv = + pathv_to_linear_and_cubic_beziers(shape->getCurve()->get_pathvector()); Piecewise<D2<SBasis> > pwd2_in = paths_to_pw(original_pathv); pwd2_in = remove_short_cuts(pwd2_in, 0.01); - int counterTotal = 0; - std::vector<Geom::Satellite> satellites; - for (PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { - if (path_it->empty()){ + int global_counter = 0; + std::vector<Geom::Satellite> satellites; + for (PathVector::const_iterator path_it = original_pathv.begin(); + path_it != original_pathv.end(); ++path_it) { + if (path_it->empty()) { continue; } Geom::Path::const_iterator curve_it1 = path_it->begin(); Geom::Path::const_iterator curve_endit = path_it->end_default(); if (path_it->closed()) { - const Curve &closingline = path_it->back_closed(); - // the closing line segment is always of type - // LineSegment. - if (are_near(closingline.initialPoint(), closingline.finalPoint())) { - // closingline.isDegenerate() did not work, because it only checks for - // *exact* zero length, which goes wrong for relative coordinates and - // rounding errors... - // the closing line segment has zero-length. So stop before that one! - curve_endit = path_it->end_open(); - } + const Curve &closingline = path_it->back_closed(); + // the closing line segment is always of type + // LineSegment. + if (are_near(closingline.initialPoint(), closingline.finalPoint())) { + // closingline.isDegenerate() did not work, because it only checks for + // *exact* zero length, which goes wrong for relative coordinates and + // rounding errors... + // the closing line segment has zero-length. So stop before that one! + curve_endit = path_it->end_open(); + } } Geom::Path::const_iterator curve_end = curve_endit; --curve_end; int counter = 0; size_t steps = chamfer_steps; while (curve_it1 != curve_endit) { - if((*curve_it1).isDegenerate() || (*curve_it1).isDegenerate()){ + if ((*curve_it1).isDegenerate() || (*curve_it1).isDegenerate()) { g_warning("LPE Fillet not handle degenerate curves."); - SPLPEItem * item = const_cast<SPLPEItem*>(lpeItem); + SPLPEItem *item = const_cast<SPLPEItem *>(lpeItem); item->removeCurrentPathEffect(false); return; } bool active = true; bool hidden = false; - if (counter==0) { + if (counter == 0) { if (!path_it->closed()) { active = false; } } - Satellite satellite(F, flexible, active, mirror_knots, hidden, 0.0, 0.0, steps); + Satellite satellite(F, flexible, active, mirror_knots, hidden, 0.0, 0.0, + steps); satellites.push_back(satellite); ++curve_it1; counter++; - counterTotal++; + global_counter++; } } - pointwise = new Pointwise( pwd2_in,satellites); - satellitearrayparam_values.set_pointwise(pointwise); + pointwise = new Pointwise(pwd2_in, satellites); + satellitearrayparam_values.setPointwise(pointwise); } else { g_warning("LPE Fillet/Chamfer can only be applied to shapes (not groups)."); - SPLPEItem * item = const_cast<SPLPEItem*>(lpeItem); + SPLPEItem *item = const_cast<SPLPEItem *>(lpeItem); item->removeCurrentPathEffect(false); } } @@ -161,28 +174,36 @@ Gtk::Widget *LPEFilletChamfer::newWidget() Parameter *param = *it; Gtk::Widget *widg = param->param_newWidget(); if (param->param_key == "radius") { - Inkscape::UI::Widget::Scalar *widgRegistered = Gtk::manage(dynamic_cast<Inkscape::UI::Widget::Scalar *>(widg)); - widgRegistered->signal_value_changed().connect(sigc::mem_fun(*this, &LPEFilletChamfer::updateAmount)); - widg = widgRegistered; + Inkscape::UI::Widget::Scalar *widg_registered = + Gtk::manage(dynamic_cast<Inkscape::UI::Widget::Scalar *>(widg)); + widg_registered->signal_value_changed() + .connect(sigc::mem_fun(*this, &LPEFilletChamfer::updateAmount)); + widg = widg_registered; if (widg) { - Gtk::HBox *scalarParameter = dynamic_cast<Gtk::HBox *>(widg); - std::vector<Gtk::Widget *> childList = scalarParameter->get_children(); - Gtk::Entry *entryWidg = dynamic_cast<Gtk::Entry *>(childList[1]); - entryWidg->set_width_chars(6); + Gtk::HBox *scalar_parameter = dynamic_cast<Gtk::HBox *>(widg); + std::vector<Gtk::Widget *> childList = + scalar_parameter->get_children(); + Gtk::Entry *entry_widget = dynamic_cast<Gtk::Entry *>(childList[1]); + entry_widget->set_width_chars(6); } } else if (param->param_key == "chamfer_steps") { - Inkscape::UI::Widget::Scalar *widgRegistered = Gtk::manage(dynamic_cast<Inkscape::UI::Widget::Scalar *>(widg)); - widgRegistered->signal_value_changed().connect(sigc::mem_fun(*this, &LPEFilletChamfer::updateChamferSteps)); - widg = widgRegistered; + Inkscape::UI::Widget::Scalar *widg_registered = + Gtk::manage(dynamic_cast<Inkscape::UI::Widget::Scalar *>(widg)); + widg_registered->signal_value_changed().connect( + sigc::mem_fun(*this, &LPEFilletChamfer::updateChamferSteps)); + widg = widg_registered; if (widg) { - Gtk::HBox *scalarParameter = dynamic_cast<Gtk::HBox *>(widg); - std::vector<Gtk::Widget *> childList = scalarParameter->get_children(); - Gtk::Entry *entryWidg = dynamic_cast<Gtk::Entry *>(childList[1]); - entryWidg->set_width_chars(3); + Gtk::HBox *scalar_parameter = dynamic_cast<Gtk::HBox *>(widg); + std::vector<Gtk::Widget *> childList = + scalar_parameter->get_children(); + Gtk::Entry *entry_widget = dynamic_cast<Gtk::Entry *>(childList[1]); + entry_widget->set_width_chars(3); } } else if (param->param_key == "helper_size") { - Inkscape::UI::Widget::Scalar *widgRegistered = Gtk::manage(dynamic_cast<Inkscape::UI::Widget::Scalar *>(widg)); - widgRegistered->signal_value_changed().connect(sigc::mem_fun(*this, &LPEFilletChamfer::refreshKnots)); + Inkscape::UI::Widget::Scalar *widg_registered = + Gtk::manage(dynamic_cast<Inkscape::UI::Widget::Scalar *>(widg)); + widg_registered->signal_value_changed() + .connect(sigc::mem_fun(*this, &LPEFilletChamfer::refreshKnots)); } else if (param->param_key == "only_selected") { Gtk::manage(widg); } @@ -199,32 +220,39 @@ Gtk::Widget *LPEFilletChamfer::newWidget() } ++it; } - - Gtk::HBox *filletContainer = Gtk::manage(new Gtk::HBox(true, 0)); - Gtk::Button *fillet = Gtk::manage(new Gtk::Button(Glib::ustring(_("Fillet")))); - fillet->signal_clicked().connect(sigc::mem_fun(*this, &LPEFilletChamfer::fillet)); - - filletContainer->pack_start(*fillet, true, true, 2); - Gtk::Button *inverseFillet = Gtk::manage(new Gtk::Button(Glib::ustring(_("Inverse fillet")))); - inverseFillet->signal_clicked().connect(sigc::mem_fun(*this, &LPEFilletChamfer::inverseFillet)); - filletContainer->pack_start(*inverseFillet, true, true, 2); - - Gtk::HBox *chamferContainer = Gtk::manage(new Gtk::HBox(true, 0)); - Gtk::Button *chamfer = Gtk::manage(new Gtk::Button(Glib::ustring(_("Chamfer")))); - chamfer->signal_clicked().connect(sigc::mem_fun(*this, &LPEFilletChamfer::chamfer)); - - chamferContainer->pack_start(*chamfer, true, true, 2); - Gtk::Button *inverseChamfer = Gtk::manage(new Gtk::Button(Glib::ustring(_("Inverse chamfer")))); - inverseChamfer->signal_clicked().connect(sigc::mem_fun(*this, &LPEFilletChamfer::inverseChamfer)); - chamferContainer->pack_start(*inverseChamfer, true, true, 2); - - vbox->pack_start(*filletContainer, true, true, 2); - vbox->pack_start(*chamferContainer, true, true, 2); + + Gtk::HBox *fillet_container = Gtk::manage(new Gtk::HBox(true, 0)); + Gtk::Button *fillet = + Gtk::manage(new Gtk::Button(Glib::ustring(_("Fillet")))); + fillet->signal_clicked() + .connect(sigc::mem_fun(*this, &LPEFilletChamfer::fillet)); + + fillet_container->pack_start(*fillet, true, true, 2); + Gtk::Button *inverse_fillet = + Gtk::manage(new Gtk::Button(Glib::ustring(_("Inverse fillet")))); + inverse_fillet->signal_clicked() + .connect(sigc::mem_fun(*this, &LPEFilletChamfer::inverseFillet)); + fillet_container->pack_start(*inverse_fillet, true, true, 2); + + Gtk::HBox *chamfer_container = Gtk::manage(new Gtk::HBox(true, 0)); + Gtk::Button *chamfer = + Gtk::manage(new Gtk::Button(Glib::ustring(_("Chamfer")))); + chamfer->signal_clicked() + .connect(sigc::mem_fun(*this, &LPEFilletChamfer::chamfer)); + + chamfer_container->pack_start(*chamfer, true, true, 2); + Gtk::Button *inverse_chamfer = + Gtk::manage(new Gtk::Button(Glib::ustring(_("Inverse chamfer")))); + inverse_chamfer->signal_clicked() + .connect(sigc::mem_fun(*this, &LPEFilletChamfer::inverseChamfer)); + chamfer_container->pack_start(*inverse_chamfer, true, true, 2); + + vbox->pack_start(*fillet_container, true, true, 2); + vbox->pack_start(*chamfer_container, true, true, 2); return vbox; } - void LPEFilletChamfer::fillet() { updateSatelliteType(F); @@ -247,7 +275,7 @@ void LPEFilletChamfer::inverseChamfer() void LPEFilletChamfer::refreshKnots() { - if(satellitearrayparam_values.knoth){ + if (satellitearrayparam_values.knoth) { satellitearrayparam_values.knoth->update_knots(); } } @@ -256,81 +284,90 @@ void LPEFilletChamfer::updateAmount() { double power = 0; if (!flexible) { - power = Inkscape::Util::Quantity::convert(radius, unit.get_abbreviation(), defaultUnit); + power = Inkscape::Util::Quantity::convert(radius, unit.get_abbreviation(), + defaultUnit); } else { - power = radius/100; + power = radius / 100; } std::vector<Geom::Satellite> satellites = pointwise->getSatellites(); Piecewise<D2<SBasis> > pwd2 = pointwise->getPwd2(); - Pathinfo pathInfo(pwd2); - for (std::vector<Geom::Satellite>::iterator it = satellites.begin(); it != satellites.end(); ++it) { - if(!pathInfo.getIsClosed(it - satellites.begin()) && pathInfo.getFirst(it - satellites.begin()) == (unsigned)(it - satellites.begin())){ + Pathinfo path_info(pwd2); + for (std::vector<Geom::Satellite>::iterator it = satellites.begin(); + it != satellites.end(); ++it) { + if (!path_info.isClosed(it - satellites.begin()) && + path_info.first(it - satellites.begin()) == + (unsigned)(it - satellites.begin())) { it->amount = 0; continue; } - if(ignore_radius_0 && it->amount == 0){ + if (ignore_radius_0 && it->amount == 0) { continue; } - boost::optional<size_t> prev = pathInfo.getPrevious(it - satellites.begin()); - boost::optional<Geom::D2<Geom::SBasis> > prevPwd2 = boost::none; - boost::optional<Geom::Satellite > prevSat = boost::none; - if(prev){ - prevPwd2 = pwd2[*prev]; - prevSat = satellites[*prev]; + boost::optional<size_t> previous = + path_info.previous(it - satellites.begin()); + boost::optional<Geom::D2<Geom::SBasis> > previous_d2 = boost::none; + boost::optional<Geom::Satellite> previous_satellite = boost::none; + if (previous) { + previous_d2 = pwd2[*previous]; + previous_satellite = satellites[*previous]; } - if(only_selected){ - Geom::Point satPoint = pwd2.valueAt(it - satellites.begin()); - if(isNodePointSelected(satPoint)){ - if(!use_knot_distance && !flexible){ - it->amount = it->rad_to_len(power, prevPwd2, pwd2[it - satellites.begin()], prevSat); + if (only_selected) { + Geom::Point satellite_point = pwd2.valueAt(it - satellites.begin()); + if (isNodePointSelected(satellite_point)) { + if (!use_knot_distance && !flexible) { + it->amount = it->radToLen(power, previous_d2, + pwd2[it - satellites.begin()], previous_satellite); } else { it->amount = power; } } } else { - if(!use_knot_distance && !flexible){ - it->amount = it->rad_to_len(power, prevPwd2, pwd2[it - satellites.begin()], prevSat); + if (!use_knot_distance && !flexible) { + it->amount = it->radToLen(power, previous_d2, + pwd2[it - satellites.begin()], previous_satellite); } else { it->amount = power; } } } pointwise->setSatellites(satellites); - satellitearrayparam_values.set_pointwise(pointwise); + satellitearrayparam_values.setPointwise(pointwise); } void LPEFilletChamfer::updateChamferSteps() { std::vector<Geom::Satellite> satellites = pointwise->getSatellites(); Piecewise<D2<SBasis> > pwd2 = pointwise->getPwd2(); - for (std::vector<Geom::Satellite>::iterator it = satellites.begin(); it != satellites.end(); ++it) { - if(ignore_radius_0 && it->amount == 0){ + for (std::vector<Geom::Satellite>::iterator it = satellites.begin(); + it != satellites.end(); ++it) { + if (ignore_radius_0 && it->amount == 0) { continue; } - if(only_selected){ - Geom::Point satPoint = pwd2.valueAt(it - satellites.begin()); - if(isNodePointSelected(satPoint)){ - it->steps = chamfer_steps; + if (only_selected) { + Geom::Point satellite_point = pwd2.valueAt(it - satellites.begin()); + if (isNodePointSelected(satellite_point)) { + it->steps = chamfer_steps; } } else { it->steps = chamfer_steps; } } pointwise->setSatellites(satellites); - satellitearrayparam_values.set_pointwise(pointwise); + satellitearrayparam_values.setPointwise(pointwise); } void LPEFilletChamfer::updateSatelliteType(Geom::SatelliteType satellitetype) { std::vector<Geom::Satellite> satellites = pointwise->getSatellites(); Piecewise<D2<SBasis> > pwd2 = pointwise->getPwd2(); - for (std::vector<Geom::Satellite>::iterator it = satellites.begin(); it != satellites.end(); ++it) { - if(ignore_radius_0 && it->amount == 0){ + for (std::vector<Geom::Satellite>::iterator it = satellites.begin(); + it != satellites.end(); ++it) { + if (ignore_radius_0 && it->amount == 0) { continue; } - if(only_selected){ - Geom::Point satPoint = pwd2.valueAt(it - satellites.begin()); - if(isNodePointSelected(satPoint)){ + if (only_selected) { + Geom::Point satellite_point = pwd2.valueAt(it - satellites.begin()); + if (isNodePointSelected(satellite_point)) { it->satelliteType = satellitetype; } } else { @@ -338,75 +375,76 @@ void LPEFilletChamfer::updateSatelliteType(Geom::SatelliteType satellitetype) } } pointwise->setSatellites(satellites); - satellitearrayparam_values.set_pointwise(pointwise); + satellitearrayparam_values.setPointwise(pointwise); } void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem) { - SPLPEItem * splpeitem = const_cast<SPLPEItem *>(lpeItem); - SPShape * shape = dynamic_cast<SPShape *>(splpeitem); + SPLPEItem *splpeitem = const_cast<SPLPEItem *>(lpeItem); + SPShape *shape = dynamic_cast<SPShape *>(splpeitem); if (shape) { SPCurve *c = shape->getCurve(); - SPPath * path = dynamic_cast<SPPath *>(shape); - if(path){ + SPPath *path = dynamic_cast<SPPath *>(shape); + if (path) { c = path->get_original_curve(); } //fillet chamfer specific calls - satellitearrayparam_values.set_document_unit(defaultUnit); - satellitearrayparam_values.set_use_distance(use_knot_distance); - satellitearrayparam_values.set_unit(unit.get_abbreviation()); + satellitearrayparam_values.setDocumentUnit(defaultUnit); + satellitearrayparam_values.setUseDistance(use_knot_distance); + satellitearrayparam_values.setUnit(unit.get_abbreviation()); //mandatory call - satellitearrayparam_values.set_effect_type(this->effectType()); - - PathVector const &original_pathv = pathv_to_linear_and_cubic_beziers(c->get_pathvector()); + satellitearrayparam_values.setEffectType(effectType()); + + 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<Geom::Satellite> sats = satellitearrayparam_values.data(); + std::vector<Geom::Satellite> sats = satellitearrayparam_values.data(); //optional call - if(hide_knots){ - satellitearrayparam_values.set_helper_size(0); + if (hide_knots) { + satellitearrayparam_values.setHelperSize(0); } else { - satellitearrayparam_values.set_helper_size(helper_size); + satellitearrayparam_values.setHelperSize(helper_size); } bool refresh = false; bool hide = true; - for (std::vector<Satellite>::iterator it = sats.begin(); it != sats.end();) - { - if(it->isTime != flexible){ + for (std::vector<Satellite>::iterator it = sats.begin(); + it != sats.end();) { + if (it->isTime != flexible) { it->isTime = flexible; double amount = it->amount; D2<SBasis> d2_in = pwd2_in[it - sats.begin()]; - if(it->isTime){ - double time = it->toTime(amount,d2_in); + if (it->isTime) { + double time = it->toTime(amount, d2_in); it->amount = time; } else { - double size = it->toSize(amount,d2_in); + double size = it->toSize(amount, d2_in); it->amount = size; } } - if(it->hasMirror != mirror_knots){ + if (it->hasMirror != mirror_knots) { it->hasMirror = mirror_knots; refresh = true; } - if(it->hidden == false){ + if (it->hidden == false) { hide = false; } it->hidden = hide_knots; ++it; } - if(hide != hide_knots){ + if (hide != hide_knots) { refresh = true; } - - if(pointwise && c->get_segment_count() != segCount && segCount != 0){ - pointwise->recalculate_for_new_pwd2(pwd2_in); - segCount = c->get_segment_count(); + + if (pointwise && c->get_segment_count() != segment_size && segment_size != 0) { + pointwise->recalculateForNewPwd2(pwd2_in); + segment_size = c->get_segment_count(); } else { pointwise = new Pointwise(pwd2_in, sats); - segCount = c->get_segment_count(); + segment_size = c->get_segment_count(); } - satellitearrayparam_values.set_pointwise(pointwise); - if(refresh){ + satellitearrayparam_values.setPointwise(pointwise); + if (refresh) { refreshKnots(); } } else { @@ -418,246 +456,272 @@ void LPEFilletChamfer::adjustForNewPath(std::vector<Geom::Path> const &path_in) { if (!path_in.empty() && pointwise) { - pointwise->recalculate_for_new_pwd2(remove_short_cuts(paths_to_pw(pathv_to_linear_and_cubic_beziers(path_in)),0.01)); - satellitearrayparam_values.set_pointwise(pointwise); + pointwise->recalculateForNewPwd2(remove_short_cuts( + paths_to_pw(pathv_to_linear_and_cubic_beziers(path_in)), 0.01)); + satellitearrayparam_values.setPointwise(pointwise); } } std::vector<Geom::Path> LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in) { - const double gapHelper = 0.00001; - std::vector<Geom::Path> pathvector_out; + const double GAP_HELPER = 0.00001; + std::vector<Geom::Path> path_out; 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); + 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(); path_it != path_in_processed.end(); ++path_it) { - if (path_it->empty()){ + if (path_it->empty()) { continue; } - Geom::Path path_out; + Geom::Path tmp_path; Geom::Path::const_iterator curve_it1 = path_it->begin(); Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); Geom::Path::const_iterator curve_endit = path_it->end_default(); - if(path_it->size() == 1){ + if (path_it->size() == 1) { counter++; - path_out.start((*curve_it1).pointAt(0)); - path_out.append(*curve_it1); - pathvector_out.push_back(path_out); + tmp_path.start((*curve_it1).pointAt(0)); + tmp_path.append(*curve_it1); + path_out.push_back(tmp_path); continue; } if (path_it->closed()) { - const Geom::Curve &closingline = path_it->back_closed(); - // the closing line segment is always of type - // Geom::LineSegment. - if (are_near(closingline.initialPoint(), closingline.finalPoint())) { - // closingline.isDegenerate() did not work, because it only checks for - // *exact* zero length, which goes wrong for relative coordinates and - // rounding errors... - // the closing line segment has zero-length. So stop before that one! - curve_endit = path_it->end_open(); - } + const Geom::Curve &closingline = path_it->back_closed(); + // the closing line segment is always of type + // Geom::LineSegment. + if (are_near(closingline.initialPoint(), closingline.finalPoint())) { + // closingline.isDegenerate() did not work, because it only checks for + // *exact* zero length, which goes wrong for relative coordinates and + // rounding errors... + // the closing line segment has zero-length. So stop before that one! + curve_endit = path_it->end_open(); + } } - size_t counterCurves = 0; + size_t counter_curves = 0; size_t first = counter; double time0 = 0; std::vector<Geom::Satellite> sats = pointwise->getSatellites(); while (curve_it1 != curve_endit) { - if((*curve_it1).isDegenerate() || (*curve_it1).isDegenerate()){ + if ((*curve_it1).isDegenerate() || (*curve_it1).isDegenerate()) { g_warning("LPE Fillet not handle degenerate curves."); return path_in; } Satellite satellite; - Curve *curve_it2Fixed = path_it->begin()->duplicate(); - if(!path_it->closed()){ - if(curve_it2 != curve_endit){ - curve_it2Fixed = (*curve_it2).duplicate(); - if(sats.size()> counter+1 ){ - satellite = sats[counter+1]; + Curve *curve_it2_fixed = path_it->begin()->duplicate(); + if (!path_it->closed()) { + if (curve_it2 != curve_endit) { + curve_it2_fixed = (*curve_it2).duplicate(); + if (sats.size() > counter + 1) { + satellite = sats[counter + 1]; } } else { - if(time0 != 1){ - Curve *lastCurve = curve_it1->portion(time0, 1); - lastCurve->setInitial(path_out.finalPoint()); - path_out.append(*lastCurve); + if (time0 != 1) { + Curve *last_curve = curve_it1->portion(time0, 1); + last_curve->setInitial(tmp_path.finalPoint()); + tmp_path.append(*last_curve); } ++curve_it1; counter++; - counterCurves++; + counter_curves++; continue; } } else { - if(curve_it2 != curve_endit){ - curve_it2Fixed = (*curve_it2).duplicate(); - if(sats.size()> counter+1 ){ - satellite = sats[counter+1]; + if (curve_it2 != curve_endit) { + curve_it2_fixed = (*curve_it2).duplicate(); + if (sats.size() > counter + 1) { + satellite = sats[counter + 1]; } } else { - if(sats.size()> first ){ + if (sats.size() > first) { satellite = sats[first]; } } } - if(first == counter){ - if(sats.size() > first && sats[first].active){ - time0 = sats[first].getTime(path_it->begin()->duplicate()->toSBasis()); + if (first == counter) { + if (sats.size() > first && sats[first].active) { + time0 = + sats[first].time(path_it->begin()->duplicate()->toSBasis()); } else { time0 = 0; } } bool last = curve_it2 == curve_endit; - double s = satellite.getSize(curve_it2Fixed->toSBasis()); - double time1 = satellite.getOpositeTime(s,(*curve_it1).toSBasis()); - double time2 = satellite.getTime(curve_it2Fixed->toSBasis()); - if(!satellite.active){ + double s = satellite.size(curve_it2_fixed->toSBasis()); + double time1 = satellite.time(s, true, (*curve_it1).toSBasis()); + double time2 = satellite.time(curve_it2_fixed->toSBasis()); + if (!satellite.active) { time1 = 1; time2 = 0; } - - if(time1 <= time0){ + + if (time1 <= time0) { time1 = time0; } std::vector<double> times; times.push_back(time0); times.push_back(time1); times.push_back(time2); - Curve *knotCurve1 = curve_it1->portion(times[0], times[1]); - if (counterCurves > 0) { - knotCurve1->setInitial(path_out.finalPoint()); + Curve *knot_curve_1 = curve_it1->portion(times[0], times[1]); + if (counter_curves > 0) { + knot_curve_1->setInitial(tmp_path.finalPoint()); } else { - path_out.start((*curve_it1).pointAt(times[0])); - } - - Point startArcPoint = knotCurve1->finalPoint(); - Point endArcPoint = curve_it2Fixed->pointAt(times[2]); - if(times[2] == 1){ - endArcPoint = curve_it2Fixed->pointAt(times[2]-gapHelper); - } - if(times[1] == times[0]){ - startArcPoint = curve_it1->pointAt(times[0]+gapHelper); - } - double k1 = distance(startArcPoint, curve_it1->finalPoint()) * K; - double k2 = distance(endArcPoint, curve_it2Fixed->initialPoint()) * K; - Geom::CubicBezier const *cubic1 = dynamic_cast<Geom::CubicBezier const *>(&*knotCurve1); - Ray ray1(startArcPoint, curve_it1->finalPoint()); - if (cubic1) { - ray1.setPoints((*cubic1)[2], startArcPoint); - } - Point handle1 = Point::polar(ray1.angle(),k1) + startArcPoint; - if(time0 == 1){ - handle1 = startArcPoint; - } - Curve *knotCurve2 = curve_it2Fixed->portion(times[2], 1); - Geom::CubicBezier const *cubic2 = dynamic_cast<Geom::CubicBezier const *>(&*knotCurve2); - Ray ray2(curve_it2Fixed->initialPoint(), endArcPoint); - if (cubic2) { - ray2.setPoints(endArcPoint, (*cubic2)[1]); - } - Point handle2 = endArcPoint - Point::polar(ray2.angle(),k2); - - bool ccwToggle = cross(curve_it1->finalPoint() - startArcPoint, endArcPoint - startArcPoint) < 0; - double angle = angle_between(ray1, ray2, ccwToggle); - double handleAngle = ray1.angle() - angle; - if (ccwToggle) { - handleAngle = ray1.angle() + angle; - } - Point inverseHandle1 = Point::polar(handleAngle,k1) + startArcPoint; - if(time0 == 1){ - inverseHandle1 = startArcPoint; - } - handleAngle = ray2.angle() + angle; - if (ccwToggle) { - handleAngle = ray2.angle() - angle; - } - Point inverseHandle2 = endArcPoint - Point::polar(handleAngle,k2); - if(times[2] == 1){ - endArcPoint = curve_it2Fixed->pointAt(times[2]); - } - if(times[1] == times[0]){ - startArcPoint = curve_it1->pointAt(times[0]); - } - Line const x_line(Geom::Point(0,0),Geom::Point(1,0)); - Line const angled_line(startArcPoint,endArcPoint); - double angleArc = Geom::angle_between( x_line,angled_line); - double radius = Geom::distance(startArcPoint,middle_point(startArcPoint,endArcPoint))/sin(angle/2.0); + tmp_path.start((*curve_it1).pointAt(times[0])); + } + + Point start_arc_point = knot_curve_1->finalPoint(); + Point end_arc_point = curve_it2_fixed->pointAt(times[2]); + if (times[2] == 1) { + end_arc_point = curve_it2_fixed->pointAt(times[2] - GAP_HELPER); + } + if (times[1] == times[0]) { + start_arc_point = curve_it1->pointAt(times[0] + GAP_HELPER); + } + double k1 = distance(start_arc_point, curve_it1->finalPoint()) * K; + double k2 = distance(end_arc_point, curve_it2_fixed->initialPoint()) * K; + Geom::CubicBezier const *cubic_1 = + dynamic_cast<Geom::CubicBezier const *>(&*knot_curve_1); + Ray ray_1(start_arc_point, curve_it1->finalPoint()); + if (cubic_1) { + ray_1.setPoints((*cubic_1)[2], start_arc_point); + } + Point handle_1 = Point::polar(ray_1.angle(), k1) + start_arc_point; + if (time0 == 1) { + handle_1 = start_arc_point; + } + Curve *knot_curve_2 = curve_it2_fixed->portion(times[2], 1); + Geom::CubicBezier const *cubic_2 = + dynamic_cast<Geom::CubicBezier const *>(&*knot_curve_2); + Ray ray_2(curve_it2_fixed->initialPoint(), end_arc_point); + if (cubic_2) { + ray_2.setPoints(end_arc_point, (*cubic_2)[1]); + } + Point handle_2 = end_arc_point - Point::polar(ray_2.angle(), k2); + + bool ccw_toggle = cross(curve_it1->finalPoint() - start_arc_point, + end_arc_point - start_arc_point) < 0; + double angle = angle_between(ray_1, ray_2, ccw_toggle); + double handleAngle = ray_1.angle() - angle; + if (ccw_toggle) { + handleAngle = ray_1.angle() + angle; + } + Point inverse_handle_1 = Point::polar(handleAngle, k1) + start_arc_point; + if (time0 == 1) { + inverse_handle_1 = start_arc_point; + } + handleAngle = ray_2.angle() + angle; + if (ccw_toggle) { + handleAngle = ray_2.angle() - angle; + } + Point inverse_handle_2 = end_arc_point - Point::polar(handleAngle, k2); + if (times[2] == 1) { + end_arc_point = curve_it2_fixed->pointAt(times[2]); + } + if (times[1] == times[0]) { + start_arc_point = curve_it1->pointAt(times[0]); + } + Line const x_line(Geom::Point(0, 0), Geom::Point(1, 0)); + Line const angled_line(start_arc_point, end_arc_point); + double arc_angle = Geom::angle_between(x_line, angled_line); + double radius = Geom::distance(start_arc_point, + middle_point(start_arc_point, end_arc_point)) / + sin(angle / 2.0); Coord rx = radius; Coord ry = rx; if (times[1] != 1) { - if (times[1] != times[0] || times[1] == times[0] == 1 ) { - if(!knotCurve1->isDegenerate()){ - path_out.append(*knotCurve1); + if (times[1] != times[0] || times[1] == times[0] == 1) { + if (!knot_curve_1->isDegenerate()) { + tmp_path.append(*knot_curve_1); } } SatelliteType type = satellite.satelliteType; size_t steps = satellite.steps; - if(steps < 1){ + if (steps < 1) { steps = 1; } if (type == C) { Geom::Path path_chamfer; - path_chamfer.start(path_out.finalPoint()); - if((is_straight_curve(*curve_it1) && is_straight_curve(*curve_it2Fixed) && method != FM_BEZIER )|| method == FM_ARC){ - path_chamfer.appendNew<SVGEllipticalArc>(rx, ry, angleArc, 0, ccwToggle, endArcPoint); + path_chamfer.start(tmp_path.finalPoint()); + if ((is_straight_curve(*curve_it1) && + is_straight_curve(*curve_it2_fixed) && method != FM_BEZIER) || + method == FM_ARC) { + path_chamfer.appendNew<SVGEllipticalArc>(rx, ry, arc_angle, 0, + ccw_toggle, end_arc_point); } else { - path_chamfer.appendNew<Geom::CubicBezier>(handle1, handle2, endArcPoint); + path_chamfer.appendNew<Geom::CubicBezier>(handle_1, handle_2, + end_arc_point); } - double chamfer_stepsTime = 1.0/steps; - for(size_t i = 1; i < steps; i++){ - Geom::Point chamferStep = path_chamfer.pointAt(chamfer_stepsTime * i); - path_out.appendNew<Geom::LineSegment>(chamferStep); + double chamfer_stepsTime = 1.0 / steps; + for (size_t i = 1; i < steps; i++) { + Geom::Point chamfer_step = + path_chamfer.pointAt(chamfer_stepsTime * i); + tmp_path.appendNew<Geom::LineSegment>(chamfer_step); } - path_out.appendNew<Geom::LineSegment>(endArcPoint); + tmp_path.appendNew<Geom::LineSegment>(end_arc_point); } else if (type == IC) { Geom::Path path_chamfer; - path_chamfer.start(path_out.finalPoint()); - if((is_straight_curve(*curve_it1) && is_straight_curve(*curve_it2Fixed) && method != FM_BEZIER )|| method == FM_ARC){ - ccwToggle = ccwToggle?0:1; - path_chamfer.appendNew<SVGEllipticalArc>(rx, ry, angleArc, 0, ccwToggle, endArcPoint); - }else{ - path_chamfer.appendNew<Geom::CubicBezier>(inverseHandle1, inverseHandle2, endArcPoint); + path_chamfer.start(tmp_path.finalPoint()); + if ((is_straight_curve(*curve_it1) && + is_straight_curve(*curve_it2_fixed) && method != FM_BEZIER) || + method == FM_ARC) { + ccw_toggle = ccw_toggle ? 0 : 1; + path_chamfer.appendNew<SVGEllipticalArc>(rx, ry, arc_angle, 0, + ccw_toggle, end_arc_point); + } else { + path_chamfer.appendNew<Geom::CubicBezier>( + inverse_handle_1, inverse_handle_2, end_arc_point); } - double chamfer_stepsTime = 1.0/steps; - for(size_t i = 1; i < steps; i++){ - Geom::Point chamferStep = path_chamfer.pointAt(chamfer_stepsTime * i); - path_out.appendNew<Geom::LineSegment>(chamferStep); + double chamfer_stepsTime = 1.0 / steps; + for (size_t i = 1; i < steps; i++) { + Geom::Point chamfer_step = + path_chamfer.pointAt(chamfer_stepsTime * i); + tmp_path.appendNew<Geom::LineSegment>(chamfer_step); } - path_out.appendNew<Geom::LineSegment>(endArcPoint); + tmp_path.appendNew<Geom::LineSegment>(end_arc_point); } else if (type == IF) { - if((is_straight_curve(*curve_it1) && is_straight_curve(*curve_it2Fixed) && method != FM_BEZIER )|| method == FM_ARC){ - ccwToggle = ccwToggle?0:1; - path_out.appendNew<SVGEllipticalArc>(rx, ry, angleArc, 0, ccwToggle, endArcPoint); - }else{ - path_out.appendNew<Geom::CubicBezier>(inverseHandle1, inverseHandle2, endArcPoint); + if ((is_straight_curve(*curve_it1) && + is_straight_curve(*curve_it2_fixed) && method != FM_BEZIER) || + method == FM_ARC) { + ccw_toggle = ccw_toggle ? 0 : 1; + tmp_path.appendNew<SVGEllipticalArc>(rx, ry, arc_angle, 0, ccw_toggle, + end_arc_point); + } else { + tmp_path.appendNew<Geom::CubicBezier>(inverse_handle_1, + inverse_handle_2, end_arc_point); } - } else if (type == F){ - if((is_straight_curve(*curve_it1) && is_straight_curve(*curve_it2Fixed) && method != FM_BEZIER )|| method == FM_ARC){ - path_out.appendNew<SVGEllipticalArc>(rx, ry, angleArc, 0, ccwToggle, endArcPoint); + } else if (type == F) { + if ((is_straight_curve(*curve_it1) && + is_straight_curve(*curve_it2_fixed) && method != FM_BEZIER) || + method == FM_ARC) { + tmp_path.appendNew<SVGEllipticalArc>(rx, ry, arc_angle, 0, ccw_toggle, + end_arc_point); } else { - path_out.appendNew<Geom::CubicBezier>(handle1, handle2, endArcPoint); + tmp_path.appendNew<Geom::CubicBezier>(handle_1, handle_2, + end_arc_point); } } } else { - if(!knotCurve1->isDegenerate()){ - path_out.append(*knotCurve1); + if (!knot_curve_1->isDegenerate()) { + tmp_path.append(*knot_curve_1); } } if (path_it->closed() && last) { - path_out.close(); + tmp_path.close(); } ++curve_it1; if (curve_it2 != curve_endit) { ++curve_it2; } counter++; - counterCurves++; + counter_curves++; time0 = times[2]; } - pathvector_out.push_back(path_out); + path_out.push_back(tmp_path); } - return pathvector_out; + return path_out; } }; //namespace LivePathEffect diff --git a/src/live_effects/lpe-fillet-chamfer.h b/src/live_effects/lpe-fillet-chamfer.h index e56200a17..c519679f8 100644 --- a/src/live_effects/lpe-fillet-chamfer.h +++ b/src/live_effects/lpe-fillet-chamfer.h @@ -10,7 +10,8 @@ * Special thanks to Johan Engelen for the base of the effect -powerstroke- * Also to ScislaC for point me to the idea * Also su_v for his construvtive feedback and time - * and finaly to Liam P. White for his big help on coding, that save me a lot of hours + * and finaly to Liam P. White for his big help on coding, that save me a lot of + * hours * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -36,10 +37,11 @@ public: LPEFilletChamfer(LivePathEffectObject *lpeobject); virtual ~LPEFilletChamfer(); virtual void doBeforeEffect(SPLPEItem const *lpeItem); - virtual std::vector<Geom::Path> doEffect_path(std::vector<Geom::Path> const &path_in); + virtual std::vector<Geom::Path> + doEffect_path(std::vector<Geom::Path> const &path_in); virtual void doOnApply(SPLPEItem const *lpeItem); virtual void adjustForNewPath(std::vector<Geom::Path> const &path_in); - virtual Gtk::Widget* newWidget(); + virtual Gtk::Widget *newWidget(); void updateSatelliteType(Geom::SatelliteType satellitetype); void updateChamferSteps(); @@ -49,7 +51,7 @@ public: void inverseChamfer(); void fillet(); void inverseFillet(); - + SatelliteArrayParam satellitearrayparam_values; private: @@ -66,7 +68,7 @@ private: ScalarParam helper_size; Geom::Pointwise *pointwise; - double segCount; + double segment_size; LPEFilletChamfer(const LPEFilletChamfer &); LPEFilletChamfer &operator=(const LPEFilletChamfer &); diff --git a/src/live_effects/parameter/satellitearray.cpp b/src/live_effects/parameter/satellitearray.cpp index 24a491b4b..bac907343 100644 --- a/src/live_effects/parameter/satellitearray.cpp +++ b/src/live_effects/parameter/satellitearray.cpp @@ -19,27 +19,26 @@ // this has to be included last. #include <glibmm/i18n.h> - using namespace Geom; namespace Inkscape { namespace LivePathEffect { -SatelliteArrayParam::SatelliteArrayParam( - const Glib::ustring &label, const Glib::ustring &tip, - const Glib::ustring &key, Inkscape::UI::Widget::Registry *wr, - Effect *effect) - : ArrayParam<Geom::Satellite>(label, tip, key, wr, effect, 0), - knoth(NULL) +SatelliteArrayParam::SatelliteArrayParam(const Glib::ustring &label, + const Glib::ustring &tip, + const Glib::ustring &key, + Inkscape::UI::Widget::Registry *wr, + Effect *effect) + : ArrayParam<Geom::Satellite>(label, tip, key, wr, effect, 0), knoth(NULL) { - knot_shape = SP_KNOT_SHAPE_DIAMOND; - knot_mode = SP_KNOT_MODE_XOR; - knot_color = 0x00ff0000; - helper_size = 0; - use_distance = false; + _knot_shape = SP_KNOT_SHAPE_DIAMOND; + _knot_mode = SP_KNOT_MODE_XOR; + _knot_color = 0x00ff0000; + _helper_size = 0; + _use_distance = false; _effectType = FILLET_CHAMFER; - last_pointwise = NULL; + _last_pointwise = NULL; } SatelliteArrayParam::~SatelliteArrayParam() {} @@ -48,138 +47,141 @@ void SatelliteArrayParam::set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color) { - knot_shape = shape; - knot_mode = mode; - knot_color = color; + _knot_shape = shape; + _knot_mode = mode; + _knot_color = color; } -void SatelliteArrayParam::set_pointwise(Geom::Pointwise *pointwise) +void SatelliteArrayParam::setPointwise(Geom::Pointwise *pointwise) { - last_pointwise = pointwise; - param_set_and_write_new_value(last_pointwise->getSatellites()); + _last_pointwise = pointwise; + param_set_and_write_new_value(_last_pointwise->getSatellites()); } -void SatelliteArrayParam::set_document_unit(Glib::ustring value_document_unit) +void SatelliteArrayParam::setDocumentUnit(Glib::ustring value_document_unit) { - documentUnit = value_document_unit; + _documentUnit = value_document_unit; } -void SatelliteArrayParam::set_use_distance(bool use_knot_distance ) +void SatelliteArrayParam::setUseDistance(bool use_knot_distance) { - use_distance = use_knot_distance; + _use_distance = use_knot_distance; } -void SatelliteArrayParam::set_unit(const gchar *abbr) +void SatelliteArrayParam::setUnit(const gchar *abbr) { - unit = abbr; + _unit = abbr; } -void SatelliteArrayParam::set_effect_type(EffectType et) +void SatelliteArrayParam::setEffectType(EffectType et) { _effectType = et; } -void SatelliteArrayParam::set_helper_size(int hs) +void SatelliteArrayParam::setHelperSize(int hs) { - helper_size = hs; + _helper_size = hs; updateCanvasIndicators(); } void SatelliteArrayParam::updateCanvasIndicators(bool mirror) { - if(!last_pointwise){ + if (!_last_pointwise) { return; } - Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = last_pointwise->getPwd2(); - Pathinfo pathInfo(pwd2); - if( mirror == true){ - hp.clear(); + Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = _last_pointwise->getPwd2(); + Pathinfo path_info(pwd2); + if (mirror == true) { + _hp.clear(); } for (size_t i = 0; i < _vector.size(); ++i) { - if(!_vector[i].active || _vector[i].hidden){ + if (!_vector[i].active || _vector[i].hidden) { continue; } - if((!_vector[i].hasMirror && mirror == true) || _vector[i].amount == 0){ + if ((!_vector[i].hasMirror && mirror == true) || _vector[i].amount == 0) { continue; } double pos = 0; - if(pwd2.size() <= i){ + if (pwd2.size() <= i) { break; } Geom::D2<Geom::SBasis> d2 = pwd2[i]; bool overflow = false; - double size_out = _vector[i].getSize(pwd2[i]); + double size_out = _vector[i].size(pwd2[i]); double lenght_out = Geom::length(pwd2[i], Geom::EPSILON); double lenght_in = 0; - boost::optional<size_t> d2_prev_index = pathInfo.getPrevious(i); - if(d2_prev_index){ + 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); } - if(mirror == true){ - if(d2_prev_index){ + if (mirror == true) { + if (d2_prev_index) { d2 = pwd2[*d2_prev_index]; - pos = _vector[i].getOpositeTime(size_out,d2); - if(lenght_out < size_out){ + pos = _vector[i].time(size_out, true, d2); + if (lenght_out < size_out) { overflow = true; } } } else { - pos = _vector[i].getTime(d2); - if(lenght_in < size_out){ + pos = _vector[i].time(d2); + if (lenght_in < size_out) { overflow = true; } } if (pos <= 0 || pos >= 1) { continue; } - Geom::Point ptA = d2.valueAt(pos); - Geom::Point derivA = unit_vector(derivative(d2).valueAt(pos)); + Geom::Point point_a = d2.valueAt(pos); + Geom::Point deriv_a = unit_vector(derivative(d2).valueAt(pos)); Geom::Rotate rot(Geom::Rotate::from_degrees(-90)); - derivA = derivA * rot; - Geom::Point C = ptA - derivA * helper_size; - Geom::Point D = ptA + derivA * helper_size; - Geom::Ray ray1(C, D); - char const * svgd = "M 1,0.25 0.5,0 1,-0.25 M 1,0.5 0,0 1,-0.5"; + deriv_a = deriv_a * rot; + Geom::Point point_c = point_a - deriv_a * _helper_size; + Geom::Point point_d = point_a + deriv_a * _helper_size; + Geom::Ray ray_1(point_c, point_d); + char const *svgd = "M 1,0.25 0.5,0 1,-0.25 M 1,0.5 0,0 1,-0.5"; Geom::PathVector pathv = sp_svg_read_pathv(svgd); Geom::Affine aff = Geom::Affine(); - aff *= Geom::Scale(helper_size); - if(mirror == true){ - aff *= Geom::Rotate(ray1.angle() - deg_to_rad(90)); + aff *= Geom::Scale(_helper_size); + if (mirror == true) { + aff *= Geom::Rotate(ray_1.angle() - deg_to_rad(90)); } else { - aff *= Geom::Rotate(ray1.angle() - deg_to_rad(270)); + aff *= Geom::Rotate(ray_1.angle() - deg_to_rad(270)); } pathv *= aff; pathv += d2.valueAt(pos); - hp.push_back(pathv[0]); - hp.push_back(pathv[1]); - if(overflow){ - double diameter = helper_size; - if(helper_size == 0){ + _hp.push_back(pathv[0]); + _hp.push_back(pathv[1]); + if (overflow) { + double diameter = _helper_size; + if (_helper_size == 0) { diameter = 15; - char const * svgd; - svgd = "M 0.7,0.35 A 0.35,0.35 0 0 1 0.35,0.7 0.35,0.35 0 0 1 0,0.35 0.35,0.35 0 0 1 0.35,0 0.35,0.35 0 0 1 0.7,0.35 Z"; + char const *svgd; + svgd = "M 0.7,0.35 A 0.35,0.35 0 0 1 0.35,0.7 0.35,0.35 0 0 1 0,0.35 " + "0.35,0.35 0 0 1 0.35,0 0.35,0.35 0 0 1 0.7,0.35 Z"; Geom::PathVector pathv = sp_svg_read_pathv(svgd); - pathv *= Geom::Scale (diameter); - pathv += ptA-Geom::Point(diameter * 0.35,diameter * 0.35); - hp.push_back(pathv[0]); + pathv *= Geom::Scale(diameter); + pathv += point_a - Geom::Point(diameter * 0.35, diameter * 0.35); + _hp.push_back(pathv[0]); } else { - char const * svgd; - svgd = "M 0 -1.32 A 1.32 1.32 0 0 0 -1.32 0 A 1.32 1.32 0 0 0 0 1.32 A 1.32 1.32 0 0 0 1.18 0.59 L 0 0 L 1.18 -0.59 A 1.32 1.32 0 0 0 0 -1.32 z"; + char const *svgd; + svgd = "M 0 -1.32 A 1.32 1.32 0 0 0 -1.32 0 A 1.32 1.32 0 0 0 0 1.32 A " + "1.32 1.32 0 0 0 1.18 0.59 L 0 0 L 1.18 -0.59 A 1.32 1.32 0 0 0 " + "0 -1.32 z"; Geom::PathVector pathv = sp_svg_read_pathv(svgd); aff = Geom::Affine(); - aff *= Geom::Scale(helper_size/2.0); - if(mirror == true){ - aff *= Geom::Rotate(ray1.angle() - deg_to_rad(90)); + aff *= Geom::Scale(_helper_size / 2.0); + if (mirror == true) { + aff *= Geom::Rotate(ray_1.angle() - deg_to_rad(90)); } else { - aff *= Geom::Rotate(ray1.angle() - deg_to_rad(270)); + aff *= Geom::Rotate(ray_1.angle() - deg_to_rad(270)); } pathv *= aff; pathv += d2.valueAt(pos); - hp.push_back(pathv[0]); + _hp.push_back(pathv[0]); } } } - if( mirror == true){ + if (mirror == true) { updateCanvasIndicators(false); } } @@ -191,58 +193,47 @@ void SatelliteArrayParam::updateCanvasIndicators() void SatelliteArrayParam::addCanvasIndicators( SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec) { - hp_vec.push_back(hp); -} - -void SatelliteArrayParam::recalculate_knots() -{ - if(last_pointwise){ - _vector = last_pointwise->getSatellites(); - } + hp_vec.push_back(_hp); } -void -SatelliteArrayParam::param_transform_multiply(Geom::Affine const &postmul, +void SatelliteArrayParam::param_transform_multiply(Geom::Affine const &postmul, bool /*set*/) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/options/transform/rectcorners", true)) { for (size_t i = 0; i < _vector.size(); ++i) { - if(!_vector[i].isTime && _vector[i].amount > 0){ - _vector[i].amount = _vector[i].amount * ((postmul.expansionX() + postmul.expansionY()) / 2); + if (!_vector[i].isTime && _vector[i].amount > 0) { + _vector[i].amount = _vector[i].amount * + ((postmul.expansionX() + postmul.expansionY()) / 2); } } param_set_and_write_new_value(_vector); } - - // param_set_and_write_new_value( (*this) * postmul ); } void SatelliteArrayParam::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, - SPItem *item, - bool mirror) + SPItem *item, bool mirror) { - //recalculate_knots(); for (size_t i = 0; i < _vector.size(); ++i) { size_t iPlus = i; - if( mirror == true){ + if (mirror == true) { iPlus = i + _vector.size(); } - if(!_vector[i].active){ + if (!_vector[i].active) { continue; } - if(!_vector[i].hasMirror && mirror == true){ + if (!_vector[i].hasMirror && mirror == true) { continue; } using namespace Geom; SatelliteType type = _vector[i].satelliteType; //IF is for filletChamfer effect... - if(_effectType == FILLET_CHAMFER){ + if (_effectType == FILLET_CHAMFER) { const gchar *tip; - if (type == C){ - tip = _("<b>Chamfer</b>: <b>Ctrl+Click</b> toggle type, " + if (type == C) { + tip = _("<b>Chamfer</b>: <b>Ctrl+Click</b> toggle type, " "<b>Shift+Click</b> open dialog, " "<b>Ctrl+Alt+Click</b> reset"); } else if (type == IC) { @@ -261,11 +252,11 @@ void SatelliteArrayParam::addKnotHolderEntities(KnotHolder *knotholder, FilletChamferKnotHolderEntity *e = new FilletChamferKnotHolderEntity(this, iPlus); e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _(tip), - knot_shape, knot_mode, knot_color); + _knot_shape, _knot_mode, _knot_color); knotholder->add(e); } } - if( mirror == true){ + if (mirror == true) { addKnotHolderEntities(knotholder, desktop, item, false); } } @@ -274,159 +265,155 @@ void SatelliteArrayParam::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) { - knoth = knotholder; - addKnotHolderEntities(knotholder, desktop, item, true); + knoth = knotholder; + addKnotHolderEntities(knotholder, desktop, item, true); } -FilletChamferKnotHolderEntity::FilletChamferKnotHolderEntity(SatelliteArrayParam *p, size_t index) - : _pparam(p), - _index(index) -{ -} +FilletChamferKnotHolderEntity::FilletChamferKnotHolderEntity( + SatelliteArrayParam *p, size_t index) + : _pparam(p), _index(index) {} void FilletChamferKnotHolderEntity::knot_set(Point const &p, - Point const &/*origin*/, - guint state) + Point const &/*origin*/, + guint state) { Geom::Point s = snap_knot_position(p, state); size_t index = _index; - if( _index >= _pparam->_vector.size()){ - index = _index-_pparam->_vector.size(); + if (_index >= _pparam->_vector.size()) { + index = _index - _pparam->_vector.size(); } if (!valid_index(index)) { return; } - if( !_pparam->last_pointwise ){ + if (!_pparam->_last_pointwise) { return; } Geom::Satellite satellite = _pparam->_vector.at(index); - if(!satellite.active || satellite.hidden){ + if (!satellite.active || satellite.hidden) { return; } - Geom::Pointwise* pointwise = _pparam->last_pointwise; + Geom::Pointwise *pointwise = _pparam->_last_pointwise; Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = pointwise->getPwd2(); - Pathinfo pathInfo(pwd2); - if(_pparam->_vector.size() <= _index){ - boost::optional<size_t> d2_prev_index = pathInfo.getPrevious(index); - if(d2_prev_index){ + Pathinfo path_info(pwd2); + if (_pparam->_vector.size() <= _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 mirrorTime = Geom::nearest_point(s, d2_in); - double timeStart = 0; + double mirror_time = Geom::nearest_point(s, d2_in); + double time_start = 0; std::vector<Geom::Satellite> sats = pointwise->getSatellites(); - timeStart = sats[*d2_prev_index].getTime(d2_in); - if(timeStart > mirrorTime){ - mirrorTime = timeStart; + time_start = sats[*d2_prev_index].time(d2_in); + if (time_start > mirror_time) { + mirror_time = time_start; } - double size = satellite.toSize(mirrorTime, d2_in); + double size = satellite.toSize(mirror_time, d2_in); double amount = Geom::length(d2_in, Geom::EPSILON) - size; - if(satellite.isTime){ - amount = satellite.toTime(amount,pwd2[index]); + if (satellite.isTime) { + amount = satellite.toTime(amount, pwd2[index]); } satellite.amount = amount; } } else { - satellite.setPosition(s,pwd2[index]); + satellite.setPosition(s, pwd2[index]); } - _pparam->_vector.at(index) = satellite; - SPLPEItem * splpeitem = dynamic_cast<SPLPEItem *>(item); - if(splpeitem){ + _pparam->_vector.at(index) = satellite; + SPLPEItem *splpeitem = dynamic_cast<SPLPEItem *>(item); + if (splpeitem) { sp_lpe_item_update_patheffect(splpeitem, false, false); } } - -Geom::Point -FilletChamferKnotHolderEntity::knot_get() const +Geom::Point FilletChamferKnotHolderEntity::knot_get() const { - Geom::Point tmpPoint; + Geom::Point tmp_point; size_t index = _index; - if( _index >= _pparam->_vector.size()){ - index = _index-_pparam->_vector.size(); + if (_index >= _pparam->_vector.size()) { + index = _index - _pparam->_vector.size(); } if (!valid_index(index)) { return Point(infinity(), infinity()); } Geom::Satellite satellite = _pparam->_vector.at(index); - if(!_pparam->last_pointwise){ + if (!_pparam->_last_pointwise) { return Point(infinity(), infinity()); } - if(!satellite.active || satellite.hidden){ + if (!satellite.active || satellite.hidden) { return Point(infinity(), infinity()); } - Geom::Pointwise* pointwise = _pparam->last_pointwise; + Geom::Pointwise *pointwise = _pparam->_last_pointwise; Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = pointwise->getPwd2(); - Pathinfo pathInfo(pwd2); - if(pwd2.size() <= index){ + Pathinfo path_info(pwd2); + if (pwd2.size() <= index) { return Point(infinity(), infinity()); } this->knot->show(); - if( _index >= _pparam->_vector.size()){ - tmpPoint = satellite.getPosition(pwd2[index]); - boost::optional<size_t> d2_prev_index = pathInfo.getPrevious(index); - if(d2_prev_index){ - Geom::D2<Geom::SBasis> d2_in = pwd2[*d2_prev_index]; - double s = satellite.getSize(pwd2[index]); - double t = satellite.getOpositeTime(s,d2_in); - if(t > 1){ + if (_index >= _pparam->_vector.size()) { + tmp_point = satellite.getPosition(pwd2[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.size(pwd2[index]); + double t = satellite.time(s, true, d2_in); + if (t > 1) { t = 1; } - if(t < 0){ + if (t < 0) { t = 0; } - double timeStart = 0; - timeStart = pointwise->getSatellites()[*d2_prev_index].getTime(d2_in); - if(timeStart > t){ - t = timeStart; + double time_start = 0; + time_start = pointwise->getSatellites()[*d2_prev_index].time(d2_in); + if (time_start > t) { + t = time_start; } - tmpPoint = (d2_in).valueAt(t); + tmp_point = (d2_in).valueAt(t); } } else { - tmpPoint = satellite.getPosition(pwd2[index]); + tmp_point = satellite.getPosition(pwd2[index]); } - Geom::Point const canvas_point = tmpPoint; + Geom::Point const canvas_point = tmp_point; return canvas_point; } void FilletChamferKnotHolderEntity::knot_click(guint state) { - if( !_pparam->last_pointwise){ + if (!_pparam->_last_pointwise) { return; } size_t index = _index; - if( _index >= _pparam->_vector.size()){ - index = _index-_pparam->_vector.size(); + if (_index >= _pparam->_vector.size()) { + index = _index - _pparam->_vector.size(); } if (state & GDK_CONTROL_MASK) { if (state & GDK_MOD1_MASK) { _pparam->_vector.at(index).amount = 0.0; _pparam->param_set_and_write_new_value(_pparam->_vector); sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); - }else{ + } else { using namespace Geom; SatelliteType type = _pparam->_vector.at(index).satelliteType; - switch(type){ - case F: - type = IF; - break; - case IF: - type = C; - break; - case C: - type = IC; - break; - default: - type = F; - break; + switch (type) { + case F: + type = IF; + break; + case IF: + type = C; + break; + case C: + type = IC; + break; + default: + type = F; + break; } _pparam->_vector.at(index).satelliteType = type; _pparam->param_set_and_write_new_value(_pparam->_vector); sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); const gchar *tip; - if (type == C){ - tip = _("<b>Chamfer</b>: <b>Ctrl+Click</b> toggle type, " + if (type == C) { + tip = _("<b>Chamfer</b>: <b>Ctrl+Click</b> toggle type, " "<b>Shift+Click</b> open dialog, " "<b>Ctrl+Alt+Click</b> reset"); } else if (type == IC) { @@ -446,55 +433,63 @@ void FilletChamferKnotHolderEntity::knot_click(guint state) this->knot->show(); } } else if (state & GDK_SHIFT_MASK) { - Piecewise<D2<SBasis> > pwd2 = _pparam->last_pointwise->getPwd2(); - Pathinfo pathInfo(pwd2); - double amount = _pparam->_vector.at(index).amount; - if(!_pparam->use_distance && !_pparam->_vector.at(index).isTime){ - boost::optional<size_t> prev = pathInfo.getPrevious(index); + Piecewise<D2<SBasis> > pwd2 = _pparam->_last_pointwise->getPwd2(); + Pathinfo path_info(pwd2); + double amount = _pparam->_vector.at(index).amount; + if (!_pparam->_use_distance && !_pparam->_vector.at(index).isTime) { + boost::optional<size_t> prev = path_info.previous(index); boost::optional<Geom::D2<Geom::SBasis> > prevPwd2 = boost::none; - boost::optional<Geom::Satellite > prevSat = boost::none; - if(prev){ + boost::optional<Geom::Satellite> prevSat = boost::none; + if (prev) { prevPwd2 = pwd2[*prev]; prevSat = _pparam->_vector.at(*prev); } - amount = _pparam->_vector.at(index).len_to_rad(amount, prevPwd2, pwd2[index], prevSat); + amount = _pparam->_vector.at(index) + .lenToRad(amount, prevPwd2, pwd2[index], prevSat); } bool aprox = false; - D2<SBasis> d2_out = _pparam->last_pointwise->getPwd2()[index]; - boost::optional<size_t> d2_prev_index = pathInfo.getPrevious(index); - 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; + D2<SBasis> d2_out = _pparam->_last_pointwise->getPwd2()[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]; + aprox = ((d2_in)[0].degreesOfFreedom() != 2 || + d2_out[0].degreesOfFreedom() != 2) && + !_pparam->_use_distance + ? true + : false; } Inkscape::UI::Dialogs::FilletChamferPropertiesDialog::showDialog( - this->desktop, amount , this, _pparam->unit, _pparam->use_distance, aprox, _pparam->documentUnit,_pparam->_vector.at(index)); - + this->desktop, amount, this, _pparam->_unit, _pparam->_use_distance, + aprox, _pparam->_documentUnit, _pparam->_vector.at(index)); + } } void FilletChamferKnotHolderEntity::knot_set_offset(Geom::Satellite satellite) { - if( !_pparam->last_pointwise){ + if (!_pparam->_last_pointwise) { return; } size_t index = _index; - if( _index >= _pparam->_vector.size()){ - index = _index-_pparam->_vector.size(); + if (_index >= _pparam->_vector.size()) { + index = _index - _pparam->_vector.size(); } double amount = satellite.amount; - double maxAmount = amount; - if(!_pparam->use_distance && !satellite.isTime){ - Piecewise<D2<SBasis> > pwd2 = _pparam->last_pointwise->getPwd2(); - Pathinfo pathInfo(pwd2); - boost::optional<size_t> prev = pathInfo.getPrevious(index); + double max_amount = amount; + if (!_pparam->_use_distance && !satellite.isTime) { + Piecewise<D2<SBasis> > pwd2 = _pparam->_last_pointwise->getPwd2(); + Pathinfo path_info(pwd2); + boost::optional<size_t> prev = path_info.previous(index); boost::optional<Geom::D2<Geom::SBasis> > prevPwd2 = boost::none; - boost::optional<Geom::Satellite > prevSat = boost::none; - if(prev){ + boost::optional<Geom::Satellite> prevSat = boost::none; + if (prev) { prevPwd2 = pwd2[*prev]; prevSat = _pparam->_vector.at(*prev); } - amount = _pparam->_vector.at(index).rad_to_len(amount, prevPwd2, pwd2[index], prevSat); - if(maxAmount > 0 && amount == 0){ + amount = _pparam->_vector.at(index) + .radToLen(amount, prevPwd2, pwd2[index], prevSat); + if (max_amount > 0 && amount == 0) { amount = _pparam->_vector.at(index).amount; } } @@ -502,8 +497,8 @@ void FilletChamferKnotHolderEntity::knot_set_offset(Geom::Satellite satellite) _pparam->_vector.at(index) = satellite; this->parent_holder->knot_ungrabbed_handler(this->knot, 0); _pparam->param_set_and_write_new_value(_pparam->_vector); - SPLPEItem * splpeitem = dynamic_cast<SPLPEItem *>(item); - if(splpeitem){ + SPLPEItem *splpeitem = dynamic_cast<SPLPEItem *>(item); + if (splpeitem) { sp_lpe_item_update_patheffect(splpeitem, false, false); } } diff --git a/src/live_effects/parameter/satellitearray.h b/src/live_effects/parameter/satellitearray.h index ee0cfbad3..bb53af12b 100644 --- a/src/live_effects/parameter/satellitearray.h +++ b/src/live_effects/parameter/satellitearray.h @@ -10,11 +10,11 @@ * To Nathan Hurst for his review and help on refactor * and finaly to Liam P. White for his big help on coding, that save me a lot of * hours - * - * + * + * * This parameter act as bridge from pointwise class to serialize it as a LPE * parameter - * + * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -32,69 +32,80 @@ class FilletChamferKnotHolderEntity; class SatelliteArrayParam : public ArrayParam<Geom::Satellite> { public: - SatelliteArrayParam(const Glib::ustring &label, - const Glib::ustring &tip, - const Glib::ustring &key, - Inkscape::UI::Widget::Registry *wr, - Effect *effect); + SatelliteArrayParam(const Glib::ustring &label, const Glib::ustring &tip, + const Glib::ustring &key, + Inkscape::UI::Widget::Registry *wr, Effect *effect); virtual ~SatelliteArrayParam(); - virtual Gtk::Widget * param_newWidget() { + virtual Gtk::Widget *param_newWidget() + { return NULL; } - - void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, - guint32 color); - virtual void set_helper_size(int hs); - virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); - virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item, bool mirror); - virtual void addCanvasIndicators(SPLPEItem const *lpeitem,std::vector<Geom::PathVector> &hp_vec); - virtual bool providesKnotHolderEntities() const { + virtual void setHelperSize(int hs); + virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, + SPItem *item); + virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, + SPItem *item, bool mirror); + virtual void addCanvasIndicators(SPLPEItem const *lpeitem, + std::vector<Geom::PathVector> &hp_vec); + virtual void updateCanvasIndicators(); + virtual void updateCanvasIndicators(bool mirror); + virtual bool providesKnotHolderEntities() const + { return true; } void param_transform_multiply(Geom::Affine const &postmul, bool /*set*/); - void set_document_unit(Glib::ustring value_document_unit); - void set_use_distance(bool use_knot_distance ); - void set_unit(const gchar *abbr); - void set_effect_type(EffectType et); - void recalculate_knots(); - virtual void updateCanvasIndicators(); - virtual void updateCanvasIndicators(bool mirror); - void set_pointwise(Geom::Pointwise *pointwise); + void setDocumentUnit(Glib::ustring value_document__unit); + void setUseDistance(bool use_knot_distance); + void setUnit(const gchar *abbr); + void setEffectType(EffectType et); + void setPointwise(Geom::Pointwise *pointwise); + void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, + guint32 color); + friend class FilletChamferKnotHolderEntity; friend class LPEFilletChamfer; + protected: KnotHolder *knoth; + private: SatelliteArrayParam(const SatelliteArrayParam &); SatelliteArrayParam &operator=(const SatelliteArrayParam &); - SPKnotShapeType knot_shape; - SPKnotModeType knot_mode; - guint32 knot_color; - Geom::PathVector hp; - int helper_size; - bool use_distance; - const gchar *unit; - Glib::ustring documentUnit; + SPKnotShapeType _knot_shape; + SPKnotModeType _knot_mode; + guint32 _knot_color; + Geom::PathVector _hp; + int _helper_size; + bool _use_distance; + const gchar *_unit; + Glib::ustring _documentUnit; EffectType _effectType; - Geom::Pointwise *last_pointwise; + Geom::Pointwise *_last_pointwise; }; class FilletChamferKnotHolderEntity : public KnotHolderEntity { public: FilletChamferKnotHolderEntity(SatelliteArrayParam *p, size_t index); - virtual ~FilletChamferKnotHolderEntity() {_pparam->knoth = NULL;} + virtual ~FilletChamferKnotHolderEntity() + { + _pparam->knoth = NULL; + } - virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, + guint state); virtual Geom::Point knot_get() const; 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(size_t index) const { + /** Checks whether the index falls within the size of the parameter's vector + */ + bool valid_index(size_t index) const + { return (_pparam->_vector.size() > index); - }; + } + ; private: SatelliteArrayParam *_pparam; diff --git a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp index 443a48c13..2960f0d34 100644 --- a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp +++ b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp @@ -53,7 +53,7 @@ FilletChamferPropertiesDialog::FilletChamferPropertiesDialog() _fillet_chamfer_position_numeric.set_increments(1,1); //todo: get tha max aloable infinity freeze the widget _fillet_chamfer_position_numeric.set_range(0., 999999999999999999.); - + _fillet_chamfer_position_label.set_label(_("Radius (pixels):")); _fillet_chamfer_position_label.set_alignment(1.0, 0.5); @@ -65,7 +65,7 @@ FilletChamferPropertiesDialog::FilletChamferPropertiesDialog() _fillet_chamfer_chamfer_subdivisions.set_increments(1,1); //todo: get tha max aloable infinity freeze the widget _fillet_chamfer_chamfer_subdivisions.set_range(1, 4294967295); - + _fillet_chamfer_chamfer_subdivisions_label.set_label(_("Chamfer subdivisions:")); _fillet_chamfer_chamfer_subdivisions_label.set_alignment(1.0, 0.5); @@ -119,29 +119,29 @@ FilletChamferPropertiesDialog::FilletChamferPropertiesDialog() FilletChamferPropertiesDialog::~FilletChamferPropertiesDialog() { - _set_desktop(NULL); + _setDesktop(NULL); } void FilletChamferPropertiesDialog::showDialog( - SPDesktop *desktop, double amount, + SPDesktop *desktop, double _amount, const Inkscape::LivePathEffect:: FilletChamferKnotHolderEntity *pt, - const gchar *unit, - bool use_distance, - bool aprox_radius, - Glib::ustring documentUnit, - Geom::Satellite satellite) + const gchar *_unit, + bool _use_distance, + bool _aprox_radius, + Glib::ustring _documentUnit, + Geom::Satellite _satellite) { FilletChamferPropertiesDialog *dialog = new FilletChamferPropertiesDialog(); - dialog->_set_desktop(desktop); - dialog->_set_unit(unit); - dialog->_set_use_distance(use_distance); - dialog->_set_aprox(aprox_radius); - dialog->_set_document_unit(documentUnit); - dialog->_set_amount(amount); - dialog->_set_satellite(satellite); - dialog->_set_pt(pt); + dialog->_setDesktop(desktop); + dialog->_setUnit(_unit); + dialog->_setUseDistance(_use_distance); + dialog->_setAprox(_aprox_radius); + dialog->_setDocumentUnit(_documentUnit); + dialog->_setAmount(_amount); + dialog->_setSatellite(_satellite); + dialog->_setPt(pt); dialog->set_title(_("Modify Fillet-Chamfer")); dialog->_apply_button.set_label(_("_Modify")); @@ -156,7 +156,7 @@ void FilletChamferPropertiesDialog::showDialog( void FilletChamferPropertiesDialog::_apply() { - + double d_pos = _fillet_chamfer_position_numeric.get_value(); if (d_pos >= 0) { if (_fillet_chamfer_type_fillet.get_active() == true) { @@ -174,11 +174,11 @@ void FilletChamferPropertiesDialog::_apply() } d_pos = d_pos / 100; } else { - d_pos = Inkscape::Util::Quantity::convert(d_pos, unit, document_unit); + d_pos = Inkscape::Util::Quantity::convert(d_pos, _unit, _document_unit); } _satellite.amount = d_pos; size_t steps = (size_t)_fillet_chamfer_chamfer_subdivisions.get_value(); - if(steps < 1){ + if(steps < 1) { steps = 1; } _satellite.steps = steps; @@ -189,7 +189,7 @@ void FilletChamferPropertiesDialog::_apply() void FilletChamferPropertiesDialog::_close() { - _set_desktop(NULL); + _setDesktop(NULL); destroy_(); Glib::signal_idle().connect( sigc::bind_return( @@ -211,26 +211,26 @@ void FilletChamferPropertiesDialog::_handleButtonEvent(GdkEventButton *event) } } -void FilletChamferPropertiesDialog::_set_satellite(Geom::Satellite satellite) +void FilletChamferPropertiesDialog::_setSatellite(Geom::Satellite satellite) { double position; std::string distance_or_radius = std::string(_("Radius")); - if(aprox){ + if(_aprox) { distance_or_radius = std::string(_("Radius approximated")); } - if(use_distance){ + if(_use_distance) { distance_or_radius = std::string(_("Knot distance")); } if (satellite.isTime) { - position = amount * 100; + position = _amount * 100; _flexible = true; _fillet_chamfer_position_label.set_label(_("Position (%):")); } else { _flexible = false; - std::string posConcat = Glib::ustring::compose (_("%1 (%2):"), distance_or_radius, unit); + std::string posConcat = Glib::ustring::compose (_("%1 (%2):"), distance_or_radius, _unit); _fillet_chamfer_position_label.set_label(_(posConcat.c_str())); - position = amount; - position = Inkscape::Util::Quantity::convert(position, document_unit, unit); + position = _amount; + position = Inkscape::Util::Quantity::convert(position, _document_unit, _unit); } _fillet_chamfer_position_numeric.set_value(position); _fillet_chamfer_chamfer_subdivisions.set_value(satellite.steps); @@ -246,7 +246,7 @@ void FilletChamferPropertiesDialog::_set_satellite(Geom::Satellite satellite) _satellite = satellite; } -void FilletChamferPropertiesDialog::_set_pt( +void FilletChamferPropertiesDialog::_setPt( const Inkscape::LivePathEffect:: FilletChamferKnotHolderEntity *pt) { @@ -255,35 +255,35 @@ void FilletChamferPropertiesDialog::_set_pt( pt); } -void FilletChamferPropertiesDialog::_set_unit(const gchar *abbr) +void FilletChamferPropertiesDialog::_setUnit(const gchar *abbr) { - unit = abbr; + _unit = abbr; } -void FilletChamferPropertiesDialog::_set_amount(double amm) +void FilletChamferPropertiesDialog::_setAmount(double amm) { - amount = amm; + _amount = amm; } -void FilletChamferPropertiesDialog::_set_document_unit(Glib::ustring abbr) +void FilletChamferPropertiesDialog::_setDocumentUnit(Glib::ustring abbr) { - document_unit = abbr; + _document_unit = abbr; } -void FilletChamferPropertiesDialog::_set_use_distance(bool use_knot_distance) +void FilletChamferPropertiesDialog::_setUseDistance(bool use_knot_distance) { - use_distance = use_knot_distance; + _use_distance = use_knot_distance; } -void FilletChamferPropertiesDialog::_set_aprox(bool aprox_radius) +void FilletChamferPropertiesDialog::_setAprox(bool _aprox_radius) { - aprox = aprox_radius; + _aprox = _aprox_radius; } -void FilletChamferPropertiesDialog::_set_desktop(SPDesktop *desktop) +void FilletChamferPropertiesDialog::_setDesktop(SPDesktop *desktop) { if (desktop) { Inkscape::GC::anchor(desktop); diff --git a/src/ui/dialog/lpe-fillet-chamfer-properties.h b/src/ui/dialog/lpe-fillet-chamfer-properties.h index 1a40eea9b..51fc847c3 100644 --- a/src/ui/dialog/lpe-fillet-chamfer-properties.h +++ b/src/ui/dialog/lpe-fillet-chamfer-properties.h @@ -23,18 +23,19 @@ public: FilletChamferPropertiesDialog(); virtual ~FilletChamferPropertiesDialog(); - Glib::ustring getName() const { + Glib::ustring getName() const + { return "LayerPropertiesDialog"; } - static void showDialog(SPDesktop *desktop, double amount, + static void showDialog(SPDesktop *desktop, double _amount, const Inkscape::LivePathEffect:: FilletChamferKnotHolderEntity *pt, - const gchar *unit, - bool use_distance, - bool aprox_radius, - Glib::ustring documentUnit, - Geom::Satellite satellite); + const gchar *_unit, + bool _use_distance, + bool _aprox_radius, + Glib::ustring _documentUnit, + Geom::Satellite _satellite); protected: @@ -60,36 +61,39 @@ protected: sigc::connection _destroy_connection; - static FilletChamferPropertiesDialog &_instance() { + static FilletChamferPropertiesDialog &_instance() + { static FilletChamferPropertiesDialog instance; return instance; } - void _set_desktop(SPDesktop *desktop); - void _set_pt(const Inkscape::LivePathEffect:: + void _setDesktop(SPDesktop *desktop); + void _setPt(const Inkscape::LivePathEffect:: FilletChamferKnotHolderEntity *pt); - void _set_unit(const gchar *abbr); - void _set_document_unit(Glib::ustring abbr); - void _set_use_distance(bool use_knot_distance); - void _set_aprox(bool aprox_radius); + void _setUnit(const gchar *abbr); + void _setDocumentUnit(Glib::ustring abbr); + void _setUseDistance(bool use_knot_distance); + void _setAprox(bool aprox_radius); + void _setAmount(double amount); + void _setSatellite(Geom::Satellite satellite); + void _prepareLabelRenderer(Gtk::TreeModel::const_iterator const &row); + + bool _handleKeyEvent(GdkEventKey *event); + void _handleButtonEvent(GdkEventButton *event); + void _apply(); void _close(); bool _flexible; Geom::Satellite _satellite; - const gchar *unit; - Glib::ustring document_unit; - bool use_distance; - double amount; - bool aprox; - void _set_amount(double amount); - void _set_satellite(Geom::Satellite satellite); - void _prepareLabelRenderer(Gtk::TreeModel::const_iterator const &row); + const gchar *_unit; + Glib::ustring _document_unit; + bool _use_distance; + double _amount; + bool _aprox; - bool _handleKeyEvent(GdkEventKey *event); - void _handleButtonEvent(GdkEventButton *event); friend class Inkscape::LivePathEffect:: - FilletChamferKnotHolderEntity; + FilletChamferKnotHolderEntity; private: FilletChamferPropertiesDialog( |
