Code

3DBox tool: snap the first point of the drag action
[inkscape.git] / src / live_effects / effect.cpp
index 9aefb07040520b0116a150805586d29e35a0ef2c..9dbd27b5041383c10ff45e94ed130433e367f429 100644 (file)
@@ -28,8 +28,8 @@
 #include "tools-switch.h"
 #include "message-stack.h"
 #include "desktop.h"
-#include "nodepath.h"
-
+#include "knotholder.h"
+#include "sp-lpe-item.h"
 #include "live_effects/lpeobject.h"
 #include "live_effects/parameter/parameter.h"
 #include <glibmm/ustring.h>
@@ -74,6 +74,8 @@
 #include "live_effects/lpe-path_length.h"
 #include "live_effects/lpe-line_segment.h"
 #include "live_effects/lpe-recursiveskeleton.h"
+#include "live_effects/lpe-extrude.h"
+#include "live_effects/lpe-powerstroke.h"
 
 
 namespace Inkscape {
@@ -85,11 +87,12 @@ const Util::EnumData<EffectType> LPETypeData[] = {
 #ifdef LPE_ENABLE_TEST_EFFECTS
     {DOEFFECTSTACK_TEST,    N_("doEffect stack test"),     "doeffectstacktest"},
     {ANGLE_BISECTOR,        N_("Angle bisector"),          "angle_bisector"},
+    // TRANSLATORS: boolean operations
     {BOOLOPS,               N_("Boolops"),                 "boolops"},
     {CIRCLE_WITH_RADIUS,    N_("Circle (by center and radius)"),   "circle_with_radius"},
     {CIRCLE_3PTS,           N_("Circle by 3 points"),      "circle_3pts"},
     {DYNASTROKE,            N_("Dynamic stroke"),          "dynastroke"},
-    {INTERPOLATE,           N_("Interpolate Sub-Paths"),   "interpolate"},
+    {EXTRUDE,               N_("Extrude"),                 "extrude"},
     {LATTICE,               N_("Lattice Deformation"),     "lattice"},
     {LINE_SEGMENT,          N_("Line Segment"),            "line_segment"},
     {MIRROR_SYMMETRY,       N_("Mirror symmetry"),         "mirror_symmetry"},
@@ -98,9 +101,9 @@ const Util::EnumData<EffectType> LPETypeData[] = {
     {PATH_LENGTH,           N_("Path length"),             "path_length"},
     {PERP_BISECTOR,         N_("Perpendicular bisector"),  "perp_bisector"},
     {PERSPECTIVE_PATH,      N_("Perspective path"),        "perspective_path"},
+    {POWERSTROKE,           N_("Power stroke"),            "powerstroke"},
     {COPY_ROTATE,           N_("Rotate copies"),           "copy_rotate"},
     {RECURSIVE_SKELETON,    N_("Recursive skeleton"),      "recursive_skeleton"},
-    {RULER,                 N_("Ruler"),                   "ruler"},
     {TANGENT_TO_CURVE,      N_("Tangent to curve"),        "tangent_to_curve"},
     {TEXT_LABEL,            N_("Text label"),              "text_label"},
 #endif
@@ -115,8 +118,11 @@ const Util::EnumData<EffectType> LPETypeData[] = {
     {CONSTRUCT_GRID,        N_("Construct grid"),          "construct_grid"},
     {SPIRO,                 N_("Spiro spline"),            "spiro"},
     {ENVELOPE,              N_("Envelope Deformation"),    "envelope"},
+    {INTERPOLATE,           N_("Interpolate Sub-Paths"),   "interpolate"},
     {ROUGH_HATCHES,         N_("Hatches (rough)"),         "rough_hatches"},
     {SKETCH,                N_("Sketch"),                  "sketch"},
+    {RULER,                 N_("Ruler"),                   "ruler"},
+/* 0.49 */
 };
 const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData));
 
@@ -231,6 +237,12 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj)
         case RECURSIVE_SKELETON:
             neweffect = static_cast<Effect*> ( new LPERecursiveSkeleton(lpeobj) );
             break;
+        case EXTRUDE:
+            neweffect = static_cast<Effect*> ( new LPEExtrude(lpeobj) );
+            break;
+        case POWERSTROKE:
+            neweffect = static_cast<Effect*> ( new LPEPowerStroke(lpeobj) );
+            break;
         default:
             g_warning("LivePathEffect::Effect::New   called with invalid patheffect type (%d)", lpenr);
             neweffect = NULL;
@@ -270,7 +282,6 @@ Effect::createAndApply(EffectType type, SPDocument *doc, SPItem *item)
 Effect::Effect(LivePathEffectObject *lpeobject)
     : oncanvasedit_it(0),
       is_visible(_("Is visible?"), _("If unchecked, the effect remains applied to the object but is temporarily disabled on canvas"), "is_visible", &wr, this, true),
-      deactivate_knotholder(_("Deactivate knotholder?"), _("Check this to deactivate knotholder handles (useful if they interfere with node handles during editing)"), "deactivate_knotholder", &wr, this, false),
       show_orig_path(false),
       lpeobj(lpeobject),
       concatenate_before_pwd2(false),
@@ -278,7 +289,7 @@ Effect::Effect(LivePathEffectObject *lpeobject)
       is_ready(false) // is automatically set to false if providesOwnFlashPaths() is not overridden
 {
     registerParameter( dynamic_cast<Parameter *>(&is_visible) );
-    registerParameter( dynamic_cast<Parameter *>(&deactivate_knotholder) );
+    is_visible.widget_is_visible = false;
 }
 
 Effect::~Effect()
@@ -469,9 +480,6 @@ void
 Effect::addHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) {
     using namespace Inkscape::LivePathEffect;
 
-    if (deactivate_knotholder)
-        return;
-
     // add handles provided by the effect itself
     addKnotHolderEntities(knotholder, desktop, item);
 
@@ -508,7 +516,7 @@ Effect::getHelperPaths(SPLPEItem *lpeitem)
     std::vector<Geom::PathVector> hp_vec;
 
     if (!SP_IS_SHAPE(lpeitem)) {
-        g_print ("How to handle helperpaths for non-shapes?\n"); // non-shapes are for example SPGroups.
+//        g_print ("How to handle helperpaths for non-shapes?\n"); // non-shapes are for example SPGroups.
         return hp_vec;
     }
 
@@ -554,13 +562,15 @@ Effect::newWidget(Gtk::Tooltips * tooltips)
 
     std::vector<Parameter *>::iterator it = param_vector.begin();
     while (it != param_vector.end()) {
-        Parameter * param = *it;
-        Gtk::Widget * widg = param->param_newWidget(tooltips);
-        Glib::ustring * tip = param->param_getTooltip();
-        if (widg) {
-           vbox->pack_start(*widg, true, true, 2);
-            if (tip != NULL) {
-                tooltips->set_tip(*widg, *tip);
+        if ((*it)->widget_is_visible) {
+            Parameter * param = *it;
+            Gtk::Widget * widg = param->param_newWidget(tooltips);
+            Glib::ustring * tip = param->param_getTooltip();
+            if (widg) {
+                vbox->pack_start(*widg, true, true, 2);
+                if (tip != NULL) {
+                    tooltips->set_tip(*widg, *tip);
+                }
             }
         }
 
@@ -659,13 +669,6 @@ Effect::resetDefaults(SPItem * /*item*/)
     }
 }
 
-void
-Effect::setup_nodepath(Inkscape::NodePath::Path *np)
-{
-    np->helperpath_rgba = 0xff0000ff;
-    np->helperpath_width = 1.0;
-}
-
 void
 Effect::transform_multiply(Geom::Matrix const& postmul, bool set)
 {
@@ -676,7 +679,6 @@ Effect::transform_multiply(Geom::Matrix const& postmul, bool set)
     }
 }
 
-// TODO: take _all_ parameters into account, not only PointParams
 bool
 Effect::providesKnotholder()
 {