X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Flive_effects%2Flpe-copy_rotate.cpp;h=dac34c5d485bad8057bae5966942e8e5f8b02463;hb=29b1527f9bdcb4ac48c0e7e4730c366abb7a5bcb;hp=d193b6d66591ae483d9e4915c7b9422dc6c5b7f5;hpb=6b03b973a8d36d45d5345ba1013db10df1c7a5ce;p=inkscape.git diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp index d193b6d66..dac34c5d4 100644 --- a/src/live_effects/lpe-copy_rotate.cpp +++ b/src/live_effects/lpe-copy_rotate.cpp @@ -29,15 +29,15 @@ namespace CR { class KnotHolderEntityStartingAngle : public LPEKnotHolderEntity { public: - virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state); - virtual NR::Point knot_get(); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual Geom::Point knot_get(); }; class KnotHolderEntityRotationAngle : public LPEKnotHolderEntity { public: - virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state); - virtual NR::Point knot_get(); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual Geom::Point knot_get(); }; } // namespace CR @@ -76,8 +76,8 @@ LPECopyRotate::doOnApply(SPLPEItem *lpeitem) { SPCurve *curve = SP_SHAPE(lpeitem)->curve; - A = curve->first_point(); - B = curve->last_point(); + A = *(curve->first_point()); + B = *(curve->last_point()); origin.param_setValue(A); @@ -90,6 +90,11 @@ LPECopyRotate::doEffect_pwd2 (Geom::Piecewise > const & p { using namespace Geom; + // I first suspected the minus sign to be a bug in 2geom but it is + // likely due to SVG's choice of coordinate system orientation (max) + start_pos = origin + dir * Rotate(-deg_to_rad(starting_angle)) * dist_angle_handle; + rot_pos = origin + dir * Rotate(-deg_to_rad(starting_angle + rotation_angle)) * dist_angle_handle; + A = pwd2_in.firstValue(); B = pwd2_in.lastValue(); dir = unit_vector(B - A); @@ -108,6 +113,20 @@ LPECopyRotate::doEffect_pwd2 (Geom::Piecewise > const & p return output; } +void +LPECopyRotate::addCanvasIndicators(SPLPEItem */*lpeitem*/, std::vector &hp_vec) +{ + using namespace Geom; + + Path path(start_pos); + path.appendNew((Geom::Point) origin); + path.appendNew(rot_pos); + + PathVector pathv; + pathv.push_back(path); + hp_vec.push_back(pathv); +} + namespace CR { using namespace Geom; @@ -125,15 +144,15 @@ get_effect(SPItem *item) } void -KnotHolderEntityStartingAngle::knot_set(NR::Point const &p, NR::Point const &/*origin*/, guint state) +KnotHolderEntityStartingAngle::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { LPECopyRotate* lpe = get_effect(item); - NR::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p); // I first suspected the minus sign to be a bug in 2geom but it is // likely due to SVG's choice of coordinate system orientation (max) - lpe->starting_angle.param_set_value(rad_to_deg(-angle_between(lpe->dir, s.to_2geom() - lpe->origin))); + lpe->starting_angle.param_set_value(rad_to_deg(-angle_between(lpe->dir, s - lpe->origin))); if (state & GDK_SHIFT_MASK) { lpe->dist_angle_handle = L2(lpe->B - lpe->A); } else { @@ -145,15 +164,15 @@ KnotHolderEntityStartingAngle::knot_set(NR::Point const &p, NR::Point const &/*o } void -KnotHolderEntityRotationAngle::knot_set(NR::Point const &p, NR::Point const &/*origin*/, guint state) +KnotHolderEntityRotationAngle::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { LPECopyRotate* lpe = get_effect(item); - NR::Point const s = snap_knot_position(p); + Geom::Point const s = snap_knot_position(p); // I first suspected the minus sign to be a bug in 2geom but it is // likely due to SVG's choice of coordinate system orientation (max) - lpe->rotation_angle.param_set_value(rad_to_deg(-angle_between(lpe->dir, s.to_2geom() - lpe->origin)) - lpe->starting_angle); + lpe->rotation_angle.param_set_value(rad_to_deg(-angle_between(lpe->dir, s - lpe->origin)) - lpe->starting_angle); if (state & GDK_SHIFT_MASK) { lpe->dist_angle_handle = L2(lpe->B - lpe->A); } else { @@ -164,26 +183,18 @@ KnotHolderEntityRotationAngle::knot_set(NR::Point const &p, NR::Point const &/*o sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true); } -NR::Point +Geom::Point KnotHolderEntityStartingAngle::knot_get() { LPECopyRotate* lpe = get_effect(item); - // I first suspected the minus sign to be a bug in 2geom but it is - // likely due to SVG's choice of coordinate system orientation (max) - Point d = lpe->dir * Rotate(-deg_to_rad(lpe->starting_angle)) * lpe->dist_angle_handle; - - return snap_knot_position(lpe->origin + d); + return snap_knot_position(lpe->start_pos); } -NR::Point +Geom::Point KnotHolderEntityRotationAngle::knot_get() { LPECopyRotate* lpe = get_effect(item); - // I first suspected the minus sign to be a bug in 2geom but it is - // likely due to SVG's choice of coordinate system orientation (max) - Point d = lpe->dir * Rotate(-deg_to_rad(lpe->starting_angle + lpe->rotation_angle)) * lpe->dist_angle_handle; - - return snap_knot_position(lpe->origin + d); + return snap_knot_position(lpe->rot_pos); } } // namespace CR