diff options
| author | Liam P. White <inkscapebrony@gmail.com> | 2014-10-31 00:22:23 +0000 |
|---|---|---|
| committer | Liam P. White <inkscapebrony@gmail.com> | 2014-10-31 00:22:23 +0000 |
| commit | a95976663a5d9ffe10fb39aa03f6ad42b067ae95 (patch) | |
| tree | 73aa5717905b22abcb80d7134dc6fca4eb95c573 /src/live_effects | |
| parent | Update to experimental r13619 (diff) | |
| parent | Fix units.xml (diff) | |
| download | inkscape-a95976663a5d9ffe10fb39aa03f6ad42b067ae95.tar.gz inkscape-a95976663a5d9ffe10fb39aa03f6ad42b067ae95.zip | |
Update to trunk r13648
(bzr r13341.5.19)
Diffstat (limited to 'src/live_effects')
| -rw-r--r-- | src/live_effects/lpe-fillet-chamfer.cpp | 12 | ||||
| -rw-r--r-- | src/live_effects/lpe-perspective-envelope.cpp | 3 | ||||
| -rw-r--r-- | src/live_effects/lpe-powerstroke.cpp | 12 | ||||
| -rw-r--r-- | src/live_effects/parameter/filletchamferpointarray.cpp | 9 | ||||
| -rw-r--r-- | src/live_effects/parameter/powerstrokepointarray.cpp | 49 |
5 files changed, 40 insertions, 45 deletions
diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp index b267c92ed..a3964f553 100644 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ b/src/live_effects/lpe-fillet-chamfer.cpp @@ -34,6 +34,7 @@ #include "ui/tool/selectable-control-point.h" #include "ui/tool/node.h" #include "ui/tools/node-tool.h" +#include <util/units.h> // TODO due to internal breakage in glibmm headers, this must be last: #include <glibmm/i18n.h> @@ -172,9 +173,9 @@ void LPEFilletChamfer::toggleHide() for (std::vector<Point>::const_iterator point_it = filletChamferData.begin(); point_it != filletChamferData.end(); ++point_it) { if (hide_knots) { - result.push_back(Point((*point_it)[X], abs((*point_it)[Y]) * -1)); + result.push_back(Point((*point_it)[X], std::abs((*point_it)[Y]) * -1)); } else { - result.push_back(Point((*point_it)[X], abs((*point_it)[Y]))); + result.push_back(Point((*point_it)[X], std::abs((*point_it)[Y]))); } } fillet_chamfer_values.param_set_and_write_new_value(result); @@ -211,7 +212,8 @@ void LPEFilletChamfer::updateFillet() { double power = 0; if (!flexible) { - power = Inkscape::Util::Quantity::convert(radius, unit.get_abbreviation(), "px") * -1; + Inkscape::Util::Unit const *doc_units = SP_ACTIVE_DESKTOP->namedview->doc_units; + power = Inkscape::Util::Quantity::convert(radius, unit.get_abbreviation(), doc_units->abbr) * -1; } else { power = radius; } @@ -589,11 +591,11 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in) } int type = 0; if(path_it->closed() && last){ - type = abs(filletChamferData[counter - counterCurves][Y]); + type = std::abs(filletChamferData[counter - counterCurves][Y]); } else if (!path_it->closed() && last){ //0 } else { - type = abs(filletChamferData[counter + 1][Y]); + type = std::abs(filletChamferData[counter + 1][Y]); } if (type == 3 || type == 4) { if (type == 4) { diff --git a/src/live_effects/lpe-perspective-envelope.cpp b/src/live_effects/lpe-perspective-envelope.cpp index 6f6838c81..c070cf17b 100644 --- a/src/live_effects/lpe-perspective-envelope.cpp +++ b/src/live_effects/lpe-perspective-envelope.cpp @@ -308,6 +308,9 @@ void LPEPerspectiveEnvelope::doBeforeEffect (SPLPEItem const* lpeitem) { original_bbox(lpeitem); + SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem); + item->apply_to_clippath(item); + item->apply_to_mask(item); setDefaults(); } diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 58d733b53..03a10807a 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -659,6 +659,15 @@ LPEPowerStroke::doEffect_path (std::vector<Geom::Path> const & path_in) ts.push_back( Point( pwd2_in.domain().max(), (end_linecap==LINECAP_ZERO_WIDTH) ? 0. : ts.back()[Geom::Y]) ); } + + // do the interpolation in a coordinate system that is more alike to the on-canvas knots, + // instead of the heavily compressed coordinate system of (segment_no offset, Y) in which the knots are stored + double pwd2_in_arclength = length(pwd2_in); + double xcoord_scaling = pwd2_in_arclength / ts.back()[Geom::X]; + for (std::size_t i = 0, e = ts.size(); i < e; ++i) { + ts[i][Geom::X] *= xcoord_scaling; + } + // create stroke path where points (x,y) := (t, offset) Geom::Interpolate::Interpolator *interpolator = Geom::Interpolate::Interpolator::create(static_cast<Geom::Interpolate::InterpolatorType>(interpolator_type.get_value())); if (Geom::Interpolate::CubicBezierJohan *johan = dynamic_cast<Geom::Interpolate::CubicBezierJohan*>(interpolator)) { @@ -670,6 +679,9 @@ LPEPowerStroke::doEffect_path (std::vector<Geom::Path> const & path_in) Geom::Path strokepath = interpolator->interpolateToPath(ts); delete interpolator; + // apply the inverse knot-xcoord scaling that was applied before the interpolation + strokepath *= Scale(1/xcoord_scaling, 1); + D2<Piecewise<SBasis> > patternd2 = make_cuts_independent(strokepath.toPwSb()); Piecewise<SBasis> x = Piecewise<SBasis>(patternd2[0]); Piecewise<SBasis> y = Piecewise<SBasis>(patternd2[1]); diff --git a/src/live_effects/parameter/filletchamferpointarray.cpp b/src/live_effects/parameter/filletchamferpointarray.cpp index e2b1aba61..db24a9735 100644 --- a/src/live_effects/parameter/filletchamferpointarray.cpp +++ b/src/live_effects/parameter/filletchamferpointarray.cpp @@ -175,13 +175,8 @@ void FilletChamferPointArrayParam::recalculate_controlpoints_for_new_pwd2( last_pathv[counterPaths][counter - offset].initialPoint(), 0.1))) { if ( curve_it2 == curve_endit) { - if (last_pathv[counterPaths].size() < pathv[counterPaths].size()) { - offset = abs(last_pathv[counterPaths].size() - - pathv[counterPaths].size()); - } else if (last_pathv[counterPaths].size() > - pathv[counterPaths].size()) { - offset = (abs(last_pathv[counterPaths].size() - - pathv[counterPaths].size())) * -1; + if (last_pathv[counterPaths].size() != pathv[counterPaths].size()) { + offset = (last_pathv[counterPaths].size() - pathv[counterPaths].size()) * -1; } else { offset = 0; } diff --git a/src/live_effects/parameter/powerstrokepointarray.cpp b/src/live_effects/parameter/powerstrokepointarray.cpp index 851b12ef8..e0c2f4c68 100644 --- a/src/live_effects/parameter/powerstrokepointarray.cpp +++ b/src/live_effects/parameter/powerstrokepointarray.cpp @@ -8,17 +8,13 @@ #include "live_effects/parameter/powerstrokepointarray.h" #include "live_effects/effect.h" -#include "svg/svg.h" -#include "svg/stringstream.h" #include "knotholder.h" #include "sp-lpe-item.h" #include <2geom/piecewise.h> #include <2geom/sbasis-geometric.h> -// needed for on-canvas editting: -#include "desktop.h" -#include "live_effects/lpeobject.h" +#include "preferences.h" // for proportional stroke/path scaling behavior #include <glibmm/i18n.h> @@ -44,38 +40,25 @@ Gtk::Widget * PowerStrokePointArrayParam::param_newWidget() { return NULL; -/* - Inkscape::UI::Widget::RegisteredTransformedPoint * pointwdg = Gtk::manage( - new Inkscape::UI::Widget::RegisteredTransformedPoint( param_label, - param_tooltip, - param_key, - *param_wr, - param_effect->getRepr(), - param_effect->getSPDoc() ) ); - // TODO: fix to get correct desktop (don't use SP_ACTIVE_DESKTOP) - SPDesktop *desktop = SP_ACTIVE_DESKTOP; - Geom::Affine transf = desktop->doc2dt(); - pointwdg->setTransform(transf); - pointwdg->setValue( *this ); - pointwdg->clearProgrammatically(); - pointwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change point parameter")); - - Gtk::HBox * hbox = Gtk::manage( new Gtk::HBox() ); - static_cast<Gtk::HBox*>(hbox)->pack_start(*pointwdg, true, true); - static_cast<Gtk::HBox*>(hbox)->show_all_children(); - - return dynamic_cast<Gtk::Widget *> (hbox); -*/ } -void PowerStrokePointArrayParam::param_transform_multiply(Geom::Affine const& postmul, bool /*set*/) +void PowerStrokePointArrayParam::param_transform_multiply(Geom::Affine const &postmul, bool /*set*/) { - std::vector<Geom::Point> result; - for (std::vector<Geom::Point>::const_iterator point_it = _vector.begin(); point_it != _vector.end(); ++point_it) { - Geom::Coord A = (*point_it)[Geom::Y] * ((postmul.expansionX() + postmul.expansionY()) / 2); - result.push_back(Geom::Point((*point_it)[Geom::X], A)); + // Check if proportional stroke-width scaling is on + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + bool transform_stroke = prefs ? prefs->getBool("/options/transform/stroke", true) : true; + if (transform_stroke) { + std::vector<Geom::Point> result; + result.reserve(_vector.size()); // reserve space for the points that will be added in the for loop + for (std::vector<Geom::Point>::const_iterator point_it = _vector.begin(), e = _vector.end(); + point_it != e; ++point_it) + { + // scale each width knot with the average scaling in X and Y + Geom::Coord const A = (*point_it)[Geom::Y] * ((postmul.expansionX() + postmul.expansionY()) / 2); + result.push_back(Geom::Point((*point_it)[Geom::X], A)); + } + param_set_and_write_new_value(result); } - param_set_and_write_new_value(result); } /** call this method to recalculate the controlpoints such that they stay at the same location relative to the new path. Useful after adding/deleting nodes to the path.*/ |
