summaryrefslogtreecommitdiffstats
path: root/src/live_effects/lpe-fillet-chamfer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/live_effects/lpe-fillet-chamfer.cpp')
-rw-r--r--src/live_effects/lpe-fillet-chamfer.cpp66
1 files changed, 30 insertions, 36 deletions
diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp
index 802340698..a8e2ea6b8 100644
--- a/src/live_effects/lpe-fillet-chamfer.cpp
+++ b/src/live_effects/lpe-fillet-chamfer.cpp
@@ -58,6 +58,7 @@ LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject) :
use_knot_distance(_("Use knots distance instead radius"), _("Use knots distance instead radius"), "use_knot_distance", &wr, this, false),
hide_knots(_("Hide knots"), _("Hide knots"), "hide_knots", &wr, this, false),
ignore_radius_0(_("Ignore 0 radius knots"), _("Ignore 0 radius knots"), "ignore_radius_0", &wr, this, false),
+ helper_size(_("Helper size with direction:"), _("Helper size with direction"), "helper_size", &wr, this, 0),
pointwise()
{
registerParameter(&satellitepairarrayparam_values);
@@ -65,6 +66,7 @@ LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject) :
registerParameter(&method);
registerParameter(&radius);
registerParameter(&chamfer_steps);
+ registerParameter(&helper_size);
registerParameter(&flexible);
registerParameter(&use_knot_distance);
registerParameter(&mirror_knots);
@@ -78,6 +80,9 @@ 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_increments(5, 5);
+ helper_size.param_set_digits(0);
}
LPEFilletChamfer::~LPEFilletChamfer() {}
@@ -126,8 +131,7 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem)
bool active = true;
bool hidden = false;
if (counter==0) {
- if (path_it->closed()) {
- } else {
+ if (!path_it->closed()) {
active = false;
}
}
@@ -179,27 +183,12 @@ 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::chamferSubdivisions));
- 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));
- */
} else if (param->param_key == "only_selected") {
Gtk::manage(widg);
- }/* else if (param->param_key == "ignore_radius_0") {
- Gtk::manage(widg);
}
- */
Glib::ustring *tip = param->param_getTooltip();
if (widg) {
vbox->pack_start(*widg, true, true, 2);
@@ -211,7 +200,6 @@ Gtk::Widget *LPEFilletChamfer::newWidget()
}
}
}
-
++it;
}
@@ -285,24 +273,25 @@ double LPEFilletChamfer::len_to_rad(double A, std::pair<int,Geom::Satellite> sa
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_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;
}
@@ -328,21 +317,27 @@ void LPEFilletChamfer::updateFillet()
std::vector<std::pair<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) {
+ if(pointwise->findClosingSatellites(it->first).size() == 0 && it->second.getIsStart()){
+ it->second.setAmmount(0);
+ continue;
+ }
if(ignore_radius_0 && it->second.getAmmount() == 0){
continue;
}
if(only_selected){
Geom::Point satPoint = pwd2.valueAt(it->first);
if(isNodePointSelected(satPoint)){
- it->second.setAmmount(power);
- }
- if(!use_knot_distance && !flexible){
- it->second.setAmmount(rad_to_len(power,*it));
+ if(!use_knot_distance && !flexible){
+ it->second.setAmmount(rad_to_len(power,*it));
+ } else {
+ it->second.setAmmount(power);
+ }
}
} else {
- it->second.setAmmount(power);
if(!use_knot_distance && !flexible){
it->second.setAmmount(rad_to_len(power,*it));
+ } else {
+ it->second.setAmmount(power);
}
}
}
@@ -384,12 +379,14 @@ 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);
- //wating to recalculate
- //recalculate_controlpoints_for_new_pwd2(pwd2_in);
std::vector<std::pair<int,Geom::Satellite> > satellites = satellitepairarrayparam_values.data();
- pointwise->setPwd2(pwd2_in);
- pointwise->setSatellites(satellites);
+ pointwise = new Pointwise(pwd2_in,satellites);
satellitepairarrayparam_values.set_pointwise(pointwise);
+ if(hide_knots){
+ satellitepairarrayparam_values.set_helper_size(0);
+ } else {
+ satellitepairarrayparam_values.set_helper_size(helper_size);
+ }
bool changed = false;
bool refresh = false;
for (std::vector<std::pair<int,Geom::Satellite> >::iterator it = satellites.begin(); it != satellites.end(); ++it) {
@@ -491,10 +488,7 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in)
}
bool last = curve_it2 == curve_endit;
- double s = satellite.getAmmount();
- if(satellite.getIsTime()){
- s = satellite.toSize(s, curve_it2Fixed->toSBasis());
- }
+ double s = satellite.getSize(curve_it2Fixed->toSBasis());
double time1 = satellite.getOpositeTime(s,(*curve_it1).toSBasis());
double time2 = satellite.getTime(curve_it2Fixed->toSBasis());
if(time1 <= time0){