gegl r2598 - in trunk: . gegl gegl/property-types
- From: ok svn gnome org
- To: svn-commits-list gnome org
- Subject: gegl r2598 - in trunk: . gegl gegl/property-types
- Date: Sun, 5 Oct 2008 21:01:09 +0000 (UTC)
Author: ok
Date: Sun Oct 5 21:01:09 2008
New Revision: 2598
URL: http://svn.gnome.org/viewvc/gegl?rev=2598&view=rev
Log:
* gegl/gegl-xml.c: (param_set), (serialize_properties): parse
properties that are GeglVectors as SVG paths.
* gegl/property-types/gegl-vector.[ch]: (gegl_vector_parse_svg_path):
added SVG path parser that directly builds a path for the GeglVector
object.
Modified:
trunk/ChangeLog
trunk/gegl/gegl-xml.c
trunk/gegl/property-types/gegl-vector.c
trunk/gegl/property-types/gegl-vector.h
Modified: trunk/gegl/gegl-xml.c
==============================================================================
--- trunk/gegl/gegl-xml.c (original)
+++ trunk/gegl/gegl-xml.c Sun Oct 5 21:01:09 2008
@@ -31,6 +31,7 @@
#include "operation/gegl-operation.h"
#include "property-types/gegl-color.h"
#include "property-types/gegl-curve.h"
+#include "property-types/gegl-vector.h"
#include "property-types/gegl-paramspecs.h"
#include "gegl-instrument.h"
#include "gegl-xml.h"
@@ -194,6 +195,12 @@
pd->curve = NULL;
}
}
+ else if (paramspec->value_type == GEGL_TYPE_VECTOR)
+ {
+ GeglVector *vector = gegl_vector_new ();
+ gegl_vector_parse_svg_path (vector, param_value);
+ gegl_node_set (new, param_name, vector, NULL);
+ }
else
{
g_warning ("operation desired unknown parapspec type for %s",
@@ -1067,6 +1074,10 @@
indent += 2; ind; indent -= 2; xml_param_end (ss);
g_object_unref (curve);
}
+ else if (properties[i]->value_type == GEGL_TYPE_VECTOR)
+ {
+ g_print ("serialization of GeglVector NYI\n");
+ }
else
{
g_warning ("%s: serialization of %s properties not implemented",
Modified: trunk/gegl/property-types/gegl-vector.c
==============================================================================
--- trunk/gegl/property-types/gegl-vector.c (original)
+++ trunk/gegl/property-types/gegl-vector.c Sun Oct 5 21:01:09 2008
@@ -939,7 +939,6 @@
gdouble y3)
{
GeglVectorPrivate *priv;
- g_print ("foo\n");
priv = GEGL_VECTOR_GET_PRIVATE (self);
priv->path = path_curve_to (priv->path, x1, y1, x2, y2, x3, y3);
/*gegl_vector_emit_changed (self);*/
@@ -1324,4 +1323,70 @@
return G_PARAM_SPEC (param_vector);
}
+static const gchar *parse_float_pair (const gchar *p,
+ gdouble *x,
+ gdouble *y)
+{
+ gchar *t = (void*) p;
+ while (*t && (*t<'0' || *t > '9')) t++;
+ if (!t)
+ return p;
+ *x = g_ascii_strtod (t, &t);
+ while (*t && (*t<'0' || *t > '9')) t++;
+ if (!t)
+ return p;
+ *y = g_ascii_strtod (t, &t);
+ return t;
+}
+
+
+void gegl_vector_parse_svg_path (GeglVector *vector,
+ const gchar *path)
+{
+ /* This isn't really a fully compliant SVG path parser, but it will work
+ * for at least */
+ const gchar *p = path;
+ gdouble x0, y0, x1, y1, x2, y2;
+ while (*p)
+ {
+ switch (*p)
+ {
+ case 'M':
+ p = parse_float_pair (p, &x0, &y0);
+ gegl_vector_move_to (vector, x0, y0);
+ continue;
+ case 'L':
+ p = parse_float_pair (p, &x0, &y0);
+ gegl_vector_line_to (vector, x0, y0);
+ continue;
+ case 'C':
+ p = parse_float_pair (p, &x0, &y0);
+ p = parse_float_pair (p, &x1, &y1);
+ p = parse_float_pair (p, &x2, &y2);
+ gegl_vector_curve_to (vector, x0, y0, x1, y1, x2, y2);
+ continue;
+ case 'm':
+ p = parse_float_pair (p, &x0, &y0);
+ gegl_vector_rel_move_to (vector, x0, y0);
+ continue;
+ case 'l':
+ p = parse_float_pair (p, &x0, &y0);
+ gegl_vector_rel_line_to (vector, x0, y0);
+ continue;
+ case 'c':
+ p = parse_float_pair (p, &x0, &y0);
+ p = parse_float_pair (p, &x1, &y1);
+ p = parse_float_pair (p, &x2, &y2);
+ gegl_vector_rel_curve_to (vector, x0, y0, x1, y1, x2, y2);
+ continue;
+ case 'z':
+ break;
+ case ' ':
+ break;
+ default:
+ g_print ("seeing '%c' not sure what to do\n", *p);
+ }
+ p++;
+ }
+}
Modified: trunk/gegl/property-types/gegl-vector.h
==============================================================================
--- trunk/gegl/property-types/gegl-vector.h (original)
+++ trunk/gegl/property-types/gegl-vector.h Sun Oct 5 21:01:09 2008
@@ -123,6 +123,9 @@
gdouble linewidth,
gdouble hardness);
+void gegl_vector_parse_svg_path (GeglVector *vector,
+ const gchar *path);
+
G_END_DECLS
#endif /* __GEGL_VECTOR_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]