1 #define __SP_FETURBULENCE_CPP__
3 /** \file
4 * SVG <feTurbulence> implementation.
5 *
6 */
7 /*
8 * Authors:
9 * hugo Rodrigues <haa.rodrigues@gmail.com>
10 *
11 * Copyright (C) 2006 Hugo Rodrigues
12 *
13 * Released under GNU GPL, read the file 'COPYING' for more information
14 */
16 #ifdef HAVE_CONFIG_H
17 # include "config.h"
18 #endif
20 #include "attributes.h"
21 #include "svg/svg.h"
22 #include "sp-feturbulence.h"
23 #include "xml/repr.h"
26 /* FeTurbulence base class */
28 static void sp_feTurbulence_class_init(SPFeTurbulenceClass *klass);
29 static void sp_feTurbulence_init(SPFeTurbulence *feTurbulence);
31 static void sp_feTurbulence_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
32 static void sp_feTurbulence_release(SPObject *object);
33 static void sp_feTurbulence_set(SPObject *object, unsigned int key, gchar const *value);
34 static void sp_feTurbulence_update(SPObject *object, SPCtx *ctx, guint flags);
35 static Inkscape::XML::Node *sp_feTurbulence_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
37 static SPFilterPrimitiveClass *feTurbulence_parent_class;
39 GType
40 sp_feTurbulence_get_type()
41 {
42 static GType feTurbulence_type = 0;
44 if (!feTurbulence_type) {
45 GTypeInfo feTurbulence_info = {
46 sizeof(SPFeTurbulenceClass),
47 NULL, NULL,
48 (GClassInitFunc) sp_feTurbulence_class_init,
49 NULL, NULL,
50 sizeof(SPFeTurbulence),
51 16,
52 (GInstanceInitFunc) sp_feTurbulence_init,
53 NULL, /* value_table */
54 };
55 feTurbulence_type = g_type_register_static(SP_TYPE_FILTER_PRIMITIVE, "SPFeTurbulence", &feTurbulence_info, (GTypeFlags)0);
56 }
57 return feTurbulence_type;
58 }
60 static void
61 sp_feTurbulence_class_init(SPFeTurbulenceClass *klass)
62 {
63 SPObjectClass *sp_object_class = (SPObjectClass *)klass;
65 feTurbulence_parent_class = (SPFilterPrimitiveClass*)g_type_class_peek_parent(klass);
67 sp_object_class->build = sp_feTurbulence_build;
68 sp_object_class->release = sp_feTurbulence_release;
69 sp_object_class->write = sp_feTurbulence_write;
70 sp_object_class->set = sp_feTurbulence_set;
71 sp_object_class->update = sp_feTurbulence_update;
72 }
74 static void
75 sp_feTurbulence_init(SPFeTurbulence *feTurbulence)
76 {
77 }
79 /**
80 * Reads the Inkscape::XML::Node, and initializes SPFeTurbulence variables. For this to get called,
81 * our name must be associated with a repr via "sp_object_type_register". Best done through
82 * sp-object-repr.cpp's repr_name_entries array.
83 */
84 static void
85 sp_feTurbulence_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
86 {
87 if (((SPObjectClass *) feTurbulence_parent_class)->build) {
88 ((SPObjectClass *) feTurbulence_parent_class)->build(object, document, repr);
89 }
91 /*LOAD ATTRIBUTES FROM REPR HERE*/
92 }
94 /**
95 * Drops any allocated memory.
96 */
97 static void
98 sp_feTurbulence_release(SPObject *object)
99 {
100 if (((SPObjectClass *) feTurbulence_parent_class)->release)
101 ((SPObjectClass *) feTurbulence_parent_class)->release(object);
102 }
104 /**
105 * Sets a specific value in the SPFeTurbulence.
106 */
107 static void
108 sp_feTurbulence_set(SPObject *object, unsigned int key, gchar const *value)
109 {
110 SPFeTurbulence *feTurbulence = SP_FETURBULENCE(object);
112 switch(key) {\r
113 /*DEAL WITH SETTING ATTRIBUTES HERE*/
114 default:
115 if (((SPObjectClass *) feTurbulence_parent_class)->set)
116 ((SPObjectClass *) feTurbulence_parent_class)->set(object, key, value);
117 break;
118 }
120 }
122 /**
123 * Receives update notifications.
124 */
125 static void
126 sp_feTurbulence_update(SPObject *object, SPCtx *ctx, guint flags)
127 {
128 if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG |
129 SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
131 /* do something to trigger redisplay, updates? */
133 }
135 if (((SPObjectClass *) feTurbulence_parent_class)->update) {
136 ((SPObjectClass *) feTurbulence_parent_class)->update(object, ctx, flags);
137 }
138 }
140 /**
141 * Writes its settings to an incoming repr object, if any.
142 */
143 static Inkscape::XML::Node *
144 sp_feTurbulence_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
145 {
146 // Inkscape-only object, not copied during an "plain SVG" dump:
147 if (flags & SP_OBJECT_WRITE_EXT) {
148 if (repr) {
149 // is this sane?
150 repr->mergeFrom(SP_OBJECT_REPR(object), "id");
151 } else {
152 repr = SP_OBJECT_REPR(object)->duplicate();
153 }
154 }
156 if (((SPObjectClass *) feTurbulence_parent_class)->write) {
157 ((SPObjectClass *) feTurbulence_parent_class)->write(object, repr, flags);
158 }
160 return repr;
161 }
164 /*
165 Local Variables:
166 mode:c++
167 c-file-style:"stroustrup"
168 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
169 indent-tabs-mode:nil
170 fill-column:99
171 End:
172 */
173 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :