From 761a541468cc0b8a7fcfb8c65784c0896f0f80f4 Mon Sep 17 00:00:00 2001 From: haa_rodrigues Date: Wed, 2 Aug 2006 21:31:59 +0000 Subject: [PATCH] Added skeleton files for other filter primitives' SP-objects. Added blur slider on fill/stroke dialog (uncomment on object-properties.cpp). --- src/Makefile_insert | 36 +++++- src/attributes-test.h | 10 ++ src/attributes.cpp | 68 ++++++++++- src/attributes.h | 68 ++++++++++- src/desktop-style.cpp | 16 ++- src/desktop-style.h | 5 +- src/dialogs/object-properties.cpp | 143 ++++++++++++++++++++++ src/sp-feblend-fns.h | 38 ++++++ src/sp-feblend.cpp | 196 ++++++++++++++++++++++++++++++ src/sp-feblend.h | 45 +++++++ src/sp-fecolormatrix-fns.h | 38 ++++++ src/sp-fecolormatrix.cpp | 196 ++++++++++++++++++++++++++++++ src/sp-fecolormatrix.h | 45 +++++++ src/sp-fecomponenttransfer.cpp | 196 ++++++++++++++++++++++++++++++ src/sp-fecomponenttransfer.h | 45 +++++++ src/sp-fecomposite-fns.h | 38 ++++++ src/sp-fecomposite.cpp | 196 ++++++++++++++++++++++++++++++ src/sp-fecomposite.h | 45 +++++++ src/sp-feconvolvematrix-fns.h | 38 ++++++ src/sp-feconvolvematrix.cpp | 196 ++++++++++++++++++++++++++++++ src/sp-feconvolvematrix.h | 45 +++++++ src/sp-fediffuselighting-fns.h | 38 ++++++ src/sp-fediffuselighting.cpp | 196 ++++++++++++++++++++++++++++++ src/sp-fediffuselighting.h | 83 +++++++++++++ src/sp-fedisplacementmap-fns.h | 38 ++++++ src/sp-fedisplacementmap.cpp | 196 ++++++++++++++++++++++++++++++ src/sp-fedisplacementmap.h | 45 +++++++ src/sp-feflood-fns.h | 38 ++++++ src/sp-feflood.cpp | 196 ++++++++++++++++++++++++++++++ src/sp-feflood.h | 45 +++++++ src/sp-feimage-fns.h | 38 ++++++ src/sp-feimage.cpp | 196 ++++++++++++++++++++++++++++++ src/sp-feimage.h | 45 +++++++ src/sp-femerge-fns.h | 38 ++++++ src/sp-femerge.cpp | 196 ++++++++++++++++++++++++++++++ src/sp-femerge.h | 45 +++++++ src/sp-femorphology-fns.h | 38 ++++++ src/sp-femorphology.cpp | 196 ++++++++++++++++++++++++++++++ src/sp-femorphology.h | 45 +++++++ src/sp-feoffset-fns.h | 38 ++++++ src/sp-feoffset.cpp | 196 ++++++++++++++++++++++++++++++ src/sp-feoffset.h | 45 +++++++ src/sp-fespecularlighting-fns.h | 38 ++++++ src/sp-fespecularlighting.cpp | 196 ++++++++++++++++++++++++++++++ src/sp-fespecularlighting.h | 45 +++++++ src/sp-fetile-fns.h | 38 ++++++ src/sp-fetile.cpp | 196 ++++++++++++++++++++++++++++++ src/sp-fetile.h | 45 +++++++ src/sp-feturbulence-fns.h | 38 ++++++ src/sp-feturbulence.cpp | 196 ++++++++++++++++++++++++++++++ src/sp-feturbulence.h | 45 +++++++ src/sp-object-repr.cpp | 32 ++++- src/style.cpp | 49 ++++++-- src/style.h | 1 + 54 files changed, 4591 insertions(+), 22 deletions(-) create mode 100644 src/sp-feblend-fns.h create mode 100644 src/sp-feblend.cpp create mode 100644 src/sp-feblend.h create mode 100644 src/sp-fecolormatrix-fns.h create mode 100644 src/sp-fecolormatrix.cpp create mode 100644 src/sp-fecolormatrix.h create mode 100644 src/sp-fecomponenttransfer.cpp create mode 100644 src/sp-fecomponenttransfer.h create mode 100644 src/sp-fecomposite-fns.h create mode 100644 src/sp-fecomposite.cpp create mode 100644 src/sp-fecomposite.h create mode 100644 src/sp-feconvolvematrix-fns.h create mode 100644 src/sp-feconvolvematrix.cpp create mode 100644 src/sp-feconvolvematrix.h create mode 100644 src/sp-fediffuselighting-fns.h create mode 100644 src/sp-fediffuselighting.cpp create mode 100644 src/sp-fediffuselighting.h create mode 100644 src/sp-fedisplacementmap-fns.h create mode 100644 src/sp-fedisplacementmap.cpp create mode 100644 src/sp-fedisplacementmap.h create mode 100644 src/sp-feflood-fns.h create mode 100644 src/sp-feflood.cpp create mode 100644 src/sp-feflood.h create mode 100644 src/sp-feimage-fns.h create mode 100644 src/sp-feimage.cpp create mode 100644 src/sp-feimage.h create mode 100644 src/sp-femerge-fns.h create mode 100644 src/sp-femerge.cpp create mode 100644 src/sp-femerge.h create mode 100644 src/sp-femorphology-fns.h create mode 100644 src/sp-femorphology.cpp create mode 100644 src/sp-femorphology.h create mode 100644 src/sp-feoffset-fns.h create mode 100644 src/sp-feoffset.cpp create mode 100644 src/sp-feoffset.h create mode 100644 src/sp-fespecularlighting-fns.h create mode 100644 src/sp-fespecularlighting.cpp create mode 100644 src/sp-fespecularlighting.h create mode 100644 src/sp-fetile-fns.h create mode 100644 src/sp-fetile.cpp create mode 100644 src/sp-fetile.h create mode 100644 src/sp-feturbulence-fns.h create mode 100644 src/sp-feturbulence.cpp create mode 100644 src/sp-feturbulence.h diff --git a/src/Makefile_insert b/src/Makefile_insert index dd65108ce..0b236eeca 100644 --- a/src/Makefile_insert +++ b/src/Makefile_insert @@ -143,10 +143,40 @@ libinkpre_a_SOURCES = \ sp-cursor.cpp sp-cursor.h \ sp-defs.cpp sp-defs.h \ sp-ellipse.cpp sp-ellipse.h \ + sp-feblend.cpp sp-feblend.h \ + sp-feblend-fns.h \ + sp-fecolormatrix.cpp sp-fecolormatrix.h \ + sp-fecolormatrix-fns.h \ + sp-fecomponenttransfer.cpp sp-fecomponenttransfer.h \ + sp-fecomponenttransfer-fns.h \ + sp-fecomposite.cpp sp-fecomposite.h \ + sp-fecomposite-fns.h \ + sp-feconvolvematrix.cpp sp-feconvolvematrix.h \ + sp-feconvolvematrix-fns.h \ + sp-fediffuselighting.cpp sp-fediffuselighting.h \ + sp-fediffuselighting-fns.h \ + sp-fedisplacementmap.cpp sp-fedisplacementmap.h \ + sp-fedisplacementmap-fns.h \ + sp-feflood.cpp sp-feflood.h \ + sp-feflood-fns.h \ + sp-feimage.cpp sp-feimage.h \ + sp-feimage-fns.h \ + sp-femerge.cpp sp-femerge.h \ + sp-femerge-fns.h \ + sp-femorphology.cpp sp-femorphology.h \ + sp-femorphology-fns.h \ + sp-feoffset.cpp sp-feoffset.h \ + sp-feoffset-fns.h \ + sp-fespecularlighting.cpp sp-fespecularlighting.h \ + sp-fespecularlighting-fns.h \ + sp-fetile.cpp sp-fetile.h \ + sp-fetile-fns.h \ + sp-feturbulence.cpp sp-feturbulence.h \ + sp-feturbulence-fns.h \ sp-filter-fns.h \ - sp-filter-reference.cpp \ - sp-filter-reference.h \ - sp-filter-units.h \ + sp-filter-reference.cpp \ + sp-filter-reference.h \ + sp-filter-units.h \ sp-filter.cpp sp-filter.h \ sp-flowdiv.h sp-flowdiv.cpp \ sp-flowregion.h sp-flowregion.cpp \ diff --git a/src/attributes-test.h b/src/attributes-test.h index c71b8f04c..f0db48ad0 100644 --- a/src/attributes-test.h +++ b/src/attributes-test.h @@ -96,10 +96,20 @@ struct {char const *attr; bool supported;} const all_attrs[] = { {"end", true}, {"exponent", false}, {"externalResourcesRequired", false}, + {"feBlend", false}, {"feColorMatrix", false}, + {"feComponentTransfer", false}, {"feComposite", false}, + {"feConvolveMatrix", false}, + {"feDiffuseLighting", false}, + {"feDisplacementMap", false}, + {"feFlood", false}, {"feGaussianBlur", false}, + {"feImage", false}, + {"feMerge", false}, {"feMorphology", false}, + {"feOffset", false}, + {"feSpecularLighting", false}, {"feTile", false}, {"fill", true}, {"fill-opacity", true}, diff --git a/src/attributes.cpp b/src/attributes.cpp index f0ecc1e41..867e5989c 100644 --- a/src/attributes.cpp +++ b/src/attributes.cpp @@ -175,8 +175,70 @@ static SPStyleProp const props[] = { {SP_ATTR_FILTERUNITS, "filterUnits"}, {SP_ATTR_PRIMITIVEUNITS, "primitiveUnits"}, {SP_ATTR_FILTERRES, "filterRes"}, - /* SPGaussianBlur */ + /*feBlend*/ + {SP_ATTR_MODE, "mode"}, + {SP_ATTR_IN2, "in2"}, + /*feColorMatrix*/ + {SP_ATTR_TYPE, "type"}, + {SP_ATTR_VALUES, "values"}, + /*feComponentTransfer*/ + //{SP_ATTR_TYPE, "type"}, + {SP_ATTR_TABLEVALUES, "tableValues"}, + {SP_ATTR_SLOPE, "slope"}, + {SP_ATTR_INTERCEPT, "intercept"}, + {SP_ATTR_AMPLITUDE, "amplitude"}, + {SP_ATTR_EXPONENT, "exponent"}, + //{SP_ATTR_OFFSET, "offset"}, + /*feComposite*/ + {SP_ATTR_OPERATOR, "operator"}, + {SP_ATTR_K1, "k1"}, + {SP_ATTR_K2, "k2"}, + {SP_ATTR_K3, "k3"}, + {SP_ATTR_K4, "k4"}, + //{SP_ATTR_IN2, "in2"}, + /*feConvolveMatrix*/ + {SP_ATTR_ORDER, "order"}, + {SP_ATTR_KERNELMATRIX, "kernelMatrix"}, + {SP_ATTR_DIVISOR, "divisor"}, + {SP_ATTR_BIAS, "bias"}, + {SP_ATTR_TARGETX, "targetX"}, + {SP_ATTR_TARGETY, "targetY"}, + {SP_ATTR_EDGEMODE, "edgeMode"}, + {SP_ATTR_KERNELUNITLENGTH, "kernelUnitLength"}, + {SP_ATTR_PRESERVEALPHA, "preserveAlpha"}, + /*feDiffuseLighting*/ + {SP_ATTR_SURFACESCALE, "surfaceScale"}, + {SP_ATTR_DIFFUSECONSTANT, "diffuseConstant"}, + //{SP_ATTR_KERNELUNITLENGTH, "kernelUnitLength"}, + /*feDisplacementMap*/ + {SP_ATTR_SCALE, "scale"}, + {SP_ATTR_XCHANNELSELECTOR, "xChannelSelector"}, + {SP_ATTR_YCHANNELSELECTOR, "yChannelSelector"}, + //{SP_ATTR_IN2, "in2"}, + /*feFlood*/ + {SP_ATTR_FLOODCOLOR, "flood-color"}, + {SP_ATTR_FLOODOPACITY, "flood-opacity"}, + /* SPGaussianBlur */ {SP_ATTR_STDDEVIATION, "stdDeviation"}, + /*feImage*/ + /*feMerge*/ + /*feMorphology*/ + //{SP_ATTR_OPERATOR, "operator"}, + {SP_ATTR_RADIUS, "radius"}, + /*feOffset*/ + //{SP_ATTR_DX, "dx"}, + //{SP_ATTR_DY, "dy"}, + /*feSpecularLighting*/ + //{SP_ATTR_SURFACESCALE, "surfaceScale"}, + {SP_ATTR_SPECULARCONSTANT, "specularConstant"}, + {SP_ATTR_SPECULAREXPONENT, "specularExponent"}, + /*feTile*/ + /*feTurbulence*/ + {SP_ATTR_BASEFREQUENCY, "baseFrequency"}, + {SP_ATTR_NUMOCTAVES, "numOctaves"}, + {SP_ATTR_SEED, "seed"}, + {SP_ATTR_STITCHTILES, "stitchTiles"}, + //{SP_ATTR_TYPE, "type"}, /* SPGradient */ {SP_ATTR_GRADIENTUNITS, "gradientUnits"}, {SP_ATTR_GRADIENTTRANSFORM, "gradientTransform"}, @@ -201,7 +263,7 @@ static SPStyleProp const props[] = { {SP_ATTR_MARKERHEIGHT, "markerHeight"}, {SP_ATTR_ORIENT, "orient"}, /* SPStyleElem */ - {SP_ATTR_TYPE, "type"}, + //{SP_ATTR_TYPE, "type"}, /* Animations */ {SP_ATTR_ATTRIBUTENAME, "attributeName"}, {SP_ATTR_ATTRIBUTETYPE, "attributeType"}, @@ -215,7 +277,7 @@ static SPStyleProp const props[] = { {SP_ATTR_REPEATDUR, "repeatDur"}, /* Interpolating animations */ {SP_ATTR_CALCMODE, "calcMode"}, - {SP_ATTR_VALUES, "values"}, + //{SP_ATTR_VALUES, "values"}, {SP_ATTR_KEYTIMES, "keyTimes"}, {SP_ATTR_KEYSPLINES, "keySplines"}, {SP_ATTR_FROM, "from"}, diff --git a/src/attributes.h b/src/attributes.h index d80e87006..5ef817e49 100644 --- a/src/attributes.h +++ b/src/attributes.h @@ -175,8 +175,70 @@ enum SPAttributeEnum { SP_ATTR_FILTERUNITS, SP_ATTR_PRIMITIVEUNITS, SP_ATTR_FILTERRES, - /* SPGaussianBlur */ + /*feBlend*/ + SP_ATTR_MODE, + SP_ATTR_IN2, + /*feColorMatrix*/ + SP_ATTR_TYPE, + SP_ATTR_VALUES, + /*feComponentTransfer*/ + //SP_ATTR_TYPE, + SP_ATTR_TABLEVALUES, + SP_ATTR_SLOPE, + SP_ATTR_INTERCEPT, + SP_ATTR_AMPLITUDE, + SP_ATTR_EXPONENT, + //SP_ATTR_OFFSET, + /*feComposite*/ + SP_ATTR_OPERATOR, + SP_ATTR_K1, + SP_ATTR_K2, + SP_ATTR_K3, + SP_ATTR_K4, + //SP_ATTR_IN2, + /*feConvolveMatrix*/ + SP_ATTR_ORDER, + SP_ATTR_KERNELMATRIX, + SP_ATTR_DIVISOR, + SP_ATTR_BIAS, + SP_ATTR_TARGETX, + SP_ATTR_TARGETY, + SP_ATTR_EDGEMODE, + SP_ATTR_KERNELUNITLENGTH, + SP_ATTR_PRESERVEALPHA, + /*feDiffuseLighting*/ + SP_ATTR_SURFACESCALE, + SP_ATTR_DIFFUSECONSTANT, + //SP_ATTR_KERNELUNITLENGTH, + /*feDisplacementMap*/ + SP_ATTR_SCALE, + SP_ATTR_XCHANNELSELECTOR, + SP_ATTR_YCHANNELSELECTOR, + //SP_ATTR_IN2, + /*feFlood*/ + SP_ATTR_FLOODCOLOR, + SP_ATTR_FLOODOPACITY, + /* SPGaussianBlur */ SP_ATTR_STDDEVIATION, + /*feImage*/ + /*feMerge*/ + /*feMorphology*/ + //SP_ATTR_OPERATOR, + SP_ATTR_RADIUS, + /*feOffset*/ + //SP_ATTR_DX, + //SP_ATTR_DY, + /*feSpecularLighting*/ + //SP_ATTR_SURFACESCALE, + SP_ATTR_SPECULARCONSTANT, + SP_ATTR_SPECULAREXPONENT, + /*feTile*/ + /*feTurbulence*/ + SP_ATTR_BASEFREQUENCY, + SP_ATTR_NUMOCTAVES, + SP_ATTR_SEED, + SP_ATTR_STITCHTILES, + //SP_ATTR_TYPE, /* SPGradient */ SP_ATTR_GRADIENTUNITS, SP_ATTR_GRADIENTTRANSFORM, @@ -201,7 +263,7 @@ enum SPAttributeEnum { SP_ATTR_MARKERHEIGHT, SP_ATTR_ORIENT, /* SPStyleElem */ - SP_ATTR_TYPE, + //SP_ATTR_TYPE, /* Animations */ SP_ATTR_ATTRIBUTENAME, SP_ATTR_ATTRIBUTETYPE, @@ -215,7 +277,7 @@ enum SPAttributeEnum { SP_ATTR_REPEATDUR, /* Interpolating animations */ SP_ATTR_CALCMODE, - SP_ATTR_VALUES, + //SP_ATTR_VALUES, SP_ATTR_KEYTIMES, SP_ATTR_KEYSPLINES, SP_ATTR_FROM, diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index c9989df27..ff96f7e8e 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -1009,6 +1009,18 @@ objects_query_fontfamily (GSList *objects, SPStyle *style_res) } } +/** + * Write to style_res the average opacity of a list of objects. + */ +int +objects_query_blur (GSList *objects, SPStyle *style_res) +{ + /*************temporary**********/ + //style_res->opacity.value = SP_SCALE24_FROM_FLOAT(0.5); + return QUERY_STYLE_MULTIPLE_SAME; + /*************temporary**********/ +} + /** * Query the given list of objects for the given property, write * the result to style, return appropriate flag. @@ -1039,8 +1051,10 @@ sp_desktop_query_style_from_list (GSList *list, SPStyle *style, int property) return objects_query_fontstyle (list, style); } else if (property == QUERY_STYLE_PROPERTY_FONTNUMBERS) { return objects_query_fontnumbers (list, style); - } + } else if (property == QUERY_STYLE_PROPERTY_BLUR) { + return objects_query_blur (list, style); + } return QUERY_STYLE_NOTHING; } diff --git a/src/desktop-style.h b/src/desktop-style.h index 8f8388289..a1fd8a4ff 100644 --- a/src/desktop-style.h +++ b/src/desktop-style.h @@ -46,7 +46,8 @@ enum { // which property was queried (add when you need more) QUERY_STYLE_PROPERTY_FONTFAMILY, // font-family QUERY_STYLE_PROPERTY_FONTSTYLE, // font style QUERY_STYLE_PROPERTY_FONTNUMBERS, // size, spacings - QUERY_STYLE_PROPERTY_MASTEROPACITY // opacity + QUERY_STYLE_PROPERTY_MASTEROPACITY, // opacity + QUERY_STYLE_PROPERTY_BLUR // opacity }; void sp_desktop_apply_css_recursive(SPObject *o, SPCSSAttr *css, bool skip_lines); @@ -72,6 +73,8 @@ int objects_query_miterlimit (GSList *objects, SPStyle *style_res); int objects_query_strokecap (GSList *objects, SPStyle *style_res); int objects_query_strokejoin (GSList *objects, SPStyle *style_res); +int objects_query_blur (GSList *objects, SPStyle *style_res); + int sp_desktop_query_style_from_list (GSList *list, SPStyle *style, int property); int sp_desktop_query_style(SPDesktop *desktop, SPStyle *style, int property); bool sp_desktop_query_style_all (SPDesktop *desktop, SPStyle *query); diff --git a/src/dialogs/object-properties.cpp b/src/dialogs/object-properties.cpp index f96949f5b..df750c71b 100644 --- a/src/dialogs/object-properties.cpp +++ b/src/dialogs/object-properties.cpp @@ -38,6 +38,8 @@ #include "desktop-handles.h" #include "desktop-style.h" #include "document.h" +#include "document-private.h" +#include #include "xml/repr.h" static GtkWidget *dlg = NULL; @@ -50,6 +52,7 @@ static gchar *prefs_path = "dialogs.fillstroke"; static void sp_fillstroke_selection_modified ( Inkscape::Application *inkscape, Inkscape::Selection *selection, guint flags, GtkObject *base ); static void sp_fillstroke_selection_changed ( Inkscape::Application *inkscape, Inkscape::Selection *selection, GtkObject *base ); static void sp_fillstroke_opacity_changed (GtkAdjustment *a, SPWidget *dlg); +static void sp_fillstroke_blur_changed (GtkAdjustment *a, SPWidget *dlg); static void sp_object_properties_dialog_destroy (GtkObject *object, gpointer data) @@ -213,6 +216,39 @@ sp_object_properties_dialog (void) g_signal_connect ( G_OBJECT (INKSCAPE), "modify_selection", G_CALLBACK (sp_fillstroke_selection_modified), dlg ); g_signal_connect ( G_OBJECT (INKSCAPE), "activate_desktop", G_CALLBACK (sp_fillstroke_selection_changed), dlg ); + + /* Blur */ +/* uncomment to display blur slider*/ +/* GtkWidget *b_vb = gtk_vbox_new (FALSE, 0); + gtk_box_pack_start (GTK_BOX (vb), b_vb, FALSE, FALSE, 2); + gtk_object_set_data (GTK_OBJECT (dlg), "blur", b_vb); + + GtkWidget *blur_l_hb = gtk_hbox_new (FALSE, 4); + GtkWidget *blur_l = gtk_label_new_with_mnemonic (_("_Blur")); + gtk_misc_set_alignment (GTK_MISC (blur_l), 0.0, 1.0); + gtk_box_pack_start (GTK_BOX (blur_l_hb), blur_l, FALSE, FALSE, 4); + gtk_box_pack_start (GTK_BOX (b_vb), blur_l_hb, FALSE, FALSE, 0); + + GtkWidget *blur_hb = gtk_hbox_new (FALSE, 4); + gtk_box_pack_start (GTK_BOX (b_vb), blur_hb, FALSE, FALSE, 0); + + GtkObject *blur_a = gtk_adjustment_new (0.0, 0.0, 1.0, 0.01, 0.1, 0.0); + gtk_object_set_data(GTK_OBJECT(dlg), "blur_adjustment", blur_a); + + GtkWidget *blur_s = gtk_hscale_new (GTK_ADJUSTMENT (blur_a)); + gtk_scale_set_draw_value (GTK_SCALE (blur_s), FALSE); + gtk_box_pack_start (GTK_BOX (blur_hb), blur_s, TRUE, TRUE, 4); + gtk_label_set_mnemonic_widget (GTK_LABEL(blur_l), blur_s); + + GtkWidget *blur_sb = gtk_spin_button_new (GTK_ADJUSTMENT (blur_a), 0.01, 3); + gtk_box_pack_start (GTK_BOX (blur_hb), blur_sb, FALSE, FALSE, 0); + + gtk_signal_connect ( blur_a, "value_changed", + GTK_SIGNAL_FUNC (sp_fillstroke_blur_changed), + dlg ); + + gtk_widget_show_all (b_vb); +*/ sp_fillstroke_selection_changed(NULL, NULL, NULL); gtk_widget_show (dlg); @@ -314,6 +350,113 @@ sp_fillstroke_opacity_changed (GtkAdjustment *a, SPWidget *dlg) } + +/** + * Creates new private filter for the given vector + */ + +static SPFilter * +sp_filter_get(SPDocument *document, gdouble stdDeviation) +{ + g_return_val_if_fail(document != NULL, NULL); + + SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document); + + // create a new private filter of the requested type + Inkscape::XML::Node *repr; + repr = sp_repr_new("svg:filter"); + // privates are garbage-collectable + repr->setAttribute("inkscape:collect", "always"); + + Inkscape::XML::Node *b_repr; + b_repr = sp_repr_new("svg:feGaussianBlur"); + // privates are garbage-collectable + b_repr->setAttribute("inkscape:collect", "always"); + + + Inkscape::CSSOStringStream os; + os << CLAMP (stdDeviation, 0.0, 1.0); + b_repr->setAttribute("stdDeviation", os.str().c_str()); + + repr->appendChild(b_repr); + Inkscape::GC::release(b_repr); + + /* Append the new private filter to defs */ + SP_OBJECT_REPR(defs)->appendChild(repr); + Inkscape::GC::release(repr); + + // get corresponding object + SPFilter *f = (SPFilter *) document->getObjectByRepr(repr); + g_assert(f != NULL); + g_assert(SP_IS_FILTER(f)); + + return f; +} + +/* + * TODO: check if selection has a filter applied and change its parameters instead of creating a new one + */ +static void +sp_fillstroke_blur_changed (GtkAdjustment *a, SPWidget *dlg) +{ + //if dialog is locked, return + if (gtk_object_get_data (GTK_OBJECT (dlg), "blocked")) + return; + + //lock dialog + gtk_object_set_data (GTK_OBJECT (dlg), "blocked", GUINT_TO_POINTER (TRUE)); + + //get desktop + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + if (!desktop) { + return; + } + + if(a->value==0.0) //blur set to zero, remove filter + { + //if there is a filter attached, remove it + SPCSSAttr *css = sp_repr_css_attr_new (); + sp_repr_css_unset_property (css, "filter"); + sp_desktop_set_style (desktop, css); + sp_repr_css_attr_unref (css); + + } else { //blur non-zero + + //get current selection + Inkscape::Selection *selection = sp_desktop_selection (desktop); + //get list of selected items + GSList const *items = selection->itemList(); + //get current document + SPDocument *document = sp_desktop_document (desktop); + + + //create new filter with feGaussianBlur primitive + SPFilter *constructed = sp_filter_get(document, a->value); + + //apply created filter to every selected item + for (GSList const *i = items; i != NULL; i = i->next) { + + gchar *val = g_strdup_printf("url(#%s)", SP_OBJECT_ID(constructed)); + + SPCSSAttr *css = sp_repr_css_attr_new(); + sp_repr_css_set_property(css, "filter", val); + g_free(val); + sp_repr_css_change_recursive(SP_OBJECT_REPR(SP_ITEM(i->data)), css, "style"); + + sp_desktop_set_style (SP_ACTIVE_DESKTOP, css); + sp_repr_css_attr_unref(css); + + SP_OBJECT(SP_ITEM(i->data))->requestDisplayUpdate(( SP_OBJECT_MODIFIED_FLAG | + SP_OBJECT_STYLE_MODIFIED_FLAG )); + } + } + + sp_document_maybe_done (sp_desktop_document (SP_ACTIVE_DESKTOP), "fillstroke:blur", SP_VERB_NONE, "object-properties.cpp:467"); + + gtk_object_set_data (GTK_OBJECT (dlg), "blocked", GUINT_TO_POINTER (FALSE)); +} + + /* Local Variables: mode:c++ diff --git a/src/sp-feblend-fns.h b/src/sp-feblend-fns.h new file mode 100644 index 000000000..f08ed9dd1 --- /dev/null +++ b/src/sp-feblend-fns.h @@ -0,0 +1,38 @@ +#ifndef SP_FEBLEND_FNS_H +#define SP_FEBLEND_FNS_H + +/** \file + * Macros and fn declarations related to gaussian blur filter. + */ + +#include +#include + +namespace Inkscape { +namespace XML { +class Node; +} +} + +class SPFeBlend; + +#define SP_TYPE_FEBLEND (sp_feBlend_get_type()) +#define SP_FEBLEND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FEBLEND, SPFeBlend)) +#define SP_FEBLEND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FEBLEND, SPFeBlendClass)) +#define SP_IS_FEBLEND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEBLEND)) +#define SP_IS_FEBLEND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEBLEND)) + +GType sp_feBlend_get_type(); + +#endif /* !SP_FEBLEND_FNS_H */ + +/* + 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/sp-feblend.cpp b/src/sp-feblend.cpp new file mode 100644 index 000000000..41f1ceaf1 --- /dev/null +++ b/src/sp-feblend.cpp @@ -0,0 +1,196 @@ +#define __SP_FEBLEND_CPP__ + +/** \file + * SVG implementation. + * + */ +/* + * Authors: + * hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "attributes.h" +#include "svg/svg.h" +#include "sp-feblend.h" +#include "xml/repr.h" + +//#define SP_MACROS_SILENT +//#include "macros.h" + +#define DEBUG_FEBLEND +#ifdef DEBUG_FEBLEND +# define debug(f, a...) { g_print("%s(%d) %s:", \ + __FILE__,__LINE__,__FUNCTION__); \ + g_print(f, ## a); \ + g_print("\n"); \ + } +#else +# define debug(f, a...) /**/ +#endif + +/* FeBlend base class */ + +static void sp_feBlend_class_init(SPFeBlendClass *klass); +static void sp_feBlend_init(SPFeBlend *feBlend); + +static void sp_feBlend_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); +static void sp_feBlend_release(SPObject *object); +static void sp_feBlend_set(SPObject *object, unsigned int key, gchar const *value); +static void sp_feBlend_update(SPObject *object, SPCtx *ctx, guint flags); +static Inkscape::XML::Node *sp_feBlend_write(SPObject *object, Inkscape::XML::Node *repr, guint flags); + +static SPObjectClass *feBlend_parent_class; + +GType +sp_feBlend_get_type() +{ + static GType feBlend_type = 0; + + if (!feBlend_type) { + GTypeInfo feBlend_info = { + sizeof(SPFeBlendClass), + NULL, NULL, + (GClassInitFunc) sp_feBlend_class_init, + NULL, NULL, + sizeof(SPFeBlend), + 16, + (GInstanceInitFunc) sp_feBlend_init, + NULL, /* value_table */ + }; + feBlend_type = g_type_register_static(SP_TYPE_OBJECT, "SPFeBlend", &feBlend_info, (GTypeFlags)0); + } + return feBlend_type; +} + +static void +sp_feBlend_class_init(SPFeBlendClass *klass) +{ + SPObjectClass *sp_object_class = (SPObjectClass *)klass; + + feBlend_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass); + + sp_object_class->build = sp_feBlend_build; + sp_object_class->release = sp_feBlend_release; + sp_object_class->write = sp_feBlend_write; + sp_object_class->set = sp_feBlend_set; + sp_object_class->update = sp_feBlend_update; +} + +static void +sp_feBlend_init(SPFeBlend *feBlend) +{ + debug("0x%p",feBlend); +} + +/** + * Reads the Inkscape::XML::Node, and initializes SPFeBlend variables. For this to get called, + * our name must be associated with a repr via "sp_object_type_register". Best done through + * sp-object-repr.cpp's repr_name_entries array. + */ +static void +sp_feBlend_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +{ + debug("0x%p",object); + if (((SPObjectClass *) feBlend_parent_class)->build) { + ((SPObjectClass *) feBlend_parent_class)->build(object, document, repr); + } + + /*LOAD ATTRIBUTES FROM REPR HERE*/ +} + +/** + * Drops any allocated memory. + */ +static void +sp_feBlend_release(SPObject *object) +{ + debug("0x%p",object); + + if (((SPObjectClass *) feBlend_parent_class)->release) + ((SPObjectClass *) feBlend_parent_class)->release(object); +} + +/** + * Sets a specific value in the SPFeBlend. + */ +static void +sp_feBlend_set(SPObject *object, unsigned int key, gchar const *value) +{ + debug("0x%p %s(%u): '%s'",object, + sp_attribute_name(key),key,value); + SPFeBlend *feBlend = SP_FEBLEND(object); + + switch(key) { + /*DEAL WITH SETTING ATTRIBUTES HERE*/ + default: + if (((SPObjectClass *) feBlend_parent_class)->set) + ((SPObjectClass *) feBlend_parent_class)->set(object, key, value); + break; + } + +} + +/** + * Receives update notifications. + */ +static void +sp_feBlend_update(SPObject *object, SPCtx *ctx, guint flags) +{ + debug("0x%p",object); + + if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | + SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { + + /* do something to trigger redisplay, updates? */ + + } + + if (((SPObjectClass *) feBlend_parent_class)->update) { + ((SPObjectClass *) feBlend_parent_class)->update(object, ctx, flags); + } +} + +/** + * Writes its settings to an incoming repr object, if any. + */ +static Inkscape::XML::Node * +sp_feBlend_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) +{ + debug("0x%p",object); + + // Inkscape-only object, not copied during an "plain SVG" dump: + if (flags & SP_OBJECT_WRITE_EXT) { + if (repr) { + // is this sane? + repr->mergeFrom(SP_OBJECT_REPR(object), "id"); + } else { + repr = SP_OBJECT_REPR(object)->duplicate(); + } + } + + if (((SPObjectClass *) feBlend_parent_class)->write) { + ((SPObjectClass *) feBlend_parent_class)->write(object, repr, flags); + } + + return repr; +} + + +/* + 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/sp-feblend.h b/src/sp-feblend.h new file mode 100644 index 000000000..3119524ca --- /dev/null +++ b/src/sp-feblend.h @@ -0,0 +1,45 @@ +#ifndef SP_FEBLEND_H_SEEN +#define SP_FEBLEND_H_SEEN + +/** \file + * SVG implementation, see sp-feBlend.cpp. + */ +/* + * Authors: + * Hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "sp-filter.h" +#include "sp-feblend-fns.h" + +/* FeBlend base class */ +class SPFeBlendClass; + +struct SPFeBlend : public SPFilter { + /** BLEND ATTRIBUTES HERE */ + +}; + +struct SPFeBlendClass { + SPFilterClass parent_class; +}; + +GType sp_feBlend_get_type(); + + +#endif /* !SP_FEBLEND_H_SEEN */ + +/* + 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/sp-fecolormatrix-fns.h b/src/sp-fecolormatrix-fns.h new file mode 100644 index 000000000..3a4a8d35c --- /dev/null +++ b/src/sp-fecolormatrix-fns.h @@ -0,0 +1,38 @@ +#ifndef SP_FECOLORMATRIX_FNS_H +#define SP_FECOLORMATRIX_FNS_H + +/** \file + * Macros and fn declarations related to gaussian blur filter. + */ + +#include +#include + +namespace Inkscape { +namespace XML { +class Node; +} +} + +class SPFeColorMatrix; + +#define SP_TYPE_FECOLORMATRIX (sp_feColorMatrix_get_type()) +#define SP_FECOLORMATRIX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FECOLORMATRIX, SPFeColorMatrix)) +#define SP_FECOLORMATRIX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FECOLORMATRIX, SPFeColorMatrixClass)) +#define SP_IS_FECOLORMATRIX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FECOLORMATRIX)) +#define SP_IS_FECOLORMATRIX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FECOLORMATRIX)) + +GType sp_feColorMatrix_get_type(); + +#endif /* !SP_FECOLORMATRIX_FNS_H */ + +/* + 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/sp-fecolormatrix.cpp b/src/sp-fecolormatrix.cpp new file mode 100644 index 000000000..eab5bb8be --- /dev/null +++ b/src/sp-fecolormatrix.cpp @@ -0,0 +1,196 @@ +#define __SP_FECOLORMATRIX_CPP__ + +/** \file + * SVG implementation. + * + */ +/* + * Authors: + * hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "attributes.h" +#include "svg/svg.h" +#include "sp-fecolorMatrix.h" +#include "xml/repr.h" + +//#define SP_MACROS_SILENT +//#include "macros.h" + +#define DEBUG_FECOLORMATRIX +#ifdef DEBUG_FECOLORMATRIX +# define debug(f, a...) { g_print("%s(%d) %s:", \ + __FILE__,__LINE__,__FUNCTION__); \ + g_print(f, ## a); \ + g_print("\n"); \ + } +#else +# define debug(f, a...) /**/ +#endif + +/* FeColorMatrix base class */ + +static void sp_feColorMatrix_class_init(SPFeColorMatrixClass *klass); +static void sp_feColorMatrix_init(SPFeColorMatrix *feColorMatrix); + +static void sp_feColorMatrix_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); +static void sp_feColorMatrix_release(SPObject *object); +static void sp_feColorMatrix_set(SPObject *object, unsigned int key, gchar const *value); +static void sp_feColorMatrix_update(SPObject *object, SPCtx *ctx, guint flags); +static Inkscape::XML::Node *sp_feColorMatrix_write(SPObject *object, Inkscape::XML::Node *repr, guint flags); + +static SPObjectClass *feColorMatrix_parent_class; + +GType +sp_feColorMatrix_get_type() +{ + static GType feColorMatrix_type = 0; + + if (!feColorMatrix_type) { + GTypeInfo feColorMatrix_info = { + sizeof(SPFeColorMatrixClass), + NULL, NULL, + (GClassInitFunc) sp_feColorMatrix_class_init, + NULL, NULL, + sizeof(SPFeColorMatrix), + 16, + (GInstanceInitFunc) sp_feColorMatrix_init, + NULL, /* value_table */ + }; + feColorMatrix_type = g_type_register_static(SP_TYPE_OBJECT, "SPFeColorMatrix", &feColorMatrix_info, (GTypeFlags)0); + } + return feColorMatrix_type; +} + +static void +sp_feColorMatrix_class_init(SPFeColorMatrixClass *klass) +{ + SPObjectClass *sp_object_class = (SPObjectClass *)klass; + + feColorMatrix_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass); + + sp_object_class->build = sp_feColorMatrix_build; + sp_object_class->release = sp_feColorMatrix_release; + sp_object_class->write = sp_feColorMatrix_write; + sp_object_class->set = sp_feColorMatrix_set; + sp_object_class->update = sp_feColorMatrix_update; +} + +static void +sp_feColorMatrix_init(SPFeColorMatrix *feColorMatrix) +{ + debug("0x%p",feColorMatrix); +} + +/** + * Reads the Inkscape::XML::Node, and initializes SPFeColorMatrix variables. For this to get called, + * our name must be associated with a repr via "sp_object_type_register". Best done through + * sp-object-repr.cpp's repr_name_entries array. + */ +static void +sp_feColorMatrix_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +{ + debug("0x%p",object); + if (((SPObjectClass *) feColorMatrix_parent_class)->build) { + ((SPObjectClass *) feColorMatrix_parent_class)->build(object, document, repr); + } + + /*LOAD ATTRIBUTES FROM REPR HERE*/ +} + +/** + * Drops any allocated memory. + */ +static void +sp_feColorMatrix_release(SPObject *object) +{ + debug("0x%p",object); + + if (((SPObjectClass *) feColorMatrix_parent_class)->release) + ((SPObjectClass *) feColorMatrix_parent_class)->release(object); +} + +/** + * Sets a specific value in the SPFeColorMatrix. + */ +static void +sp_feColorMatrix_set(SPObject *object, unsigned int key, gchar const *value) +{ + debug("0x%p %s(%u): '%s'",object, + sp_attribute_name(key),key,value); + SPFeColorMatrix *feColorMatrix = SP_FECOLORMATRIX(object); + + switch(key) { + /*DEAL WITH SETTING ATTRIBUTES HERE*/ + default: + if (((SPObjectClass *) feColorMatrix_parent_class)->set) + ((SPObjectClass *) feColorMatrix_parent_class)->set(object, key, value); + break; + } + +} + +/** + * Receives update notifications. + */ +static void +sp_feColorMatrix_update(SPObject *object, SPCtx *ctx, guint flags) +{ + debug("0x%p",object); + + if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | + SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { + + /* do something to trigger redisplay, updates? */ + + } + + if (((SPObjectClass *) feColorMatrix_parent_class)->update) { + ((SPObjectClass *) feColorMatrix_parent_class)->update(object, ctx, flags); + } +} + +/** + * Writes its settings to an incoming repr object, if any. + */ +static Inkscape::XML::Node * +sp_feColorMatrix_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) +{ + debug("0x%p",object); + + // Inkscape-only object, not copied during an "plain SVG" dump: + if (flags & SP_OBJECT_WRITE_EXT) { + if (repr) { + // is this sane? + repr->mergeFrom(SP_OBJECT_REPR(object), "id"); + } else { + repr = SP_OBJECT_REPR(object)->duplicate(); + } + } + + if (((SPObjectClass *) feColorMatrix_parent_class)->write) { + ((SPObjectClass *) feColorMatrix_parent_class)->write(object, repr, flags); + } + + return repr; +} + + +/* + 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/sp-fecolormatrix.h b/src/sp-fecolormatrix.h new file mode 100644 index 000000000..8f3c8093a --- /dev/null +++ b/src/sp-fecolormatrix.h @@ -0,0 +1,45 @@ +#ifndef SP_FECOLORMATRIX_H_SEEN +#define SP_FECOLORMATRIX_H_SEEN + +/** \file + * SVG implementation, see sp-feColorMatrix.cpp. + */ +/* + * Authors: + * Hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "sp-filter.h" +#include "sp-fecolormatrix-fns.h" + +/* FeColorMatrix base class */ +class SPFeColorMatrixClass; + +struct SPFeColorMatrix : public SPFilter { + /** COLORMATRIX ATTRIBUTES HERE */ + +}; + +struct SPFeColorMatrixClass { + SPFilterClass parent_class; +}; + +GType sp_feColorMatrix_get_type(); + + +#endif /* !SP_FECOLORMATRIX_H_SEEN */ + +/* + 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/sp-fecomponenttransfer.cpp b/src/sp-fecomponenttransfer.cpp new file mode 100644 index 000000000..ffb6f552f --- /dev/null +++ b/src/sp-fecomponenttransfer.cpp @@ -0,0 +1,196 @@ +#define __SP_FECOMPONENTTRANSFER_CPP__ + +/** \file + * SVG implementation. + * + */ +/* + * Authors: + * hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "attributes.h" +#include "svg/svg.h" +#include "sp-fecomponentTransfer.h" +#include "xml/repr.h" + +//#define SP_MACROS_SILENT +//#include "macros.h" + +#define DEBUG_FECOMPONENTTRANSFER +#ifdef DEBUG_FECOMPONENTTRANSFER +# define debug(f, a...) { g_print("%s(%d) %s:", \ + __FILE__,__LINE__,__FUNCTION__); \ + g_print(f, ## a); \ + g_print("\n"); \ + } +#else +# define debug(f, a...) /**/ +#endif + +/* FeComponentTransfer base class */ + +static void sp_feComponentTransfer_class_init(SPFeComponentTransferClass *klass); +static void sp_feComponentTransfer_init(SPFeComponentTransfer *feComponentTransfer); + +static void sp_feComponentTransfer_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); +static void sp_feComponentTransfer_release(SPObject *object); +static void sp_feComponentTransfer_set(SPObject *object, unsigned int key, gchar const *value); +static void sp_feComponentTransfer_update(SPObject *object, SPCtx *ctx, guint flags); +static Inkscape::XML::Node *sp_feComponentTransfer_write(SPObject *object, Inkscape::XML::Node *repr, guint flags); + +static SPObjectClass *feComponentTransfer_parent_class; + +GType +sp_feComponentTransfer_get_type() +{ + static GType feComponentTransfer_type = 0; + + if (!feComponentTransfer_type) { + GTypeInfo feComponentTransfer_info = { + sizeof(SPFeComponentTransferClass), + NULL, NULL, + (GClassInitFunc) sp_feComponentTransfer_class_init, + NULL, NULL, + sizeof(SPFeComponentTransfer), + 16, + (GInstanceInitFunc) sp_feComponentTransfer_init, + NULL, /* value_table */ + }; + feComponentTransfer_type = g_type_register_static(SP_TYPE_OBJECT, "SPFeComponentTransfer", &feComponentTransfer_info, (GTypeFlags)0); + } + return feComponentTransfer_type; +} + +static void +sp_feComponentTransfer_class_init(SPFeComponentTransferClass *klass) +{ + SPObjectClass *sp_object_class = (SPObjectClass *)klass; + + feComponentTransfer_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass); + + sp_object_class->build = sp_feComponentTransfer_build; + sp_object_class->release = sp_feComponentTransfer_release; + sp_object_class->write = sp_feComponentTransfer_write; + sp_object_class->set = sp_feComponentTransfer_set; + sp_object_class->update = sp_feComponentTransfer_update; +} + +static void +sp_feComponentTransfer_init(SPFeComponentTransfer *feComponentTransfer) +{ + debug("0x%p",feComponentTransfer); +} + +/** + * Reads the Inkscape::XML::Node, and initializes SPFeComponentTransfer variables. For this to get called, + * our name must be associated with a repr via "sp_object_type_register". Best done through + * sp-object-repr.cpp's repr_name_entries array. + */ +static void +sp_feComponentTransfer_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +{ + debug("0x%p",object); + if (((SPObjectClass *) feComponentTransfer_parent_class)->build) { + ((SPObjectClass *) feComponentTransfer_parent_class)->build(object, document, repr); + } + + /*LOAD ATTRIBUTES FROM REPR HERE*/ +} + +/** + * Drops any allocated memory. + */ +static void +sp_feComponentTransfer_release(SPObject *object) +{ + debug("0x%p",object); + + if (((SPObjectClass *) feComponentTransfer_parent_class)->release) + ((SPObjectClass *) feComponentTransfer_parent_class)->release(object); +} + +/** + * Sets a specific value in the SPFeComponentTransfer. + */ +static void +sp_feComponentTransfer_set(SPObject *object, unsigned int key, gchar const *value) +{ + debug("0x%p %s(%u): '%s'",object, + sp_attribute_name(key),key,value); + SPFeComponentTransfer *feComponentTransfer = SP_FECOMPONENTTRANSFER(object); + + switch(key) { + /*DEAL WITH SETTING ATTRIBUTES HERE*/ + default: + if (((SPObjectClass *) feComponentTransfer_parent_class)->set) + ((SPObjectClass *) feComponentTransfer_parent_class)->set(object, key, value); + break; + } + +} + +/** + * Receives update notifications. + */ +static void +sp_feComponentTransfer_update(SPObject *object, SPCtx *ctx, guint flags) +{ + debug("0x%p",object); + + if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | + SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { + + /* do something to trigger redisplay, updates? */ + + } + + if (((SPObjectClass *) feComponentTransfer_parent_class)->update) { + ((SPObjectClass *) feComponentTransfer_parent_class)->update(object, ctx, flags); + } +} + +/** + * Writes its settings to an incoming repr object, if any. + */ +static Inkscape::XML::Node * +sp_feComponentTransfer_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) +{ + debug("0x%p",object); + + // Inkscape-only object, not copied during an "plain SVG" dump: + if (flags & SP_OBJECT_WRITE_EXT) { + if (repr) { + // is this sane? + repr->mergeFrom(SP_OBJECT_REPR(object), "id"); + } else { + repr = SP_OBJECT_REPR(object)->duplicate(); + } + } + + if (((SPObjectClass *) feComponentTransfer_parent_class)->write) { + ((SPObjectClass *) feComponentTransfer_parent_class)->write(object, repr, flags); + } + + return repr; +} + + +/* + 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/sp-fecomponenttransfer.h b/src/sp-fecomponenttransfer.h new file mode 100644 index 000000000..0fb400ffa --- /dev/null +++ b/src/sp-fecomponenttransfer.h @@ -0,0 +1,45 @@ +#ifndef SP_FECOMPONENTTRANSFER_H_SEEN +#define SP_FECOMPONENTTRANSFER_H_SEEN + +/** \file + * SVG implementation, see sp-feComponentTransfer.cpp. + */ +/* + * Authors: + * Hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "sp-filter.h" +#include "sp-fecomponenttransfer-fns.h" + +/* FeComponentTransfer base class */ +class SPFeComponentTransferClass; + +struct SPFeComponentTransfer : public SPFilter { + /** COMPONENTTRANSFER ATTRIBUTES HERE */ + +}; + +struct SPFeComponentTransferClass { + SPFilterClass parent_class; +}; + +GType sp_feComponentTransfer_get_type(); + + +#endif /* !SP_FECOMPONENTTRANSFER_H_SEEN */ + +/* + 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/sp-fecomposite-fns.h b/src/sp-fecomposite-fns.h new file mode 100644 index 000000000..c79cb17bb --- /dev/null +++ b/src/sp-fecomposite-fns.h @@ -0,0 +1,38 @@ +#ifndef SP_FECOMPOSITE_FNS_H +#define SP_FECOMPOSITE_FNS_H + +/** \file + * Macros and fn declarations related to gaussian blur filter. + */ + +#include +#include + +namespace Inkscape { +namespace XML { +class Node; +} +} + +class SPFeComposite; + +#define SP_TYPE_FECOMPOSITE (sp_feComposite_get_type()) +#define SP_FECOMPOSITE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FECOMPOSITE, SPFeComposite)) +#define SP_FECOMPOSITE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FECOMPOSITE, SPFeCompositeClass)) +#define SP_IS_FECOMPOSITE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FECOMPOSITE)) +#define SP_IS_FECOMPOSITE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FECOMPOSITE)) + +GType sp_feComposite_get_type(); + +#endif /* !SP_FECOMPOSITE_FNS_H */ + +/* + 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/sp-fecomposite.cpp b/src/sp-fecomposite.cpp new file mode 100644 index 000000000..621ea300a --- /dev/null +++ b/src/sp-fecomposite.cpp @@ -0,0 +1,196 @@ +#define __SP_FECOMPOSITE_CPP__ + +/** \file + * SVG implementation. + * + */ +/* + * Authors: + * hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "attributes.h" +#include "svg/svg.h" +#include "sp-fecomposite.h" +#include "xml/repr.h" + +//#define SP_MACROS_SILENT +//#include "macros.h" + +#define DEBUG_FECOMPOSITE +#ifdef DEBUG_FECOMPOSITE +# define debug(f, a...) { g_print("%s(%d) %s:", \ + __FILE__,__LINE__,__FUNCTION__); \ + g_print(f, ## a); \ + g_print("\n"); \ + } +#else +# define debug(f, a...) /**/ +#endif + +/* FeComposite base class */ + +static void sp_feComposite_class_init(SPFeCompositeClass *klass); +static void sp_feComposite_init(SPFeComposite *feComposite); + +static void sp_feComposite_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); +static void sp_feComposite_release(SPObject *object); +static void sp_feComposite_set(SPObject *object, unsigned int key, gchar const *value); +static void sp_feComposite_update(SPObject *object, SPCtx *ctx, guint flags); +static Inkscape::XML::Node *sp_feComposite_write(SPObject *object, Inkscape::XML::Node *repr, guint flags); + +static SPObjectClass *feComposite_parent_class; + +GType +sp_feComposite_get_type() +{ + static GType feComposite_type = 0; + + if (!feComposite_type) { + GTypeInfo feComposite_info = { + sizeof(SPFeCompositeClass), + NULL, NULL, + (GClassInitFunc) sp_feComposite_class_init, + NULL, NULL, + sizeof(SPFeComposite), + 16, + (GInstanceInitFunc) sp_feComposite_init, + NULL, /* value_table */ + }; + feComposite_type = g_type_register_static(SP_TYPE_OBJECT, "SPFeComposite", &feComposite_info, (GTypeFlags)0); + } + return feComposite_type; +} + +static void +sp_feComposite_class_init(SPFeCompositeClass *klass) +{ + SPObjectClass *sp_object_class = (SPObjectClass *)klass; + + feComposite_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass); + + sp_object_class->build = sp_feComposite_build; + sp_object_class->release = sp_feComposite_release; + sp_object_class->write = sp_feComposite_write; + sp_object_class->set = sp_feComposite_set; + sp_object_class->update = sp_feComposite_update; +} + +static void +sp_feComposite_init(SPFeComposite *feComposite) +{ + debug("0x%p",feComposite); +} + +/** + * Reads the Inkscape::XML::Node, and initializes SPFeComposite variables. For this to get called, + * our name must be associated with a repr via "sp_object_type_register". Best done through + * sp-object-repr.cpp's repr_name_entries array. + */ +static void +sp_feComposite_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +{ + debug("0x%p",object); + if (((SPObjectClass *) feComposite_parent_class)->build) { + ((SPObjectClass *) feComposite_parent_class)->build(object, document, repr); + } + + /*LOAD ATTRIBUTES FROM REPR HERE*/ +} + +/** + * Drops any allocated memory. + */ +static void +sp_feComposite_release(SPObject *object) +{ + debug("0x%p",object); + + if (((SPObjectClass *) feComposite_parent_class)->release) + ((SPObjectClass *) feComposite_parent_class)->release(object); +} + +/** + * Sets a specific value in the SPFeComposite. + */ +static void +sp_feComposite_set(SPObject *object, unsigned int key, gchar const *value) +{ + debug("0x%p %s(%u): '%s'",object, + sp_attribute_name(key),key,value); + SPFeComposite *feComposite = SP_FECOMPOSITE(object); + + switch(key) { + /*DEAL WITH SETTING ATTRIBUTES HERE*/ + default: + if (((SPObjectClass *) feComposite_parent_class)->set) + ((SPObjectClass *) feComposite_parent_class)->set(object, key, value); + break; + } + +} + +/** + * Receives update notifications. + */ +static void +sp_feComposite_update(SPObject *object, SPCtx *ctx, guint flags) +{ + debug("0x%p",object); + + if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | + SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { + + /* do something to trigger redisplay, updates? */ + + } + + if (((SPObjectClass *) feComposite_parent_class)->update) { + ((SPObjectClass *) feComposite_parent_class)->update(object, ctx, flags); + } +} + +/** + * Writes its settings to an incoming repr object, if any. + */ +static Inkscape::XML::Node * +sp_feComposite_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) +{ + debug("0x%p",object); + + // Inkscape-only object, not copied during an "plain SVG" dump: + if (flags & SP_OBJECT_WRITE_EXT) { + if (repr) { + // is this sane? + repr->mergeFrom(SP_OBJECT_REPR(object), "id"); + } else { + repr = SP_OBJECT_REPR(object)->duplicate(); + } + } + + if (((SPObjectClass *) feComposite_parent_class)->write) { + ((SPObjectClass *) feComposite_parent_class)->write(object, repr, flags); + } + + return repr; +} + + +/* + 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/sp-fecomposite.h b/src/sp-fecomposite.h new file mode 100644 index 000000000..468325827 --- /dev/null +++ b/src/sp-fecomposite.h @@ -0,0 +1,45 @@ +#ifndef SP_FECOMPOSITE_H_SEEN +#define SP_FECOMPOSITE_H_SEEN + +/** \file + * SVG implementation, see sp-feComposite.cpp. + */ +/* + * Authors: + * Hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "sp-filter.h" +#include "sp-fecomposite-fns.h" + +/* FeComposite base class */ +class SPFeCompositeClass; + +struct SPFeComposite : public SPFilter { + /** COMPOSITE ATTRIBUTES HERE */ + +}; + +struct SPFeCompositeClass { + SPFilterClass parent_class; +}; + +GType sp_feComposite_get_type(); + + +#endif /* !SP_FECOMPOSITE_H_SEEN */ + +/* + 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/sp-feconvolvematrix-fns.h b/src/sp-feconvolvematrix-fns.h new file mode 100644 index 000000000..76baf7f41 --- /dev/null +++ b/src/sp-feconvolvematrix-fns.h @@ -0,0 +1,38 @@ +#ifndef SP_FECONVOLVEMATRIX_FNS_H +#define SP_FECONVOLVEMATRIX_FNS_H + +/** \file + * Macros and fn declarations related to gaussian blur filter. + */ + +#include +#include + +namespace Inkscape { +namespace XML { +class Node; +} +} + +class SPFeConvolveMatrix; + +#define SP_TYPE_FECONVOLVEMATRIX (sp_feConvolveMatrix_get_type()) +#define SP_FECONVOLVEMATRIX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FECONVOLVEMATRIX, SPFeConvolveMatrix)) +#define SP_FECONVOLVEMATRIX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FECONVOLVEMATRIX, SPFeConvolveMatrixClass)) +#define SP_IS_FECONVOLVEMATRIX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FECONVOLVEMATRIX)) +#define SP_IS_FECONVOLVEMATRIX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FECONVOLVEMATRIX)) + +GType sp_feConvolveMatrix_get_type(); + +#endif /* !SP_FECONVOLVEMATRIX_FNS_H */ + +/* + 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/sp-feconvolvematrix.cpp b/src/sp-feconvolvematrix.cpp new file mode 100644 index 000000000..0db036742 --- /dev/null +++ b/src/sp-feconvolvematrix.cpp @@ -0,0 +1,196 @@ +#define __SP_FECONVOLVEMATRIX_CPP__ + +/** \file + * SVG implementation. + * + */ +/* + * Authors: + * hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "attributes.h" +#include "svg/svg.h" +#include "sp-feconvolvematrix.h" +#include "xml/repr.h" + +//#define SP_MACROS_SILENT +//#include "macros.h" + +#define DEBUG_FECONVOLVEMATRIX +#ifdef DEBUG_FECONVOLVEMATRIX +# define debug(f, a...) { g_print("%s(%d) %s:", \ + __FILE__,__LINE__,__FUNCTION__); \ + g_print(f, ## a); \ + g_print("\n"); \ + } +#else +# define debug(f, a...) /**/ +#endif + +/* FeConvolveMatrix base class */ + +static void sp_feConvolveMatrix_class_init(SPFeConvolveMatrixClass *klass); +static void sp_feConvolveMatrix_init(SPFeConvolveMatrix *feConvolveMatrix); + +static void sp_feConvolveMatrix_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); +static void sp_feConvolveMatrix_release(SPObject *object); +static void sp_feConvolveMatrix_set(SPObject *object, unsigned int key, gchar const *value); +static void sp_feConvolveMatrix_update(SPObject *object, SPCtx *ctx, guint flags); +static Inkscape::XML::Node *sp_feConvolveMatrix_write(SPObject *object, Inkscape::XML::Node *repr, guint flags); + +static SPObjectClass *feConvolveMatrix_parent_class; + +GType +sp_feConvolveMatrix_get_type() +{ + static GType feConvolveMatrix_type = 0; + + if (!feConvolveMatrix_type) { + GTypeInfo feConvolveMatrix_info = { + sizeof(SPFeConvolveMatrixClass), + NULL, NULL, + (GClassInitFunc) sp_feConvolveMatrix_class_init, + NULL, NULL, + sizeof(SPFeConvolveMatrix), + 16, + (GInstanceInitFunc) sp_feConvolveMatrix_init, + NULL, /* value_table */ + }; + feConvolveMatrix_type = g_type_register_static(SP_TYPE_OBJECT, "SPFeConvolveMatrix", &feConvolveMatrix_info, (GTypeFlags)0); + } + return feConvolveMatrix_type; +} + +static void +sp_feConvolveMatrix_class_init(SPFeConvolveMatrixClass *klass) +{ + SPObjectClass *sp_object_class = (SPObjectClass *)klass; + + feConvolveMatrix_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass); + + sp_object_class->build = sp_feConvolveMatrix_build; + sp_object_class->release = sp_feConvolveMatrix_release; + sp_object_class->write = sp_feConvolveMatrix_write; + sp_object_class->set = sp_feConvolveMatrix_set; + sp_object_class->update = sp_feConvolveMatrix_update; +} + +static void +sp_feConvolveMatrix_init(SPFeConvolveMatrix *feConvolveMatrix) +{ + debug("0x%p",feConvolveMatrix); +} + +/** + * Reads the Inkscape::XML::Node, and initializes SPFeConvolveMatrix variables. For this to get called, + * our name must be associated with a repr via "sp_object_type_register". Best done through + * sp-object-repr.cpp's repr_name_entries array. + */ +static void +sp_feConvolveMatrix_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +{ + debug("0x%p",object); + if (((SPObjectClass *) feConvolveMatrix_parent_class)->build) { + ((SPObjectClass *) feConvolveMatrix_parent_class)->build(object, document, repr); + } + + /*LOAD ATTRIBUTES FROM REPR HERE*/ +} + +/** + * Drops any allocated memory. + */ +static void +sp_feConvolveMatrix_release(SPObject *object) +{ + debug("0x%p",object); + + if (((SPObjectClass *) feConvolveMatrix_parent_class)->release) + ((SPObjectClass *) feConvolveMatrix_parent_class)->release(object); +} + +/** + * Sets a specific value in the SPFeConvolveMatrix. + */ +static void +sp_feConvolveMatrix_set(SPObject *object, unsigned int key, gchar const *value) +{ + debug("0x%p %s(%u): '%s'",object, + sp_attribute_name(key),key,value); + SPFeConvolveMatrix *feConvolveMatrix = SP_FECONVOLVEMATRIX(object); + + switch(key) { + /*DEAL WITH SETTING ATTRIBUTES HERE*/ + default: + if (((SPObjectClass *) feConvolveMatrix_parent_class)->set) + ((SPObjectClass *) feConvolveMatrix_parent_class)->set(object, key, value); + break; + } + +} + +/** + * Receives update notifications. + */ +static void +sp_feConvolveMatrix_update(SPObject *object, SPCtx *ctx, guint flags) +{ + debug("0x%p",object); + + if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | + SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { + + /* do something to trigger redisplay, updates? */ + + } + + if (((SPObjectClass *) feConvolveMatrix_parent_class)->update) { + ((SPObjectClass *) feConvolveMatrix_parent_class)->update(object, ctx, flags); + } +} + +/** + * Writes its settings to an incoming repr object, if any. + */ +static Inkscape::XML::Node * +sp_feConvolveMatrix_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) +{ + debug("0x%p",object); + + // Inkscape-only object, not copied during an "plain SVG" dump: + if (flags & SP_OBJECT_WRITE_EXT) { + if (repr) { + // is this sane? + repr->mergeFrom(SP_OBJECT_REPR(object), "id"); + } else { + repr = SP_OBJECT_REPR(object)->duplicate(); + } + } + + if (((SPObjectClass *) feConvolveMatrix_parent_class)->write) { + ((SPObjectClass *) feConvolveMatrix_parent_class)->write(object, repr, flags); + } + + return repr; +} + + +/* + 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/sp-feconvolvematrix.h b/src/sp-feconvolvematrix.h new file mode 100644 index 000000000..911f5d71c --- /dev/null +++ b/src/sp-feconvolvematrix.h @@ -0,0 +1,45 @@ +#ifndef SP_FECONVOLVEMATRIX_H_SEEN +#define SP_FECONVOLVEMATRIX_H_SEEN + +/** \file + * SVG implementation, see sp-feConvolveMatrix.cpp. + */ +/* + * Authors: + * Hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "sp-filter.h" +#include "sp-feconvolvematrix-fns.h" + +/* FeConvolveMatrix base class */ +class SPFeConvolveMatrixClass; + +struct SPFeConvolveMatrix : public SPFilter { + /** CONVOLVEMATRIX ATTRIBUTES HERE */ + +}; + +struct SPFeConvolveMatrixClass { + SPFilterClass parent_class; +}; + +GType sp_feConvolveMatrix_get_type(); + + +#endif /* !SP_FECONVOLVEMATRIX_H_SEEN */ + +/* + 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/sp-fediffuselighting-fns.h b/src/sp-fediffuselighting-fns.h new file mode 100644 index 000000000..b91ed80f6 --- /dev/null +++ b/src/sp-fediffuselighting-fns.h @@ -0,0 +1,38 @@ +#ifndef SP_FEDIFFUSELIGHTING_FNS_H +#define SP_FEDIFFUSELIGHTING_FNS_H + +/** \file + * Macros and fn declarations related to gaussian blur filter. + */ + +#include +#include + +namespace Inkscape { +namespace XML { +class Node; +} +} + +class SPFeDiffuseLighting; + +#define SP_TYPE_FEDIFFUSELIGHTING (sp_feDiffuseLighting_get_type()) +#define SP_FEDIFFUSELIGHTING(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FEDIFFUSELIGHTING, SPFeDiffuseLighting)) +#define SP_FEDIFFUSELIGHTING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FEDIFFUSELIGHTING, SPFeDiffuseLightingClass)) +#define SP_IS_FEDIFFUSELIGHTING(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEDIFFUSELIGHTING)) +#define SP_IS_FEDIFFUSELIGHTING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEDIFFUSELIGHTING)) + +GType sp_feDiffuseLighting_get_type(); + +#endif /* !SP_FEDIFFUSELIGHTING_FNS_H */ + +/* + 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/sp-fediffuselighting.cpp b/src/sp-fediffuselighting.cpp new file mode 100644 index 000000000..5683b330d --- /dev/null +++ b/src/sp-fediffuselighting.cpp @@ -0,0 +1,196 @@ +#define __SP_FEDIFFUSELIGHTING_CPP__ + +/** \file + * SVG implementation. + * + */ +/* + * Authors: + * hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "attributes.h" +#include "svg/svg.h" +#include "sp-fediffuselighting.h" +#include "xml/repr.h" + +//#define SP_MACROS_SILENT +//#include "macros.h" + +#define DEBUG_FEDIFFUSELIGHTING +#ifdef DEBUG_FEDIFFUSELIGHTING +# define debug(f, a...) { g_print("%s(%d) %s:", \ + __FILE__,__LINE__,__FUNCTION__); \ + g_print(f, ## a); \ + g_print("\n"); \ + } +#else +# define debug(f, a...) /**/ +#endif + +/* FeDiffuseLighting base class */ + +static void sp_feDiffuseLighting_class_init(SPFeDiffuseLightingClass *klass); +static void sp_feDiffuseLighting_init(SPFeDiffuseLighting *feDiffuseLighting); + +static void sp_feDiffuseLighting_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); +static void sp_feDiffuseLighting_release(SPObject *object); +static void sp_feDiffuseLighting_set(SPObject *object, unsigned int key, gchar const *value); +static void sp_feDiffuseLighting_update(SPObject *object, SPCtx *ctx, guint flags); +static Inkscape::XML::Node *sp_feDiffuseLighting_write(SPObject *object, Inkscape::XML::Node *repr, guint flags); + +static SPObjectClass *feDiffuseLighting_parent_class; + +GType +sp_feDiffuseLighting_get_type() +{ + static GType feDiffuseLighting_type = 0; + + if (!feDiffuseLighting_type) { + GTypeInfo feDiffuseLighting_info = { + sizeof(SPFeDiffuseLightingClass), + NULL, NULL, + (GClassInitFunc) sp_feDiffuseLighting_class_init, + NULL, NULL, + sizeof(SPFeDiffuseLighting), + 16, + (GInstanceInitFunc) sp_feDiffuseLighting_init, + NULL, /* value_table */ + }; + feDiffuseLighting_type = g_type_register_static(SP_TYPE_OBJECT, "SPFeDiffuseLighting", &feDiffuseLighting_info, (GTypeFlags)0); + } + return feDiffuseLighting_type; +} + +static void +sp_feDiffuseLighting_class_init(SPFeDiffuseLightingClass *klass) +{ + SPObjectClass *sp_object_class = (SPObjectClass *)klass; + + feDiffuseLighting_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass); + + sp_object_class->build = sp_feDiffuseLighting_build; + sp_object_class->release = sp_feDiffuseLighting_release; + sp_object_class->write = sp_feDiffuseLighting_write; + sp_object_class->set = sp_feDiffuseLighting_set; + sp_object_class->update = sp_feDiffuseLighting_update; +} + +static void +sp_feDiffuseLighting_init(SPFeDiffuseLighting *feDiffuseLighting) +{ + debug("0x%p",feDiffuseLighting); +} + +/** + * Reads the Inkscape::XML::Node, and initializes SPFeDiffuseLighting variables. For this to get called, + * our name must be associated with a repr via "sp_object_type_register". Best done through + * sp-object-repr.cpp's repr_name_entries array. + */ +static void +sp_feDiffuseLighting_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +{ + debug("0x%p",object); + if (((SPObjectClass *) feDiffuseLighting_parent_class)->build) { + ((SPObjectClass *) feDiffuseLighting_parent_class)->build(object, document, repr); + } + + /*LOAD ATTRIBUTES FROM REPR HERE*/ +} + +/** + * Drops any allocated memory. + */ +static void +sp_feDiffuseLighting_release(SPObject *object) +{ + debug("0x%p",object); + + if (((SPObjectClass *) feDiffuseLighting_parent_class)->release) + ((SPObjectClass *) feDiffuseLighting_parent_class)->release(object); +} + +/** + * Sets a specific value in the SPFeDiffuseLighting. + */ +static void +sp_feDiffuseLighting_set(SPObject *object, unsigned int key, gchar const *value) +{ + debug("0x%p %s(%u): '%s'",object, + sp_attribute_name(key),key,value); + SPFeDiffuseLighting *feDiffuseLighting = SP_FEDIFFUSELIGHTING(object); + + switch(key) { + /*DEAL WITH SETTING ATTRIBUTES HERE*/ + default: + if (((SPObjectClass *) feDiffuseLighting_parent_class)->set) + ((SPObjectClass *) feDiffuseLighting_parent_class)->set(object, key, value); + break; + } + +} + +/** + * Receives update notifications. + */ +static void +sp_feDiffuseLighting_update(SPObject *object, SPCtx *ctx, guint flags) +{ + debug("0x%p",object); + + if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | + SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { + + /* do something to trigger redisplay, updates? */ + + } + + if (((SPObjectClass *) feDiffuseLighting_parent_class)->update) { + ((SPObjectClass *) feDiffuseLighting_parent_class)->update(object, ctx, flags); + } +} + +/** + * Writes its settings to an incoming repr object, if any. + */ +static Inkscape::XML::Node * +sp_feDiffuseLighting_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) +{ + debug("0x%p",object); + + // Inkscape-only object, not copied during an "plain SVG" dump: + if (flags & SP_OBJECT_WRITE_EXT) { + if (repr) { + // is this sane? + repr->mergeFrom(SP_OBJECT_REPR(object), "id"); + } else { + repr = SP_OBJECT_REPR(object)->duplicate(); + } + } + + if (((SPObjectClass *) feDiffuseLighting_parent_class)->write) { + ((SPObjectClass *) feDiffuseLighting_parent_class)->write(object, repr, flags); + } + + return repr; +} + + +/* + 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/sp-fediffuselighting.h b/src/sp-fediffuselighting.h new file mode 100644 index 000000000..598f380e3 --- /dev/null +++ b/src/sp-fediffuselighting.h @@ -0,0 +1,83 @@ +#ifndef SP_FEDIFFUSELIGHTING_FNS_H +#define SP_FEDIFFUSELIGHTING_FNS_H + +/** \file + * Macros and fn declarations related to gaussian blur filter. + */ + +#include +#include + +namespace Inkscape { +namespace XML { +class Node; +} +} + +class SPFeDiffuseLighting; + +#define SP_TYPE_FEDIFFUSELIGHTING (sp_feDiffuseLighting_get_type()) +#define SP_FEDIFFUSELIGHTING(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FEDIFFUSELIGHTING, SPFeDiffuseLighting)) +#define SP_FEDIFFUSELIGHTING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FEDIFFUSELIGHTING, SPFeDiffuseLightingClass)) +#define SP_IS_FEDIFFUSELIGHTING(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEDIFFUSELIGHTING)) +#define SP_IS_FEDIFFUSELIGHTING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEDIFFUSELIGHTING)) + +GType sp_feDiffuseLighting_get_type(); + +#endif /* !SP_FEDIFFUSELIGHTING_FNS_H */ + +/* + 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 : +#ifndef SP_FEDIFFUSELIGHTING_H_SEEN +#define SP_FEDIFFUSELIGHTING_H_SEEN + +/** \file + * SVG implementation, see sp-feDiffuseLighting.cpp. + */ +/* + * Authors: + * Hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "sp-filter.h" +#include "sp-fediffuselighting-fns.h" + +/* FeDiffuseLighting base class */ +class SPFeDiffuseLightingClass; + +struct SPFeDiffuseLighting : public SPFilter { + /** DIFFUSELIGHTING ATTRIBUTES HERE */ + +}; + +struct SPFeDiffuseLightingClass { + SPFilterClass parent_class; +}; + +GType sp_feDiffuseLighting_get_type(); + + +#endif /* !SP_FEDIFFUSELIGHTING_H_SEEN */ + +/* + 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/sp-fedisplacementmap-fns.h b/src/sp-fedisplacementmap-fns.h new file mode 100644 index 000000000..6d92c6b78 --- /dev/null +++ b/src/sp-fedisplacementmap-fns.h @@ -0,0 +1,38 @@ +#ifndef SP_FEDISPLACEMENTMAP_FNS_H +#define SP_FEDISPLACEMENTMAP_FNS_H + +/** \file + * Macros and fn declarations related to gaussian blur filter. + */ + +#include +#include + +namespace Inkscape { +namespace XML { +class Node; +} +} + +class SPFeDisplacementMap; + +#define SP_TYPE_FEDISPLACEMENTMAP (sp_feDisplacementMap_get_type()) +#define SP_FEDISPLACEMENTMAP(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FEDISPLACEMENTMAP, SPFeDisplacementMap)) +#define SP_FEDISPLACEMENTMAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FEDISPLACEMENTMAP, SPFeDisplacementMapClass)) +#define SP_IS_FEDISPLACEMENTMAP(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEDISPLACEMENTMAP)) +#define SP_IS_FEDISPLACEMENTMAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEDISPLACEMENTMAP)) + +GType sp_feDisplacementMap_get_type(); + +#endif /* !SP_FEDISPLACEMENTMAP_FNS_H */ + +/* + 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/sp-fedisplacementmap.cpp b/src/sp-fedisplacementmap.cpp new file mode 100644 index 000000000..43eb82043 --- /dev/null +++ b/src/sp-fedisplacementmap.cpp @@ -0,0 +1,196 @@ +#define __SP_FEDISPLACEMENTMAP_CPP__ + +/** \file + * SVG implementation. + * + */ +/* + * Authors: + * hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "attributes.h" +#include "svg/svg.h" +#include "sp-fedisplacementmap.h" +#include "xml/repr.h" + +//#define SP_MACROS_SILENT +//#include "macros.h" + +#define DEBUG_FEDISPLACEMENTMAP +#ifdef DEBUG_FEDISPLACEMENTMAP +# define debug(f, a...) { g_print("%s(%d) %s:", \ + __FILE__,__LINE__,__FUNCTION__); \ + g_print(f, ## a); \ + g_print("\n"); \ + } +#else +# define debug(f, a...) /**/ +#endif + +/* FeDisplacementMap base class */ + +static void sp_feDisplacementMap_class_init(SPFeDisplacementMapClass *klass); +static void sp_feDisplacementMap_init(SPFeDisplacementMap *feDisplacementMap); + +static void sp_feDisplacementMap_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); +static void sp_feDisplacementMap_release(SPObject *object); +static void sp_feDisplacementMap_set(SPObject *object, unsigned int key, gchar const *value); +static void sp_feDisplacementMap_update(SPObject *object, SPCtx *ctx, guint flags); +static Inkscape::XML::Node *sp_feDisplacementMap_write(SPObject *object, Inkscape::XML::Node *repr, guint flags); + +static SPObjectClass *feDisplacementMap_parent_class; + +GType +sp_feDisplacementMap_get_type() +{ + static GType feDisplacementMap_type = 0; + + if (!feDisplacementMap_type) { + GTypeInfo feDisplacementMap_info = { + sizeof(SPFeDisplacementMapClass), + NULL, NULL, + (GClassInitFunc) sp_feDisplacementMap_class_init, + NULL, NULL, + sizeof(SPFeDisplacementMap), + 16, + (GInstanceInitFunc) sp_feDisplacementMap_init, + NULL, /* value_table */ + }; + feDisplacementMap_type = g_type_register_static(SP_TYPE_OBJECT, "SPFeDisplacementMap", &feDisplacementMap_info, (GTypeFlags)0); + } + return feDisplacementMap_type; +} + +static void +sp_feDisplacementMap_class_init(SPFeDisplacementMapClass *klass) +{ + SPObjectClass *sp_object_class = (SPObjectClass *)klass; + + feDisplacementMap_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass); + + sp_object_class->build = sp_feDisplacementMap_build; + sp_object_class->release = sp_feDisplacementMap_release; + sp_object_class->write = sp_feDisplacementMap_write; + sp_object_class->set = sp_feDisplacementMap_set; + sp_object_class->update = sp_feDisplacementMap_update; +} + +static void +sp_feDisplacementMap_init(SPFeDisplacementMap *feDisplacementMap) +{ + debug("0x%p",feDisplacementMap); +} + +/** + * Reads the Inkscape::XML::Node, and initializes SPFeDisplacementMap variables. For this to get called, + * our name must be associated with a repr via "sp_object_type_register". Best done through + * sp-object-repr.cpp's repr_name_entries array. + */ +static void +sp_feDisplacementMap_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +{ + debug("0x%p",object); + if (((SPObjectClass *) feDisplacementMap_parent_class)->build) { + ((SPObjectClass *) feDisplacementMap_parent_class)->build(object, document, repr); + } + + /*LOAD ATTRIBUTES FROM REPR HERE*/ +} + +/** + * Drops any allocated memory. + */ +static void +sp_feDisplacementMap_release(SPObject *object) +{ + debug("0x%p",object); + + if (((SPObjectClass *) feDisplacementMap_parent_class)->release) + ((SPObjectClass *) feDisplacementMap_parent_class)->release(object); +} + +/** + * Sets a specific value in the SPFeDisplacementMap. + */ +static void +sp_feDisplacementMap_set(SPObject *object, unsigned int key, gchar const *value) +{ + debug("0x%p %s(%u): '%s'",object, + sp_attribute_name(key),key,value); + SPFeDisplacementMap *feDisplacementMap = SP_FEDISPLACEMENTMAP(object); + + switch(key) { + /*DEAL WITH SETTING ATTRIBUTES HERE*/ + default: + if (((SPObjectClass *) feDisplacementMap_parent_class)->set) + ((SPObjectClass *) feDisplacementMap_parent_class)->set(object, key, value); + break; + } + +} + +/** + * Receives update notifications. + */ +static void +sp_feDisplacementMap_update(SPObject *object, SPCtx *ctx, guint flags) +{ + debug("0x%p",object); + + if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | + SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { + + /* do something to trigger redisplay, updates? */ + + } + + if (((SPObjectClass *) feDisplacementMap_parent_class)->update) { + ((SPObjectClass *) feDisplacementMap_parent_class)->update(object, ctx, flags); + } +} + +/** + * Writes its settings to an incoming repr object, if any. + */ +static Inkscape::XML::Node * +sp_feDisplacementMap_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) +{ + debug("0x%p",object); + + // Inkscape-only object, not copied during an "plain SVG" dump: + if (flags & SP_OBJECT_WRITE_EXT) { + if (repr) { + // is this sane? + repr->mergeFrom(SP_OBJECT_REPR(object), "id"); + } else { + repr = SP_OBJECT_REPR(object)->duplicate(); + } + } + + if (((SPObjectClass *) feDisplacementMap_parent_class)->write) { + ((SPObjectClass *) feDisplacementMap_parent_class)->write(object, repr, flags); + } + + return repr; +} + + +/* + 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/sp-fedisplacementmap.h b/src/sp-fedisplacementmap.h new file mode 100644 index 000000000..6800d4485 --- /dev/null +++ b/src/sp-fedisplacementmap.h @@ -0,0 +1,45 @@ +#ifndef SP_FEDISPLACEMENTMAP_H_SEEN +#define SP_FEDISPLACEMENTMAP_H_SEEN + +/** \file + * SVG implementation, see sp-feDisplacementMap.cpp. + */ +/* + * Authors: + * Hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "sp-filter.h" +#include "sp-fedisplacementmap-fns.h" + +/* FeDisplacementMap base class */ +class SPFeDisplacementMapClass; + +struct SPFeDisplacementMap : public SPFilter { + /** DISPLACEMENTMAP ATTRIBUTES HERE */ + +}; + +struct SPFeDisplacementMapClass { + SPFilterClass parent_class; +}; + +GType sp_feDisplacementMap_get_type(); + + +#endif /* !SP_FEDISPLACEMENTMAP_H_SEEN */ + +/* + 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/sp-feflood-fns.h b/src/sp-feflood-fns.h new file mode 100644 index 000000000..8cc507274 --- /dev/null +++ b/src/sp-feflood-fns.h @@ -0,0 +1,38 @@ +#ifndef SP_FEFLOOD_FNS_H +#define SP_FEFLOOD_FNS_H + +/** \file + * Macros and fn declarations related to gaussian blur filter. + */ + +#include +#include + +namespace Inkscape { +namespace XML { +class Node; +} +} + +class SPFeFlood; + +#define SP_TYPE_FEFLOOD (sp_feFlood_get_type()) +#define SP_FEFLOOD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FEFLOOD, SPFeFlood)) +#define SP_FEFLOOD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FEFLOOD, SPFeFloodClass)) +#define SP_IS_FEFLOOD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEFLOOD)) +#define SP_IS_FEFLOOD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEFLOOD)) + +GType sp_feFlood_get_type(); + +#endif /* !SP_FEFLOOD_FNS_H */ + +/* + 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/sp-feflood.cpp b/src/sp-feflood.cpp new file mode 100644 index 000000000..e10c871af --- /dev/null +++ b/src/sp-feflood.cpp @@ -0,0 +1,196 @@ +#define __SP_FEFLOOD_CPP__ + +/** \file + * SVG implementation. + * + */ +/* + * Authors: + * hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "attributes.h" +#include "svg/svg.h" +#include "sp-feflood.h" +#include "xml/repr.h" + +//#define SP_MACROS_SILENT +//#include "macros.h" + +#define DEBUG_FEFLOOD +#ifdef DEBUG_FEFLOOD +# define debug(f, a...) { g_print("%s(%d) %s:", \ + __FILE__,__LINE__,__FUNCTION__); \ + g_print(f, ## a); \ + g_print("\n"); \ + } +#else +# define debug(f, a...) /**/ +#endif + +/* FeFlood base class */ + +static void sp_feFlood_class_init(SPFeFloodClass *klass); +static void sp_feFlood_init(SPFeFlood *feFlood); + +static void sp_feFlood_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); +static void sp_feFlood_release(SPObject *object); +static void sp_feFlood_set(SPObject *object, unsigned int key, gchar const *value); +static void sp_feFlood_update(SPObject *object, SPCtx *ctx, guint flags); +static Inkscape::XML::Node *sp_feFlood_write(SPObject *object, Inkscape::XML::Node *repr, guint flags); + +static SPObjectClass *feFlood_parent_class; + +GType +sp_feFlood_get_type() +{ + static GType feFlood_type = 0; + + if (!feFlood_type) { + GTypeInfo feFlood_info = { + sizeof(SPFeFloodClass), + NULL, NULL, + (GClassInitFunc) sp_feFlood_class_init, + NULL, NULL, + sizeof(SPFeFlood), + 16, + (GInstanceInitFunc) sp_feFlood_init, + NULL, /* value_table */ + }; + feFlood_type = g_type_register_static(SP_TYPE_OBJECT, "SPFeFlood", &feFlood_info, (GTypeFlags)0); + } + return feFlood_type; +} + +static void +sp_feFlood_class_init(SPFeFloodClass *klass) +{ + SPObjectClass *sp_object_class = (SPObjectClass *)klass; + + feFlood_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass); + + sp_object_class->build = sp_feFlood_build; + sp_object_class->release = sp_feFlood_release; + sp_object_class->write = sp_feFlood_write; + sp_object_class->set = sp_feFlood_set; + sp_object_class->update = sp_feFlood_update; +} + +static void +sp_feFlood_init(SPFeFlood *feFlood) +{ + debug("0x%p",feFlood); +} + +/** + * Reads the Inkscape::XML::Node, and initializes SPFeFlood variables. For this to get called, + * our name must be associated with a repr via "sp_object_type_register". Best done through + * sp-object-repr.cpp's repr_name_entries array. + */ +static void +sp_feFlood_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +{ + debug("0x%p",object); + if (((SPObjectClass *) feFlood_parent_class)->build) { + ((SPObjectClass *) feFlood_parent_class)->build(object, document, repr); + } + + /*LOAD ATTRIBUTES FROM REPR HERE*/ +} + +/** + * Drops any allocated memory. + */ +static void +sp_feFlood_release(SPObject *object) +{ + debug("0x%p",object); + + if (((SPObjectClass *) feFlood_parent_class)->release) + ((SPObjectClass *) feFlood_parent_class)->release(object); +} + +/** + * Sets a specific value in the SPFeFlood. + */ +static void +sp_feFlood_set(SPObject *object, unsigned int key, gchar const *value) +{ + debug("0x%p %s(%u): '%s'",object, + sp_attribute_name(key),key,value); + SPFeFlood *feFlood = SP_FEFLOOD(object); + + switch(key) { + /*DEAL WITH SETTING ATTRIBUTES HERE*/ + default: + if (((SPObjectClass *) feFlood_parent_class)->set) + ((SPObjectClass *) feFlood_parent_class)->set(object, key, value); + break; + } + +} + +/** + * Receives update notifications. + */ +static void +sp_feFlood_update(SPObject *object, SPCtx *ctx, guint flags) +{ + debug("0x%p",object); + + if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | + SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { + + /* do something to trigger redisplay, updates? */ + + } + + if (((SPObjectClass *) feFlood_parent_class)->update) { + ((SPObjectClass *) feFlood_parent_class)->update(object, ctx, flags); + } +} + +/** + * Writes its settings to an incoming repr object, if any. + */ +static Inkscape::XML::Node * +sp_feFlood_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) +{ + debug("0x%p",object); + + // Inkscape-only object, not copied during an "plain SVG" dump: + if (flags & SP_OBJECT_WRITE_EXT) { + if (repr) { + // is this sane? + repr->mergeFrom(SP_OBJECT_REPR(object), "id"); + } else { + repr = SP_OBJECT_REPR(object)->duplicate(); + } + } + + if (((SPObjectClass *) feFlood_parent_class)->write) { + ((SPObjectClass *) feFlood_parent_class)->write(object, repr, flags); + } + + return repr; +} + + +/* + 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/sp-feflood.h b/src/sp-feflood.h new file mode 100644 index 000000000..4fc5da31d --- /dev/null +++ b/src/sp-feflood.h @@ -0,0 +1,45 @@ +#ifndef SP_FEFLOOD_H_SEEN +#define SP_FEFLOOD_H_SEEN + +/** \file + * SVG implementation, see sp-feFlood.cpp. + */ +/* + * Authors: + * Hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "sp-filter.h" +#include "sp-feflood-fns.h" + +/* FeFlood base class */ +class SPFeFloodClass; + +struct SPFeFlood : public SPFilter { + /** FLOOD ATTRIBUTES HERE */ + +}; + +struct SPFeFloodClass { + SPFilterClass parent_class; +}; + +GType sp_feFlood_get_type(); + + +#endif /* !SP_FEFLOOD_H_SEEN */ + +/* + 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/sp-feimage-fns.h b/src/sp-feimage-fns.h new file mode 100644 index 000000000..0a8b453fe --- /dev/null +++ b/src/sp-feimage-fns.h @@ -0,0 +1,38 @@ +#ifndef SP_FEIMAGE_FNS_H +#define SP_FEIMAGE_FNS_H + +/** \file + * Macros and fn declarations related to gaussian blur filter. + */ + +#include +#include + +namespace Inkscape { +namespace XML { +class Node; +} +} + +class SPFeImage; + +#define SP_TYPE_FEIMAGE (sp_feImage_get_type()) +#define SP_FEIMAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FEIMAGE, SPFeImage)) +#define SP_FEIMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FEIMAGE, SPFeImageClass)) +#define SP_IS_FEIMAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEIMAGE)) +#define SP_IS_FEIMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEIMAGE)) + +GType sp_feImage_get_type(); + +#endif /* !SP_FEIMAGE_FNS_H */ + +/* + 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/sp-feimage.cpp b/src/sp-feimage.cpp new file mode 100644 index 000000000..08bb1f3e2 --- /dev/null +++ b/src/sp-feimage.cpp @@ -0,0 +1,196 @@ +#define __SP_FEIMAGE_CPP__ + +/** \file + * SVG implementation. + * + */ +/* + * Authors: + * hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "attributes.h" +#include "svg/svg.h" +#include "sp-feimage.h" +#include "xml/repr.h" + +//#define SP_MACROS_SILENT +//#include "macros.h" + +#define DEBUG_FEIMAGE +#ifdef DEBUG_FEIMAGE +# define debug(f, a...) { g_print("%s(%d) %s:", \ + __FILE__,__LINE__,__FUNCTION__); \ + g_print(f, ## a); \ + g_print("\n"); \ + } +#else +# define debug(f, a...) /**/ +#endif + +/* FeImage base class */ + +static void sp_feImage_class_init(SPFeImageClass *klass); +static void sp_feImage_init(SPFeImage *feImage); + +static void sp_feImage_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); +static void sp_feImage_release(SPObject *object); +static void sp_feImage_set(SPObject *object, unsigned int key, gchar const *value); +static void sp_feImage_update(SPObject *object, SPCtx *ctx, guint flags); +static Inkscape::XML::Node *sp_feImage_write(SPObject *object, Inkscape::XML::Node *repr, guint flags); + +static SPObjectClass *feImage_parent_class; + +GType +sp_feImage_get_type() +{ + static GType feImage_type = 0; + + if (!feImage_type) { + GTypeInfo feImage_info = { + sizeof(SPFeImageClass), + NULL, NULL, + (GClassInitFunc) sp_feImage_class_init, + NULL, NULL, + sizeof(SPFeImage), + 16, + (GInstanceInitFunc) sp_feImage_init, + NULL, /* value_table */ + }; + feImage_type = g_type_register_static(SP_TYPE_OBJECT, "SPFeImage", &feImage_info, (GTypeFlags)0); + } + return feImage_type; +} + +static void +sp_feImage_class_init(SPFeImageClass *klass) +{ + SPObjectClass *sp_object_class = (SPObjectClass *)klass; + + feImage_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass); + + sp_object_class->build = sp_feImage_build; + sp_object_class->release = sp_feImage_release; + sp_object_class->write = sp_feImage_write; + sp_object_class->set = sp_feImage_set; + sp_object_class->update = sp_feImage_update; +} + +static void +sp_feImage_init(SPFeImage *feImage) +{ + debug("0x%p",feImage); +} + +/** + * Reads the Inkscape::XML::Node, and initializes SPFeImage variables. For this to get called, + * our name must be associated with a repr via "sp_object_type_register". Best done through + * sp-object-repr.cpp's repr_name_entries array. + */ +static void +sp_feImage_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +{ + debug("0x%p",object); + if (((SPObjectClass *) feImage_parent_class)->build) { + ((SPObjectClass *) feImage_parent_class)->build(object, document, repr); + } + + /*LOAD ATTRIBUTES FROM REPR HERE*/ +} + +/** + * Drops any allocated memory. + */ +static void +sp_feImage_release(SPObject *object) +{ + debug("0x%p",object); + + if (((SPObjectClass *) feImage_parent_class)->release) + ((SPObjectClass *) feImage_parent_class)->release(object); +} + +/** + * Sets a specific value in the SPFeImage. + */ +static void +sp_feImage_set(SPObject *object, unsigned int key, gchar const *value) +{ + debug("0x%p %s(%u): '%s'",object, + sp_attribute_name(key),key,value); + SPFeImage *feImage = SP_FEIMAGE(object); + + switch(key) { + /*DEAL WITH SETTING ATTRIBUTES HERE*/ + default: + if (((SPObjectClass *) feImage_parent_class)->set) + ((SPObjectClass *) feImage_parent_class)->set(object, key, value); + break; + } + +} + +/** + * Receives update notifications. + */ +static void +sp_feImage_update(SPObject *object, SPCtx *ctx, guint flags) +{ + debug("0x%p",object); + + if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | + SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { + + /* do something to trigger redisplay, updates? */ + + } + + if (((SPObjectClass *) feImage_parent_class)->update) { + ((SPObjectClass *) feImage_parent_class)->update(object, ctx, flags); + } +} + +/** + * Writes its settings to an incoming repr object, if any. + */ +static Inkscape::XML::Node * +sp_feImage_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) +{ + debug("0x%p",object); + + // Inkscape-only object, not copied during an "plain SVG" dump: + if (flags & SP_OBJECT_WRITE_EXT) { + if (repr) { + // is this sane? + repr->mergeFrom(SP_OBJECT_REPR(object), "id"); + } else { + repr = SP_OBJECT_REPR(object)->duplicate(); + } + } + + if (((SPObjectClass *) feImage_parent_class)->write) { + ((SPObjectClass *) feImage_parent_class)->write(object, repr, flags); + } + + return repr; +} + + +/* + 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/sp-feimage.h b/src/sp-feimage.h new file mode 100644 index 000000000..958c6232f --- /dev/null +++ b/src/sp-feimage.h @@ -0,0 +1,45 @@ +#ifndef SP_FEIMAGE_H_SEEN +#define SP_FEIMAGE_H_SEEN + +/** \file + * SVG implementation, see sp-feImage.cpp. + */ +/* + * Authors: + * Hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "sp-filter.h" +#include "sp-feimage-fns.h" + +/* FeImage base class */ +class SPFeImageClass; + +struct SPFeImage : public SPFilter { + /** IMAGE ATTRIBUTES HERE */ + +}; + +struct SPFeImageClass { + SPFilterClass parent_class; +}; + +GType sp_feImage_get_type(); + + +#endif /* !SP_FEIMAGE_H_SEEN */ + +/* + 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/sp-femerge-fns.h b/src/sp-femerge-fns.h new file mode 100644 index 000000000..24bda1ae2 --- /dev/null +++ b/src/sp-femerge-fns.h @@ -0,0 +1,38 @@ +#ifndef SP_FEMERGE_FNS_H +#define SP_FEMERGE_FNS_H + +/** \file + * Macros and fn declarations related to gaussian blur filter. + */ + +#include +#include + +namespace Inkscape { +namespace XML { +class Node; +} +} + +class SPFeMerge; + +#define SP_TYPE_FEMERGE (sp_feMerge_get_type()) +#define SP_FEMERGE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FEMERGE, SPFeMerge)) +#define SP_FEMERGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FEMERGE, SPFeMergeClass)) +#define SP_IS_FEMERGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEMERGE)) +#define SP_IS_FEMERGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEMERGE)) + +GType sp_feMerge_get_type(); + +#endif /* !SP_FEMERGE_FNS_H */ + +/* + 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/sp-femerge.cpp b/src/sp-femerge.cpp new file mode 100644 index 000000000..6904f5b52 --- /dev/null +++ b/src/sp-femerge.cpp @@ -0,0 +1,196 @@ +#define __SP_FEMERGE_CPP__ + +/** \file + * SVG implementation. + * + */ +/* + * Authors: + * hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "attributes.h" +#include "svg/svg.h" +#include "sp-femerge.h" +#include "xml/repr.h" + +//#define SP_MACROS_SILENT +//#include "macros.h" + +#define DEBUG_FEMERGE +#ifdef DEBUG_FEMERGE +# define debug(f, a...) { g_print("%s(%d) %s:", \ + __FILE__,__LINE__,__FUNCTION__); \ + g_print(f, ## a); \ + g_print("\n"); \ + } +#else +# define debug(f, a...) /**/ +#endif + +/* FeMerge base class */ + +static void sp_feMerge_class_init(SPFeMergeClass *klass); +static void sp_feMerge_init(SPFeMerge *feMerge); + +static void sp_feMerge_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); +static void sp_feMerge_release(SPObject *object); +static void sp_feMerge_set(SPObject *object, unsigned int key, gchar const *value); +static void sp_feMerge_update(SPObject *object, SPCtx *ctx, guint flags); +static Inkscape::XML::Node *sp_feMerge_write(SPObject *object, Inkscape::XML::Node *repr, guint flags); + +static SPObjectClass *feMerge_parent_class; + +GType +sp_feMerge_get_type() +{ + static GType feMerge_type = 0; + + if (!feMerge_type) { + GTypeInfo feMerge_info = { + sizeof(SPFeMergeClass), + NULL, NULL, + (GClassInitFunc) sp_feMerge_class_init, + NULL, NULL, + sizeof(SPFeMerge), + 16, + (GInstanceInitFunc) sp_feMerge_init, + NULL, /* value_table */ + }; + feMerge_type = g_type_register_static(SP_TYPE_OBJECT, "SPFeMerge", &feMerge_info, (GTypeFlags)0); + } + return feMerge_type; +} + +static void +sp_feMerge_class_init(SPFeMergeClass *klass) +{ + SPObjectClass *sp_object_class = (SPObjectClass *)klass; + + feMerge_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass); + + sp_object_class->build = sp_feMerge_build; + sp_object_class->release = sp_feMerge_release; + sp_object_class->write = sp_feMerge_write; + sp_object_class->set = sp_feMerge_set; + sp_object_class->update = sp_feMerge_update; +} + +static void +sp_feMerge_init(SPFeMerge *feMerge) +{ + debug("0x%p",feMerge); +} + +/** + * Reads the Inkscape::XML::Node, and initializes SPFeMerge variables. For this to get called, + * our name must be associated with a repr via "sp_object_type_register". Best done through + * sp-object-repr.cpp's repr_name_entries array. + */ +static void +sp_feMerge_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +{ + debug("0x%p",object); + if (((SPObjectClass *) feMerge_parent_class)->build) { + ((SPObjectClass *) feMerge_parent_class)->build(object, document, repr); + } + + /*LOAD ATTRIBUTES FROM REPR HERE*/ +} + +/** + * Drops any allocated memory. + */ +static void +sp_feMerge_release(SPObject *object) +{ + debug("0x%p",object); + + if (((SPObjectClass *) feMerge_parent_class)->release) + ((SPObjectClass *) feMerge_parent_class)->release(object); +} + +/** + * Sets a specific value in the SPFeMerge. + */ +static void +sp_feMerge_set(SPObject *object, unsigned int key, gchar const *value) +{ + debug("0x%p %s(%u): '%s'",object, + sp_attribute_name(key),key,value); + SPFeMerge *feMerge = SP_FEMERGE(object); + + switch(key) { + /*DEAL WITH SETTING ATTRIBUTES HERE*/ + default: + if (((SPObjectClass *) feMerge_parent_class)->set) + ((SPObjectClass *) feMerge_parent_class)->set(object, key, value); + break; + } + +} + +/** + * Receives update notifications. + */ +static void +sp_feMerge_update(SPObject *object, SPCtx *ctx, guint flags) +{ + debug("0x%p",object); + + if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | + SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { + + /* do something to trigger redisplay, updates? */ + + } + + if (((SPObjectClass *) feMerge_parent_class)->update) { + ((SPObjectClass *) feMerge_parent_class)->update(object, ctx, flags); + } +} + +/** + * Writes its settings to an incoming repr object, if any. + */ +static Inkscape::XML::Node * +sp_feMerge_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) +{ + debug("0x%p",object); + + // Inkscape-only object, not copied during an "plain SVG" dump: + if (flags & SP_OBJECT_WRITE_EXT) { + if (repr) { + // is this sane? + repr->mergeFrom(SP_OBJECT_REPR(object), "id"); + } else { + repr = SP_OBJECT_REPR(object)->duplicate(); + } + } + + if (((SPObjectClass *) feMerge_parent_class)->write) { + ((SPObjectClass *) feMerge_parent_class)->write(object, repr, flags); + } + + return repr; +} + + +/* + 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/sp-femerge.h b/src/sp-femerge.h new file mode 100644 index 000000000..41bdfa377 --- /dev/null +++ b/src/sp-femerge.h @@ -0,0 +1,45 @@ +#ifndef SP_FEMERGE_H_SEEN +#define SP_FEMERGE_H_SEEN + +/** \file + * SVG implementation, see sp-feMerge.cpp. + */ +/* + * Authors: + * Hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "sp-filter.h" +#include "sp-femerge-fns.h" + +/* FeMerge base class */ +class SPFeMergeClass; + +struct SPFeMerge : public SPFilter { + /** MERGE ATTRIBUTES HERE */ + +}; + +struct SPFeMergeClass { + SPFilterClass parent_class; +}; + +GType sp_feMerge_get_type(); + + +#endif /* !SP_FEMERGE_H_SEEN */ + +/* + 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/sp-femorphology-fns.h b/src/sp-femorphology-fns.h new file mode 100644 index 000000000..a0550405d --- /dev/null +++ b/src/sp-femorphology-fns.h @@ -0,0 +1,38 @@ +#ifndef SP_FEMORPHOLOGY_FNS_H +#define SP_FEMORPHOLOGY_FNS_H + +/** \file + * Macros and fn declarations related to gaussian blur filter. + */ + +#include +#include + +namespace Inkscape { +namespace XML { +class Node; +} +} + +class SPFeMorphology; + +#define SP_TYPE_FEMORPHOLOGY (sp_feMorphology_get_type()) +#define SP_FEMORPHOLOGY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FEMORPHOLOGY, SPFeMorphology)) +#define SP_FEMORPHOLOGY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FEMORPHOLOGY, SPFeMorphologyClass)) +#define SP_IS_FEMORPHOLOGY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEMORPHOLOGY)) +#define SP_IS_FEMORPHOLOGY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEMORPHOLOGY)) + +GType sp_feMorphology_get_type(); + +#endif /* !SP_FEMORPHOLOGY_FNS_H */ + +/* + 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/sp-femorphology.cpp b/src/sp-femorphology.cpp new file mode 100644 index 000000000..5d015232f --- /dev/null +++ b/src/sp-femorphology.cpp @@ -0,0 +1,196 @@ +#define __SP_FEMORPHOLOGY_CPP__ + +/** \file + * SVG implementation. + * + */ +/* + * Authors: + * hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "attributes.h" +#include "svg/svg.h" +#include "sp-femorphology.h" +#include "xml/repr.h" + +//#define SP_MACROS_SILENT +//#include "macros.h" + +#define DEBUG_FEMORPHOLOGY +#ifdef DEBUG_FEMORPHOLOGY +# define debug(f, a...) { g_print("%s(%d) %s:", \ + __FILE__,__LINE__,__FUNCTION__); \ + g_print(f, ## a); \ + g_print("\n"); \ + } +#else +# define debug(f, a...) /**/ +#endif + +/* FeMorphology base class */ + +static void sp_feMorphology_class_init(SPFeMorphologyClass *klass); +static void sp_feMorphology_init(SPFeMorphology *feMorphology); + +static void sp_feMorphology_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); +static void sp_feMorphology_release(SPObject *object); +static void sp_feMorphology_set(SPObject *object, unsigned int key, gchar const *value); +static void sp_feMorphology_update(SPObject *object, SPCtx *ctx, guint flags); +static Inkscape::XML::Node *sp_feMorphology_write(SPObject *object, Inkscape::XML::Node *repr, guint flags); + +static SPObjectClass *feMorphology_parent_class; + +GType +sp_feMorphology_get_type() +{ + static GType feMorphology_type = 0; + + if (!feMorphology_type) { + GTypeInfo feMorphology_info = { + sizeof(SPFeMorphologyClass), + NULL, NULL, + (GClassInitFunc) sp_feMorphology_class_init, + NULL, NULL, + sizeof(SPFeMorphology), + 16, + (GInstanceInitFunc) sp_feMorphology_init, + NULL, /* value_table */ + }; + feMorphology_type = g_type_register_static(SP_TYPE_OBJECT, "SPFeMorphology", &feMorphology_info, (GTypeFlags)0); + } + return feMorphology_type; +} + +static void +sp_feMorphology_class_init(SPFeMorphologyClass *klass) +{ + SPObjectClass *sp_object_class = (SPObjectClass *)klass; + + feMorphology_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass); + + sp_object_class->build = sp_feMorphology_build; + sp_object_class->release = sp_feMorphology_release; + sp_object_class->write = sp_feMorphology_write; + sp_object_class->set = sp_feMorphology_set; + sp_object_class->update = sp_feMorphology_update; +} + +static void +sp_feMorphology_init(SPFeMorphology *feMorphology) +{ + debug("0x%p",feMorphology); +} + +/** + * Reads the Inkscape::XML::Node, and initializes SPFeMorphology variables. For this to get called, + * our name must be associated with a repr via "sp_object_type_register". Best done through + * sp-object-repr.cpp's repr_name_entries array. + */ +static void +sp_feMorphology_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +{ + debug("0x%p",object); + if (((SPObjectClass *) feMorphology_parent_class)->build) { + ((SPObjectClass *) feMorphology_parent_class)->build(object, document, repr); + } + + /*LOAD ATTRIBUTES FROM REPR HERE*/ +} + +/** + * Drops any allocated memory. + */ +static void +sp_feMorphology_release(SPObject *object) +{ + debug("0x%p",object); + + if (((SPObjectClass *) feMorphology_parent_class)->release) + ((SPObjectClass *) feMorphology_parent_class)->release(object); +} + +/** + * Sets a specific value in the SPFeMorphology. + */ +static void +sp_feMorphology_set(SPObject *object, unsigned int key, gchar const *value) +{ + debug("0x%p %s(%u): '%s'",object, + sp_attribute_name(key),key,value); + SPFeMorphology *feMorphology = SP_FEMORPHOLOGY(object); + + switch(key) { + /*DEAL WITH SETTING ATTRIBUTES HERE*/ + default: + if (((SPObjectClass *) feMorphology_parent_class)->set) + ((SPObjectClass *) feMorphology_parent_class)->set(object, key, value); + break; + } + +} + +/** + * Receives update notifications. + */ +static void +sp_feMorphology_update(SPObject *object, SPCtx *ctx, guint flags) +{ + debug("0x%p",object); + + if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | + SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { + + /* do something to trigger redisplay, updates? */ + + } + + if (((SPObjectClass *) feMorphology_parent_class)->update) { + ((SPObjectClass *) feMorphology_parent_class)->update(object, ctx, flags); + } +} + +/** + * Writes its settings to an incoming repr object, if any. + */ +static Inkscape::XML::Node * +sp_feMorphology_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) +{ + debug("0x%p",object); + + // Inkscape-only object, not copied during an "plain SVG" dump: + if (flags & SP_OBJECT_WRITE_EXT) { + if (repr) { + // is this sane? + repr->mergeFrom(SP_OBJECT_REPR(object), "id"); + } else { + repr = SP_OBJECT_REPR(object)->duplicate(); + } + } + + if (((SPObjectClass *) feMorphology_parent_class)->write) { + ((SPObjectClass *) feMorphology_parent_class)->write(object, repr, flags); + } + + return repr; +} + + +/* + 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/sp-femorphology.h b/src/sp-femorphology.h new file mode 100644 index 000000000..c810c0360 --- /dev/null +++ b/src/sp-femorphology.h @@ -0,0 +1,45 @@ +#ifndef SP_FEMORPHOLOGY_H_SEEN +#define SP_FEMORPHOLOGY_H_SEEN + +/** \file + * SVG implementation, see sp-feMorphology.cpp. + */ +/* + * Authors: + * Hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "sp-filter.h" +#include "sp-femorphology-fns.h" + +/* FeMorphology base class */ +class SPFeMorphologyClass; + +struct SPFeMorphology : public SPFilter { + /** MORPHOLOGY ATTRIBUTES HERE */ + +}; + +struct SPFeMorphologyClass { + SPFilterClass parent_class; +}; + +GType sp_feMorphology_get_type(); + + +#endif /* !SP_FEMORPHOLOGY_H_SEEN */ + +/* + 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/sp-feoffset-fns.h b/src/sp-feoffset-fns.h new file mode 100644 index 000000000..38561c188 --- /dev/null +++ b/src/sp-feoffset-fns.h @@ -0,0 +1,38 @@ +#ifndef SP_FEOFFSET_FNS_H +#define SP_FEOFFSET_FNS_H + +/** \file + * Macros and fn declarations related to gaussian blur filter. + */ + +#include +#include + +namespace Inkscape { +namespace XML { +class Node; +} +} + +class SPFeOffset; + +#define SP_TYPE_FEOFFSET (sp_feOffset_get_type()) +#define SP_FEOFFSET(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FEOFFSET, SPFeOffset)) +#define SP_FEOFFSET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FEOFFSET, SPFeOffsetClass)) +#define SP_IS_FEOFFSET(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FEOFFSET)) +#define SP_IS_FEOFFSET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FEOFFSET)) + +GType sp_feOffset_get_type(); + +#endif /* !SP_FEOFFSET_FNS_H */ + +/* + 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/sp-feoffset.cpp b/src/sp-feoffset.cpp new file mode 100644 index 000000000..3429ceb18 --- /dev/null +++ b/src/sp-feoffset.cpp @@ -0,0 +1,196 @@ +#define __SP_FEOFFSET_CPP__ + +/** \file + * SVG implementation. + * + */ +/* + * Authors: + * hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "attributes.h" +#include "svg/svg.h" +#include "sp-feoffset.h" +#include "xml/repr.h" + +//#define SP_MACROS_SILENT +//#include "macros.h" + +#define DEBUG_FEOFFSET +#ifdef DEBUG_FEOFFSET +# define debug(f, a...) { g_print("%s(%d) %s:", \ + __FILE__,__LINE__,__FUNCTION__); \ + g_print(f, ## a); \ + g_print("\n"); \ + } +#else +# define debug(f, a...) /**/ +#endif + +/* FeOffset base class */ + +static void sp_feOffset_class_init(SPFeOffsetClass *klass); +static void sp_feOffset_init(SPFeOffset *feOffset); + +static void sp_feOffset_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); +static void sp_feOffset_release(SPObject *object); +static void sp_feOffset_set(SPObject *object, unsigned int key, gchar const *value); +static void sp_feOffset_update(SPObject *object, SPCtx *ctx, guint flags); +static Inkscape::XML::Node *sp_feOffset_write(SPObject *object, Inkscape::XML::Node *repr, guint flags); + +static SPObjectClass *feOffset_parent_class; + +GType +sp_feOffset_get_type() +{ + static GType feOffset_type = 0; + + if (!feOffset_type) { + GTypeInfo feOffset_info = { + sizeof(SPFeOffsetClass), + NULL, NULL, + (GClassInitFunc) sp_feOffset_class_init, + NULL, NULL, + sizeof(SPFeOffset), + 16, + (GInstanceInitFunc) sp_feOffset_init, + NULL, /* value_table */ + }; + feOffset_type = g_type_register_static(SP_TYPE_OBJECT, "SPFeOffset", &feOffset_info, (GTypeFlags)0); + } + return feOffset_type; +} + +static void +sp_feOffset_class_init(SPFeOffsetClass *klass) +{ + SPObjectClass *sp_object_class = (SPObjectClass *)klass; + + feOffset_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass); + + sp_object_class->build = sp_feOffset_build; + sp_object_class->release = sp_feOffset_release; + sp_object_class->write = sp_feOffset_write; + sp_object_class->set = sp_feOffset_set; + sp_object_class->update = sp_feOffset_update; +} + +static void +sp_feOffset_init(SPFeOffset *feOffset) +{ + debug("0x%p",feOffset); +} + +/** + * Reads the Inkscape::XML::Node, and initializes SPFeOffset variables. For this to get called, + * our name must be associated with a repr via "sp_object_type_register". Best done through + * sp-object-repr.cpp's repr_name_entries array. + */ +static void +sp_feOffset_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +{ + debug("0x%p",object); + if (((SPObjectClass *) feOffset_parent_class)->build) { + ((SPObjectClass *) feOffset_parent_class)->build(object, document, repr); + } + + /*LOAD ATTRIBUTES FROM REPR HERE*/ +} + +/** + * Drops any allocated memory. + */ +static void +sp_feOffset_release(SPObject *object) +{ + debug("0x%p",object); + + if (((SPObjectClass *) feOffset_parent_class)->release) + ((SPObjectClass *) feOffset_parent_class)->release(object); +} + +/** + * Sets a specific value in the SPFeOffset. + */ +static void +sp_feOffset_set(SPObject *object, unsigned int key, gchar const *value) +{ + debug("0x%p %s(%u): '%s'",object, + sp_attribute_name(key),key,value); + SPFeOffset *feOffset = SP_FEOFFSET(object); + + switch(key) { + /*DEAL WITH SETTING ATTRIBUTES HERE*/ + default: + if (((SPObjectClass *) feOffset_parent_class)->set) + ((SPObjectClass *) feOffset_parent_class)->set(object, key, value); + break; + } + +} + +/** + * Receives update notifications. + */ +static void +sp_feOffset_update(SPObject *object, SPCtx *ctx, guint flags) +{ + debug("0x%p",object); + + if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | + SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { + + /* do something to trigger redisplay, updates? */ + + } + + if (((SPObjectClass *) feOffset_parent_class)->update) { + ((SPObjectClass *) feOffset_parent_class)->update(object, ctx, flags); + } +} + +/** + * Writes its settings to an incoming repr object, if any. + */ +static Inkscape::XML::Node * +sp_feOffset_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) +{ + debug("0x%p",object); + + // Inkscape-only object, not copied during an "plain SVG" dump: + if (flags & SP_OBJECT_WRITE_EXT) { + if (repr) { + // is this sane? + repr->mergeFrom(SP_OBJECT_REPR(object), "id"); + } else { + repr = SP_OBJECT_REPR(object)->duplicate(); + } + } + + if (((SPObjectClass *) feOffset_parent_class)->write) { + ((SPObjectClass *) feOffset_parent_class)->write(object, repr, flags); + } + + return repr; +} + + +/* + 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/sp-feoffset.h b/src/sp-feoffset.h new file mode 100644 index 000000000..7a5c2b783 --- /dev/null +++ b/src/sp-feoffset.h @@ -0,0 +1,45 @@ +#ifndef SP_FEOFFSET_H_SEEN +#define SP_FEOFFSET_H_SEEN + +/** \file + * SVG implementation, see sp-feOffset.cpp. + */ +/* + * Authors: + * Hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "sp-filter.h" +#include "sp-feoffset-fns.h" + +/* FeOffset base class */ +class SPFeOffsetClass; + +struct SPFeOffset : public SPFilter { + /** OFFSET ATTRIBUTES HERE */ + +}; + +struct SPFeOffsetClass { + SPFilterClass parent_class; +}; + +GType sp_feOffset_get_type(); + + +#endif /* !SP_FEOFFSET_H_SEEN */ + +/* + 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/sp-fespecularlighting-fns.h b/src/sp-fespecularlighting-fns.h new file mode 100644 index 000000000..bd48ba684 --- /dev/null +++ b/src/sp-fespecularlighting-fns.h @@ -0,0 +1,38 @@ +#ifndef SP_FESPECULARLIGHTING_FNS_H +#define SP_FESPECULARLIGHTING_FNS_H + +/** \file + * Macros and fn declarations related to gaussian blur filter. + */ + +#include +#include + +namespace Inkscape { +namespace XML { +class Node; +} +} + +class SPFeSpecularLighting; + +#define SP_TYPE_FESPECULARLIGHTING (sp_feSpecularLighting_get_type()) +#define SP_FESPECULARLIGHTING(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FESPECULARLIGHTING, SPFeSpecularLighting)) +#define SP_FESPECULARLIGHTING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FESPECULARLIGHTING, SPFeSpecularLightingClass)) +#define SP_IS_FESPECULARLIGHTING(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FESPECULARLIGHTING)) +#define SP_IS_FESPECULARLIGHTING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FESPECULARLIGHTING)) + +GType sp_feSpecularLighting_get_type(); + +#endif /* !SP_FESPECULARLIGHTING_FNS_H */ + +/* + 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/sp-fespecularlighting.cpp b/src/sp-fespecularlighting.cpp new file mode 100644 index 000000000..4fe25d48a --- /dev/null +++ b/src/sp-fespecularlighting.cpp @@ -0,0 +1,196 @@ +#define __SP_FESPECULARLIGHTING_CPP__ + +/** \file + * SVG implementation. + * + */ +/* + * Authors: + * hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "attributes.h" +#include "svg/svg.h" +#include "sp-fespecularlighting.h" +#include "xml/repr.h" + +//#define SP_MACROS_SILENT +//#include "macros.h" + +#define DEBUG_FESPECULARLIGHTING +#ifdef DEBUG_FESPECULARLIGHTING +# define debug(f, a...) { g_print("%s(%d) %s:", \ + __FILE__,__LINE__,__FUNCTION__); \ + g_print(f, ## a); \ + g_print("\n"); \ + } +#else +# define debug(f, a...) /**/ +#endif + +/* FeSpecularLighting base class */ + +static void sp_feSpecularLighting_class_init(SPFeSpecularLightingClass *klass); +static void sp_feSpecularLighting_init(SPFeSpecularLighting *feSpecularLighting); + +static void sp_feSpecularLighting_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); +static void sp_feSpecularLighting_release(SPObject *object); +static void sp_feSpecularLighting_set(SPObject *object, unsigned int key, gchar const *value); +static void sp_feSpecularLighting_update(SPObject *object, SPCtx *ctx, guint flags); +static Inkscape::XML::Node *sp_feSpecularLighting_write(SPObject *object, Inkscape::XML::Node *repr, guint flags); + +static SPObjectClass *feSpecularLighting_parent_class; + +GType +sp_feSpecularLighting_get_type() +{ + static GType feSpecularLighting_type = 0; + + if (!feSpecularLighting_type) { + GTypeInfo feSpecularLighting_info = { + sizeof(SPFeSpecularLightingClass), + NULL, NULL, + (GClassInitFunc) sp_feSpecularLighting_class_init, + NULL, NULL, + sizeof(SPFeSpecularLighting), + 16, + (GInstanceInitFunc) sp_feSpecularLighting_init, + NULL, /* value_table */ + }; + feSpecularLighting_type = g_type_register_static(SP_TYPE_OBJECT, "SPFeSpecularLighting", &feSpecularLighting_info, (GTypeFlags)0); + } + return feSpecularLighting_type; +} + +static void +sp_feSpecularLighting_class_init(SPFeSpecularLightingClass *klass) +{ + SPObjectClass *sp_object_class = (SPObjectClass *)klass; + + feSpecularLighting_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass); + + sp_object_class->build = sp_feSpecularLighting_build; + sp_object_class->release = sp_feSpecularLighting_release; + sp_object_class->write = sp_feSpecularLighting_write; + sp_object_class->set = sp_feSpecularLighting_set; + sp_object_class->update = sp_feSpecularLighting_update; +} + +static void +sp_feSpecularLighting_init(SPFeSpecularLighting *feSpecularLighting) +{ + debug("0x%p",feSpecularLighting); +} + +/** + * Reads the Inkscape::XML::Node, and initializes SPFeSpecularLighting variables. For this to get called, + * our name must be associated with a repr via "sp_object_type_register". Best done through + * sp-object-repr.cpp's repr_name_entries array. + */ +static void +sp_feSpecularLighting_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +{ + debug("0x%p",object); + if (((SPObjectClass *) feSpecularLighting_parent_class)->build) { + ((SPObjectClass *) feSpecularLighting_parent_class)->build(object, document, repr); + } + + /*LOAD ATTRIBUTES FROM REPR HERE*/ +} + +/** + * Drops any allocated memory. + */ +static void +sp_feSpecularLighting_release(SPObject *object) +{ + debug("0x%p",object); + + if (((SPObjectClass *) feSpecularLighting_parent_class)->release) + ((SPObjectClass *) feSpecularLighting_parent_class)->release(object); +} + +/** + * Sets a specific value in the SPFeSpecularLighting. + */ +static void +sp_feSpecularLighting_set(SPObject *object, unsigned int key, gchar const *value) +{ + debug("0x%p %s(%u): '%s'",object, + sp_attribute_name(key),key,value); + SPFeSpecularLighting *feSpecularLighting = SP_FESPECULARLIGHTING(object); + + switch(key) { + /*DEAL WITH SETTING ATTRIBUTES HERE*/ + default: + if (((SPObjectClass *) feSpecularLighting_parent_class)->set) + ((SPObjectClass *) feSpecularLighting_parent_class)->set(object, key, value); + break; + } + +} + +/** + * Receives update notifications. + */ +static void +sp_feSpecularLighting_update(SPObject *object, SPCtx *ctx, guint flags) +{ + debug("0x%p",object); + + if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | + SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { + + /* do something to trigger redisplay, updates? */ + + } + + if (((SPObjectClass *) feSpecularLighting_parent_class)->update) { + ((SPObjectClass *) feSpecularLighting_parent_class)->update(object, ctx, flags); + } +} + +/** + * Writes its settings to an incoming repr object, if any. + */ +static Inkscape::XML::Node * +sp_feSpecularLighting_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) +{ + debug("0x%p",object); + + // Inkscape-only object, not copied during an "plain SVG" dump: + if (flags & SP_OBJECT_WRITE_EXT) { + if (repr) { + // is this sane? + repr->mergeFrom(SP_OBJECT_REPR(object), "id"); + } else { + repr = SP_OBJECT_REPR(object)->duplicate(); + } + } + + if (((SPObjectClass *) feSpecularLighting_parent_class)->write) { + ((SPObjectClass *) feSpecularLighting_parent_class)->write(object, repr, flags); + } + + return repr; +} + + +/* + 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/sp-fespecularlighting.h b/src/sp-fespecularlighting.h new file mode 100644 index 000000000..885215b89 --- /dev/null +++ b/src/sp-fespecularlighting.h @@ -0,0 +1,45 @@ +#ifndef SP_FESPECULARLIGHTING_H_SEEN +#define SP_FESPECULARLIGHTING_H_SEEN + +/** \file + * SVG implementation, see sp-feSpecularLighting.cpp. + */ +/* + * Authors: + * Hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "sp-filter.h" +#include "sp-fespecularlighting-fns.h" + +/* FeSpecularLighting base class */ +class SPFeSpecularLightingClass; + +struct SPFeSpecularLighting : public SPFilter { + /** SPECULARLIGHTING ATTRIBUTES HERE */ + +}; + +struct SPFeSpecularLightingClass { + SPFilterClass parent_class; +}; + +GType sp_feSpecularLighting_get_type(); + + +#endif /* !SP_FESPECULARLIGHTING_H_SEEN */ + +/* + 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/sp-fetile-fns.h b/src/sp-fetile-fns.h new file mode 100644 index 000000000..b7c4c5f27 --- /dev/null +++ b/src/sp-fetile-fns.h @@ -0,0 +1,38 @@ +#ifndef SP_FETILE_FNS_H +#define SP_FETILE_FNS_H + +/** \file + * Macros and fn declarations related to gaussian blur filter. + */ + +#include +#include + +namespace Inkscape { +namespace XML { +class Node; +} +} + +class SPFeTile; + +#define SP_TYPE_FETILE (sp_feTile_get_type()) +#define SP_FETILE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FETILE, SPFeTile)) +#define SP_FETILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FETILE, SPFeTileClass)) +#define SP_IS_FETILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FETILE)) +#define SP_IS_FETILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FETILE)) + +GType sp_feTile_get_type(); + +#endif /* !SP_FETILE_FNS_H */ + +/* + 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/sp-fetile.cpp b/src/sp-fetile.cpp new file mode 100644 index 000000000..a11fbc020 --- /dev/null +++ b/src/sp-fetile.cpp @@ -0,0 +1,196 @@ +#define __SP_FETILE_CPP__ + +/** \file + * SVG implementation. + * + */ +/* + * Authors: + * hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "attributes.h" +#include "svg/svg.h" +#include "sp-fetile.h" +#include "xml/repr.h" + +//#define SP_MACROS_SILENT +//#include "macros.h" + +#define DEBUG_FETILE +#ifdef DEBUG_FETILE +# define debug(f, a...) { g_print("%s(%d) %s:", \ + __FILE__,__LINE__,__FUNCTION__); \ + g_print(f, ## a); \ + g_print("\n"); \ + } +#else +# define debug(f, a...) /**/ +#endif + +/* FeTile base class */ + +static void sp_feTile_class_init(SPFeTileClass *klass); +static void sp_feTile_init(SPFeTile *feTile); + +static void sp_feTile_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); +static void sp_feTile_release(SPObject *object); +static void sp_feTile_set(SPObject *object, unsigned int key, gchar const *value); +static void sp_feTile_update(SPObject *object, SPCtx *ctx, guint flags); +static Inkscape::XML::Node *sp_feTile_write(SPObject *object, Inkscape::XML::Node *repr, guint flags); + +static SPObjectClass *feTile_parent_class; + +GType +sp_feTile_get_type() +{ + static GType feTile_type = 0; + + if (!feTile_type) { + GTypeInfo feTile_info = { + sizeof(SPFeTileClass), + NULL, NULL, + (GClassInitFunc) sp_feTile_class_init, + NULL, NULL, + sizeof(SPFeTile), + 16, + (GInstanceInitFunc) sp_feTile_init, + NULL, /* value_table */ + }; + feTile_type = g_type_register_static(SP_TYPE_OBJECT, "SPFeTile", &feTile_info, (GTypeFlags)0); + } + return feTile_type; +} + +static void +sp_feTile_class_init(SPFeTileClass *klass) +{ + SPObjectClass *sp_object_class = (SPObjectClass *)klass; + + feTile_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass); + + sp_object_class->build = sp_feTile_build; + sp_object_class->release = sp_feTile_release; + sp_object_class->write = sp_feTile_write; + sp_object_class->set = sp_feTile_set; + sp_object_class->update = sp_feTile_update; +} + +static void +sp_feTile_init(SPFeTile *feTile) +{ + debug("0x%p",feTile); +} + +/** + * Reads the Inkscape::XML::Node, and initializes SPFeTile variables. For this to get called, + * our name must be associated with a repr via "sp_object_type_register". Best done through + * sp-object-repr.cpp's repr_name_entries array. + */ +static void +sp_feTile_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +{ + debug("0x%p",object); + if (((SPObjectClass *) feTile_parent_class)->build) { + ((SPObjectClass *) feTile_parent_class)->build(object, document, repr); + } + + /*LOAD ATTRIBUTES FROM REPR HERE*/ +} + +/** + * Drops any allocated memory. + */ +static void +sp_feTile_release(SPObject *object) +{ + debug("0x%p",object); + + if (((SPObjectClass *) feTile_parent_class)->release) + ((SPObjectClass *) feTile_parent_class)->release(object); +} + +/** + * Sets a specific value in the SPFeTile. + */ +static void +sp_feTile_set(SPObject *object, unsigned int key, gchar const *value) +{ + debug("0x%p %s(%u): '%s'",object, + sp_attribute_name(key),key,value); + SPFeTile *feTile = SP_FETILE(object); + + switch(key) { + /*DEAL WITH SETTING ATTRIBUTES HERE*/ + default: + if (((SPObjectClass *) feTile_parent_class)->set) + ((SPObjectClass *) feTile_parent_class)->set(object, key, value); + break; + } + +} + +/** + * Receives update notifications. + */ +static void +sp_feTile_update(SPObject *object, SPCtx *ctx, guint flags) +{ + debug("0x%p",object); + + if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | + SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { + + /* do something to trigger redisplay, updates? */ + + } + + if (((SPObjectClass *) feTile_parent_class)->update) { + ((SPObjectClass *) feTile_parent_class)->update(object, ctx, flags); + } +} + +/** + * Writes its settings to an incoming repr object, if any. + */ +static Inkscape::XML::Node * +sp_feTile_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) +{ + debug("0x%p",object); + + // Inkscape-only object, not copied during an "plain SVG" dump: + if (flags & SP_OBJECT_WRITE_EXT) { + if (repr) { + // is this sane? + repr->mergeFrom(SP_OBJECT_REPR(object), "id"); + } else { + repr = SP_OBJECT_REPR(object)->duplicate(); + } + } + + if (((SPObjectClass *) feTile_parent_class)->write) { + ((SPObjectClass *) feTile_parent_class)->write(object, repr, flags); + } + + return repr; +} + + +/* + 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/sp-fetile.h b/src/sp-fetile.h new file mode 100644 index 000000000..4cec1c3aa --- /dev/null +++ b/src/sp-fetile.h @@ -0,0 +1,45 @@ +#ifndef SP_FETILE_H_SEEN +#define SP_FETILE_H_SEEN + +/** \file + * SVG implementation, see sp-feTile.cpp. + */ +/* + * Authors: + * Hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "sp-filter.h" +#include "sp-fetile-fns.h" + +/* FeTile base class */ +class SPFeTileClass; + +struct SPFeTile : public SPFilter { + /** TILE ATTRIBUTES HERE */ + +}; + +struct SPFeTileClass { + SPFilterClass parent_class; +}; + +GType sp_feTile_get_type(); + + +#endif /* !SP_FETILE_H_SEEN */ + +/* + 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/sp-feturbulence-fns.h b/src/sp-feturbulence-fns.h new file mode 100644 index 000000000..43b4450a5 --- /dev/null +++ b/src/sp-feturbulence-fns.h @@ -0,0 +1,38 @@ +#ifndef SP_FETURBULENCE_FNS_H +#define SP_FETURBULENCE_FNS_H + +/** \file + * Macros and fn declarations related to gaussian blur filter. + */ + +#include +#include + +namespace Inkscape { +namespace XML { +class Node; +} +} + +class SPFeTurbulence; + +#define SP_TYPE_FETURBULENCE (sp_feTurbulence_get_type()) +#define SP_FETURBULENCE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_FETURBULENCE, SPFeTurbulence)) +#define SP_FETURBULENCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_FETURBULENCE, SPFeTurbulenceClass)) +#define SP_IS_FETURBULENCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_FETURBULENCE)) +#define SP_IS_FETURBULENCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_FETURBULENCE)) + +GType sp_feTurbulence_get_type(); + +#endif /* !SP_FETURBULENCE_FNS_H */ + +/* + 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/sp-feturbulence.cpp b/src/sp-feturbulence.cpp new file mode 100644 index 000000000..0122f1f20 --- /dev/null +++ b/src/sp-feturbulence.cpp @@ -0,0 +1,196 @@ +#define __SP_FETURBULENCE_CPP__ + +/** \file + * SVG implementation. + * + */ +/* + * Authors: + * hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "attributes.h" +#include "svg/svg.h" +#include "sp-feturbulence.h" +#include "xml/repr.h" + +//#define SP_MACROS_SILENT +//#include "macros.h" + +#define DEBUG_FETURBULENCE +#ifdef DEBUG_FETURBULENCE +# define debug(f, a...) { g_print("%s(%d) %s:", \ + __FILE__,__LINE__,__FUNCTION__); \ + g_print(f, ## a); \ + g_print("\n"); \ + } +#else +# define debug(f, a...) /**/ +#endif + +/* FeTurbulence base class */ + +static void sp_feTurbulence_class_init(SPFeTurbulenceClass *klass); +static void sp_feTurbulence_init(SPFeTurbulence *feTurbulence); + +static void sp_feTurbulence_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); +static void sp_feTurbulence_release(SPObject *object); +static void sp_feTurbulence_set(SPObject *object, unsigned int key, gchar const *value); +static void sp_feTurbulence_update(SPObject *object, SPCtx *ctx, guint flags); +static Inkscape::XML::Node *sp_feTurbulence_write(SPObject *object, Inkscape::XML::Node *repr, guint flags); + +static SPObjectClass *feTurbulence_parent_class; + +GType +sp_feTurbulence_get_type() +{ + static GType feTurbulence_type = 0; + + if (!feTurbulence_type) { + GTypeInfo feTurbulence_info = { + sizeof(SPFeTurbulenceClass), + NULL, NULL, + (GClassInitFunc) sp_feTurbulence_class_init, + NULL, NULL, + sizeof(SPFeTurbulence), + 16, + (GInstanceInitFunc) sp_feTurbulence_init, + NULL, /* value_table */ + }; + feTurbulence_type = g_type_register_static(SP_TYPE_OBJECT, "SPFeTurbulence", &feTurbulence_info, (GTypeFlags)0); + } + return feTurbulence_type; +} + +static void +sp_feTurbulence_class_init(SPFeTurbulenceClass *klass) +{ + SPObjectClass *sp_object_class = (SPObjectClass *)klass; + + feTurbulence_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass); + + sp_object_class->build = sp_feTurbulence_build; + sp_object_class->release = sp_feTurbulence_release; + sp_object_class->write = sp_feTurbulence_write; + sp_object_class->set = sp_feTurbulence_set; + sp_object_class->update = sp_feTurbulence_update; +} + +static void +sp_feTurbulence_init(SPFeTurbulence *feTurbulence) +{ + debug("0x%p",feTurbulence); +} + +/** + * Reads the Inkscape::XML::Node, and initializes SPFeTurbulence variables. For this to get called, + * our name must be associated with a repr via "sp_object_type_register". Best done through + * sp-object-repr.cpp's repr_name_entries array. + */ +static void +sp_feTurbulence_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +{ + debug("0x%p",object); + if (((SPObjectClass *) feTurbulence_parent_class)->build) { + ((SPObjectClass *) feTurbulence_parent_class)->build(object, document, repr); + } + + /*LOAD ATTRIBUTES FROM REPR HERE*/ +} + +/** + * Drops any allocated memory. + */ +static void +sp_feTurbulence_release(SPObject *object) +{ + debug("0x%p",object); + + if (((SPObjectClass *) feTurbulence_parent_class)->release) + ((SPObjectClass *) feTurbulence_parent_class)->release(object); +} + +/** + * Sets a specific value in the SPFeTurbulence. + */ +static void +sp_feTurbulence_set(SPObject *object, unsigned int key, gchar const *value) +{ + debug("0x%p %s(%u): '%s'",object, + sp_attribute_name(key),key,value); + SPFeTurbulence *feTurbulence = SP_FETURBULENCE(object); + + switch(key) { + /*DEAL WITH SETTING ATTRIBUTES HERE*/ + default: + if (((SPObjectClass *) feTurbulence_parent_class)->set) + ((SPObjectClass *) feTurbulence_parent_class)->set(object, key, value); + break; + } + +} + +/** + * Receives update notifications. + */ +static void +sp_feTurbulence_update(SPObject *object, SPCtx *ctx, guint flags) +{ + debug("0x%p",object); + + if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | + SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { + + /* do something to trigger redisplay, updates? */ + + } + + if (((SPObjectClass *) feTurbulence_parent_class)->update) { + ((SPObjectClass *) feTurbulence_parent_class)->update(object, ctx, flags); + } +} + +/** + * Writes its settings to an incoming repr object, if any. + */ +static Inkscape::XML::Node * +sp_feTurbulence_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) +{ + debug("0x%p",object); + + // Inkscape-only object, not copied during an "plain SVG" dump: + if (flags & SP_OBJECT_WRITE_EXT) { + if (repr) { + // is this sane? + repr->mergeFrom(SP_OBJECT_REPR(object), "id"); + } else { + repr = SP_OBJECT_REPR(object)->duplicate(); + } + } + + if (((SPObjectClass *) feTurbulence_parent_class)->write) { + ((SPObjectClass *) feTurbulence_parent_class)->write(object, repr, flags); + } + + return repr; +} + + +/* + 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/sp-feturbulence.h b/src/sp-feturbulence.h new file mode 100644 index 000000000..9040e7a99 --- /dev/null +++ b/src/sp-feturbulence.h @@ -0,0 +1,45 @@ +#ifndef SP_FETURBULENCE_H_SEEN +#define SP_FETURBULENCE_H_SEEN + +/** \file + * SVG implementation, see sp-feTurbulence.cpp. + */ +/* + * Authors: + * Hugo Rodrigues + * + * Copyright (C) 2006 Hugo Rodrigues + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "sp-filter.h" +#include "sp-feturbulence-fns.h" + +/* FeTurbulence base class */ +class SPFeTurbulenceClass; + +struct SPFeTurbulence : public SPFilter { + /** TURBULENCE ATTRIBUTES HERE */ + +}; + +struct SPFeTurbulenceClass { + SPFilterClass parent_class; +}; + +GType sp_feTurbulence_get_type(); + + +#endif /* !SP_FETURBULENCE_H_SEEN */ + +/* + 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/sp-object-repr.cpp b/src/sp-object-repr.cpp index 4ffbce04f..2ab53163a 100644 --- a/src/sp-object-repr.cpp +++ b/src/sp-object-repr.cpp @@ -45,6 +45,21 @@ #include "xml/repr.h" #include "sp-filter.h" #include "sp-gaussian-blur.h" +#include "sp-feblend.h" +#include "sp-fecolormatrix.h" +#include "sp-fecomponenttransfer.h" +#include "sp-fecomposite.h" +#include "sp-feconvolvematrix.h" +#include "sp-fediffuselighting.h" +#include "sp-fedisplacementmap.h" +#include "sp-feflood.h" +#include "sp-feimage.h" +#include "sp-femerge.h" +#include "sp-femorphology.h" +#include "sp-feoffset.h" +#include "sp-fespecularlighting.h" +#include "sp-fetile.h" +#include "sp-feturbulence.h" enum NameType { REPR_NAME, SODIPODI_TYPE }; static unsigned const N_NAME_TYPES = SODIPODI_TYPE + 1; @@ -114,7 +129,22 @@ populate_dtables() { "svg:flowRoot", SP_TYPE_FLOWTEXT }, { "svg:flowSpan", SP_TYPE_FLOWTSPAN }, { "svg:g", SP_TYPE_GROUP }, - { "svg:gaussianBlur", SP_TYPE_GAUSSIANBLUR }, + { "feBlend", SP_TYPE_FEBLEND }, + { "feColorMatrix", SP_TYPE_FECOLORMATRIX }, + { "feComponentTransfer", SP_TYPE_FECOMPONENTTRANSFER }, + { "feComposite", SP_TYPE_FECOMPOSITE }, + { "feConvolveMatrix", SP_TYPE_FECONVOLVEMATRIX }, + { "feDiffuseLighting", SP_TYPE_FEDIFFUSELIGHTING }, + { "feDisplacementMap", SP_TYPE_FEDISPLACEMENTMAP }, + { "feFlood", SP_TYPE_FEFLOOD }, + { "feGaussianBlur", SP_TYPE_GAUSSIANBLUR }, + { "feImage", SP_TYPE_FEIMAGE }, + { "feMerge", SP_TYPE_FEMERGE }, + { "feMorphology", SP_TYPE_FEMORPHOLOGY }, + { "feOffset", SP_TYPE_FEOFFSET }, + { "feSpecularLighting", SP_TYPE_FESPECULARLIGHTING }, + { "feTile", SP_TYPE_FETILE }, + { "feTurbulence", SP_TYPE_FETURBULENCE }, { "svg:image", SP_TYPE_IMAGE }, { "svg:line", SP_TYPE_LINE }, { "svg:linearGradient", SP_TYPE_LINEARGRADIENT }, diff --git a/src/style.cpp b/src/style.cpp index 0eb8b0869..bd880b857 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -118,7 +118,7 @@ static void sp_style_clear(SPStyle *style); static void sp_style_merge_property(SPStyle *style, gint id, gchar const *val); static void sp_style_merge_ipaint(SPStyle *style, SPIPaint *paint, SPIPaint const *parent); -static void sp_style_merge_ifilter(SPIFilter *child, SPIFilter const *parent); +static void sp_style_merge_ifilter(SPStyle *style, SPIFilter *child, SPIFilter const *parent); static void sp_style_read_dash(SPStyle *style, gchar const *str); static SPTextStyle *sp_text_style_new(void); @@ -138,7 +138,7 @@ static void sp_style_read_itextdecoration(SPITextDecoration *val, gchar const *s static void sp_style_read_icolor(SPIPaint *paint, gchar const *str, SPStyle *style, SPDocument *document); static void sp_style_read_ipaint(SPIPaint *paint, gchar const *str, SPStyle *style, SPDocument *document); static void sp_style_read_ifontsize(SPIFontSize *val, gchar const *str); -static void sp_style_read_ifilter(SPIFilter *f, gchar const *str, SPDocument *document); +static void sp_style_read_ifilter(SPIFilter *f, gchar const *str, SPStyle *style, SPDocument *document); static void sp_style_read_penum(SPIEnum *val, Inkscape::XML::Node *repr, gchar const *key, SPStyleEnum const *dict, bool can_explicitly_inherit); static void sp_style_read_plength(SPILength *val, Inkscape::XML::Node *repr, gchar const *key); @@ -160,6 +160,8 @@ static void css2_unescape_unquote(SPIString *val); static void sp_style_paint_clear(SPStyle *style, SPIPaint *paint); +static void sp_style_filter_clear(SPStyle *style, SPIFilter *filter); + #define SPS_READ_IENUM_IF_UNSET(v,s,d,i) if (!(v)->set) {sp_style_read_ienum((v), (s), (d), (i));} #define SPS_READ_PENUM_IF_UNSET(v,r,k,d,i) if (!(v)->set) {sp_style_read_penum((v), (r), (k), (d), (i));} @@ -409,6 +411,7 @@ sp_style_new() style->fill_hreffed = false; style->stroke_hreffed = false; + style->filter_hreffed = false; new (&style->release_connection) sigc::connection(); @@ -475,6 +478,7 @@ sp_style_unref(SPStyle *style) if (style->text) sp_text_style_unref(style->text); sp_style_paint_clear(style, &style->fill); sp_style_paint_clear(style, &style->stroke); + sp_style_filter_clear(style, &style->filter); style->fill_release_connection.disconnect(); style->fill_release_connection.~connection(); style->fill_modified_connection.disconnect(); @@ -676,8 +680,7 @@ sp_style_read(SPStyle *style, SPObject *object, Inkscape::XML::Node *repr) if (!style->filter.set) { val = repr->attribute("filter"); if (val) { - sp_style_read_ifilter(&style->filter, val, - (object) ? SP_OBJECT_DOCUMENT(object) : NULL); + sp_style_read_ifilter(&style->filter, val, style, (object) ? SP_OBJECT_DOCUMENT(object) : NULL); } } SPS_READ_PENUM_IF_UNSET(&style->enable_background, repr, @@ -917,7 +920,7 @@ sp_style_merge_property(SPStyle *style, gint id, gchar const *val) /* Filter */ case SP_PROP_FILTER: if (!style->filter.set && !style->filter.inherit) { - sp_style_read_ifilter(&style->filter, val, (style->object) ? SP_OBJECT_DOCUMENT(style->object) : NULL); + sp_style_read_ifilter(&style->filter, val, style, (style->object) ? SP_OBJECT_DOCUMENT(style->object) : NULL); } break; case SP_PROP_FLOOD_COLOR: @@ -1456,7 +1459,7 @@ sp_style_merge_from_parent(SPStyle *const style, SPStyle const *const parent) /* Filter effects */ if(style->filter.set && style->filter.inherit) { - sp_style_merge_ifilter(&style->filter, &parent->filter); + sp_style_merge_ifilter(style, &style->filter, &parent->filter); } if(style->enable_background.inherit) { @@ -2113,12 +2116,15 @@ sp_style_merge_ipaint(SPStyle *style, SPIPaint *paint, SPIPaint const *parent) * Filter effects do not inherit by default */ static void -sp_style_merge_ifilter(SPIFilter *child, SPIFilter const *parent) +sp_style_merge_ifilter(SPStyle *style, SPIFilter *child, SPIFilter const *parent) { + sp_style_filter_clear(style, child); child->set = parent->set; child->inherit = parent->inherit; child->filter = parent->filter; child->uri = parent->uri; + sp_object_href(SP_OBJECT(child), style); + style->filter_hreffed = true; } /** @@ -2397,6 +2403,7 @@ sp_style_clear(SPStyle *style) sp_style_paint_clear(style, &style->fill); sp_style_paint_clear(style, &style->stroke); + sp_style_filter_clear(style, &style->filter); if (style->stroke_dash.dash) { g_free(style->stroke_dash.dash); } @@ -3100,7 +3107,7 @@ sp_style_read_ifontsize(SPIFontSize *val, gchar const *str) * Set SPIFilter object from string. */ static void -sp_style_read_ifilter(SPIFilter *f, gchar const *str, SPDocument *document) +sp_style_read_ifilter( SPIFilter *f, gchar const *str, SPStyle * style, SPDocument *document) { /* Try all possible values: inherit, none, uri */ if (streq(str, "inherit")) { @@ -3128,10 +3135,12 @@ sp_style_read_ifilter(SPIFilter *f, gchar const *str, SPDocument *document) obj = sp_uri_reference_resolve(document, str); if (SP_IS_FILTER(obj)) { f->filter = SP_FILTER(obj); + sp_object_href(SP_OBJECT(f->filter), style); + style->filter_hreffed = true; //g_signal_connect(G_OBJECT(f->filter), "release", - // G_CALLBACK(sp_style_filter_release), style); + // G_CALLBACK(sp_style_filter_release), style); //g_signal_connect(G_OBJECT(f->filter), "modified", - // G_CALLBACK(sp_style_filter_modified), style); + // G_CALLBACK(sp_style_filter_modified), style); } else { g_warning("Element '%s' not found or is not a filter", f->uri); } @@ -3664,6 +3673,26 @@ sp_style_paint_clear(SPStyle *style, SPIPaint *paint) paint->iccColor = NULL; } + +/** + * Clear filter object, and disconnect style from paintserver (if present). + */ +static void +sp_style_filter_clear(SPStyle *style, SPIFilter *f) +{ + + if (style->filter_hreffed) { + sp_object_hunref(SP_OBJECT(f->filter), style); + style->filter_hreffed = false; + } + //style->fill_release_connection.disconnect(); + //style->fill_modified_connection.disconnect(); + + f->filter = NULL; + +} + + /** * Clear all style property attributes in object. */ diff --git a/src/style.h b/src/style.h index 1cc4b5a10..a200a970f 100644 --- a/src/style.h +++ b/src/style.h @@ -345,6 +345,7 @@ struct SPStyle { /// style has hreffed its fill/stroke paintservers, needs to release. bool fill_hreffed; bool stroke_hreffed; + bool filter_hreffed; sigc::connection release_connection; -- 2.30.2