X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Flive_effects%2Feffect.h;h=ae42e358c2ef3e03bb1fc5d7e48d8d2ef89fdb70;hb=a72ec1a2bb8eb1f6aabcb0904c539ee609b716c3;hp=844a158b59ca9e59ccf1f2aa1b62b2c7386d9e69;hpb=fb5a72174252e0e79107dcad3bf5a2bbd73e349c;p=inkscape.git diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index 844a158b5..ae42e358c 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -4,7 +4,7 @@ /* * Inkscape::LivePathEffect * -* Copyright (C) Johan Engelen 2007 +* Copyright (C) Johan Engelen 2007-2008 * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -14,17 +14,19 @@ #include #include #include <2geom/path.h> +#include <2geom/forward.h> #include "ui/widget/registry.h" -#include "util/enums.h" +#include "sp-lpe-item.h" +#include "knotholder.h" +#include "parameter/bool.h" +#include "effect-enum.h" #define LPE_CONVERSION_TOLERANCE 0.01 // FIXME: find good solution for this. -//#define LPE_ENABLE_TEST_EFFECTS - struct SPDocument; struct SPDesktop; struct SPItem; -class NArtBpath; +class SPNodeContext; struct LivePathEffectObject; namespace Gtk { @@ -39,81 +41,147 @@ namespace XML { class Node; } +namespace NodePath { + class Path ; +} + namespace LivePathEffect { -enum EffectType { - SKELETAL_STROKES = 0, -#ifdef LPE_ENABLE_TEST_EFFECTS - SLANT, - DOEFFECTSTACK_TEST, -#endif - GEARS, - CURVE_STITCH, - INVALID_LPE // This must be last +enum LPEPathFlashType { + SUPPRESS_FLASH, +// PERMANENT_FLASH, + DEFAULT }; -extern const Util::EnumData LPETypeData[INVALID_LPE]; -extern const Util::EnumDataConverter LPETypeConverter; - -class Parameter; - class Effect { public: + static Effect* New(EffectType lpenr, LivePathEffectObject *lpeobj); + static void createAndApply(const char* name, SPDocument *doc, SPItem *item); + static void createAndApply(EffectType type, SPDocument *doc, SPItem *item); + virtual ~Effect(); - Glib::ustring getName(); + EffectType effectType (); + + virtual void doOnApply (SPLPEItem *lpeitem); + virtual void doBeforeEffect (SPLPEItem *lpeitem); + + void writeParamsToSVG(); + + virtual void acceptParamPath (SPPath *param_path); + static int acceptsNumClicks(EffectType type); + int acceptsNumClicks() { return acceptsNumClicks(effectType()); } + void doAcceptPathPreparations(SPLPEItem *lpeitem); + + /* + * isReady() indicates whether all preparations which are necessary to apply the LPE are done, + * e.g., waiting for a parameter path either before the effect is created or when it needs a + * path as argument. This is set in sp_lpe_item_add_path_effect(). + */ + inline bool isReady() { return is_ready; } + inline void setReady(bool ready = true) { is_ready = ready; } virtual void doEffect (SPCurve * curve); - static Effect* New(EffectType lpenr, LivePathEffectObject *lpeobj); + virtual Gtk::Widget * newWidget(Gtk::Tooltips * tooltips); + + virtual void resetDefaults(SPItem * item); - virtual Gtk::Widget * getWidget(); + virtual void setup_nodepath(Inkscape::NodePath::Path *np); - Inkscape::XML::Node * getRepr(); - SPDocument * getSPDoc(); + /// /todo: is this method really necessary? it causes UI inconsistensies... (johan) + virtual void transform_multiply(Geom::Matrix const& postmul, bool set); + + // /TODO: providesKnotholder() is currently used as an indicator of whether a nodepath is + // created for an item or not. When we allow both at the same time, this needs rethinking! + bool providesKnotholder(); + // /TODO: in view of providesOwnFlashPaths() below, this is somewhat redundant + // (but spiro lpe still needs it!) + virtual LPEPathFlashType pathFlashType() { return DEFAULT; } + void addHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); + std::vector getHelperPaths(SPLPEItem *lpeitem); + + inline bool providesOwnFlashPaths() { + return provides_own_flash_paths || show_orig_path; + } + inline bool showOrigPath() { return show_orig_path; } + + Glib::ustring getName(); + Inkscape::XML::Node * getRepr(); + SPDocument * getSPDoc(); LivePathEffectObject * getLPEObj() {return lpeobj;}; + Parameter * getParameter(const char * key); void readallParameters(Inkscape::XML::Node * repr); void setParameter(const gchar * key, const gchar * new_value); + inline bool isVisible() { return is_visible; } + void editNextParamOncanvas(SPItem * item, SPDesktop * desktop); protected: Effect(LivePathEffectObject *lpeobject); - // provide a set of doEffect functions so the developer has a choice + // provide a set of doEffect functions so the developer has a choice // of what kind of input/output parameters he desires. - // the order in which they appear is the order in which they are + // the order in which they appear is the order in which they are // called by this base class. (i.e. doEffect(SPCurve * curve) defaults to calling // doEffect(std::vector ) - virtual NArtBpath * - doEffect (NArtBpath * path_in); - virtual std::vector - doEffect (std::vector & path_in); - virtual Geom::Piecewise > - doEffect (Geom::Piecewise > & pwd2_in); + virtual std::vector + doEffect_path (std::vector const & path_in); + virtual Geom::Piecewise > + doEffect_pwd2 (Geom::Piecewise > const & pwd2_in); void registerParameter(Parameter * param); + void registerKnotHolderHandle(KnotHolderEntity* entity, const char* descr); Parameter * getNextOncanvasEditableParam(); - typedef std::map param_map_type; - param_map_type param_map; + void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); + + //virtual std::vector getCanvasIndicators(SPLPEItem *lpeitem); + virtual void addCanvasIndicators(SPLPEItem *lpeitem, std::vector &hp_vec); + + + std::vector param_vector; + std::vector > kh_entity_vector; + int oncanvasedit_it; + BoolParam is_visible; + BoolParam deactivate_knotholder; // the user can use this to deactivate knotholders (for + // convenience, because they may interfere with node handles + // during editing); this is probably only temporary - Inkscape::UI::Widget::Registry wr; - Gtk::VBox * vbox; - Gtk::Tooltips * tooltips; + bool show_orig_path; // set this to true in derived effects to automatically have the original + // path displayed as helperpath + + Inkscape::UI::Widget::Registry wr; LivePathEffectObject *lpeobj; - param_map_type::iterator oncanvasedit_it; + // this boolean defaults to false, it concatenates the input path to one pwd2, + // instead of normally 'splitting' the path into continuous pwd2 paths. + bool concatenate_before_pwd2; private: + bool provides_own_flash_paths; // if true, the standard flash path is suppressed + + bool is_ready; + Effect(const Effect&); Effect& operator=(const Effect&); }; - } //namespace LivePathEffect } //namespace Inkscape #endif + +/* + 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 :