mirror of https://github.com/GNOME/gimp.git
app: remove public function gimp_vectors_bounds()
and move its code into the GimpItem::bounds() implementation.
This commit is contained in:
parent
7e90a3e4e5
commit
658a7834fe
|
@ -69,7 +69,7 @@ static gint64 gimp_vectors_get_memsize (GimpObject *object,
|
|||
|
||||
static gboolean gimp_vectors_is_attached (const GimpItem *item);
|
||||
static GimpItemTree * gimp_vectors_get_tree (GimpItem *item);
|
||||
static gboolean gimp_vectors_item_bounds (GimpItem *item,
|
||||
static gboolean gimp_vectors_bounds (GimpItem *item,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
gdouble *width,
|
||||
|
@ -199,7 +199,7 @@ gimp_vectors_class_init (GimpVectorsClass *klass)
|
|||
|
||||
item_class->is_attached = gimp_vectors_is_attached;
|
||||
item_class->get_tree = gimp_vectors_get_tree;
|
||||
item_class->bounds = gimp_vectors_item_bounds;
|
||||
item_class->bounds = gimp_vectors_bounds;
|
||||
item_class->duplicate = gimp_vectors_duplicate;
|
||||
item_class->convert = gimp_vectors_convert;
|
||||
item_class->translate = gimp_vectors_translate;
|
||||
|
@ -323,23 +323,69 @@ gimp_vectors_get_tree (GimpItem *item)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gimp_vectors_item_bounds (GimpItem *item,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
gdouble *width,
|
||||
gdouble *height)
|
||||
gimp_vectors_bounds (GimpItem *item,
|
||||
gdouble *x,
|
||||
gdouble *y,
|
||||
gdouble *width,
|
||||
gdouble *height)
|
||||
{
|
||||
gdouble x1, y1, x2, y2;
|
||||
gdouble retval;
|
||||
GimpVectors *vectors = GIMP_VECTORS (item);
|
||||
|
||||
retval = gimp_vectors_bounds (GIMP_VECTORS (item), &x1, &y1, &x2, &y2);
|
||||
if (! vectors->bounds_valid)
|
||||
{
|
||||
GimpStroke *stroke;
|
||||
|
||||
*x = x1;
|
||||
*y = y1;
|
||||
*width = x2 - x1;
|
||||
*height = y2 - y1;
|
||||
vectors->bounds_empty = TRUE;
|
||||
vectors->bounds_x1 = vectors->bounds_x2 = 0.0;
|
||||
vectors->bounds_y1 = vectors->bounds_y2 = 0.0;
|
||||
|
||||
return retval;
|
||||
for (stroke = gimp_vectors_stroke_get_next (vectors, NULL);
|
||||
stroke;
|
||||
stroke = gimp_vectors_stroke_get_next (vectors, stroke))
|
||||
{
|
||||
GArray *stroke_coords;
|
||||
gboolean closed;
|
||||
|
||||
stroke_coords = gimp_stroke_interpolate (stroke, 1.0, &closed);
|
||||
|
||||
if (stroke_coords)
|
||||
{
|
||||
GimpCoords point;
|
||||
gint i;
|
||||
|
||||
if (vectors->bounds_empty && stroke_coords->len > 0)
|
||||
{
|
||||
point = g_array_index (stroke_coords, GimpCoords, 0);
|
||||
|
||||
vectors->bounds_x1 = vectors->bounds_x2 = point.x;
|
||||
vectors->bounds_y1 = vectors->bounds_y2 = point.y;
|
||||
|
||||
vectors->bounds_empty = FALSE;
|
||||
}
|
||||
|
||||
for (i = 0; i < stroke_coords->len; i++)
|
||||
{
|
||||
point = g_array_index (stroke_coords, GimpCoords, i);
|
||||
|
||||
vectors->bounds_x1 = MIN (vectors->bounds_x1, point.x);
|
||||
vectors->bounds_y1 = MIN (vectors->bounds_y1, point.y);
|
||||
vectors->bounds_x2 = MAX (vectors->bounds_x2, point.x);
|
||||
vectors->bounds_y2 = MAX (vectors->bounds_y2, point.y);
|
||||
}
|
||||
|
||||
g_array_free (stroke_coords, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
vectors->bounds_valid = TRUE;
|
||||
}
|
||||
|
||||
*x = vectors->bounds_x1;
|
||||
*y = vectors->bounds_y1;
|
||||
*width = vectors->bounds_x2 - vectors->bounds_x1;
|
||||
*height = vectors->bounds_y2 - vectors->bounds_y1;
|
||||
|
||||
return ! vectors->bounds_empty;
|
||||
}
|
||||
|
||||
static GimpItem *
|
||||
|
@ -1053,74 +1099,6 @@ gimp_vectors_real_get_distance (const GimpVectors *vectors,
|
|||
return 0;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_vectors_bounds (GimpVectors *vectors,
|
||||
gdouble *x1,
|
||||
gdouble *y1,
|
||||
gdouble *x2,
|
||||
gdouble *y2)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE);
|
||||
g_return_val_if_fail (x1 != NULL && y1 != NULL &&
|
||||
x2 != NULL && y2 != NULL, FALSE);
|
||||
|
||||
if (! vectors->bounds_valid)
|
||||
{
|
||||
GimpStroke *stroke;
|
||||
|
||||
vectors->bounds_empty = TRUE;
|
||||
vectors->bounds_x1 = vectors->bounds_x2 = 0.0;
|
||||
vectors->bounds_y1 = vectors->bounds_y2 = 0.0;
|
||||
|
||||
for (stroke = gimp_vectors_stroke_get_next (vectors, NULL);
|
||||
stroke;
|
||||
stroke = gimp_vectors_stroke_get_next (vectors, stroke))
|
||||
{
|
||||
GArray *stroke_coords;
|
||||
gboolean closed;
|
||||
|
||||
stroke_coords = gimp_stroke_interpolate (stroke, 1.0, &closed);
|
||||
|
||||
if (stroke_coords)
|
||||
{
|
||||
GimpCoords point;
|
||||
gint i;
|
||||
|
||||
if (vectors->bounds_empty && stroke_coords->len > 0)
|
||||
{
|
||||
point = g_array_index (stroke_coords, GimpCoords, 0);
|
||||
|
||||
vectors->bounds_x1 = vectors->bounds_x2 = point.x;
|
||||
vectors->bounds_y1 = vectors->bounds_y2 = point.y;
|
||||
|
||||
vectors->bounds_empty = FALSE;
|
||||
}
|
||||
|
||||
for (i = 0; i < stroke_coords->len; i++)
|
||||
{
|
||||
point = g_array_index (stroke_coords, GimpCoords, i);
|
||||
|
||||
vectors->bounds_x1 = MIN (vectors->bounds_x1, point.x);
|
||||
vectors->bounds_y1 = MIN (vectors->bounds_y1, point.y);
|
||||
vectors->bounds_x2 = MAX (vectors->bounds_x2, point.x);
|
||||
vectors->bounds_y2 = MAX (vectors->bounds_y2, point.y);
|
||||
}
|
||||
|
||||
g_array_free (stroke_coords, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
vectors->bounds_valid = TRUE;
|
||||
}
|
||||
|
||||
*x1 = vectors->bounds_x1;
|
||||
*y1 = vectors->bounds_y1;
|
||||
*x2 = vectors->bounds_x2;
|
||||
*y2 = vectors->bounds_y2;
|
||||
|
||||
return (! vectors->bounds_empty);
|
||||
}
|
||||
|
||||
gint
|
||||
gimp_vectors_interpolate (const GimpVectors *vectors,
|
||||
const GimpStroke *stroke,
|
||||
|
|
|
@ -166,14 +166,8 @@ gdouble gimp_vectors_get_length (const GimpVectors *vectors,
|
|||
gdouble gimp_vectors_get_distance (const GimpVectors *vectors,
|
||||
const GimpCoords *coord);
|
||||
|
||||
gboolean gimp_vectors_bounds (GimpVectors *vectors,
|
||||
gdouble *x1,
|
||||
gdouble *y1,
|
||||
gdouble *x2,
|
||||
gdouble *y2);
|
||||
|
||||
|
||||
/* returns the number of valid coordinates */
|
||||
|
||||
gint gimp_vectors_interpolate (const GimpVectors *vectors,
|
||||
const GimpStroke *stroke,
|
||||
gdouble precision,
|
||||
|
|
Loading…
Reference in New Issue