Code

fix shift+middle button zoom area when there are other modifiers in the mask; safe...
[inkscape.git] / src / live_effects / lpe-parallel.cpp
index 2f3a6d0cebdc1b2d26ee204fa67d888e3d2a6a3a..6b4a55504823de51cd9ae2db5ce38ae5b92ed6d1 100644 (file)
@@ -24,22 +24,18 @@ namespace LivePathEffect {
 
 namespace Pl {
 
-class KnotHolderEntityLeftEnd : public KnotHolderEntity
+class KnotHolderEntityLeftEnd : public LPEKnotHolderEntity
 {
 public:
-    virtual bool isLPEParam() { return true; }
-
-    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 KnotHolderEntityRightEnd : public KnotHolderEntity
+class KnotHolderEntityRightEnd : public LPEKnotHolderEntity
 {
 public:
-    virtual bool isLPEParam() { return true; }
-
-    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 Pl
@@ -71,8 +67,8 @@ LPEParallel::doOnApply (SPLPEItem *lpeitem)
 {
     SPCurve *curve = SP_SHAPE(lpeitem)->curve;
 
-    A = curve->first_point().to_2geom();
-    B = curve->last_point().to_2geom();
+    A = *(curve->first_point());
+    B = *(curve->last_point());
     dir = unit_vector(B - A);
 
     offset_pt.param_set_and_write_new_value((A + B)/2 + dir.ccw() * 100);
@@ -112,39 +108,43 @@ get_effect(SPItem *item)
 }
 
 void
-KnotHolderEntityLeftEnd::knot_set(NR::Point const &p, NR::Point const &/*origin*/, guint /*state*/)
+KnotHolderEntityLeftEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/)
 {
     using namespace Geom;
 
     LPEParallel *lpe = get_effect(item);
     
-    double lambda = L2(p - lpe->offset_pt) * sgn(dot(p.to_2geom() - lpe->offset_pt, lpe->dir));
+    Geom::Point const s = snap_knot_position(p);
+
+    double lambda = L2(s - lpe->offset_pt) * sgn(dot(s - lpe->offset_pt, lpe->dir));
     lpe->length_left.param_set_value(-lambda);
 
     sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true);
 }
 
 void
-KnotHolderEntityRightEnd::knot_set(NR::Point const &p, NR::Point const &/*origin*/, guint /*state*/)
+KnotHolderEntityRightEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/)
 {
     using namespace Geom;
 
     LPEParallel *lpe = get_effect(item);
     
-    double lambda = L2(p - lpe->offset_pt) * sgn(dot(p.to_2geom() - lpe->offset_pt, lpe->dir));
+    Geom::Point const s = snap_knot_position(p);
+
+    double lambda = L2(s - lpe->offset_pt) * sgn(dot(s - lpe->offset_pt, lpe->dir));
     lpe->length_right.param_set_value(lambda);
 
     sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true);
 }
 
-NR::Point
+Geom::Point
 KnotHolderEntityLeftEnd::knot_get()
 {
     LPEParallel *lpe = get_effect(item);
     return lpe->C;
 }
 
-NR::Point
+Geom::Point
 KnotHolderEntityRightEnd::knot_get()
 {
     LPEParallel *lpe = get_effect(item);