summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-03-04 22:42:59 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-03-04 22:42:59 +0000
commit1db09cce6114c1b2d95ac77b00672caad0447b29 (patch)
tree8aa92d59737bc340b63bd73c368f856da0a46a51 /src
parentupdate to trunk (diff)
downloadinkscape-1db09cce6114c1b2d95ac77b00672caad0447b29.tar.gz
inkscape-1db09cce6114c1b2d95ac77b00672caad0447b29.zip
All features done, only need piecewise update function
(bzr r13645.1.33)
Diffstat (limited to 'src')
-rw-r--r--src/2geom/pointwise.cpp87
-rw-r--r--src/2geom/pointwise.h25
-rw-r--r--src/2geom/satellite.cpp4
-rw-r--r--src/2geom/satellite.h13
-rw-r--r--src/live_effects/lpe-fillet-chamfer.cpp127
-rw-r--r--src/live_effects/lpe-fillet-chamfer.h4
-rw-r--r--src/live_effects/parameter/array.cpp12
-rw-r--r--src/live_effects/parameter/array.h4
-rw-r--r--src/live_effects/parameter/satellitepairarray.cpp161
-rw-r--r--src/live_effects/parameter/satellitepairarray.h12
-rw-r--r--src/ui/dialog/lpe-fillet-chamfer-properties.cpp313
-rw-r--r--src/ui/dialog/lpe-fillet-chamfer-properties.h118
12 files changed, 763 insertions, 117 deletions
diff --git a/src/2geom/pointwise.cpp b/src/2geom/pointwise.cpp
index 0115ea103..1d1c69cee 100644
--- a/src/2geom/pointwise.cpp
+++ b/src/2geom/pointwise.cpp
@@ -30,23 +30,26 @@
*/
#include <2geom/pointwise.h>
+#include <2geom/ray.h>
+#include <2geom/path-intersection.h>
+#include <cmath>
namespace Geom {
-Pointwise::Pointwise(Piecewise<D2<SBasis> > pwd2, std::vector<std::pair<int,Satellite> > satellites)
+Pointwise::Pointwise(Piecewise<D2<SBasis> > pwd2, std::vector<std::pair<unsigned int,Satellite> > satellites)
: _pwd2(pwd2), _satellites(satellites)
{
};
Pointwise::~Pointwise(){};
-std::vector<std::pair<int,Satellite> >
+std::vector<std::pair<unsigned int,Satellite> >
Pointwise::getSatellites(){
return _satellites;
}
void
-Pointwise::setSatellites(std::vector<std::pair<int,Satellite> > sat){
+Pointwise::setSatellites(std::vector<std::pair<unsigned int,Satellite> > sat){
_satellites = sat;
}
@@ -60,11 +63,77 @@ Pointwise::setPwd2(Piecewise<D2<SBasis> > pwd2_in){
_pwd2 = pwd2_in;
}
+double
+Pointwise::rad_to_len(double A, std::pair<unsigned int,Geom::Satellite> satellite)
+{
+ double len = 0;
+ boost::optional<Geom::D2<Geom::SBasis> > d2_in = getCurveIn(satellite);
+ if(d2_in){
+ Geom::D2<Geom::SBasis> d2_out = _pwd2[satellite.first];
+ Piecewise<D2<SBasis> > offset_curve0 = Piecewise<D2<SBasis> >(*d2_in)+rot90(unitVector(derivative(*d2_in)))*(A);
+ Piecewise<D2<SBasis> > offset_curve1 = Piecewise<D2<SBasis> >(d2_out)+rot90(unitVector(derivative(d2_out)))*(A);
+ Geom::Path p0 = path_from_piecewise(offset_curve0, 0.1)[0];
+ Geom::Path p1 = path_from_piecewise(offset_curve1, 0.1)[0];
+ Geom::Crossings cs = Geom::crossings(p0, p1);
+ if(cs.size() > 0){
+ Point cp =p0(cs[0].ta);
+ double p0pt = nearest_point(cp, d2_out);
+ len = satellite.second.toSize(p0pt,d2_out);
+ } else {
+ if(A > 0){
+ len = rad_to_len(A * -1, satellite);
+ }
+ }
+ }
+ return len;
+}
+
+double
+Pointwise::len_to_rad(double A, std::pair<unsigned int,Geom::Satellite> satellite)
+{
+ boost::optional<Geom::D2<Geom::SBasis> > d2_in = getCurveIn(satellite);
+ if(d2_in){
+ Geom::D2<Geom::SBasis> d2_out = _pwd2[satellite.first];
+ double time_in = satellite.second.getOpositeTime(A, *d2_in);
+ double time_out = satellite.second.toTime(A,d2_out);
+ Geom::Point startArcPoint = (*d2_in).valueAt(time_in);
+ Geom::Point endArcPoint = d2_out.valueAt(time_out);
+ Piecewise<D2<SBasis> > u;
+ u.push_cut(0);
+ u.push((*d2_in), 1);
+ Geom::Curve * A = path_from_piecewise(u, 0.1)[0][0].duplicate();
+ Piecewise<D2<SBasis> > u2;
+ u2.push_cut(0);
+ u2.push((d2_out), 1);
+ Geom::Curve * B = path_from_piecewise(u2, 0.1)[0][0].duplicate();
+ Curve *knotCurve1 = A->portion(0, time_in);
+ Curve *knotCurve2 = B->portion(time_out, 1);
+ Geom::CubicBezier const *cubic1 = dynamic_cast<Geom::CubicBezier const *>(&*knotCurve1);
+ Ray ray1(startArcPoint, (*d2_in).valueAt(1));
+ if (cubic1) {
+ ray1.setPoints((*cubic1)[2], startArcPoint);
+ }
+ Geom::CubicBezier const *cubic2 = dynamic_cast<Geom::CubicBezier const *>(&*knotCurve2);
+ Ray ray2(d2_out.valueAt(0), endArcPoint);
+ if (cubic2) {
+ ray2.setPoints(endArcPoint, (*cubic2)[1]);
+ }
+ bool ccwToggle = cross((*d2_in).valueAt(1) - startArcPoint, endArcPoint - startArcPoint) < 0;
+ double distanceArc = Geom::distance(startArcPoint,middle_point(startArcPoint,endArcPoint));
+ double angleBetween = angle_between(ray1, ray2, ccwToggle);
+ double divisor = std::sin(angleBetween/2.0);
+ if(divisor > 0){
+ return distanceArc/divisor;
+ }
+ }
+ return 0;
+}
+
boost::optional<Geom::D2<Geom::SBasis> >
-Pointwise::getCurveIn(std::pair<int,Satellite> sat){
+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));
- int counterTotal = 0;
+ 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()){
continue;
@@ -85,7 +154,7 @@ Pointwise::getCurveIn(std::pair<int,Satellite> sat){
}
Geom::Path::const_iterator curve_end = curve_endit;
--curve_end;
- int counter = 0;
+ unsigned int counter = 0;
while (curve_it1 != curve_endit) {
if(counterTotal == sat.first){
if (counter==0) {
@@ -107,7 +176,7 @@ Pointwise::getCurveIn(std::pair<int,Satellite> sat){
}
std::vector<Satellite>
-Pointwise::findSatellites(int A, int B) const
+Pointwise::findSatellites(unsigned int A, int B) const
{
std::vector<Satellite> ret;
int counter = 0;
@@ -124,7 +193,7 @@ Pointwise::findSatellites(int A, int B) const
}
std::vector<Satellite>
-Pointwise::findClosingSatellites(int A) const
+Pointwise::findClosingSatellites(unsigned int A) const
{
std::vector<Satellite> ret;
bool finded = false;
@@ -143,7 +212,7 @@ Pointwise::findClosingSatellites(int A) const
}
std::vector<Satellite>
-Pointwise::findPeviousSatellites(int A, int B) const
+Pointwise::findPeviousSatellites(unsigned int A, int B) const
{
std::vector<Satellite> ret;
for(unsigned i = 0; i < _satellites.size(); i++){
diff --git a/src/2geom/pointwise.h b/src/2geom/pointwise.h
index aa907d498..b6bd4c4fd 100644
--- a/src/2geom/pointwise.h
+++ b/src/2geom/pointwise.h
@@ -64,29 +64,32 @@ class Pointwise
{
public:
Pointwise(){};
- Pointwise(Piecewise<D2<SBasis> > pwd2, std::vector<std::pair<int,Satellite> > satellites);
+ Pointwise(Piecewise<D2<SBasis> > pwd2, std::vector<std::pair<unsigned int,Satellite> > satellites);
virtual ~Pointwise();
- std::vector<Satellite> findSatellites(int A, int B = -1) const;
- std::vector<Satellite> findPeviousSatellites(int A, int B) const;
- std::vector<Satellite> findClosingSatellites(int A) const;
- std::vector<std::pair<int,Satellite> > getSatellites();
- void setSatellites(std::vector<std::pair<int,Satellite> > sat);
+ std::vector<Satellite> findSatellites(unsigned int A, int B = -1) const;
+ std::vector<Satellite> findPeviousSatellites(unsigned int A, int B) const;
+ std::vector<Satellite> findClosingSatellites(unsigned int A) const;
+ double rad_to_len(double A, std::pair<unsigned int,Geom::Satellite> satellite);
+ double len_to_rad(double A, std::pair<unsigned int,Geom::Satellite> satellite);
+ std::vector<std::pair<unsigned int,Satellite> > getSatellites();
+ void setSatellites(std::vector<std::pair<unsigned int,Satellite> > sat);
Piecewise<D2<SBasis> > getPwd2();
void setPwd2(Piecewise<D2<SBasis> > pwd2_in);
- boost::optional<Geom::D2<Geom::SBasis> > getCurveIn(std::pair<int,Satellite> sat);
+ boost::optional<Geom::D2<Geom::SBasis> > getCurveIn(std::pair<unsigned int,Satellite> sat);
Pointwise recalculate_for_new_pwd2(Piecewise<D2<SBasis> > A);
+ /*
Pointwise pwd2_reverse(int index);
Pointwise pwd2_append(int index);
Pointwise pwd2_prepend(int index);
Pointwise pwd2_add(int index);
Pointwise pwd2_del(int index);
- Pointwise satellite_add(int index,Satellite sat);
- Pointwise satellite_del(int index,Satellite sat);
-
+ Pointwise satellite_add(unsigned int index,Satellite sat);
+ Pointwise satellite_del(unsigned int index,Satellite sat);
+ */
private:
Piecewise<D2<SBasis> > _pwd2;
- std::vector<std::pair<int,Satellite> > _satellites;
+ std::vector<std::pair<unsigned int,Satellite> > _satellites;
};
diff --git a/src/2geom/satellite.cpp b/src/2geom/satellite.cpp
index c216595dc..22c3c8bed 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)
- : _satellitetype(satellitetype), _isTime(isTime), _isClosing(isClosing), _isStart(isStart), _active(active), _hasMirror(hasMirror), _hidden(hidden), _ammount(ammount), _angle(angle){};
+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() {};
diff --git a/src/2geom/satellite.h b/src/2geom/satellite.h
index 48be13cc4..4b0797620 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);
+ Satellite(SatelliteType satellitetype, bool isTime, bool isClosing, bool isStart, bool active, bool hasMirror, bool hidden, double ammount, double angle, unsigned int steps);
virtual ~Satellite();
@@ -99,6 +99,11 @@ class Satellite
_angle = A;
}
+ void setSteps(int A)
+ {
+ _steps = A;
+ }
+
SatelliteType getSatelliteType() const
{
return _satellitetype;
@@ -150,6 +155,11 @@ class Satellite
return _angle;
}
+ int getSteps() const
+ {
+ return _steps;
+ }
+
void setPosition(Geom::Point p, Geom::D2<Geom::SBasis> d2_in);
Geom::Point getPosition(Geom::D2<Geom::SBasis> curve);
double getSize(Geom::D2<Geom::SBasis> d2_in);
@@ -169,6 +179,7 @@ class Satellite
bool _hidden;
double _ammount;
double _angle;
+ unsigned int _steps;
};
} // end namespace Geom
diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp
index 786945cd0..118a89ead 100644
--- a/src/live_effects/lpe-fillet-chamfer.cpp
+++ b/src/live_effects/lpe-fillet-chamfer.cpp
@@ -28,7 +28,6 @@
#include "helper/geom.h"
#include "display/curve.h"
#include "ui/tools-switch.h"
-#include <2geom/path-intersection.h>
#include <vector>
// TODO due to internal breakage in glibmm headers, this must be last:
#include <glibmm/i18n.h>
@@ -97,7 +96,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<int,Geom::Satellite> > satellites;
+ std::vector<std::pair<unsigned int,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,6 +118,7 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem)
Geom::Path::const_iterator curve_end = curve_endit;
--curve_end;
int counter = 0;
+ unsigned int steps = 0;
while (curve_it1 != curve_endit) {
bool isStart = false;
if(counter == 0){
@@ -135,7 +135,7 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem)
active = false;
}
}
- Satellite satellite(F, flexible, isClosing, isStart, active, mirror_knots, hidden, 0.0, 0.0);
+ Satellite satellite(F, flexible, isClosing, isStart, active, mirror_knots, hidden, 0.0, 0.0, steps);
satellites.push_back(std::make_pair(counterTotal, satellite));
++curve_it1;
counter++;
@@ -146,7 +146,7 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem)
bool isClosing = false;
bool isStart = false;
bool hidden = true;
- Satellite satellite(F, flexible, isClosing, isStart, active, mirror_knots, hidden, 0.0, 0.0);
+ Satellite satellite(F, flexible, isClosing, isStart, active, mirror_knots, hidden, 0.0, 0.0, steps);
satellites.push_back(std::make_pair(counterTotal, satellite));
}
}
@@ -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::updateFillet));
+ widgRegistered->signal_value_changed().connect(sigc::mem_fun(*this, &LPEFilletChamfer::updateAmmount));
widg = widgRegistered;
if (widg) {
Gtk::HBox *scalarParameter = dynamic_cast<Gtk::HBox *>(widg);
@@ -183,6 +183,16 @@ Gtk::Widget *LPEFilletChamfer::newWidget()
Gtk::Entry *entryWidg = dynamic_cast<Gtk::Entry *>(childList[1]);
entryWidg->set_width_chars(6);
}
+ } else if (param->param_key == "chamfer_steps") {
+ Inkscape::UI::Widget::Scalar *widgRegistered = Gtk::manage(dynamic_cast<Inkscape::UI::Widget::Scalar *>(widg));
+ widgRegistered->signal_value_changed().connect(sigc::mem_fun(*this, &LPEFilletChamfer::updateChamferSteps));
+ widg = widgRegistered;
+ if (widg) {
+ Gtk::HBox *scalarParameter = dynamic_cast<Gtk::HBox *>(widg);
+ std::vector<Gtk::Widget *> childList = scalarParameter->get_children();
+ Gtk::Entry *entryWidg = dynamic_cast<Gtk::Entry *>(childList[1]);
+ entryWidg->set_width_chars(3);
+ }
} else if (param->param_key == "helper_size") {
Inkscape::UI::Widget::Scalar *widgRegistered = Gtk::manage(dynamic_cast<Inkscape::UI::Widget::Scalar *>(widg));
widgRegistered->signal_value_changed().connect(sigc::mem_fun(*this, &LPEFilletChamfer::refreshKnots));
@@ -248,59 +258,6 @@ void LPEFilletChamfer::inverseChamfer()
updateSatelliteType(IC);
}
-/*
-double LPEFilletChamfer::len_to_rad(double A, std::pair<int,Geom::Satellite> satellite)
-{
- Piecewise<Geom::D2<Geom::SBasis> > pwd2 = pointwise->getPwd2();
- boost::optional<Geom::D2<Geom::SBasis> > d2_in = pointwise->getCurveIn(satellite);
- if(d2_in){
- Geom::D2<Geom::SBasis> d2_out = pwd2[satellite.first];
- double time_in = satellite.second.getOpositeTime(A, *d2_in);
- double time_out = satellite.second.toTime(A,d2_out);
- Geom::Point startArcPoint = (*d2_in).valueAt(time_in);
- Geom::Point endArcPoint = d2_out.valueAt(time_out);
- Ray ray1(startArcPoint, (*d2_in).valueAt(1));
- Ray ray2(d2_out.valueAt(0), endArcPoint);
- bool ccwToggle = cross((*d2_in).valueAt(1) - startArcPoint, endArcPoint - startArcPoint) < 0;
- double distanceArc = Geom::distance(startArcPoint,middle_point(startArcPoint,endArcPoint));
- double angleBetween = angle_between(ray1, ray2, ccwToggle);
- return distanceArc/sin(angleBetween/2.0);
- }
- return 0;
-}
-*/
-
-double LPEFilletChamfer::rad_to_len(double A, std::pair<int,Geom::Satellite> satellite)
-{
- double len = 0;
- std::cout << A << "A\n";
- Piecewise<Geom::D2<Geom::SBasis> > pwd2 = pointwise->getPwd2();
- boost::optional<Geom::D2<Geom::SBasis> > d2_in = pointwise->getCurveIn(satellite);
- if(d2_in){
- std::cout << satellite.first << "satellite.first\n";
- std::cout << "d2in\n";
- Geom::D2<Geom::SBasis> d2_out = pwd2[satellite.first];
- Piecewise<D2<SBasis> > offset_curve0 = Piecewise<D2<SBasis> >(*d2_in)+rot90(unitVector(derivative(*d2_in)))*(A);
- Piecewise<D2<SBasis> > offset_curve1 = Piecewise<D2<SBasis> >(d2_out)+rot90(unitVector(derivative(d2_out)))*(A);
- Geom::Path p0 = path_from_piecewise(offset_curve0, 0.1)[0];
- Geom::Path p1 = path_from_piecewise(offset_curve1, 0.1)[0];
- Geom::Crossings cs = Geom::crossings(p0, p1);
- if(cs.size() > 0){
- Point cp =p0(cs[0].ta);
- std::cout << cp << "cp\n";
- double p0pt = nearest_point(cp, d2_out);
- len = satellite.second.toSize(p0pt,d2_out);
- } else {
- if(A > 0){
- len = rad_to_len(A * -1, satellite);
- }
- }
- std::cout << len << "len\n";
- }
- return len;
-}
-
-
void LPEFilletChamfer::refreshKnots()
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
@@ -310,7 +267,7 @@ void LPEFilletChamfer::refreshKnots()
}
}
-void LPEFilletChamfer::updateFillet()
+void LPEFilletChamfer::updateAmmount()
{
double power = 0;
if (!flexible) {
@@ -318,9 +275,9 @@ void LPEFilletChamfer::updateFillet()
} else {
power = radius/100;
}
- std::vector<std::pair<int,Geom::Satellite> > satellites = pointwise->getSatellites();
+ std::vector<std::pair<unsigned int,Geom::Satellite> > satellites = pointwise->getSatellites();
Piecewise<D2<SBasis> > pwd2 = pointwise->getPwd2();
- for (std::vector<std::pair<int,Geom::Satellite> >::iterator it = satellites.begin(); it != satellites.end(); ++it) {
+ 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);
continue;
@@ -332,14 +289,14 @@ void LPEFilletChamfer::updateFillet()
Geom::Point satPoint = pwd2.valueAt(it->first);
if(isNodePointSelected(satPoint)){
if(!use_knot_distance && !flexible){
- it->second.setAmmount(rad_to_len(power,*it));
+ it->second.setAmmount(pointwise->rad_to_len(power,*it));
} else {
it->second.setAmmount(power);
}
}
} else {
if(!use_knot_distance && !flexible){
- it->second.setAmmount(rad_to_len(power,*it));
+ it->second.setAmmount(pointwise->rad_to_len(power,*it));
} else {
it->second.setAmmount(power);
}
@@ -349,11 +306,32 @@ void LPEFilletChamfer::updateFillet()
satellitepairarrayparam_values.param_set_and_write_new_value(satellites);
}
+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){
+ continue;
+ }
+ if(only_selected){
+ Geom::Point satPoint = pwd2.valueAt(it->first);
+ if(isNodePointSelected(satPoint)){
+ it->second.setSteps(chamfer_steps);
+ }
+ } else {
+ it->second.setSteps(chamfer_steps);
+ }
+ }
+ pointwise->setSatellites(satellites);
+ satellitepairarrayparam_values.param_set_and_write_new_value(satellites);
+}
+
void LPEFilletChamfer::updateSatelliteType(Geom::SatelliteType satellitetype)
{
- std::vector<std::pair<int,Geom::Satellite> > satellites = pointwise->getSatellites();
+ std::vector<std::pair<unsigned int,Geom::Satellite> > satellites = pointwise->getSatellites();
Piecewise<D2<SBasis> > pwd2 = pointwise->getPwd2();
- for (std::vector<std::pair<int,Geom::Satellite> >::iterator it = satellites.begin(); it != satellites.end(); ++it) {
+ 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){
continue;
}
@@ -383,7 +361,7 @@ 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(pathv_to_linear_and_cubic_beziers(original_pathv));
pwd2_in = remove_short_cuts(pwd2_in, 0.01);
- std::vector<std::pair<int,Geom::Satellite> > satellites = satellitepairarrayparam_values.data();
+ std::vector<std::pair<unsigned int,Geom::Satellite> > satellites = satellitepairarrayparam_values.data();
pointwise = new Pointwise(pwd2_in,satellites);
satellitepairarrayparam_values.set_pointwise(pointwise);
if(hide_knots){
@@ -391,9 +369,12 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem)
} 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<int,Geom::Satellite> >::iterator it = satellites.begin(); it != satellites.end(); ++it) {
+ 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();
@@ -574,6 +555,10 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in)
}
}
SatelliteType type = satellite.getSatelliteType();
+ unsigned int steps = satellite.getSteps();
+ if(steps < 1){
+ steps = 1;
+ }
if (type == C) {
Geom::Path path_chamfer;
path_chamfer.start(path_out.finalPoint());
@@ -582,8 +567,8 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in)
} else {
path_chamfer.appendNew<Geom::CubicBezier>(handle1, handle2, endArcPoint);
}
- double chamfer_stepsTime = 1.0/chamfer_steps;
- for(unsigned int i = 1; i < chamfer_steps; i++){
+ double chamfer_stepsTime = 1.0/steps;
+ for(unsigned int i = 1; i < steps; i++){
Geom::Point chamferStep = path_chamfer.pointAt(chamfer_stepsTime * i);
path_out.appendNew<Geom::LineSegment>(chamferStep);
}
@@ -597,8 +582,8 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in)
}else{
path_chamfer.appendNew<Geom::CubicBezier>(inverseHandle1, inverseHandle2, endArcPoint);
}
- double chamfer_stepsTime = 1.0/chamfer_steps;
- for(unsigned int i = 1; i < chamfer_steps; i++){
+ double chamfer_stepsTime = 1.0/steps;
+ for(unsigned int 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/lpe-fillet-chamfer.h b/src/live_effects/lpe-fillet-chamfer.h
index c194d2edd..56db6305e 100644
--- a/src/live_effects/lpe-fillet-chamfer.h
+++ b/src/live_effects/lpe-fillet-chamfer.h
@@ -40,9 +40,9 @@ public:
virtual void adjustForNewPath(std::vector<Geom::Path> const &path_in);
virtual Gtk::Widget* newWidget();
/*double len_to_rad(double A, std::pair<int,Geom::Satellite> sat);*/
- double rad_to_len(double A, std::pair<int,Geom::Satellite> satellite);
void updateSatelliteType(Geom::SatelliteType satellitetype);
- void updateFillet();
+ void updateChamferSteps();
+ void updateAmmount();
void refreshKnots();
void chamfer();
void inverseChamfer();
diff --git a/src/live_effects/parameter/array.cpp b/src/live_effects/parameter/array.cpp
index c00cdd8da..e4c480d93 100644
--- a/src/live_effects/parameter/array.cpp
+++ b/src/live_effects/parameter/array.cpp
@@ -54,7 +54,7 @@ sp_svg_satellite_read_d(gchar const *str, Geom::Satellite *sat){
return 0;
}
gchar ** strarray = g_strsplit(str, "*", 0);
- if(strarray[8] && !strarray[9]){
+ if(strarray[9] && !strarray[10]){
sat->setSatelliteType(strarray[0]);
sat->setIsTime(strncmp(strarray[1],"1",1) == 0);
sat->setIsClosing(strncmp(strarray[2],"1",1) == 0);
@@ -63,10 +63,14 @@ sp_svg_satellite_read_d(gchar const *str, Geom::Satellite *sat){
sat->setHasMirror(strncmp(strarray[5],"1",1) == 0);
sat->setHidden(strncmp(strarray[6],"1",1) == 0);
double ammount,angle;
+ float stepsTmp;
sp_svg_number_read_d(strarray[7], &ammount);
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->setAngle(angle);
+ sat->setSteps(steps);
g_strfreev (strarray);
return 1;
}
@@ -75,12 +79,12 @@ sp_svg_satellite_read_d(gchar const *str, Geom::Satellite *sat){
}
template <>
-std::pair<int, Geom::Satellite>
-ArrayParam<std::pair<int, Geom::Satellite> >::readsvg(const gchar * str)
+std::pair<unsigned int, Geom::Satellite>
+ArrayParam<std::pair<unsigned int, Geom::Satellite> >::readsvg(const gchar * str)
{
gchar ** strarray = g_strsplit(str, ",", 2);
double index;
- std::pair<int, Geom::Satellite> result;
+ std::pair<unsigned int, 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);
diff --git a/src/live_effects/parameter/array.h b/src/live_effects/parameter/array.h
index 0be155f50..d28576fce 100644
--- a/src/live_effects/parameter/array.h
+++ b/src/live_effects/parameter/array.h
@@ -112,7 +112,7 @@ protected:
str << nVector;
}
- void writesvgData(SVGOStringStream &str, std::pair<int, Geom::Satellite> const &nVector) const {
+ void writesvgData(SVGOStringStream &str, std::pair<unsigned int, Geom::Satellite> const &nVector) const {
str << nVector.first;
str << ",";
str << nVector.second.getSatelliteTypeGchar();
@@ -132,6 +132,8 @@ protected:
str << nVector.second.getAmmount();
str << "*";
str << nVector.second.getAngle();
+ str << "*";
+ str << nVector.second.getSteps();
}
StorageType readsvg(const gchar * str);
diff --git a/src/live_effects/parameter/satellitepairarray.cpp b/src/live_effects/parameter/satellitepairarray.cpp
index 72a666dc2..ffd04e14c 100644
--- a/src/live_effects/parameter/satellitepairarray.cpp
+++ b/src/live_effects/parameter/satellitepairarray.cpp
@@ -9,6 +9,7 @@
*/
#include "knotholder.h"
+#include "ui/dialog/lpe-fillet-chamfer-properties.h"
#include "live_effects/parameter/satellitepairarray.h"
#include "sp-lpe-item.h"
// TODO due to internal breakage in glibmm headers,
@@ -26,18 +27,14 @@ SatellitePairArrayParam::SatellitePairArrayParam(
const Glib::ustring &label, const Glib::ustring &tip,
const Glib::ustring &key, Inkscape::UI::Widget::Registry *wr,
Effect *effect)
- : ArrayParam<std::pair<int,Geom::Satellite> >(label, tip, key, wr, effect, 0)
+ : ArrayParam<std::pair<unsigned int,Geom::Satellite> >(label, tip, key, wr, effect, 0)
{
knot_shape = SP_KNOT_SHAPE_DIAMOND;
knot_mode = SP_KNOT_MODE_XOR;
knot_color = 0x00ff0000;
- /*
- std::vector<std::pair<int,Geom::Satellite> > satellites;
- Geom::Path path;
- path.start(Geom::Point(0,0));
- path.appendNew<Geom::LineSegment>(Geom::Point(0,1));
- last_pointwise = new Pointwise(path.toPwSb(),satellites);
- */
+ helper_size = 0;
+ use_distance = false;
+
last_pointwise = NULL;
}
@@ -57,6 +54,21 @@ void SatellitePairArrayParam::set_pointwise(Geom::Pointwise *pointwise)
last_pointwise = pointwise;
}
+void SatellitePairArrayParam::set_document_unit(Glib::ustring const * value_document_unit)
+{
+ documentUnit = value_document_unit;
+}
+
+void SatellitePairArrayParam::set_use_distance(bool use_knot_distance )
+{
+ use_distance = use_knot_distance;
+}
+
+void SatellitePairArrayParam::set_unit(const gchar *abbr)
+{
+ unit = abbr;
+}
+
void SatellitePairArrayParam::set_helper_size(int hs)
{
helper_size = hs;
@@ -73,7 +85,7 @@ void SatellitePairArrayParam::updateCanvasIndicators()
continue;
}
double pos = 0;
- if(pwd2.size() <= _vector[i].first){
+ if(pwd2.size() <= (unsigned)_vector[i].first){
break;
}
Geom::D2<Geom::SBasis> d2 = pwd2[_vector[i].first];
@@ -136,10 +148,26 @@ void SatellitePairArrayParam::addKnotHolderEntities(KnotHolder *knotholder,
if(_vector[i].second.getHasMirror()){
addKnotHolderEntitieMirrored(knotholder, desktop, item, i);
}
+ using namespace Geom;
+ SatelliteType type = _vector[i].second.getSatelliteType();
const gchar *tip;
- tip = _("<b>Fillet</b>: <b>Ctrl+Click</b> toggle type, "
- "<b>Shift+Click</b> open dialog, "
- "<b>Ctrl+Alt+Click</b> reset");
+ 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);
e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _(tip),
@@ -152,8 +180,26 @@ void SatellitePairArrayParam::addKnotHolderEntitieMirrored(KnotHolder *knotholde
SPDesktop *desktop,
SPItem *item, int i)
{
+ using namespace Geom;
+ SatelliteType type = _vector[i].second.getSatelliteType();
const gchar *tip;
- tip = _("<b>Mirror</b> ppp");
+ 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),
@@ -257,6 +303,95 @@ SatellitePairArrayParamKnotHolderEntity::knot_get() const
}
+void SatellitePairArrayParamKnotHolderEntity::knot_click(guint state)
+{
+ 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->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.at(index).second.getSatelliteType();
+ switch(type){
+ case F:
+ type = IF;
+ break;
+ case IF:
+ type = C;
+ break;
+ case C:
+ type = IC;
+ break;
+ default:
+ type = F;
+ break;
+ }
+ _pparam->_vector.at(index).second.setSatelliteType(type);
+ _pparam->param_set_and_write_new_value(_pparam->_vector);
+ sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false);
+ 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");
+ }
+ this->knot->tip = g_strdup(tip);
+ this->knot->show();
+ }
+ } else if (state & GDK_SHIFT_MASK) {
+ double ammount = _pparam->_vector.at(index).second.getAmmount();
+ if(!_pparam->use_distance && !_pparam->_vector.at(index).second.getIsTime()){
+ ammount = _pparam->last_pointwise->len_to_rad(ammount, _pparam->_vector.at(index));
+ }
+ boost::optional<Geom::D2<Geom::SBasis> > d2_in = _pparam->last_pointwise->getCurveIn(_pparam->_vector.at(index));
+ bool aprox = false;
+ D2<SBasis> d2_out = _pparam->last_pointwise->getPwd2()[index];
+ if(d2_in){
+ 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);
+
+ }
+}
+
+void SatellitePairArrayParamKnotHolderEntity::knot_set_offset(Geom::Satellite satellite)
+{
+ int index = _index;
+ if( _index >= _pparam->_vector.size()){
+ index = _index-_pparam->_vector.size();
+ }
+ double ammount = satellite.getAmmount();
+ if(!_pparam->use_distance && !satellite.getIsTime()){
+ ammount = _pparam->last_pointwise->rad_to_len(ammount, _pparam->_vector.at(index));
+ }
+ satellite.setAmmount(ammount);
+ _pparam->_vector.at(index).second = satellite;
+ this->parent_holder->knot_ungrabbed_handler(this->knot, 0);
+ _pparam->param_set_and_write_new_value(_pparam->_vector);
+ SPLPEItem * splpeitem = dynamic_cast<SPLPEItem *>(item);
+ if(splpeitem){
+ sp_lpe_item_update_patheffect(splpeitem, false, false);
+ }
+}
+
} /* namespace LivePathEffect */
} /* namespace Inkscape */
diff --git a/src/live_effects/parameter/satellitepairarray.h b/src/live_effects/parameter/satellitepairarray.h
index 1ecc1fee6..21fb0fbd8 100644
--- a/src/live_effects/parameter/satellitepairarray.h
+++ b/src/live_effects/parameter/satellitepairarray.h
@@ -29,7 +29,7 @@ namespace LivePathEffect {
class SatellitePairArrayParamKnotHolderEntity;
-class SatellitePairArrayParam : public ArrayParam<std::pair<int, Geom::Satellite> > {
+class SatellitePairArrayParam : public ArrayParam<std::pair<unsigned int, Geom::Satellite> > {
public:
SatellitePairArrayParam(const Glib::ustring &label,
const Glib::ustring &tip,
@@ -51,6 +51,9 @@ public:
virtual bool providesKnotHolderEntities() const {
return true;
}
+ void set_document_unit(Glib::ustring const * value_document_unit);
+ void set_use_distance(bool use_knot_distance );
+ void set_unit(const gchar *abbr);
virtual void updateCanvasIndicators();
void set_pointwise(Geom::Pointwise *pointwise);
friend class SatellitePairArrayParamKnotHolderEntity;
@@ -64,7 +67,9 @@ private:
guint32 knot_color;
Geom::PathVector hp;
int helper_size;
-
+ bool use_distance;
+ const gchar *unit;
+ Glib::ustring const * documentUnit;
Geom::Pointwise *last_pointwise;
};
@@ -76,7 +81,8 @@ public:
virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state);
virtual Geom::Point knot_get() const;
-
+ 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 {
return (_pparam->_vector.size() > index);
diff --git a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp
index e69de29bb..fe0deba57 100644
--- a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp
+++ b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp
@@ -0,0 +1,313 @@
+/**
+ * From the code of Liam P.White from his Power Stroke Knot dialog
+ *
+ * Released under GNU GPL. Read the file 'COPYING' for more information
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if GLIBMM_DISABLE_DEPRECATED &&HAVE_GLIBMM_THREADS_H
+#include <glibmm/threads.h>
+#endif
+
+#include <gtkmm.h>
+#include "lpe-fillet-chamfer-properties.h"
+#include <boost/lexical_cast.hpp>
+#include <glibmm/main.h>
+#include <glibmm/i18n.h>
+#include "inkscape.h"
+#include "desktop.h"
+#include "document.h"
+#include "document-undo.h"
+#include "layer-manager.h"
+#include "message-stack.h"
+
+#include "sp-object.h"
+#include "sp-item.h"
+#include "verbs.h"
+#include "selection.h"
+#include "selection-chemistry.h"
+#include "ui/icon-names.h"
+#include "ui/widget/imagetoggler.h"
+#include "util/units.h"
+#include <cmath>
+
+//#include "event-context.h"
+
+namespace Inkscape {
+namespace UI {
+namespace Dialogs {
+
+FilletChamferPropertiesDialog::FilletChamferPropertiesDialog()
+ : _desktop(NULL), _knotpoint(NULL), _position_visible(false)
+{
+ Gtk::Box *mainVBox = get_vbox();
+ mainVBox->set_homogeneous(false);
+ _layout_table.set_spacings(4);
+ _layout_table.resize(3, 3);
+
+ // Layer name widgets
+ _fillet_chamfer_position_numeric.set_digits(4);
+ _fillet_chamfer_position_numeric.set_increments(1,1);
+ //todo: get tha max aloable infinity freeze the widget
+ _fillet_chamfer_position_numeric.set_range(0., 999999999999999999.);
+
+ _fillet_chamfer_position_label.set_label(_("Radius (pixels):"));
+ _fillet_chamfer_position_label.set_alignment(1.0, 0.5);
+
+ _layout_table.attach(_fillet_chamfer_position_label, 0, 1, 0, 1, Gtk::FILL,
+ Gtk::FILL);
+ _layout_table.attach(_fillet_chamfer_position_numeric, 1, 2, 0, 1,
+ Gtk::FILL | Gtk::EXPAND, Gtk::FILL);
+ _fillet_chamfer_chamfer_subdivisions.set_digits(0);
+ _fillet_chamfer_chamfer_subdivisions.set_increments(1,1);
+ //todo: get tha max aloable infinity freeze the widget
+ _fillet_chamfer_chamfer_subdivisions.set_range(1, 4294967295);
+
+ _fillet_chamfer_chamfer_subdivisions_label.set_label(_("Chamfer subdivisions:"));
+ _fillet_chamfer_chamfer_subdivisions_label.set_alignment(1.0, 0.5);
+
+ _layout_table.attach(_fillet_chamfer_chamfer_subdivisions_label, 0, 1, 1, 2, Gtk::FILL,
+ Gtk::FILL);
+ _layout_table.attach(_fillet_chamfer_chamfer_subdivisions, 1, 2, 1, 2,
+ Gtk::FILL | Gtk::EXPAND, Gtk::FILL);
+ _fillet_chamfer_type_fillet.set_label(_("Fillet"));
+ _fillet_chamfer_type_fillet.set_group(_fillet_chamfer_type_group);
+ _fillet_chamfer_type_inverse_fillet.set_label(_("Inverse fillet"));
+ _fillet_chamfer_type_inverse_fillet.set_group(_fillet_chamfer_type_group);
+ _fillet_chamfer_type_chamfer.set_label(_("Chamfer"));
+ _fillet_chamfer_type_chamfer.set_group(_fillet_chamfer_type_group);
+ _fillet_chamfer_type_inverse_chamfer.set_label(_("Inverse chamfer"));
+ _fillet_chamfer_type_inverse_chamfer.set_group(_fillet_chamfer_type_group);
+
+
+ mainVBox->pack_start(_layout_table, true, true, 4);
+ mainVBox->pack_start(_fillet_chamfer_type_fillet, true, true, 4);
+ mainVBox->pack_start(_fillet_chamfer_type_inverse_fillet, true, true, 4);
+ mainVBox->pack_start(_fillet_chamfer_type_chamfer, true, true, 4);
+ mainVBox->pack_start(_fillet_chamfer_type_inverse_chamfer, true, true, 4);
+
+ // Buttons
+ _close_button.set_use_stock(true);
+ _close_button.set_label(Gtk::Stock::CANCEL.id);
+ _close_button.set_can_default();
+
+ _apply_button.set_use_underline(true);
+ _apply_button.set_can_default();
+
+ _close_button.signal_clicked()
+ .connect(sigc::mem_fun(*this, &FilletChamferPropertiesDialog::_close));
+ _apply_button.signal_clicked()
+ .connect(sigc::mem_fun(*this, &FilletChamferPropertiesDialog::_apply));
+
+ signal_delete_event().connect(sigc::bind_return(
+ sigc::hide(sigc::mem_fun(*this, &FilletChamferPropertiesDialog::_close)),
+ true));
+
+ add_action_widget(_close_button, Gtk::RESPONSE_CLOSE);
+ add_action_widget(_apply_button, Gtk::RESPONSE_APPLY);
+
+ _apply_button.grab_default();
+
+ show_all_children();
+
+ set_focus(_fillet_chamfer_position_numeric);
+}
+
+FilletChamferPropertiesDialog::~FilletChamferPropertiesDialog()
+{
+
+ _set_desktop(NULL);
+}
+
+void FilletChamferPropertiesDialog::showDialog(
+ SPDesktop *desktop, double ammount,
+ const Inkscape::LivePathEffect::
+ SatellitePairArrayParamKnotHolderEntity *pt,
+ const gchar *unit,
+ bool use_distance,
+ bool aprox_radius,
+ Glib::ustring const * documentUnit,
+ Geom::Satellite satellite)
+{
+ FilletChamferPropertiesDialog *dialog = new FilletChamferPropertiesDialog();
+
+ dialog->_set_desktop(desktop);
+ dialog->_set_unit(unit);
+ dialog->_set_use_distance(use_distance);
+ dialog->_set_aprox(aprox_radius);
+ dialog->_set_document_unit(documentUnit);
+ dialog->_set_ammount(ammount);
+ dialog->_set_satellite(satellite);
+ dialog->_set_pt(pt);
+
+ dialog->set_title(_("Modify Fillet-Chamfer"));
+ dialog->_apply_button.set_label(_("_Modify"));
+
+ dialog->set_modal(true);
+ desktop->setWindowTransient(dialog->gobj());
+ dialog->property_destroy_with_parent() = true;
+
+ dialog->show();
+ dialog->present();
+}
+
+void FilletChamferPropertiesDialog::_apply()
+{
+
+ double d_pos = _fillet_chamfer_position_numeric.get_value();
+ if (d_pos >= 0) {
+ if (_fillet_chamfer_type_fillet.get_active() == true) {
+ _satellite.setSatelliteType(Geom::F);
+ } else if (_fillet_chamfer_type_inverse_fillet.get_active() == true) {
+ _satellite.setSatelliteType(Geom::IF);
+ } else if (_fillet_chamfer_type_inverse_chamfer.get_active() == true) {
+ _satellite.setSatelliteType(Geom::IC);
+ } else {
+ _satellite.setSatelliteType(Geom::C);
+ }
+ if (_flexible) {
+ if (d_pos > 99.99999 || d_pos < 0) {
+ d_pos = 0;
+ }
+ d_pos = d_pos / 100;
+ } else {
+ d_pos = Inkscape::Util::Quantity::convert(d_pos, unit, *document_unit);
+ }
+ _satellite.setAmmount( d_pos);
+ unsigned int steps = (unsigned int)_fillet_chamfer_chamfer_subdivisions.get_value();
+ if(steps < 1){
+ steps = 1;
+ }
+ _satellite.setSteps(steps);
+ _knotpoint->knot_set_offset(_satellite);
+ }
+ _close();
+}
+
+void FilletChamferPropertiesDialog::_close()
+{
+ _set_desktop(NULL);
+ destroy_();
+ Glib::signal_idle().connect(
+ sigc::bind_return(
+ sigc::bind(sigc::ptr_fun(&::operator delete), this),
+ false
+ )
+ );
+}
+
+bool FilletChamferPropertiesDialog::_handleKeyEvent(GdkEventKey * /*event*/)
+{
+ return false;
+}
+
+void FilletChamferPropertiesDialog::_handleButtonEvent(GdkEventButton *event)
+{
+ if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1)) {
+ _apply();
+ }
+}
+
+void FilletChamferPropertiesDialog::_set_satellite(Geom::Satellite satellite)
+{
+ double position;
+ std::string distance_or_radius = std::string(_("Radius"));
+ if(aprox){
+ distance_or_radius = std::string(_("Radius approximated"));
+ }
+ if(use_distance){
+ distance_or_radius = std::string(_("Knot distance"));
+ }
+ if (satellite.getIsTime()) {
+ position = ammount * 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 = Inkscape::Util::Quantity::convert(position, *document_unit, unit);
+ }
+ _fillet_chamfer_position_numeric.set_value(position);
+ if (satellite.getSatelliteType() == Geom::F) {
+ _fillet_chamfer_type_fillet.set_active(true);
+ } else if (satellite.getSatelliteType() == Geom::IF) {
+ _fillet_chamfer_type_inverse_fillet.set_active(true);
+ } else if (satellite.getSatelliteType() == Geom::C) {
+ _fillet_chamfer_type_chamfer.set_active(true);
+ _fillet_chamfer_chamfer_subdivisions.set_value(satellite.getSteps());
+ } else if (satellite.getSatelliteType() == Geom::IC) {
+ _fillet_chamfer_type_inverse_chamfer.set_active(true);
+ _fillet_chamfer_chamfer_subdivisions.set_value(satellite.getSteps());
+ }
+ _satellite = satellite;
+}
+
+void FilletChamferPropertiesDialog::_set_pt(
+ const Inkscape::LivePathEffect::
+ SatellitePairArrayParamKnotHolderEntity *pt)
+{
+ _knotpoint = const_cast<
+ Inkscape::LivePathEffect::SatellitePairArrayParamKnotHolderEntity *>(
+ pt);
+}
+
+void FilletChamferPropertiesDialog::_set_unit(const gchar *abbr)
+{
+ unit = abbr;
+}
+
+void FilletChamferPropertiesDialog::_set_ammount(double amm)
+{
+ ammount = amm;
+}
+
+
+
+
+void FilletChamferPropertiesDialog::_set_document_unit(Glib::ustring const *abbr)
+{
+ document_unit = abbr;
+}
+
+void FilletChamferPropertiesDialog::_set_use_distance(bool use_knot_distance)
+{
+ use_distance = use_knot_distance;
+}
+
+void FilletChamferPropertiesDialog::_set_aprox(bool aprox_radius)
+{
+ aprox = aprox_radius;
+}
+
+void FilletChamferPropertiesDialog::_set_desktop(SPDesktop *desktop)
+{
+ if (desktop) {
+ Inkscape::GC::anchor(desktop);
+ }
+ if (_desktop) {
+ Inkscape::GC::release(_desktop);
+ }
+ _desktop = desktop;
+}
+
+} // namespace
+} // namespace
+} // namespace
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim:
+// filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99
+// :
diff --git a/src/ui/dialog/lpe-fillet-chamfer-properties.h b/src/ui/dialog/lpe-fillet-chamfer-properties.h
index e69de29bb..63215d17c 100644
--- a/src/ui/dialog/lpe-fillet-chamfer-properties.h
+++ b/src/ui/dialog/lpe-fillet-chamfer-properties.h
@@ -0,0 +1,118 @@
+/**
+ *
+ * From the code of Liam P.White from his Power Stroke Knot dialog
+ *
+ * Released under GNU GPL. Read the file 'COPYING' for more information
+ */
+
+#ifndef INKSCAPE_DIALOG_FILLET_CHAMFER_PROPERTIES_H
+#define INKSCAPE_DIALOG_FILLET_CHAMFER_PROPERTIES_H
+
+#include <2geom/point.h>
+#include <gtkmm.h>
+#include "live_effects/parameter/satellitepairarray.h"
+
+class SPDesktop;
+
+namespace Inkscape {
+namespace UI {
+namespace Dialogs {
+
+class FilletChamferPropertiesDialog : public Gtk::Dialog {
+public:
+ FilletChamferPropertiesDialog();
+ virtual ~FilletChamferPropertiesDialog();
+
+ Glib::ustring getName() const {
+ return "LayerPropertiesDialog";
+ }
+
+ static void showDialog(SPDesktop *desktop, double ammount,
+ const Inkscape::LivePathEffect::
+ SatellitePairArrayParamKnotHolderEntity *pt,
+ const gchar *unit,
+ bool use_distance,
+ bool aprox_radius,
+ Glib::ustring const * documentUnit,
+ Geom::Satellite satellite);
+
+protected:
+
+ SPDesktop *_desktop;
+ Inkscape::LivePathEffect::SatellitePairArrayParamKnotHolderEntity *
+ _knotpoint;
+
+ Gtk::Label _fillet_chamfer_position_label;
+ Gtk::SpinButton _fillet_chamfer_position_numeric;
+ Gtk::RadioButton::Group _fillet_chamfer_type_group;
+ Gtk::RadioButton _fillet_chamfer_type_fillet;
+ Gtk::RadioButton _fillet_chamfer_type_inverse_fillet;
+ Gtk::RadioButton _fillet_chamfer_type_chamfer;
+ Gtk::RadioButton _fillet_chamfer_type_inverse_chamfer;
+ Gtk::Label _fillet_chamfer_chamfer_subdivisions_label;
+ Gtk::SpinButton _fillet_chamfer_chamfer_subdivisions;
+
+ Gtk::Table _layout_table;
+ bool _position_visible;
+
+ Gtk::Button _close_button;
+ Gtk::Button _apply_button;
+
+ sigc::connection _destroy_connection;
+
+ static FilletChamferPropertiesDialog &_instance() {
+ static FilletChamferPropertiesDialog instance;
+ return instance;
+ }
+
+ void _set_desktop(SPDesktop *desktop);
+ void _set_pt(const Inkscape::LivePathEffect::
+ SatellitePairArrayParamKnotHolderEntity *pt);
+ void _set_unit(const gchar *abbr);
+ void _set_document_unit(Glib::ustring const * abbr);
+ void _set_use_distance(bool use_knot_distance);
+ void _set_aprox(bool aprox_radius);
+ void _apply();
+ void _close();
+ bool _flexible;
+ Geom::Satellite _satellite;
+ const gchar *unit;
+ Glib::ustring const * document_unit;
+ bool use_distance;
+ double ammount;
+ bool aprox;
+ void _set_ammount(double ammount);
+ void _set_satellite(Geom::Satellite satellite);
+ void _prepareLabelRenderer(Gtk::TreeModel::const_iterator const &row);
+
+ bool _handleKeyEvent(GdkEventKey *event);
+ void _handleButtonEvent(GdkEventButton *event);
+
+ friend class Inkscape::LivePathEffect::
+ SatellitePairArrayParamKnotHolderEntity;
+
+private:
+ FilletChamferPropertiesDialog(
+ FilletChamferPropertiesDialog const &); // no copy
+ FilletChamferPropertiesDialog &operator=(
+ FilletChamferPropertiesDialog const &); // no assign
+};
+
+} // namespace
+} // namespace
+} // namespace
+
+#endif //INKSCAPE_DIALOG_LAYER_PROPERTIES_H
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim:
+// filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99
+// :