From 4e335f7fc2b4de9a807499c8ea53a74eafe35c5c Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Tue, 20 May 2003 11:55:12 +0000 Subject: [PATCH] no need to include gimp-intl.h. 2003-05-20 Sven Neumann * app/core/gimpimage-flip.c: no need to include gimp-intl.h. * app/core/gimpimage-rotate.c: change the image size if needed; implemented rotation of guides. * app/vectors/gimpvectors.c: implemented rotation of vectors. --- ChangeLog | 9 +++ app/core/gimpimage-flip.c | 2 - app/core/gimpimage-rotate.c | 124 ++++++++++++++++++++++++++++-------- app/vectors/gimpvectors.c | 39 +++++++----- 4 files changed, 132 insertions(+), 42 deletions(-) diff --git a/ChangeLog b/ChangeLog index 50e7ee3cd5..1511cc3b7e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2003-05-20 Sven Neumann + + * app/core/gimpimage-flip.c: no need to include gimp-intl.h. + + * app/core/gimpimage-rotate.c: change the image size if needed; + implemented rotation of guides. + + * app/vectors/gimpvectors.c: implemented rotation of vectors. + 2003-05-20 Michael Natterer * app/core/gimpimage-undo-push.c: remember the guide's orientation diff --git a/app/core/gimpimage-flip.c b/app/core/gimpimage-flip.c index 067cfc1a1a..ceceeb0aff 100644 --- a/app/core/gimpimage-flip.c +++ b/app/core/gimpimage-flip.c @@ -34,8 +34,6 @@ #include "gimplayer-floating-sel.h" #include "gimplist.h" -#include "gimp-intl.h" - void gimp_image_flip (GimpImage *gimage, diff --git a/app/core/gimpimage-rotate.c b/app/core/gimpimage-rotate.c index d53690791f..82e2c3a4ca 100644 --- a/app/core/gimpimage-rotate.c +++ b/app/core/gimpimage-rotate.c @@ -34,7 +34,9 @@ #include "gimplayer-floating-sel.h" #include "gimplist.h" -#include "gimp-intl.h" + +static void gimp_image_rotate_guides (GimpImage *gimage, + GimpRotationType rotate_type); void @@ -48,10 +50,12 @@ gimp_image_rotate (GimpImage *gimage, GList *list; gdouble center_x; gdouble center_y; + gint tmp; gint num_channels; gint num_layers; gint num_vectors; gint progress_current = 1; + gboolean size_changed = FALSE; g_return_if_fail (GIMP_IS_IMAGE (gimage)); @@ -73,6 +77,24 @@ gimp_image_rotate (GimpImage *gimage, if (floating_layer) floating_sel_relax (floating_layer, TRUE); + /* Resize the image (if needed) */ + switch (rotate_type) + { + case GIMP_ROTATE_90: + case GIMP_ROTATE_270: + gimp_image_undo_push_image_size (gimage, NULL); + + tmp = gimage->width; + gimage->width = gimage->height; + gimage->height = tmp; + + size_changed = TRUE; + break; + + case GIMP_ROTATE_180: + break; + } + /* Rotate all channels */ for (list = GIMP_LIST (gimage->channels)->list; list; @@ -124,30 +146,7 @@ gimp_image_rotate (GimpImage *gimage, } /* Rotate all Guides */ -#if 0 /* FIXME: implement! */ - for (list = gimage->guides; list; list = g_list_next (list)) - { - GimpGuide *guide = list->data; - - switch (guide->orientation) - { - case GIMP_ORIENTATION_HORIZONTAL: - if (rotate_type == GIMP_ORIENTATION_VERTICAL) - gimp_image_move_guide (gimage, guide, - gimage->height - guide->position, TRUE); - break; - - case GIMP_ORIENTATION_VERTICAL: - if (rotate_type == GIMP_ORIENTATION_HORIZONTAL) - gimp_image_move_guide (gimage, guide, - gimage->width - guide->position, TRUE); - break; - - default: - break; - } - } -#endif + gimp_image_rotate_guides (gimage, rotate_type); /* Make sure the projection matches the gimage size */ gimp_image_projection_allocate (gimage); @@ -158,7 +157,82 @@ gimp_image_rotate (GimpImage *gimage, gimp_image_undo_group_end (gimage); + if (size_changed) + gimp_viewable_size_changed (GIMP_VIEWABLE (gimage)); + gimp_image_mask_changed (gimage); gimp_unset_busy (gimage->gimp); } + +static void +gimp_image_rotate_guides (GimpImage *gimage, + GimpRotationType rotate_type) +{ + GList *list; + + /* Rotate all Guides */ + for (list = gimage->guides; list; list = g_list_next (list)) + { + GimpGuide *guide = list->data; + + switch (rotate_type) + { + case GIMP_ROTATE_90: + switch (guide->orientation) + { + case GIMP_ORIENTATION_HORIZONTAL: + gimp_image_undo_push_image_guide (gimage, NULL, guide); + guide->orientation = GIMP_ORIENTATION_VERTICAL; + guide->position = gimage->width - guide->position; + break; + + case GIMP_ORIENTATION_VERTICAL: + gimp_image_undo_push_image_guide (gimage, NULL, guide); + guide->orientation = GIMP_ORIENTATION_HORIZONTAL; + break; + + default: + break; + } + break; + + case GIMP_ROTATE_180: + switch (guide->orientation) + { + case GIMP_ORIENTATION_HORIZONTAL: + gimp_image_move_guide (gimage, guide, + gimage->height - guide->position, TRUE); + break; + + case GIMP_ORIENTATION_VERTICAL: + gimp_image_move_guide (gimage, guide, + gimage->width - guide->position, TRUE); + break; + + default: + break; + } + break; + + case GIMP_ROTATE_270: + switch (guide->orientation) + { + case GIMP_ORIENTATION_HORIZONTAL: + gimp_image_undo_push_image_guide (gimage, NULL, guide); + guide->orientation = GIMP_ORIENTATION_VERTICAL; + break; + + case GIMP_ORIENTATION_VERTICAL: + gimp_image_undo_push_image_guide (gimage, NULL, guide); + guide->orientation = GIMP_ORIENTATION_HORIZONTAL; + guide->position = gimage->height - guide->position; + break; + + default: + break; + } + break; + } + } +} diff --git a/app/vectors/gimpvectors.c b/app/vectors/gimpvectors.c index 6613902784..ed4b7c64b4 100644 --- a/app/vectors/gimpvectors.c +++ b/app/vectors/gimpvectors.c @@ -25,6 +25,7 @@ #include "vectors-types.h" +#include "core/gimpdrawable-transform-utils.h" #include "core/gimpimage.h" #include "core/gimpimage-undo-push.h" #include "core/gimpmarshal.h" @@ -445,6 +446,24 @@ gimp_vectors_rotate (GimpItem *item, { GimpVectors *vectors; GList *list; + GimpMatrix3 matrix; + gdouble angle = 0.0; + + switch (rotate_type) + { + case GIMP_ROTATE_90: + angle = - G_PI_2; + break; + case GIMP_ROTATE_180: + angle = G_PI; + break; + case GIMP_ROTATE_270: + angle = G_PI_2; + break; + } + + gimp_drawable_transform_matrix_rotate_center (center_x, center_y, angle, + matrix); vectors = GIMP_VECTORS (item); @@ -454,7 +473,6 @@ gimp_vectors_rotate (GimpItem *item, _("Rotate Path"), vectors); -#if 0 /* FIXME: implement! */ for (list = vectors->strokes; list; list = g_list_next (list)) { GimpStroke *stroke = list->data; @@ -464,22 +482,13 @@ gimp_vectors_rotate (GimpItem *item, { GimpAnchor *anchor = list2->data; - switch (flip_type) - { - case GIMP_ORIENTATION_HORIZONTAL: - anchor->position.x = -(anchor->position.x - axis) + axis; - break; - - case GIMP_ORIENTATION_VERTICAL: - anchor->position.y = -(anchor->position.y - axis) + axis; - break; - - default: - break; - } + gimp_matrix3_transform_point (matrix, + anchor->position.x, + anchor->position.y, + &anchor->position.x, + &anchor->position.y); } } -#endif gimp_vectors_thaw (vectors); }