summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2016-05-10 21:16:49 +0000
committerjabiertxof <info@marker.es>2016-05-10 21:16:49 +0000
commit07717a370b8efe6ddbb0c69d115bb063a2e7686a (patch)
treedf507f7bc83681ce315137c5828ce6c8b24cdf76 /src
parentupdate to trunk (diff)
downloadinkscape-07717a370b8efe6ddbb0c69d115bb063a2e7686a.tar.gz
inkscape-07717a370b8efe6ddbb0c69d115bb063a2e7686a.zip
Working with path updates
(bzr r13645.1.130)
Diffstat (limited to 'src')
-rw-r--r--src/helper/geom-pointwise.cpp63
-rw-r--r--src/helper/geom-pointwise.h12
-rw-r--r--src/helper/geom-satellite.cpp22
-rw-r--r--src/live_effects/CMakeLists.txt4
-rw-r--r--src/live_effects/lpe-fillet-chamfer.cpp248
-rw-r--r--src/live_effects/parameter/array.cpp41
-rw-r--r--src/live_effects/parameter/array.h9
-rw-r--r--src/live_effects/parameter/satellitesarray.cpp310
-rw-r--r--src/live_effects/parameter/satellitesarray.h2
-rw-r--r--src/ui/dialog/lpe-fillet-chamfer-properties.h2
10 files changed, 353 insertions, 360 deletions
diff --git a/src/helper/geom-pointwise.cpp b/src/helper/geom-pointwise.cpp
index a96b7cbda..a7082ec24 100644
--- a/src/helper/geom-pointwise.cpp
+++ b/src/helper/geom-pointwise.cpp
@@ -15,42 +15,41 @@
*/
#include <helper/geom-pointwise.h>
-
PwD2SBasis Pointwise::getPwd2() const
{
return _pwd2;
}
-Geom::Pathvector Pointwise::getPV() const
+Geom::PathVector Pointwise::getPV() const
{
return _pathvector;
}
void Pointwise::setPwd2(PwD2SBasis const &pwd2_in)
{
- _pathvector = path_from_piecewise(Geom::remove_short_cuts(_pwd2,0.01),0.01);
_pwd2 = pwd2_in;
+ _pathvector = path_from_piecewise(Geom::remove_short_cuts(_pwd2,0.01),0.01);
}
-Satelites Pointwise::getSatellites()
+Satellites Pointwise::getSatellites()
{
return _satellites;
}
size_t Pointwise::getTotalSatellites()
{
- size_t counter = 0
- for (size_t i = 0; i < satellites.size(); ++i) {
- for (size_t j = 0; j < satellites[i].size(); ++j) {
+ size_t counter = 0;
+ for (size_t i = 0; i < _satellites.size(); ++i) {
+ for (size_t j = 0; j < _satellites[i].size(); ++j) {
counter++;
}
}
return counter;
}
-void Pointwise::setSatellites(Satelites const &sats)
+void Pointwise::setSatellites(Satellites const &satellites)
{
- _satellites = sats;
+ _satellites = satellites;
}
void Pointwise::recalculateForNewPwd2(PwD2SBasis const &A, Geom::PathVector const &B, Satellite const &S)
@@ -64,7 +63,7 @@ void Pointwise::recalculateForNewPwd2(PwD2SBasis const &A, Geom::PathVector cons
void Pointwise::recalculatePwD2(PwD2SBasis const &A, Satellite const &S)
{
- Satelites sats;
+ Satellites satellites;
Geom::PathVector new_pathv = path_from_piecewise(Geom::remove_short_cuts(A,0.01),0.01);
Geom::PathVector old_pathv = _pathvector;
_pathvector.clear();
@@ -74,11 +73,8 @@ void Pointwise::recalculatePwD2(PwD2SBasis const &A, Satellite const &S)
for (size_t i = 0; i < new_pathv.size(); i++) {
bool match = false;
for (size_t j = 0; j < old_pathv.size(); j++) {
- std::vector<satellite> subpath_satellites;
if ( new_pathv[i] == old_pathv[j]){
- _pathvector.push_back(old_pathv[j];
- sats.push_back(_satellites[j]);
- _satellites.erase(_satellites.begin() + j);
+ satellites.push_back(_satellites[j]);
old_pathv.erase(old_pathv.begin() + j);
new_pathv.erase(new_pathv.begin() + i);
match = true;
@@ -86,12 +82,11 @@ void Pointwise::recalculatePwD2(PwD2SBasis const &A, Satellite const &S)
}
}
if (!match && new_size > old_increments){
- _pathvector.push_back(new_pathv[i]);
- std::vector<satellite> subpath_satellites;
- for (size_t k = 0; k < new_pathv[i].size(); k++) {
+ std::vector<Satellite> subpath_satellites;
+ for (size_t k = 0; k < new_pathv[i].size_closed(); k++) {
subpath_satellites.push_back(Satellite(_satellites[0][0].satellite_type));
}
- sats.push_back(subpath_satellites);
+ satellites.push_back(subpath_satellites);
old_increments ++;
}
}
@@ -99,30 +94,37 @@ void Pointwise::recalculatePwD2(PwD2SBasis const &A, Satellite const &S)
//we asume not change the order of subpaths when remove or add nodes to existing subpaths
for (size_t l = 0; l < old_pathv.size(); l++) {
//we assume we only can delete or add nodes not a mix of both
+ std::vector<Satellite> subpath_satellites;
if (old_pathv[l].size() > new_pathv[l].size()){
//erase nodes
for (size_t m = 0; m < old_pathv[l].size(); m++) {
- if (!are_near(old_pathv[l][m].initialPoint(), new_pathv[l][m].initialPoint()) {
- _satellites[l].erase(_satellites.begin() + m);
+ if (are_near(old_pathv[l][m].initialPoint(), new_pathv[l][m].initialPoint())) {
+ subpath_satellites.push_back(_satellites[l][m]);
}
}
- } else if (old_pathv[l].size() > new_pathv[l].size()) {
+ if (!old_pathv[l].closed() &&
+ are_near(old_pathv[l][old_pathv[l].size() - 1].finalPoint(), new_pathv[l][new_pathv[l].size() - 1].finalPoint()))
+ {
+ subpath_satellites.push_back(_satellites[l][old_pathv[l].size()]);
+ }
+ } else if (old_pathv[l].size() < new_pathv[l].size()) {
//add nodes
for (size_t m = 0; m < old_pathv[l].size(); m++) {
- if (!are_near(old_pathv[l][m].initialPoint(), new_pathv[l][m].initialPoint()) {
- _satellites[l].insert(_satellites.begin() + m, S);
+ if (!are_near(old_pathv[l][m].initialPoint(), new_pathv[l][m].initialPoint())) {
+ _satellites[l].insert(_satellites[l].begin() + m, S);
}
}
+ if (!old_pathv[l].closed() && !are_near(old_pathv[l][old_pathv[l].size()-1].finalPoint(), new_pathv[l][old_pathv[l].size()-1].finalPoint())) {
+ _satellites[l].insert(_satellites[l].begin() + old_pathv[l].size(), S);
+ }
} else {
//never happends
}
- sats.push_back(_satellites[l]);
- _pathvector.push_back(new_pathv[l]);
-
+ satellites.push_back(subpath_satellites);
}
}
setPwd2(A);
- setSatellites(sats);
+ setSatellites(satellites);
}
void Pointwise::insertDegenerateSatellites(PwD2SBasis const &A, Geom::PathVector const &B, Satellite const &S)
@@ -136,15 +138,14 @@ void Pointwise::insertDegenerateSatellites(PwD2SBasis const &A, Geom::PathVector
size_t counter_added = 0;
for (size_t i = 0; i < B.size(); i++) {
size_t counter = 0;
- if (B[i]->empty()) {
+ if (B[i].empty()) {
continue;
}
- for (size_t j = 0; j < B[i].size(); j++) {
- if ((B[i][j].isDegenerate() && counter_added < satellite_gap) {
+ for (size_t j = 0; j < B[i].size_closed(); j++) {
+ if (B[i][j].isDegenerate() && counter_added < satellite_gap) {
counter_added++;
_satellites[i].insert(_satellites[i].begin() + counter + 1 ,S);
}
- ++curve_it1;
counter++;
}
}
diff --git a/src/helper/geom-pointwise.h b/src/helper/geom-pointwise.h
index 4c2ec7957..fa03a5db7 100644
--- a/src/helper/geom-pointwise.h
+++ b/src/helper/geom-pointwise.h
@@ -28,16 +28,16 @@
/**
* @brief Pointwise a class to manage a vector of satellites per piecewise curve
*/
-typedef Geom::Piecewise<Geom::D2<Geom::SBasis> > PwD2SBasisasis;
-typedef std::vector< Satelites > Satelites;
+typedef Geom::Piecewise<Geom::D2<Geom::SBasis> > PwD2SBasis;
+typedef std::vector<std::vector<Satellite> > Satellites;
class Pointwise {
public:
PwD2SBasis getPwd2() const;
- Geom::Pathvector getPV() const;
+ Geom::PathVector getPV() const;
void setPwd2(PwD2SBasis const &pwd2_in);
- Satelites getSatellites();
+ Satellites getSatellites();
size_t getTotalSatellites();
- void setSatellites(Satelites const &sats);
+ void setSatellites(Satellites const &satellites);
void recalculateForNewPwd2(PwD2SBasis const &A, Geom::PathVector const &B, Satellite const &S);
//Fired when a path is modified.
void recalculatePwD2(PwD2SBasis const &A, Satellite const &S);
@@ -48,7 +48,7 @@ public:
private:
PwD2SBasis _pwd2;
Geom::PathVector _pathvector;
- Satelites _satellites;
+ Satellites _satellites;
};
#endif //SEEN_POINTWISE_H
diff --git a/src/helper/geom-satellite.cpp b/src/helper/geom-satellite.cpp
index 027497d78..2672a571b 100644
--- a/src/helper/geom-satellite.cpp
+++ b/src/helper/geom-satellite.cpp
@@ -136,22 +136,22 @@ double Satellite::lenToRad(
Geom::Point end_arc_point = curve_out.pointAt(time_out);
Geom::Curve *knot_curve1 = curve_in.portion(0, time_in);
Geom::Curve *knot_curve2 = curve_out.portion(time_out, 1);
- Geom::cubic_bezier const *cubic1 = dynamic_cast<Geom::cubic_bezier const *>(&*knot_curve1);
- Geom::Ray ray1(startArcPoint, curve_in.pointAt(1));
+ Geom::CubicBezier const *cubic1 = dynamic_cast<Geom::CubicBezier const *>(&*knot_curve1);
+ Geom::Ray ray1(start_arc_point, curve_in.pointAt(1));
if (cubic1) {
- ray1.setPoints((*cubic1)[2], startArcPoint);
+ ray1.setPoints((*cubic1)[2], start_arc_point);
}
- Geom::cubic_bezier const *cubic2 = dynamic_cast<Geom::cubic_bezier const *>(&*knot_curve2);
- Geom::Ray ray2(curve_out.pointAt(0), endArcPoint);
+ Geom::CubicBezier const *cubic2 = dynamic_cast<Geom::CubicBezier const *>(&*knot_curve2);
+ Geom::Ray ray2(curve_out.pointAt(0), end_arc_point);
if (cubic2) {
- ray2.setPoints(endArcPoint, (*cubic2)[1]);
+ ray2.setPoints(end_arc_point, (*cubic2)[1]);
}
- bool ccw_toggle = cross(curve_in.pointAt(1) - startArcPoint,
- end_arc_point - startArcPoint) < 0;
+ bool ccw_toggle = cross(curve_in.pointAt(1) - start_arc_point,
+ end_arc_point - start_arc_point) < 0;
double distance_arc =
- Geom::distance(startArcPoint, middle_point(startArcPoint, endArcPoint));
- double angle_between = angle_between(ray1, ray2, ccw_toggle);
- double divisor = std::sin(angle_between / 2.0);
+ Geom::distance(start_arc_point, middle_point(start_arc_point, end_arc_point));
+ double angle = angle_between(ray1, ray2, ccw_toggle);
+ double divisor = std::sin(angle / 2.0);
if (divisor > 0) {
return distance_arc / divisor;
}
diff --git a/src/live_effects/CMakeLists.txt b/src/live_effects/CMakeLists.txt
index a1aa811a9..64364c88c 100644
--- a/src/live_effects/CMakeLists.txt
+++ b/src/live_effects/CMakeLists.txt
@@ -65,7 +65,7 @@ set(live_effects_SRC
parameter/path.cpp
parameter/point.cpp
parameter/powerstrokepointarray.cpp
- parameter/satellitearray.cpp
+ parameter/satellitesarray.cpp
parameter/random.cpp
parameter/text.cpp
parameter/togglebutton.cpp
@@ -145,7 +145,7 @@ set(live_effects_SRC
parameter/path.h
parameter/point.h
parameter/powerstrokepointarray.h
- parameter/satellitearray.h
+ parameter/satellitesarray.h
parameter/random.h
parameter/text.h
parameter/togglebutton.h
diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp
index bcab1c055..ab1cf41e3 100644
--- a/src/live_effects/lpe-fillet-chamfer.cpp
+++ b/src/live_effects/lpe-fillet-chamfer.cpp
@@ -97,29 +97,32 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem)
continue;
}
std::vector<Satellite> subpath_satellites;
- Geom::Path::const_iterator curve_it1 = path_it->begin();
- Geom::Path::const_iterator curve_endit = path_it->end_default();
- bool start = true;
- while (curve_it1 != curve_endit) {
- bool hidden = false;
- if (start) {
- if (!path_it->closed()) {
- hidden = true;
- }
- start = false;
- }
+ for (Geom::Path::const_iterator curve_it = path_it->begin(); curve_it != path_it->end(); ++curve_it) {
+ //Maybe we want this satellites...
+ //if (curve_it->isDegenerate()) {
+ // continue
+ //}
+ Satellite satellite(FILLET);
+ satellite.setSteps(chamfer_steps);
+ subpath_satellites.push_back(satellite);
+ }
+ //we add the last satellite on open path because pointwise is related to nodes, not curves
+ //so maybe in the future we can need this last satellite in other effects
+ //dont remove for this effect because pointwise class has methods when the path is modiffied
+ //and we want one method for all uses
+ if (!path_it->closed()) {
Satellite satellite(FILLET);
- satellite.setHidden(hidden);
satellite.setSteps(chamfer_steps);
subpath_satellites.push_back(satellite);
- ++curve_it1;
}
satellites.push_back(subpath_satellites);
}
pointwise = new Pointwise();
+ //Why Pwd2? Could we switch all to pathvector instead?
+ //I usualy use a pathvector, except some curve operations with D2<SBasis>
+ //if yes maybe "poinwise" need a rename
pointwise->setPwd2(paths_to_pw(pathv));
pointwise->setSatellites(satellites);
- //pointwise->setStart();
satellites_param.setPointwise(pointwise);
} else {
g_warning("LPE Fillet/Chamfer can only be applied to shapes (not groups).");
@@ -261,29 +264,33 @@ void LPEFilletChamfer::updateAmount()
for (size_t j = 0; j < satellites[i].size(); ++j) {
boost::optional<size_t> curve_prev_index = boost::none;
if(j == 0 && pathv[i].closed()){
- curve_prev_index = pathv[pathv[i].size() - 1];
+ curve_prev_index = pathv[i].size() - 1;
} else if(!pathv[i].closed() || j != 0) {
curve_prev_index = j - 1;
}
- if (!pathv[i].closed() && sat_curve_time == 0) {
- it->amount = 0;
+ if (!pathv[i].closed() && j == 0) {
+ satellites[i][j].amount = 0;
+ continue;
+ }
+ if (pathv[i].size() == j) {
continue;
}
- if ((!apply_no_radius && it->amount == 0) ||
- (!apply_with_radius && it->amount != 0))
+ if ((!apply_no_radius && satellites[i][j].amount == 0) ||
+ (!apply_with_radius && satellites[i][j].amount != 0))
{
continue;
}
- Geom::Point satellite_point = pwd2.valueAt(it - satellites.begin());
+
+ Geom::Point satellite_point = pathv[i].pointAt(j);
if (isNodePointSelected(satellite_point) || !only_selected) {
if (!use_knot_distance && !flexible) {
if(curve_prev_index) {
- it->amount = it->radToLen(power, pathv[i][*curve_prev_index], pathv[i][j]);
+ satellites[i][j].amount = satellites[i][j].radToLen(power, pathv[i][*curve_prev_index], pathv[i][j]);
} else {
- it->amount = 0.0;
+ satellites[i][j].amount = 0.0;
}
} else {
- it->amount = power;
+ satellites[i][j].amount = power;
}
}
}
@@ -294,22 +301,22 @@ void LPEFilletChamfer::updateAmount()
void LPEFilletChamfer::updateChamferSteps()
{
- std::vector<Satellite> satellites = pointwise->getSatellites();
+ Satellites satellites = pointwise->getSatellites();
Geom::PathVector pathv = pointwise->getPV();
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))
+ if ((!apply_no_radius && satellites[i][j].amount == 0) ||
+ (!apply_with_radius && satellites[i][j].amount != 0))
{
continue;
}
if (only_selected) {
Geom::Point satellite_point = pathv[i].pointAt(j);
if (isNodePointSelected(satellite_point)) {
- satellites[i][j]->steps = chamfer_steps;
+ satellites[i][j].steps = chamfer_steps;
}
} else {
- satellites[i][j]->steps = chamfer_steps;
+ satellites[i][j].steps = chamfer_steps;
}
}
}
@@ -319,22 +326,28 @@ void LPEFilletChamfer::updateChamferSteps()
void LPEFilletChamfer::updateSatelliteType(SatelliteType satellitetype)
{
- std::vector<Satellite> satellites = pointwise->getSatellites();
+ Satellites satellites = pointwise->getSatellites();
Geom::PathVector pathv = pointwise->getPV();
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))
+ if ((!apply_no_radius && satellites[i][j].amount == 0) ||
+ (!apply_with_radius && satellites[i][j].amount != 0))
{
continue;
}
+ if (pathv[i].size() == j) {
+ if (!only_selected) {
+ satellites[i][j].satellite_type = satellitetype;
+ }
+ continue;
+ }
if (only_selected) {
Geom::Point satellite_point = pathv[i].pointAt(j);
if (isNodePointSelected(satellite_point)) {
- satellites[i][j]->satellite_type = satellitetype;
+ satellites[i][j].satellite_type = satellitetype;
}
} else {
- satellites[i][j]->satellite_type = satellitetype;
+ satellites[i][j].satellite_type = satellitetype;
}
}
}
@@ -361,44 +374,47 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem)
satellites_param.setEffectType(effectType());
Geom::PathVector const pathv = pathv_to_linear_and_cubic_beziers(c->get_pathvector());
- Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = paths_to_pw(pathv);
- pwd2 = remove_short_cuts(pwd2, 0.01);
- Satellites satelites = satellites_param.data();
- if(satelites.empty()) {
+ Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = remove_short_cuts(paths_to_pw(pathv), 0.01);;
+ Satellites satellites = satellites_param.data();
+ if(satellites.empty()) {
doOnApply(lpeItem);
- satelites = satellites_param.data();
+ satellites = satellites_param.data();
}
if (hide_knots) {
satellites_param.setHelperSize(0);
} else {
satellites_param.setHelperSize(helper_size);
}
- size_t number_curves = pathv.curveCount();
+ size_t number_nodes = pathv.nodes().size();
for (size_t i = 0; i < satellites.size(); ++i) {
for (size_t j = 0; j < satellites[i].size(); ++j) {
- if (satellites[i][j]->is_time != flexible) {
- satellites[i][j]->is_time = flexible;
- double amount = satellites[i][j]->amount;
+ if (satellites[i][j].is_time != flexible) {
+ satellites[i][j].is_time = flexible;
+ double amount = satellites[i][j].amount;
+ if (pathv[i].size() == j){
+ continue;
+ }
Geom::Curve const &curve_in = pathv[i][j];
- if (satellites[i][j]->is_time) {
+ if (satellites[i][j].is_time) {
double time = timeAtArcLength(amount, curve_in);
- satellites[i][j]->amount = time;
+ satellites[i][j].amount = time;
} else {
double size = arcLengthAt(amount, curve_in);
- satellites[i][j]->amount = size;
+ satellites[i][j].amount = size;
}
}
- if (satellites[i][j]->has_mirror != mirror_knots) {
- satellites[i][j]->has_mirror = mirror_knots;
+ if (satellites[i][j].has_mirror != mirror_knots) {
+ satellites[i][j].has_mirror = mirror_knots;
}
- satellites[i][j]->hidden = hide_knots;
+ satellites[i][j].hidden = hide_knots;
}
}
//if are diferent sizes call to poinwise recalculate
//todo: fire a reverse satellites on reverse path. Maybe a new method
//like "are_similar" to avoid precission issues on reverse a pointwise
//and after convert to Pathvector
- if (pointwise && number_curves != pointwise->getTotalSatellites()) {
+ if (pointwise && number_nodes != pointwise->getTotalSatellites()) {
+ std::cout << "gasdfgffffffffffffffffffffffffffffffffffffffffffffffffff\n";
Satellite satellite(satellites[0][0].satellite_type);
satellite.setIsTime(satellites[0][0].is_time);
satellite.setHasMirror(satellites[0][0].has_mirror);
@@ -408,7 +424,6 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem)
pointwise->setPwd2(pwd2);
pointwise->setSatellites(satellites);
}
- pointwise->setStart();
satellites_param.setPointwise(pointwise);
refreshKnots();
} else {
@@ -427,86 +442,63 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in)
{
const double GAP_HELPER = 0.00001;
Geom::PathVector path_out;
- size_t counter_paths = 0;
+ size_t path = 0;
const double K = (4.0 / 3.0) * (sqrt(2.0) - 1.0);
- Geom::PathVector path_in_processed = pathv_to_linear_and_cubic_beziers(path_in);
- for (Geom::PathVector::const_iterator path_it = path_in_processed.begin(); path_it != path_in_processed.end(); ++path_it) {
+ Geom::PathVector pathv = pathv_to_linear_and_cubic_beziers(path_in);
+ for (Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) {
if (path_it->empty()) {
continue;
}
_hp.push_back(*path_it);
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) {
- counter++;
- tmp_path.start((*curve_it1).pointAt(0));
- tmp_path.append(*curve_it1);
+ path++;
+ tmp_path.start(path_it[0].pointAt(0));
+ tmp_path.append(path_it[0]);
path_out.push_back(tmp_path);
continue;
}
- size_t counter_curves = 0;
- size_t first = counter;
double time0 = 0;
- Satellites satelites = pointwise->getSatellites();
- while (curve_it1 != curve_endit) {
- if (curve_it2 != curve_endit && (*curve_it2).isDegenerate()) {
- ++curve_it2;
- }
- if ((*curve_it1).isDegenerate()) {
- ++curve_it1;
- counter_curves++;
- time0 = 0.0;
- continue;
- }
- Satellite satellite;
- Geom::Curve *curve_it2_fixed = path_it->begin()->duplicate();
- if (!path_it->closed()) {
- if (curve_it2 != curve_endit) {
- curve_it2_fixed = (*curve_it2).duplicate();
- if (satellites[counter_paths].size() > counter_curves + 1) {
- satellite = satellites[counter_paths][counter_curves + 1];
- }
- } else {
- if (time0 != 1) {
- Geom::Curve *last_curve = curve_it1->portion(time0, 1);
- last_curve->setInitial(tmp_path.finalPoint());
- tmp_path.append(*last_curve);
- }
- ++curve_it1;
- counter_curves++;
- continue;
- }
- } else {
- if (curve_it2 != curve_endit) {
- curve_it2_fixed = (*curve_it2).duplicate();
- if (satellites[counter_paths].size() > counter_curves + 1) {
- satellite = satellites[counter_paths][counter_curves + 1];;
- }
-
- } else {
- if (satellites[counter_paths].size() > 0) {
- satellite = satellites[counter_paths][0];
- }
+ size_t curve = 0;
+ Satellites satellites = pointwise->getSatellites();
+ for (Geom::Path::const_iterator curve_it1 = path_it->begin(); curve_it1 != path_it->end(); ++curve_it1) {
+ boost::optional<size_t> curve_next_index = boost::none;
+ if (curve == pathv[path].size() - 1 && pathv[path].closed()) {
+ curve_next_index = 0;
+ } else if (curve != pathv[path].size() -1 || !pathv[path].closed()) {
+ curve_next_index = curve + 1;
+ }
+ if (curve == pathv[path].size() -1 && !pathv[path].closed()) { //the path is open and we are at end of path
+ if (time0 != 1) { //Previous satellite not at 100% amount
+ Geom::Curve *last_curve = curve_it1->portion(time0, 1);
+ last_curve->setInitial(tmp_path.finalPoint());
+ tmp_path.append(*last_curve);
+ delete last_curve;
}
+ continue;
}
- if (counter_curves == 0) {
- if (satellites[counter_paths].size() > 0 && satellites[counter_paths][0].active) {
- time0 = satellites[counter_paths][0].time(*path_it->begin());
- } else {
+ Geom::Curve const &curve_it2 = pathv[path][*curve_next_index];
+// if (curve != pathv[path].size() && (*curve_it2).isDegenerate()) {
+// ++curve_it2;
+// }
+// if ((*curve_it1).isDegenerate()) {
+// ++curve_it1;
+// counter_curves++;
+// time0 = 0.0;
+// continue;
+// }
+ Satellite satellite = satellites[path][*curve_next_index];
+ if (!curve) { //curve == 0
+ if (!path_it->closed()) {
time0 = 0;
+ } else {
+ time0 = satellites[path][0].time(*curve_it1);
}
}
- Geom::Curve const &curve_it2_fixed_ref = *curve_it2_fixed;
- bool last = curve_it2 == curve_endit;
- double s = satellite.arcDistance(curve_it2_fixed_ref);
+ bool last = pathv[path].size() - 1 == curve;
+ double s = satellite.arcDistance(curve_it2);
double time1 = satellite.time(s, true, (*curve_it1));
- double time2 = satellite.time(curve_it2_fixed_ref);
- if (!satellite.active) {
- time1 = 1;
- time2 = 0;
- }
+ double time2 = satellite.time(curve_it2);
if (time1 <= time0) {
time1 = time0;
@@ -519,22 +511,22 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in)
times.push_back(time1);
times.push_back(time2);
Geom::Curve *knot_curve_1 = curve_it1->portion(times[0], times[1]);
- if (counter_curves > 0) {
+ if (curve > 0) {
knot_curve_1->setInitial(tmp_path.finalPoint());
} else {
tmp_path.start((*curve_it1).pointAt(times[0]));
}
Geom::Point start_arc_point = knot_curve_1->finalPoint();
- Geom::Point end_arc_point = curve_it2_fixed_ref.pointAt(times[2]);
+ Geom::Point end_arc_point = curve_it2.pointAt(times[2]);
if (times[2] == 1) {
- end_arc_point = curve_it2_fixed_ref.pointAt(times[2] - GAP_HELPER);
+ end_arc_point = curve_it2.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_ref.initialPoint()) * K;
+ double k2 = distance(end_arc_point, curve_it2.initialPoint()) * K;
Geom::CubicBezier const *cubic_1 =
dynamic_cast<Geom::CubicBezier const *>(&*knot_curve_1);
Geom::Ray ray_1(start_arc_point, curve_it1->finalPoint());
@@ -545,10 +537,10 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in)
if (time0 == 1) {
handle_1 = start_arc_point;
}
- Geom::Curve *knot_curve_2 = curve_it2_fixed_ref.portion(times[2], 1);
+ Geom::Curve *knot_curve_2 = curve_it2.portion(times[2], 1);
Geom::CubicBezier const *cubic_2 =
dynamic_cast<Geom::CubicBezier const *>(&*knot_curve_2);
- Geom::Ray ray_2(curve_it2_fixed_ref.initialPoint(), end_arc_point);
+ Geom::Ray ray_2(curve_it2.initialPoint(), end_arc_point);
if (cubic_2) {
ray_2.setPoints(end_arc_point, (*cubic_2)[1]);
}
@@ -571,7 +563,7 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in)
}
Geom::Point inverse_handle_2 = end_arc_point - Geom::Point::polar(handleAngle, k2);
if (times[2] == 1) {
- end_arc_point = curve_it2_fixed_ref.pointAt(times[2]);
+ end_arc_point = curve_it2.pointAt(times[2]);
}
if (times[1] == times[0]) {
start_arc_point = curve_it1->pointAt(times[0]);
@@ -599,7 +591,7 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in)
Geom::Path path_chamfer;
path_chamfer.start(tmp_path.finalPoint());
if ((is_straight_curve(*curve_it1) &&
- is_straight_curve(curve_it2_fixed_ref) && method != FM_BEZIER) ||
+ is_straight_curve(curve_it2) && method != FM_BEZIER) ||
method == FM_ARC) {
ccw_toggle = ccw_toggle ? 0 : 1;
path_chamfer.appendNew<Geom::EllipticalArc>(rx, ry, arc_angle, 0,
@@ -618,7 +610,7 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in)
Geom::Path path_chamfer;
path_chamfer.start(tmp_path.finalPoint());
if ((is_straight_curve(*curve_it1) &&
- is_straight_curve(curve_it2_fixed_ref) && method != FM_BEZIER) ||
+ is_straight_curve(curve_it2) && method != FM_BEZIER) ||
method == FM_ARC) {
path_chamfer.appendNew<Geom::EllipticalArc>(rx, ry, arc_angle, 0,
ccw_toggle, end_arc_point);
@@ -635,7 +627,7 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in)
tmp_path.appendNew<Geom::LineSegment>(end_arc_point);
} else if (type == INVERSE_FILLET) {
if ((is_straight_curve(*curve_it1) &&
- is_straight_curve(curve_it2_fixed_ref) && method != FM_BEZIER) ||
+ is_straight_curve(curve_it2) && method != FM_BEZIER) ||
method == FM_ARC) {
tmp_path.appendNew<Geom::EllipticalArc>(rx, ry, arc_angle, 0, ccw_toggle,
end_arc_point);
@@ -645,7 +637,7 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in)
}
} else if (type == FILLET) {
if ((is_straight_curve(*curve_it1) &&
- is_straight_curve(curve_it2_fixed_ref) && method != FM_BEZIER) ||
+ is_straight_curve(curve_it2) && method != FM_BEZIER) ||
method == FM_ARC) {
ccw_toggle = ccw_toggle ? 0 : 1;
tmp_path.appendNew<Geom::EllipticalArc>(rx, ry, arc_angle, 0, ccw_toggle,
@@ -663,14 +655,10 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in)
if (path_it->closed() && last) {
tmp_path.close();
}
- ++curve_it1;
- if (curve_it2 != curve_endit) {
- ++curve_it2;
- }
- counter_curves++;
+ curve++;
time0 = times[2];
}
- counter_paths++;
+ path++;
path_out.push_back(tmp_path);
}
return path_out;
diff --git a/src/live_effects/parameter/array.cpp b/src/live_effects/parameter/array.cpp
index 0bbe39293..c9e2d6563 100644
--- a/src/live_effects/parameter/array.cpp
+++ b/src/live_effects/parameter/array.cpp
@@ -15,35 +15,36 @@ namespace LivePathEffect {
//TODO: move maybe
unsigned int
-sp_svg_satellite_vector_read_d(gchar const *str, std::vector<Satellite> *satellites){
+sp_svg_satellite_vector_read_d(gchar const *str, std::vector<Satellite> *subpath_satellites){
if (!str) {
return 0;
}
- gchar ** strarray = g_strsplit(str, "@", 0);
- for (size_t i = 0; i < strarray.size(); ++i) {
- gchar ** strsubarray = g_strsplit(strarray[i], ",", 7);
+ gchar ** strarray = g_strsplit(str, " @ ", 0);
+ gchar ** iter = strarray;
+ while (*iter != NULL) {
+ gchar ** strsubarray = g_strsplit(*iter, ",", 7);
if(strlen(str) > 0 && strsubarray[6] && !strsubarray[7]){
- Satellite sat;
- sat->setSatelliteType(g_strstrip(strsubarray[0]));
- sat->is_time = strncmp(strsubarray[1],"1",1) == 0;
- sat->has_mirror = strncmp(strsubarray[2],"1",1) == 0;
- sat->hidden = strncmp(strsubarray[3],"1",1) == 0;
+ Satellite satellite;
+ satellite.setSatelliteType(g_strstrip(strsubarray[0]));
+ satellite.is_time = strncmp(strsubarray[1],"1",1) == 0;
+ satellite.has_mirror = strncmp(strsubarray[2],"1",1) == 0;
+ satellite.hidden = strncmp(strsubarray[3],"1",1) == 0;
double amount,angle;
float stepsTmp;
sp_svg_number_read_d(strsubarray[4], &amount);
sp_svg_number_read_d(strsubarray[5], &angle);
sp_svg_number_read_f(strsubarray[6], &stepsTmp);
unsigned int steps = (unsigned int)stepsTmp;
- sat->amount = amount;
- sat->angle = angle;
- sat->steps = steps;
+ satellite.amount = amount;
+ satellite.angle = angle;
+ satellite.steps = steps;
+ subpath_satellites->push_back(satellite);
g_strfreev (strsubarray);
- satellites.push_back(sat);
}
- g_strfreev (strsubarray);
+ iter++;
}
g_strfreev (strarray);
- if (!sat.empty()){
+ if (!subpath_satellites->empty()){
return 1;
}
return 0;
@@ -88,12 +89,12 @@ template <>
std::vector<Satellite>
ArrayParam<std::vector<Satellite > >::readsvg(const gchar * str)
{
- std::vector<Satellite > satellites;
- if (sp_svg_satellite_vector_read_d(str, &satellites)) {
- return satellites;
+ std::vector<Satellite > subpath_satellites;
+ if (sp_svg_satellite_vector_read_d(str, &subpath_satellites)) {
+ return subpath_satellites;
}
- satellites.push_back(Satellite satellite(FILLET));
- return satellites;
+ subpath_satellites.push_back(Satellite(FILLET));
+ return subpath_satellites;
}
diff --git a/src/live_effects/parameter/array.h b/src/live_effects/parameter/array.h
index 7076a465f..64d01650c 100644
--- a/src/live_effects/parameter/array.h
+++ b/src/live_effects/parameter/array.h
@@ -51,7 +51,7 @@ public:
virtual bool param_readSVGValue(const gchar * strvalue) {
_vector.clear();
- gchar ** strarray = g_strsplit(strvalue, "|", 0);
+ gchar ** strarray = g_strsplit(strvalue, " | ", 0);
gchar ** iter = strarray;
while (*iter != NULL) {
_vector.push_back( readsvg(*iter) );
@@ -112,6 +112,10 @@ protected:
void writesvgData(SVGOStringStream &str, std::vector<Satellite> const &nVector) const {
for (size_t i = 0; i < nVector.size(); ++i) {
+ if (i != 0) {
+ // separate items with @ symbol ¿Any other?
+ str << " @ ";
+ }
str << nVector[i].getSatelliteTypeGchar();
str << ",";
str << nVector[i].is_time;
@@ -125,9 +129,6 @@ protected:
str << nVector[i].angle;
str << ",";
str << nVector[i].steps;
- if (i != nVector.size()-1) {
- str << "@";
- }
}
}
diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp
index 9274a4aff..9f14a1d5b 100644
--- a/src/live_effects/parameter/satellitesarray.cpp
+++ b/src/live_effects/parameter/satellitesarray.cpp
@@ -26,7 +26,7 @@ SatellitesArrayParam::SatellitesArrayParam(const Glib::ustring &label,
const Glib::ustring &key,
Inkscape::UI::Widget::Registry *wr,
Effect *effect)
- : ArrayArrayParam<ArrayArrayParam<Satellite> >(label, tip, key, wr, effect, 0), knoth(NULL)
+ : ArrayParam<std::vector<Satellite> >(label, tip, key, wr, effect, 0), knoth(NULL)
{
_knot_shape = SP_KNOT_SHAPE_DIAMOND;
_knot_mode = SP_KNOT_MODE_XOR;
@@ -77,104 +77,106 @@ void SatellitesArrayParam::updateCanvasIndicators(bool mirror)
if (mirror == true) {
_hp.clear();
}
- for (size_t i = 0; i < _vector.size(); ++i) {
- for (size_t j = 0; j < _vector[i].size(); ++j) {
- if (!_vector[i][j].active || _vector[i][j].hidden) {
- continue;
- }
- if ((!_vector[i][j].has_mirror && mirror == true) || _vector[i][j].amount == 0) {
- continue;
- }
- double pos = 0;
- if (pathv.size() <= i || pathv[i].size() <= j) {
- break;
- }
- Geom::Curve *curve_in = pathv[i][j].duplicate();
- bool overflow = false;
- double size_out = _vector[i][j].arcDistance(*curve_in);
- double lenght_out = curve_in->length();
- double lenght_in = 0;
-
- boost::optional<size_t> curve_prev_index = boost::none;
- if(j == 0 && pathv[i].closed()){
- curve_prev_index = pathv[pathv[i].size() - 1];
- } else if(!pathv[i].closed() || j != 0) {
- curve_prev_index = j - 1;
- }
- if (curve_prev_index) {
- lenght_in = pathv.curveAt(*curve_prev_index).length();
- }
- if (mirror == true) {
+ if (_effectType == FILLET_CHAMFER) {
+ for (size_t i = 0; i < _vector.size(); ++i) {
+ for (size_t j = 0; j < _vector[i].size(); ++j) {
+ if ( _vector[i][j].hidden) {
+ continue;
+ }
+ if ((!_vector[i][j].has_mirror && mirror == true) || _vector[i][j].amount == 0) {
+ continue;
+ }
+ double pos = 0;
+ if (pathv[i].size() == j) { //ignore last satellite in open paths with fillet chamfer effect
+ continue;
+ }
+ Geom::Curve *curve_in = pathv[i][j].duplicate();
+ bool overflow = false;
+ double size_out = _vector[i][j].arcDistance(*curve_in);
+ double lenght_out = curve_in->length();
+ double lenght_in = 0;
+
+ boost::optional<size_t> curve_prev_index = boost::none;
+ if(j == 0 && pathv[i].closed()){
+ curve_prev_index = pathv[i].size() - 1;
+ } else if(!pathv[i].closed() || j != 0) {
+ curve_prev_index = j - 1;
+ }
if (curve_prev_index) {
- curve_in = const_cast<Geom::Curve *>(&pathv.curveAt(*curve_prev_index));
- pos = _vector[i][j].time(size_out, true, *curve_in);
- if (lenght_out < size_out) {
+ lenght_in = pathv.curveAt(*curve_prev_index).length();
+ }
+ if (mirror) {
+ if (curve_prev_index) {
+ curve_in = const_cast<Geom::Curve *>(&pathv.curveAt(*curve_prev_index));
+ pos = _vector[i][j].time(size_out, true, *curve_in);
+ if (lenght_out < size_out) {
+ overflow = true;
+ }
+ }
+ } else {
+ pos = _vector[i][j].time(*curve_in);
+ if (lenght_in < size_out) {
overflow = true;
}
}
- } else {
- pos = _vector[i][j].time(*curve_in);
- if (lenght_in < size_out) {
- overflow = true;
+ if (pos <= 0 || pos >= 1) {
+ continue;
}
- }
- if (pos <= 0 || pos >= 1) {
- continue;
- }
- Geom::Point point_a = curve_in->pointAt(pos);
- Geom::Point deriv_a = unit_vector(derivative(curve_in->toSBasis()).pointAt(pos));
- Geom::Rotate rot(Geom::Rotate::from_degrees(-90));
- 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(ray_1.angle() - Geom::rad_from_deg(90));
- } else {
- aff *= Geom::Rotate(ray_1.angle() - Geom::rad_from_deg(270));
- }
- aff *= Geom::Translate(curve_in->pointAt(pos));
- pathv *= aff;
- _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";
- Geom::PathVector pathv = sp_svg_read_pathv(svgd);
- aff = Geom::Affine();
- aff *= Geom::Scale(diameter);
- aff *= Geom::Translate(point_a - Geom::Point(diameter * 0.35, diameter * 0.35));
- pathv *= aff;
- _hp.push_back(pathv[0]);
+ Geom::Point point_a = curve_in->pointAt(pos);
+ Geom::Point deriv_a = unit_vector(derivative(curve_in->toSBasis()).pointAt(pos));
+ Geom::Rotate rot(Geom::Rotate::from_degrees(-90));
+ 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) {
+ aff *= Geom::Rotate(ray_1.angle() - Geom::rad_from_deg(90));
} 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";
- Geom::PathVector pathv = sp_svg_read_pathv(svgd);
- aff = Geom::Affine();
- aff *= Geom::Scale(_helper_size / 2.0);
- if (mirror == true) {
- aff *= Geom::Rotate(ray_1.angle() - Geom::rad_from_deg(90));
+ aff *= Geom::Rotate(ray_1.angle() - Geom::rad_from_deg(270));
+ }
+ aff *= Geom::Translate(curve_in->pointAt(pos));
+ pathv *= aff;
+ _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";
+ Geom::PathVector pathv = sp_svg_read_pathv(svgd);
+ aff = Geom::Affine();
+ aff *= Geom::Scale(diameter);
+ aff *= Geom::Translate(point_a - Geom::Point(diameter * 0.35, diameter * 0.35));
+ pathv *= aff;
+ _hp.push_back(pathv[0]);
} else {
- aff *= Geom::Rotate(ray_1.angle() - Geom::rad_from_deg(270));
+ 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) {
+ aff *= Geom::Rotate(ray_1.angle() - Geom::rad_from_deg(90));
+ } else {
+ aff *= Geom::Rotate(ray_1.angle() - Geom::rad_from_deg(270));
+ }
+ aff *= Geom::Translate(curve_in->pointAt(pos));
+ pathv *= aff;
+ _hp.push_back(pathv[0]);
}
- aff *= Geom::Translate(curve_in->pointAt(pos));
- pathv *= aff;
- _hp.push_back(pathv[0]);
}
}
}
}
- if (mirror == true) {
+ if (mirror) {
updateCanvasIndicators(false);
}
}
@@ -198,8 +200,7 @@ void SatellitesArrayParam::param_transform_multiply(Geom::Affine const &postmul,
for (size_t i = 0; i < _vector.size(); ++i) {
for (size_t j = 0; j < _vector[i].size(); ++j) {
if (!_vector[i][j].is_time && _vector[i][j].amount > 0) {
- _vector[i][j].amount = _vector[i][j].amount *
- ((postmul.expansionX() + postmul.expansionY()) / 2);
+ _vector[i][j].amount = _vector[i][j].amount * ((postmul.expansionX() + postmul.expansionY()) / 2);
}
}
}
@@ -208,24 +209,22 @@ void SatellitesArrayParam::param_transform_multiply(Geom::Affine const &postmul,
}
void SatellitesArrayParam::addKnotHolderEntities(KnotHolder *knotholder,
- SPDesktop *desktop,
- SPItem *item, bool mirror)
+ SPDesktop *desktop,
+ SPItem *item, bool mirror)
{
for (size_t i = 0; i < _vector.size(); ++i) {
for (size_t j = 0; j < _vector[i].size(); ++j) {
- size_t iPlus = j;
- if (mirror == true) {
- iPlus = j + _vector[i].size();
- }
- if (!_vector[i][j].active) {
+ if (!_vector[i][j].has_mirror && mirror) {
continue;
}
- if (!_vector[i][j].has_mirror && mirror == true) {
- continue;
+ SatelliteType type = _vector[i][j].satellite_type;
+ size_t index = i;
+ size_t subindex = j;
+ if (mirror) {
+ subindex = subindex + _vector[i].size();
}
using namespace Geom;
- SatelliteType type = _vector[i][j].satellite_type;
- //IF is for filletChamfer effect...
+ //If is for filletChamfer effect...
if (_effectType == FILLET_CHAMFER) {
const gchar *tip;
if (type == CHAMFER) {
@@ -245,15 +244,13 @@ void SatellitesArrayParam::addKnotHolderEntities(KnotHolder *knotholder,
"<b>Shift+Click</b> open dialog, "
"<b>Ctrl+Alt+Click</b> reset");
}
- FilletChamferKnotHolderEntity *e =
- new FilletChamferKnotHolderEntity(this, i, iPlus);
- e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _(tip),
- _knot_shape, _knot_mode, _knot_color);
+ FilletChamferKnotHolderEntity *e = new FilletChamferKnotHolderEntity(this, index, subindex);
+ e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _(tip),_knot_shape, _knot_mode, _knot_color);
knotholder->add(e);
}
}
}
- if (mirror == true) {
+ if (mirror) {
addKnotHolderEntities(knotholder, desktop, item, false);
}
}
@@ -279,7 +276,7 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p,
if (_subindex >= _pparam->_vector[_index].size()) {
subindex = _subindex - _pparam->_vector[_index].size();
}
- if (!valid_index(subindex)) {
+ if (!valid_index(_index)) {
return;
}
@@ -287,39 +284,39 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p,
return;
}
- Satellite satellite = _pparam->_vector[_index].at(subindex);
- if (!satellite.active || satellite.hidden) {
+ Satellite satellite = _pparam->_vector[_index][subindex];
+ if (satellite.hidden) {
return;
}
Pointwise *pointwise = _pparam->_last_pointwise;
- Geom::PathVector pathv = pparam->_last_pointwise->getPV();
- if (_subindex >= _pparam->_vector[_index].size() ) {
+ Geom::PathVector pathv = pointwise->getPV();
+ if (subindex != _subindex) {
boost::optional<size_t> curve_prev_index = boost::none;
- if(_subindex == 0 && pathv[_index].closed()){
- curve_prev_index = pathv[pathv[_index].size() - 1];
- } else if(!pathv[_index].closed() || _subindex != 0) {
- curve_prev_index = _subindex - 1;
+ if(subindex == 0 && pathv[_index].closed()){
+ curve_prev_index = pathv[_index].size() - 1;
+ } else if(!pathv[_index].closed() || subindex != 0) {
+ curve_prev_index = subindex - 1;
}
if (curve_prev_index) {
Geom::Curve const &curve_in = pathv[_index][*curve_prev_index];
double mirror_time = Geom::nearest_time(s, curve_in);
double time_start = 0;
- Satellites sats = pointwise->getSatellites();
- time_start = sats[_index][*curve_prev_index].time(curve_in);
+ Satellites satellites = pointwise->getSatellites();
+ time_start = satellites[_index][*curve_prev_index].time(curve_in);
if (time_start > mirror_time) {
mirror_time = time_start;
}
double size = arcLengthAt(mirror_time, curve_in);
double amount = curve_in.length() - size;
if (satellite.is_time) {
- amount = timeAtArcLength(amount, pathv[_index][);
+ amount = timeAtArcLength(amount, pathv[_index][subindex]);
}
satellite.amount = amount;
}
} else {
- satellite.setPosition(s, pathv[_index]);
+ satellite.setPosition(s, pathv[_index][subindex]);
}
- _pparam->_vector[_index][_subindex] = satellite;
+ _pparam->_vector[_index][subindex] = satellite;
SPLPEItem *splpeitem = dynamic_cast<SPLPEItem *>(item);
if (splpeitem) {
sp_lpe_item_update_patheffect(splpeitem, false, false);
@@ -333,33 +330,41 @@ Geom::Point FilletChamferKnotHolderEntity::knot_get() const
if (_subindex >= _pparam->_vector[_index].size()) {
subindex = _subindex - _pparam->_vector[_index].size();
}
- if (!valid_index(_subindex)) {
+ if (!valid_index(_index)) {
return Geom::Point(Geom::infinity(), Geom::infinity());
}
- Satellite satellite = _pparam->_vector[_index][_subindex];
- if (!_pparam->_last_pointwise) {
+ Satellite satellite = _pparam->_vector[_index][subindex];
+ Pointwise *pointwise = _pparam->_last_pointwise;
+ if (!pointwise) {
return Geom::Point(Geom::infinity(), Geom::infinity());
}
- if (!satellite.active || satellite.hidden) {
+ Geom::PathVector pathv = pointwise->getPV();
+ if (pathv[_index].size() <= subindex){ //We know this path is open and is last satellite. Hide it
+ _pparam->_vector[_index][subindex].hidden = true;
return Geom::Point(Geom::infinity(), Geom::infinity());
}
- Pointwise *pointwise = _pparam->_last_pointwise;
- Geom::PathVector pathv = pparam->_last_pointwise->getPV();
- if (pathv[_index].size() <= subindex) {
+ if (!pathv[_index].closed() && subindex == 0){ //Path is open hide first satellite
+ _pparam->_vector[_index][subindex].hidden = true;
+ return Geom::Point(Geom::infinity(), Geom::infinity());
+ }
+ if (satellite.hidden) {
+ return Geom::Point(Geom::infinity(), Geom::infinity());
+ }
+ if (subindex != _subindex && !_pparam->_vector[_index][subindex].has_mirror) {
return Geom::Point(Geom::infinity(), Geom::infinity());
}
this->knot->show();
- if (_subindex >= _pparam->_vector[index].size()) {
- tmp_point = satellite.getPosition(pathv[_index][_subindex]);
+ if (subindex != _subindex) {
+ tmp_point = satellite.getPosition(pathv[_index][subindex]);
boost::optional<size_t> curve_prev_index = boost::none;
- if(_subindex == 0 && pathv[_index].closed()){
- curve_prev_index = pathv[pathv[_index].size() - 1];
- } else if(!pathv[_index].closed() || _subindex != 0) {
- curve_prev_index = _subindex - 1;
+ if(subindex == 0 && pathv[_index].closed()){
+ curve_prev_index = pathv[_index].size() - 1;
+ } else if(!pathv[_index].closed() || subindex != 0) {
+ curve_prev_index = subindex - 1;
}
if (curve_prev_index) {
Geom::Curve const &curve_in = pathv[_index][*curve_prev_index];
- double s = satellite.arcDistance(pathv[_index][_subindex]);
+ double s = satellite.arcDistance(pathv[_index][subindex]);
double t = satellite.time(s, true, curve_in);
if (t > 1) {
t = 1;
@@ -375,7 +380,7 @@ Geom::Point FilletChamferKnotHolderEntity::knot_get() const
tmp_point = (curve_in).pointAt(t);
}
} else {
- tmp_point = satellite.getPosition(pathv[_index][_subindex]);
+ tmp_point = satellite.getPosition(pathv[_index][subindex]);
}
Geom::Point const canvas_point = tmp_point;
return canvas_point;
@@ -386,19 +391,18 @@ void FilletChamferKnotHolderEntity::knot_click(guint state)
if (!_pparam->_last_pointwise) {
return;
}
-
size_t subindex = _subindex;
if (_subindex >= _pparam->_vector[_index].size()) {
subindex = _subindex - _pparam->_vector[_index].size();
}
if (state & GDK_CONTROL_MASK) {
if (state & GDK_MOD1_MASK) {
- _pparam->_vector[_index][_subindex].amount = 0.0;
+ _pparam->_vector[_index][subindex].amount = 0.0;
_pparam->param_set_and_write_new_value(_pparam->_vector);
sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false);
} else {
using namespace Geom;
- SatelliteType type = _pparam->_vector[_index][_subindex].satellite_type;
+ SatelliteType type = _pparam->_vector[_index][subindex].satellite_type;
switch (type) {
case FILLET:
type = INVERSE_FILLET;
@@ -438,13 +442,13 @@ void FilletChamferKnotHolderEntity::knot_click(guint state)
this->knot->show();
}
} else if (state & GDK_SHIFT_MASK) {
- Geom::PathVector pathv = pparam->_last_pointwise->getPV();
- double amount = _pparam->_vector[_index][_subindex].amount;
+ Geom::PathVector pathv = _pparam->_last_pointwise->getPV();
+ double amount = _pparam->_vector[_index][subindex].amount;
boost::optional<size_t> curve_prev_index = boost::none;
- if(_subindex == 0 && pathv[_index].closed()){
- curve_prev_index = pathv[pathv[_index].size() - 1];
- } else if(!pathv[_index].closed() || _subindex != 0) {
- curve_prev_index = _subindex - 1;
+ if(subindex == 0 && pathv[_index].closed()){
+ curve_prev_index = pathv[_index].size() - 1;
+ } else if(!pathv[_index].closed() || subindex != 0) {
+ curve_prev_index = subindex - 1;
}
if (!_pparam->_use_distance && !_pparam->_vector[_index][subindex].is_time) {
if (curve_prev_index) {
@@ -454,10 +458,9 @@ void FilletChamferKnotHolderEntity::knot_click(guint state)
}
}
bool aprox = false;
- Geom::D2<Geom::SBasis> d2_out = _pparam->_last_pointwise->getPwd2()[_index][subindex];
+ Geom::D2<Geom::SBasis> d2_out = pathv[_index][subindex].toSBasis();
if (curve_prev_index) {
- Geom::D2<Geom::SBasis> d2_in =
- _pparam->_last_pointwise->getPwd2()[_index][*curve_prev_index];
+ Geom::D2<Geom::SBasis> d2_in = pathv[_index][*curve_prev_index].toSBasis();
aprox = ((d2_in)[0].degreesOfFreedom() != 2 ||
d2_out[0].degreesOfFreedom() != 2) &&
!_pparam->_use_distance
@@ -483,17 +486,16 @@ void FilletChamferKnotHolderEntity::knot_set_offset(Satellite satellite)
double amount = satellite.amount;
double max_amount = amount;
if (!_pparam->_use_distance && !satellite.is_time) {
- Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = _pparam->_last_pointwise->getPwd2();
- Geom::PathVector pathv = path_from_piecewise(Geom::remove_short_cuts(pwd2,0.01),0.01);
- Geom::Path sat_path = pathv.pathAt(index);
+ Pointwise *pointwise = _pparam->_last_pointwise;
+ Geom::PathVector pathv = pointwise->getPV();
boost::optional<size_t> curve_prev_index = boost::none;
- if(_subindex == 0 && pathv[_index].closed()){
- curve_prev_index = pathv[pathv[_index].size() - 1];
- } else if(!pathv[_index].closed() || _subindex != 0) {
- curve_prev_index = _subindex - 1;
+ if(subindex == 0 && pathv[_index].closed()){
+ curve_prev_index = pathv[_index].size() - 1;
+ } else if(!pathv[_index].closed() || subindex != 0) {
+ curve_prev_index = subindex - 1;
}
if (curve_prev_index) {
- amount = _pparam->_vector[_index][subindex].radToLen(amount, pathv[_index][*prev], pathv[_index][subindex]);
+ amount = _pparam->_vector[_index][subindex].radToLen(amount, pathv[_index][*curve_prev_index], pathv[_index][subindex]);
} else {
amount = 0.0;
}
diff --git a/src/live_effects/parameter/satellitesarray.h b/src/live_effects/parameter/satellitesarray.h
index db3776ba3..9a9ec4a88 100644
--- a/src/live_effects/parameter/satellitesarray.h
+++ b/src/live_effects/parameter/satellitesarray.h
@@ -30,7 +30,7 @@ namespace LivePathEffect {
class FilletChamferKnotHolderEntity;
-class SatellitesArrayParam : public ArrayArrayParam<Satellite> {
+class SatellitesArrayParam : public ArrayParam<std::vector<Satellite> > {
public:
SatellitesArrayParam(const Glib::ustring &label, const Glib::ustring &tip,
const Glib::ustring &key,
diff --git a/src/ui/dialog/lpe-fillet-chamfer-properties.h b/src/ui/dialog/lpe-fillet-chamfer-properties.h
index f982db286..105cafe68 100644
--- a/src/ui/dialog/lpe-fillet-chamfer-properties.h
+++ b/src/ui/dialog/lpe-fillet-chamfer-properties.h
@@ -10,7 +10,7 @@
#include <2geom/point.h>
#include <gtkmm.h>
-#include "live_effects/parameter/satellitearray.h"
+#include "live_effects/parameter/satellitesarray.h"
class SPDesktop;