From 0508bdcc4bc0dfe56e9a2dd513ece591e0891537 Mon Sep 17 00:00:00 2001 From: Dave Neary Date: Sat, 6 Sep 2003 16:39:08 +0000 Subject: [PATCH] Include libart headers app/vectors/gimpvectors.[ch] 2003-09-06 Dave Neary * app/vectors/Makefile.am: Include libart headers * app/vectors/gimpvectors.[ch] * app/vectors/gimpstroke.[ch] * app/vectors/gimpbezierstroke.[ch]: Committing unfinished, useless stub code for converting a GimpVectors object to a libart vector path. Will pad this out later. --- ChangeLog | 9 ++++++++ app/vectors/Makefile.am | 1 + app/vectors/gimpbezierstroke.c | 10 +++++++++ app/vectors/gimpstroke.c | 14 ++++++++++++ app/vectors/gimpstroke.h | 5 +++++ app/vectors/gimpvectors.c | 40 ++++++++++++++++++++++++++++++++++ app/vectors/gimpvectors.h | 3 +++ 7 files changed, 82 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6af79cbc2a..63b59ab64f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2003-09-06 Dave Neary + + * app/vectors/Makefile.am: Include libart headers + * app/vectors/gimpvectors.[ch] + * app/vectors/gimpstroke.[ch] + * app/vectors/gimpbezierstroke.[ch]: Committing unfinished, + useless stub code for converting a GimpVectors object to a + libart vector path. Will pad this out later. + 2003-09-06 Michael Natterer * app/core/gimpdrawable.c (gimp_drawable_fill): made my last diff --git a/app/vectors/Makefile.am b/app/vectors/Makefile.am index 7c8fcbcea9..b58a8225aa 100644 --- a/app/vectors/Makefile.am +++ b/app/vectors/Makefile.am @@ -9,6 +9,7 @@ INCLUDES = \ -I$(top_srcdir) \ -I$(top_srcdir)/app \ $(GTK_CFLAGS) \ + $(LIBART_CFLAGS) \ -I$(includedir) noinst_LIBRARIES = libappvectors.a diff --git a/app/vectors/gimpbezierstroke.c b/app/vectors/gimpbezierstroke.c index 6be2a5444b..75f308c74d 100644 --- a/app/vectors/gimpbezierstroke.c +++ b/app/vectors/gimpbezierstroke.c @@ -115,6 +115,7 @@ static void gimp_bezier_coords_subdivide2 (const GimpCoords *beziercoords, static gboolean gimp_bezier_coords_is_straight (const GimpCoords *beziercoords, const gdouble precision); +static void gimp_bezier_stroke_to_art_point (ArtVpath *vec); /* private variables */ @@ -178,6 +179,7 @@ gimp_bezier_stroke_class_init (GimpBezierStrokeClass *klass) stroke_class->extend = gimp_bezier_stroke_extend; stroke_class->connect_stroke = gimp_bezier_stroke_connect_stroke; stroke_class->interpolate = gimp_bezier_stroke_interpolate; + stroke_class->to_art_point = gimp_bezier_stroke_to_art_point; } static void @@ -1606,3 +1608,11 @@ gimp_bezier_coords_subdivide2 (const GimpCoords *beziercoords, ret_coords, depth-1); } } + +static void +gimp_bezier_stroke_to_art_point (ArtVpath *vec) +{ + g_printerr ("gimp_bezier_stroke_to_art_point: default implementation\n"); + + return; +} diff --git a/app/vectors/gimpstroke.c b/app/vectors/gimpstroke.c index 8972a16bf0..51b94107d5 100644 --- a/app/vectors/gimpstroke.c +++ b/app/vectors/gimpstroke.c @@ -21,6 +21,9 @@ #include "config.h" +/* For ArtVpath */ +#include + #include "glib-object.h" #include "vectors-types.h" @@ -146,6 +149,7 @@ static GList * gimp_stroke_real_get_draw_anchors (const GimpStroke *stroke); static GList * gimp_stroke_real_get_draw_controls (const GimpStroke *stroke); static GArray * gimp_stroke_real_get_draw_lines (const GimpStroke *stroke); +static void gimp_stroke_to_art_point (ArtVpath *vec); /* private variables */ @@ -237,6 +241,8 @@ gimp_stroke_class_init (GimpStrokeClass *klass) klass->get_draw_anchors = gimp_stroke_real_get_draw_anchors; klass->get_draw_controls = gimp_stroke_real_get_draw_controls; klass->get_draw_lines = gimp_stroke_real_get_draw_lines; + + klass->to_art_point = gimp_stroke_to_art_point; } static void @@ -1205,3 +1211,11 @@ gimp_stroke_real_get_draw_lines (const GimpStroke *stroke) return ret_lines; } + +static void +gimp_stroke_to_art_point (ArtVpath *vec) +{ + g_printerr ("gimp_stroke_to_art_point: default implementation\n"); + + return; +} diff --git a/app/vectors/gimpstroke.h b/app/vectors/gimpstroke.h index 673ba476f6..32bffa44be 100644 --- a/app/vectors/gimpstroke.h +++ b/app/vectors/gimpstroke.h @@ -22,6 +22,8 @@ #ifndef __GIMP_STROKE_H__ #define __GIMP_STROKE_H__ +/* For ArtVpath */ +#include #include "core/gimpobject.h" @@ -163,6 +165,8 @@ struct _GimpStrokeClass GList * (* get_draw_anchors) (const GimpStroke *stroke); GList * (* get_draw_controls) (const GimpStroke *stroke); GArray * (* get_draw_lines) (const GimpStroke *stroke); + void (* to_art_point) (ArtVpath *vec); + }; @@ -303,3 +307,4 @@ GArray * gimp_stroke_get_draw_lines (const GimpStroke *stroke); #endif /* __GIMP_STROKE_H__ */ + diff --git a/app/vectors/gimpvectors.c b/app/vectors/gimpvectors.c index d4c5fef55b..d60a011c49 100644 --- a/app/vectors/gimpvectors.c +++ b/app/vectors/gimpvectors.c @@ -946,3 +946,43 @@ gimp_vectors_real_make_bezier (const GimpVectors *vectors) return NULL; } + +/* + * gimp_vectors_to_art_vpath: Create an ArtVpath from a GimpVectors object. + * @vectors: The source path + * + * Traverses the stroke list of a GimpVector object, adding nodes to an + * ArtVpath as it goes. + * The destination path is allocated inside this function, and must be + * freed after use. + * + * Return value: Newly allocated ArtVpath. + */ +ArtVpath * +gimp_vectors_to_art_vpath(const GimpVectors *vectors) +{ + ArtVpath * vec; /* Libart path we're creating */ + GimpStroke *cur_stroke; + guint num_points = g_list_length (vectors->strokes); + + vec = art_new (ArtVpath, num_points); + + gimp_vectors_freeze (vectors); + + /* Get the list of Strokes in the vector, and create the equivalent + * ArtVpath node */ + + for (cur_stroke = gimp_vectors_stroke_get_next (vectors, NULL); + cur_stroke; + cur_stroke = gimp_vectors_stroke_get_next (vectors, cur_stroke)) + { + /* Add this stroke to the art_vpath */ + GIMP_STROKE_GET_CLASS(cur_stroke)->to_art_point (vec); + } + + gimp_vectors_thaw (vectors); + + /* That's it - nothing else to see here */ + return vec; + +} diff --git a/app/vectors/gimpvectors.h b/app/vectors/gimpvectors.h index 6719de4ba1..dd01918fba 100644 --- a/app/vectors/gimpvectors.h +++ b/app/vectors/gimpvectors.h @@ -22,6 +22,7 @@ #ifndef __GIMP_VECTORS_H__ #define __GIMP_VECTORS_H__ +#include #include "core/gimpitem.h" @@ -162,5 +163,7 @@ gint gimp_vectors_interpolate (const GimpVectors *vectors, GimpVectors * gimp_vectors_make_bezier (const GimpVectors *vectors); +/* Convert to libart vector path */ +ArtVpath * gimp_vectors_to_art_vpath(const GimpVectors * vectors); #endif /* __GIMP_VECTORS_H__ */