Code

Add default mirroring line to lpe-symmetry because the on-canvas clicks seem more...
authorcilix42 <cilix42@users.sourceforge.net>
Wed, 30 Jul 2008 11:29:49 +0000 (11:29 +0000)
committercilix42 <cilix42@users.sourceforge.net>
Wed, 30 Jul 2008 11:29:49 +0000 (11:29 +0000)
src/live_effects/lpe-mirror_symmetry.cpp
src/live_effects/lpe-mirror_symmetry.h

index 39d3bfe30488b76f78ae1bcd54da5bf53e5c9ed9..a70ab507f55467f905751aeee743f2d5ec3af822 100644 (file)
@@ -38,24 +38,23 @@ LPEMirrorSymmetry::LPEMirrorSymmetry(LivePathEffectObject *lpeobject) :
 
 LPEMirrorSymmetry::~LPEMirrorSymmetry()
 {
-
 }
 
 void
-LPEMirrorSymmetry::acceptParamPath (SPPath *param_path) {
+LPEMirrorSymmetry::doOnApply (SPLPEItem *lpeitem)
+{
     using namespace Geom;
 
-    SPCurve* curve = sp_path_get_curve_for_edit (param_path);
-    Geom::Point A(curve->first_point());
-    Geom::Point B(curve->last_point());
-    
-    Piecewise<D2<SBasis> > rline = Piecewise<D2<SBasis> >(D2<SBasis>(Linear(A[X], B[X]), Linear(A[Y], B[Y])));
-    reflection_line.set_new_value( rline, true );
-
-    SP_OBJECT(param_path)->deleteObject(true);
+    SPItem *item = SP_ITEM(lpeitem);
+    Geom::Matrix t = sp_item_i2d_affine(item);
+    NR::Maybe<Geom::Rect> bbox = item->getBounds(t);
 
-    // don't remove this; needed for cleanup tasks
-    Effect::acceptParamPath(param_path);
+    Point A(bbox->left(), bbox->bottom());
+    Point B(bbox->left(), bbox->top());
+    A *= t;
+    B *= t;
+    Piecewise<D2<SBasis> > rline = Piecewise<D2<SBasis> >(D2<SBasis>(Linear(A[X], B[X]), Linear(A[Y], B[Y])));
+    reflection_line.set_new_value(rline, true);
 }
 
 std::vector<Geom::Path>
@@ -90,8 +89,6 @@ LPEMirrorSymmetry::doEffect_path (std::vector<Geom::Path> const & path_in)
     return path_out;
 }
 
-/* ######################## */
-
 } //namespace LivePathEffect
 } /* namespace Inkscape */
 
index 40b0292c446f5d497e77a8a4ad908a55b571a23d..a37e0d45cbc400224874fbed1c0be45dbbd24558 100644 (file)
@@ -28,8 +28,7 @@ public:
     LPEMirrorSymmetry(LivePathEffectObject *lpeobject);
     virtual ~LPEMirrorSymmetry();
 
-    virtual void acceptParamPath (SPPath *param_path);
-    virtual int acceptsNumParams() { return 2; }
+    virtual void doOnApply (SPLPEItem *lpeitem);
 
     virtual std::vector<Geom::Path> doEffect_path (std::vector<Geom::Path> const & path_in);