summaryrefslogtreecommitdiffstats
path: root/src/live_effects/lpe-simplify.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2016-03-15 21:57:03 +0000
committerJabiertxof <jtx@jtx.marker.es>2016-03-15 21:57:03 +0000
commit6bd1c2a30b66e15fe055b22bd47dadb771f7fae2 (patch)
tree1b991cc2736f84fb069666802d485bd29cff6394 /src/live_effects/lpe-simplify.cpp
parentUpdate to limit options to radius = 0, radious > 0 or both (diff)
parentfix-bug-1557192. paint-order crash with multiple items (diff)
downloadinkscape-6bd1c2a30b66e15fe055b22bd47dadb771f7fae2.tar.gz
inkscape-6bd1c2a30b66e15fe055b22bd47dadb771f7fae2.zip
Update to trunk
(bzr r13645.1.119)
Diffstat (limited to 'src/live_effects/lpe-simplify.cpp')
-rw-r--r--src/live_effects/lpe-simplify.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/live_effects/lpe-simplify.cpp b/src/live_effects/lpe-simplify.cpp
index f6842a030..f807bdc8d 100644
--- a/src/live_effects/lpe-simplify.cpp
+++ b/src/live_effects/lpe-simplify.cpp
@@ -28,8 +28,8 @@ namespace LivePathEffect {
LPESimplify::LPESimplify(LivePathEffectObject *lpeobject)
: Effect(lpeobject),
steps(_("Steps:"),_("Change number of simplify steps "), "steps", &wr, this,1),
- threshold(_("Roughly threshold:"), _("Roughly threshold:"), "threshold", &wr, this, 0.003),
- smooth_angles(_("Smooth angles:"), _("Max degree difference on handles to preform a smooth"), "smooth_angles", &wr, this, 20.),
+ threshold(_("Roughly threshold:"), _("Roughly threshold:"), "threshold", &wr, this, 0.002),
+ smooth_angles(_("Smooth angles:"), _("Max degree difference on handles to perform a smooth"), "smooth_angles", &wr, this, 0.),
helper_size(_("Helper size:"), _("Helper size"), "helper_size", &wr, this, 5),
simplify_individual_paths(_("Paths separately"), _("Simplifying paths (separately)"), "simplify_individual_paths", &wr, this, false,
"", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")),
@@ -51,7 +51,7 @@ LPESimplify::LPESimplify(LivePathEffectObject *lpeobject)
steps.param_set_increments(1, 1);
steps.param_set_digits(0);
- smooth_angles.param_set_range(0.0, 365.0);
+ smooth_angles.param_set_range(0.0, 360.0);
smooth_angles.param_set_increments(10, 10);
smooth_angles.param_set_digits(2);
@@ -60,6 +60,7 @@ LPESimplify::LPESimplify(LivePathEffectObject *lpeobject)
helper_size.param_set_digits(2);
radius_helper_nodes = 6.0;
+ apply_to_clippath_and_mask = true;
}
LPESimplify::~LPESimplify() {}
@@ -71,10 +72,7 @@ LPESimplify::doBeforeEffect (SPLPEItem const* lpeitem)
hp.clear();
}
bbox = SP_ITEM(lpeitem)->visualBounds();
- SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem);
radius_helper_nodes = helper_size;
- item->apply_to_clippath(item);
- item->apply_to_mask(item);
}
Gtk::Widget *
@@ -138,6 +136,7 @@ LPESimplify::doEffect(SPCurve *curve)
if(simplify_individual_paths) {
size = Geom::L2(Geom::bounds_fast(original_pathv)->dimensions());
}
+ size /= sp_lpe_item->i2doc_affine().descrim();
for (int unsigned i = 0; i < steps; i++) {
if ( simplify_just_coalesce ) {
pathliv->Coalesce(threshold * size);
@@ -198,13 +197,15 @@ LPESimplify::generateHelperPathAndSmooth(Geom::PathVector &result)
Geom::Point point_at2 = curve_it1->finalPoint();
Geom::Point point_at3 = curve_it1->finalPoint();
Geom::Point point_at4 = curve_it1->finalPoint();
+
+ if(start == Geom::Point(0,0)) {
+ start = point_at1;
+ }
+
if (cubic) {
point_at1 = (*cubic)[1];
point_at2 = (*cubic)[2];
}
- if(start == Geom::Point(0,0)) {
- start = point_at1;
- }
if(path_it->closed() && curve_it2 == curve_endit) {
point_at4 = start;
@@ -217,13 +218,13 @@ LPESimplify::generateHelperPathAndSmooth(Geom::PathVector &result)
}
Geom::Ray ray1(point_at2, point_at3);
Geom::Ray ray2(point_at3, point_at4);
- double angle1 = Geom::rad_to_deg(ray1.angle());
- double angle2 = Geom::rad_to_deg(ray2.angle());
- if((smooth_angles >= angle2 - angle1) && !are_near(point_at4,point_at3) && !are_near(point_at2,point_at3)) {
+ double angle1 = Geom::deg_from_rad(ray1.angle());
+ double angle2 = Geom::deg_from_rad(ray2.angle());
+ if((smooth_angles >= std::abs(angle2 - angle1)) && !are_near(point_at4,point_at3) && !are_near(point_at2,point_at3)) {
double dist = Geom::distance(point_at2,point_at3);
Geom::Angle angleFixed = ray2.angle();
angleFixed -= Geom::Angle::from_degrees(180.0);
- point_at2 = Geom::Point::polar(angleFixed,dist) + point_at3;
+ point_at2 = Geom::Point::polar(angleFixed, dist) + point_at3;
}
nCurve->curveto(point_at1, point_at2, curve_it1->finalPoint());
cubic = dynamic_cast<Geom::CubicBezier const *>(nCurve->last_segment());