Code

remove many unnecessary to_2geom and from_2geom calls
[inkscape.git] / src / live_effects / lpe-mirror_symmetry.cpp
index e41d4084ddb4c10cf1b0cb9877af74b4810552fb..bb2b908deeb4fab3a9ef74b5e346b651a079c242 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().to_2geom());
-    Geom::Point B(curve->last_point().to_2geom());
-    
-    Piecewise<D2<SBasis> > rline = Piecewise<D2<SBasis> >(D2<SBasis>(Linear(A[X], B[X]), Linear(A[Y], B[Y])));
-    reflection_line.param_set_and_write_new_value(rline);
-
-    SP_OBJECT(param_path)->deleteObject(true);
+    SPItem *item = SP_ITEM(lpeitem);
+    Geom::Matrix t = sp_item_i2d_affine(item);
+    Geom::Rect bbox = to_2geom(*item->getBounds(t)); // fixme: what happens if getBounds does not return a valid rect?
 
-    // 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 */