effect.cpp revision 3031066f5c2bef3af74912f2d0f510b0113d7058
/*
* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
* Abhishek Sharma
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
//#define LPE_ENABLE_TEST_EFFECTS
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
// include effects:
#include "live_effects/lpe-patternalongpath.h"
#include "live_effects/effect.h"
#include "live_effects/lpe-bendpath.h"
#include "live_effects/lpe-sketch.h"
#include "live_effects/lpe-vonkoch.h"
#include "live_effects/lpe-knot.h"
#include "live_effects/lpe-rough-hatches.h"
#include "live_effects/lpe-dynastroke.h"
#include "live_effects/lpe-test-doEffect-stack.h"
//BSpline
#include "live_effects/lpe-bspline.h"
//BSpline End
#include "live_effects/lpe-gears.h"
#include "live_effects/lpe-curvestitch.h"
#include "live_effects/lpe-circle_with_radius.h"
#include "live_effects/lpe-perspective_path.h"
#include "live_effects/lpe-spiro.h"
#include "live_effects/lpe-lattice.h"
#include "live_effects/lpe-envelope.h"
#include "live_effects/lpe-constructgrid.h"
#include "live_effects/lpe-perp_bisector.h"
#include "live_effects/lpe-tangent_to_curve.h"
#include "live_effects/lpe-mirror_symmetry.h"
#include "live_effects/lpe-circle_3pts.h"
#include "live_effects/lpe-angle_bisector.h"
#include "live_effects/lpe-parallel.h"
#include "live_effects/lpe-copy_rotate.h"
#include "live_effects/lpe-offset.h"
#include "live_effects/lpe-ruler.h"
#include "live_effects/lpe-boolops.h"
#include "live_effects/lpe-interpolate.h"
#include "live_effects/lpe-text_label.h"
#include "live_effects/lpe-path_length.h"
#include "live_effects/lpe-line_segment.h"
#include "live_effects/lpe-recursiveskeleton.h"
#include "live_effects/lpe-extrude.h"
#include "live_effects/lpe-powerstroke.h"
#include "live_effects/lpe-clone-original.h"
#include "xml/node-event-vector.h"
#include "sp-object.h"
#include "attributes.h"
#include "message-stack.h"
#include "desktop.h"
#include "inkscape.h"
#include "document.h"
#include "document-private.h"
#include "xml/document.h"
#include "pen-context.h"
#include "tools-switch.h"
#include "message-stack.h"
#include "desktop.h"
#include "knotholder.h"
#include "sp-lpe-item.h"
#include "live_effects/lpeobject.h"
#include "live_effects/parameter/parameter.h"
#include <exception>
namespace Inkscape {
namespace LivePathEffect {
// {constant defined in effect-enum.h, N_("name of your effect"), "name of your effect in SVG"}
#ifdef LPE_ENABLE_TEST_EFFECTS
// TRANSLATORS: boolean operations
#endif
/* 0.46 */
{PATTERN_ALONG_PATH, N_("Pattern Along Path"), "skeletal"}, // for historic reasons, this effect is called skeletal(strokes) in Inkscape:SVG
/* 0.47 */
/* 0.49 */
//BSpline
//BSpline End
};
const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData));
int
switch (type) {
case INVALID_LPE: return -1; // in case we want to distinguish between invalid LPE and valid ones that expect zero clicks
case ANGLE_BISECTOR: return 3;
case CIRCLE_3PTS: return 3;
case CIRCLE_WITH_RADIUS: return 2;
case LINE_SEGMENT: return 2;
case PERP_BISECTOR: return 2;
default: return 0;
}
}
{
switch (lpenr) {
case PATTERN_ALONG_PATH:
break;
case BEND_PATH:
break;
case SKETCH:
break;
case ROUGH_HATCHES:
break;
case VONKOCH:
break;
case KNOT:
break;
case GEARS:
break;
case CURVE_STITCH:
break;
case LATTICE:
break;
case ENVELOPE:
break;
case CIRCLE_WITH_RADIUS:
break;
case PERSPECTIVE_PATH:
break;
case SPIRO:
break;
case CONSTRUCT_GRID:
break;
case PERP_BISECTOR:
break;
case TANGENT_TO_CURVE:
break;
case MIRROR_SYMMETRY:
break;
case CIRCLE_3PTS:
break;
case ANGLE_BISECTOR:
break;
case PARALLEL:
break;
case COPY_ROTATE:
break;
case OFFSET:
break;
case RULER:
break;
case BOOLOPS:
break;
case INTERPOLATE:
break;
case TEXT_LABEL:
break;
case PATH_LENGTH:
break;
case LINE_SEGMENT:
break;
case DOEFFECTSTACK_TEST:
break;
//BSpline
case BSPLINE:
break;
//BSpline End
case DYNASTROKE:
break;
case RECURSIVE_SKELETON:
break;
case EXTRUDE:
break;
case POWERSTROKE:
break;
case CLONE_ORIGINAL:
break;
default:
break;
}
if (neweffect) {
}
return neweffect;
}
{
// Path effect definition
}
void
{
}
: _provides_knotholder_entities(false),
oncanvasedit_it(0),
is_visible(_("Is visible?"), _("If unchecked, the effect remains applied to the object but is temporarily disabled on canvas"), "is_visible", &wr, this, true),
show_orig_path(false),
concatenate_before_pwd2(false),
provides_own_flash_paths(true), // is automatically set to false if providesOwnFlashPaths() is not overridden
is_ready(false) // is automatically set to false if providesOwnFlashPaths() is not overridden
{
is_visible.widget_is_visible = false;
}
{
}
{
else
}
Effect::effectType() const {
return lpeobj->effecttype;
}
/**
* Is performed a single time when the effect is freshly applied to a path
*/
void
{
}
/**
* Is performed each time before the effect is updated.
*/
void
{
//Do nothing for simple effects
}
/**
* Effects can have a parameter path set before they are applied by accepting a nonzero number of
* mouse clicks. This method activates the pen context, which waits for the specified number of
* clicks. Override Effect::acceptsNumClicks() to return the number of expected mouse clicks.
*/
void
{
// switch to pen context
SPDesktop *desktop = inkscape_active_desktop(); // TODO: Is there a better method to find the item's desktop?
}
pc->waiting_LPE = this;
pc->polylines_only = true;
g_strdup_printf(_("Please specify a parameter path for the LPE '%s' with %d mouse clicks"),
}
void
Effect::writeParamsToSVG() {
(*p)->write_to_SVG();
}
}
/**
* If the effect expects a path parameter (specified by a number of mouse clicks) before it is
* applied, this is the method that processes the resulting path. Override it to customize it for
* your LPE. But don't forget to call the parent method so that is_ready is set to true!
*/
void
setReady();
}
/*
* Here be the doEffect function chain:
*/
void
{
}
{
if ( !concatenate_before_pwd2 ) {
// default behavior
// add the output path vector to the already accumulated vector:
}
}
} else {
// concatenate the path into possibly discontinuous pwd2
}
}
return path_out;
}
{
g_warning("Effect has no doEffect implementation");
return pwd2_in;
}
void
{
if (value) {
if (!accepted) {
}
} else {
// set default value
}
++it;
}
}
/* This function does not and SHOULD NOT write to XML */
void
{
if (param) {
if (new_value) {
if (!accepted) {
}
} else {
// set default value
}
}
}
void
{
}
/**
* Add all registered LPE knotholder handles to the knotholder
*/
void
using namespace Inkscape::LivePathEffect;
// add handles provided by the effect itself
// add handles provided by the effect's parameters (if any)
}
}
/**
* Return a vector of PathVectors which contain all helperpaths that should be drawn by the effect.
* This is the function called by external code like SPLPEItem.
*/
{
if (!SP_IS_SHAPE(lpeitem)) {
// g_print ("How to handle helperpaths for non-shapes?\n"); // non-shapes are for example SPGroups.
return hp_vec;
}
// TODO: we can probably optimize this by using a lot more references
// rather than copying PathVectors all over the place
if (show_orig_path) {
// add original path to helperpaths
}
// add other helperpaths provided by the effect itself
// add helperpaths provided by the effect's parameters
}
return hp_vec;
}
/**
* Add possible canvas indicators (i.e., helperpaths other than the original path) to \a hp_vec
* This function should be overwritten by derived effects if they want to provide their own helperpaths.
*/
void
{
}
/**
* This *creates* a new widget, management of deletion should be done by the caller
*/
{
// use manage here, because after deletion of Effect object, others might still be pointing to this widget.
if ((*it)->widget_is_visible) {
if (widg) {
if (tip) {
} else {
widg->set_has_tooltip(false);
}
}
}
++it;
}
}
{
}
{
g_message("Effect::getSPDoc() returns NULL");
}
}
{
return param;
}
++it;
}
return NULL;
}
{
return NULL;
oncanvasedit_it = 0;
}
int old_it = oncanvasedit_it;
do {
return param;
} else {
oncanvasedit_it = 0;
}
}
return NULL;
}
void
{
if (!desktop) return;
if (param) {
} else {
_("None of the applied path effect's parameters can be edited on-canvas.") );
}
}
/* 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!
*/
void
{
(*p)->param_set_default();
(*p)->write_to_SVG();
}
}
void
{
// 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) {
}
}
bool
Effect::providesKnotholder() const
{
// does the effect actively provide any knotholder entities of its own?
return true;
}
// otherwise: are there any parameters that have knotholderentities?
for (std::vector<Parameter *>::const_iterator p = param_vector.begin(); p != param_vector.end(); ++p) {
if ((*p)->providesKnotHolderEntities()) {
return true;
}
}
return false;
}
} /* namespace LivePathEffect */
} /* namespace Inkscape */
/*
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 :