Code

Rename LPE: mirror reflect --> mirror symmetry
[inkscape.git] / src / live_effects / effect.cpp
index 4e500a4981fb6e73eece9fe5e6cdfd1cabbca4da..66d2334e018684ad2ed8b74748c9ab8853dfb012 100644 (file)
 #include "live_effects/lpe-constructgrid.h"
 #include "live_effects/lpe-perp_bisector.h"
 #include "live_effects/lpe-tangent_to_curve.h"
-#include "live_effects/lpe-mirror_reflect.h"
+#include "live_effects/lpe-mirror_symmetry.h"
 #include "live_effects/lpe-circle_3pts.h"
 #include "live_effects/lpe-angle_bisector.h"
 #include "live_effects/lpe-parallel.h"
 #include "live_effects/lpe-copy_rotate.h"
+#include "live_effects/lpe-offset.h"
 // end of includes
 
 namespace Inkscape {
@@ -86,11 +87,12 @@ const Util::EnumData<EffectType> LPETypeData[INVALID_LPE] = {
     {CONSTRUCT_GRID,        N_("Construct grid"),        "construct_grid"},
     {PERP_BISECTOR, N_("Perpendicular bisector"), "perp_bisector"},
     {TANGENT_TO_CURVE, N_("Tangent to curve"), "tangent_to_curve"},
-    {MIRROR_REFLECT, N_("Mirror reflection"), "mirror_reflect"},
+    {MIRROR_SYMMETRY, N_("Mirror symmetry"), "mirror_symmetry"},
     {CIRCLE_3PTS, N_("Circle through 3 points"), "circle_3pts"},
     {ANGLE_BISECTOR, N_("Angle bisector"), "angle_bisector"},
     {PARALLEL, N_("Parallel"), "parallel"},
     {COPY_ROTATE, N_("Rotate copies"), "copy_rotate"},
+    {OFFSET, N_("Offset"), "offset"},
 };
 const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, INVALID_LPE);
 
@@ -149,8 +151,8 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj)
         case TANGENT_TO_CURVE:
             neweffect = static_cast<Effect*> ( new LPETangentToCurve(lpeobj) );
             break;
-        case MIRROR_REFLECT:
-            neweffect = static_cast<Effect*> ( new LPEMirrorReflect(lpeobj) );
+        case MIRROR_SYMMETRY:
+            neweffect = static_cast<Effect*> ( new LPEMirrorSymmetry(lpeobj) );
             break;
         case CIRCLE_3PTS:
             neweffect = static_cast<Effect*> ( new LPECircle3Pts(lpeobj) );
@@ -164,6 +166,9 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj)
         case COPY_ROTATE:
             neweffect = static_cast<Effect*> ( new LPECopyRotate(lpeobj) );
             break;
+        case OFFSET:
+            neweffect = static_cast<Effect*> ( new LPEOffset(lpeobj) );
+            break;
         default:
             g_warning("LivePathEffect::Effect::New   called with invalid patheffect type (%d)", lpenr);
             neweffect = NULL;
@@ -192,9 +197,6 @@ Effect::createAndApply(const char* name, SPDocument *doc, SPItem *item)
     gchar *href = g_strdup_printf("#%s", repr_id);
     sp_lpe_item_add_path_effect(SP_LPE_ITEM(item), href, true);
     g_free(href);
-
-    sp_document_done(doc, SP_VERB_DIALOG_LIVE_PATH_EFFECT,
-                     _("Create and apply path effect"));
 }
 
 void
@@ -290,7 +292,7 @@ Effect::writeParamsToSVG() {
  * your LPE. But don't forget to call the parent method so that done_pathparam_set is set to true!
  */
 void
-Effect::acceptParamPath (SPPath *param_path) {
+Effect::acceptParamPath (SPPath */*param_path*/) {
     done_pathparam_set = true;
 }
 
@@ -304,7 +306,7 @@ Effect::doEffect (SPCurve * curve)
 
     std::vector<Geom::Path> result_pathv = doEffect_path(orig_pathv);
 
-    curve->set_pathv(result_pathv);
+    curve->set_pathvector(result_pathv);
 }
 
 std::vector<Geom::Path>
@@ -413,11 +415,13 @@ Effect::addHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) {
 
 void
 Effect::addPointParamHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) {
-    using namespace std;
+    using namespace Inkscape::LivePathEffect;
     for (std::vector<Parameter *>::iterator p = param_vector.begin(); p != param_vector.end(); ++p) {
-        if ((*p)->paramType() == Inkscape::LivePathEffect::POINT_PARAM) {
+        if ((*p)->paramType() == POINT_PARAM) {
+            PointParam *pparam = static_cast<PointParam *>(*p);
             KnotHolderEntity *e = dynamic_cast<KnotHolderEntity *>(*p);
-            e->create(desktop, item, knotholder);
+            e->create(desktop, item, knotholder, pparam->handleTip(),
+                      pparam->knotShape(), pparam->knotMode(), pparam->knotColor());
             knotholder->add(e);
         }
     }
@@ -434,16 +438,26 @@ Effect::addHelperPaths(SPLPEItem *lpeitem, SPDesktop *desktop)
         // must create the helper curve for the original path manually; once we allow nodepaths and
         // knotholders alongside each other, this needs to be rethought!
         SPCanvasItem *canvasitem = sp_nodepath_generate_helperpath(desktop, SP_PATH(lpeitem));
-        // TODO: Make sure the tempitem doesn't get destroyed when the mouse leaves the item
         Inkscape::Display::TemporaryItem* tmpitem = desktop->add_temporary_canvasitem (canvasitem, 0);
         lpeitem->lpe_helperpaths.push_back(tmpitem);
     }
 
+    for (std::vector<Parameter *>::iterator p = param_vector.begin(); p != param_vector.end(); ++p) {
+        if ((*p)->paramType() == Inkscape::LivePathEffect::PATH_PARAM) {
+            SPCurve *c = new SPCurve(static_cast<Inkscape::LivePathEffect::PathParam*>(*p)->get_pathvector());
+
+            // TODO: factor this out (also the copied code above); see also lpe-lattice.cpp
+            SPCanvasItem *canvasitem = sp_nodepath_generate_helperpath(desktop, c, SP_ITEM(lpeitem), 0x009000ff);
+            Inkscape::Display::TemporaryItem* tmpitem = desktop->add_temporary_canvasitem (canvasitem, 0);
+            lpeitem->lpe_helperpaths.push_back(tmpitem);
+        }
+    }
+
     addHelperPathsImpl(lpeitem, desktop);
 }
 
 void
-Effect::addHelperPathsImpl(SPLPEItem *lpeitem, SPDesktop *desktop)
+Effect::addHelperPathsImpl(SPLPEItem */*lpeitem*/, SPDesktop */*desktop*/)
 {
     // if this method is overloaded in derived classes, provides_own_flash_paths will be true
     provides_own_flash_paths = false;