effect.cpp revision a617d38416993f79b57879c6bfa174e9be78bb40
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
9dc68827cbd515262ecb8d5ae8547d9e82c72e00Jon A. Cruz * Abhishek Sharma
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm * Released under GNU GPL, read the file 'COPYING' for more information
799f674d1756b6937a578c2f64b7c57fed08a827Liam P. White//#define LPE_ENABLE_TEST_EFFECTS //uncomment for toy effects
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm// include effects:
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White#include "live_effects/lpe-fill-between-strokes.h"
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White#include "live_effects/lpe-fill-between-many.h"
72b7b31db250f20b90730d2888e6a554b434a407johanengelenconst Util::EnumData<EffectType> LPETypeData[] = {
06cd6b0ab2dbe286184e35d1078bab18c966b0d2jfbarraud // {constant defined in effect-enum.h, N_("name of your effect"), "name of your effect in SVG"}
790674255fb54e588b4b6d73ee9e15050b45d1a4johanengelen {DOEFFECTSTACK_TEST, N_("doEffect stack test"), "doeffectstacktest"},
9de5f3bfa8e35ad5e6adcd6eaad4d0d49e7043a3johanengelen {ANGLE_BISECTOR, N_("Angle bisector"), "angle_bisector"},
2b2321eb83f7bd0173589734d6f40b4fe90961f9helix // TRANSLATORS: boolean operations
f555c315692d0a6b221636e8a7004fe9eda0b2cbcilix {CIRCLE_WITH_RADIUS, N_("Circle (by center and radius)"), "circle_with_radius"},
4d2f452da50c83a3bced2bab8cb9e2b287c6efd1johanengelen {CIRCLE_3PTS, N_("Circle by 3 points"), "circle_3pts"},
4d2f452da50c83a3bced2bab8cb9e2b287c6efd1johanengelen {DYNASTROKE, N_("Dynamic stroke"), "dynastroke"},
9de5f3bfa8e35ad5e6adcd6eaad4d0d49e7043a3johanengelen {LATTICE, N_("Lattice Deformation"), "lattice"},
9de5f3bfa8e35ad5e6adcd6eaad4d0d49e7043a3johanengelen {MIRROR_SYMMETRY, N_("Mirror symmetry"), "mirror_symmetry"},
9de5f3bfa8e35ad5e6adcd6eaad4d0d49e7043a3johanengelen {PERP_BISECTOR, N_("Perpendicular bisector"), "perp_bisector"},
9de5f3bfa8e35ad5e6adcd6eaad4d0d49e7043a3johanengelen {PERSPECTIVE_PATH, N_("Perspective path"), "perspective_path"},
9de5f3bfa8e35ad5e6adcd6eaad4d0d49e7043a3johanengelen {COPY_ROTATE, N_("Rotate copies"), "copy_rotate"},
afa1e71af5a64b54df797ac1f0bcf32c6613b371johanengelen {RECURSIVE_SKELETON, N_("Recursive skeleton"), "recursive_skeleton"},
9de5f3bfa8e35ad5e6adcd6eaad4d0d49e7043a3johanengelen {TANGENT_TO_CURVE, N_("Tangent to curve"), "tangent_to_curve"},
4d2f452da50c83a3bced2bab8cb9e2b287c6efd1johanengelen {PATTERN_ALONG_PATH, N_("Pattern Along Path"), "skeletal"}, // for historic reasons, this effect is called skeletal(strokes) in Inkscape:SVG
4d2f452da50c83a3bced2bab8cb9e2b287c6efd1johanengelen {CURVE_STITCH, N_("Stitch Sub-Paths"), "curvestitching"},
4d2f452da50c83a3bced2bab8cb9e2b287c6efd1johanengelen {CONSTRUCT_GRID, N_("Construct grid"), "construct_grid"},
4daaa4a6cb870ab0b4f6fbd66943a7535535f1adjohanengelen {ENVELOPE, N_("Envelope Deformation"), "envelope"},
1ba2d157b7006f2f1a6043bc29e9c66be6386373johanengelen {INTERPOLATE, N_("Interpolate Sub-Paths"), "interpolate"},
0c4410dc5d53461e85445298c1f5d08d2d823c98jfbarraud {ROUGH_HATCHES, N_("Hatches (rough)"), "rough_hatches"},
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White {POWERSTROKE, N_("Power stroke"), "powerstroke"},
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White {CLONE_ORIGINAL, N_("Clone original path"), "clone_original"},
136203b42d18389e16f7e30427dd6424e555149dJabiertxo Arraiza Cenoz {BSPLINE, N_("BSpline"), "bspline"},
a617d38416993f79b57879c6bfa174e9be78bb40Liam P. White {TAPER_STROKE, N_("Taper stroke"), "taper_stroke"},
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White/* Ponyscape */
6a5c006765230bd994cc6ac027dab6ed15837bbfLiam P. White {ATTACH_PATH, N_("Attach path"), "attach_path"},
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White {FILL_BETWEEN_STROKES, N_("Fill between strokes"), "fill_between_strokes"},
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White {FILL_BETWEEN_MANY, N_("Fill between many"), "fill_between_many"},
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White {ELLIPSE_5PTS, N_("Ellipse by 5 points"), "ellipse_5pts"},
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White {BOUNDING_BOX, N_("Bounding Box"), "bounding_box"},
72b7b31db250f20b90730d2888e6a554b434a407johanengelenconst Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData));
eac94793745a61429b52a4b489e148737d091749cilix case INVALID_LPE: return -1; // in case we want to distinguish between invalid LPE and valid ones that expect zero clicks
a45e91fd09273632e9acf849bb72621832156f07cilix default: return 0;
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrmEffect::New(EffectType lpenr, LivePathEffectObject *lpeobj)
92fe3142613d000eff89db8a983b3b18b14eee79johanengelen neweffect = static_cast<Effect*> ( new LPEPatternAlongPath(lpeobj) );
92fe3142613d000eff89db8a983b3b18b14eee79johanengelen neweffect = static_cast<Effect*> ( new LPEBendPath(lpeobj) );
92fe3142613d000eff89db8a983b3b18b14eee79johanengelen neweffect = static_cast<Effect*> ( new LPESketch(lpeobj) );
06cd6b0ab2dbe286184e35d1078bab18c966b0d2jfbarraud neweffect = static_cast<Effect*> ( new LPERoughHatches(lpeobj) );
92fe3142613d000eff89db8a983b3b18b14eee79johanengelen neweffect = static_cast<Effect*> ( new LPEVonKoch(lpeobj) );
92fe3142613d000eff89db8a983b3b18b14eee79johanengelen neweffect = static_cast<Effect*> ( new LPEKnot(lpeobj) );
92fe3142613d000eff89db8a983b3b18b14eee79johanengelen neweffect = static_cast<Effect*> ( new LPEGears(lpeobj) );
92fe3142613d000eff89db8a983b3b18b14eee79johanengelen neweffect = static_cast<Effect*> ( new LPECurveStitch(lpeobj) );
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen neweffect = static_cast<Effect*> ( new LPELattice(lpeobj) );
0563fd55cbad59e8a878e6d4cbbdd8e47f74488djohanengelen neweffect = static_cast<Effect*> ( new LPEEnvelope(lpeobj) );
92fe3142613d000eff89db8a983b3b18b14eee79johanengelen neweffect = static_cast<Effect*> ( new LPECircleWithRadius(lpeobj) );
92fe3142613d000eff89db8a983b3b18b14eee79johanengelen neweffect = static_cast<Effect*> ( new LPEPerspectivePath(lpeobj) );
c169f6cddd2da06cfb761339f445bbd8866f72a8buliabyak neweffect = static_cast<Effect*> ( new LPESpiro(lpeobj) );
6f4a90e526af850ffc36064f58f09c190f3b633fjohanengelen neweffect = static_cast<Effect*> ( new LPEConstructGrid(lpeobj) );
f4db63be4e929f4706410914295deccaceea19cdcilix neweffect = static_cast<Effect*> ( new LPEPerpBisector(lpeobj) );
ab99111a42436818e6902e044c8f3af2b724263bcilix neweffect = static_cast<Effect*> ( new LPETangentToCurve(lpeobj) );
76db360f5f052775326e6d406b9e1e9e2966e11acilix neweffect = static_cast<Effect*> ( new LPEMirrorSymmetry(lpeobj) );
3d0482af18ffb591c1d8ddecf516629e1bcd2ae4cilix neweffect = static_cast<Effect*> ( new LPECircle3Pts(lpeobj) );
64aee804a6a47424f7994e60558351b8cf2ea4dbcilix neweffect = static_cast<Effect*> ( new LPEAngleBisector(lpeobj) );
b320a8d186114a5122ddc3afbe95110eb6cb10cecilix neweffect = static_cast<Effect*> ( new LPEParallel(lpeobj) );
044d712d4d03f8354962d54e47cfac2346a69ccccilix neweffect = static_cast<Effect*> ( new LPECopyRotate(lpeobj) );
61cfd957cd023c4f432ea0c7307784a56bf978e9cilix neweffect = static_cast<Effect*> ( new LPEOffset(lpeobj) );
2f5c0701b333a695eedb1680beb1adf95c0723dacilix neweffect = static_cast<Effect*> ( new LPERuler(lpeobj) );
add2ffae3c4686b50d888775bbdf083a4726a210johanengelen neweffect = static_cast<Effect*> ( new LPEBoolops(lpeobj) );
0a75b58e47d3de42550c4f7960e253ea3befc09ajohanengelen neweffect = static_cast<Effect*> ( new LPEInterpolate(lpeobj) );
4afe3fc6b9c122bc5c02b27aea3845ba41384d2acilix neweffect = static_cast<Effect*> ( new LPETextLabel(lpeobj) );
ecf048161ae0284d01d34ca5844204775c0d3fdecilix neweffect = static_cast<Effect*> ( new LPEPathLength(lpeobj) );
3515994554d167522343ce57417648b39370ccabcilix neweffect = static_cast<Effect*> ( new LPELineSegment(lpeobj) );
790674255fb54e588b4b6d73ee9e15050b45d1a4johanengelen neweffect = static_cast<Effect*> ( new LPEdoEffectStackTest(lpeobj) );
136203b42d18389e16f7e30427dd6424e555149dJabiertxo Arraiza Cenoz neweffect = static_cast<Effect*> ( new LPEBSpline(lpeobj) );
081a89987d4cb46e707c9dd5648a7a24a01a750djfbarraud neweffect = static_cast<Effect*> ( new LPEDynastroke(lpeobj) );
afa1e71af5a64b54df797ac1f0bcf32c6613b371johanengelen neweffect = static_cast<Effect*> ( new LPERecursiveSkeleton(lpeobj) );
b62895f15526ccefdf1e274c49c02aa043895ee9johanengelen neweffect = static_cast<Effect*> ( new LPEExtrude(lpeobj) );
4fe8248cd521387d0829c423bf4492e2cbdfd7cdJohan Engelen neweffect = static_cast<Effect*> ( new LPEPowerStroke(lpeobj) );
05e1ec4d6f1ccc3a0db3cc13e8a3b18489714f14Johan Engelen neweffect = static_cast<Effect*> ( new LPECloneOriginal(lpeobj) );
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White neweffect = static_cast<Effect*> ( new LPEAttachPath(lpeobj) );
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White neweffect = static_cast<Effect*> ( new LPEFillBetweenStrokes(lpeobj) );
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White neweffect = static_cast<Effect*> ( new LPEFillBetweenMany(lpeobj) );
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White neweffect = static_cast<Effect*> ( new LPEEllipse5Pts(lpeobj) );
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White neweffect = static_cast<Effect*> ( new LPEBoundingBox(lpeobj) );
8ba84881e79b6175868d04179ca86f4823a69ec0Liam P. White neweffect = static_cast<Effect*> ( new LPEJoinType(lpeobj) );
d10a0baa40c22107b37b2ae2f687b108f5c05d99Liam P. White neweffect = static_cast<Effect*> ( new LPETaperStroke(lpeobj) );
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm g_warning("LivePathEffect::Effect::New called with invalid patheffect type (%d)", lpenr);
f68aabe351946119c80978525cd86564dd33e02fJon A. Cruz neweffect->readallParameters(lpeobj->getRepr());
9dc68827cbd515262ecb8d5ae8547d9e82c72e00Jon A. Cruzvoid Effect::createAndApply(const char* name, SPDocument *doc, SPItem *item)
6656f193fdace606d1b162d6dea0223bc295f0a6cilix // Path effect definition
9dc68827cbd515262ecb8d5ae8547d9e82c72e00Jon A. Cruz Inkscape::XML::Document *xml_doc = doc->getReprDoc();
6656f193fdace606d1b162d6dea0223bc295f0a6cilix Inkscape::XML::Node *repr = xml_doc->createElement("inkscape:path-effect");
07b7f1aaaf1087716e784a50cf574a059f7018d3Jon A. Cruz doc->getDefs()->getRepr()->addChild(repr, NULL); // adds to <defs> and assigns the 'id' attribute
f4ce66b44581cea80a736cf20244c0539a7525daJohan B. C. Engelen SP_LPE_ITEM(item)->addPathEffect(href, true);
09ba3247163582bf2e30e17c4c154aa259ce038acilixEffect::createAndApply(EffectType type, SPDocument *doc, SPItem *item)
6656f193fdace606d1b162d6dea0223bc295f0a6cilix createAndApply(LPETypeConverter.get_key(type).c_str(), doc, item);
71146abe8aba032d73788a625fee5769a581bd3ccilix is_visible(_("Is visible?"), _("If unchecked, the effect remains applied to the object but is temporarily disabled on canvas"), "is_visible", &wr, this, true),
c27006137a3ad49e074b97b3297db753e1ac8eefcilix provides_own_flash_paths(true), // is automatically set to false if providesOwnFlashPaths() is not overridden
c27006137a3ad49e074b97b3297db753e1ac8eefcilix is_ready(false) // is automatically set to false if providesOwnFlashPaths() is not overridden
71146abe8aba032d73788a625fee5769a581bd3ccilix registerParameter( dynamic_cast<Parameter *>(&is_visible) );
72b7b31db250f20b90730d2888e6a554b434a407johanengelen if (lpeobj->effecttype_set && LPETypeConverter.is_valid_id(lpeobj->effecttype) )
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm return Glib::ustring( _(LPETypeConverter.get_label(lpeobj->effecttype).c_str()) );
77a4a003111bd5cfb771d4849801c898aeb889b0cilix * Is performed a single time when the effect is freshly applied to a path
a39c187369a59e887255e3f704a3ababf2b10678Johan B. C. EngelenEffect::doOnApply (SPLPEItem const*/*lpeitem*/)
77a4a003111bd5cfb771d4849801c898aeb889b0cilix * Is performed each time before the effect is updated.
0b2d8abc1011ad865fce3b883ccb2587cb15cc90Johan B. C. EngelenEffect::doBeforeEffect (SPLPEItem const*/*lpeitem*/)
23d859f2ce09c04ed802cb4912cc9c50f512f0a2bgk //Do nothing for simple effects
799f674d1756b6937a578c2f64b7c57fed08a827Liam P. Whitevoid Effect::doAfterEffect (SPLPEItem const* lpeitem)
799f674d1756b6937a578c2f64b7c57fed08a827Liam P. Whitevoid Effect::doOnRemove (SPLPEItem const* lpeitem)
62c8c7faca825a94361a0cecb568735f83475933Liam P. White//secret impl methods (shhhh!)
62c8c7faca825a94361a0cecb568735f83475933Liam P. Whitevoid Effect::doOnApply_impl(SPLPEItem const* lpeitem)
62c8c7faca825a94361a0cecb568735f83475933Liam P. White sp_lpe_item = const_cast<SPLPEItem *>(lpeitem);
e65cfa2ea933c3cbc05f00c6e8ab1cef1f68672fLiam P. White /*sp_curve = SP_SHAPE(sp_lpe_item)->getCurve();
e65cfa2ea933c3cbc05f00c6e8ab1cef1f68672fLiam P. White pathvector_before_effect = sp_curve->get_pathvector();*/
62c8c7faca825a94361a0cecb568735f83475933Liam P. Whitevoid Effect::doBeforeEffect_impl(SPLPEItem const* lpeitem)
62c8c7faca825a94361a0cecb568735f83475933Liam P. White sp_lpe_item = const_cast<SPLPEItem *>(lpeitem);
64a311db53efc60ec257d3f6d128b53204eb4683Liam P. White //printf("(SPLPEITEM*) %p\n", sp_lpe_item);
62c8c7faca825a94361a0cecb568735f83475933Liam P. White pathvector_before_effect = sp_curve->get_pathvector();
147c8e03bb214f85cd5906ddc6413c4293c4baa9cilix * Effects can have a parameter path set before they are applied by accepting a nonzero number of
147c8e03bb214f85cd5906ddc6413c4293c4baa9cilix * mouse clicks. This method activates the pen context, which waits for the specified number of
494c671e141564431d7d05f141c885d9a2789db5cilix * clicks. Override Effect::acceptsNumClicks() to return the number of expected mouse clicks.
77a4a003111bd5cfb771d4849801c898aeb889b0cilix // switch to pen context
77a4a003111bd5cfb771d4849801c898aeb889b0cilix SPDesktop *desktop = inkscape_active_desktop(); // TODO: Is there a better method to find the item's desktop?
5f19756f48574526dda8abedebf811c9d1456e80Markus Engel Inkscape::UI::Tools::ToolBase *ec = desktop->event_context;
5f19756f48574526dda8abedebf811c9d1456e80Markus Engel Inkscape::UI::Tools::PenTool *pc = SP_PEN_CONTEXT(ec);
494c671e141564431d7d05f141c885d9a2789db5cilix pc->expecting_clicks_for_LPE = this->acceptsNumClicks();
77a4a003111bd5cfb771d4849801c898aeb889b0cilix ec->desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE,
77a4a003111bd5cfb771d4849801c898aeb889b0cilix g_strdup_printf(_("Please specify a parameter path for the LPE '%s' with %d mouse clicks"),
97a20864afec63a0b7bb757b628ee2ae596cf648cilix std::vector<Inkscape::LivePathEffect::Parameter *>::iterator p;
97a20864afec63a0b7bb757b628ee2ae596cf648cilix for (p = param_vector.begin(); p != param_vector.end(); ++p) {
77a4a003111bd5cfb771d4849801c898aeb889b0cilix * If the effect expects a path parameter (specified by a number of mouse clicks) before it is
77a4a003111bd5cfb771d4849801c898aeb889b0cilix * applied, this is the method that processes the resulting path. Override it to customize it for
c27006137a3ad49e074b97b3297db753e1ac8eefcilix * your LPE. But don't forget to call the parent method so that is_ready is set to true!
0b2d8abc1011ad865fce3b883ccb2587cb15cc90Johan B. C. EngelenEffect::acceptParamPath (SPPath const*/*param_path*/) {
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm * Here be the doEffect function chain:
b802808a0226a87371021393c4f1da776aa6a6adjohanengelen std::vector<Geom::Path> orig_pathv = curve->get_pathvector();
b802808a0226a87371021393c4f1da776aa6a6adjohanengelen std::vector<Geom::Path> result_pathv = doEffect_path(orig_pathv);
ecda720053ff791e35dae3c5c1177bc225b6cdf1johanengelenEffect::doEffect_path (std::vector<Geom::Path> const & path_in)
46c4893a7458eda6edcd064121bc000634af7a09johanengelen // default behavior
46c4893a7458eda6edcd064121bc000634af7a09johanengelen for (unsigned int i=0; i < path_in.size(); i++) {
46c4893a7458eda6edcd064121bc000634af7a09johanengelen Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2_in = path_in[i].toPwSb();
46c4893a7458eda6edcd064121bc000634af7a09johanengelen Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2_out = doEffect_pwd2(pwd2_in);
46c4893a7458eda6edcd064121bc000634af7a09johanengelen std::vector<Geom::Path> path = Geom::path_from_piecewise( pwd2_out, LPE_CONVERSION_TOLERANCE);
46c4893a7458eda6edcd064121bc000634af7a09johanengelen // add the output path vector to the already accumulated vector:
46c4893a7458eda6edcd064121bc000634af7a09johanengelen // concatenate the path into possibly discontinuous pwd2
46c4893a7458eda6edcd064121bc000634af7a09johanengelen Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2_in;
46c4893a7458eda6edcd064121bc000634af7a09johanengelen for (unsigned int i=0; i < path_in.size(); i++) {
46c4893a7458eda6edcd064121bc000634af7a09johanengelen Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2_out = doEffect_pwd2(pwd2_in);
46c4893a7458eda6edcd064121bc000634af7a09johanengelen path_out = Geom::path_from_piecewise( pwd2_out, LPE_CONVERSION_TOLERANCE);
ecda720053ff791e35dae3c5c1177bc225b6cdf1johanengelenEffect::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in)
0b2d8abc1011ad865fce3b883ccb2587cb15cc90Johan B. C. EngelenEffect::readallParameters(Inkscape::XML::Node const* repr)
93bb287e28a818fd5ba61b99d012e0500a49ccf6johanengelen std::vector<Parameter *>::iterator it = param_vector.begin();
93bb287e28a818fd5ba61b99d012e0500a49ccf6johanengelen bool accepted = param->param_readSVGValue(value);
93bb287e28a818fd5ba61b99d012e0500a49ccf6johanengelen g_warning("Effect::readallParameters - '%s' not accepted for %s", value, key);
93bb287e28a818fd5ba61b99d012e0500a49ccf6johanengelen // set default value
0fc5ce7045233dae7e15fdc86774370f1b1d73cbjohanengelen/* This function does not and SHOULD NOT write to XML */
0fc5ce7045233dae7e15fdc86774370f1b1d73cbjohanengelenEffect::setParameter(const gchar * key, const gchar * new_value)
93bb287e28a818fd5ba61b99d012e0500a49ccf6johanengelen bool accepted = param->param_readSVGValue(new_value);
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm g_warning("Effect::setParameter - '%s' not accepted for %s", new_value, key);
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm // set default value
5be124ad592f5c71eca838ad2eaac9ffa953605fcilix * Add all registered LPE knotholder handles to the knotholder
5be124ad592f5c71eca838ad2eaac9ffa953605fcilixEffect::addHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) {
797bee69297bbdd86c5cff2e0771a71d1e2ac69dcilix // add handles provided by the effect itself
25ad3718fb4b96b39930af8e043c8ee1e624fd10cilix // add handles provided by the effect's parameters (if any)
25ad3718fb4b96b39930af8e043c8ee1e624fd10cilix for (std::vector<Parameter *>::iterator p = param_vector.begin(); p != param_vector.end(); ++p) {
25ad3718fb4b96b39930af8e043c8ee1e624fd10cilix (*p)->addKnotHolderEntities(knotholder, desktop, item);
4f6f96b37466fa06ffc85e7a0921db83bdeac757Johan B. C. Engelen * Return a vector of PathVectors which contain all canvas indicators for this effect.
4f6f96b37466fa06ffc85e7a0921db83bdeac757Johan B. C. Engelen * This is the function called by external code to get all canvas indicators (effect and its parameters)
4f6f96b37466fa06ffc85e7a0921db83bdeac757Johan B. C. Engelen * lpeitem = the item onto which this effect is applied
4f6f96b37466fa06ffc85e7a0921db83bdeac757Johan B. C. Engelen * @todo change return type to one pathvector, add all paths to one pathvector instead of maintaining a vector of pathvectors
4f6f96b37466fa06ffc85e7a0921db83bdeac757Johan B. C. EngelenEffect::getCanvasIndicators(SPLPEItem const* lpeitem)
a0f7fce08805ee4c0e78577d34d914e6d6d789d1scislac// g_print ("How to handle helperpaths for non-shapes?\n"); // non-shapes are for example SPGroups.
4f6f96b37466fa06ffc85e7a0921db83bdeac757Johan B. C. Engelen // add indicators provided by the effect itself
4f6f96b37466fa06ffc85e7a0921db83bdeac757Johan B. C. Engelen // add indicators provided by the effect's parameters
2e2b8bd323e3693f9d86f545ce049d3f1b45d1c2cilix for (std::vector<Parameter *>::iterator p = param_vector.begin(); p != param_vector.end(); ++p) {
2e2b8bd323e3693f9d86f545ce049d3f1b45d1c2cilix * Add possible canvas indicators (i.e., helperpaths other than the original path) to \a hp_vec
2e2b8bd323e3693f9d86f545ce049d3f1b45d1c2cilix * This function should be overwritten by derived effects if they want to provide their own helperpaths.
0b2d8abc1011ad865fce3b883ccb2587cb15cc90Johan B. C. EngelenEffect::addCanvasIndicators(SPLPEItem const*/*lpeitem*/, std::vector<Geom::PathVector> &/*hp_vec*/)
73d455c08e8062e257dd052d2d690b9300434351cilix * This *creates* a new widget, management of deletion should be done by the caller
c0cd5511d3b975ebe07d019c1f5528108725e438johanengelen // use manage here, because after deletion of Effect object, others might still be pointing to this widget.
c0cd5511d3b975ebe07d019c1f5528108725e438johanengelen Gtk::VBox * vbox = Gtk::manage( new Gtk::VBox() );
c0cd5511d3b975ebe07d019c1f5528108725e438johanengelen std::vector<Parameter *>::iterator it = param_vector.begin();
5cf332777b4c27336d64c273ac63bce3ee27a53dAlex Valavanis Gtk::Widget * widg = param->param_newWidget();
93bb287e28a818fd5ba61b99d012e0500a49ccf6johanengelen std::vector<Parameter *>::iterator it = param_vector.begin();
af8d25189f88abf89cdbe0e180e271c94079624fbuliabyak if (oncanvasedit_it >= static_cast<int>(param_vector.size())) {
a0334366488989ef25fb812d7030d298c0917c96johanengelen Parameter * param = param_vector[oncanvasedit_it];
f9504c822b72a774b910958446fd1e730235b7cbjoncruz if (oncanvasedit_it == static_cast<int>(param_vector.size())) { // loop round the map
fb5a72174252e0e79107dcad3bf5a2bbd73e349cjohanengelen } while (oncanvasedit_it != old_it); // iterate until complete loop through map has been made
fb5a72174252e0e79107dcad3bf5a2bbd73e349cjohanengelenEffect::editNextParamOncanvas(SPItem * item, SPDesktop * desktop)
fb5a72174252e0e79107dcad3bf5a2bbd73e349cjohanengelen if (!desktop) return;
fb5a72174252e0e79107dcad3bf5a2bbd73e349cjohanengelen Parameter * param = getNextOncanvasEditableParam();
fb5a72174252e0e79107dcad3bf5a2bbd73e349cjohanengelen gchar *message = g_strdup_printf(_("Editing parameter <b>%s</b>."), param->param_label.c_str());
fb5a72174252e0e79107dcad3bf5a2bbd73e349cjohanengelen desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, message);
fb5a72174252e0e79107dcad3bf5a2bbd73e349cjohanengelen desktop->messageStack()->flash( Inkscape::WARNING_MESSAGE,
fb5a72174252e0e79107dcad3bf5a2bbd73e349cjohanengelen _("None of the applied path effect's parameters can be edited on-canvas.") );
42e99769805c14a5cc01c805faa3c3b03f9dd1c0johanengelen/* This function should reset the defaults and is used for example to initialize an effect right after it has been applied to a path
42e99769805c14a5cc01c805faa3c3b03f9dd1c0johanengelen* The nice thing about this is that this function can use knowledge of the original path and set things accordingly for example to the size or origin of the original path!
a39c187369a59e887255e3f704a3ababf2b10678Johan B. C. EngelenEffect::resetDefaults(SPItem const* /*item*/)
a69e3ca5fcc8acacf862c577620d75f472d58cecjohanengelen std::vector<Inkscape::LivePathEffect::Parameter *>::iterator p;
a69e3ca5fcc8acacf862c577620d75f472d58cecjohanengelen for (p = param_vector.begin(); p != param_vector.end(); ++p) {
d37634d73670180f99a3e0ea583621373d90ec4fJohan EngelenEffect::transform_multiply(Geom::Affine const& postmul, bool set)
ddc251b3cf95b0097b6a5ee39ea132bd4d7d5cbcjohanengelen // cycle through all parameters. Most parameters will not need transformation, but path and point params do.
84d6d1f7365e49f2936df9df890ce49d2c000ce2Kris for (std::vector<Parameter *>::iterator it = param_vector.begin(); it != param_vector.end(); ++it) {
42ba1b712b7b430669fc49aa9facb439181081becilix // does the effect actively provide any knotholder entities of its own?
42ba1b712b7b430669fc49aa9facb439181081becilix return true;
6c3e745a94ef6b25a4ef9f018d350a7535aa45afTed Gould // otherwise: are there any parameters that have knotholderentities?
507f5de177a9e789927e7ac3e80ac05b27720084Johan B. C. Engelen for (std::vector<Parameter *>::const_iterator p = param_vector.begin(); p != param_vector.end(); ++p) {
42ba1b712b7b430669fc49aa9facb439181081becilix return true;
42ba1b712b7b430669fc49aa9facb439181081becilix return false;
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm} /* namespace LivePathEffect */
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm} /* namespace Inkscape */
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm Local Variables:
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm c-file-style:"stroustrup"
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm indent-tabs-mode:nil
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm fill-column:99
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :