summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbulia byak <buliabyak@gmail.com>2006-10-07 19:45:27 +0000
committerbuliabyak <buliabyak@users.sourceforge.net>2006-10-07 19:45:27 +0000
commit9ee92fcf77cf5791f59e5daa094b6ae4bfbafeb8 (patch)
tree7489f67bb0a8aa98c2e002741ff0364554b5be1c
parentwhitespace (line ends) (diff)
downloadinkscape-9ee92fcf77cf5791f59e5daa094b6ae4bfbafeb8.tar.gz
inkscape-9ee92fcf77cf5791f59e5daa094b6ae4bfbafeb8.zip
new file for filter manipulation stuff
(bzr r1775)
-rw-r--r--src/Makefile_insert2
-rw-r--r--src/filter-chemistry.cpp91
-rw-r--r--src/filter-chemistry.h33
3 files changed, 126 insertions, 0 deletions
diff --git a/src/Makefile_insert b/src/Makefile_insert
index d0ef0248b..d6694a759 100644
--- a/src/Makefile_insert
+++ b/src/Makefile_insert
@@ -70,6 +70,7 @@ libinkpre_a_SOURCES = \
event-log.cpp event-log.h \
extract-uri.cpp extract-uri.h \
file.cpp file.h \
+ filter-chemistry.cpp filter-chemistry.h \
fontsize-expansion.cpp fontsize-expansion.h \
forward.h \
geom.cpp geom.h \
@@ -270,6 +271,7 @@ libinkpost_a_SOURCES = \
decimal-round.h \
dir-util.cpp dir-util.h \
fill-or-stroke.h \
+ filter-chemistry.cpp filter-chemistry.h \
fixes.cpp \
gc-alloc.h \
gc-anchored.h gc-anchored.cpp \
diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp
new file mode 100644
index 000000000..0b374160c
--- /dev/null
+++ b/src/filter-chemistry.cpp
@@ -0,0 +1,91 @@
+#define __SP_FILTER_CHEMISTRY_C__
+
+/*
+ * Various utility methods for filters
+ *
+ * Authors:
+ * Hugo Rodrigues
+ * bulia byak
+ *
+ * Copyright (C) 2006 authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+
+#include "style.h"
+#include "document-private.h"
+#include "desktop-style.h"
+
+#include "sp-filter.h"
+#include "sp-gaussian-blur.h"
+#include "svg/css-ostringstream.h"
+
+#include "xml/repr.h"
+
+/**
+ * Creates a filter with blur primitive of specified stdDeviation
+ */
+SPFilter *
+new_filter_gaussian_blur (SPDocument *document, gdouble stdDeviation)
+{
+ g_return_val_if_fail(document != NULL, NULL);
+
+ SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document);
+
+ // create a new private filter
+ Inkscape::XML::Node *repr;
+ repr = sp_repr_new("svg:filter");
+ repr->setAttribute("inkscape:collect", "always");
+
+ //create feGaussianBlur node
+ Inkscape::XML::Node *b_repr;
+ b_repr = sp_repr_new("svg:feGaussianBlur");
+ b_repr->setAttribute("inkscape:collect", "always");
+
+ //set stdDeviation attribute
+ Inkscape::CSSOStringStream os;
+ os << stdDeviation;
+ b_repr->setAttribute("stdDeviation", os.str().c_str());
+
+ //set feGaussianBlur as child of filter node
+ repr->appendChild(b_repr);
+ Inkscape::GC::release(b_repr);
+
+ // Append the new filter node to defs
+ SP_OBJECT_REPR(defs)->appendChild(repr);
+ Inkscape::GC::release(repr);
+
+ // get corresponding object
+ SPFilter *f = SP_FILTER( document->getObjectByRepr(repr) );
+ SPGaussianBlur *b = SP_GAUSSIANBLUR( document->getObjectByRepr(b_repr) );
+
+ g_assert(f != NULL);
+ g_assert(SP_IS_FILTER(f));
+ g_assert(b != NULL);
+ g_assert(SP_IS_GAUSSIANBLUR(b));
+
+ return f;
+}
+
+void remove_filter (SPObject *item, bool recursive)
+{
+ SPCSSAttr *css = sp_repr_css_attr_new ();
+ sp_repr_css_unset_property (css, "filter");
+ if (recursive)
+ sp_repr_css_change_recursive(SP_OBJECT_REPR(item), css, "style");
+ else
+ sp_repr_css_change (SP_OBJECT_REPR(item), css, "style");
+ sp_repr_css_attr_unref (css);
+}
+
+/*
+ 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:encoding=utf-8:textwidth=99 :
diff --git a/src/filter-chemistry.h b/src/filter-chemistry.h
new file mode 100644
index 000000000..31776323e
--- /dev/null
+++ b/src/filter-chemistry.h
@@ -0,0 +1,33 @@
+#ifndef __SP_FILTER_CHEMISTRY_H__
+#define __SP_FILTER_CHEMISTRY_H__
+
+/*
+ * Various utility methods for filters
+ *
+ * Authors:
+ * Hugo Rodrigues
+ * bulia byak
+ *
+ * Copyright (C) 2006 authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "forward.h"
+#include "sp-filter.h"
+
+SPFilter *new_filter_gaussian_blur (SPDocument *document, gdouble stdDeviation);
+void remove_filter (SPObject *item, bool recursive);
+
+#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:encoding=utf-8:textwidth=99 :