Code

restored pedro/work and added it to make.exclude
[inkscape.git] / src / sp-gaussian-blur.cpp
1 #define __SP_GAUSSIANBLUR_CPP__
3 /** \file
4  * SVG <gaussianBlur> 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-gaussian-blur.h"
23 #include "xml/repr.h"
25 //#define SP_MACROS_SILENT
26 //#include "macros.h"
28 #define DEBUG_GAUSSIANBLUR
29 #ifdef DEBUG_GAUSSIANBLUR
30 # define debug(f, a...) { g_print("%s(%d) %s:", \
31                                   __FILE__,__LINE__,__FUNCTION__); \
32                           g_print(f, ## a); \
33                           g_print("\n"); \
34                         }
35 #else
36 # define debug(f, a...) /**/
37 #endif
39 /* GaussianBlur base class */
41 static void sp_gaussianBlur_class_init(SPGaussianBlurClass *klass);
42 static void sp_gaussianBlur_init(SPGaussianBlur *gaussianBlur);
44 static void sp_gaussianBlur_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
45 static void sp_gaussianBlur_release(SPObject *object);
46 static void sp_gaussianBlur_set(SPObject *object, unsigned int key, gchar const *value);
47 static void sp_gaussianBlur_update(SPObject *object, SPCtx *ctx, guint flags);
48 static Inkscape::XML::Node *sp_gaussianBlur_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
50 static SPObjectClass *gaussianBlur_parent_class;
52 GType
53 sp_gaussianBlur_get_type()
54 {
55     static GType gaussianBlur_type = 0;
57     if (!gaussianBlur_type) {
58         GTypeInfo gaussianBlur_info = {
59             sizeof(SPGaussianBlurClass),
60             NULL, NULL,
61             (GClassInitFunc) sp_gaussianBlur_class_init,
62             NULL, NULL,
63             sizeof(SPGaussianBlur),
64             16,
65             (GInstanceInitFunc) sp_gaussianBlur_init,
66             NULL,    /* value_table */
67         };
68         gaussianBlur_type = g_type_register_static(SP_TYPE_OBJECT, "SPGaussianBlur", &gaussianBlur_info, (GTypeFlags)0);
69     }
70     return gaussianBlur_type;
71 }
73 static void
74 sp_gaussianBlur_class_init(SPGaussianBlurClass *klass)
75 {
76     SPObjectClass *sp_object_class = (SPObjectClass *)klass;
78     gaussianBlur_parent_class = (SPObjectClass*)g_type_class_peek_parent(klass);
80     sp_object_class->build = sp_gaussianBlur_build;
81     sp_object_class->release = sp_gaussianBlur_release;
82     sp_object_class->write = sp_gaussianBlur_write;
83     sp_object_class->set = sp_gaussianBlur_set;
84     sp_object_class->update = sp_gaussianBlur_update;
85 }
87 static void
88 sp_gaussianBlur_init(SPGaussianBlur *gaussianBlur)
89 {
90     debug("0x%p",gaussianBlur);
92 //    gaussianBlur->stdDeviation = 1;
93 }
95 /**
96  * Reads the Inkscape::XML::Node, and initializes SPGaussianBlur variables.  For this to get called,
97  * our name must be associated with a repr via "sp_object_type_register".  Best done through
98  * sp-object-repr.cpp's repr_name_entries array.
99  */
100 static void
101 sp_gaussianBlur_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
103     debug("0x%p",object);
104     if (((SPObjectClass *) gaussianBlur_parent_class)->build) {
105         ((SPObjectClass *) gaussianBlur_parent_class)->build(object, document, repr);
106     }
108     sp_object_read_attr(object, "stdDeviation");
112 /**
113  * Drops any allocated memory.
114  */
115 static void
116 sp_gaussianBlur_release(SPObject *object)
118     debug("0x%p",object);
120     if (((SPObjectClass *) gaussianBlur_parent_class)->release)
121         ((SPObjectClass *) gaussianBlur_parent_class)->release(object);
124 /**
125  * Sets a specific value in the SPGaussianBlur.
126  */
127 static void
128 sp_gaussianBlur_set(SPObject *object, unsigned int key, gchar const *value)
130     debug("0x%p %s(%u): '%s'",object,
131             sp_attribute_name(key),key,value);
132     SPGaussianBlur *gaussianBlur = SP_GAUSSIANBLUR(object);
134     switch(key) {
135         case SP_ATTR_STDDEVIATION:
136                 gaussianBlur->stdDeviation.set(value);
137             break;
138         default:
139             if (((SPObjectClass *) gaussianBlur_parent_class)->set)
140                 ((SPObjectClass *) gaussianBlur_parent_class)->set(object, key, value);
141             break;
142     }
146 /**
147  * Receives update notifications.
148  */
149 static void
150 sp_gaussianBlur_update(SPObject *object, SPCtx *ctx, guint flags)
152     debug("0x%p",object);
154     if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG |
155                  SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
157         /* do something to trigger redisplay, updates? */
159     }
161     if (((SPObjectClass *) gaussianBlur_parent_class)->update) {
162         ((SPObjectClass *) gaussianBlur_parent_class)->update(object, ctx, flags);
163     }
166 /**
167  * Writes its settings to an incoming repr object, if any.
168  */
169 static Inkscape::XML::Node *
170 sp_gaussianBlur_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
172     debug("0x%p",object);
174     // Inkscape-only object, not copied during an "plain SVG" dump:
175     if (flags & SP_OBJECT_WRITE_EXT) {
176         if (repr) {
177             // is this sane?
178             repr->mergeFrom(SP_OBJECT_REPR(object), "id");
179         } else {
180             repr = SP_OBJECT_REPR(object)->duplicate();
181         }
182     }
184     if (((SPObjectClass *) gaussianBlur_parent_class)->write) {
185         ((SPObjectClass *) gaussianBlur_parent_class)->write(object, repr, flags);
186     }
188     return repr;
192 /*
193   Local Variables:
194   mode:c++
195   c-file-style:"stroustrup"
196   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
197   indent-tabs-mode:nil
198   fill-column:99
199   End:
200 */
201 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :