summaryrefslogtreecommitdiffstats
path: root/src/live_effects
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2008-05-30 20:36:13 +0000
committerjohanengelen <johanengelen@users.sourceforge.net>2008-05-30 20:36:13 +0000
commit8e8734dc15e614586f9b4963b69671ce16d5c137 (patch)
tree036c4af16f6f673757e6e2c580a8ec5c4f3518de /src/live_effects
parentremove warnings (diff)
downloadinkscape-8e8734dc15e614586f9b4963b69671ce16d5c137.tar.gz
inkscape-8e8734dc15e614586f9b4963b69671ce16d5c137.zip
LPE STACKING!
(many thanks to the french students who made this.) (bzr r5766)
Diffstat (limited to 'src/live_effects')
-rw-r--r--src/live_effects/CMakeLists.txt3
-rw-r--r--src/live_effects/Makefile_insert17
-rw-r--r--src/live_effects/effect.cpp19
-rw-r--r--src/live_effects/effect.h3
-rw-r--r--src/live_effects/lpe-bendpath.cpp15
-rw-r--r--src/live_effects/lpe-bendpath.h2
-rw-r--r--src/live_effects/lpe-perp_bisector.cpp391
-rw-r--r--src/live_effects/lpe-perspective_path.cpp16
-rw-r--r--src/live_effects/lpe-perspective_path.h2
-rw-r--r--src/live_effects/lpe-tangent_to_curve.cpp318
-rw-r--r--src/live_effects/lpeobject-reference.cpp2
-rw-r--r--src/live_effects/lpeobject-reference.h2
12 files changed, 406 insertions, 384 deletions
diff --git a/src/live_effects/CMakeLists.txt b/src/live_effects/CMakeLists.txt
index 28d54d87c..7d3221357 100644
--- a/src/live_effects/CMakeLists.txt
+++ b/src/live_effects/CMakeLists.txt
@@ -13,13 +13,13 @@ lpe-constructgrid.h
lpe-curvestitch.cpp
lpe-curvestitch.h
lpe-envelope.cpp
-lpe-envelope.h
lpe-gears.cpp
lpe-gears.h
lpegroupbbox.cpp
lpegroupbbox.h
lpe-knot.cpp
lpe-knot.h
+lpe-lattice.cpp
lpeobject.cpp
lpeobject.h
lpeobject-reference.cpp
@@ -46,3 +46,4 @@ spiro.cpp
spiro.h
)
+
diff --git a/src/live_effects/Makefile_insert b/src/live_effects/Makefile_insert
index 4629a4d02..ea49aa269 100644
--- a/src/live_effects/Makefile_insert
+++ b/src/live_effects/Makefile_insert
@@ -32,8 +32,16 @@ live_effects_liblive_effects_a_SOURCES = \
live_effects/lpe-gears.h \
live_effects/lpe-test-doEffect-stack.cpp \
live_effects/lpe-test-doEffect-stack.h \
+ live_effects/lpe-lattice.cpp \
+ live_effects/lpe-lattice.h \
+ live_effects/lpe-envelope.cpp \
+ live_effects/lpe-envelope.h \
live_effects/lpe-spiro.cpp \
live_effects/lpe-spiro.h \
+ live_effects/lpe-tangent_to_curve.cpp \
+ live_effects/lpe-tangent_to_curve.h \
+ live_effects/lpe-perp_bisector.cpp \
+ live_effects/lpe-perp_bisector.h \
live_effects/spiro.h \
live_effects/spiro.cpp \
live_effects/bezctx.h \
@@ -42,11 +50,6 @@ live_effects_liblive_effects_a_SOURCES = \
live_effects/lpe-circle_with_radius.cpp \
live_effects/lpe-circle_with_radius.h \
live_effects/lpe-perspective_path.cpp \
- live_effects/lpe-perspective_path.h \
- live_effects/lpe-envelope.cpp \
- live_effects/lpe-envelope.h \
- live_effects/lpe-perp_bisector.cpp \
- live_effects/lpe-perp_bisector.h \
- live_effects/lpe-tangent_to_curve.cpp \
- live_effects/lpe-tangent_to_curve.h
+ live_effects/lpe-perspective_path.h
+
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index 906955575..f968ec5c0 100644
--- a/src/live_effects/effect.cpp
+++ b/src/live_effects/effect.cpp
@@ -43,8 +43,9 @@
#include "live_effects/lpe-circle_with_radius.h"
#include "live_effects/lpe-perspective_path.h"
#include "live_effects/lpe-spiro.h"
-#include "live_effects/lpe-constructgrid.h"
+#include "live_effects/lpe-lattice.h"
#include "live_effects/lpe-envelope.h"
+#include "live_effects/lpe-constructgrid.h"
#include "live_effects/lpe-perp_bisector.h"
#include "live_effects/lpe-tangent_to_curve.h"
// end of includes
@@ -66,14 +67,15 @@ const Util::EnumData<EffectType> LPETypeData[INVALID_LPE] = {
{DOEFFECTSTACK_TEST, N_("doEffect stack test"), "doeffectstacktest"},
#endif
{GEARS, N_("Gears"), "gears"},
- {CURVE_STITCH, N_("Stitch Sub-Paths"), "curvestitching"},
+ {CURVE_STITCH, N_("Stitch Sub-Paths"), "curvestitching"},
{CIRCLE_WITH_RADIUS, N_("Circle (center+radius)"), "circle_with_radius"},
{PERSPECTIVE_PATH, N_("Perspective path"), "perspective_path"},
{SPIRO, N_("Spiro spline"), "spiro"},
- {CONSTRUCT_GRID, N_("Construct grid"), "construct_grid"},
+ {LATTICE, N_("Lattice Deformation"), "lattice"},
{ENVELOPE, N_("Envelope Deformation"), "envelope"},
+ {CONSTRUCT_GRID, N_("Construct grid"), "construct_grid"},
{PERP_BISECTOR, N_("Perpendicular bisector"), "perp_bisector"},
- {TANGENT_TO_CURVE, N_("Tangent to curve"), "tangent_to_curve"},
+ {TANGENT_TO_CURVE, N_("Tangent to curve"), "tangent_to_curve"}
};
const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, INVALID_LPE);
@@ -108,6 +110,12 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj)
case CURVE_STITCH:
neweffect = static_cast<Effect*> ( new LPECurveStitch(lpeobj) );
break;
+ case LATTICE:
+ neweffect = static_cast<Effect*> ( new LPELattice(lpeobj) );
+ break;
+ case ENVELOPE:
+ neweffect = static_cast<Effect*> ( new LPEEnvelope(lpeobj) );
+ break;
case CIRCLE_WITH_RADIUS:
neweffect = static_cast<Effect*> ( new LPECircleWithRadius(lpeobj) );
break;
@@ -120,9 +128,6 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj)
case CONSTRUCT_GRID:
neweffect = static_cast<Effect*> ( new LPEConstructGrid(lpeobj) );
break;
- case ENVELOPE:
- neweffect = static_cast<Effect*> ( new LPEEnvelope(lpeobj) );
- break;
case PERP_BISECTOR:
neweffect = static_cast<Effect*> ( new LPEPerpBisector(lpeobj) );
break;
diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h
index 1255595d0..d5a49d71e 100644
--- a/src/live_effects/effect.h
+++ b/src/live_effects/effect.h
@@ -66,8 +66,9 @@ enum EffectType {
CIRCLE_WITH_RADIUS,
PERSPECTIVE_PATH,
SPIRO,
- CONSTRUCT_GRID,
+ LATTICE,
ENVELOPE,
+ CONSTRUCT_GRID,
PERP_BISECTOR,
TANGENT_TO_CURVE,
INVALID_LPE // This must be last
diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp
index 6b9fbbb97..282ea8270 100644
--- a/src/live_effects/lpe-bendpath.cpp
+++ b/src/live_effects/lpe-bendpath.cpp
@@ -68,8 +68,6 @@ LPEBendPath::LPEBendPath(LivePathEffectObject *lpeobject) :
prop_scale.param_set_increments(0.01, 0.10);
concatenate_before_pwd2 = true;
-
- groupSpecialBehavior = false;
}
LPEBendPath::~LPEBendPath()
@@ -80,12 +78,8 @@ LPEBendPath::~LPEBendPath()
void
LPEBendPath::doBeforeEffect (SPLPEItem *lpeitem)
{
- if(SP_IS_GROUP(lpeitem))
- {
- groupSpecialBehavior = true;
-
- original_bbox(lpeitem);
- }
+ // get the item bounding box
+ original_bbox(lpeitem);
}
Geom::Piecewise<Geom::D2<Geom::SBasis> >
@@ -105,11 +99,6 @@ LPEBendPath::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd
Piecewise<SBasis> y = vertical_pattern.get_value() ? Piecewise<SBasis>(patternd2[0]) : Piecewise<SBasis>(patternd2[1]);
//We use the group bounding box size or the path bbox size to translate well x and y
- if(groupSpecialBehavior == false)
- {
- boundingbox_X = bounds_exact(x);
- boundingbox_Y = bounds_exact(y);
- }
x-= vertical_pattern.get_value() ? boundingbox_Y.min() : boundingbox_X.min();
y-= vertical_pattern.get_value() ? boundingbox_X.middle() : boundingbox_Y.middle();
diff --git a/src/live_effects/lpe-bendpath.h b/src/live_effects/lpe-bendpath.h
index e05112de9..1d3a9861e 100644
--- a/src/live_effects/lpe-bendpath.h
+++ b/src/live_effects/lpe-bendpath.h
@@ -47,8 +47,6 @@ private:
BoolParam scale_y_rel;
BoolParam vertical_pattern;
- bool groupSpecialBehavior;
-
void on_pattern_pasted();
LPEBendPath(const LPEBendPath&);
diff --git a/src/live_effects/lpe-perp_bisector.cpp b/src/live_effects/lpe-perp_bisector.cpp
index b31ad6696..52a21fbaf 100644
--- a/src/live_effects/lpe-perp_bisector.cpp
+++ b/src/live_effects/lpe-perp_bisector.cpp
@@ -1,187 +1,204 @@
-#define INKSCAPE_LPE_PERP_BISECTOR_CPP
-/** \file
- * LPE <perp_bisector> implementation.
- */
-/*
- * Authors:
- * Maximilian Albert
- * Johan Engelen
- *
- * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
- * Copyright (C) Maximilin Albert 2008 <maximilian.albert@gmail.com>
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#include "live_effects/lpe-perp_bisector.h"
-#include "display/curve.h"
-#include <libnr/n-art-bpath.h>
-#include "sp-path.h"
-#include "line-geometry.h"
-
-#include <2geom/path.h>
-
-namespace Inkscape {
-namespace LivePathEffect {
-
-/* FIXME: We should arguably make these member functions of LPEPerpBisector.
- Is there an easy way to register member functions with knotholder?
- */
-NR::Point bisector_left_end_get(SPItem *item) {
- Inkscape::LivePathEffect::LPEPerpBisector *lpe =
- (Inkscape::LivePathEffect::LPEPerpBisector *) sp_lpe_item_get_livepatheffect(SP_LPE_ITEM(item));
-
- return NR::Point(lpe->C);
-}
-
-NR::Point bisector_right_end_get(SPItem *item) {
- Inkscape::LivePathEffect::LPEPerpBisector *lpe =
- (Inkscape::LivePathEffect::LPEPerpBisector *) sp_lpe_item_get_livepatheffect(SP_LPE_ITEM(item));
-
- return NR::Point(lpe->D);
-}
-
-void
-bisector_end_set(SPItem *item, NR::Point const &p, bool left) {
- Inkscape::LivePathEffect::LPEPerpBisector *lpe =
- (Inkscape::LivePathEffect::LPEPerpBisector *) sp_lpe_item_get_livepatheffect(SP_LPE_ITEM(item));
-
- double lambda = Geom::nearest_point(p.to_2geom(), lpe->M, lpe->perp_dir);
- if (left) {
- lpe->C = lpe->M + lpe->perp_dir * lambda;
- lpe->length_left.param_set_value(lambda);
- } else {
- lpe->D = lpe->M + lpe->perp_dir * lambda;
- lpe->length_right.param_set_value(-lambda);
- }
-
- sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), true);
-}
-
-void
-bisector_left_end_set(SPItem *item, NR::Point const &p, NR::Point const &/*origin*/, guint /*state*/) {
- bisector_end_set(item, p);
-}
-
-void
-bisector_right_end_set(SPItem *item, NR::Point const &p, NR::Point const &/*origin*/, guint /*state*/) {
- bisector_end_set(item, p, false);
-}
-
-NR::Point path_start_get(SPItem *item) {
- Inkscape::LivePathEffect::LPEPerpBisector *lpe =
- (Inkscape::LivePathEffect::LPEPerpBisector *) sp_lpe_item_get_livepatheffect(SP_LPE_ITEM(item));
-
- return NR::Point(lpe->A);
-}
-
-NR::Point path_end_get(SPItem *item) {
- Inkscape::LivePathEffect::LPEPerpBisector *lpe =
- (Inkscape::LivePathEffect::LPEPerpBisector *) sp_lpe_item_get_livepatheffect(SP_LPE_ITEM(item));
-
- return NR::Point(lpe->B);
-}
-
-void
-path_set_start_end(SPItem *item, NR::Point const &p, bool start) {
- SPCurve* curve = sp_path_get_curve_for_edit (SP_PATH(item)); // TODO: Should we use sp_shape_get_curve()?
- NR::Matrix const i2d (sp_item_i2d_affine (SP_ITEM(item)));
-
- Geom::Point A, B;
- if (start) {
- A = p.to_2geom();
- B = (curve->last_point()).to_2geom();
- } else {
- A = (curve->first_point()).to_2geom();
- B = (p.to_2geom());
- }
-
- SPCurve *c = new SPCurve();
- c->moveto(A);
- c->lineto(B);
- sp_path_set_original_curve(SP_PATH(item), c, TRUE, true);
- c->unref();
-}
-
-void path_start_set(SPItem *item, NR::Point const &p, NR::Point const &/*origin*/, guint /*state*/) {
- path_set_start_end(item, p);
-}
-
-void path_end_set(SPItem *item, NR::Point const &p, NR::Point const &/*origin*/, guint /*state*/) {
- path_set_start_end(item, p, false);
-}
-
-LPEPerpBisector::LPEPerpBisector(LivePathEffectObject *lpeobject) :
- Effect(lpeobject),
- length_left(_("Length left"), _("Specifies the left end of the bisector"), "length-left", &wr, this, 200),
- length_right(_("Length right"), _("Specifies the right end of the bisector"), "length-right", &wr, this, 200),
- A(0,0), B(0,0), M(0,0), C(0,0), D(0,0), perp_dir(0,0)
-{
- // register all your parameters here, so Inkscape knows which parameters this effect has:
- registerParameter( dynamic_cast<Parameter *>(&length_left) );
- registerParameter( dynamic_cast<Parameter *>(&length_right) );
-
- registerKnotHolderHandle(path_start_set, path_start_get);
- registerKnotHolderHandle(path_end_set, path_end_get);
- registerKnotHolderHandle(bisector_left_end_set, bisector_left_end_get);
- registerKnotHolderHandle(bisector_right_end_set, bisector_right_end_get);
-}
-
-LPEPerpBisector::~LPEPerpBisector()
-{
-}
-
-void
-LPEPerpBisector::doOnApply (SPLPEItem *lpeitem)
-{
- /* make the path a straight line */
- SPCurve* curve = sp_path_get_curve_for_edit (SP_PATH(lpeitem)); // TODO: Should we use sp_shape_get_curve()?
-
- Geom::Point A((curve->first_point()).to_2geom());
- Geom::Point B((curve->last_point()).to_2geom());
-
- SPCurve *c = new SPCurve();
- c->moveto(A);
- c->lineto(B);
- // TODO: Why doesn't sp_path_set_original_curve(SP_PATH(lpeitem), c, TRUE, true) work?
- SP_PATH(lpeitem)->original_curve = c->ref();
- c->unref();
-}
-
-
-Geom::Piecewise<Geom::D2<Geom::SBasis> >
-LPEPerpBisector::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in)
-{
- using namespace Geom;
-
- Piecewise<D2<SBasis> > output;
-
- A = pwd2_in.firstValue();
- B = pwd2_in.lastValue();
- M = (A + B)/2;
-
- perp_dir = unit_vector((B - A).ccw());
-
- C = M + perp_dir * length_left;
- D = M - perp_dir * length_right;
-
- output = Piecewise<D2<SBasis> >(D2<SBasis>(Linear(C[X], D[X]), Linear(C[Y], D[Y])));
-
- return output;
-}
-
-/* ######################## */
-
-} //namespace LivePathEffect
-} /* namespace Inkscape */
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
+#define INKSCAPE_LPE_PERP_BISECTOR_CPP
+/** \file
+ * LPE <perp_bisector> implementation.
+ */
+/*
+ * Authors:
+ * Maximilian Albert
+ * Johan Engelen
+ *
+ * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ * Copyright (C) Maximilin Albert 2008 <maximilian.albert@gmail.com>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "live_effects/lpe-perp_bisector.h"
+#include "display/curve.h"
+#include <libnr/n-art-bpath.h>
+#include "sp-path.h"
+#include "line-geometry.h"
+#include "sp-lpe-item.h"
+#include <2geom/path.h>
+
+namespace Inkscape {
+namespace LivePathEffect {
+
+/* FIXME: We should make these member functions of LPEPerpBisector.
+ Is there an easy way to register member functions with knotholder?
+ KNOWN BUG: Because of the above, this effect does not work well when in an LPE stack
+ */
+NR::Point bisector_left_end_get(SPItem *item) {
+ Inkscape::LivePathEffect::LPEPerpBisector *lpe =
+ dynamic_cast<Inkscape::LivePathEffect::LPEPerpBisector *> (sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)));
+
+ if (lpe)
+ return NR::Point(lpe->C);
+ else
+ return NR::Point(0,0);
+}
+
+NR::Point bisector_right_end_get(SPItem *item) {
+ Inkscape::LivePathEffect::LPEPerpBisector *lpe =
+ dynamic_cast<Inkscape::LivePathEffect::LPEPerpBisector *> (sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)));
+
+ if (lpe)
+ return NR::Point(lpe->D);
+ else
+ return NR::Point(0,0);
+}
+
+void
+bisector_end_set(SPItem *item, NR::Point const &p, bool left) {
+ Inkscape::LivePathEffect::LPEPerpBisector *lpe =
+ dynamic_cast<Inkscape::LivePathEffect::LPEPerpBisector *> (sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)));
+
+ if (!lpe)
+ return;
+
+ double lambda = Geom::nearest_point(p.to_2geom(), lpe->M, lpe->perp_dir);
+ if (left) {
+ lpe->C = lpe->M + lpe->perp_dir * lambda;
+ lpe->length_left.param_set_value(lambda);
+ } else {
+ lpe->D = lpe->M + lpe->perp_dir * lambda;
+ lpe->length_right.param_set_value(-lambda);
+ }
+
+ // FIXME: this should not directly ask for updating the item. It should write to SVG, which triggers updating.
+ sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), true, true);
+}
+
+void
+bisector_left_end_set(SPItem *item, NR::Point const &p, NR::Point const &/*origin*/, guint /*state*/) {
+ bisector_end_set(item, p);
+}
+
+void
+bisector_right_end_set(SPItem *item, NR::Point const &p, NR::Point const &/*origin*/, guint /*state*/) {
+ bisector_end_set(item, p, false);
+}
+
+NR::Point path_start_get(SPItem *item) {
+ Inkscape::LivePathEffect::LPEPerpBisector *lpe =
+ dynamic_cast<Inkscape::LivePathEffect::LPEPerpBisector *> (sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)));
+
+ if (lpe)
+ return NR::Point(lpe->A);
+ else
+ return NR::Point(0,0);
+}
+
+NR::Point path_end_get(SPItem *item) {
+ Inkscape::LivePathEffect::LPEPerpBisector *lpe =
+ dynamic_cast<Inkscape::LivePathEffect::LPEPerpBisector *> (sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)));
+
+ if (lpe)
+ return NR::Point(lpe->B);
+ else
+ return NR::Point(0,0);
+}
+
+void
+path_set_start_end(SPItem *item, NR::Point const &p, bool start) {
+ SPCurve* curve = sp_path_get_curve_for_edit (SP_PATH(item)); // TODO: Should we use sp_shape_get_curve()?
+ NR::Matrix const i2d (sp_item_i2d_affine (SP_ITEM(item)));
+
+ Geom::Point A, B;
+ if (start) {
+ A = p.to_2geom();
+ B = (curve->last_point()).to_2geom();
+ } else {
+ A = (curve->first_point()).to_2geom();
+ B = (p.to_2geom());
+ }
+
+ SPCurve *c = new SPCurve();
+ c->moveto(A);
+ c->lineto(B);
+ sp_path_set_original_curve(SP_PATH(item), c, TRUE, true);
+ c->unref();
+}
+
+void path_start_set(SPItem *item, NR::Point const &p, NR::Point const &/*origin*/, guint /*state*/) {
+ path_set_start_end(item, p);
+}
+
+void path_end_set(SPItem *item, NR::Point const &p, NR::Point const &/*origin*/, guint /*state*/) {
+ path_set_start_end(item, p, false);
+}
+
+LPEPerpBisector::LPEPerpBisector(LivePathEffectObject *lpeobject) :
+ Effect(lpeobject),
+ length_left(_("Length left"), _("Specifies the left end of the bisector"), "length-left", &wr, this, 200),
+ length_right(_("Length right"), _("Specifies the right end of the bisector"), "length-right", &wr, this, 200),
+ A(0,0), B(0,0), M(0,0), C(0,0), D(0,0), perp_dir(0,0)
+{
+ // register all your parameters here, so Inkscape knows which parameters this effect has:
+ registerParameter( dynamic_cast<Parameter *>(&length_left) );
+ registerParameter( dynamic_cast<Parameter *>(&length_right) );
+
+ registerKnotHolderHandle(path_start_set, path_start_get);
+ registerKnotHolderHandle(path_end_set, path_end_get);
+ registerKnotHolderHandle(bisector_left_end_set, bisector_left_end_get);
+ registerKnotHolderHandle(bisector_right_end_set, bisector_right_end_get);
+}
+
+LPEPerpBisector::~LPEPerpBisector()
+{
+}
+
+void
+LPEPerpBisector::doOnApply (SPLPEItem *lpeitem)
+{
+ /* make the path a straight line */
+ SPCurve* curve = sp_path_get_curve_for_edit (SP_PATH(lpeitem)); // TODO: Should we use sp_shape_get_curve()?
+
+ Geom::Point A((curve->first_point()).to_2geom());
+ Geom::Point B((curve->last_point()).to_2geom());
+
+ SPCurve *c = new SPCurve();
+ c->moveto(A);
+ c->lineto(B);
+ // TODO: Why doesn't sp_path_set_original_curve(SP_PATH(lpeitem), c, TRUE, true) work?
+ SP_PATH(lpeitem)->original_curve = c->ref();
+ c->unref();
+}
+
+
+Geom::Piecewise<Geom::D2<Geom::SBasis> >
+LPEPerpBisector::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in)
+{
+ using namespace Geom;
+
+ Piecewise<D2<SBasis> > output;
+
+ A = pwd2_in.firstValue();
+ B = pwd2_in.lastValue();
+ M = (A + B)/2;
+
+ perp_dir = unit_vector((B - A).ccw());
+
+ C = M + perp_dir * length_left;
+ D = M - perp_dir * length_right;
+
+ output = Piecewise<D2<SBasis> >(D2<SBasis>(Linear(C[X], D[X]), Linear(C[Y], D[Y])));
+
+ return output;
+}
+
+/* ######################## */
+
+} //namespace LivePathEffect
+} /* namespace Inkscape */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/live_effects/lpe-perspective_path.cpp b/src/live_effects/lpe-perspective_path.cpp
index 57bc458a9..cf6d1cecd 100644
--- a/src/live_effects/lpe-perspective_path.cpp
+++ b/src/live_effects/lpe-perspective_path.cpp
@@ -59,8 +59,6 @@ LPEPerspectivePath::LPEPerspectivePath(LivePathEffectObject *lpeobject) :
Proj::TransfMat3x4 pmat = persp->tmat;
pmat.copy_tmat(tmat);
-
- groupSpecialBehavior = false;
}
LPEPerspectivePath::~LPEPerspectivePath()
@@ -71,14 +69,9 @@ LPEPerspectivePath::~LPEPerspectivePath()
void
LPEPerspectivePath::doBeforeEffect (SPLPEItem *lpeitem)
{
- if(SP_IS_GROUP(lpeitem))
- {
- groupSpecialBehavior = true;
- original_bbox(lpeitem);
- }
+ original_bbox(lpeitem, true);
}
-
Geom::Piecewise<Geom::D2<Geom::SBasis> >
LPEPerspectivePath::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in)
{
@@ -93,14 +86,9 @@ LPEPerspectivePath::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > cons
D2<Piecewise<SBasis> > B = make_cuts_independant(path_a_pw);
Piecewise<SBasis> preimage[4];
- if(!groupSpecialBehavior)
- {
- boundingbox_X = bounds_fast(pwd2_in)[0];
- boundingbox_Y = bounds_fast(pwd2_in)[1];
- }
-
Geom::Point orig = Geom::Point(uses_plane_xy ? boundingbox_X.max() : boundingbox_X.min(),
boundingbox_Y.middle());
+
//Geom::Point orig = Geom::Point(bounds_X.min(), bounds_Y.middle());
//orig = Geom::Point(orig[X], sp_document_height(inkscape_active_document()) - orig[Y]);
diff --git a/src/live_effects/lpe-perspective_path.h b/src/live_effects/lpe-perspective_path.h
index a2f451e65..02dcf2325 100644
--- a/src/live_effects/lpe-perspective_path.h
+++ b/src/live_effects/lpe-perspective_path.h
@@ -48,8 +48,6 @@ private:
std::vector<Geom::Point> handles;
double tmat[3][4];
-
- bool groupSpecialBehavior;
};
} //namespace LivePathEffect
diff --git a/src/live_effects/lpe-tangent_to_curve.cpp b/src/live_effects/lpe-tangent_to_curve.cpp
index 65948837f..6293ba233 100644
--- a/src/live_effects/lpe-tangent_to_curve.cpp
+++ b/src/live_effects/lpe-tangent_to_curve.cpp
@@ -1,148 +1,170 @@
-#define INKSCAPE_LPE_TANGENT_TO_CURVE_CPP
-/** \file
- * Implementation of tangent-to-curve LPE.
- */
-
-/*
- * Authors:
- * Johan Engelen
- * Maximilian Albert
- *
- * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
- * Copyright (C) Maximilian Albert 2008 <maximilian.albert@gmail.com>
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#include "live_effects/lpe-tangent_to_curve.h"
-// FIXME: The following are only needed to convert the path's SPCurve* to pwd2.
-// There must be a more convenient way to achieve this.
-#include "sp-path.h"
-#include "display/curve.h"
-#include "libnr/n-art-bpath-2geom.h"
-
-#include <2geom/path.h>
-#include <2geom/transforms.h>
-
-namespace Inkscape {
-namespace LivePathEffect {
-
-/* FIXME: We should arguably make these member functions of LPETangentToCurve.
- Is there an easy way to register member functions with knotholder?
- */
-NR::Point attach_pt_get(SPItem *item) {
- Inkscape::LivePathEffect::LPETangentToCurve *lpe =
- (Inkscape::LivePathEffect::LPETangentToCurve *) sp_lpe_item_get_livepatheffect(SP_LPE_ITEM(item));
-
- return lpe->ptA;
-}
-
-void attach_pt_set(SPItem *item, NR::Point const &p, NR::Point const &origin, guint state) {
- Inkscape::LivePathEffect::LPETangentToCurve *lpe =
- (Inkscape::LivePathEffect::LPETangentToCurve *) sp_lpe_item_get_livepatheffect(SP_LPE_ITEM(item));
-
- using namespace Geom;
-
- // FIXME: There must be a better way of converting the path's SPCurve* to pwd2.
- SPCurve *curve = sp_path_get_curve_for_edit (SP_PATH(item));
- const NArtBpath *bpath = curve->get_bpath();
- Piecewise<D2<SBasis> > pwd2;
- std::vector<Geom::Path> pathv = BPath_to_2GeomPath(bpath);
- for (unsigned int i=0; i < pathv.size(); i++) {
- pwd2.concat(pathv[i].toPwSb());
- }
-
- double t0 = nearest_point(p.to_2geom(), pwd2);
- lpe->t_attach.param_set_value(t0);
-
- sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), true);
-}
-
-NR::Point left_end_get(SPItem *item) {
- Inkscape::LivePathEffect::LPETangentToCurve *lpe =
- (Inkscape::LivePathEffect::LPETangentToCurve *) sp_lpe_item_get_livepatheffect(SP_LPE_ITEM(item));
-
- return lpe->C;
-}
-
-NR::Point right_end_get(SPItem *item) {
- Inkscape::LivePathEffect::LPETangentToCurve *lpe =
- (Inkscape::LivePathEffect::LPETangentToCurve *) sp_lpe_item_get_livepatheffect(SP_LPE_ITEM(item));
-
- return lpe->D;
-}
-
-void left_end_set(SPItem *item, NR::Point const &p, NR::Point const &origin, guint state) {
- Inkscape::LivePathEffect::LPETangentToCurve *lpe =
- (Inkscape::LivePathEffect::LPETangentToCurve *) sp_lpe_item_get_livepatheffect(SP_LPE_ITEM(item));
-
- double lambda = Geom::nearest_point(p.to_2geom(), lpe->ptA, lpe->derivA);
- lpe->length_left.param_set_value(-lambda);
-
- sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), true);
-}
-
-void right_end_set(SPItem *item, NR::Point const &p, NR::Point const &origin, guint state) {
- Inkscape::LivePathEffect::LPETangentToCurve *lpe =
- (Inkscape::LivePathEffect::LPETangentToCurve *) sp_lpe_item_get_livepatheffect(SP_LPE_ITEM(item));
-
- double lambda = Geom::nearest_point(p.to_2geom(), lpe->ptA, lpe->derivA);
- lpe->length_right.param_set_value(lambda);
-
- sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), true);
-}
-
-LPETangentToCurve::LPETangentToCurve(LivePathEffectObject *lpeobject) :
- Effect(lpeobject),
- t_attach(_("Location along curve"), _("Location of the point of attachment along the curve (between 0.0 and number-of-segments)"), "t_attach", &wr, this, 0.5),
- length_left(_("Length left"), _("Specifies the left end of the tangent"), "length-left", &wr, this, 150),
- length_right(_("Length right"), _("Specifies the right end of the tangent"), "length-right", &wr, this, 150),
- angle(_("Angle"), _("Additional angle between tangent and curve"), "angle", &wr, this, 0.0)
-{
- registerParameter( dynamic_cast<Parameter *>(&t_attach) );
- registerParameter( dynamic_cast<Parameter *>(&length_left) );
- registerParameter( dynamic_cast<Parameter *>(&length_right) );
- registerParameter( dynamic_cast<Parameter *>(&angle) );
- registerKnotHolderHandle(attach_pt_set, attach_pt_get);
- registerKnotHolderHandle(left_end_set, left_end_get);
- registerKnotHolderHandle(right_end_set, right_end_get);
-}
-
-LPETangentToCurve::~LPETangentToCurve()
-{
-}
-
-Geom::Piecewise<Geom::D2<Geom::SBasis> >
-LPETangentToCurve::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in)
-{
- using namespace Geom;
- Piecewise<D2<SBasis> > output;
-
- ptA = pwd2_in.valueAt(t_attach);
- derivA = unit_vector(derivative(pwd2_in).valueAt(t_attach));
-
- // TODO: Why are positive angles measured clockwise, not counterclockwise?
- Geom::Rotate rot(Geom::Rotate::from_degrees(-angle));
- derivA = derivA * rot;
-
- C = ptA - derivA * length_left;
- D = ptA + derivA * length_right;
-
- output = Piecewise<D2<SBasis> >(D2<SBasis>(Linear(C[X], D[X]), Linear(C[Y], D[Y])));
-
- return output;
-}
-
-} //namespace LivePathEffect
-} /* namespace Inkscape */
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
+#define INKSCAPE_LPE_TANGENT_TO_CURVE_CPP
+/** \file
+ * Implementation of tangent-to-curve LPE.
+ */
+
+/*
+ * Authors:
+ * Johan Engelen
+ * Maximilian Albert
+ *
+ * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ * Copyright (C) Maximilian Albert 2008 <maximilian.albert@gmail.com>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "live_effects/lpe-tangent_to_curve.h"
+// FIXME: The following are only needed to convert the path's SPCurve* to pwd2.
+// There must be a more convenient way to achieve this.
+#include "sp-path.h"
+#include "display/curve.h"
+#include "libnr/n-art-bpath-2geom.h"
+
+#include <2geom/path.h>
+#include <2geom/transforms.h>
+
+namespace Inkscape {
+namespace LivePathEffect {
+
+/* FIXME: We should make these member functions of LPETangentToCurve.
+ Is there an easy way to register member functions with knotholder?
+ KNOWN BUG: Because of the above, this effect does not work well when in an LPE stack
+*/
+NR::Point attach_pt_get(SPItem *item) {
+ Inkscape::LivePathEffect::LPETangentToCurve *lpe =
+ dynamic_cast<Inkscape::LivePathEffect::LPETangentToCurve *> (sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)));
+
+ if (lpe)
+ return lpe->ptA;
+ else
+ return NR::Point(0,0);
+}
+
+void attach_pt_set(SPItem *item, NR::Point const &p, NR::Point const &origin, guint state) {
+ Inkscape::LivePathEffect::LPETangentToCurve *lpe =
+ dynamic_cast<Inkscape::LivePathEffect::LPETangentToCurve *> (sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)));
+
+ if (!lpe)
+ return;
+
+ using namespace Geom;
+
+ // FIXME: There must be a better way of converting the path's SPCurve* to pwd2.
+ SPCurve *curve = sp_path_get_curve_for_edit (SP_PATH(item));
+ const NArtBpath *bpath = curve->get_bpath();
+ Piecewise<D2<SBasis> > pwd2;
+ std::vector<Geom::Path> pathv = BPath_to_2GeomPath(bpath);
+ for (unsigned int i=0; i < pathv.size(); i++) {
+ pwd2.concat(pathv[i].toPwSb());
+ }
+
+ double t0 = nearest_point(p.to_2geom(), pwd2);
+ lpe->t_attach.param_set_value(t0);
+
+ // FIXME: this should not directly ask for updating the item. It should write to SVG, which triggers updating.
+ sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), true, true);
+}
+
+NR::Point left_end_get(SPItem *item) {
+ Inkscape::LivePathEffect::LPETangentToCurve *lpe =
+ dynamic_cast<Inkscape::LivePathEffect::LPETangentToCurve *> (sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)));
+
+ if (lpe)
+ return lpe->C;
+ else
+ return NR::Point(0,0);
+}
+
+NR::Point right_end_get(SPItem *item) {
+ Inkscape::LivePathEffect::LPETangentToCurve *lpe =
+ dynamic_cast<Inkscape::LivePathEffect::LPETangentToCurve *> (sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)));
+
+ if (lpe)
+ return lpe->D;
+ else
+ return NR::Point(0,0);
+}
+
+void left_end_set(SPItem *item, NR::Point const &p, NR::Point const &origin, guint state) {
+ Inkscape::LivePathEffect::LPETangentToCurve *lpe =
+ dynamic_cast<Inkscape::LivePathEffect::LPETangentToCurve *> (sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)));
+
+ if (!lpe)
+ return;
+
+ double lambda = Geom::nearest_point(p.to_2geom(), lpe->ptA, lpe->derivA);
+ lpe->length_left.param_set_value(-lambda);
+
+ // FIXME: this should not directly ask for updating the item. It should write to SVG, which triggers updating.
+ sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), true, true);
+}
+
+void right_end_set(SPItem *item, NR::Point const &p, NR::Point const &origin, guint state) {
+ Inkscape::LivePathEffect::LPETangentToCurve *lpe =
+ dynamic_cast<Inkscape::LivePathEffect::LPETangentToCurve *> (sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)));
+
+ if (!lpe)
+ return;
+
+ double lambda = Geom::nearest_point(p.to_2geom(), lpe->ptA, lpe->derivA);
+ lpe->length_right.param_set_value(lambda);
+
+ // FIXME: this should not directly ask for updating the item. It should write to SVG, which triggers updating.
+ sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), true, true);
+}
+
+LPETangentToCurve::LPETangentToCurve(LivePathEffectObject *lpeobject) :
+ Effect(lpeobject),
+ t_attach(_("Location along curve"), _("Location of the point of attachment along the curve (between 0.0 and number-of-segments)"), "t_attach", &wr, this, 0.5),
+ length_left(_("Length left"), _("Specifies the left end of the tangent"), "length-left", &wr, this, 150),
+ length_right(_("Length right"), _("Specifies the right end of the tangent"), "length-right", &wr, this, 150),
+ angle(_("Angle"), _("Additional angle between tangent and curve"), "angle", &wr, this, 0.0)
+{
+ registerParameter( dynamic_cast<Parameter *>(&t_attach) );
+ registerParameter( dynamic_cast<Parameter *>(&length_left) );
+ registerParameter( dynamic_cast<Parameter *>(&length_right) );
+ registerParameter( dynamic_cast<Parameter *>(&angle) );
+ registerKnotHolderHandle(attach_pt_set, attach_pt_get);
+ registerKnotHolderHandle(left_end_set, left_end_get);
+ registerKnotHolderHandle(right_end_set, right_end_get);
+}
+
+LPETangentToCurve::~LPETangentToCurve()
+{
+}
+
+Geom::Piecewise<Geom::D2<Geom::SBasis> >
+LPETangentToCurve::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in)
+{
+ using namespace Geom;
+ Piecewise<D2<SBasis> > output;
+
+ ptA = pwd2_in.valueAt(t_attach);
+ derivA = unit_vector(derivative(pwd2_in).valueAt(t_attach));
+
+ // TODO: Why are positive angles measured clockwise, not counterclockwise?
+ Geom::Rotate rot(Geom::Rotate::from_degrees(-angle));
+ derivA = derivA * rot;
+
+ C = ptA - derivA * length_left;
+ D = ptA + derivA * length_right;
+
+ output = Piecewise<D2<SBasis> >(D2<SBasis>(Linear(C[X], D[X]), Linear(C[Y], D[Y])));
+
+ return output;
+}
+
+} //namespace LivePathEffect
+} /* namespace Inkscape */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/live_effects/lpeobject-reference.cpp b/src/live_effects/lpeobject-reference.cpp
index 34005e791..8a8dd94da 100644
--- a/src/live_effects/lpeobject-reference.cpp
+++ b/src/live_effects/lpeobject-reference.cpp
@@ -59,7 +59,7 @@ bool LPEObjectReference::_acceptObject(SPObject * const obj) const
}
void
-LPEObjectReference::link(char *to)
+LPEObjectReference::link(const char *to)
{
if ( to == NULL ) {
quit_listening();
diff --git a/src/live_effects/lpeobject-reference.h b/src/live_effects/lpeobject-reference.h
index 6a2f75327..e5f7556f1 100644
--- a/src/live_effects/lpeobject-reference.h
+++ b/src/live_effects/lpeobject-reference.h
@@ -41,7 +41,7 @@ public:
sigc::connection _delete_connection;
sigc::connection _changed_connection;
- void link(char* to);
+ void link(const char* to);
void unlink(void);
void start_listening(LivePathEffectObject* to);
void quit_listening(void);