effect.cpp revision 797bee69297bbdd86c5cff2e0771a71d1e2ac69d
#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_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"
// end of includes
namespace Inkscape {
namespace LivePathEffect {
// {constant defined in effect.h, N_("name of your effect"), "name of your effect in SVG"}
#ifdef LPE_ENABLE_TEST_EFFECTS
#endif
{FREEHAND_SHAPE, N_("Freehand Shape"), "freehand_shape"}, // this is actually a special type of PatternAlongPath, used to paste shapes in pen/pencil tool
{PATTERN_ALONG_PATH, N_("Pattern Along Path"), "skeletal"}, // for historic reasons, this effect is called skeletal(strokes) in Inkscape:SVG
};
const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData));
{
switch (lpenr) {
case PATTERN_ALONG_PATH:
break;
case FREEHAND_SHAPE:
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_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;
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
}
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),
show_orig_path(false),
concatenate_before_pwd2(false),
provides_own_flash_paths(true) // is automatically set to false if providesOwnFlashPaths() is not overridden
{
}
{
}
{
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 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::acceptsNumParams() 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 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
using namespace Inkscape::LivePathEffect;
// add handles provided by the effect itself
}
// add handles provided by the effect's parameters (if any)
}
}
void
{
if (providesKnotholder() && showOrigPath()) {
// TODO: we assume that if the LPE provides its own knotholder, there is no nodepath so we
// must create the helper curve for the original path manually; once we allow nodepaths and
// knotholders alongside each other, this needs to be rethought!
}
if ( Inkscape::LivePathEffect::PathParam *pathparam = dynamic_cast<Inkscape::LivePathEffect::PathParam*>(*p) ) {
// TODO: factor this out (also the copied code above); see also lpe-lattice.cpp
SPCanvasItem *canvasitem = sp_nodepath_generate_helperpath(desktop, c, SP_ITEM(lpeitem), 0x009000ff);
}
}
}
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++) {
}
}
// TODO: take _all_ parameters into account, not only PointParams
bool
{
// does the effect actively provide any knotholder entities of its own?
if (kh_entity_vector.size() > 0)
return true;
// otherwise: are there any PointParams?
if ( Inkscape::LivePathEffect::PointParam *pointparam = dynamic_cast<Inkscape::LivePathEffect::PointParam*>(*p) ) {
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 :