summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5be124a)
raw | patch | inline | side by side (parent: 5be124a)
author | cilix42 <cilix42@users.sourceforge.net> | |
Sun, 8 Jun 2008 18:08:56 +0000 (18:08 +0000) | ||
committer | cilix42 <cilix42@users.sourceforge.net> | |
Sun, 8 Jun 2008 18:08:56 +0000 (18:08 +0000) |
Put the KnotHolderEntity classes into their own namespaces to avoid clashes.
index a990a858d2afaeb6fe42d93fc61940056c18e578..21d86f80ad9dbb6ba1792f1f42346145c17f9aeb 100644 (file)
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();
index 139ca21bf5e9d30c0d8178026786aa34a1792db6..9c7ed0a7e67ba00355a0aa92c93f5e4cbe18410a 100644 (file)
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
}
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)));
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),
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);
index 7c4f4fd4e7d6ff3f7782b7c07862ffd8db2c5b1b..19fb7d23e29ea04b1ae2f21d90781c68525735e1 100644 (file)
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);
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;
index 02d34f31204e5862c65d0468e2b5027bb8d90e58..6fc7161edd246ded109bdd0c06c76c28dc42dba4 100644 (file)
namespace Inkscape {
namespace LivePathEffect {
+namespace TtC {
+
class KnotHolderEntityAttachPt : public KnotHolderEntity
{
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),
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()
return output;
}
+namespace TtC {
+
+// TODO: make this more generic
static LPETangentToCurve *
get_effect(SPItem *item)
{
lpe->length_right.write_to_SVG();
}
-
-
-
+} // namespace TtC
} //namespace LivePathEffect
} /* namespace Inkscape */
index 678c32c3696130dbf5cbb21108c44c9606b828cb..8fe54335cbd0646971cd7c713280de5c4998afb3 100644 (file)
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;