diff options
| author | Jabiertxo Arraiza Cenoz <jtx@jtx-desktop.markerlab.es> | 2017-09-13 16:35:35 +0000 |
|---|---|---|
| committer | Jabiertxo Arraiza Cenoz <jtx@jtx-desktop.markerlab.es> | 2017-09-13 16:35:35 +0000 |
| commit | 58ef38f81c81f38149952f48e674a5fa5402bb98 (patch) | |
| tree | 277865a2701aadfcc3566cf0f6b05374b8c28ca3 /src | |
| parent | Fixes for clone original LPE (diff) | |
| download | inkscape-58ef38f81c81f38149952f48e674a5fa5402bb98.tar.gz inkscape-58ef38f81c81f38149952f48e674a5fa5402bb98.zip | |
Fixes for bug #1716926. Consider backport
Diffstat (limited to 'src')
| -rw-r--r-- | src/live_effects/lpe-patternalongpath.cpp | 79 | ||||
| -rw-r--r-- | src/live_effects/parameter/path.cpp | 33 |
2 files changed, 61 insertions, 51 deletions
diff --git a/src/live_effects/lpe-patternalongpath.cpp b/src/live_effects/lpe-patternalongpath.cpp index 22b18e077..4aa172161 100644 --- a/src/live_effects/lpe-patternalongpath.cpp +++ b/src/live_effects/lpe-patternalongpath.cpp @@ -294,25 +294,29 @@ KnotHolderEntityWidthPatternAlongPath::knot_set(Geom::Point const &p, Geom::Poin Geom::Point const s = snap_knot_position(p, state); SPShape const *sp_shape = dynamic_cast<SPShape const *>(SP_LPE_ITEM(item)); if (sp_shape) { - Geom::Path const *path_in = sp_shape->getCurveBeforeLPE()->first_path(); - Geom::Point ptA = path_in->pointAt(Geom::PathTime(0, 0.0)); - Geom::Point B = path_in->pointAt(Geom::PathTime(1, 0.0)); - Geom::Curve const *first_curve = &path_in->curveAt(Geom::PathTime(0, 0.0)); - Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const *>(&*first_curve); - Geom::Ray ray(ptA, B); - if (cubic) { - ray.setPoints(ptA, (*cubic)[1]); - } - ray.setAngle(ray.angle() + Geom::rad_from_deg(90)); - Geom::Point knot_pos = this->knot->pos * item->i2dt_affine().inverse(); - Geom::Coord nearest_to_ray = ray.nearestTime(knot_pos); - if(nearest_to_ray == 0){ - lpe->prop_scale.param_set_value(-Geom::distance(s , ptA)/(lpe->original_height/2.0)); - } else { - lpe->prop_scale.param_set_value(Geom::distance(s , ptA)/(lpe->original_height/2.0)); + SPCurve *curve_before = sp_shape->getCurveBeforeLPE(); + if (curve_before) { + Geom::Path const *path_in = curve_before->first_path(); + Geom::Point ptA = path_in->pointAt(Geom::PathTime(0, 0.0)); + Geom::Point B = path_in->pointAt(Geom::PathTime(1, 0.0)); + Geom::Curve const *first_curve = &path_in->curveAt(Geom::PathTime(0, 0.0)); + Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const *>(&*first_curve); + Geom::Ray ray(ptA, B); + if (cubic) { + ray.setPoints(ptA, (*cubic)[1]); + } + ray.setAngle(ray.angle() + Geom::rad_from_deg(90)); + Geom::Point knot_pos = this->knot->pos * item->i2dt_affine().inverse(); + Geom::Coord nearest_to_ray = ray.nearestTime(knot_pos); + if(nearest_to_ray == 0){ + lpe->prop_scale.param_set_value(-Geom::distance(s , ptA)/(lpe->original_height/2.0)); + } else { + lpe->prop_scale.param_set_value(Geom::distance(s , ptA)/(lpe->original_height/2.0)); + } + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setDouble("/live_effect/pap/width", lpe->prop_scale); + curve_before->unref(); } - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setDouble("/live_effect/pap/width", lpe->prop_scale); } sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true); } @@ -324,25 +328,28 @@ KnotHolderEntityWidthPatternAlongPath::knot_get() const SPShape const *sp_shape = dynamic_cast<SPShape const *>(SP_LPE_ITEM(item)); if (sp_shape) { - Geom::Path const *path_in = sp_shape->getCurveBeforeLPE()->first_path(); - Geom::Point ptA = path_in->pointAt(Geom::PathTime(0, 0.0)); - Geom::Point B = path_in->pointAt(Geom::PathTime(1, 0.0)); - Geom::Curve const *first_curve = &path_in->curveAt(Geom::PathTime(0, 0.0)); - Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const *>(&*first_curve); - Geom::Ray ray(ptA, B); - if (cubic) { - ray.setPoints(ptA, (*cubic)[1]); + SPCurve *curve_before = sp_shape->getCurveBeforeLPE(); + if (curve_before) { + Geom::Path const *path_in = curve_before->first_path(); + Geom::Point ptA = path_in->pointAt(Geom::PathTime(0, 0.0)); + Geom::Point B = path_in->pointAt(Geom::PathTime(1, 0.0)); + Geom::Curve const *first_curve = &path_in->curveAt(Geom::PathTime(0, 0.0)); + Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const *>(&*first_curve); + Geom::Ray ray(ptA, B); + if (cubic) { + ray.setPoints(ptA, (*cubic)[1]); + } + ray.setAngle(ray.angle() + Geom::rad_from_deg(90)); + Geom::Point result_point = Geom::Point::polar(ray.angle(), (lpe->original_height/2.0) * lpe->prop_scale) + ptA; + + pap_helper_path.clear(); + Geom::Path hp(result_point); + hp.appendNew<Geom::LineSegment>(ptA); + pap_helper_path.push_back(hp); + hp.clear(); + curve_before->unref(); + return result_point; } - ray.setAngle(ray.angle() + Geom::rad_from_deg(90)); - Geom::Point result_point = Geom::Point::polar(ray.angle(), (lpe->original_height/2.0) * lpe->prop_scale) + ptA; - - pap_helper_path.clear(); - Geom::Path hp(result_point); - hp.appendNew<Geom::LineSegment>(ptA); - pap_helper_path.push_back(hp); - hp.clear(); - - return result_point; } return Geom::Point(); } diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index 470535314..a91e50db8 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -79,21 +79,24 @@ PathParam::PathParam( const Glib::ustring& label, const Glib::ustring& tip, PathParam::~PathParam() { remove_link(); - using namespace Inkscape::UI; - SPDesktop *desktop = SP_ACTIVE_DESKTOP; - if (desktop) { - if (tools_isactive(desktop, TOOLS_NODES)) { - SPItem * item = SP_ACTIVE_DESKTOP->getSelection()->singleItem(); - if (item != NULL) { - Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>(desktop->event_context); - std::set<ShapeRecord> shapes; - ShapeRecord r; - r.item = item; - shapes.insert(r); - nt->_multipath->setItems(shapes); - } - } - } +//TODO: Removed to fix a bug https://bugs.launchpad.net/inkscape/+bug/1716926 +// Maybe wee need to resurrect, not know when this code is added, but seems also not working now in a few test I do. +// in the future and do a deeper fix in multi-path-manipulator +// using namespace Inkscape::UI; +// SPDesktop *desktop = SP_ACTIVE_DESKTOP; +// if (desktop) { +// if (tools_isactive(desktop, TOOLS_NODES)) { +// SPItem * item = SP_ACTIVE_DESKTOP->getSelection()->singleItem(); +// if (item) { +// Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>(desktop->event_context); +// std::set<ShapeRecord> shapes; +// ShapeRecord r; +// r.item = item; +// shapes.insert(r); +// nt->_multipath->setItems(shapes); +// } +// } +// } g_free(defvalue); } |
