[gimp] GimpCageConfig: add function to add and remove point at arbitrary index
- From: Michael Muré <mmure src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] GimpCageConfig: add function to add and remove point at arbitrary index
- Date: Mon, 2 May 2011 22:47:01 +0000 (UTC)
commit b0cedaa677cdf99e26b8feff490324659a669e1c
Author: Michael Muré <batolettre gmail com>
Date: Wed Apr 20 19:50:38 2011 +0200
GimpCageConfig: add function to add and remove point at arbitrary index
app/gegl/gimpcageconfig.c | 41 +++++++++++++++++++++++++++++++++++++++--
app/gegl/gimpcageconfig.h | 6 ++++++
2 files changed, 45 insertions(+), 2 deletions(-)
---
diff --git a/app/gegl/gimpcageconfig.c b/app/gegl/gimpcageconfig.c
index b0816b8..23b42f0 100644
--- a/app/gegl/gimpcageconfig.c
+++ b/app/gegl/gimpcageconfig.c
@@ -166,7 +166,7 @@ gimp_cage_config_get_n_points (GimpCageConfig *gcc)
* @x: x value of the new point
* @y: y value of the new point
*
- * Add a new point in the polygon of the cage, and make allocation if needed.
+ * Add a new point in the last index of the polygon of the cage.
* Point is added in both source and destination cage
*/
void
@@ -174,9 +174,30 @@ gimp_cage_config_add_cage_point (GimpCageConfig *gcc,
gdouble x,
gdouble y)
{
+ gimp_cage_config_insert_cage_point (gcc, gcc->cage_points->len - 1, x, y);
+}
+
+/**
+ * gimp_cage_config_insert_cage_point:
+ * @gcc: the cage config
+ * @point_number: index where the point will be inserted
+ * @x: x value of the new point
+ * @y: y value of the new point
+ *
+ * Insert a new point in the polygon of the cage at the given index.
+ * Point is added in both source and destination cage
+ */
+void
+gimp_cage_config_insert_cage_point (GimpCageConfig *gcc,
+ gint point_number,
+ gdouble x,
+ gdouble y)
+{
GimpCagePoint point;
g_return_if_fail (GIMP_IS_CAGE_CONFIG (gcc));
+ g_return_if_fail (point_number <= gcc->cage_points->len);
+ g_return_if_fail (point_number >= 0);
point.src_point.x = x + DELTA;
point.src_point.y = y + DELTA;
@@ -184,7 +205,7 @@ gimp_cage_config_add_cage_point (GimpCageConfig *gcc,
point.dest_point.x = x + DELTA;
point.dest_point.y = y + DELTA;
- g_array_append_val (gcc->cage_points, point);
+ g_array_insert_val (gcc->cage_points, point_number, point);
gimp_cage_config_compute_scaling_factor (gcc);
gimp_cage_config_compute_edges_normal (gcc);
@@ -199,7 +220,23 @@ gimp_cage_config_add_cage_point (GimpCageConfig *gcc,
void
gimp_cage_config_remove_last_cage_point (GimpCageConfig *gcc)
{
+ gimp_cage_config_remove_cage_point (gcc, gcc->cage_points->len - 1);
+}
+
+/**
+ * gimp_cage_config_remove_cage_point:
+ * @gcc: the cage config
+ * @point_number: the index of the point to remove
+ *
+ * Remove the given point from the cage
+ */
+void
+gimp_cage_config_remove_cage_point (GimpCageConfig *gcc,
+ gint point_number)
+{
g_return_if_fail (GIMP_IS_CAGE_CONFIG (gcc));
+ g_return_if_fail (point_number < gcc->cage_points->len);
+ g_return_if_fail (point_number >= 0);
if (gcc->cage_points->len > 0)
g_array_remove_index (gcc->cage_points, gcc->cage_points->len - 1);
diff --git a/app/gegl/gimpcageconfig.h b/app/gegl/gimpcageconfig.h
index 6d8c544..6c495a9 100644
--- a/app/gegl/gimpcageconfig.h
+++ b/app/gegl/gimpcageconfig.h
@@ -67,7 +67,13 @@ guint gimp_cage_config_get_n_points (GimpCageConfig *gcc);
void gimp_cage_config_add_cage_point (GimpCageConfig *gcc,
gdouble x,
gdouble y);
+void gimp_cage_config_insert_cage_point (GimpCageConfig *gcc,
+ gint point_number,
+ gdouble x,
+ gdouble y);
void gimp_cage_config_remove_last_cage_point (GimpCageConfig *gcc);
+void gimp_cage_config_remove_cage_point (GimpCageConfig *gcc,
+ gint point_number);
GimpVector2 gimp_cage_config_get_point_coordinate (GimpCageConfig *gcc,
GimpCageMode mode,
gint point_number);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]