lpe-skeleton.cpp revision 76addc201c409e81eaaa73fe27cc0f79c4db097c
dbb33756bd786e9432e18ec7be93f8c416e1b492Jon A. Cruz/**
dbb33756bd786e9432e18ec7be93f8c416e1b492Jon A. Cruz * @file
dbb33756bd786e9432e18ec7be93f8c416e1b492Jon A. Cruz * Minimal dummy LPE effect implementation, used as an example for a base
6c3e745a94ef6b25a4ef9f018d350a7535aa45afTed Gould * starting class when implementing new LivePathEffects.
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm *
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm * In vi, three global search-and-replaces will let you rename everything
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm * in this and the .h file:
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm *
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm * :%s/SKELETON/YOURNAME/g
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm * :%s/Skeleton/Yourname/g
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm * :%s/skeleton/yourname/g
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm */
6c3e745a94ef6b25a4ef9f018d350a7535aa45afTed Gould/* Authors:
3cfad782faf34c654ec837780ed7b3fe95e82c2eJohan B. C. Engelen * Johan Engelen <j.b.c.engelen@alumnus.utwente.nl>
02b211d5ad0015f24b09dee846a89cf19e95f98dcilix *
3cfad782faf34c654ec837780ed7b3fe95e82c2eJohan B. C. Engelen * Copyright (C) 2007-2012 Authors
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm *
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm * Released under GNU GPL, read the file 'COPYING' for more information
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm */
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm#include "live_effects/lpe-skeleton.h"
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm// You might need to include other 2geom files. You can add them here:
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm#include <2geom/path.h>
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm
101f2e5b97fe12353f196f581a4dbadc23a33980Alex Valavanis#include <glibmm/i18n.h>
101f2e5b97fe12353f196f581a4dbadc23a33980Alex Valavanis
3cfad782faf34c654ec837780ed7b3fe95e82c2eJohan B. C. Engelen//#include "knot-holder-entity.h"
3cfad782faf34c654ec837780ed7b3fe95e82c2eJohan B. C. Engelen//#include "knotholder.h"
3cfad782faf34c654ec837780ed7b3fe95e82c2eJohan B. C. Engelen
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrmnamespace Inkscape {
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrmnamespace LivePathEffect {
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrmLPESkeleton::LPESkeleton(LivePathEffectObject *lpeobject) :
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm Effect(lpeobject),
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm // initialise your parameters here:
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm number(_("Float parameter"), _("just a real number like 1.4!"), "svgname", &wr, this, 1.2)
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm{
80d34fe4a953d704430b44c6201a4fcbf455dfc6cilix /* uncomment the following line to have the original path displayed while the item is selected */
80d34fe4a953d704430b44c6201a4fcbf455dfc6cilix //show_orig_path = true;
3cfad782faf34c654ec837780ed7b3fe95e82c2eJohan B. C. Engelen /* uncomment the following line to enable display of the effect-specific on-canvas handles (knotholder entities) */
3cfad782faf34c654ec837780ed7b3fe95e82c2eJohan B. C. Engelen //_provides_knotholder_entities
80d34fe4a953d704430b44c6201a4fcbf455dfc6cilix
80d34fe4a953d704430b44c6201a4fcbf455dfc6cilix /* register all your parameters here, so Inkscape knows which parameters this effect has: */
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm registerParameter( dynamic_cast<Parameter *>(&number) );
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm}
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrmLPESkeleton::~LPESkeleton()
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm{
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm}
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm/* ########################
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm * Choose to implement one of the doEffect functions. You can delete or comment out the others.
02b211d5ad0015f24b09dee846a89cf19e95f98dcilix */
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm/*
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrmvoid
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrmLPESkeleton::doEffect (SPCurve * curve)
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm{
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm // spice this up to make the effect actually *do* something!
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm}
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm
76addc201c409e81eaaa73fe27cc0f79c4db097cKrzysztof KosińskiGeom::PathVector
76addc201c409e81eaaa73fe27cc0f79c4db097cKrzysztof KosińskiLPESkeleton::doEffect_path (Geom::PathVector const & path_in)
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm{
76addc201c409e81eaaa73fe27cc0f79c4db097cKrzysztof Kosiński Geom::PathVector path_out;
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm path_out = path_in; // spice this up to make the effect actually *do* something!
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm return path_out;
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm}
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm*/
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrmGeom::Piecewise<Geom::D2<Geom::SBasis> >
ecda720053ff791e35dae3c5c1177bc225b6cdf1johanengelenLPESkeleton::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in)
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm{
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm Geom::Piecewise<Geom::D2<Geom::SBasis> > output;
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm output = pwd2_in; // spice this up to make the effect actually *do* something!
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm return output;
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm}
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm
bf09820d782b89c56d79f070d06d7cf2682c270ecilix/* ########################
3cfad782faf34c654ec837780ed7b3fe95e82c2eJohan B. C. Engelen * If you want to provide effect-specific on-canvas handles (knotholder entities), define them here:
bf09820d782b89c56d79f070d06d7cf2682c270ecilix */
bf09820d782b89c56d79f070d06d7cf2682c270ecilix
6c3e745a94ef6b25a4ef9f018d350a7535aa45afTed Gould/*
bf09820d782b89c56d79f070d06d7cf2682c270ecilixnamespace Skeleton {
bf09820d782b89c56d79f070d06d7cf2682c270ecilix
25ad3718fb4b96b39930af8e043c8ee1e624fd10cilixclass KnotHolderEntityMyHandle : public LPEKnotHolderEntity
bf09820d782b89c56d79f070d06d7cf2682c270ecilix{
bf09820d782b89c56d79f070d06d7cf2682c270ecilixpublic:
bf09820d782b89c56d79f070d06d7cf2682c270ecilix // the set() and get() methods must be implemented, click() is optional
5b20351508dc029f37f23fb7add6d0b43bf47f20johanengelen virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state);
0b2d8abc1011ad865fce3b883ccb2587cb15cc90Johan B. C. Engelen virtual Geom::Point knot_get() const;
bf09820d782b89c56d79f070d06d7cf2682c270ecilix //virtual void knot_click(guint state);
bf09820d782b89c56d79f070d06d7cf2682c270ecilix};
bf09820d782b89c56d79f070d06d7cf2682c270ecilix
bf09820d782b89c56d79f070d06d7cf2682c270ecilix} // namespace Skeleton
3cfad782faf34c654ec837780ed7b3fe95e82c2eJohan B. C. Engelen
3cfad782faf34c654ec837780ed7b3fe95e82c2eJohan B. C. Engelenvoid
3cfad782faf34c654ec837780ed7b3fe95e82c2eJohan B. C. EngelenLPESkeleton::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) {
3cfad782faf34c654ec837780ed7b3fe95e82c2eJohan B. C. Engelen {
3cfad782faf34c654ec837780ed7b3fe95e82c2eJohan B. C. Engelen KnotHolderEntityMyHandle *e = new KnotHolderEntityMyHandle(this);
3cfad782faf34c654ec837780ed7b3fe95e82c2eJohan B. C. Engelen e->create( desktop, item, knotholder,
3cfad782faf34c654ec837780ed7b3fe95e82c2eJohan B. C. Engelen _("Text describing what this handle does"),
3cfad782faf34c654ec837780ed7b3fe95e82c2eJohan B. C. Engelen //optional: knot_shape, knot_mode, knot_color);
3cfad782faf34c654ec837780ed7b3fe95e82c2eJohan B. C. Engelen knotholder->add(e);
3cfad782faf34c654ec837780ed7b3fe95e82c2eJohan B. C. Engelen }
3cfad782faf34c654ec837780ed7b3fe95e82c2eJohan B. C. Engelen};
6c3e745a94ef6b25a4ef9f018d350a7535aa45afTed Gould*/
bf09820d782b89c56d79f070d06d7cf2682c270ecilix
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm/* ######################## */
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm} //namespace LivePathEffect
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm} /* namespace Inkscape */
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm/*
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm Local Variables:
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm mode:c++
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 End:
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm*/
a4030d5ca449e7e384bc699cd249ee704faaeab0Chris Morgan// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :