summaryrefslogtreecommitdiffstats
path: root/src/live_effects
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/live_effects
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/live_effects')
-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
6 files changed, 226 insertions, 94 deletions
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);