summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-03-07 12:55:16 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-03-07 12:55:16 +0000
commit62ebac099d8fa013e34a773c0fe3aee56b5a5758 (patch)
treed1eea7a31f9fd8f261bc1322f76167c228dcf0b8 /src
parentAdd to po files (diff)
downloadinkscape-62ebac099d8fa013e34a773c0fe3aee56b5a5758.tar.gz
inkscape-62ebac099d8fa013e34a773c0fe3aee56b5a5758.zip
finish helper paths and beter handle of fillet/chamfer overflow. Also make the satellitepairarray LPE parameter usable for other pointwise effects, not only to fillet chamfer
(bzr r13645.1.35)
Diffstat (limited to 'src')
-rw-r--r--src/2geom/pointwise.cpp2
-rw-r--r--src/2geom/satellite.cpp39
-rw-r--r--src/2geom/satellite.h12
-rw-r--r--src/live_effects/lpe-fillet-chamfer.cpp53
-rw-r--r--src/live_effects/lpe-fillet-chamfer.h2
-rw-r--r--src/live_effects/parameter/array.cpp6
-rw-r--r--src/live_effects/parameter/array.h2
-rw-r--r--src/live_effects/parameter/satellitepairarray.cpp217
-rw-r--r--src/live_effects/parameter/satellitepairarray.h16
-rw-r--r--src/ui/dialog/lpe-fillet-chamfer-properties.cpp20
-rw-r--r--src/ui/dialog/lpe-fillet-chamfer-properties.h14
11 files changed, 222 insertions, 161 deletions
diff --git a/src/2geom/pointwise.cpp b/src/2geom/pointwise.cpp
index 1d1c69cee..3b182916a 100644
--- a/src/2geom/pointwise.cpp
+++ b/src/2geom/pointwise.cpp
@@ -132,7 +132,7 @@ Pointwise::len_to_rad(double A, std::pair<unsigned int,Geom::Satellite> satelli
boost::optional<Geom::D2<Geom::SBasis> >
Pointwise::getCurveIn(std::pair<unsigned int,Satellite> sat){
//curve out = sat.first;
- std::vector<Geom::Path> path_in_processed = pathv_to_linear_and_cubic_beziers(path_from_piecewise(_pwd2, 0.001));
+ std::vector<Geom::Path> path_in_processed = path_from_piecewise(_pwd2, 0.001);
unsigned int counterTotal = 0;
for (PathVector::const_iterator path_it = path_in_processed.begin(); path_it != path_in_processed.end(); ++path_it) {
if (path_it->empty()){
diff --git a/src/2geom/satellite.cpp b/src/2geom/satellite.cpp
index 22c3c8bed..3420db7f6 100644
--- a/src/2geom/satellite.cpp
+++ b/src/2geom/satellite.cpp
@@ -40,8 +40,8 @@ namespace Geom {
Satellite::Satellite(){};
-Satellite::Satellite(SatelliteType satellitetype, bool isTime, bool isClosing, bool isStart, bool active, bool hasMirror, bool hidden, double ammount, double angle, unsigned int steps)
- : _satellitetype(satellitetype), _isTime(isTime), _isClosing(isClosing), _isStart(isStart), _active(active), _hasMirror(hasMirror), _hidden(hidden), _ammount(ammount), _angle(angle), _steps(steps){};
+Satellite::Satellite(SatelliteType satellitetype, bool isTime, bool isClosing, bool isStart, bool active, bool hasMirror, bool hidden, double amount, double angle, unsigned int steps)
+ : _satellitetype(satellitetype), _isTime(isTime), _isClosing(isClosing), _isStart(isStart), _active(active), _hasMirror(hasMirror), _hidden(hidden), _amount(amount), _angle(angle), _steps(steps){};
Satellite::~Satellite() {};
@@ -49,13 +49,14 @@ double
Satellite::toTime(double A,Geom::D2<Geom::SBasis> d2_in)
{
if(!d2_in.isFinite() || d2_in.isZero() || A == 0){
- _ammount = 0;
return 0;
}
double t = 0;
double lenghtPart = Geom::length(d2_in, Geom::EPSILON);
- if (A > lenghtPart) {
- t = 1;
+ if (A > lenghtPart || d2_in[0].degreesOfFreedom() == 2) {
+ if (lenghtPart != 0) {
+ t = A / lenghtPart;
+ }
} else if (d2_in[0].degreesOfFreedom() != 2) {
Geom::Piecewise<Geom::D2<Geom::SBasis> > u;
u.push_cut(0);
@@ -64,15 +65,8 @@ Satellite::toTime(double A,Geom::D2<Geom::SBasis> d2_in)
if (t_roots.size() > 0) {
t = t_roots[0];
}
- } else {
- //to be sure
- if (lenghtPart != 0) {
- t = A / lenghtPart;
- }
- }
- if(t > 0.998){
- t = 1;
}
+
return t;
}
@@ -80,19 +74,18 @@ double
Satellite::toSize(double A,Geom::D2<Geom::SBasis> d2_in)
{
if(!d2_in.isFinite() || d2_in.isZero() || A == 0){
- _ammount = 0;
return 0;
}
double s = 0;
double lenghtPart = Geom::length(d2_in, Geom::EPSILON);
- if (d2_in[0].degreesOfFreedom() != 2) {
+ if (A > lenghtPart || d2_in[0].degreesOfFreedom() == 2) {
+ s = (A * lenghtPart);
+ } else if (d2_in[0].degreesOfFreedom() != 2) {
Geom::Piecewise<Geom::D2<Geom::SBasis> > u;
u.push_cut(0);
u.push(d2_in, 1);
u = Geom::portion(u, 0.0, A);
s = Geom::length(u, 0.001);
- } else {
- s = (A * lenghtPart);
}
return s;
}
@@ -110,16 +103,19 @@ Satellite::getOpositeTime(double s, Geom::D2<Geom::SBasis> d2_in)
double
Satellite::getTime(Geom::D2<Geom::SBasis> d2_in){
- double t = getAmmount();
+ double t = getAmount();
if(!getIsTime()){
t = toTime(t, d2_in);
}
+ if(t > 1){
+ t = 1;
+ }
return t;
}
double
Satellite::getSize(Geom::D2<Geom::SBasis> d2_in){
- double s = getAmmount();
+ double s = getAmount();
if(getIsTime()){
s = toSize(s, d2_in);
}
@@ -129,7 +125,8 @@ Satellite::getSize(Geom::D2<Geom::SBasis> d2_in){
Geom::Point
Satellite::getPosition(Geom::D2<Geom::SBasis> d2_in){
- return d2_in.valueAt(getTime(d2_in));
+ double t = getTime(d2_in);
+ return d2_in.valueAt(t);
}
void
@@ -139,7 +136,7 @@ Satellite::setPosition(Geom::Point p, Geom::D2<Geom::SBasis> d2_in)
if(!getIsTime()){
A = toSize(A, d2_in);
}
- setAmmount(A);
+ setAmount(A);
}
} // end namespace Geom
diff --git a/src/2geom/satellite.h b/src/2geom/satellite.h
index 4b0797620..d14a98a7f 100644
--- a/src/2geom/satellite.h
+++ b/src/2geom/satellite.h
@@ -45,7 +45,7 @@ class Satellite
public:
Satellite();
- Satellite(SatelliteType satellitetype, bool isTime, bool isClosing, bool isStart, bool active, bool hasMirror, bool hidden, double ammount, double angle, unsigned int steps);
+ Satellite(SatelliteType satellitetype, bool isTime, bool isClosing, bool isStart, bool active, bool hasMirror, bool hidden, double amount, double angle, unsigned int steps);
virtual ~Satellite();
@@ -89,9 +89,9 @@ class Satellite
{
_hidden = A;
}
- void setAmmount(double A)
+ void setAmount(double A)
{
- _ammount = A;
+ _amount = A;
}
void setAngle(double A)
@@ -145,9 +145,9 @@ class Satellite
return _hidden;
}
- double getAmmount() const
+ double getAmount() const
{
- return _ammount;
+ return _amount;
}
double getAngle() const
@@ -177,7 +177,7 @@ class Satellite
bool _active;
bool _hasMirror;
bool _hidden;
- double _ammount;
+ double _amount;
double _angle;
unsigned int _steps;
};
diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp
index 118a89ead..d979171be 100644
--- a/src/live_effects/lpe-fillet-chamfer.cpp
+++ b/src/live_effects/lpe-fillet-chamfer.cpp
@@ -79,7 +79,7 @@ LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject) :
chamfer_steps.param_set_range(1, 999);
chamfer_steps.param_set_increments(1, 1);
chamfer_steps.param_set_digits(0);
- helper_size.param_set_range(0, infinity());
+ helper_size.param_set_range(0, 999);
helper_size.param_set_increments(5, 5);
helper_size.param_set_digits(0);
}
@@ -175,7 +175,7 @@ Gtk::Widget *LPEFilletChamfer::newWidget()
Gtk::Widget *widg = param->param_newWidget();
if (param->param_key == "radius") {
Inkscape::UI::Widget::Scalar *widgRegistered = Gtk::manage(dynamic_cast<Inkscape::UI::Widget::Scalar *>(widg));
- widgRegistered->signal_value_changed().connect(sigc::mem_fun(*this, &LPEFilletChamfer::updateAmmount));
+ widgRegistered->signal_value_changed().connect(sigc::mem_fun(*this, &LPEFilletChamfer::updateAmount));
widg = widgRegistered;
if (widg) {
Gtk::HBox *scalarParameter = dynamic_cast<Gtk::HBox *>(widg);
@@ -267,7 +267,7 @@ void LPEFilletChamfer::refreshKnots()
}
}
-void LPEFilletChamfer::updateAmmount()
+void LPEFilletChamfer::updateAmount()
{
double power = 0;
if (!flexible) {
@@ -279,26 +279,26 @@ void LPEFilletChamfer::updateAmmount()
Piecewise<D2<SBasis> > pwd2 = pointwise->getPwd2();
for (std::vector<std::pair<unsigned int,Geom::Satellite> >::iterator it = satellites.begin(); it != satellites.end(); ++it) {
if(pointwise->findClosingSatellites(it->first).size() == 0 && it->second.getIsStart()){
- it->second.setAmmount(0);
+ it->second.setAmount(0);
continue;
}
- if(ignore_radius_0 && it->second.getAmmount() == 0){
+ if(ignore_radius_0 && it->second.getAmount() == 0){
continue;
}
if(only_selected){
Geom::Point satPoint = pwd2.valueAt(it->first);
if(isNodePointSelected(satPoint)){
if(!use_knot_distance && !flexible){
- it->second.setAmmount(pointwise->rad_to_len(power,*it));
+ it->second.setAmount(pointwise->rad_to_len(power,*it));
} else {
- it->second.setAmmount(power);
+ it->second.setAmount(power);
}
}
} else {
if(!use_knot_distance && !flexible){
- it->second.setAmmount(pointwise->rad_to_len(power,*it));
+ it->second.setAmount(pointwise->rad_to_len(power,*it));
} else {
- it->second.setAmmount(power);
+ it->second.setAmount(power);
}
}
}
@@ -311,7 +311,7 @@ void LPEFilletChamfer::updateChamferSteps()
std::vector<std::pair<unsigned int,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) {
- if(ignore_radius_0 && it->second.getAmmount() == 0){
+ if(ignore_radius_0 && it->second.getAmount() == 0){
continue;
}
if(only_selected){
@@ -332,7 +332,7 @@ void LPEFilletChamfer::updateSatelliteType(Geom::SatelliteType satellitetype)
std::vector<std::pair<unsigned int,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) {
- if(ignore_radius_0 && it->second.getAmmount() == 0){
+ if(ignore_radius_0 && it->second.getAmount() == 0){
continue;
}
if(only_selected){
@@ -358,33 +358,40 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem)
if(path){
c = path->get_original_curve();
}
+ //fillet chamfer specific calls
+ satellitepairarrayparam_values.set_document_unit(defaultUnit);
+ satellitepairarrayparam_values.set_use_distance(use_knot_distance);
+ satellitepairarrayparam_values.set_unit(unit.get_abbreviation());
+ //mandatory call
+ satellitepairarrayparam_values.set_effect_type(this->effectType());
+
PathVector const &original_pathv = pathv_to_linear_and_cubic_beziers(c->get_pathvector());
- Piecewise<D2<SBasis> > pwd2_in = paths_to_pw(pathv_to_linear_and_cubic_beziers(original_pathv));
+ 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> > satellites = satellitepairarrayparam_values.data();
pointwise = new Pointwise(pwd2_in,satellites);
+
+ //mandatory call
satellitepairarrayparam_values.set_pointwise(pointwise);
+ //optional call
if(hide_knots){
satellitepairarrayparam_values.set_helper_size(0);
} else {
satellitepairarrayparam_values.set_helper_size(helper_size);
}
- satellitepairarrayparam_values.set_document_unit(defaultUnit);
- satellitepairarrayparam_values.set_use_distance(use_knot_distance);
- satellitepairarrayparam_values.set_unit(unit.get_abbreviation());
bool changed = false;
bool refresh = false;
for (std::vector<std::pair<unsigned int,Geom::Satellite> >::iterator it = satellites.begin(); it != satellites.end(); ++it) {
if(it->second.getIsTime() != flexible){
it->second.setIsTime(flexible);
- double ammount = it->second.getAmmount();
+ double amount = it->second.getAmount();
D2<SBasis> d2_in = pwd2_in[it->first];
if(it->second.getIsTime()){
- double time = it->second.toTime(ammount,d2_in);
- it->second.setAmmount(time);
+ double time = it->second.toTime(amount,d2_in);
+ it->second.setAmount(time);
} else {
- double size = it->second.toSize(ammount,d2_in);
- it->second.setAmmount(size);
+ double size = it->second.toSize(amount,d2_in);
+ it->second.setAmount(size);
}
changed = true;
}
@@ -483,6 +490,10 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in)
if(time1 <= time0){
time1 = time0;
}
+ std::cout << counter << ":::::::::::::::::::::::::::::\n";
+ std::cout << time0 << "time0\n";
+ std::cout << time1 << "time1\n";
+ std::cout << time2 << "time2\n";
std::vector<double> times;
times.push_back(time0);
times.push_back(time1);
@@ -549,7 +560,7 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in)
Coord rx = radius;
Coord ry = rx;
if (times[1] != 1) {
- if (times[1] != times[0] || times[1] == times[0] == 1) {
+ if (times[1] != times[0] || times[1] == times[0] == 1 ) {
if(!knotCurve1->isDegenerate()){
path_out.append(*knotCurve1);
}
diff --git a/src/live_effects/lpe-fillet-chamfer.h b/src/live_effects/lpe-fillet-chamfer.h
index 56db6305e..3d22216d4 100644
--- a/src/live_effects/lpe-fillet-chamfer.h
+++ b/src/live_effects/lpe-fillet-chamfer.h
@@ -42,7 +42,7 @@ public:
/*double len_to_rad(double A, std::pair<int,Geom::Satellite> sat);*/
void updateSatelliteType(Geom::SatelliteType satellitetype);
void updateChamferSteps();
- void updateAmmount();
+ void updateAmount();
void refreshKnots();
void chamfer();
void inverseChamfer();
diff --git a/src/live_effects/parameter/array.cpp b/src/live_effects/parameter/array.cpp
index e4c480d93..e8a1b9532 100644
--- a/src/live_effects/parameter/array.cpp
+++ b/src/live_effects/parameter/array.cpp
@@ -62,13 +62,13 @@ sp_svg_satellite_read_d(gchar const *str, Geom::Satellite *sat){
sat->setActive(strncmp(strarray[4],"1",1) == 0);
sat->setHasMirror(strncmp(strarray[5],"1",1) == 0);
sat->setHidden(strncmp(strarray[6],"1",1) == 0);
- double ammount,angle;
+ double amount,angle;
float stepsTmp;
- sp_svg_number_read_d(strarray[7], &ammount);
+ sp_svg_number_read_d(strarray[7], &amount);
sp_svg_number_read_d(strarray[8], &angle);
sp_svg_number_read_f(strarray[9], &stepsTmp);
unsigned int steps = (unsigned int)stepsTmp;
- sat->setAmmount(ammount);
+ sat->setAmount(amount);
sat->setAngle(angle);
sat->setSteps(steps);
g_strfreev (strarray);
diff --git a/src/live_effects/parameter/array.h b/src/live_effects/parameter/array.h
index d28576fce..a6e797d4e 100644
--- a/src/live_effects/parameter/array.h
+++ b/src/live_effects/parameter/array.h
@@ -129,7 +129,7 @@ protected:
str << "*";
str << nVector.second.getHidden();
str << "*";
- str << nVector.second.getAmmount();
+ str << nVector.second.getAmount();
str << "*";
str << nVector.second.getAngle();
str << "*";
diff --git a/src/live_effects/parameter/satellitepairarray.cpp b/src/live_effects/parameter/satellitepairarray.cpp
index ffd04e14c..9c2c1f93b 100644
--- a/src/live_effects/parameter/satellitepairarray.cpp
+++ b/src/live_effects/parameter/satellitepairarray.cpp
@@ -34,7 +34,7 @@ SatellitePairArrayParam::SatellitePairArrayParam(
knot_color = 0x00ff0000;
helper_size = 0;
use_distance = false;
-
+ _effectType = FILLET_CHAMFER;
last_pointwise = NULL;
}
@@ -69,37 +69,61 @@ void SatellitePairArrayParam::set_unit(const gchar *abbr)
unit = abbr;
}
+void SatellitePairArrayParam::set_effect_type(EffectType et)
+{
+ _effectType = et;
+}
+
void SatellitePairArrayParam::set_helper_size(int hs)
{
helper_size = hs;
updateCanvasIndicators();
}
-void SatellitePairArrayParam::updateCanvasIndicators()
+void SatellitePairArrayParam::updateCanvasIndicators(bool mirror)
{
+ if( last_pointwise == NULL){
+ return;
+ }
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = last_pointwise->getPwd2();
- hp.clear();
- bool mirrorPass = false;
+ if( mirror == true){
+ hp.clear();
+ }
for (unsigned int i = 0; i < _vector.size(); ++i) {
if(!_vector[i].second.getActive() || !_vector[i].second.getHidden()){
continue;
}
+ if((!_vector[i].second.getHasMirror() && mirror == true) || _vector[i].second.getAmount() == 0){
+ continue;
+ }
double pos = 0;
if(pwd2.size() <= (unsigned)_vector[i].first){
break;
}
Geom::D2<Geom::SBasis> d2 = pwd2[_vector[i].first];
- if(mirrorPass == true){
- double size = _vector[i].second.getSize(pwd2[_vector[i].first]);
- boost::optional<Geom::D2<Geom::SBasis> > curve_in = last_pointwise->getCurveIn(_vector[i]);
+ bool overflow = false;
+ 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<Geom::D2<Geom::SBasis> > curve_in = last_pointwise->getCurveIn(_vector[i]);
+ if(curve_in){
+ lenght_in = Geom::length(*curve_in, Geom::EPSILON);
+ }
+ if(mirror == true){
if(curve_in){
d2 = *curve_in;
- pos = _vector[i].second.getOpositeTime(size,*curve_in);
+ pos = _vector[i].second.getOpositeTime(size_out,*curve_in);
+ if(lenght_out < size_out){
+ overflow = true;
+ }
}
} else {
pos = _vector[i].second.getTime(pwd2[_vector[i].first]);
+ if(lenght_in < size_out){
+ overflow = true;
+ }
}
- if (pos == 0) {
+ if (pos <= 0 || pos >= 1) {
continue;
}
Geom::Point ptA = d2.valueAt(pos);
@@ -113,7 +137,7 @@ void SatellitePairArrayParam::updateCanvasIndicators()
Geom::PathVector pathv = sp_svg_read_pathv(svgd);
Geom::Affine aff = Geom::Affine();
aff *= Geom::Scale(helper_size);
- if(mirrorPass == true){
+ if(mirror == true){
aff *= Geom::Rotate(ray1.angle() - deg_to_rad(90));
} else {
aff *= Geom::Rotate(ray1.angle() - deg_to_rad(270));
@@ -122,13 +146,40 @@ void SatellitePairArrayParam::updateCanvasIndicators()
pathv += d2.valueAt(pos);
hp.push_back(pathv[0]);
hp.push_back(pathv[1]);
- if(_vector[i].second.getHasMirror() && mirrorPass == false){
- mirrorPass = true;
- i--;
- } else {
- mirrorPass = false;
+ 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);
+ pathv *= Geom::Scale (diameter);
+ pathv += ptA-Geom::Point(diameter * 0.35,diameter * 0.35);
+ hp.push_back(pathv[0]);
+ } 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(ray1.angle() - deg_to_rad(90));
+ } else {
+ aff *= Geom::Rotate(ray1.angle() - deg_to_rad(270));
+ }
+ pathv *= aff;
+ pathv += d2.valueAt(pos);
+ hp.push_back(pathv[0]);
+ }
}
}
+ if( mirror == true){
+ updateCanvasIndicators(false);
+ }
+}
+void SatellitePairArrayParam::updateCanvasIndicators()
+{
+ updateCanvasIndicators(true);
}
void SatellitePairArrayParam::addCanvasIndicators(
@@ -139,76 +190,62 @@ void SatellitePairArrayParam::addCanvasIndicators(
void SatellitePairArrayParam::addKnotHolderEntities(KnotHolder *knotholder,
SPDesktop *desktop,
- SPItem *item)
+ SPItem *item,
+ bool mirror)
{
for (unsigned int i = 0; i < _vector.size(); ++i) {
if(!_vector[i].second.getActive() || !_vector[i].second.getHidden()){
continue;
}
- if(_vector[i].second.getHasMirror()){
- addKnotHolderEntitieMirrored(knotholder, desktop, item, i);
+ if(!_vector[i].second.getHasMirror() && mirror == true){
+ continue;
+ }
+ int iPlus = i;
+ if( mirror == true){
+ iPlus = i + _vector.size();
}
using namespace Geom;
SatelliteType type = _vector[i].second.getSatelliteType();
- const gchar *tip;
- if (type == C){
- tip = _("<b>Chamfer</b>: <b>Ctrl+Click</b> toggle type, "
- "<b>Shift+Click</b> open dialog, "
- "<b>Ctrl+Alt+Click</b> reset");
- } else if (type == IC) {
- tip = _("<b>Inverse Chamfer</b>: <b>Ctrl+Click</b> toggle type, "
- "<b>Shift+Click</b> open dialog, "
- "<b>Ctrl+Alt+Click</b> reset");
- } else if (type == IF) {
- tip = _("<b>Inverse Fillet</b>: <b>Ctrl+Click</b> toggle type, "
- "<b>Shift+Click</b> open dialog, "
- "<b>Ctrl+Alt+Click</b> reset");
- } else {
- tip = _("<b>Fillet</b>: <b>Ctrl+Click</b> toggle type, "
- "<b>Shift+Click</b> open dialog, "
- "<b>Ctrl+Alt+Click</b> reset");
+ //IF is for filletChamfer effect...
+ if(_effectType == FILLET_CHAMFER){
+ const gchar *tip;
+ if (type == C){
+ tip = _("<b>Chamfer</b>: <b>Ctrl+Click</b> toggle type, "
+ "<b>Shift+Click</b> open dialog, "
+ "<b>Ctrl+Alt+Click</b> reset");
+ } else if (type == IC) {
+ tip = _("<b>Inverse Chamfer</b>: <b>Ctrl+Click</b> toggle type, "
+ "<b>Shift+Click</b> open dialog, "
+ "<b>Ctrl+Alt+Click</b> reset");
+ } else if (type == IF) {
+ tip = _("<b>Inverse Fillet</b>: <b>Ctrl+Click</b> toggle type, "
+ "<b>Shift+Click</b> open dialog, "
+ "<b>Ctrl+Alt+Click</b> reset");
+ } else {
+ tip = _("<b>Fillet</b>: <b>Ctrl+Click</b> toggle type, "
+ "<b>Shift+Click</b> open dialog, "
+ "<b>Ctrl+Alt+Click</b> reset");
+ }
+ FilletChamferKnotHolderEntity *e =
+ new FilletChamferKnotHolderEntity(this, iPlus);
+ e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _(tip),
+ knot_shape, knot_mode, knot_color);
+ knotholder->add(e);
}
- SatellitePairArrayParamKnotHolderEntity *e =
- new SatellitePairArrayParamKnotHolderEntity(this, i);
- e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _(tip),
- knot_shape, knot_mode, knot_color);
- knotholder->add(e);
+ }
+ if( mirror == true){
+ addKnotHolderEntities(knotholder, desktop, item, false);
}
}
-void SatellitePairArrayParam::addKnotHolderEntitieMirrored(KnotHolder *knotholder,
+void SatellitePairArrayParam::addKnotHolderEntities(KnotHolder *knotholder,
SPDesktop *desktop,
- SPItem *item, int i)
+ SPItem *item)
{
- using namespace Geom;
- SatelliteType type = _vector[i].second.getSatelliteType();
- const gchar *tip;
- if (type == C){
- tip = _("<b>Chamfer</b>: <b>Ctrl+Click</b> toggle type, "
- "<b>Shift+Click</b> open dialog, "
- "<b>Ctrl+Alt+Click</b> reset");
- } else if (type == IC) {
- tip = _("<b>Inverse Chamfer</b>: <b>Ctrl+Click</b> toggle type, "
- "<b>Shift+Click</b> open dialog, "
- "<b>Ctrl+Alt+Click</b> reset");
- } else if (type == IF) {
- tip = _("<b>Inverse Fillet</b>: <b>Ctrl+Click</b> toggle type, "
- "<b>Shift+Click</b> open dialog, "
- "<b>Ctrl+Alt+Click</b> reset");
- } else {
- tip = _("<b>Fillet</b>: <b>Ctrl+Click</b> toggle type, "
- "<b>Shift+Click</b> open dialog, "
- "<b>Ctrl+Alt+Click</b> reset");
- }
- SatellitePairArrayParamKnotHolderEntity *e =
- new SatellitePairArrayParamKnotHolderEntity(this, i + _vector.size());
- e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _(tip),
- knot_shape, knot_mode, knot_color);
- knotholder->add(e);
+ addKnotHolderEntities(knotholder, desktop, item, true);
}
-
-SatellitePairArrayParamKnotHolderEntity::SatellitePairArrayParamKnotHolderEntity(SatellitePairArrayParam *p, unsigned int index)
+FilletChamferKnotHolderEntity::FilletChamferKnotHolderEntity(SatellitePairArrayParam *p, unsigned int index)
: _pparam(p),
_index(index)
{
@@ -216,7 +253,7 @@ SatellitePairArrayParamKnotHolderEntity::SatellitePairArrayParamKnotHolderEntity
-void SatellitePairArrayParamKnotHolderEntity::knot_set(Point const &p,
+void FilletChamferKnotHolderEntity::knot_set(Point const &p,
Point const &/*origin*/,
guint state)
{
@@ -244,10 +281,11 @@ void SatellitePairArrayParamKnotHolderEntity::knot_set(Point const &p,
mirrorTime = timeStart;
}
double size = satellite.second.toSize(mirrorTime, *d2_in);
- double lenght = Geom::length(*d2_in, Geom::EPSILON) - size;
- double time = satellite.second.toTime(lenght,pwd2[satellite.first]);
- s = pwd2[satellite.first].valueAt(time);
- satellite.second.setPosition(s,pwd2[satellite.first]);
+ double amount = Geom::length(*d2_in, Geom::EPSILON) - size;
+ if(satellite.second.getIsTime()){
+ amount = satellite.second.toTime(amount,pwd2[satellite.first]);
+ }
+ satellite.second.setAmount(amount);
}
} else {
satellite.second.setPosition(s,pwd2[satellite.first]);
@@ -260,7 +298,7 @@ void SatellitePairArrayParamKnotHolderEntity::knot_set(Point const &p,
}
Geom::Point
-SatellitePairArrayParamKnotHolderEntity::knot_get() const
+FilletChamferKnotHolderEntity::knot_get() const
{
Geom::Point tmpPoint;
int index = _index;
@@ -303,15 +341,19 @@ SatellitePairArrayParamKnotHolderEntity::knot_get() const
}
-void SatellitePairArrayParamKnotHolderEntity::knot_click(guint state)
+void FilletChamferKnotHolderEntity::knot_click(guint state)
{
+ if( _pparam->last_pointwise == NULL){
+ return;
+ }
+
int index = _index;
if( _index >= _pparam->_vector.size()){
index = _index-_pparam->_vector.size();
}
if (state & GDK_CONTROL_MASK) {
if (state & GDK_MOD1_MASK) {
- _pparam->_vector.at(index).second.setAmmount(0.0);
+ _pparam->_vector.at(index).second.setAmount(0.0);
_pparam->param_set_and_write_new_value(_pparam->_vector);
sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false);
}else{
@@ -356,9 +398,9 @@ void SatellitePairArrayParamKnotHolderEntity::knot_click(guint state)
this->knot->show();
}
} else if (state & GDK_SHIFT_MASK) {
- double ammount = _pparam->_vector.at(index).second.getAmmount();
+ double amount = _pparam->_vector.at(index).second.getAmount();
if(!_pparam->use_distance && !_pparam->_vector.at(index).second.getIsTime()){
- ammount = _pparam->last_pointwise->len_to_rad(ammount, _pparam->_vector.at(index));
+ amount = _pparam->last_pointwise->len_to_rad(amount, _pparam->_vector.at(index));
}
boost::optional<Geom::D2<Geom::SBasis> > d2_in = _pparam->last_pointwise->getCurveIn(_pparam->_vector.at(index));
bool aprox = false;
@@ -367,22 +409,29 @@ void SatellitePairArrayParamKnotHolderEntity::knot_click(guint state)
aprox = ((*d2_in)[0].degreesOfFreedom() != 2 || d2_out[0].degreesOfFreedom() != 2) && !_pparam->use_distance?true:false;
}
Inkscape::UI::Dialogs::FilletChamferPropertiesDialog::showDialog(
- this->desktop, ammount , this, _pparam->unit, _pparam->use_distance, aprox, _pparam->documentUnit,_pparam->_vector.at(index).second);
+ this->desktop, amount , this, _pparam->unit, _pparam->use_distance, aprox, _pparam->documentUnit,_pparam->_vector.at(index).second);
}
}
-void SatellitePairArrayParamKnotHolderEntity::knot_set_offset(Geom::Satellite satellite)
+void FilletChamferKnotHolderEntity::knot_set_offset(Geom::Satellite satellite)
{
+ if( _pparam->last_pointwise == NULL){
+ return;
+ }
int index = _index;
if( _index >= _pparam->_vector.size()){
index = _index-_pparam->_vector.size();
}
- double ammount = satellite.getAmmount();
+ double amount = satellite.getAmount();
+ double maxAmount = amount;
if(!_pparam->use_distance && !satellite.getIsTime()){
- ammount = _pparam->last_pointwise->rad_to_len(ammount, _pparam->_vector.at(index));
+ amount = _pparam->last_pointwise->rad_to_len(amount, _pparam->_vector.at(index));
+ if(maxAmount > 0 && amount == 0){
+ amount = _pparam->_vector.at(index).second.getAmount();
+ }
}
- satellite.setAmmount(ammount);
+ satellite.setAmount(amount);
_pparam->_vector.at(index).second = satellite;
this->parent_holder->knot_ungrabbed_handler(this->knot, 0);
_pparam->param_set_and_write_new_value(_pparam->_vector);
diff --git a/src/live_effects/parameter/satellitepairarray.h b/src/live_effects/parameter/satellitepairarray.h
index 21fb0fbd8..79a015c6d 100644
--- a/src/live_effects/parameter/satellitepairarray.h
+++ b/src/live_effects/parameter/satellitepairarray.h
@@ -20,6 +20,7 @@
#include <glib.h>
#include "live_effects/parameter/array.h"
+#include "live_effects/effect-enum.h"
#include "knot-holder-entity.h"
#include <2geom/pointwise.h>
@@ -27,7 +28,7 @@ namespace Inkscape {
namespace LivePathEffect {
-class SatellitePairArrayParamKnotHolderEntity;
+class FilletChamferKnotHolderEntity;
class SatellitePairArrayParam : public ArrayParam<std::pair<unsigned int, Geom::Satellite> > {
public:
@@ -46,7 +47,7 @@ public:
guint32 color);
virtual void set_helper_size(int hs);
virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
- virtual void addKnotHolderEntitieMirrored(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item, int i);
+ virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item, bool mirror);
virtual void addCanvasIndicators(SPLPEItem const *lpeitem,std::vector<Geom::PathVector> &hp_vec);
virtual bool providesKnotHolderEntities() const {
return true;
@@ -54,9 +55,11 @@ public:
void set_document_unit(Glib::ustring const * value_document_unit);
void set_use_distance(bool use_knot_distance );
void set_unit(const gchar *abbr);
+ void set_effect_type(EffectType et);
virtual void updateCanvasIndicators();
+ virtual void updateCanvasIndicators(bool mirror);
void set_pointwise(Geom::Pointwise *pointwise);
- friend class SatellitePairArrayParamKnotHolderEntity;
+ friend class FilletChamferKnotHolderEntity;
private:
SatellitePairArrayParam(const SatellitePairArrayParam &);
@@ -70,14 +73,15 @@ private:
bool use_distance;
const gchar *unit;
Glib::ustring const * documentUnit;
+ EffectType _effectType;
Geom::Pointwise *last_pointwise;
};
-class SatellitePairArrayParamKnotHolderEntity : public KnotHolderEntity {
+class FilletChamferKnotHolderEntity : public KnotHolderEntity {
public:
- SatellitePairArrayParamKnotHolderEntity(SatellitePairArrayParam *p, unsigned int index);
- virtual ~SatellitePairArrayParamKnotHolderEntity() {}
+ FilletChamferKnotHolderEntity(SatellitePairArrayParam *p, unsigned int index);
+ virtual ~FilletChamferKnotHolderEntity() {}
virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state);
virtual Geom::Point knot_get() const;
diff --git a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp
index fe0deba57..8a6cbadad 100644
--- a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp
+++ b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp
@@ -123,9 +123,9 @@ FilletChamferPropertiesDialog::~FilletChamferPropertiesDialog()
}
void FilletChamferPropertiesDialog::showDialog(
- SPDesktop *desktop, double ammount,
+ SPDesktop *desktop, double amount,
const Inkscape::LivePathEffect::
- SatellitePairArrayParamKnotHolderEntity *pt,
+ FilletChamferKnotHolderEntity *pt,
const gchar *unit,
bool use_distance,
bool aprox_radius,
@@ -139,7 +139,7 @@ void FilletChamferPropertiesDialog::showDialog(
dialog->_set_use_distance(use_distance);
dialog->_set_aprox(aprox_radius);
dialog->_set_document_unit(documentUnit);
- dialog->_set_ammount(ammount);
+ dialog->_set_amount(amount);
dialog->_set_satellite(satellite);
dialog->_set_pt(pt);
@@ -176,7 +176,7 @@ void FilletChamferPropertiesDialog::_apply()
} else {
d_pos = Inkscape::Util::Quantity::convert(d_pos, unit, *document_unit);
}
- _satellite.setAmmount( d_pos);
+ _satellite.setAmount( d_pos);
unsigned int steps = (unsigned int)_fillet_chamfer_chamfer_subdivisions.get_value();
if(steps < 1){
steps = 1;
@@ -222,14 +222,14 @@ void FilletChamferPropertiesDialog::_set_satellite(Geom::Satellite satellite)
distance_or_radius = std::string(_("Knot distance"));
}
if (satellite.getIsTime()) {
- position = ammount * 100;
+ position = amount * 100;
_flexible = true;
_fillet_chamfer_position_label.set_label(_("Position (%):"));
} else {
_flexible = false;
std::string posConcat = Glib::ustring::compose (_("%1 (%2):"), distance_or_radius, unit);
_fillet_chamfer_position_label.set_label(_(posConcat.c_str()));
- position = ammount;
+ position = amount;
position = Inkscape::Util::Quantity::convert(position, *document_unit, unit);
}
_fillet_chamfer_position_numeric.set_value(position);
@@ -249,10 +249,10 @@ void FilletChamferPropertiesDialog::_set_satellite(Geom::Satellite satellite)
void FilletChamferPropertiesDialog::_set_pt(
const Inkscape::LivePathEffect::
- SatellitePairArrayParamKnotHolderEntity *pt)
+ FilletChamferKnotHolderEntity *pt)
{
_knotpoint = const_cast<
- Inkscape::LivePathEffect::SatellitePairArrayParamKnotHolderEntity *>(
+ Inkscape::LivePathEffect::FilletChamferKnotHolderEntity *>(
pt);
}
@@ -261,9 +261,9 @@ void FilletChamferPropertiesDialog::_set_unit(const gchar *abbr)
unit = abbr;
}
-void FilletChamferPropertiesDialog::_set_ammount(double amm)
+void FilletChamferPropertiesDialog::_set_amount(double amm)
{
- ammount = amm;
+ amount = amm;
}
diff --git a/src/ui/dialog/lpe-fillet-chamfer-properties.h b/src/ui/dialog/lpe-fillet-chamfer-properties.h
index 63215d17c..6051b49d3 100644
--- a/src/ui/dialog/lpe-fillet-chamfer-properties.h
+++ b/src/ui/dialog/lpe-fillet-chamfer-properties.h
@@ -27,9 +27,9 @@ public:
return "LayerPropertiesDialog";
}
- static void showDialog(SPDesktop *desktop, double ammount,
+ static void showDialog(SPDesktop *desktop, double amount,
const Inkscape::LivePathEffect::
- SatellitePairArrayParamKnotHolderEntity *pt,
+ FilletChamferKnotHolderEntity *pt,
const gchar *unit,
bool use_distance,
bool aprox_radius,
@@ -39,7 +39,7 @@ public:
protected:
SPDesktop *_desktop;
- Inkscape::LivePathEffect::SatellitePairArrayParamKnotHolderEntity *
+ Inkscape::LivePathEffect::FilletChamferKnotHolderEntity *
_knotpoint;
Gtk::Label _fillet_chamfer_position_label;
@@ -67,7 +67,7 @@ protected:
void _set_desktop(SPDesktop *desktop);
void _set_pt(const Inkscape::LivePathEffect::
- SatellitePairArrayParamKnotHolderEntity *pt);
+ FilletChamferKnotHolderEntity *pt);
void _set_unit(const gchar *abbr);
void _set_document_unit(Glib::ustring const * abbr);
void _set_use_distance(bool use_knot_distance);
@@ -79,9 +79,9 @@ protected:
const gchar *unit;
Glib::ustring const * document_unit;
bool use_distance;
- double ammount;
+ double amount;
bool aprox;
- void _set_ammount(double ammount);
+ void _set_amount(double amount);
void _set_satellite(Geom::Satellite satellite);
void _prepareLabelRenderer(Gtk::TreeModel::const_iterator const &row);
@@ -89,7 +89,7 @@ protected:
void _handleButtonEvent(GdkEventButton *event);
friend class Inkscape::LivePathEffect::
- SatellitePairArrayParamKnotHolderEntity;
+ FilletChamferKnotHolderEntity;
private:
FilletChamferPropertiesDialog(