summaryrefslogtreecommitdiffstats
path: root/src/helper/geom-pathvectorsatellites.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2016-06-12 22:58:55 +0000
committerjabiertxof <info@marker.es>2016-06-12 22:58:55 +0000
commit73f078b27b669c941651ecf14a3119ae491ccabf (patch)
tree859d650d22f499e1b3af266bcd3e43ff39bdbc6f /src/helper/geom-pathvectorsatellites.cpp
parentHandle both directions on knot reposition (diff)
downloadinkscape-73f078b27b669c941651ecf14a3119ae491ccabf.tar.gz
inkscape-73f078b27b669c941651ecf14a3119ae491ccabf.zip
Fix 90% of tweenk review
(bzr r13645.1.155)
Diffstat (limited to 'src/helper/geom-pathvectorsatellites.cpp')
-rw-r--r--src/helper/geom-pathvectorsatellites.cpp111
1 files changed, 110 insertions, 1 deletions
diff --git a/src/helper/geom-pathvectorsatellites.cpp b/src/helper/geom-pathvectorsatellites.cpp
index 625506b2f..c56887f53 100644
--- a/src/helper/geom-pathvectorsatellites.cpp
+++ b/src/helper/geom-pathvectorsatellites.cpp
@@ -1,6 +1,6 @@
/**
* \file
- * \brief PathVectorSatellites a class to manage a vector of satellites per piecewise node
+ * \brief PathVectorSatellites a class to manage satellites -per node extra data- in a pathvector
*/ /*
* Authors:
* Jabiertxof
@@ -60,6 +60,115 @@ std::pair<size_t, size_t> PathVectorSatellites::getIndexData(size_t index)
return std::make_pair(0,0);
}
+void PathVectorSatellites::setSelected(std::vector<size_t> selected)
+{
+ size_t counter = 0;
+ for (size_t i = 0; i < _satellites.size(); ++i) {
+ for (size_t j = 0; j < _satellites[i].size(); ++j) {
+ if(find (selected.begin(), selected.end(), counter) != selected.end()){
+ _satellites[i][j].setSelected(true);
+ } else {
+ _satellites[i][j].setSelected(false);
+ }
+ counter++;
+ }
+ }
+}
+
+void PathVectorSatellites::updateSteps(size_t steps, bool apply_no_radius, bool apply_with_radius, bool only_selected)
+{
+ for (size_t i = 0; i < _satellites.size(); ++i) {
+ for (size_t j = 0; j < _satellites[i].size(); ++j) {
+ if ((!apply_no_radius && _satellites[i][j].amount == 0) ||
+ (!apply_with_radius && _satellites[i][j].amount != 0))
+ {
+ continue;
+ }
+ if (only_selected) {
+ if (_satellites[i][j].selected) {
+ _satellites[i][j].steps = steps;
+ }
+ } else {
+ _satellites[i][j].steps = steps;
+ }
+ }
+ }
+}
+
+void PathVectorSatellites::updateAmount(double radius, bool apply_no_radius, bool apply_with_radius, bool only_selected,
+ bool use_knot_distance, bool flexible)
+{
+ double power = 0;
+ if (!flexible) {
+ power = radius;
+ } else {
+ power = radius / 100;
+ }
+ for (size_t i = 0; i < _satellites.size(); ++i) {
+ for (size_t j = 0; j < _satellites[i].size(); ++j) {
+ boost::optional<size_t> previous_index = boost::none;
+ if(j == 0 && _pathvector[i].closed()){
+ previous_index = _pathvector[i].size() - 1;
+ } else if(!_pathvector[i].closed() || j != 0) {
+ previous_index = j - 1;
+ }
+ if (!_pathvector[i].closed() && j == 0) {
+ _satellites[i][j].amount = 0;
+ continue;
+ }
+ if (_pathvector[i].size() == j) {
+ continue;
+ }
+ if ((!apply_no_radius && _satellites[i][j].amount == 0) ||
+ (!apply_with_radius && _satellites[i][j].amount != 0))
+ {
+ continue;
+ }
+
+ Geom::Point satellite_point = _pathvector[i].pointAt(j);
+ if (_satellites[i][j].selected || !only_selected) {
+ if (!use_knot_distance && !flexible) {
+ if(previous_index) {
+ _satellites[i][j].amount = _satellites[i][j].radToLen(power, _pathvector[i][*previous_index], _pathvector[i][j]);
+ } else {
+ _satellites[i][j].amount = 0.0;
+ }
+ } else {
+ _satellites[i][j].amount = power;
+ }
+ }
+ }
+ }
+}
+
+void PathVectorSatellites::updateSatelliteType(SatelliteType satellitetype, bool apply_no_radius, bool apply_with_radius,
+ bool only_selected)
+{
+ for (size_t i = 0; i < _satellites.size(); ++i) {
+ for (size_t j = 0; j < _satellites[i].size(); ++j) {
+ if ((!apply_no_radius && _satellites[i][j].amount == 0) ||
+ (!apply_with_radius && _satellites[i][j].amount != 0))
+ {
+ continue;
+ }
+ if (_pathvector[i].size() == j) {
+ if (!only_selected) {
+ _satellites[i][j].satellite_type = satellitetype;
+ }
+ continue;
+ }
+ if (only_selected) {
+ Geom::Point satellite_point = _pathvector[i].pointAt(j);
+ if (_satellites[i][j].selected) {
+ _satellites[i][j].satellite_type = satellitetype;
+ }
+ } else {
+ _satellites[i][j].satellite_type = satellitetype;
+ }
+ }
+ }
+}
+
void PathVectorSatellites::recalculateForNewPathVector(Geom::PathVector const pathv, Satellite const S)
{
Satellites satellites;