mirror of https://github.com/GNOME/gimp.git
added gimp_paint_core_stroke_vectors() which strokes the whole vector
2002-02-26 Michael Natterer <mitch@gimp.org> * app/paint/gimppaintcore-stroke.[ch]: added gimp_paint_core_stroke_vectors() which strokes the whole vector using one undo step. * app/gui/vectors-commands.c: use the new function. * app/tools/gimpvectortool.c: changed to do evil voodoo in gimp_vectors_tool_set_vectors() and thus to always find a display to show the vectors.
This commit is contained in:
parent
316d84552d
commit
5aa1c92f6d
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2002-02-26 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/paint/gimppaintcore-stroke.[ch]: added
|
||||
gimp_paint_core_stroke_vectors() which strokes the whole vector
|
||||
using one undo step.
|
||||
|
||||
* app/gui/vectors-commands.c: use the new function.
|
||||
|
||||
* app/tools/gimpvectortool.c: changed to do evil voodoo in
|
||||
gimp_vectors_tool_set_vectors() and thus to always find a
|
||||
display to show the vectors.
|
||||
|
||||
2002-02-26 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* NEWS: updated
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include "paint/gimppaintcore.h"
|
||||
#include "paint/gimppaintcore-stroke.h"
|
||||
|
||||
#include "vectors/gimpstroke.h"
|
||||
#include "vectors/gimpvectors.h"
|
||||
|
||||
#include "display/gimpdisplay-foreach.h"
|
||||
|
@ -341,7 +340,6 @@ vectors_stroke_vectors_cmd_callback (GtkWidget *widget,
|
|||
GimpToolInfo *tool_info;
|
||||
GimpPaintOptions *paint_options;
|
||||
GimpDisplay *gdisp;
|
||||
GimpStroke *stroke;
|
||||
|
||||
tool_info = (GimpToolInfo *)
|
||||
gimp_container_get_child_by_name (gimage->gimp->tool_info_list,
|
||||
|
@ -351,37 +349,16 @@ vectors_stroke_vectors_cmd_callback (GtkWidget *widget,
|
|||
|
||||
core_type = g_type_from_name (tool_info->paint_core_name);
|
||||
|
||||
core = g_object_new (g_type_from_name (tool_info->paint_core_name), NULL);
|
||||
core = g_object_new (core_type, NULL);
|
||||
|
||||
gdisp = gimp_context_get_display (gimp_get_current_context (gimage->gimp));
|
||||
|
||||
tool_manager_control_active (gimage->gimp, PAUSE, gdisp);
|
||||
|
||||
undo_push_group_start (gimage, PAINT_UNDO_GROUP);
|
||||
|
||||
for (stroke = active_vectors->strokes; stroke; stroke = stroke->next)
|
||||
{
|
||||
GimpCoords *coords;
|
||||
gint n_coords;
|
||||
gboolean closed;
|
||||
|
||||
coords = gimp_stroke_interpolate (stroke, 1.0,
|
||||
&n_coords,
|
||||
&closed);
|
||||
|
||||
if (coords)
|
||||
{
|
||||
gimp_paint_core_stroke (core,
|
||||
gimp_paint_core_stroke_vectors (core,
|
||||
active_drawable,
|
||||
paint_options,
|
||||
coords,
|
||||
n_coords);
|
||||
|
||||
g_free (coords);
|
||||
}
|
||||
}
|
||||
|
||||
undo_push_group_end (gimage);
|
||||
active_vectors);
|
||||
|
||||
tool_manager_control_active (gimage->gimp, RESUME, gdisp);
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include "paint/gimppaintcore.h"
|
||||
#include "paint/gimppaintcore-stroke.h"
|
||||
|
||||
#include "vectors/gimpstroke.h"
|
||||
#include "vectors/gimpvectors.h"
|
||||
|
||||
#include "display/gimpdisplay-foreach.h"
|
||||
|
@ -341,7 +340,6 @@ vectors_stroke_vectors_cmd_callback (GtkWidget *widget,
|
|||
GimpToolInfo *tool_info;
|
||||
GimpPaintOptions *paint_options;
|
||||
GimpDisplay *gdisp;
|
||||
GimpStroke *stroke;
|
||||
|
||||
tool_info = (GimpToolInfo *)
|
||||
gimp_container_get_child_by_name (gimage->gimp->tool_info_list,
|
||||
|
@ -351,37 +349,16 @@ vectors_stroke_vectors_cmd_callback (GtkWidget *widget,
|
|||
|
||||
core_type = g_type_from_name (tool_info->paint_core_name);
|
||||
|
||||
core = g_object_new (g_type_from_name (tool_info->paint_core_name), NULL);
|
||||
core = g_object_new (core_type, NULL);
|
||||
|
||||
gdisp = gimp_context_get_display (gimp_get_current_context (gimage->gimp));
|
||||
|
||||
tool_manager_control_active (gimage->gimp, PAUSE, gdisp);
|
||||
|
||||
undo_push_group_start (gimage, PAINT_UNDO_GROUP);
|
||||
|
||||
for (stroke = active_vectors->strokes; stroke; stroke = stroke->next)
|
||||
{
|
||||
GimpCoords *coords;
|
||||
gint n_coords;
|
||||
gboolean closed;
|
||||
|
||||
coords = gimp_stroke_interpolate (stroke, 1.0,
|
||||
&n_coords,
|
||||
&closed);
|
||||
|
||||
if (coords)
|
||||
{
|
||||
gimp_paint_core_stroke (core,
|
||||
gimp_paint_core_stroke_vectors (core,
|
||||
active_drawable,
|
||||
paint_options,
|
||||
coords,
|
||||
n_coords);
|
||||
|
||||
g_free (coords);
|
||||
}
|
||||
}
|
||||
|
||||
undo_push_group_end (gimage);
|
||||
active_vectors);
|
||||
|
||||
tool_manager_control_active (gimage->gimp, RESUME, gdisp);
|
||||
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
|
||||
#include "core/gimpdrawable.h"
|
||||
|
||||
#include "vectors/gimpstroke.h"
|
||||
#include "vectors/gimpvectors.h"
|
||||
|
||||
#include "gimppaintcore.h"
|
||||
#include "gimppaintcore-stroke.h"
|
||||
|
||||
|
@ -72,3 +75,100 @@ gimp_paint_core_stroke (GimpPaintCore *core,
|
|||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_paint_core_stroke_vectors (GimpPaintCore *core,
|
||||
GimpDrawable *drawable,
|
||||
GimpPaintOptions *paint_options,
|
||||
GimpVectors *vectors)
|
||||
{
|
||||
GimpStroke *stroke;
|
||||
GimpCoords *coords = NULL;
|
||||
gint n_coords;
|
||||
gboolean closed;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_PAINT_CORE (core), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
|
||||
g_return_val_if_fail (paint_options != NULL, FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE);
|
||||
|
||||
/* gimp_stroke_interpolate() may return NULL, so iterate over the
|
||||
* list of strokes until one returns coords
|
||||
*/
|
||||
for (stroke = vectors->strokes; stroke; stroke = stroke->next)
|
||||
{
|
||||
coords = gimp_stroke_interpolate (stroke, 1.0,
|
||||
&n_coords,
|
||||
&closed);
|
||||
|
||||
if (coords)
|
||||
break;
|
||||
}
|
||||
|
||||
if (! coords)
|
||||
return FALSE;
|
||||
|
||||
if (! gimp_paint_core_start (core, drawable, &coords[0]))
|
||||
{
|
||||
g_free (coords);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gimp_paint_core_paint (core, drawable, paint_options, INIT_PAINT);
|
||||
|
||||
do
|
||||
{
|
||||
gint i;
|
||||
|
||||
core->start_coords = coords[0];
|
||||
core->last_coords = coords[0];
|
||||
|
||||
gimp_paint_core_paint (core, drawable, paint_options, MOTION_PAINT);
|
||||
|
||||
for (i = 1; i < n_coords; i++)
|
||||
{
|
||||
core->cur_coords = coords[i];
|
||||
|
||||
gimp_paint_core_interpolate (core, drawable, paint_options);
|
||||
|
||||
core->last_coords = core->cur_coords;
|
||||
}
|
||||
|
||||
if (closed)
|
||||
{
|
||||
core->cur_coords = coords[0];
|
||||
|
||||
gimp_paint_core_interpolate (core, drawable, paint_options);
|
||||
|
||||
core->last_coords = core->cur_coords;
|
||||
}
|
||||
|
||||
g_free (coords);
|
||||
coords = NULL;
|
||||
|
||||
if (stroke->next)
|
||||
{
|
||||
stroke = stroke->next;
|
||||
|
||||
/* see above */
|
||||
for ( ; stroke; stroke = stroke->next)
|
||||
{
|
||||
coords = gimp_stroke_interpolate (stroke, 1.0,
|
||||
&n_coords,
|
||||
&closed);
|
||||
|
||||
if (coords)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (coords);
|
||||
|
||||
gimp_paint_core_paint (core, drawable, paint_options, FINISH_PAINT);
|
||||
|
||||
gimp_paint_core_finish (core, drawable);
|
||||
|
||||
gimp_paint_core_cleanup (core);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -20,11 +20,15 @@
|
|||
#define __GIMP_PAINT_CORE_STROKE_H__
|
||||
|
||||
|
||||
gboolean gimp_paint_core_stroke (GimpPaintCore *core,
|
||||
GimpDrawable *drawable,
|
||||
GimpPaintOptions *paint_options,
|
||||
GimpCoords *strokes,
|
||||
gint n_strokes);
|
||||
gboolean gimp_paint_core_stroke (GimpPaintCore *core,
|
||||
GimpDrawable *drawable,
|
||||
GimpPaintOptions *paint_options,
|
||||
GimpCoords *strokes,
|
||||
gint n_strokes);
|
||||
gboolean gimp_paint_core_stroke_vectors (GimpPaintCore *core,
|
||||
GimpDrawable *drawable,
|
||||
GimpPaintOptions *paint_options,
|
||||
GimpVectors *vectors);
|
||||
|
||||
|
||||
#endif /* __GIMP_PAINT_CORE_STROKE_H__ */
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#include "tools-types.h"
|
||||
#include "gui/gui-types.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-guides.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
@ -526,23 +528,79 @@ void
|
|||
gimp_vector_tool_set_vectors (GimpVectorTool *vector_tool,
|
||||
GimpVectors *vectors)
|
||||
{
|
||||
GimpDrawTool *draw_tool;
|
||||
GimpTool *tool;
|
||||
GimpItem *item;
|
||||
|
||||
g_return_if_fail (GIMP_IS_VECTOR_TOOL (vector_tool));
|
||||
g_return_if_fail (GIMP_IS_VECTORS (vectors));
|
||||
|
||||
gimp_draw_tool_pause (GIMP_DRAW_TOOL (vector_tool));
|
||||
draw_tool = GIMP_DRAW_TOOL (vector_tool);
|
||||
tool = GIMP_TOOL (vector_tool);
|
||||
item = GIMP_ITEM (vectors);
|
||||
|
||||
if (draw_tool->gdisp)
|
||||
{
|
||||
if (draw_tool->gdisp->gimage == item->gimage)
|
||||
gimp_draw_tool_pause (draw_tool);
|
||||
else
|
||||
gimp_draw_tool_stop (draw_tool);
|
||||
}
|
||||
|
||||
if (vector_tool->vectors)
|
||||
g_object_unref (G_OBJECT (vector_tool->vectors));
|
||||
|
||||
vector_tool->vectors = vectors;
|
||||
vector_tool->cur_stroke = NULL;
|
||||
vector_tool->cur_anchor = NULL;
|
||||
vector_tool->vectors = vectors;
|
||||
vector_tool->cur_stroke = NULL;
|
||||
vector_tool->cur_anchor = NULL;
|
||||
vector_tool->active_anchors = NULL;
|
||||
vector_tool->function = VECTORS_CREATING;
|
||||
|
||||
if (vector_tool->vectors)
|
||||
g_object_ref (G_OBJECT (vector_tool->vectors));
|
||||
|
||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (vector_tool));
|
||||
if (draw_tool->gdisp && draw_tool->gdisp->gimage == item->gimage)
|
||||
{
|
||||
gimp_draw_tool_resume (draw_tool);
|
||||
}
|
||||
else if (tool->gdisp && tool->gdisp->gimage == item->gimage)
|
||||
{
|
||||
gimp_draw_tool_start (draw_tool, tool->gdisp);
|
||||
}
|
||||
else
|
||||
{
|
||||
GimpContext *context;
|
||||
GimpDisplay *gdisp;
|
||||
|
||||
context = gimp_get_current_context (tool->tool_info->gimp);
|
||||
|
||||
gdisp = gimp_context_get_display (context);
|
||||
|
||||
if (gdisp->gimage != item->gimage)
|
||||
{
|
||||
GSList *list;
|
||||
|
||||
gdisp = NULL;
|
||||
|
||||
for (list = display_list; list; list = g_slist_next (list))
|
||||
{
|
||||
if (((GimpDisplay *) list->data)->gimage == item->gimage)
|
||||
{
|
||||
gimp_context_set_display (context,
|
||||
(GimpDisplay *) list->data);
|
||||
|
||||
gdisp = gimp_context_get_display (context);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (! gdisp)
|
||||
return;
|
||||
}
|
||||
|
||||
tool->gdisp = gdisp;
|
||||
tool->state = ACTIVE;
|
||||
|
||||
gimp_draw_tool_start (draw_tool, tool->gdisp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue