lpe-parallel.cpp revision 25ad3718fb4b96b39930af8e043c8ee1e624fd10
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix * LPE <parallel> implementation
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix * Maximilian Albert
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix * Copyright (C) Maximilian Albert 2008 <maximilian.albert@gmail.com>
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix * Released under GNU GPL, read the file 'COPYING' for more information
b320a8d186114a5122ddc3afbe95110eb6cb10cecilixnamespace Pl {
25ad3718fb4b96b39930af8e043c8ee1e624fd10cilixclass KnotHolderEntityLeftEnd : public LPEKnotHolderEntity
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
25ad3718fb4b96b39930af8e043c8ee1e624fd10cilixclass KnotHolderEntityRightEnd : public LPEKnotHolderEntity
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix} // namespace Pl
b320a8d186114a5122ddc3afbe95110eb6cb10cecilixLPEParallel::LPEParallel(LivePathEffectObject *lpeobject) :
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix // initialise your parameters here:
79d46cc367c4181803d9a7a327b163643f23e8a7cilix offset_pt(_("Offset"), _("Adjust the offset"), "offset_pt", &wr, this),
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix length_left(_("Length left"), _("Specifies the left end of the parallel"), "length-left", &wr, this, 150),
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix length_right(_("Length right"), _("Specifies the right end of the parallel"), "length-right", &wr, this, 150)
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix registerParameter(dynamic_cast<Parameter *>(&offset_pt));
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix registerParameter( dynamic_cast<Parameter *>(&length_left) );
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix registerParameter( dynamic_cast<Parameter *>(&length_right) );
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix registerKnotHolderHandle(new Pl::KnotHolderEntityLeftEnd(), _("Adjust the \"left\" end of the parallel"));
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix registerKnotHolderHandle(new Pl::KnotHolderEntityRightEnd(), _("Adjust the \"right\" end of the parallel"));
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix offset_pt.param_set_and_write_new_value((A + B)/2 + dir.ccw() * 100);
b320a8d186114a5122ddc3afbe95110eb6cb10cecilixLPEParallel::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in)
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix using namespace Geom;
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix output = Piecewise<D2<SBasis> >(D2<SBasis>(Linear(C[X], D[X]), Linear(C[Y], D[Y])));
b320a8d186114a5122ddc3afbe95110eb6cb10cecilixnamespace Pl {
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix// TODO: make this more generic
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix Effect *effect = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item));
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix g_print ("Warning: Effect is not of type LPEParallel!\n");
b320a8d186114a5122ddc3afbe95110eb6cb10cecilixKnotHolderEntityLeftEnd::knot_set(NR::Point const &p, NR::Point const &/*origin*/, guint /*state*/)
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix using namespace Geom;
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix double lambda = L2(p - lpe->offset_pt) * sgn(dot(p.to_2geom() - lpe->offset_pt, lpe->dir));
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true);
b320a8d186114a5122ddc3afbe95110eb6cb10cecilixKnotHolderEntityRightEnd::knot_set(NR::Point const &p, NR::Point const &/*origin*/, guint /*state*/)
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix using namespace Geom;
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix double lambda = L2(p - lpe->offset_pt) * sgn(dot(p.to_2geom() - lpe->offset_pt, lpe->dir));
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true);
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix return lpe->C;
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix return lpe->D;
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix} // namespace Pl
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix/* ######################## */
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix} //namespace LivePathEffect
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix} /* namespace Inkscape */
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix Local Variables:
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix c-file-style:"stroustrup"
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix indent-tabs-mode:nil
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix fill-column:99
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :