effect.cpp revision 04c99c338ffdc6e10cb6f5c18f6f06b3f555e8eb
#define INKSCAPE_LIVEPATHEFFECT_CPP
/*
* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "live_effects/effect.h"
#include "display/display-forward.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 "nodepath.h"
#include "live_effects/lpeobject.h"
#include "live_effects/parameter/parameter.h"
#include "libnr/n-art-bpath-2geom.h"
#include <gtkmm.h>
#include <exception>
// include effects:
#include "live_effects/lpe-patternalongpath.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-test-doEffect-stack.h"
#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_reflect.h"
// end of includes
namespace Inkscape {
namespace LivePathEffect {
// {constant defined in effect.h, N_("name of your effect"), "name of your effect in SVG"}
{PATTERN_ALONG_PATH, N_("Pattern Along Path"), "skeletal"}, // for historic reasons, this effect is called skeletal(strokes) in Inkscape:SVG
#ifdef LPE_ENABLE_TEST_EFFECTS
#endif
};
{
switch (lpenr) {
case PATTERN_ALONG_PATH:
break;
case BEND_PATH:
break;
case SKETCH:
break;
case VONKOCH:
break;
case KNOT:
break;
#ifdef LPE_ENABLE_TEST_EFFECTS
case DOEFFECTSTACK_TEST:
break;
#endif
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_REFLECT:
break;
default:
break;
}
if (neweffect) {
}
return neweffect;
}
void
{
// Path effect definition
SP_OBJECT_REPR(SP_DOCUMENT_DEFS(doc))->addChild(repr, NULL); // adds to <defs> and assigns the 'id' attribute
_("Create and apply path effect"));
}
void
{
}
: 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),
done_pathparam_set(false),
provides_own_flash_paths(true), // is automatically set to false if providesOwnFlashPaths() is not overridden
show_orig_path(false),
concatenate_before_pwd2(false)
{
}
{
}
{
else
}
Effect::effectType() {
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 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::acceptsNumParams() to set 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 done_pathparam_set is set to true!
*/
void
done_pathparam_set = true;
}
/*
* 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
{
}
// TODO: should we provide a way to alter the handle's appearance?
void
{
}
/**
* Add all registered LPE knotholder handles to the knotholder
*/
void
}
}
void
using namespace std;
KnotHolderEntity *e = dynamic_cast<KnotHolderEntity *>(*p);
knotholder->add(e);
}
}
}
void
{
if (show_orig_path) {
// TODO: Make sure the tempitem doesn't get destroyed when the mouse leaves the item
}
}
void
{
// if this method is overloaded in derived classes, provides_own_flash_paths will be true
provides_own_flash_paths = false;
}
/**
* 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 (widg) {
}
}
it++;
}
}
{
return SP_OBJECT_REPR(lpeobj);
}
{
return SP_OBJECT_DOCUMENT(lpeobj);
}
{
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
{
// do nothing for simple effects
}
void
{
}
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++) {
}
}
} /* 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 :