Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
sp-lpe-item.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
5/*
6 * Authors:
7 * Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
8 * Bastien Bouclet <bgkweb@gmail.com>
9 *
10 * Copyright (C) 2008 authors
11 *
12 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
13 */
14
15#ifndef SP_LPE_ITEM_H_SEEN
16#define SP_LPE_ITEM_H_SEEN
17
18#include <cstddef>
19#include <list>
20#include <memory>
21#include <string>
22#include <vector>
23
24#include <sigc++/scoped_connection.h>
25#include "sp-item.h"
26
28class SPShape;
29class SPDesktop;
30
31namespace Inkscape {
32
33namespace Display {
34class TemporaryItem;
35} // namespace Display
36
37namespace LivePathEffect{
38class LPEObjectReference;
39class Effect;
40} // namespace LivePathEffect
41
42} // namespace Inkscape
43
44using PathEffectSharedPtr = std::shared_ptr<Inkscape::LivePathEffect::LPEObjectReference>;
45using PathEffectList = std::list<PathEffectSharedPtr>;
46
47class SPLPEItem : public SPItem {
48 // this list contains the connections for listening to lpeobject parameter changes
49 std::list<sigc::scoped_connection> lpe_modified_connection_list;
50
51public:
52 SPLPEItem();
53 ~SPLPEItem() override;
54
55 int tag() const override { return tag_of<decltype(*this)>; }
56
57 // TODO: Data members should be private whererever possible.
58
60 // TODO: Avoid indirection/`new`:
63 std::vector<Inkscape::Display::TemporaryItem*> lpe_helperpaths;
64
65 void replacePathEffects( std::vector<LivePathEffectObject const *> const &old_lpeobjs,
66 std::vector<LivePathEffectObject const *> const &new_lpeobjs );
67
68
69 void build(SPDocument* doc, Inkscape::XML::Node* repr) override;
70 void release() override;
71
72 void set(SPAttr key, char const* value) override;
73
74 void update(SPCtx* ctx, unsigned int flags) override;
75 void modified(unsigned int flags) override;
78
79 Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override;
80
81 virtual void update_patheffect(bool write);
82 bool optimizeTransforms();
83 void notifyTransform(Geom::Affine const &postmul);
84 bool performPathEffect(Geom::PathVector &curve, SPShape *current, bool is_clip_or_mask = false);
86 bool pathEffectsEnabled() const;
87 bool hasPathEffect() const;
88 bool hasPathEffectOfType(int const type, bool is_ready = true) const;
89 bool hasPathEffectOfTypeRecursive(int const type, bool is_ready = true) const;
90 bool hasPathEffectRecursive() const;
91 SPLPEItem const * getTopPathEffect() const;
92 bool hasPathEffectOnClipOrMask(SPLPEItem * shape) const;
94 std::size_t getLPEIndex(Inkscape::LivePathEffect::Effect *lpe) const;
95 std::size_t countLPEOfType(int const type, bool inc_hidden = true, bool is_ready = true) const;
96 std::size_t getLPEReferenceIndex(PathEffectSharedPtr const &lperef) const;
99 std::vector<Inkscape::LivePathEffect::Effect *> getPathEffectsOfType(int type);
100 std::vector<Inkscape::LivePathEffect::Effect const *> getPathEffectsOfType(int type) const;
101 std::vector<Inkscape::LivePathEffect::Effect *> getPathEffects();
102 std::vector<Inkscape::LivePathEffect::Effect const *> getPathEffects() const;
103 std::vector<SPObject *> get_satellites(bool force = true, bool recursive = false, bool onchilds = false);
104 bool isOnClipboard();
105 bool isOnSymbol() const;
106 bool onsymbol = false;
107 bool hasBrokenPathEffect() const;
108 bool lpe_initialized = false;
110 PathEffectList const getEffectList() const;
111
114 void upCurrentPathEffect();
115 void removePathEffect(Inkscape::LivePathEffect::Effect* lpe, bool keep_paths);
116 void movePathEffect(gint origin, gint dest, bool select_moved = false);
126 bool setCurrentPathEffect(PathEffectSharedPtr const &lperef);
127 bool setCurrentPathEffect(LivePathEffectObject const *lpeobj);
128 SPLPEItem * removeCurrentPathEffect(bool keep_paths);
129 SPLPEItem * removeAllPathEffects(bool keep_paths, bool recursive = false);
130 void addPathEffect(std::string value, bool reset);
131 void addPathEffect(LivePathEffectObject * new_lpeobj);
132 void resetClipPathAndMaskLPE(bool fromrecurse = false);
133 void applyToMask(SPItem* to, Inkscape::LivePathEffect::Effect *lpe = nullptr);
135 void applyToClipPathOrMask(SPItem * clip_mask, SPItem* to, Inkscape::LivePathEffect::Effect *lpe = nullptr);
136 bool forkPathEffectsIfNecessary(unsigned int nr_of_allowed_users = 1, bool recursive = true, bool force = false);
138 void update_satellites(bool recursive = true);
139};
140void sp_lpe_item_update_patheffect (SPLPEItem *lpeitem, bool wholetree, bool write, bool with_satellites = false); // careful, class already has method with *very* similar name!
141void sp_lpe_item_enable_path_effects(SPLPEItem *lpeitem, bool enable);
142
143#endif /* !SP_LPE_ITEM_H_SEEN */
144
145/*
146 Local Variables:
147 mode:c++
148 c-file-style:"stroustrup"
149 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
150 indent-tabs-mode:nil
151 fill-column:99
152 End:
153*/
154// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
Point origin
Definition aa.cpp:227
SPAttr
Definition attributes.h:27
constexpr int tag_of
Convenience function to retrieve the tag (class id) of a given type.
Definition cast.h:26
3x3 matrix representing an affine transformation.
Definition affine.h:70
Sequence of subpaths.
Definition pathvector.h:122
Interface for refcounted XML nodes.
Definition node.h:80
To do: update description of desktop.
Definition desktop.h:149
Typed SVG document implementation.
Definition document.h:101
Base class for visual SVG elements.
Definition sp-item.h:109
bool onsymbol
bool isOnClipboard()
The lpeitem is on clipboard.
void remove_child(Inkscape::XML::Node *child) override
std::vector< Inkscape::LivePathEffect::Effect * > getPathEffectsOfType(int type)
void notifyTransform(Geom::Affine const &postmul)
notify tranbsform applied to a LPE
void release() override
void duplicateCurrentPathEffect()
void downCurrentPathEffect()
Inkscape::LivePathEffect::Effect * getCurrentLPE()
void resetClipPathAndMaskLPE(bool fromrecurse=false)
PathEffectSharedPtr getNextLPEReference(PathEffectSharedPtr const &lperef)
std::vector< Inkscape::LivePathEffect::Effect * > getPathEffects()
int tag() const override
Definition sp-lpe-item.h:55
void applyToMask(SPItem *to, Inkscape::LivePathEffect::Effect *lpe=nullptr)
void upCurrentPathEffect()
bool hasBrokenPathEffect() const
used for shapes so they can see if they should also disable shape calculation and read from d=
Inkscape::LivePathEffect::Effect * getFirstPathEffectOfType(int type)
bool hasPathEffect() const
void applyToClipPath(SPItem *to, Inkscape::LivePathEffect::Effect *lpe=nullptr)
SPLPEItem const * getTopPathEffect() const
returns top most LPE item with LPE
PathEffectSharedPtr current_path_effect
Definition sp-lpe-item.h:62
void movePathEffect(gint origin, gint dest, bool select_moved=false)
PathEffectSharedPtr getLastLPEReference()
std::list< sigc::scoped_connection > lpe_modified_connection_list
Definition sp-lpe-item.h:49
std::vector< SPObject * > get_satellites(bool force=true, bool recursive=false, bool onchilds=false)
void replacePathEffects(std::vector< LivePathEffectObject const * > const &old_lpeobjs, std::vector< LivePathEffectObject const * > const &new_lpeobjs)
Writes a new "inkscape:path-effect" string to xml, where the old_lpeobjects are substituted by the ne...
SPLPEItem * removeCurrentPathEffect(bool keep_paths)
If keep_path is true, the item should not be updated, effectively 'flattening' the LPE.
bool performOnePathEffect(Geom::PathVector &curve, SPShape *current, Inkscape::LivePathEffect::Effect *lpe, bool is_clip_or_mask=false)
returns true when LPE was successful.
void update_satellites(bool recursive=true)
bool hasPathEffectOnClipOrMaskRecursive(SPLPEItem *shape) const
returns true when any LPE apply to clip or mask.
std::size_t getLPEReferenceIndex(PathEffectSharedPtr const &lperef) const
std::size_t getLPEIndex(Inkscape::LivePathEffect::Effect *lpe) const
bool hasPathEffectOfTypeRecursive(int const type, bool is_ready=true) const
bool performPathEffect(Geom::PathVector &curve, SPShape *current, bool is_clip_or_mask=false)
returns true when LPE was successful.
bool lpe_initialized
std::size_t countLPEOfType(int const type, bool inc_hidden=true, bool is_ready=true) const
PathEffectList getEffectList()
void child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) override
bool hasPathEffectOfType(int const type, bool is_ready=true) const
SPLPEItem * removeAllPathEffects(bool keep_paths, bool recursive=false)
If keep_path is true, the item should not be updated, effectively 'flattening' the LPE.
SPLPEItem * flattenCurrentPathEffect()
void removePathEffect(Inkscape::LivePathEffect::Effect *lpe, bool keep_paths)
int path_effects_enabled
Definition sp-lpe-item.h:59
bool hasPathEffectRecursive() const
void addPathEffect(std::string value, bool reset)
void applyToClipPathOrMask(SPItem *clip_mask, SPItem *to, Inkscape::LivePathEffect::Effect *lpe=nullptr)
Inkscape::LivePathEffect::Effect * getLastLPE()
bool pathEffectsEnabled() const
virtual void update_patheffect(bool write)
PathEffectList * path_effect_list
Definition sp-lpe-item.h:61
void update(SPCtx *ctx, unsigned int flags) override
bool forkPathEffectsIfNecessary(unsigned int nr_of_allowed_users=1, bool recursive=true, bool force=false)
Check all effects in the stack if they are used by other items, and fork them if so.
void build(SPDocument *doc, Inkscape::XML::Node *repr) override
void modified(unsigned int flags) override
bool hasPathEffectOnClipOrMask(SPLPEItem *shape) const
returns true when any LPE apply to clip or mask.
PathEffectSharedPtr getCurrentLPEReference()
~SPLPEItem() override
Inkscape::XML::Node * write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override
PathEffectSharedPtr getPrevLPEReference(PathEffectSharedPtr const &lperef)
std::vector< Inkscape::Display::TemporaryItem * > lpe_helperpaths
Definition sp-lpe-item.h:63
Inkscape::LivePathEffect::Effect * getPrevLPE(Inkscape::LivePathEffect::Effect *lpe)
bool optimizeTransforms()
returns false when LPE write unoptimiced
bool isOnSymbol() const
void editNextParamOncanvas(SPDesktop *dt)
Inkscape::LivePathEffect::Effect * getNextLPE(Inkscape::LivePathEffect::Effect *lpe)
bool setCurrentPathEffect(PathEffectSharedPtr const &lperef)
Inkscape::XML::Node * repr
Definition sp-object.h:193
Base class for shapes, including <path> element.
Definition sp-shape.h:38
static char const *const current
Definition dir-util.cpp:71
Helper class to stream background task notifications as a series of messages.
static cairo_user_data_key_t key
Ocnode * child[8]
Definition quantize.cpp:33
Ocnode ** ref
Definition quantize.cpp:32
Some things pertinent to all visible shapes: SPItem, SPItemView, SPItemCtx.
std::list< PathEffectSharedPtr > PathEffectList
Definition sp-lpe-item.h:45
void sp_lpe_item_enable_path_effects(SPLPEItem *lpeitem, bool enable)
void sp_lpe_item_update_patheffect(SPLPEItem *lpeitem, bool wholetree, bool write, bool with_satellites=false)
Calls any registered handlers for the update_patheffect action.
std::shared_ptr< Inkscape::LivePathEffect::LPEObjectReference > PathEffectSharedPtr
Definition sp-lpe-item.h:44
Interface for XML documents.
Definition document.h:43
Unused.
Definition sp-object.h:94
Definition curve.h:24