static void gimp_vectors_transform (GimpItem *item, GimpContext *context, const GimpMatrix3 *matrix, GimpTransformDirection direction, GimpInterpolationType interpolation_type, GimpTransformResize clip_result, GimpProgress *progress) { GimpVectors *vectors = GIMP_VECTORS (item); GimpMatrix3 local_matrix; GList *list; gimp_vectors_freeze (vectors); gimp_image_undo_push_vectors_mod (gimp_item_get_image (item), _("Transform Path"), vectors); local_matrix = *matrix; if (direction == GIMP_TRANSFORM_BACKWARD) gimp_matrix3_invert (&local_matrix); for (list = vectors->strokes; list; list = g_list_next (list)) { GimpStroke *stroke = list->data; gimp_stroke_transform (stroke, &local_matrix); } gimp_vectors_thaw (vectors); }
static void gimp_vectors_mod_undo_pop (GimpUndo *undo, GimpUndoMode undo_mode, GimpUndoAccumulator *accum) { GimpVectorsModUndo *vectors_mod_undo = GIMP_VECTORS_MOD_UNDO (undo); GimpVectors *vectors = GIMP_VECTORS (GIMP_ITEM_UNDO (undo)->item); GimpVectors *temp; GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum); temp = vectors_mod_undo->vectors; vectors_mod_undo->vectors = GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vectors), G_TYPE_FROM_INSTANCE (vectors), FALSE)); gimp_vectors_freeze (vectors); gimp_vectors_copy_strokes (temp, vectors); GIMP_ITEM (vectors)->width = GIMP_ITEM (temp)->width; GIMP_ITEM (vectors)->height = GIMP_ITEM (temp)->height; GIMP_ITEM (vectors)->offset_x = GIMP_ITEM (temp)->offset_x; GIMP_ITEM (vectors)->offset_y = GIMP_ITEM (temp)->offset_y; g_object_unref (temp); gimp_vectors_thaw (vectors); }
void gimp_vectors_add_strokes (const GimpVectors *src_vectors, GimpVectors *dest_vectors) { GList *current_lstroke; GList *strokes_copy; g_return_if_fail (GIMP_IS_VECTORS (src_vectors)); g_return_if_fail (GIMP_IS_VECTORS (dest_vectors)); gimp_vectors_freeze (dest_vectors); strokes_copy = g_list_copy (src_vectors->strokes); current_lstroke = strokes_copy; while (current_lstroke) { current_lstroke->data = gimp_stroke_duplicate (current_lstroke->data); dest_vectors->last_stroke_ID ++; gimp_stroke_set_ID (current_lstroke->data, dest_vectors->last_stroke_ID); current_lstroke = g_list_next (current_lstroke); } dest_vectors->strokes = g_list_concat (dest_vectors->strokes, strokes_copy); gimp_vectors_thaw (dest_vectors); }
static void gimp_vectors_rotate (GimpItem *item, GimpContext *context, GimpRotationType rotate_type, gdouble center_x, gdouble center_y, gboolean clip_result) { GimpVectors *vectors = GIMP_VECTORS (item); GList *list; GimpMatrix3 matrix; gimp_matrix3_identity (&matrix); gimp_transform_matrix_rotate (&matrix, rotate_type, center_x, center_y); gimp_vectors_freeze (vectors); gimp_image_undo_push_vectors_mod (gimp_item_get_image (item), _("Rotate Path"), vectors); for (list = vectors->strokes; list; list = g_list_next (list)) { GimpStroke *stroke = list->data; gimp_stroke_transform (stroke, &matrix); } gimp_vectors_thaw (vectors); }
static void gimp_vectors_resize (GimpItem *item, GimpContext *context, gint new_width, gint new_height, gint offset_x, gint offset_y) { GimpVectors *vectors = GIMP_VECTORS (item); GimpImage *image = gimp_item_get_image (item); GList *list; gimp_vectors_freeze (vectors); if (gimp_item_is_attached (item)) gimp_image_undo_push_vectors_mod (image, NULL, vectors); for (list = vectors->strokes; list; list = g_list_next (list)) { GimpStroke *stroke = list->data; gimp_stroke_translate (stroke, offset_x, offset_y); } GIMP_ITEM_CLASS (parent_class)->resize (item, context, gimp_image_get_width (image), gimp_image_get_height (image), 0, 0); gimp_vectors_thaw (vectors); }
static void gimp_vectors_translate (GimpItem *item, gint offset_x, gint offset_y, gboolean push_undo) { GimpVectors *vectors = GIMP_VECTORS (item); GList *list; gimp_vectors_freeze (vectors); if (push_undo) gimp_image_undo_push_vectors_mod (gimp_item_get_image (item), _("Move Path"), vectors); for (list = vectors->strokes; list; list = g_list_next (list)) { GimpStroke *stroke = list->data; gimp_stroke_translate (stroke, offset_x, offset_y); } gimp_vectors_thaw (vectors); }
void gimp_vectors_stroke_remove (GimpVectors *vectors, GimpStroke *stroke) { g_return_if_fail (GIMP_IS_VECTORS (vectors)); g_return_if_fail (GIMP_IS_STROKE (stroke)); gimp_vectors_freeze (vectors); GIMP_VECTORS_GET_CLASS (vectors)->stroke_remove (vectors, stroke); gimp_vectors_thaw (vectors); }
void gimp_vectors_copy_strokes (const GimpVectors *src_vectors, GimpVectors *dest_vectors) { g_return_if_fail (GIMP_IS_VECTORS (src_vectors)); g_return_if_fail (GIMP_IS_VECTORS (dest_vectors)); gimp_vectors_freeze (dest_vectors); if (dest_vectors->strokes) { g_list_free_full (dest_vectors->strokes, (GDestroyNotify) g_object_unref); } dest_vectors->strokes = NULL; dest_vectors->last_stroke_ID = 0; gimp_vectors_add_strokes (src_vectors, dest_vectors); gimp_vectors_thaw (dest_vectors); }
static void gimp_vectors_scale (GimpItem *item, gint new_width, gint new_height, gint new_offset_x, gint new_offset_y, GimpInterpolationType interpolation_type, GimpProgress *progress) { GimpVectors *vectors = GIMP_VECTORS (item); GimpImage *image = gimp_item_get_image (item); GList *list; gimp_vectors_freeze (vectors); if (gimp_item_is_attached (item)) gimp_image_undo_push_vectors_mod (image, NULL, vectors); for (list = vectors->strokes; list; list = g_list_next (list)) { GimpStroke *stroke = list->data; gimp_stroke_scale (stroke, (gdouble) new_width / (gdouble) gimp_item_get_width (item), (gdouble) new_height / (gdouble) gimp_item_get_height (item)); gimp_stroke_translate (stroke, new_offset_x, new_offset_y); } GIMP_ITEM_CLASS (parent_class)->scale (item, gimp_image_get_width (image), gimp_image_get_height (image), 0, 0, interpolation_type, progress); gimp_vectors_thaw (vectors); }