summaryrefslogtreecommitdiffstats
path: root/src/live_effects/effect.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/live_effects/effect.cpp')
-rw-r--r--src/live_effects/effect.cpp161
1 files changed, 147 insertions, 14 deletions
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index 12990ee24..e49a15dd0 100644
--- a/src/live_effects/effect.cpp
+++ b/src/live_effects/effect.cpp
@@ -5,7 +5,7 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-//#define LPE_ENABLE_TEST_EFFECTS
+//#define LPE_ENABLE_TEST_EFFECTS //uncomment for toy effects
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -25,8 +25,13 @@
#include "live_effects/lpe-curvestitch.h"
#include "live_effects/lpe-circle_with_radius.h"
#include "live_effects/lpe-perspective_path.h"
+#include "live_effects/lpe-perspective-envelope.h"
#include "live_effects/lpe-spiro.h"
#include "live_effects/lpe-lattice.h"
+#include "live_effects/lpe-lattice2.h"
+#include "live_effects/lpe-roughen.h"
+#include "live_effects/lpe-show_handles.h"
+#include "live_effects/lpe-simplify.h"
#include "live_effects/lpe-envelope.h"
#include "live_effects/lpe-constructgrid.h"
#include "live_effects/lpe-perp_bisector.h"
@@ -40,6 +45,7 @@
#include "live_effects/lpe-ruler.h"
#include "live_effects/lpe-boolops.h"
#include "live_effects/lpe-interpolate.h"
+#include "live_effects/lpe-interpolate_points.h"
#include "live_effects/lpe-text_label.h"
#include "live_effects/lpe-path_length.h"
#include "live_effects/lpe-line_segment.h"
@@ -47,6 +53,15 @@
#include "live_effects/lpe-extrude.h"
#include "live_effects/lpe-powerstroke.h"
#include "live_effects/lpe-clone-original.h"
+#include "live_effects/lpe-bspline.h"
+#include "live_effects/lpe-attach-path.h"
+#include "live_effects/lpe-fill-between-strokes.h"
+#include "live_effects/lpe-fill-between-many.h"
+#include "live_effects/lpe-ellipse_5pts.h"
+#include "live_effects/lpe-bounding-box.h"
+#include "live_effects/lpe-jointype.h"
+#include "live_effects/lpe-taperstroke.h"
+#include "live_effects/lpe-fillet-chamfer.h"
#include "xml/node-event-vector.h"
#include "sp-object.h"
@@ -59,9 +74,7 @@
#include "xml/document.h"
#include <glibmm/i18n.h>
#include "ui/tools/pen-tool.h"
-#include "tools-switch.h"
-#include "message-stack.h"
-#include "desktop.h"
+#include "ui/tools-switch.h"
#include "knotholder.h"
#include "sp-lpe-item.h"
#include "live_effects/lpeobject.h"
@@ -105,7 +118,7 @@ const Util::EnumData<EffectType> LPETypeData[] = {
{TEXT_LABEL, N_("Text label"), "text_label"},
#endif
/* 0.46 */
- {BEND_PATH, N_("Bend"), "bend_path"},
+ {BEND_PATH, N_("Bend"), "bend_path"},
{GEARS, N_("Gears"), "gears"},
{PATTERN_ALONG_PATH, N_("Pattern Along Path"), "skeletal"}, // for historic reasons, this effect is called skeletal(strokes) in Inkscape:SVG
{CURVE_STITCH, N_("Stitch Sub-Paths"), "curvestitching"},
@@ -119,9 +132,27 @@ const Util::EnumData<EffectType> LPETypeData[] = {
{ROUGH_HATCHES, N_("Hatches (rough)"), "rough_hatches"},
{SKETCH, N_("Sketch"), "sketch"},
{RULER, N_("Ruler"), "ruler"},
-/* 0.49 */
- {POWERSTROKE, N_("Power stroke"), "powerstroke"},
- {CLONE_ORIGINAL, N_("Clone original path"), "clone_original"},
+/* 0.91 */
+ {POWERSTROKE, N_("Power stroke"), "powerstroke"},
+ {CLONE_ORIGINAL, N_("Clone original path"), "clone_original"},
+/* EXPERIMENTAL */
+ {SHOW_HANDLES, N_("Show handles"), "show_handles"},
+ {ROUGHEN, N_("Roughen"), "roughen"},
+ {BSPLINE, N_("BSpline"), "bspline"},
+ {JOIN_TYPE, N_("Join type"), "join_type"},
+ {TAPER_STROKE, N_("Taper stroke"), "taper_stroke"},
+/* Ponyscape */
+ {ATTACH_PATH, N_("Attach path"), "attach_path"},
+ {FILL_BETWEEN_STROKES, N_("Fill between strokes"), "fill_between_strokes"},
+ {FILL_BETWEEN_MANY, N_("Fill between many"), "fill_between_many"},
+ {ELLIPSE_5PTS, N_("Ellipse by 5 points"), "ellipse_5pts"},
+ {BOUNDING_BOX, N_("Bounding Box"), "bounding_box"},
+/* 0.91 */
+ {SIMPLIFY, N_("Simplify"), "simplify"},
+ {LATTICE2, N_("Lattice Deformation 2"), "lattice2"},
+ {PERSPECTIVE_ENVELOPE, N_("Perspective/Envelope"), "perspective-envelope"},
+ {FILLET_CHAMFER, N_("Fillet/Chamfer"), "fillet-chamfer"},
+ {INTERPOLATE_POINTS, N_("Interpolate points"), "interpolate_points"},
};
const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData));
@@ -218,6 +249,9 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj)
case INTERPOLATE:
neweffect = static_cast<Effect*> ( new LPEInterpolate(lpeobj) );
break;
+ case INTERPOLATE_POINTS:
+ neweffect = static_cast<Effect*> ( new LPEInterpolatePoints(lpeobj) );
+ break;
case TEXT_LABEL:
neweffect = static_cast<Effect*> ( new LPETextLabel(lpeobj) );
break;
@@ -230,6 +264,9 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj)
case DOEFFECTSTACK_TEST:
neweffect = static_cast<Effect*> ( new LPEdoEffectStackTest(lpeobj) );
break;
+ case BSPLINE:
+ neweffect = static_cast<Effect*> ( new LPEBSpline(lpeobj) );
+ break;
case DYNASTROKE:
neweffect = static_cast<Effect*> ( new LPEDynastroke(lpeobj) );
break;
@@ -245,8 +282,47 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj)
case CLONE_ORIGINAL:
neweffect = static_cast<Effect*> ( new LPECloneOriginal(lpeobj) );
break;
+ case ATTACH_PATH:
+ neweffect = static_cast<Effect*> ( new LPEAttachPath(lpeobj) );
+ break;
+ case FILL_BETWEEN_STROKES:
+ neweffect = static_cast<Effect*> ( new LPEFillBetweenStrokes(lpeobj) );
+ break;
+ case FILL_BETWEEN_MANY:
+ neweffect = static_cast<Effect*> ( new LPEFillBetweenMany(lpeobj) );
+ break;
+ case ELLIPSE_5PTS:
+ neweffect = static_cast<Effect*> ( new LPEEllipse5Pts(lpeobj) );
+ break;
+ case BOUNDING_BOX:
+ neweffect = static_cast<Effect*> ( new LPEBoundingBox(lpeobj) );
+ break;
+ case JOIN_TYPE:
+ neweffect = static_cast<Effect*> ( new LPEJoinType(lpeobj) );
+ break;
+ case TAPER_STROKE:
+ neweffect = static_cast<Effect*> ( new LPETaperStroke(lpeobj) );
+ break;
+ case SIMPLIFY:
+ neweffect = static_cast<Effect*> ( new LPESimplify(lpeobj) );
+ break;
+ case LATTICE2:
+ neweffect = static_cast<Effect*> ( new LPELattice2(lpeobj) );
+ break;
+ case PERSPECTIVE_ENVELOPE:
+ neweffect = static_cast<Effect*> ( new LPEPerspectiveEnvelope(lpeobj) );
+ break;
+ case FILLET_CHAMFER:
+ neweffect = static_cast<Effect*> ( new LPEFilletChamfer(lpeobj) );
+ break;
+ case ROUGHEN:
+ neweffect = static_cast<Effect*> ( new LPERoughen(lpeobj) );
+ break;
+ case SHOW_HANDLES:
+ neweffect = static_cast<Effect*> ( new LPEShowHandles(lpeobj) );
+ break;
default:
- g_warning("LivePathEffect::Effect::New called with invalid patheffect type (%d)", lpenr);
+ g_warning("LivePathEffect::Effect::New called with invalid patheffect type (%d)", lpenr);
neweffect = NULL;
break;
}
@@ -292,6 +368,7 @@ Effect::Effect(LivePathEffectObject *lpeobject)
{
registerParameter( dynamic_cast<Parameter *>(&is_visible) );
is_visible.widget_is_visible = false;
+ current_zoom = 0.0;
}
Effect::~Effect()
@@ -320,6 +397,38 @@ Effect::doOnApply (SPLPEItem const*/*lpeitem*/)
{
}
+void
+Effect::setSelectedNodePoints(std::vector<Geom::Point> sNP)
+{
+ selectedNodesPoints = sNP;
+}
+
+void
+Effect::setCurrentZoom(double cZ)
+{
+ current_zoom = cZ;
+}
+
+bool
+Effect::isNodePointSelected(Geom::Point const &nodePoint) const
+{
+ if (selectedNodesPoints.size() > 0) {
+ using Geom::X;
+ using Geom::Y;
+ for (std::vector<Geom::Point>::const_iterator i = selectedNodesPoints.begin();
+ i != selectedNodesPoints.end(); ++i) {
+ Geom::Point p = *i;
+ Geom::Affine transformCoordinate = sp_lpe_item->i2dt_affine();
+ Geom::Point p2(nodePoint[X],nodePoint[Y]);
+ p2 *= transformCoordinate;
+ if (Geom::are_near(p, p2, 0.01)) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
/**
* Is performed each time before the effect is updated.
*/
@@ -329,6 +438,35 @@ Effect::doBeforeEffect (SPLPEItem const*/*lpeitem*/)
//Do nothing for simple effects
}
+void Effect::doAfterEffect (SPLPEItem const* /*lpeitem*/)
+{
+}
+
+void Effect::doOnRemove (SPLPEItem const* /*lpeitem*/)
+{
+}
+
+//secret impl methods (shhhh!)
+void Effect::doOnApply_impl(SPLPEItem const* lpeitem)
+{
+ sp_lpe_item = const_cast<SPLPEItem *>(lpeitem);
+ defaultUnit = &sp_lpe_item->document->getDefaultUnit()->abbr;
+ /*sp_curve = SP_SHAPE(sp_lpe_item)->getCurve();
+ pathvector_before_effect = sp_curve->get_pathvector();*/
+ doOnApply(lpeitem);
+}
+
+void Effect::doBeforeEffect_impl(SPLPEItem const* lpeitem)
+{
+ sp_lpe_item = const_cast<SPLPEItem *>(lpeitem);
+ defaultUnit = &sp_lpe_item->document->getDefaultUnit()->abbr;
+ //printf("(SPLPEITEM*) %p\n", sp_lpe_item);
+ sp_curve = SP_SHAPE(sp_lpe_item)->getCurve();
+ pathvector_before_effect = sp_curve->get_pathvector();
+
+ doBeforeEffect(lpeitem);
+}
+
/**
* Effects can have a parameter path set before they are applied by accepting a nonzero number of
* mouse clicks. This method activates the pen context, which waits for the specified number of
@@ -496,11 +634,6 @@ Effect::getCanvasIndicators(SPLPEItem const* 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.
- return hp_vec;
- }
-
// add indicators provided by the effect itself
addCanvasIndicators(lpeitem, hp_vec);