mirror of https://github.com/GNOME/gimp.git
Implemented an (unused/untested) gimp_vectors_bounds () that returns the
2003-09-16 Simon Budig <simon@gimp.org> * app/vectors/gimpvectors.[ch]: Implemented an (unused/untested) gimp_vectors_bounds () that returns the bounding box of an vectors object. * app/tools/gimpdrawtool.[ch]: made gimp_draw_tool_on_vectors() ignore handles/anchors, since they are not visible when that function gets used.
This commit is contained in:
parent
0e407cba35
commit
e899c701ba
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2003-09-16 Simon Budig <simon@gimp.org>
|
||||
|
||||
* app/vectors/gimpvectors.[ch]: Implemented an (unused/untested)
|
||||
gimp_vectors_bounds () that returns the bounding box of an vectors
|
||||
object.
|
||||
|
||||
* app/tools/gimpdrawtool.[ch]: made gimp_draw_tool_on_vectors()
|
||||
ignore handles/anchors, since they are not visible when that
|
||||
function gets used.
|
||||
|
||||
2003-09-15 Simon Budig <simon@gimp.org>
|
||||
|
||||
* app/core/gimpimage.c: fixed bogus
|
||||
|
|
|
@ -1039,19 +1039,19 @@ gimp_draw_tool_on_vectors (GimpDrawTool *draw_tool,
|
|||
gint height,
|
||||
GimpCoords *ret_coords,
|
||||
gdouble *ret_pos,
|
||||
GimpAnchor **ret_anchor,
|
||||
GimpAnchor **ret_segment_start,
|
||||
GimpStroke **ret_stroke,
|
||||
GimpVectors **ret_vectors)
|
||||
{
|
||||
GList *list;
|
||||
GimpVectors *vectors;
|
||||
gboolean on_handle, on_curve;
|
||||
gboolean on_curve;
|
||||
|
||||
if (ret_coords) *ret_coords = *coords;
|
||||
if (ret_pos) *ret_pos = -1.0;
|
||||
if (ret_anchor) *ret_anchor = NULL;
|
||||
if (ret_stroke) *ret_stroke = NULL;
|
||||
if (ret_vectors) *ret_vectors = NULL;
|
||||
if (ret_coords) *ret_coords = *coords;
|
||||
if (ret_pos) *ret_pos = -1.0;
|
||||
if (ret_segment_start) *ret_segment_start = NULL;
|
||||
if (ret_stroke) *ret_stroke = NULL;
|
||||
if (ret_vectors) *ret_vectors = NULL;
|
||||
|
||||
for (list = GIMP_LIST (gdisp->gimage->vectors)->list;
|
||||
list;
|
||||
|
@ -1062,25 +1062,16 @@ gimp_draw_tool_on_vectors (GimpDrawTool *draw_tool,
|
|||
if (! gimp_item_get_visible (GIMP_ITEM (vectors)))
|
||||
continue;
|
||||
|
||||
on_handle = gimp_draw_tool_on_vectors_handle (draw_tool,
|
||||
gdisp,
|
||||
vectors, coords,
|
||||
width, height,
|
||||
GIMP_ANCHOR_ANCHOR,
|
||||
ret_anchor,
|
||||
ret_stroke);
|
||||
on_curve = gimp_draw_tool_on_vectors_curve (draw_tool,
|
||||
gdisp,
|
||||
vectors, coords,
|
||||
width, height,
|
||||
ret_coords,
|
||||
ret_pos,
|
||||
ret_segment_start,
|
||||
ret_stroke);
|
||||
|
||||
if (! on_handle)
|
||||
on_curve = gimp_draw_tool_on_vectors_curve (draw_tool,
|
||||
gdisp,
|
||||
vectors, coords,
|
||||
width, height,
|
||||
ret_coords,
|
||||
ret_pos,
|
||||
ret_anchor,
|
||||
ret_stroke);
|
||||
|
||||
if (on_handle || on_curve)
|
||||
if (on_curve)
|
||||
{
|
||||
if (ret_vectors)
|
||||
*ret_vectors = vectors;
|
||||
|
|
|
@ -205,7 +205,7 @@ gboolean gimp_draw_tool_on_vectors (GimpDrawTool *draw_tool,
|
|||
gint height,
|
||||
GimpCoords *ret_coords,
|
||||
gdouble *ret_pos,
|
||||
GimpAnchor **ret_anchor,
|
||||
GimpAnchor **ret_segment_start,
|
||||
GimpStroke **ret_stroke,
|
||||
GimpVectors **ret_vectors);
|
||||
|
||||
|
|
|
@ -905,6 +905,56 @@ gimp_vectors_real_get_distance (const GimpVectors *vectors,
|
|||
return 0;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_vectors_bounds (const GimpVectors *vectors,
|
||||
gdouble *x1,
|
||||
gdouble *y1,
|
||||
gdouble *x2,
|
||||
gdouble *y2)
|
||||
{
|
||||
GArray *stroke_coords;
|
||||
GimpStroke *cur_stroke;
|
||||
gint i;
|
||||
gboolean has_strokes = FALSE;
|
||||
gboolean closed;
|
||||
GimpCoords point;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE);
|
||||
g_return_val_if_fail (x1 != NULL, FALSE);
|
||||
g_return_val_if_fail (y1 != NULL, FALSE);
|
||||
g_return_val_if_fail (x2 != NULL, FALSE);
|
||||
g_return_val_if_fail (y2 != NULL, FALSE);
|
||||
|
||||
for (cur_stroke = gimp_vectors_stroke_get_next (vectors, NULL);
|
||||
cur_stroke;
|
||||
cur_stroke = gimp_vectors_stroke_get_next (vectors, cur_stroke))
|
||||
{
|
||||
stroke_coords = gimp_stroke_interpolate (cur_stroke, 1.0, &closed);
|
||||
|
||||
if (stroke_coords)
|
||||
{
|
||||
if (! has_strokes && stroke_coords->len > 0)
|
||||
{
|
||||
has_strokes = TRUE;
|
||||
point = g_array_index (stroke_coords, GimpCoords, 0);
|
||||
*x1 = *x2 = point.x;
|
||||
*y1 = *y2 = point.y;
|
||||
}
|
||||
|
||||
for (i=0; i < stroke_coords->len; i++)
|
||||
{
|
||||
point = g_array_index (stroke_coords, GimpCoords, i);
|
||||
*x1 = MIN (*x1, point.x);
|
||||
*y1 = MIN (*y1, point.y);
|
||||
*x2 = MIN (*x2, point.x);
|
||||
*y2 = MIN (*y2, point.y);
|
||||
}
|
||||
g_array_free (stroke_coords, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
return has_strokes;
|
||||
}
|
||||
|
||||
gint
|
||||
gimp_vectors_interpolate (const GimpVectors *vectors,
|
||||
|
|
|
@ -149,6 +149,12 @@ gdouble gimp_vectors_get_length (const GimpVectors *vectors,
|
|||
const GimpAnchor *start);
|
||||
gdouble gimp_vectors_get_distance (const GimpVectors *vectors,
|
||||
const GimpCoords *coord);
|
||||
gboolean gimp_vectors_bounds (const GimpVectors *vectors,
|
||||
gdouble *x1,
|
||||
gdouble *y1,
|
||||
gdouble *x2,
|
||||
gdouble *y2);
|
||||
|
||||
|
||||
/* returns the number of valid coordinates */
|
||||
gint gimp_vectors_interpolate (const GimpVectors *vectors,
|
||||
|
|
Loading…
Reference in New Issue