summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2016-05-26 17:37:15 +0000
committerjabiertxof <info@marker.es>2016-05-26 17:37:15 +0000
commit8d35486a82d04a28dc9f297147ad4666b34cde4a (patch)
tree429b621d00a1f1ce71846a0255b119aecebb6a31 /src
parentupdate to trunk (diff)
downloadinkscape-8d35486a82d04a28dc9f297147ad4666b34cde4a.tar.gz
inkscape-8d35486a82d04a28dc9f297147ad4666b34cde4a.zip
Fixing pointwise
(bzr r13645.1.143)
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/lpe-fillet-chamfer.cpp39
-rw-r--r--src/live_effects/parameter/satellitesarray.cpp56
-rw-r--r--src/live_effects/parameter/satellitesarray.h4
-rw-r--r--src/ui/tool/path-manipulator.cpp1
4 files changed, 48 insertions, 52 deletions
diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp
index a291776b7..6ec711de7 100644
--- a/src/live_effects/lpe-fillet-chamfer.cpp
+++ b/src/live_effects/lpe-fillet-chamfer.cpp
@@ -367,9 +367,21 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem)
satellites_param.setUseDistance(use_knot_distance);
//mandatory call
satellites_param.setEffectType(effectType());
- satellites_param.setPathUpdate(false);
-
Geom::PathVector const pathv = pathv_to_linear_and_cubic_beziers(c->get_pathvector());
+ //if are diferent sizes call to poinwise recalculate
+ //TODO: Update the satellite data in paths modified, Goal 0.93
+ size_t number_nodes = pathv.nodes().size();
+ size_t satellites_counter = pointwise.getTotalSatellites();
+ if (satellites_counter != 0 && number_nodes != satellites_counter) {
+ Satellite satellite(FILLET);
+ satellite.setIsTime(flexible);
+ satellite.setHasMirror(mirror_knots);
+ satellite.setHidden(hide_knots);
+ pointwise.recalculateForNewPathVector(pathv, satellite);
+ satellites_param.setPointwise(pointwise);
+ refreshKnots();
+ return;
+ }
Satellites satellites = satellites_param.data();
if(satellites.empty()) {
doOnApply(lpeItem);
@@ -380,7 +392,6 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem)
} else {
satellites_param.setHelperSize(helper_size);
}
- 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) {
@@ -404,25 +415,11 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem)
satellites[i][j].hidden = hide_knots;
}
}
- //if are diferent sizes call to poinwise recalculate
- //TODO: Update the satellite data in paths modified, Goal 0.93
- size_t satellites_counter = pointwise.getTotalSatellites();
- if (satellites_counter != 0 ){
- std::cout << number_nodes << "aaaaa" << pointwise.getTotalSatellites() << "\n";
- }
- if (satellites_counter != 0 && number_nodes != satellites_counter) {
- satellites_param.setPathUpdate(true);
- Satellite satellite(satellites[0][0].satellite_type);
- satellite.setIsTime(satellites[0][0].is_time);
- satellite.setHasMirror(mirror_knots);
- satellite.setHidden(hide_knots);
- pointwise.recalculateForNewPathVector(pathv, satellite);
- } else {
- pointwise.setPathVector(pathv);
- pointwise.setSatellites(satellites);
- }
- refreshKnots();
+
+ pointwise.setPathVector(pathv);
+ pointwise.setSatellites(satellites);
satellites_param.setPointwise(pointwise);
+ refreshKnots();
} else {
g_warning("LPE Fillet can only be applied to shapes (not groups).");
}
diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp
index 14660acc4..78f1a945f 100644
--- a/src/live_effects/parameter/satellitesarray.cpp
+++ b/src/live_effects/parameter/satellitesarray.cpp
@@ -61,26 +61,25 @@ void SatellitesArrayParam::setEffectType(EffectType et)
_effectType = et;
}
-void SatellitesArrayParam::setPathUpdate(bool path_update)
-{
- _path_update = path_update;
-}
-
void SatellitesArrayParam::setHelperSize(int hs)
{
_helper_size = hs;
updateCanvasIndicators();
}
-bool SatellitesArrayParam::validData()
+bool SatellitesArrayParam::validData(size_t index,size_t subindex)
{
- if (_path_update) { return false;}
- return _last_pointwise.getPathVector().nodes().size() == _last_pointwise.getTotalSatellites();
+ if(!_last_pointwise.getPathVector().size() > index){
+ return false;
+ }
+ if(!_last_pointwise.getPathVector()[index].size_closed() > subindex){
+ return false;
+ }
+ return true; //_last_pointwise.getPathVector().nodes().size() == _last_pointwise.getTotalSatellites();
}
+
void SatellitesArrayParam::updateCanvasIndicators(bool mirror)
{
- if (!validData()) {
- return;
- }
+
if(!_hp.empty()) {
_hp.clear();
}
@@ -94,6 +93,9 @@ void SatellitesArrayParam::updateCanvasIndicators(bool mirror)
if (_effectType == FILLET_CHAMFER) {
for (size_t i = 0; i < _vector.size(); ++i) {
for (size_t j = 0; j < _vector[i].size(); ++j) {
+ if (!validData(i, j)) {
+ return;
+ }
if (_vector[i][j].hidden || //Ignore if hidden
(!_vector[i][j].has_mirror && mirror == true) || //Ignore if not have mirror and we are in mirror loop
_vector[i][j].amount == 0 || //no helper in 0 value
@@ -216,12 +218,12 @@ void SatellitesArrayParam::addKnotHolderEntities(KnotHolder *knotholder,
SPDesktop *desktop,
SPItem *item, bool mirror)
{
- if (!validData()) {
- return;
- }
Geom::PathVector pathv = _last_pointwise.getPathVector();
for (size_t i = 0; i < _vector.size(); ++i) {
for (size_t j = 0; j < _vector[i].size(); ++j) {
+ if (!validData(i, j)) {
+ return;
+ }
if (!_vector[i][j].has_mirror && mirror) {
continue;
}
@@ -282,14 +284,14 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p,
Geom::Point const &/*origin*/,
guint state)
{
- if (! _pparam->validData() || !valid_index(_index)) {
- return;
- }
Geom::Point s = snap_knot_position(p, state);
size_t subindex = _subindex;
if (_subindex >= _pparam->_vector[_index].size()) {
subindex = _subindex - _pparam->_vector[_index].size();
}
+ if (!_pparam->validData(_index, subindex)) {
+ return;
+ }
Satellite satellite = _pparam->_vector[_index][subindex];
Geom::PathVector pathv = _pparam->_last_pointwise.getPathVector();
if (satellite.hidden ||
@@ -329,15 +331,15 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p,
Geom::Point FilletChamferKnotHolderEntity::knot_get() const
{
- if (! _pparam->validData() || !valid_index(_index)) {
- this->knot->hide();
- return Geom::Point(Geom::infinity(), Geom::infinity());
- }
Geom::Point tmp_point;
size_t subindex = _subindex;
if (_subindex >= _pparam->_vector[_index].size()) {
subindex = _subindex - _pparam->_vector[_index].size();
}
+ if (!_pparam->validData(_index, subindex)) {
+ this->knot->hide();
+ return Geom::Point(Geom::infinity(), Geom::infinity());
+ }
Satellite satellite = _pparam->_vector[_index][subindex];
Geom::PathVector pathv = _pparam->_last_pointwise.getPathVector();
if (satellite.hidden ||
@@ -380,13 +382,13 @@ Geom::Point FilletChamferKnotHolderEntity::knot_get() const
void FilletChamferKnotHolderEntity::knot_click(guint state)
{
- if (! _pparam->validData() || !valid_index(_index)) {
- return;
- }
size_t subindex = _subindex;
if (_subindex >= _pparam->_vector[_index].size()) {
subindex = _subindex - _pparam->_vector[_index].size();
}
+ if (!_pparam->validData(_index, subindex)) {
+ return;
+ }
Geom::PathVector pathv = _pparam->_last_pointwise.getPathVector();
if (!pathv[_index].closed() && subindex == 0 ||//ignore first satellites on open paths
pathv[_index].size() == subindex) //ignore last satellite in open paths with fillet chamfer effect
@@ -471,13 +473,13 @@ void FilletChamferKnotHolderEntity::knot_click(guint state)
void FilletChamferKnotHolderEntity::knot_set_offset(Satellite satellite)
{
- if (! _pparam->validData() || !valid_index(_index)) {
- return;
- }
size_t subindex = _subindex;
if (_subindex >= _pparam->_vector[_index].size()) {
subindex = _subindex - _pparam->_vector[_index].size();
}
+ if (!_pparam->validData(_index, subindex)) {
+ return;
+ }
Geom::PathVector pathv = _pparam->_last_pointwise.getPathVector();
if (satellite.hidden ||
!pathv[_index].closed() && subindex == 0 ||//ignore first satellites on open paths
diff --git a/src/live_effects/parameter/satellitesarray.h b/src/live_effects/parameter/satellitesarray.h
index 0cebb9cb4..c6893f595 100644
--- a/src/live_effects/parameter/satellitesarray.h
+++ b/src/live_effects/parameter/satellitesarray.h
@@ -55,10 +55,9 @@ public:
}
void param_transform_multiply(Geom::Affine const &postmul, bool /*set*/);
void setUseDistance(bool use_knot_distance);
- void setPathUpdate(bool path_update);
void setEffectType(EffectType et);
void setPointwise(Pointwise pointwise);
- bool validData();
+ bool validData(size_t index, size_t subindex);
void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color);
friend class FilletChamferKnotHolderEntity;
@@ -77,7 +76,6 @@ private:
Geom::PathVector _hp;
int _helper_size;
bool _use_distance;
- bool _path_update;
EffectType _effectType;
Pointwise _last_pointwise;
diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp
index 9d479432b..0d603ad1f 100644
--- a/src/ui/tool/path-manipulator.cpp
+++ b/src/ui/tool/path-manipulator.cpp
@@ -12,7 +12,6 @@
#include "live_effects/lpe-powerstroke.h"
#include "live_effects/lpe-bspline.h"
-#include "live_effects/lpe-fillet-chamfer.h"
#include <string>
#include <sstream>
#include <deque>