75 gchar
const * srcGraphic =
nullptr, gchar
const * srcGraphicAlpha =
nullptr)
77 if (from ==
nullptr)
return;
81 gchar
const * attr = g_quark_to_string(iter.key);
83 if (!strcmp(attr,
"id"))
continue;
86 if (!strcmp(attr,
"in") || !strcmp(attr,
"in2") || !strcmp(attr,
"in3")) {
87 if (srcGraphic !=
nullptr && !strcmp(from->
attribute(attr),
"SourceGraphic")) {
91 if (srcGraphicAlpha !=
nullptr && !strcmp(from->
attribute(attr),
"SourceAlpha")) {
99 from_child != nullptr ; from_child = from_child->next()) {
100 Glib::ustring
name =
"svg:";
101 name += from_child->name();
105 merge_filters(to_child, from_child, doc, srcGraphic, srcGraphicAlpha);
107 if (from_child == from->
firstChild() && !strcmp(
"filter", from->
name()) && srcGraphic !=
nullptr && to_child->
attribute(
"in") ==
nullptr) {
124 document->resources_changed_signals[g_quark_from_string(
"filter")].emit();
126 Glib::ustring url =
"url(#"; url += newfilterroot->
attribute(
"id"); url +=
")";
134#define FILTER_SRC_GRAPHIC "fbSourceGraphic"
135#define FILTER_SRC_GRAPHIC_ALPHA "fbSourceGraphicAlpha"
141 if (filterdoc ==
nullptr) {
148 std::vector<SPItem*>
items(selection->
items().begin(), selection->
items().end());
153 for(
auto spitem :
items) {
159 if (filter ==
nullptr) {
162 if (strncmp(filter,
"url(#", strlen(
"url(#")) || filter[strlen(filter) - 1] !=
')') {
167 gchar * lfilter = g_strndup(filter + 5, strlen(filter) - 6);
171 if (child_id !=
nullptr && !strcmp(lfilter, child_id)) {
179 if (filternode ==
nullptr) {
180 g_warning(
"no assigned filter found!");
184 if (filternode->
lastChild() ==
nullptr) {
191 alpha->
setAttribute(
"result", FILTER_SRC_GRAPHIC_ALPHA);
193 alpha->
setAttribute(
"values",
"0 0 0 -1 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 1 0");
197 merge_filters(filternode, filterdoc->
root(), xmldoc, FILTER_SRC_GRAPHIC, FILTER_SRC_GRAPHIC_ALPHA);
213 gchar * xml_str = g_strdup_printf(
214 "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI
"\">\n"
216 "<id>org.inkscape.effect.filter.%s</id>\n"
218 "<object-type>all</object-type>\n"
220 "<submenu name=\"" N_(
"Filters")
"\" />\n"
221 "<submenu name=\"%s\"/>\n"
223 "<menu-tip>%s</menu-tip>\n"
225 "</inkscape-extension>\n",
name,
id, submenu, tip);
233 if (!
item)
return false;
236 if (!filterdoc)
return false;
TODO: insert short description here.
Effects are extensions that take a document and do something to it in place.
The object that is the basis for the Extension system.
A cache for the document and this implementation.
void effect(Inkscape::Extension::Effect *module, ExecutionEnv *executionEnv, SPDesktop *desktop, Inkscape::Extension::Implementation::ImplementationDocumentCache *docCache) override
static void filter_init(gchar const *id, gchar const *name, gchar const *submenu, gchar const *tip, gchar const *filter)
Inkscape::Extension::Implementation::ImplementationDocumentCache * newDocCache(Inkscape::Extension::Extension *ext, SPDesktop *desktop) override
Create a new document cache object.
bool apply_filter(Inkscape::Extension::Effect *module, SPItem *item) override
bool load(Inkscape::Extension::Extension *module) override
Inkscape::XML::Document * get_filter(Inkscape::Extension::Extension *ext)
virtual gchar const * get_filter_text(Inkscape::Extension::Extension *ext)
SPItemRange items()
Returns a range of selected SPItems.
The set of selected SPObjects for a given document and layer model.
Interface for refcounted XML nodes.
virtual void appendChild(Node *child)=0
Append a node as the last child of this node.
virtual char const * name() const =0
Get the name of the element node.
virtual const AttributeVector & attributeList() const =0
Get a list of the node's attributes.
void setAttribute(Util::const_char_ptr key, Util::const_char_ptr value)
Change an attribute of this node.
virtual Node * firstChild()=0
Get the first child of this node.
virtual char const * attribute(char const *key) const =0
Get the string representation of a node's attribute.
virtual Node * lastChild()=0
Get the last child of this node.
virtual Node * root()=0
Get the root node of this node's document.
To do: update description of desktop.
Inkscape::Selection * getSelection() const
SPDefs * getDefs()
Return the main defs object for the document.
Inkscape::XML::Document * getReprDoc()
Our Inkscape::XML::Document.
Base class for visual SVG elements.
Inkscape::XML::Node * getRepr()
Returns the XML representation of tree.
A way to clear the N_ macro, which is defined as an inline function.
std::shared_ptr< Css const > css
Editable view implementation.
Inkscape::Extension::Extension: Frontend to certain, possibly pluggable, actions.
Inkscape::XML::Node * node
void merge_filters(Inkscape::XML::Node *to, Inkscape::XML::Node *from, Inkscape::XML::Document *doc, gchar const *srcGraphic=nullptr, gchar const *srcGraphicAlpha=nullptr)
void create_and_apply_filter(SPItem *item, Inkscape::XML::Document *filterdoc)
void build_from_mem(gchar const *buffer, std::unique_ptr< Implementation::Implementation > in_imp)
Create a module from a buffer holding an XML description.
static R & release(R &r)
Decrements the reference count of a anchored object.
Helper class to stream background task notifications as a series of messages.
void sp_repr_css_set(Node *repr, SPCSSAttr *css, gchar const *attr)
Sets an attribute (e.g.
SPCSSAttr * sp_repr_css_attr(Node const *repr, gchar const *attr)
Creates a new SPCSSAttr with one attribute (i.e.
char const * sp_repr_css_property(SPCSSAttr *css, gchar const *name, gchar const *defval)
Returns a character string of the value of a given style property or a default value if the attribute...
void sp_repr_css_set_property(SPCSSAttr *css, gchar const *name, gchar const *value)
Set a style property to a new value (e.g.
Document * sp_repr_read_mem(const gchar *buffer, gint length, const gchar *default_ns)
Reads and parses XML from a buffer, returning it as an Document.
C facade to Inkscape::XML::Node.
GC-managed XML node implementation.
Interface for XML documents.
virtual Node * createElement(char const *name)=0