summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/effect.h2
-rw-r--r--src/live_effects/lpe-perp_bisector.cpp93
-rw-r--r--src/live_effects/lpe-perp_bisector.h18
-rw-r--r--src/live_effects/lpe-tangent_to_curve.cpp17
-rw-r--r--src/live_effects/lpe-tangent_to_curve.h15
5 files changed, 100 insertions, 45 deletions
diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h
index a990a858d..21d86f80a 100644
--- a/src/live_effects/effect.h
+++ b/src/live_effects/effect.h
@@ -101,7 +101,7 @@ public:
virtual void transform_multiply(Geom::Matrix const& postmul, bool set);
- virtual bool providesKnotholder() { return false; }
+ bool providesKnotholder() { return (kh_entity_vector.size() > 0); }
void addHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
Glib::ustring getName();
diff --git a/src/live_effects/lpe-perp_bisector.cpp b/src/live_effects/lpe-perp_bisector.cpp
index 139ca21bf..9c7ed0a7e 100644
--- a/src/live_effects/lpe-perp_bisector.cpp
+++ b/src/live_effects/lpe-perp_bisector.cpp
@@ -23,29 +23,50 @@
namespace Inkscape {
namespace LivePathEffect {
+namespace PB {
-/* 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)));
+class KnotHolderEntityLeftEnd : public KnotHolderEntity
+{
+public:
+ virtual bool isLPEParam() { return true; }
- if (lpe)
- return NR::Point(lpe->C);
- else
- return NR::Point(0,0);
+ virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
+ virtual NR::Point knot_get();
+ virtual void onKnotUngrabbed();
+};
+
+class KnotHolderEntityRightEnd : public KnotHolderEntity
+{
+public:
+ virtual bool isLPEParam() { return true; }
+
+ virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
+ virtual NR::Point knot_get();
+ virtual void onKnotUngrabbed();
+};
+
+// TODO: Make this more generic
+static LPEPerpBisector *
+get_effect(SPItem *item)
+{
+ Effect *effect = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item));
+ if (effect->effectType() != PERP_BISECTOR) {
+ g_print ("Warning: Effect is not of type LPEPerpBisector!\n");
+ return NULL;
+ }
+ return static_cast<LPEPerpBisector *>(effect);
}
-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)));
+NR::Point
+KnotHolderEntityLeftEnd::knot_get() {
+ Inkscape::LivePathEffect::LPEPerpBisector *lpe = get_effect(item);
+ return NR::Point(lpe->C);
+}
- if (lpe)
- return NR::Point(lpe->D);
- else
- return NR::Point(0,0);
+NR::Point
+KnotHolderEntityRightEnd::knot_get() {
+ Inkscape::LivePathEffect::LPEPerpBisector *lpe = get_effect(item);
+ return NR::Point(lpe->D);
}
void
@@ -70,15 +91,30 @@ bisector_end_set(SPItem *item, NR::Point const &p, bool left) {
}
void
-bisector_left_end_set(SPItem *item, NR::Point const &p, NR::Point const &/*origin*/, guint /*state*/) {
+KnotHolderEntityLeftEnd::knot_set(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*/) {
+KnotHolderEntityRightEnd::knot_set(NR::Point const &p, NR::Point const &/*origin*/, guint /*state*/) {
bisector_end_set(item, p, false);
}
+void
+KnotHolderEntityLeftEnd::onKnotUngrabbed()
+{
+ LPEPerpBisector *lpe = get_effect(item);
+ lpe->length_left.write_to_SVG();
+}
+
+void
+KnotHolderEntityRightEnd::onKnotUngrabbed()
+{
+ LPEPerpBisector *lpe = get_effect(item);
+ lpe->length_right.write_to_SVG();
+}
+
+/**
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)));
@@ -119,14 +155,17 @@ path_set_start_end(SPItem *item, NR::Point const &p, bool start) {
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_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);
-}
+//void path_end_set(SPItem *item, NR::Point const &p, NR::Point const &/*origin*/, guint /*state*/) {
+// path_set_start_end(item, p, false);
+//}
+
+} //namescape PB
LPEPerpBisector::LPEPerpBisector(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
@@ -138,6 +177,8 @@ LPEPerpBisector::LPEPerpBisector(LivePathEffectObject *lpeobject) :
registerParameter( dynamic_cast<Parameter *>(&length_left) );
registerParameter( dynamic_cast<Parameter *>(&length_right) );
+ registerKnotHolderHandle(new PB::KnotHolderEntityLeftEnd(), _("Lala"));
+ registerKnotHolderHandle(new PB::KnotHolderEntityRightEnd(), _("Lolo"));
/**
registerKnotHolderHandle(path_start_set, path_start_get);
registerKnotHolderHandle(path_end_set, path_end_get);
diff --git a/src/live_effects/lpe-perp_bisector.h b/src/live_effects/lpe-perp_bisector.h
index 7c4f4fd4e..19fb7d23e 100644
--- a/src/live_effects/lpe-perp_bisector.h
+++ b/src/live_effects/lpe-perp_bisector.h
@@ -22,6 +22,13 @@
namespace Inkscape {
namespace LivePathEffect {
+namespace PB {
+ // we need a separate namespace to avoid clashes with LPETangentToCurve
+ class KnotHolderEntityLeftEnd;
+ class KnotHolderEntityRightEnd;
+ void bisector_end_set(SPItem *item, NR::Point const &p, bool left);
+}
+
class LPEPerpBisector : public Effect {
public:
LPEPerpBisector(LivePathEffectObject *lpeobject);
@@ -34,13 +41,10 @@ public:
virtual Geom::Piecewise<Geom::D2<Geom::SBasis> >
doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in);
- /* the knotholder functions below must be declared friends */
- friend NR::Point bisector_left_end_get(SPItem *item);
- friend NR::Point bisector_right_end_get(SPItem *item);
- friend NR::Point path_start_get(SPItem *item);
- friend NR::Point path_end_get(SPItem *item);
- friend void bisector_end_set(SPItem *item, NR::Point const &p, bool left = true);
- friend void path_set_start_end(SPItem *item, NR::Point const &p, bool start = true);
+ /* the knotholder entity functions must be declared friends */
+ friend class PB::KnotHolderEntityLeftEnd;
+ friend class PB::KnotHolderEntityRightEnd;
+ friend void PB::bisector_end_set(SPItem *item, NR::Point const &p, bool left = true);
private:
ScalarParam length_left;
diff --git a/src/live_effects/lpe-tangent_to_curve.cpp b/src/live_effects/lpe-tangent_to_curve.cpp
index 02d34f312..6fc7161ed 100644
--- a/src/live_effects/lpe-tangent_to_curve.cpp
+++ b/src/live_effects/lpe-tangent_to_curve.cpp
@@ -27,6 +27,8 @@
namespace Inkscape {
namespace LivePathEffect {
+namespace TtC {
+
class KnotHolderEntityAttachPt : public KnotHolderEntity
{
public:
@@ -57,6 +59,8 @@ public:
virtual void onKnotUngrabbed();
};
+} // namespace TtC
+
LPETangentToCurve::LPETangentToCurve(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
angle(_("Angle"), _("Additional angle between tangent and curve"), "angle", &wr, this, 0.0),
@@ -69,9 +73,9 @@ LPETangentToCurve::LPETangentToCurve(LivePathEffectObject *lpeobject) :
registerParameter( dynamic_cast<Parameter *>(&length_left) );
registerParameter( dynamic_cast<Parameter *>(&length_right) );
- registerKnotHolderHandle(new KnotHolderEntityAttachPt(), _("Adjust the \"left\" end of the tangent"));
- registerKnotHolderHandle(new KnotHolderEntityLeftEnd(), _("Adjust the \"right\" end of the tangent"));
- registerKnotHolderHandle(new KnotHolderEntityRightEnd(), _("Adjust the point of attachment of the tangent"));
+ registerKnotHolderHandle(new TtC::KnotHolderEntityAttachPt(), _("Adjust the \"left\" end of the tangent"));
+ registerKnotHolderHandle(new TtC::KnotHolderEntityLeftEnd(), _("Adjust the \"right\" end of the tangent"));
+ registerKnotHolderHandle(new TtC::KnotHolderEntityRightEnd(), _("Adjust the point of attachment of the tangent"));
}
LPETangentToCurve::~LPETangentToCurve()
@@ -99,6 +103,9 @@ LPETangentToCurve::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const
return output;
}
+namespace TtC {
+
+// TODO: make this more generic
static LPETangentToCurve *
get_effect(SPItem *item)
{
@@ -197,9 +204,7 @@ KnotHolderEntityRightEnd::onKnotUngrabbed()
lpe->length_right.write_to_SVG();
}
-
-
-
+} // namespace TtC
} //namespace LivePathEffect
} /* namespace Inkscape */
diff --git a/src/live_effects/lpe-tangent_to_curve.h b/src/live_effects/lpe-tangent_to_curve.h
index 678c32c36..8fe54335c 100644
--- a/src/live_effects/lpe-tangent_to_curve.h
+++ b/src/live_effects/lpe-tangent_to_curve.h
@@ -23,20 +23,25 @@
namespace Inkscape {
namespace LivePathEffect {
+namespace TtC {
+ // we need a separate namespace to avoid clashes with LPEPerpBisector
+ class KnotHolderEntityLeftEnd;
+ class KnotHolderEntityRightEnd;
+ class KnotHolderEntityAttachPt;
+}
+
class LPETangentToCurve : public Effect {
public:
LPETangentToCurve(LivePathEffectObject *lpeobject);
virtual ~LPETangentToCurve();
- bool providesKnotholder() { return true; }
-
virtual Geom::Piecewise<Geom::D2<Geom::SBasis> >
doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in);
/* the knotholder entity classes must be declared friends */
- friend class KnotHolderEntityLeftEnd;
- friend class KnotHolderEntityRightEnd;
- friend class KnotHolderEntityAttachPt;
+ friend class TtC::KnotHolderEntityLeftEnd;
+ friend class TtC::KnotHolderEntityRightEnd;
+ friend class TtC::KnotHolderEntityAttachPt;
private:
ScalarParam angle;