effect.cpp revision 8791d7447034c34fdedc50f261bf5c89c34e59f5
1508N/A#include "live_effects/effect.h"
691N/A#include "xml/node-event-vector.h"
691N/A#include "sp-object.h"
691N/A#include "attributes.h"
691N/A#include "message-stack.h"
1634N/A#include "inkscape.h"
1265N/A#include "document.h"
1265N/A#include "document-private.h"
691N/A#include "xml/document.h"
691N/A#include "pen-context.h"
1333N/A#include "tools-switch.h"
1333N/A#include "message-stack.h"
1333N/A#include "nodepath.h"
1333N/A#include "live_effects/lpeobject.h"
1333N/A#include "live_effects/parameter/parameter.h"
1333N/A#include "live_effects/lpe-patternalongpath.h"
1333N/A#include "live_effects/lpe-bendpath.h"
1333N/A#include "live_effects/lpe-sketch.h"
1333N/A#include "live_effects/lpe-vonkoch.h"
1333N/A#include "live_effects/lpe-knot.h"
1265N/A#include "live_effects/lpe-test-doEffect-stack.h"
1265N/A#include "live_effects/lpe-gears.h"
1333N/A#include "live_effects/lpe-curvestitch.h"
691N/A#include "live_effects/lpe-circle_with_radius.h"
1333N/A#include "live_effects/lpe-perspective_path.h"
1333N/A#include "live_effects/lpe-spiro.h"
1333N/A#include "live_effects/lpe-lattice.h"
1333N/A#include "live_effects/lpe-envelope.h"
1333N/A#include "live_effects/lpe-constructgrid.h"
1333N/A#include "live_effects/lpe-perp_bisector.h"
1333N/A#include "live_effects/lpe-tangent_to_curve.h"
691N/A#include "live_effects/lpe-mirror_symmetry.h"
1333N/A#include "live_effects/lpe-circle_3pts.h"
1333N/A#include "live_effects/lpe-angle_bisector.h"
1333N/A#include "live_effects/lpe-parallel.h"
1634N/A#include "live_effects/lpe-copy_rotate.h"
1634N/A#include "live_effects/lpe-offset.h"
1333N/A#include "live_effects/lpe-ruler.h"
1634N/A#include "live_effects/lpe-boolops.h"
1333N/A#include "live_effects/lpe-interpolate.h"
1333N/A#include "live_effects/lpe-text_label.h"
691N/A#include "live_effects/lpe-path_length.h"
1333N/A#include "live_effects/lpe-line_segment.h"
1634N/Anamespace LivePathEffect {
691N/A {FREEHAND_SHAPE, N_("Freehand Shape"), "freehand_shape"}, // this is actually a special type of PatternAlongPath, used to paste shapes in pen/pencil tool
1333N/A {PATTERN_ALONG_PATH, N_("Pattern Along Path"), "skeletal"}, // for historic reasons, this effect is called skeletal(strokes) in Inkscape:SVG
1634N/Aconst Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData));
1508N/A case PATTERN_ALONG_PATH:
1508N/A case FREEHAND_SHAPE:
1508N/A case DOEFFECTSTACK_TEST:
1634N/A case CURVE_STITCH:
1634N/A case CIRCLE_WITH_RADIUS:
1508N/A case PERSPECTIVE_PATH:
1508N/A case CONSTRUCT_GRID:
1634N/A case PERP_BISECTOR:
1265N/A case TANGENT_TO_CURVE:
1265N/A case MIRROR_SYMMETRY:
1508N/A case CIRCLE_3PTS:
1634N/A case ANGLE_BISECTOR:
1333N/A case COPY_ROTATE:
1508N/A case INTERPOLATE:
1508N/A case TEXT_LABEL:
1508N/A case PATH_LENGTH:
1508N/A case LINE_SEGMENT:
1508N/A SP_OBJECT_REPR(SP_DOCUMENT_DEFS(doc))->addChild(repr, NULL); // adds to <defs> and assigns the 'id' attribute
1508N/A : oncanvasedit_it(0),
1508N/A is_visible(_("Is visible?"), _("If unchecked, the effect remains applied to the object but is temporarily disabled on canvas"), "is_visible", &wr, this, true),
1508N/A show_orig_path(false),
1508N/A concatenate_before_pwd2(false),
1508N/A provides_own_flash_paths(true), // is automatically set to false if providesOwnFlashPaths() is not overridden
1508N/A is_ready(false) // is automatically set to false if providesOwnFlashPaths() is not overridden
1508N/A * Effects can have a parameter path set before they are applied by accepting a nonzero number of
1508N/A * mouse clicks. This method activates the pen context, which waits for the specified number of
1508N/A * clicks. Override Effect::acceptsNumClicks() to return the number of expected mouse clicks.
1508N/A SPDesktop *desktop = inkscape_active_desktop(); // TODO: Is there a better method to find the item's desktop?
1508N/A (*p)->write_to_SVG();
1508N/A * If the effect expects a path parameter (specified by a number of mouse clicks) before it is
1508N/A * applied, this is the method that processes the resulting path. Override it to customize it for
1508N/A if ( !concatenate_before_pwd2 ) {
1634N/A std::vector<Geom::Path> path = Geom::path_from_piecewise( pwd2_out, LPE_CONVERSION_TOLERANCE);
1634N/A for (std::vector<Parameter *>::iterator p = param_vector.begin(); p != param_vector.end(); ++p) {
1634N/A * Return a vector of PathVectors which contain all helperpaths that should be drawn by the effect.
1634N/A if (show_orig_path) {
1634N/A for (std::vector<Parameter *>::iterator p = param_vector.begin(); p != param_vector.end(); ++p) {
1634N/A * Add possible canvas indicators (i.e., helperpaths other than the original path) to \a hp_vec
1634N/A * This function should be overwritten by derived effects if they want to provide their own helperpaths.
1634N/AEffect::addCanvasIndicators(SPLPEItem */*lpeitem*/, std::vector<Geom::PathVector> &/*hp_vec*/)
1634N/A // use manage here, because after deletion of Effect object, others might still be pointing to this widget.
return param;
it++;
return NULL;
return NULL;
oncanvasedit_it = 0;
return param;
oncanvasedit_it = 0;
return NULL;
if (!desktop) return;
if (param) {
/* This function should reset the defaults and is used for example to initialize an effect right after it has been applied to a path
* 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!
// cycle through all parameters. Most parameters will not need transformation, but path and point params do.
for (std::vector<Parameter *>::iterator it = param_vector.begin(); it != param_vector.end(); it++) {