summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMaximilian Albert <maximilian.albert@gmail.com>2008-05-19 16:10:35 +0000
committercilix42 <cilix42@users.sourceforge.net>2008-05-19 16:10:35 +0000
commit1fa4143844daae67b07b988d4f4c353fc2a7062f (patch)
tree11120c03b3d9b28a5291b6c1c4f065fe107db9c6 /src
parentForgot to add two files in commit #18667. Sorry for breaking the build for a ... (diff)
downloadinkscape-1fa4143844daae67b07b988d4f4c353fc2a7062f.tar.gz
inkscape-1fa4143844daae67b07b988d4f4c353fc2a7062f.zip
Add handles to adapt tangent length
(bzr r5708)
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/lpe-tangent_to_curve.cpp48
-rw-r--r--src/live_effects/lpe-tangent_to_curve.h12
2 files changed, 55 insertions, 5 deletions
diff --git a/src/live_effects/lpe-tangent_to_curve.cpp b/src/live_effects/lpe-tangent_to_curve.cpp
index e7344c9dc..92aca33c6 100644
--- a/src/live_effects/lpe-tangent_to_curve.cpp
+++ b/src/live_effects/lpe-tangent_to_curve.cpp
@@ -57,12 +57,52 @@ void attach_pt_set(SPItem *item, NR::Point const &p, NR::Point const &origin, gu
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)
+ 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)
{
registerParameter( dynamic_cast<Parameter *>(&t_attach) );
+ registerParameter( dynamic_cast<Parameter *>(&length_left) );
+ registerParameter( dynamic_cast<Parameter *>(&length_right) );
registerKnotHolderHandle(attach_pt_set, attach_pt_get);
+ registerKnotHolderHandle(left_end_set, left_end_get);
+ registerKnotHolderHandle(right_end_set, right_end_get);
}
LPETangentToCurve::~LPETangentToCurve()
@@ -78,10 +118,10 @@ LPETangentToCurve::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const
ptA = pwd2_in.valueAt(t_attach);
derivA = unit_vector(derivative(pwd2_in).valueAt(t_attach));
- Point A = ptA - derivA * 100;
- Point B = ptA + derivA * 100;
+ C = ptA - derivA * length_left;
+ D = ptA + derivA * length_right;
- output = Piecewise<D2<SBasis> >(D2<SBasis>(Linear(A[X], B[X]), Linear(A[Y], B[Y])));
+ output = Piecewise<D2<SBasis> >(D2<SBasis>(Linear(C[X], D[X]), Linear(C[Y], D[Y])));
return output;
}
diff --git a/src/live_effects/lpe-tangent_to_curve.h b/src/live_effects/lpe-tangent_to_curve.h
index d8049c176..7d80b23bb 100644
--- a/src/live_effects/lpe-tangent_to_curve.h
+++ b/src/live_effects/lpe-tangent_to_curve.h
@@ -33,14 +33,24 @@ public:
/* the knotholder functions must be declared friends */
friend NR::Point attach_pt_get(SPItem *item);
+ friend NR::Point left_end_get(SPItem *item);
+ friend NR::Point right_end_get(SPItem *item);
friend void attach_pt_set(SPItem *item, NR::Point const &p, NR::Point const &origin, guint state);
+ friend void left_end_set(SPItem *item, NR::Point const &p, NR::Point const &origin, guint state);
+ friend void right_end_set(SPItem *item, NR::Point const &p, NR::Point const &origin, guint state);
private:
ScalarParam t_attach;
- Geom::Point ptA;
+ ScalarParam length_left;
+ ScalarParam length_right;
+
+ Geom::Point ptA; // point of attachment to the curve
Geom::Point derivA;
+ Geom::Point C; // left end of tangent
+ Geom::Point D; // right end of tangent
+
LPETangentToCurve(const LPETangentToCurve&);
LPETangentToCurve& operator=(const LPETangentToCurve&);
};