summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 22cc360)
raw | patch | inline | side by side (parent: 22cc360)
author | jucablues <jucablues@users.sourceforge.net> | |
Fri, 27 Jul 2007 04:23:10 +0000 (04:23 +0000) | ||
committer | jucablues <jucablues@users.sourceforge.net> | |
Fri, 27 Jul 2007 04:23:10 +0000 (04:23 +0000) |
header
src/helper-fns.h | [new file with mode: 0644] | patch | blob |
src/sp-fecomposite.cpp | patch | blob | history | |
src/sp-feconvolvematrix.cpp | patch | blob | history | |
src/sp-feoffset.cpp | patch | blob | history | |
src/sp-feturbulence.cpp | patch | blob | history |
diff --git a/src/helper-fns.h b/src/helper-fns.h
--- /dev/null
+++ b/src/helper-fns.h
@@ -0,0 +1,54 @@
+#ifndef SEEN_HELPER_FNS_H
+#define SEEN_HELPER_FNS_H
+/** \file
+ *
+ * Some helper functions
+ *
+ * Authors:
+ * Felipe CorrĂȘa da Silva Sanches <felipe.sanches@gmail.com>
+ *
+ *
+ * Copyright (C) 2006 Hugo Rodrigues
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+static double
+helperfns_read_number(gchar const *value) {
+ if (!value) return 0;
+ char *end;
+ double ret = g_ascii_strtod(value, &end);
+ if (*end) {
+ g_warning("Unable to convert \"%s\" to number", value);
+ // We could leave this out, too. If strtod can't convert
+ // anything, it will return zero.
+ ret = 0;
+ }
+ return ret;
+}
+
+static bool helperfns_read_bool(gchar const *value, bool default_value){
+ if (!value) return default_value;
+ switch(value[0]){
+ case 't':
+ if (strncmp(value, "true", 4) == 0) return true;
+ break;
+ case 'f':
+ if (strncmp(value, "false", 5) == 0) return false;
+ break;
+ }
+ return default_value;
+}
+
+#endif /* !SEEN_HELPER_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
index b191f982657f0bfac3d39b71bab5dfd472c9da8d..cb1726be79b3be2744a7f28da5546fad2716ce8e 100644 (file)
--- a/src/sp-fecomposite.cpp
+++ b/src/sp-fecomposite.cpp
#include "attributes.h"
#include "svg/svg.h"
#include "sp-fecomposite.h"
+#include "helper-fns.h"
#include "xml/repr.h"
#include "display/nr-filter-composite.h"
((SPObjectClass *) feComposite_parent_class)->release(object);
}
-static double
-sp_feComposite_read_number(gchar const *value) {
- if (!value) return 0;
-
- char *end;
- double ret = g_ascii_strtod(value, &end);
- if (*end) {
- g_warning("Unable to convert \"%s\" to number", value);
- // We could leave this out, too. If strtod can't convert
- // anything, it will return zero.
- ret = 0;
- }
- return ret;
-}
-
static FeCompositeOperator
sp_feComposite_read_operator(gchar const *value) {
if (!value) return COMPOSITE_DEFAULT;
break;
case SP_ATTR_K1:
- k_n = sp_feComposite_read_number(value);
+ k_n = helperfns_read_number(value);
if (k_n != feComposite->k1) {
feComposite->k1 = k_n;
if (feComposite->composite_operator == COMPOSITE_ARITHMETIC)
break;
case SP_ATTR_K2:
- k_n = sp_feComposite_read_number(value);
+ k_n = helperfns_read_number(value);
if (k_n != feComposite->k2) {
feComposite->k2 = k_n;
if (feComposite->composite_operator == COMPOSITE_ARITHMETIC)
break;
case SP_ATTR_K3:
- k_n = sp_feComposite_read_number(value);
+ k_n = helperfns_read_number(value);
if (k_n != feComposite->k3) {
feComposite->k3 = k_n;
if (feComposite->composite_operator == COMPOSITE_ARITHMETIC)
break;
case SP_ATTR_K4:
- k_n = sp_feComposite_read_number(value);
+ k_n = helperfns_read_number(value);
if (k_n != feComposite->k4) {
feComposite->k4 = k_n;
if (feComposite->composite_operator == COMPOSITE_ARITHMETIC)
index edd093499883324052eaea98c5e79a14b1bf5c9b..adabc1bac06d1362551897906d7087f4c3ebab49 100644 (file)
#include "attributes.h"
#include "svg/svg.h"
#include "sp-feconvolvematrix.h"
+#include "helper-fns.h"
#include "xml/repr.h"
#include "display/nr-filter-convolve-matrix.h"
((SPObjectClass *) feConvolveMatrix_parent_class)->release(object);
}
-
static std::vector<gdouble> read_kernel_matrix(const gchar* value, int size){
std::vector<gdouble> v(size, (gdouble) 0);
int i;
return v;
}
-static double
-sp_feConvolveMatrix_read_number(gchar const *value) {
- if (!value) return 0;
- char *end;
- double ret = g_ascii_strtod(value, &end);
- if (*end) {
- g_warning("Unable to convert \"%s\" to number", value);
- // We could leave this out, too. If strtod can't convert
- // anything, it will return zero.
- ret = 0;
- }
- return ret;
-}
-
static int sp_feConvolveMatrix_read_edgeMode(gchar const *value){
if (!value) return 0; //duplicate is default
switch(value[0]){
return 0; //duplicate is default
}
-
-static bool sp_feConvolveMatrix_read_bool(gchar const *value){
- if (!value) return false; //false is default
- switch(value[0]){
- case 't':
- if (strncmp(value, "true", 4) == 0) return true;
- break;
- case 'f':
- if (strncmp(value, "false", 5) == 0) return false;
- break;
- }
- return false; //false is default
-}
-
/**
* Sets a specific value in the SPFeConvolveMatrix.
*/
@@ -196,28 +168,28 @@ sp_feConvolveMatrix_set(SPObject *object, unsigned int key, gchar const *value)
object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_DIVISOR:
- read_num = sp_feConvolveMatrix_read_number(value);
+ read_num = helperfns_read_number(value);
if (read_num != feConvolveMatrix->divisor){
feConvolveMatrix->divisor = read_num;
object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
case SP_ATTR_BIAS:
- read_num = sp_feConvolveMatrix_read_number(value);
+ read_num = helperfns_read_number(value);
if (read_num != feConvolveMatrix->bias){
feConvolveMatrix->bias = read_num;
object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
case SP_ATTR_TARGETX:
- read_int = (int) sp_feConvolveMatrix_read_number(value);
+ read_int = (int) helperfns_read_number(value);
if (read_int != feConvolveMatrix->targetX){
feConvolveMatrix->targetX = read_int;
object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
case SP_ATTR_TARGETY:
- read_int = (int) sp_feConvolveMatrix_read_number(value);
+ read_int = (int) helperfns_read_number(value);
if (read_int != feConvolveMatrix->targetY){
feConvolveMatrix->targetY = read_int;
object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_PRESERVEALPHA:
- read_bool = sp_feConvolveMatrix_read_bool(value);
+ read_bool = helperfns_read_bool(value, false);
if (read_bool != feConvolveMatrix->preserveAlpha){
feConvolveMatrix->preserveAlpha = read_bool;
object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
diff --git a/src/sp-feoffset.cpp b/src/sp-feoffset.cpp
index 03d8b6227502b7a21831c7a46cd37ff7fdccc74c..67a8b99e2749b46cf90d56f115a4f6a4fe4f6914 100644 (file)
--- a/src/sp-feoffset.cpp
+++ b/src/sp-feoffset.cpp
#include "attributes.h"
#include "svg/svg.h"
#include "sp-feoffset.h"
+#include "helper-fns.h"
#include "xml/repr.h"
#include "display/nr-filter-offset.h"
((SPObjectClass *) feOffset_parent_class)->release(object);
}
-static double
-sp_feOffset_read_number(gchar const *value) {
- if (!value) return 0;
- char *end;
- double ret = g_ascii_strtod(value, &end);
- if (*end) {
- g_warning("Unable to convert \"%s\" to number", value);
- // We could leave this out, too. If strtod can't convert
- // anything, it will return zero.
- ret = 0;
- }
- return ret;
-}
-
/**
* Sets a specific value in the SPFeOffset.
*/
double read_num;
switch(key) {
case SP_ATTR_DX:
- read_num = sp_feOffset_read_number(value);
+ read_num = helperfns_read_number(value);
if (read_num != feOffset->dx) {
feOffset->dx = read_num;
object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
case SP_ATTR_DY:
- read_num = sp_feOffset_read_number(value);
+ read_num = helperfns_read_number(value);
if (read_num != feOffset->dy) {
feOffset->dy = read_num;
object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
index f7b256898023d39fd9908774905c2a971299ca27..effdd777ee1ed657785901a7ca473381b33b598a 100644 (file)
--- a/src/sp-feturbulence.cpp
+++ b/src/sp-feturbulence.cpp
#include "attributes.h"
#include "svg/svg.h"
#include "sp-feturbulence.h"
+#include "helper-fns.h"
#include "xml/repr.h"
#include <string.h>
((SPObjectClass *) feTurbulence_parent_class)->release(object);
}
-static double
-sp_feTurbulence_read_number(gchar const *value) {
- if (!value) return 0;
- char *end;
- double ret = g_ascii_strtod(value, &end);
- if (*end) {
- g_warning("Unable to convert \"%s\" to number", value);
- // We could leave this out, too. If strtod can't convert
- // anything, it will return zero.
- ret = 0;
- }
- return ret;
-}
-
static bool sp_feTurbulence_read_stitchTiles(gchar const *value){
if (!value) return false; // 'noStitch' is default
switch(value[0]){
object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_NUMOCTAVES:
- read_int = (int) sp_feTurbulence_read_number(value);
+ read_int = (int) helperfns_read_number(value);
if (read_int != feTurbulence->numOctaves){
feTurbulence->numOctaves = read_int;
object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
break;
case SP_ATTR_SEED:
- read_num = sp_feTurbulence_read_number(value);
+ read_num = helperfns_read_number(value);
if (read_num != feTurbulence->seed){
feTurbulence->seed = read_num;
object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);