gegl r2805 - in trunk: . bin gegl/property-types
- From: ok svn gnome org
- To: svn-commits-list gnome org
- Subject: gegl r2805 - in trunk: . bin gegl/property-types
- Date: Tue, 25 Nov 2008 10:19:15 +0000 (UTC)
Author: ok
Date: Tue Nov 25 10:19:15 2008
New Revision: 2805
URL: http://svn.gnome.org/viewvc/gegl?rev=2805&view=rev
Log:
* gegl/property-types/gegl-path.[ch]: improved API consistency.
* bin/editor.c: synced up with above.
Modified:
trunk/ChangeLog
trunk/bin/editor.c
trunk/gegl/property-types/gegl-path.c
trunk/gegl/property-types/gegl-path.h
Modified: trunk/bin/editor.c
==============================================================================
--- trunk/bin/editor.c (original)
+++ trunk/bin/editor.c Tue Nov 25 10:19:15 2008
@@ -340,9 +340,9 @@
static gint insert_node (gint argc, gchar **argv)
{
- GeglPathItem knot = *gegl_path_get (tools.path, tools.selected_no);
+ GeglPathItem knot = *gegl_path_get_node (tools.path, tools.selected_no);
knot.point[0].x += 10;
- gegl_path_insert (tools.path, tools.selected_no, &knot);
+ gegl_path_insert_node (tools.path, tools.selected_no, &knot);
tools.selected_no ++;
return 0;
}
@@ -353,7 +353,7 @@
if (!path)
return FALSE;
- knot = gegl_path_get (tools.path, -1);
+ knot = gegl_path_get_node (tools.path, -1);
if (!knot)
return FALSE;
if (knot->type == 'z')
@@ -366,10 +366,10 @@
static gint spiro_open (gint argc, gchar **argv)
{
- GeglPathItem knot = *gegl_path_get (tools.path, -1);
+ GeglPathItem knot = *gegl_path_get_node (tools.path, -1);
if (knot.type == 'z')
{
- gegl_path_remove (tools.path, -1);
+ gegl_path_remove_node (tools.path, -1);
g_print ("opened path\n");
return 0;
}
@@ -380,7 +380,7 @@
static gint spiro_close (gint argc, gchar **argv)
{
- GeglPathItem knot = *gegl_path_get (tools.path, -1);
+ GeglPathItem knot = *gegl_path_get_node (tools.path, -1);
if (knot.type == 'z')
{
g_print ("already closed\n");
@@ -400,21 +400,21 @@
static gint insert_node_before (gint argc, gchar **argv)
{
- GeglPathItem knot = *gegl_path_get (tools.path, tools.selected_no);
+ GeglPathItem knot = *gegl_path_get_node (tools.path, tools.selected_no);
g_assert (argv[1] && argv[2]);
if (tools.selected_no == 0)
{
- gegl_path_insert (tools.path, 0, &knot);
+ gegl_path_insert_node (tools.path, 0, &knot);
knot.point[0].x = atof (argv[1]);
knot.point[0].y = atof (argv[2]);
- gegl_path_replace (tools.path, 0, &knot);
+ gegl_path_replace_node (tools.path, 0, &knot);
}
else
{
knot.point[0].x = atof (argv[1]);
knot.point[0].y = atof (argv[2]);
- gegl_path_insert (tools.path, tools.selected_no-1, &knot);
+ gegl_path_insert_node (tools.path, tools.selected_no-1, &knot);
}
return 0;
}
@@ -430,13 +430,13 @@
return -1;
}
if (override_node_after != -1)
- knot = *gegl_path_get (tools.path, override_node_after);
+ knot = *gegl_path_get_node (tools.path, override_node_after);
else
- knot = *gegl_path_get (tools.path, tools.selected_no);
+ knot = *gegl_path_get_node (tools.path, tools.selected_no);
g_assert (argv[1] && argv[2]);
knot.point[0].x = atof (argv[1]);
knot.point[0].y = atof (argv[2]);
- gegl_path_insert (tools.path, tools.selected_no, &knot);
+ gegl_path_insert_node (tools.path, tools.selected_no, &knot);
tools.selected_no ++;
override_node_after = -1;
return 0;
@@ -444,7 +444,7 @@
static gint remove_node (gint argc, gchar **argv)
{
- gegl_path_remove (tools.path, tools.selected_no);
+ gegl_path_remove_node (tools.path, tools.selected_no);
if (tools.selected_no>0)
tools.selected_no --;
else
@@ -460,16 +460,16 @@
static gint spiro_mode (gint argc, gchar **argv)
{
- GeglPathItem knot = *gegl_path_get (tools.path, tools.selected_no);
+ GeglPathItem knot = *gegl_path_get_node (tools.path, tools.selected_no);
knot.type = argv[1][0];
g_print ("setting %c\n", knot.type);
- gegl_path_replace (tools.path, tools.selected_no, &knot);
+ gegl_path_replace_node (tools.path, tools.selected_no, &knot);
return 0;
}
static gint spiro_mode_change (gint argc, gchar **argv)
{
- GeglPathItem knot = *gegl_path_get (tools.path, tools.selected_no);
+ GeglPathItem knot = *gegl_path_get_node (tools.path, tools.selected_no);
switch (knot.type)
{
case 'v':
@@ -489,7 +489,7 @@
break;
}
g_print ("setting %c\n", knot.type);
- gegl_path_replace (tools.path, tools.selected_no, &knot);
+ gegl_path_replace_node (tools.path, tools.selected_no, &knot);
return 0;
}
@@ -583,13 +583,13 @@
vector = tools.path;
- n= gegl_path_get_count (vector);
+ n= gegl_path_get_n_nodes (vector);
prev_knot = NULL;
for (i=0;i<n;i++)
{
gdouble x, y;
- knot = gegl_path_get (vector, i);
+ knot = gegl_path_get_node (vector, i);
/* handling of handles on beziers */
if (knot->type == 'C')
@@ -680,7 +680,7 @@
gdouble px, py, nx, ny; /* prev, next */
px = prev_knot->point[0].x;
py = prev_knot->point[0].y;
- knot2 = gegl_path_get (vector, i + 1);
+ knot2 = gegl_path_get_node (vector, i + 1);
nx = knot2->point[0].x;
ny = knot2->point[0].y;
@@ -863,7 +863,7 @@
if (prev_knot)
{
GeglPathItem knot = {prev_knot->type, {{ex, ey}}};
- gegl_path_insert (vector, -1, &knot);
+ gegl_path_insert_node (vector, -1, &knot);
tools.selected_no = tools.drag_no = n;
tools.drag_sub = 0;
tools.prevx = ex;
@@ -872,7 +872,7 @@
else
{
GeglPathItem knot = {'V', {{ex, ey}}};
- gegl_path_insert (vector, -1, &knot);
+ gegl_path_insert_node (vector, -1, &knot);
tools.selected_no = tools.drag_no = n;
tools.drag_sub = 0;
tools.prevx = ex;
@@ -892,7 +892,7 @@
if (!prev_knot)
{
GeglPathItem knot = {'v', {{ex, ey}}};
- gegl_path_insert (vector, -1, &knot);
+ gegl_path_insert_node (vector, -1, &knot);
}
else
{
@@ -989,48 +989,48 @@
{
if (tools.drag_sub == 0)
{
- new_knot = *gegl_path_get (vector, tools.drag_no);
+ new_knot = *gegl_path_get_node (vector, tools.drag_no);
if (new_knot.type == 'C')
{
new_knot.point[1].x -= rx;
new_knot.point[1].y -= ry;
new_knot.point[2].x -= rx;
new_knot.point[2].y -= ry;
- gegl_path_replace (vector, tools.drag_no, &new_knot);
- new_knot = *gegl_path_get (vector, tools.drag_no + 1);
+ gegl_path_replace_node (vector, tools.drag_no, &new_knot);
+ new_knot = *gegl_path_get_node (vector, tools.drag_no + 1);
new_knot.point[0].x -= rx;
new_knot.point[0].y -= ry;
- gegl_path_replace (vector, tools.drag_no + 1, &new_knot);
+ gegl_path_replace_node (vector, tools.drag_no + 1, &new_knot);
}
else
{
new_knot.point[0].x -= rx;
new_knot.point[0].y -= ry;
- gegl_path_replace (vector, tools.drag_no, &new_knot);
+ gegl_path_replace_node (vector, tools.drag_no, &new_knot);
}
gtk_widget_queue_draw (widget);
}
else if (tools.drag_sub == 1)
{
- new_knot = *gegl_path_get (vector, tools.drag_no);
+ new_knot = *gegl_path_get_node (vector, tools.drag_no);
new_knot.point[1].x -= rx;
new_knot.point[1].y -= ry;
- gegl_path_replace (vector, tools.drag_no, &new_knot);
+ gegl_path_replace_node (vector, tools.drag_no, &new_knot);
gtk_widget_queue_draw (widget);
}
else if (tools.drag_sub == -1)
{
- new_knot = *gegl_path_get (vector, tools.drag_no + 1);
+ new_knot = *gegl_path_get_node (vector, tools.drag_no + 1);
new_knot.point[0].x -= rx;
new_knot.point[0].y -= ry;
- gegl_path_replace (vector, tools.drag_no + 1, &new_knot);
+ gegl_path_replace_node (vector, tools.drag_no + 1, &new_knot);
gtk_widget_queue_draw (widget);
}
}
/* make the closest the selected */
- n = gegl_path_get_count (vector);
+ n = gegl_path_get_n_nodes (vector);
if ((tools.selected_no != 0 &&
tools.selected_no != n -1)
|| spiro_is_closed (vector))
@@ -1042,7 +1042,7 @@
{
const GeglPathItem *node;
gdouble dist;
- node = gegl_path_get (vector, i);
+ node = gegl_path_get_node (vector, i);
dist = DIST(ex,ey,node->point[0].x,
node->point[0].y);
if (dist < bestdist)
@@ -1104,12 +1104,12 @@
cairo_new_path (cr);
gegl_path_cairo_play (vector, cr);
- n= gegl_path_get_count (vector);
+ n= gegl_path_get_n_nodes (vector);
prev_knot = NULL;
for (i=0;i<n;i++)
{
gdouble x, y;
- knot = gegl_path_get (vector, i);
+ knot = gegl_path_get_node (vector, i);
if (knot->type == 'C')
{
get_loc (prev_knot, &x, &y);
@@ -1128,7 +1128,7 @@
cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.8);
cairo_stroke (cr);
- n= gegl_path_get_count (vector);
+ n= gegl_path_get_n_nodes (vector);
prev_knot = NULL;
if (tools.drag_no==-1)
{
@@ -1154,7 +1154,7 @@
for (i=0;i<n;i++)
{
gdouble x, y;
- knot = gegl_path_get (vector, i);
+ knot = gegl_path_get_node (vector, i);
if (!knot)
g_error ("EEEK!");
@@ -1239,7 +1239,7 @@
gdouble px, py, nx, ny; /* prev, next */
px = prev_knot->point[0].x;
py = prev_knot->point[0].y;
- knot2 = gegl_path_get (vector, i + 1);
+ knot2 = gegl_path_get_node (vector, i + 1);
nx = knot2->point[0].x;
ny = knot2->point[0].y;
@@ -1372,11 +1372,11 @@
if (width_profile)
{
- n= gegl_path_get_count (width_profile);
+ n= gegl_path_get_n_nodes (width_profile);
for (i=0;i<n;i++)
{
gdouble x, y;
- knot = gegl_path_get (width_profile, i);
+ knot = gegl_path_get_node (width_profile, i);
if (knot->type == '_')
{
gegl_path_calc (vector, knot->point[0].x, &x, &y);
@@ -1456,7 +1456,7 @@
if (width_profile)
{
- knot = gegl_path_get (width_profile, tools.drag_no);
+ knot = gegl_path_get_node (width_profile, tools.drag_no);
if (knot->type == '_')
{
gdouble radius;
@@ -1470,7 +1470,7 @@
else if (new_knot.point[0].y < 0.05)
new_knot.point[0].y = 0.05;
- gegl_path_replace (width_profile, tools.drag_no, &new_knot);
+ gegl_path_replace_node (width_profile, tools.drag_no, &new_knot);
}
}
}
@@ -1537,11 +1537,11 @@
cairo_stroke (cr);
{
- n= gegl_path_get_count (width_profile);
+ n= gegl_path_get_n_nodes (width_profile);
for (i=0;i<n;i++)
{
gdouble x, y;
- knot = gegl_path_get (width_profile, i);
+ knot = gegl_path_get_node (width_profile, i);
if (knot->type == '_')
{
gegl_path_calc (vector, knot->point[0].x, &x, &y);
Modified: trunk/gegl/property-types/gegl-path.c
==============================================================================
--- trunk/gegl/property-types/gegl-path.c (original)
+++ trunk/gegl/property-types/gegl-path.c Tue Nov 25 10:19:15 2008
@@ -872,6 +872,13 @@
return self;
}
+GeglPath *
+gegl_path_new_from_string (const gchar *path_string)
+{
+ GeglPath *self = gegl_path_new ();
+ gegl_path_parse_string (self, path_string);
+ return self;
+}
gdouble
gegl_path_get_length (GeglPath *self)
@@ -985,41 +992,22 @@
struct _GeglParamPath
{
GParamSpec parent_instance;
-
- GeglPath *default_vector;
};
static void
gegl_param_vector_init (GParamSpec *self)
{
- GEGL_PARAM_PATH (self)->default_vector = gegl_path_new ();
}
static void
gegl_param_vector_finalize (GParamSpec *self)
{
- GeglParamPath *param_vector = GEGL_PARAM_PATH (self);
GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (
GEGL_TYPE_PARAM_PATH));
- if (param_vector->default_vector)
- {
- g_object_unref (param_vector->default_vector);
- param_vector->default_vector = NULL;
- }
-
parent_class->finalize (self);
}
-static void
-value_set_default (GParamSpec *param_spec,
- GValue *value)
-{
- GeglParamPath *gegl_vector = GEGL_PARAM_PATH (param_spec);
-
- g_value_set_object (value, gegl_vector->default_vector);
-}
-
GType
gegl_param_path_get_type (void)
{
@@ -1033,7 +1021,7 @@
gegl_param_vector_init,
0,
gegl_param_vector_finalize,
- value_set_default,
+ NULL,
NULL,
NULL
};
@@ -1066,8 +1054,6 @@
param_vector = g_param_spec_internal (GEGL_TYPE_PARAM_PATH,
name, nick, blurb, flags);
- param_vector->default_vector = default_vector;
-
return G_PARAM_SPEC (param_vector);
}
@@ -1204,7 +1190,7 @@
}
gint
-gegl_path_get_count (GeglPath *vector)
+gegl_path_get_n_nodes (GeglPath *vector)
{
GeglPathPrivate *priv = GEGL_PATH_GET_PRIVATE (vector);
GeglPathList *iter;
@@ -1218,8 +1204,8 @@
}
const GeglPathItem *
-gegl_path_get (GeglPath *vector,
- gint pos)
+gegl_path_get_node (GeglPath *vector,
+ gint pos)
{
GeglPathPrivate *priv = GEGL_PATH_GET_PRIVATE (vector);
GeglPathList *iter;
@@ -1251,7 +1237,7 @@
g_slice_free1 (sizeof (gpointer) + sizeof (gchar) + sizeof (gfloat)*2 *info->pairs, p);
}
-void gegl_path_remove (GeglPath *vector,
+void gegl_path_remove_node (GeglPath *vector,
gint pos)
{
GeglPathPrivate *priv = GEGL_PATH_GET_PRIVATE (vector);
@@ -1261,7 +1247,7 @@
gint count=0;
if (pos == -1)
- pos = gegl_path_get_count (vector)-1;
+ pos = gegl_path_get_n_nodes (vector)-1;
for (iter = priv->path; iter; iter=iter->next)
{
@@ -1285,7 +1271,7 @@
}
-void gegl_path_insert (GeglPath *vector,
+void gegl_path_insert_node (GeglPath *vector,
gint pos,
const GeglPathItem *knot)
{
@@ -1330,7 +1316,7 @@
gegl_path_emit_changed (vector, NULL);
}
-void gegl_path_replace (GeglPath *vector,
+void gegl_path_replace_node (GeglPath *vector,
gint pos,
const GeglPathItem *knot)
{
Modified: trunk/gegl/property-types/gegl-path.h
==============================================================================
--- trunk/gegl/property-types/gegl-path.h (original)
+++ trunk/gegl/property-types/gegl-path.h Tue Nov 25 10:19:15 2008
@@ -63,38 +63,72 @@
GType gegl_path_get_type (void) G_GNUC_CONST;
GeglPath * gegl_path_new (void);
+GeglPath * gegl_path_new_from_string(const gchar *path_string);
+
gboolean gegl_path_is_empty (GeglPath *path);
-void gegl_path_parse_string (GeglPath *path,
- const gchar *path_string);
+gint gegl_path_get_n_nodes (GeglPath *path);
+gdouble gegl_path_get_length (GeglPath *path);
+const GeglPathItem * gegl_path_get_node (GeglPath *path,
+ gint pos);
gchar * gegl_path_to_string (GeglPath *path);
-gint gegl_path_get_count (GeglPath *path);
-
-void gegl_path_clear (GeglPath *path);
-void gegl_path_append (GeglPath *self,
- ...);
-void gegl_path_insert (GeglPath *path,
- gint pos,
- const GeglPathItem *knot);
-const GeglPathItem * gegl_path_get (GeglPath *path,
- gint pos);
-void gegl_path_replace (GeglPath *path,
- gint pos,
- const GeglPathItem *knot);
-void gegl_path_remove (GeglPath *path,
- gint pos);
+gdouble gegl_path_closest_point (GeglPath *path,
+ gdouble x,
+ gdouble y,
+ gdouble *dx,
+ gdouble *dy,
+ gint *node_pos_before);
+void gegl_path_calc (GeglPath *path,
+ gdouble pos,
+ gdouble *dest_x,
+ gdouble *dest_y);
+void gegl_path_calc_values (GeglPath *self,
+ guint num_samples,
+ gdouble *dest_xs,
+ gdouble *dest_ys);
+void gegl_path_get_bounds (GeglPath *self,
+ gdouble *min_x,
+ gdouble *max_x,
+ gdouble *min_y,
+ gdouble *max_y);
void gegl_path_foreach (GeglPath *path,
void (*each_item) (
const GeglPathItem *knot,
gpointer data),
gpointer data);
+
+/* iterate through only line_to / move_to commands approximating the
+ * same path
+ */
void gegl_path_foreach_flat (GeglPath *path,
void (*each_item) (
const GeglPathItem *knot,
gpointer data),
gpointer data);
+
+void gegl_path_clear (GeglPath *path);
+void gegl_path_insert_node (GeglPath *path,
+ gint pos,
+ const GeglPathItem *knot);
+void gegl_path_replace_node (GeglPath *path,
+ gint pos,
+ const GeglPathItem *knot);
+void gegl_path_remove_node (GeglPath *path,
+ gint pos);
+
+void gegl_path_parse_string (GeglPath *path,
+ const gchar *path_string);
+
+/* convenience function for C */
+void gegl_path_append (GeglPath *self,
+ ...);
+
+
+
+
+
/* creates a new path if one doesn't already exist */
GeglPath * gegl_path_add_parameter_path (GeglPath *path,
const gchar *parameter_name);
@@ -122,30 +156,6 @@
guint num_samples,
gdouble *samples);
-gdouble gegl_path_get_length (GeglPath *path);
-gdouble gegl_path_closest_point (GeglPath *path,
- gdouble x,
- gdouble y,
- gdouble *dx,
- gdouble *dy,
- gint *node_pos_before);
-void gegl_path_calc (GeglPath *path,
- gdouble pos,
- gdouble *dest_x,
- gdouble *dest_y);
-void gegl_path_node (GeglPath *path,
- gdouble pos,
- gdouble *dest_x,
- gdouble *dest_y);
-void gegl_path_get_bounds (GeglPath *self,
- gdouble *min_x,
- gdouble *max_x,
- gdouble *min_y,
- gdouble *max_y);
-void gegl_path_calc_values (GeglPath *self,
- guint num_samples,
- gdouble *dest_xs,
- gdouble *dest_ys);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]