summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMaximilian Albert <maximilian.albert@gmail.com>2008-06-08 17:56:04 +0000
committercilix42 <cilix42@users.sourceforge.net>2008-06-08 17:56:04 +0000
commit175ad5319a1f62fb7b8a56cc99d4586ce5b10b98 (patch)
tree02702faafa4d4755c5bb90c3f6b57021d472b6d3 /src
parentMake knotholders for LPE items finally work; each effect can now overload the... (diff)
downloadinkscape-175ad5319a1f62fb7b8a56cc99d4586ce5b10b98.tar.gz
inkscape-175ad5319a1f62fb7b8a56cc99d4586ce5b10b98.zip
Better way to add LPE knotholder handles; now it happens semi-automatically in a similar way as adding LPE parameters.
(bzr r5856)
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/effect.cpp32
-rw-r--r--src/live_effects/effect.h18
-rw-r--r--src/live_effects/lpe-perp_bisector.cpp2
-rw-r--r--src/live_effects/lpe-tangent_to_curve.cpp83
-rw-r--r--src/live_effects/lpe-tangent_to_curve.h1
-rw-r--r--src/object-edit.cpp2
6 files changed, 70 insertions, 68 deletions
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index db395c81b..b08077e79 100644
--- a/src/live_effects/effect.cpp
+++ b/src/live_effects/effect.cpp
@@ -321,14 +321,26 @@ Effect::registerParameter(Parameter * param)
param_vector.push_back(param);
}
-// TODO: Does it still make sense to use this? E.g., should we keep a list of knotholder entities
-// in the effect itself and add them here in a semi-automatic manner (similarly to how it is
-// done with parameters) instead of adding each one separately in the overloaded function
-// addKnotHolderHandles()?
+// TODO: should we provide a way to alter the handle's appearance?
void
-Effect::registerKnotHolderHandle(SPKnotHolderSetFunc set_func, SPKnotHolderGetFunc get_func)
+Effect::registerKnotHolderHandle(KnotHolderEntity* entity, const char* descr)
{
- //knotholder_func_vector.push_back(std::make_pair(set_func, get_func));
+ kh_entity_vector.push_back(std::make_pair(entity, descr));
+}
+
+/**
+ * Add all registered LPE knotholder handles to the knotholder
+ */
+void
+Effect::addHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) {
+ std::vector<std::pair<KnotHolderEntity*, const char*> >::iterator i;
+ for (i = kh_entity_vector.begin(); i != kh_entity_vector.end(); ++i) {
+ KnotHolderEntity *entity = i->first;
+ const char *descr = i->second;
+
+ entity->create(desktop, item, knotholder, descr);
+ knotholder->add(entity);
+ }
}
void
@@ -347,14 +359,6 @@ Effect::addPointParamHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem
}
/**
- * Virtual method to add knotholder handles for LPE items
- */
-void
-Effect::addKnotHolderHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item)
-{
-}
-
-/**
* This *creates* a new widget, management of deletion should be done by the caller
*/
Gtk::Widget *
diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h
index c46c145b5..a990a858d 100644
--- a/src/live_effects/effect.h
+++ b/src/live_effects/effect.h
@@ -102,8 +102,7 @@ public:
virtual void transform_multiply(Geom::Matrix const& postmul, bool set);
virtual bool providesKnotholder() { return false; }
- void addPointParamHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
- virtual void addKnotHolderHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
+ void addHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
Glib::ustring getName();
Inkscape::XML::Node * getRepr();
@@ -132,10 +131,12 @@ protected:
doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in);
void registerParameter(Parameter * param);
- void registerKnotHolderHandle(SPKnotHolderSetFunc set_func, SPKnotHolderGetFunc get_func);
+ void registerKnotHolderHandle(KnotHolderEntity* entity, const char* descr);
+ void addPointParamHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
Parameter * getNextOncanvasEditableParam();
std::vector<Parameter *> param_vector;
+ std::vector<std::pair<KnotHolderEntity*, const char*> > kh_entity_vector;
int oncanvasedit_it;
BoolParam is_visible;
@@ -157,3 +158,14 @@ private:
} //namespace Inkscape
#endif
+
+/*
+ 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-perp_bisector.cpp b/src/live_effects/lpe-perp_bisector.cpp
index 39423df8b..139ca21bf 100644
--- a/src/live_effects/lpe-perp_bisector.cpp
+++ b/src/live_effects/lpe-perp_bisector.cpp
@@ -138,10 +138,12 @@ LPEPerpBisector::LPEPerpBisector(LivePathEffectObject *lpeobject) :
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()
diff --git a/src/live_effects/lpe-tangent_to_curve.cpp b/src/live_effects/lpe-tangent_to_curve.cpp
index b61a078a4..02d34f312 100644
--- a/src/live_effects/lpe-tangent_to_curve.cpp
+++ b/src/live_effects/lpe-tangent_to_curve.cpp
@@ -27,6 +27,36 @@
namespace Inkscape {
namespace LivePathEffect {
+class KnotHolderEntityAttachPt : 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();
+};
+
+class KnotHolderEntityLeftEnd : 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();
+};
+
+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();
+};
+
LPETangentToCurve::LPETangentToCurve(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
angle(_("Angle"), _("Additional angle between tangent and curve"), "angle", &wr, this, 0.0),
@@ -38,6 +68,10 @@ LPETangentToCurve::LPETangentToCurve(LivePathEffectObject *lpeobject) :
registerParameter( dynamic_cast<Parameter *>(&t_attach) );
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"));
}
LPETangentToCurve::~LPETangentToCurve()
@@ -65,55 +99,6 @@ LPETangentToCurve::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const
return output;
}
-class KnotHolderEntityAttachPt : 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();
-};
-
-class KnotHolderEntityLeftEnd : 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();
-};
-
-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();
-};
-
-void
-LPETangentToCurve::addKnotHolderHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item)
-{
- KnotHolderEntityLeftEnd *entity_left_end = new KnotHolderEntityLeftEnd();
- KnotHolderEntityRightEnd *entity_right_end = new KnotHolderEntityRightEnd();
- KnotHolderEntityAttachPt *entity_attach_pt = new KnotHolderEntityAttachPt();
-
- entity_left_end->create(desktop, item, knotholder,
- _("Adjust the \"left\" end of the tangent"));
- entity_right_end->create(desktop, item, knotholder,
- _("Adjust the \"right\" end of the tangent"));
- entity_attach_pt->create(desktop, item, knotholder,
- _("Adjust the point of attachment of the tangent"));
-
- knotholder->add(entity_left_end);
- knotholder->add(entity_right_end);
- knotholder->add(entity_attach_pt);
-}
-
static LPETangentToCurve *
get_effect(SPItem *item)
{
diff --git a/src/live_effects/lpe-tangent_to_curve.h b/src/live_effects/lpe-tangent_to_curve.h
index 0de2baf56..678c32c36 100644
--- a/src/live_effects/lpe-tangent_to_curve.h
+++ b/src/live_effects/lpe-tangent_to_curve.h
@@ -29,7 +29,6 @@ public:
virtual ~LPETangentToCurve();
bool providesKnotholder() { return true; }
- virtual void addKnotHolderHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
virtual Geom::Piecewise<Geom::D2<Geom::SBasis> >
doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in);
diff --git a/src/object-edit.cpp b/src/object-edit.cpp
index 8d8be4b85..de7fbccec 100644
--- a/src/object-edit.cpp
+++ b/src/object-edit.cpp
@@ -57,7 +57,7 @@ static KnotHolder *sp_lpe_knot_holder(SPItem *item, SPDesktop *desktop)
Inkscape::LivePathEffect::Effect *effect = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item));
// effect->addPointParamHandles(knot_holder, desktop, item);
- effect->addKnotHolderHandles(knot_holder, desktop, item);
+ effect->addHandles(knot_holder, desktop, item);
return knot_holder;
}