summaryrefslogtreecommitdiffstats
path: root/src/live_effects
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-07-06 10:01:17 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-07-06 10:01:17 +0000
commit936f6512b26120b882a1c68e50968a15002f3af4 (patch)
tree82d18a24db63832d51f5d59544dc9561680fe372 /src/live_effects
parentFix a bug displaying arcs (diff)
downloadinkscape-936f6512b26120b882a1c68e50968a15002f3af4.tar.gz
inkscape-936f6512b26120b882a1c68e50968a15002f3af4.zip
Fixes from branch review
(bzr r13645.1.102)
Diffstat (limited to 'src/live_effects')
-rw-r--r--src/live_effects/lpe-fillet-chamfer.cpp57
-rw-r--r--src/live_effects/lpe-fillet-chamfer.h1
-rw-r--r--src/live_effects/parameter/array.cpp2
-rw-r--r--src/live_effects/parameter/satellitearray.cpp81
-rw-r--r--src/live_effects/parameter/satellitearray.h1
5 files changed, 75 insertions, 67 deletions
diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp
index eb9f82918..7871ccc1e 100644
--- a/src/live_effects/lpe-fillet-chamfer.cpp
+++ b/src/live_effects/lpe-fillet-chamfer.cpp
@@ -13,7 +13,6 @@
#include "display/curve.h"
#include "helper/geom-curves.h"
#include "helper/geom-satellite.h"
-#include "helper/geom-pathinfo.h"
#include <2geom/elliptical-arc.h>
#include "knotholder.h"
#include <boost/optional.hpp>
@@ -81,8 +80,6 @@ LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject)
helper_size.param_set_digits(0);
}
-LPEFilletChamfer::~LPEFilletChamfer() {}
-
void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem)
{
SPLPEItem *splpeitem = const_cast<SPLPEItem *>(lpeItem);
@@ -101,20 +98,6 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem)
}
Geom::Path::const_iterator curve_it1 = path_it->begin();
Geom::Path::const_iterator curve_endit = path_it->end_default();
- if (path_it->closed()) {
- Geom::Curve const &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) {
@@ -142,7 +125,6 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem)
pointwise = new Pointwise();
pointwise->setPwd2(pwd2_in);
pointwise->setSatellites(satellites);
- pointwise->setPathInfo(original_pathv);
pointwise->setStart();
satellites_param.setPointwise(pointwise);
} else {
@@ -281,14 +263,13 @@ void LPEFilletChamfer::updateAmount()
}
std::vector<Satellite> satellites = pointwise->getSatellites();
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = pointwise->getPwd2();
- Pathinfo* path_info = new Pathinfo();
- path_info->set(pwd2);
for (std::vector<Satellite>::iterator it = satellites.begin();
it != satellites.end(); ++it)
{
- if (!path_info->closed(it - satellites.begin()) &&
- path_info->first(it - satellites.begin()) ==
- (unsigned)(it - satellites.begin()))
+ Geom::Path sat_path = pathvector_before_effect.pathAt(it - satellites.begin());
+ size_t sat_curve_time = Geom::nearest_time(pathvector_before_effect.curveAt(it - satellites.begin()).initialPoint() , pwd2);
+ size_t first = Geom::nearest_time(sat_path.initialPoint() , pwd2);
+ if (!sat_path.closed() && sat_curve_time == first)
{
it->amount = 0;
continue;
@@ -296,8 +277,13 @@ void LPEFilletChamfer::updateAmount()
if (ignore_radius_0 && it->amount == 0) {
continue;
}
- boost::optional<size_t> previous =
- path_info->previous(it - satellites.begin());
+ boost::optional<size_t> previous = boost::none;
+ if (sat_path.closed() && sat_curve_time == first){
+ sat_curve_time = Geom::nearest_time(sat_path.initialPoint(),pwd2);
+ previous = sat_curve_time + sat_path.size() - 1;
+ } else if(!sat_path.closed() || sat_curve_time != first){
+ previous = sat_curve_time - 1;
+ }
if (only_selected) {
Geom::Point satellite_point = pwd2.valueAt(it - satellites.begin());
if (isNodePointSelected(satellite_point)) {
@@ -425,13 +411,11 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem)
it->hidden = hide_knots;
++it;
}
- Pathinfo* path_info = new Pathinfo();
- path_info->set(original_pathv);
- size_t number_curves = path_info->size();
+ size_t number_curves = original_pathv.curveCount();
//if are diferent sizes call to poinwise recalculate
- //TODO: fire a reverse satellites on reverse path. Maybe a new method
+ //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
+ //and after convert to Pathvector
if (pointwise && number_curves != sats.size()) {
Satellite sat(sats[0].satellite_type);
sat.setIsTime(sats[0].is_time);
@@ -447,7 +431,6 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem)
pointwise->setPwd2(pwd2_in);
pointwise->setSatellites(sats);
}
- pointwise->setPathInfo(original_pathv);
pointwise->setStart();
satellites_param.setPointwise(pointwise);
refreshKnots();
@@ -488,18 +471,6 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in)
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();
- }
- }
size_t counter_curves = 0;
size_t first = counter;
double time0 = 0;
diff --git a/src/live_effects/lpe-fillet-chamfer.h b/src/live_effects/lpe-fillet-chamfer.h
index d7549d070..804709342 100644
--- a/src/live_effects/lpe-fillet-chamfer.h
+++ b/src/live_effects/lpe-fillet-chamfer.h
@@ -30,7 +30,6 @@ enum FilletMethod {
class LPEFilletChamfer : public Effect {
public:
LPEFilletChamfer(LivePathEffectObject *lpeobject);
- virtual ~LPEFilletChamfer();
virtual void doBeforeEffect(SPLPEItem const *lpeItem);
virtual Geom::PathVector
doEffect_path(Geom::PathVector const &path_in);
diff --git a/src/live_effects/parameter/array.cpp b/src/live_effects/parameter/array.cpp
index 9b326fe32..0abcd4b9b 100644
--- a/src/live_effects/parameter/array.cpp
+++ b/src/live_effects/parameter/array.cpp
@@ -20,7 +20,7 @@ sp_svg_satellite_read_d(gchar const *str, Satellite *sat){
return 0;
}
gchar ** strarray = g_strsplit(str, ",", 8);
- if(strarray[7] && !strarray[8]){
+ if(strlen(str) > 0 && strarray[7] && !strarray[8]){
sat->setSatelliteType(g_strstrip(strarray[0]));
sat->is_time = strncmp(strarray[1],"1",1) == 0;
sat->active = strncmp(strarray[2],"1",1) == 0;
diff --git a/src/live_effects/parameter/satellitearray.cpp b/src/live_effects/parameter/satellitearray.cpp
index 46c7396d0..b7d403a91 100644
--- a/src/live_effects/parameter/satellitearray.cpp
+++ b/src/live_effects/parameter/satellitearray.cpp
@@ -37,8 +37,6 @@ SatelliteArrayParam::SatelliteArrayParam(const Glib::ustring &label,
_last_pointwise = NULL;
}
-SatelliteArrayParam::~SatelliteArrayParam() {}
-
void SatelliteArrayParam::set_oncanvas_looks(SPKnotShapeType shape,
SPKnotModeType mode,
guint32 color)
@@ -76,8 +74,7 @@ void SatelliteArrayParam::updateCanvasIndicators(bool mirror)
return;
}
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = _last_pointwise->getPwd2();
- Pathinfo* path_info = new Pathinfo();
- path_info->set(pwd2);
+ Geom::PathVector pointwise_pv = path_from_piecewise(Geom::remove_short_cuts(pwd2,0.01),0.01);
if (mirror == true) {
_hp.clear();
}
@@ -97,7 +94,17 @@ void SatelliteArrayParam::updateCanvasIndicators(bool mirror)
double size_out = _vector[i].arcDistance(pwd2[i]);
double lenght_out = Geom::length(pwd2[i], Geom::EPSILON);
double lenght_in = 0;
- boost::optional<size_t> d2_prev_index = path_info->previous(i);
+
+ Geom::Path sat_path = pointwise_pv.pathAt(i);
+ boost::optional<size_t> d2_prev_index = boost::none;
+ size_t sat_curve_time = Geom::nearest_time(pointwise_pv.curveAt(i).initialPoint() , pwd2);
+ size_t first = Geom::nearest_time(sat_path.initialPoint() , pwd2);
+ if (sat_path.closed() && sat_curve_time == first){
+ sat_curve_time = Geom::nearest_time(sat_path.initialPoint(),pwd2);
+ d2_prev_index = sat_curve_time + sat_path.size() - 1;
+ } else if(!sat_path.closed() || sat_curve_time != first){
+ d2_prev_index = sat_curve_time - 1;
+ }
if (d2_prev_index) {
lenght_in = Geom::length(pwd2[*d2_prev_index], Geom::EPSILON);
}
@@ -285,10 +292,18 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p,
}
Pointwise *pointwise = _pparam->_last_pointwise;
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = pointwise->getPwd2();
- Pathinfo* path_info = new Pathinfo();
- path_info->set(pwd2);
- if (_pparam->_vector.size() <= _index) {
- boost::optional<size_t> d2_prev_index = path_info->previous(index);
+ Geom::PathVector pointwise_pv = path_from_piecewise(Geom::remove_short_cuts(pwd2,0.01),0.01);
+ if (_index >= _pparam->_vector.size() ) {
+ Geom::Path sat_path = pointwise_pv.pathAt(index);
+ boost::optional<size_t> d2_prev_index = boost::none;
+ size_t sat_curve_time = Geom::nearest_time(pointwise_pv.curveAt(index).initialPoint(),pwd2);
+ size_t first = Geom::nearest_time(sat_path.initialPoint() , pwd2);
+ if (sat_path.closed() && sat_curve_time == first){
+ sat_curve_time = Geom::nearest_time(sat_path.initialPoint(),pwd2);
+ d2_prev_index = sat_curve_time + sat_path.size() - 1;
+ } else if(!sat_path.closed() || sat_curve_time != first){
+ d2_prev_index = sat_curve_time - 1;
+ }
if (d2_prev_index) {
Geom::D2<Geom::SBasis> d2_in = pwd2[*d2_prev_index];
double mirror_time = Geom::nearest_time(s, d2_in);
@@ -334,15 +349,23 @@ Geom::Point FilletChamferKnotHolderEntity::knot_get() const
}
Pointwise *pointwise = _pparam->_last_pointwise;
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = pointwise->getPwd2();
- Pathinfo* path_info = new Pathinfo();
- path_info->set(pwd2);
+ Geom::PathVector pointwise_pv = path_from_piecewise(Geom::remove_short_cuts(pwd2,0.01),0.01);
if (pwd2.size() <= index) {
return Geom::Point(Geom::infinity(), Geom::infinity());
}
this->knot->show();
if (_index >= _pparam->_vector.size()) {
tmp_point = satellite.getPosition(pwd2[index]);
- boost::optional<size_t> d2_prev_index = path_info->previous(index);
+ Geom::Path sat_path = pointwise_pv.pathAt(index);
+ boost::optional<size_t> d2_prev_index = boost::none;
+ size_t sat_curve_time = Geom::nearest_time(pointwise_pv.curveAt(index).initialPoint(),pwd2);
+ size_t first = Geom::nearest_time(sat_path.initialPoint() , pwd2);
+ if (sat_path.closed() && sat_curve_time == first){
+ sat_curve_time = Geom::nearest_time(sat_path.initialPoint(),pwd2);
+ d2_prev_index = sat_curve_time + sat_path.size() - 1;
+ } else if(!sat_path.closed() || sat_curve_time != first){
+ d2_prev_index = sat_curve_time - 1;
+ }
if (d2_prev_index) {
Geom::D2<Geom::SBasis> d2_in = pwd2[*d2_prev_index];
double s = satellite.arcDistance(pwd2[index]);
@@ -425,20 +448,28 @@ void FilletChamferKnotHolderEntity::knot_click(guint state)
}
} else if (state & GDK_SHIFT_MASK) {
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = _pparam->_last_pointwise->getPwd2();
- Pathinfo* path_info = new Pathinfo();
- path_info->set(pwd2);
+ Geom::PathVector pointwise_pv = path_from_piecewise(Geom::remove_short_cuts(pwd2,0.01),0.01);
double amount = _pparam->_vector.at(index).amount;
+ Geom::Path sat_path = pointwise_pv.pathAt(index);
+ boost::optional<size_t> d2_prev_index = boost::none;
+ size_t sat_curve_time = Geom::nearest_time(pointwise_pv.curveAt(index).initialPoint(),pwd2);
+ size_t first = Geom::nearest_time(sat_path.initialPoint() , pwd2);
+ if (sat_path.closed() && sat_curve_time == first){
+ sat_curve_time = Geom::nearest_time(sat_path.initialPoint(),pwd2);
+ d2_prev_index = sat_curve_time + sat_path.size() - 1;
+ } else if(!sat_path.closed() || sat_curve_time != first){
+ d2_prev_index = sat_curve_time - 1;
+ }
+
if (!_pparam->_use_distance && !_pparam->_vector.at(index).is_time) {
- boost::optional<size_t> prev = path_info->previous(index);
- if (prev) {
- amount = _pparam->_vector.at(index).lenToRad(amount, pwd2[*prev], pwd2[index],_pparam->_vector.at(*prev));
+ if (d2_prev_index) {
+ amount = _pparam->_vector.at(index).lenToRad(amount, pwd2[*d2_prev_index], pwd2[index],_pparam->_vector.at(*d2_prev_index));
} else {
amount = 0.0;
}
}
bool aprox = false;
Geom::D2<Geom::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];
@@ -468,9 +499,17 @@ void FilletChamferKnotHolderEntity::knot_set_offset(Satellite satellite)
double max_amount = amount;
if (!_pparam->_use_distance && !satellite.is_time) {
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = _pparam->_last_pointwise->getPwd2();
- Pathinfo* path_info = new Pathinfo();
- path_info->set(pwd2);
- boost::optional<size_t> prev = path_info->previous(index);
+ Geom::PathVector pointwise_pv = path_from_piecewise(Geom::remove_short_cuts(pwd2,0.01),0.01);
+ Geom::Path sat_path = pointwise_pv.pathAt(index);
+ boost::optional<size_t> prev = boost::none;
+ size_t sat_curve_time = Geom::nearest_time(pointwise_pv.curveAt(index).initialPoint(),pwd2);
+ size_t first = Geom::nearest_time(sat_path.initialPoint() , pwd2);
+ if (sat_path.closed() && sat_curve_time == first){
+ sat_curve_time = Geom::nearest_time(sat_path.initialPoint(),pwd2);
+ prev = sat_curve_time + sat_path.size() - 1;
+ } else if(!sat_path.closed() || sat_curve_time != first){
+ prev = sat_curve_time - 1;
+ }
if (prev) {
amount = _pparam->_vector.at(index).radToLen(amount, pwd2[*prev], pwd2[index]);
} else {
diff --git a/src/live_effects/parameter/satellitearray.h b/src/live_effects/parameter/satellitearray.h
index cc09e7589..bb8bf27c8 100644
--- a/src/live_effects/parameter/satellitearray.h
+++ b/src/live_effects/parameter/satellitearray.h
@@ -35,7 +35,6 @@ public:
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()
{