summaryrefslogtreecommitdiffstats
path: root/src/live_effects
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-03-22 17:27:17 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-03-22 17:27:17 +0000
commit8bd246d8b59749e15de4d5d0d78e9b82fa8a601a (patch)
tree5f9792fbade2d276210c43a904d59d7e7a689681 /src/live_effects
parentupdate to trunk (diff)
downloadinkscape-8bd246d8b59749e15de4d5d0d78e9b82fa8a601a.tar.gz
inkscape-8bd246d8b59749e15de4d5d0d78e9b82fa8a601a.zip
Fixed bug when deleting nodes
(bzr r13645.1.51)
Diffstat (limited to 'src/live_effects')
-rw-r--r--src/live_effects/lpe-fillet-chamfer.cpp56
-rw-r--r--src/live_effects/parameter/array.cpp10
-rw-r--r--src/live_effects/parameter/array.h4
-rw-r--r--src/live_effects/parameter/satellitepairarray.cpp37
-rw-r--r--src/live_effects/parameter/satellitepairarray.h8
5 files changed, 60 insertions, 55 deletions
diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp
index 93c21469a..6b388b0f6 100644
--- a/src/live_effects/lpe-fillet-chamfer.cpp
+++ b/src/live_effects/lpe-fillet-chamfer.cpp
@@ -51,7 +51,7 @@ LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject) :
unit(_("Unit:"), _("Unit"), "unit", &wr, this),
method(_("Method:"), _("Fillets methods"), "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, 3),
+ 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),
@@ -97,7 +97,7 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem)
Piecewise<D2<SBasis> > pwd2_in = paths_to_pw(original_pathv);
pwd2_in = remove_short_cuts(pwd2_in, 0.01);
int counterTotal = 0;
- std::vector<std::pair<unsigned int,Geom::Satellite> > satellites;
+ std::vector<std::pair<size_t,Geom::Satellite> > satellites;
for (PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) {
if (path_it->empty()){
continue;
@@ -119,7 +119,7 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem)
Geom::Path::const_iterator curve_end = curve_endit;
--curve_end;
int counter = 0;
- unsigned int steps = chamfer_steps;
+ size_t steps = chamfer_steps;
while (curve_it1 != curve_endit) {
if((*curve_it1).isDegenerate() || (*curve_it1).isDegenerate()){
g_warning("LPE Fillet not handle degenerate curves.");
@@ -274,9 +274,9 @@ void LPEFilletChamfer::updateAmount()
} else {
power = radius/100;
}
- std::vector<std::pair<unsigned int,Geom::Satellite> > satellites = pointwise->getSatellites();
+ std::vector<std::pair<size_t,Geom::Satellite> > satellites = pointwise->getSatellites();
Piecewise<D2<SBasis> > pwd2 = pointwise->getPwd2();
- for (std::vector<std::pair<unsigned int,Geom::Satellite> >::iterator it = satellites.begin(); it != satellites.end(); ++it) {
+ for (std::vector<std::pair<size_t,Geom::Satellite> >::iterator it = satellites.begin(); it != satellites.end(); ++it) {
if(!pointwise->getIsClosed(it->first) && pointwise->getFirst(it->first) == it->first){
it->second.setAmount(0);
continue;
@@ -311,9 +311,9 @@ void LPEFilletChamfer::updateAmount()
void LPEFilletChamfer::updateChamferSteps()
{
- std::vector<std::pair<unsigned int,Geom::Satellite> > satellites = pointwise->getSatellites();
+ std::vector<std::pair<size_t,Geom::Satellite> > satellites = pointwise->getSatellites();
Piecewise<D2<SBasis> > pwd2 = pointwise->getPwd2();
- for (std::vector<std::pair<unsigned int,Geom::Satellite> >::iterator it = satellites.begin(); it != satellites.end(); ++it) {
+ for (std::vector<std::pair<size_t,Geom::Satellite> >::iterator it = satellites.begin(); it != satellites.end(); ++it) {
if(ignore_radius_0 && it->second.getAmount() == 0){
continue;
}
@@ -332,9 +332,9 @@ void LPEFilletChamfer::updateChamferSteps()
void LPEFilletChamfer::updateSatelliteType(Geom::SatelliteType satellitetype)
{
- std::vector<std::pair<unsigned int,Geom::Satellite> > satellites = pointwise->getSatellites();
+ std::vector<std::pair<size_t,Geom::Satellite> > satellites = pointwise->getSatellites();
Piecewise<D2<SBasis> > pwd2 = pointwise->getPwd2();
- for (std::vector<std::pair<unsigned int,Geom::Satellite> >::iterator it = satellites.begin(); it != satellites.end(); ++it) {
+ for (std::vector<std::pair<size_t,Geom::Satellite> >::iterator it = satellites.begin(); it != satellites.end(); ++it) {
if(ignore_radius_0 && it->second.getAmount() == 0){
continue;
}
@@ -371,12 +371,8 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem)
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<std::pair<unsigned int,Geom::Satellite> > sats;
- if(!pointwise){
- sats = satellitepairarrayparam_values.data();
- } else {
- sats = pointwise->getSatellites();
- }
+ std::vector<std::pair<size_t,Geom::Satellite> > sats = satellitepairarrayparam_values.data();
+
//optional call
if(hide_knots){
satellitepairarrayparam_values.set_helper_size(0);
@@ -384,6 +380,7 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem)
satellitepairarrayparam_values.set_helper_size(helper_size);
}
bool refresh = false;
+ bool hide = true;
for(unsigned i = 0; i < sats.size(); i++){
if(sats[i].second.getIsTime() != flexible){
sats[i].second.setIsTime(flexible);
@@ -401,13 +398,17 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem)
sats[i].second.setHasMirror(mirror_knots);
refresh = true;
}
- if(sats[i].second.getHidden() != hide_knots){
- sats[i].second.setHidden(hide_knots);
- refresh = true;
+ if(sats[i].second.getHidden() == false){
+ hide = false;
}
+ sats[i].second.setHidden(hide_knots);
+ }
+ if(hide != hide_knots){
+ refresh = true;
}
pointwise = new Pointwise(pwd2_in, sats);
//mandatory call
+ pointwise->set_extremes(false, false, true);
satellitepairarrayparam_values.set_pointwise(pointwise);
if(refresh){
refreshKnots();
@@ -421,8 +422,9 @@ void
LPEFilletChamfer::adjustForNewPath(std::vector<Geom::Path> const &path_in)
{
if (!path_in.empty() && pointwise) {
- pointwise->recalculate_for_new_pwd2(paths_to_pw(pathv_to_linear_and_cubic_beziers(path_in)));
- pointwise->set_extremes(false,true,0.0,0.0);
+ pointwise->recalculate_for_new_pwd2(remove_short_cuts(paths_to_pw(pathv_to_linear_and_cubic_beziers(path_in)),0.01));
+ pointwise->set_extremes(true, false, true, 0.0, 0.0);
+ satellitepairarrayparam_values.set_pointwise(pointwise);
}
}
@@ -431,7 +433,7 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in)
{
const double gapHelper = 0.00001;
std::vector<Geom::Path> pathvector_out;
- unsigned int counter = 0;
+ 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);
for (PathVector::const_iterator path_it = path_in_processed.begin();
@@ -462,15 +464,15 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in)
curve_endit = path_it->end_open();
}
}
- unsigned int counterCurves = 0;
- unsigned int first = counter;
+ size_t counterCurves = 0;
+ size_t first = counter;
double time0 = 0;
while (curve_it1 != curve_endit) {
if((*curve_it1).isDegenerate() || (*curve_it1).isDegenerate()){
g_warning("LPE Fillet not handle degenerate curves.");
return path_in;
}
- std::vector<unsigned int> satIndexes;
+ std::vector<size_t> satIndexes;
Satellite satellite;
Curve *curve_it2Fixed = path_it->begin()->duplicate();
if(!path_it->closed()){
@@ -602,7 +604,7 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in)
}
}
SatelliteType type = satellite.getSatelliteType();
- unsigned int steps = satellite.getSteps();
+ size_t steps = satellite.getSteps();
if(steps < 1){
steps = 1;
}
@@ -615,7 +617,7 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in)
path_chamfer.appendNew<Geom::CubicBezier>(handle1, handle2, endArcPoint);
}
double chamfer_stepsTime = 1.0/steps;
- for(unsigned int i = 1; i < steps; i++){
+ for(size_t i = 1; i < steps; i++){
Geom::Point chamferStep = path_chamfer.pointAt(chamfer_stepsTime * i);
path_out.appendNew<Geom::LineSegment>(chamferStep);
}
@@ -630,7 +632,7 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in)
path_chamfer.appendNew<Geom::CubicBezier>(inverseHandle1, inverseHandle2, endArcPoint);
}
double chamfer_stepsTime = 1.0/steps;
- for(unsigned int i = 1; i < steps; i++){
+ for(size_t i = 1; i < steps; i++){
Geom::Point chamferStep = path_chamfer.pointAt(chamfer_stepsTime * i);
path_out.appendNew<Geom::LineSegment>(chamferStep);
}
diff --git a/src/live_effects/parameter/array.cpp b/src/live_effects/parameter/array.cpp
index d8b2388da..33cb53f4e 100644
--- a/src/live_effects/parameter/array.cpp
+++ b/src/live_effects/parameter/array.cpp
@@ -78,20 +78,20 @@ sp_svg_satellite_read_d(gchar const *str, Geom::Satellite *sat){
}
template <>
-std::pair<unsigned int, Geom::Satellite>
-ArrayParam<std::pair<unsigned int, Geom::Satellite> >::readsvg(const gchar * str)
+std::pair<size_t, Geom::Satellite>
+ArrayParam<std::pair<size_t, Geom::Satellite> >::readsvg(const gchar * str)
{
gchar ** strarray = g_strsplit(str, ",", 2);
double index;
- std::pair<unsigned int, Geom::Satellite> result;
+ std::pair<size_t, Geom::Satellite> result;
unsigned int success = (int)sp_svg_number_read_d(strarray[0], &index);
Geom::Satellite sat;
success += sp_svg_satellite_read_d(strarray[1], &sat);
g_strfreev (strarray);
if (success == 2) {
- return std::make_pair(index, sat);
+ return std::make_pair((size_t)index, sat);
}
- return std::make_pair((int)Geom::infinity(),sat);
+ return std::make_pair((size_t)0,sat);
}
} /* namespace LivePathEffect */
diff --git a/src/live_effects/parameter/array.h b/src/live_effects/parameter/array.h
index 7ff477ffb..4fb053dbb 100644
--- a/src/live_effects/parameter/array.h
+++ b/src/live_effects/parameter/array.h
@@ -90,7 +90,7 @@ protected:
size_t _default_size;
void writesvg(SVGOStringStream &str, std::vector<StorageType> const &vector) const {
- for (unsigned int i = 0; i < vector.size(); ++i) {
+ for (size_t i = 0; i < vector.size(); ++i) {
if (i != 0) {
// separate items with pipe symbol
str << " | ";
@@ -111,7 +111,7 @@ protected:
str << nVector;
}
- void writesvgData(SVGOStringStream &str, std::pair<unsigned int, Geom::Satellite> const &nVector) const {
+ void writesvgData(SVGOStringStream &str, std::pair<size_t, Geom::Satellite> const &nVector) const {
str << nVector.first;
str << ",";
str << nVector.second.getSatelliteTypeGchar();
diff --git a/src/live_effects/parameter/satellitepairarray.cpp b/src/live_effects/parameter/satellitepairarray.cpp
index 47f023c29..8102edf9b 100644
--- a/src/live_effects/parameter/satellitepairarray.cpp
+++ b/src/live_effects/parameter/satellitepairarray.cpp
@@ -11,6 +11,7 @@
#include "knotholder.h"
#include "ui/dialog/lpe-fillet-chamfer-properties.h"
#include "live_effects/parameter/satellitepairarray.h"
+#include "live_effects/effect.h"
#include "sp-lpe-item.h"
// TODO due to internal breakage in glibmm headers,
// this has to be included last.
@@ -27,7 +28,7 @@ SatellitePairArrayParam::SatellitePairArrayParam(
const Glib::ustring &label, const Glib::ustring &tip,
const Glib::ustring &key, Inkscape::UI::Widget::Registry *wr,
Effect *effect)
- : ArrayParam<std::pair<unsigned int,Geom::Satellite> >(label, tip, key, wr, effect, 0)
+ : ArrayParam<std::pair<size_t,Geom::Satellite> >(label, tip, key, wr, effect, 0)
{
knot_shape = SP_KNOT_SHAPE_DIAMOND;
knot_mode = SP_KNOT_MODE_XOR;
@@ -90,7 +91,7 @@ void SatellitePairArrayParam::updateCanvasIndicators(bool mirror)
if( mirror == true){
hp.clear();
}
- for (unsigned int i = 0; i < _vector.size(); ++i) {
+ for (size_t i = 0; i < _vector.size(); ++i) {
if(!_vector[i].second.getActive() || _vector[i].second.getHidden()){
continue;
}
@@ -106,7 +107,7 @@ void SatellitePairArrayParam::updateCanvasIndicators(bool mirror)
double size_out = _vector[i].second.getSize(pwd2[_vector[i].first]);
double lenght_out = Geom::length(pwd2[_vector[i].first], Geom::EPSILON);
double lenght_in = 0;
- boost::optional<unsigned int> d2_prev_index = last_pointwise->getPrevious(_vector[i].first);
+ boost::optional<size_t> d2_prev_index = last_pointwise->getPrevious(_vector[i].first);
if(d2_prev_index){
lenght_in = Geom::length(pwd2[*d2_prev_index], Geom::EPSILON);
}
@@ -191,8 +192,7 @@ void SatellitePairArrayParam::addCanvasIndicators(
void SatellitePairArrayParam::recalculate_knots()
{
if(last_pointwise){
- _vector = last_pointwise->getSatellites();
- write_to_SVG();
+ //_vector = last_pointwise->getSatellites();
}
}
@@ -202,8 +202,8 @@ void SatellitePairArrayParam::addKnotHolderEntities(KnotHolder *knotholder,
bool mirror)
{
recalculate_knots();
- for (unsigned int i = 0; i < _vector.size(); ++i) {
- int iPlus = i;
+ for (size_t i = 0; i < _vector.size(); ++i) {
+ size_t iPlus = i;
if( mirror == true){
iPlus = i + _vector.size();
}
@@ -254,7 +254,7 @@ void SatellitePairArrayParam::addKnotHolderEntities(KnotHolder *knotholder,
addKnotHolderEntities(knotholder, desktop, item, true);
}
-FilletChamferKnotHolderEntity::FilletChamferKnotHolderEntity(SatellitePairArrayParam *p, unsigned int index)
+FilletChamferKnotHolderEntity::FilletChamferKnotHolderEntity(SatellitePairArrayParam *p, size_t index)
: _pparam(p),
_index(index)
{
@@ -267,7 +267,7 @@ void FilletChamferKnotHolderEntity::knot_set(Point const &p,
guint state)
{
Geom::Point s = snap_knot_position(p, state);
- int index = _index;
+ size_t index = _index;
if( _index >= _pparam->_vector.size()){
index = _index-_pparam->_vector.size();
}
@@ -286,12 +286,12 @@ void FilletChamferKnotHolderEntity::knot_set(Point const &p,
Geom::Pointwise* pointwise = _pparam->last_pointwise;
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = pointwise->getPwd2();
if(_pparam->_vector.size() <= _index){
- boost::optional<unsigned int> d2_prev_index = pointwise->getPrevious(satellite.first);
+ boost::optional<size_t> d2_prev_index = pointwise->getPrevious(satellite.first);
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;
- std::vector<unsigned int> satIndexes = pointwise->findPeviousSatellites(satellite.first,1);
+ std::vector<size_t> satIndexes = pointwise->findPeviousSatellites(satellite.first,1);
if(satIndexes.size()>0){
timeStart = pointwise->getSatellites()[satIndexes[0]].second.getTime(d2_in);
}
@@ -319,7 +319,7 @@ Geom::Point
FilletChamferKnotHolderEntity::knot_get() const
{
Geom::Point tmpPoint;
- int index = _index;
+ size_t index = _index;
if( _index >= _pparam->_vector.size()){
index = _index-_pparam->_vector.size();
}
@@ -335,9 +335,12 @@ FilletChamferKnotHolderEntity::knot_get() const
}
Geom::Pointwise* pointwise = _pparam->last_pointwise;
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = pointwise->getPwd2();
+ if(pwd2.size() <= (unsigned)satellite.first){
+ return Point(infinity(), infinity());
+ }
if( _index >= _pparam->_vector.size()){
tmpPoint = satellite.second.getPosition(pwd2[satellite.first]);
- boost::optional<unsigned int> d2_prev_index = pointwise->getPrevious(satellite.first);
+ boost::optional<size_t> d2_prev_index = pointwise->getPrevious(satellite.first);
if(d2_prev_index){
Geom::D2<Geom::SBasis> d2_in = pwd2[*d2_prev_index];
double s = satellite.second.getSize(pwd2[satellite.first]);
@@ -349,7 +352,7 @@ FilletChamferKnotHolderEntity::knot_get() const
t = 0;
}
double timeStart = 0;
- std::vector<unsigned int> satIndexes = pointwise->findPeviousSatellites(satellite.first,1);
+ std::vector<size_t> satIndexes = pointwise->findPeviousSatellites(satellite.first,1);
if(satIndexes.size()>0){
timeStart = pointwise->getSatellites()[satIndexes[0]].second.getTime(d2_in);
}
@@ -371,7 +374,7 @@ void FilletChamferKnotHolderEntity::knot_click(guint state)
return;
}
- int index = _index;
+ size_t index = _index;
if( _index >= _pparam->_vector.size()){
index = _index-_pparam->_vector.size();
}
@@ -428,7 +431,7 @@ void FilletChamferKnotHolderEntity::knot_click(guint state)
}
bool aprox = false;
D2<SBasis> d2_out = _pparam->last_pointwise->getPwd2()[index];
- boost::optional<unsigned int> d2_prev_index = _pparam->last_pointwise->getPrevious(_pparam->_vector.at(index).first);
+ boost::optional<size_t> d2_prev_index = _pparam->last_pointwise->getPrevious(_pparam->_vector.at(index).first);
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;
@@ -444,7 +447,7 @@ void FilletChamferKnotHolderEntity::knot_set_offset(Geom::Satellite satellite)
if( !_pparam->last_pointwise){
return;
}
- int index = _index;
+ size_t index = _index;
if( _index >= _pparam->_vector.size()){
index = _index-_pparam->_vector.size();
}
diff --git a/src/live_effects/parameter/satellitepairarray.h b/src/live_effects/parameter/satellitepairarray.h
index 9b22a386b..a85e3f83f 100644
--- a/src/live_effects/parameter/satellitepairarray.h
+++ b/src/live_effects/parameter/satellitepairarray.h
@@ -30,7 +30,7 @@ namespace LivePathEffect {
class FilletChamferKnotHolderEntity;
-class SatellitePairArrayParam : public ArrayParam<std::pair<unsigned int, Geom::Satellite> > {
+class SatellitePairArrayParam : public ArrayParam<std::pair<size_t, Geom::Satellite> > {
public:
SatellitePairArrayParam(const Glib::ustring &label,
const Glib::ustring &tip,
@@ -81,7 +81,7 @@ private:
class FilletChamferKnotHolderEntity : public KnotHolderEntity {
public:
- FilletChamferKnotHolderEntity(SatellitePairArrayParam *p, unsigned int index);
+ FilletChamferKnotHolderEntity(SatellitePairArrayParam *p, size_t index);
virtual ~FilletChamferKnotHolderEntity() {}
virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state);
@@ -89,13 +89,13 @@ public:
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(unsigned int index) const {
+ bool valid_index(size_t index) const {
return (_pparam->_vector.size() > index);
};
private:
SatellitePairArrayParam *_pparam;
- unsigned int _index;
+ size_t _index;
};
} //namespace LivePathEffect