diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2015-08-01 14:27:30 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2015-08-01 14:27:30 +0000 |
| commit | aeedb1dda68d5529363a144c13d26f8804da4c64 (patch) | |
| tree | 4ed65edbd94c98e9aafee4bec3813e8b8be84466 /src | |
| parent | fix for 1478636 (crash on import when comments in defs) (diff) | |
| download | inkscape-aeedb1dda68d5529363a144c13d26f8804da4c64.tar.gz inkscape-aeedb1dda68d5529363a144c13d26f8804da4c64.zip | |
Update simplify interactive to handle trinagle out powerstrokes, also fix it for Spiro paths. Updated toolbar slider to also update powerstroke points
(bzr r14271)
Diffstat (limited to 'src')
| -rw-r--r-- | src/ui/tools/freehand-base.cpp | 12 | ||||
| -rw-r--r-- | src/widgets/pencil-toolbar.cpp | 39 |
2 files changed, 41 insertions, 10 deletions
diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index fa45d8dbb..f4ad284c7 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -289,7 +289,7 @@ static void spdc_apply_simplify(std::string threshold, FreehandBase *dc, SPItem Effect::createAndApply(SIMPLIFY, dc->desktop->doc(), item); Effect* lpe = SP_LPE_ITEM(item)->getCurrentLPE(); - // write powerstroke parameters: + // write simplify parameters: lpe->getRepr()->setAttribute("steps", "1"); lpe->getRepr()->setAttribute("threshold", threshold); lpe->getRepr()->setAttribute("smooth_angles", "360"); @@ -314,20 +314,22 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, std::ostringstream ss; ss << tol; spdc_apply_simplify(ss.str(), dc, item); + sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); } if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1) { Effect::createAndApply(SPIRO, dc->desktop->doc(), item); } - //add the bspline node in the waiting effects + if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2) { Effect::createAndApply(BSPLINE, dc->desktop->doc(), item); } + SPShape *sp_shape = dynamic_cast<SPShape *>(item); + if (sp_shape) { + curve = sp_shape->getCurve(); + } //Store the clipboard path to apply in the future without the use of clipboard - static Geom::PathVector previous_shape_pathv; - - shapeType shape = (shapeType)prefs->getInt(tool_name(dc) + "/shape", 0); bool shape_applied = false; diff --git a/src/widgets/pencil-toolbar.cpp b/src/widgets/pencil-toolbar.cpp index aef9b4560..17c1d341d 100644 --- a/src/widgets/pencil-toolbar.cpp +++ b/src/widgets/pencil-toolbar.cpp @@ -46,8 +46,10 @@ #include "ui/uxmanager.h" #include "widgets/spinbutton-events.h" #include <selection.h> +#include "display/curve.h" #include "live_effects/effect.h" #include "live_effects/lpe-simplify.h" +#include "live_effects/lpe-powerstroke.h" #include "live_effects/effect-enum.h" #include "live_effects/lpeobject.h" #include "live_effects/lpeobject-reference.h" @@ -289,15 +291,42 @@ static void sp_pencil_tb_tolerance_value_changed(GtkAdjustment *adj, GObject *tb for (std::vector<SPItem *>::iterator it(selected.begin()); it != selected.end(); ++it){ SPLPEItem* lpeitem = dynamic_cast<SPLPEItem*>(*it); if (lpeitem && lpeitem->hasPathEffect()){ - Inkscape::LivePathEffect::Effect* thisEffect = lpeitem->getPathEffectOfType(Inkscape::LivePathEffect::SIMPLIFY); - if(thisEffect){ - Inkscape::LivePathEffect::LPESimplify *lpe = dynamic_cast<Inkscape::LivePathEffect::LPESimplify*>(thisEffect->getLPEObj()->get_lpe()); - if (lpe) { + Inkscape::LivePathEffect::Effect* simplify = lpeitem->getPathEffectOfType(Inkscape::LivePathEffect::SIMPLIFY); + if(simplify){ + Inkscape::LivePathEffect::LPESimplify *lpe_simplify = dynamic_cast<Inkscape::LivePathEffect::LPESimplify*>(simplify->getLPEObj()->get_lpe()); + if (lpe_simplify) { double tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0); tol = tol/(100.0*(102.0-tol)); std::ostringstream ss; ss << tol; - lpe->getRepr()->setAttribute("threshold", ss.str()); + Inkscape::LivePathEffect::Effect* powerstroke = lpeitem->getPathEffectOfType(Inkscape::LivePathEffect::POWERSTROKE); + bool simplified = false; + if(powerstroke){ + Inkscape::LivePathEffect::LPEPowerStroke *lpe_powerstroke = dynamic_cast<Inkscape::LivePathEffect::LPEPowerStroke*>(powerstroke->getLPEObj()->get_lpe()); + if(lpe_powerstroke){ + lpe_powerstroke->getRepr()->setAttribute("is_visible", "false"); + sp_lpe_item_update_patheffect(lpeitem, false, false); + SPShape *sp_shape = dynamic_cast<SPShape *>(lpeitem); + if (sp_shape) { + guint previous_curve_length = sp_shape->getCurve()->get_segment_count(); + lpe_simplify->getRepr()->setAttribute("threshold", ss.str()); + sp_lpe_item_update_patheffect(lpeitem, false, false); + simplified = true; + guint curve_length = sp_shape->getCurve()->get_segment_count(); + std::vector<Geom::Point> ts = lpe_powerstroke->offset_points.data(); + double factor = (double)curve_length/ (double)previous_curve_length; + for (size_t i = 0; i < ts.size(); i++) { + ts[i][Geom::X] = ts[i][Geom::X] * factor; + } + lpe_powerstroke->offset_points.param_setValue(ts); + } + lpe_powerstroke->getRepr()->setAttribute("is_visible", "true"); + sp_lpe_item_update_patheffect(lpeitem, false, false); + } + } + if(!simplified){ + lpe_simplify->getRepr()->setAttribute("threshold", ss.str()); + } } } } |
