[gimp] app: remove lots of junk from GimpPerspectiveCloneTool



commit dde7d6c0ee2bf34d12db81461bd0f9c018356dfe
Author: Michael Natterer <mitch gimp org>
Date:   Mon Mar 28 01:08:24 2011 +0200

    app: remove lots of junk from GimpPerspectiveCloneTool
    
    This is an evil transform tool copy, so do the same changes here.

 app/tools/gimpperspectiveclonetool.c |  270 ++++++++++++++--------------------
 app/tools/gimpperspectiveclonetool.h |   20 ---
 2 files changed, 108 insertions(+), 182 deletions(-)
---
diff --git a/app/tools/gimpperspectiveclonetool.c b/app/tools/gimpperspectiveclonetool.c
index a0c107f..21f29a6 100644
--- a/app/tools/gimpperspectiveclonetool.c
+++ b/app/tools/gimpperspectiveclonetool.c
@@ -109,10 +109,8 @@ static void          gimp_perspective_clone_tool_draw                   (GimpDra
 static void          gimp_perspective_clone_tool_transform_bounding_box (GimpPerspectiveCloneTool *clone_tool);
 static void          gimp_perspective_clone_tool_bounds                 (GimpPerspectiveCloneTool *tool,
                                                                          GimpDisplay              *display);
-static void          gimp_perspective_clone_tool_prepare                (GimpPerspectiveCloneTool *clone_tool,
-                                                                         GimpDisplay              *display);
-static void          gimp_perspective_clone_tool_recalc                 (GimpPerspectiveCloneTool *clone_tool,
-                                                                         GimpDisplay              *display);
+static void          gimp_perspective_clone_tool_prepare                (GimpPerspectiveCloneTool *clone_tool);
+static void          gimp_perspective_clone_tool_recalc_matrix          (GimpPerspectiveCloneTool *clone_tool);
 
 static GtkWidget   * gimp_perspective_clone_options_gui                 (GimpToolOptions *tool_options);
 
@@ -180,16 +178,6 @@ gimp_perspective_clone_tool_init (GimpPerspectiveCloneTool *clone_tool)
     }
 
   gimp_matrix3_identity (&clone_tool->transform);
-
-  clone_tool->use_grid    = FALSE;
-  clone_tool->use_handles = TRUE;
-
-#if 0
-  clone_tool->ngx          = 0;
-  clone_tool->ngy          = 0;
-  clone_tool->grid_coords  = NULL;
-  clone_tool->tgrid_coords = NULL;
-#endif
 }
 
 static void
@@ -236,10 +224,10 @@ gimp_perspective_clone_tool_initialize (GimpTool     *tool,
       /*  Find the transform bounds initializing */
       gimp_perspective_clone_tool_bounds (clone_tool, display);
 
-      gimp_perspective_clone_tool_prepare (clone_tool, display);
+      gimp_perspective_clone_tool_prepare (clone_tool);
 
       /*  Recalculate the transform tool  */
-      gimp_perspective_clone_tool_recalc (clone_tool, display);
+      gimp_perspective_clone_tool_recalc_matrix (clone_tool);
 
       /*  start drawing the bounding box and handles...  */
       gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), display);
@@ -301,7 +289,7 @@ gimp_perspective_clone_tool_control (GimpTool       *tool,
     case GIMP_TOOL_ACTION_RESUME:
       /* only in the case that "Modify Polygon" mode is set " */
       gimp_perspective_clone_tool_bounds (clone_tool, display);
-      gimp_perspective_clone_tool_recalc (clone_tool, display);
+      gimp_perspective_clone_tool_recalc_matrix (clone_tool);
       break;
 
     case GIMP_TOOL_ACTION_HALT:
@@ -353,8 +341,8 @@ gimp_perspective_clone_tool_button_press (GimpTool            *tool,
         gimp_perspective_clone_tool_oper_update (tool,
                                                  coords, state, TRUE, display);
 
-      clone_tool->lastx = clone_tool->startx = coords->x;
-      clone_tool->lasty = clone_tool->starty = coords->y;
+      clone_tool->lastx = coords->x;
+      clone_tool->lasty = coords->y;
 
       gimp_tool_control_activate (tool->control);
       break;
@@ -419,8 +407,7 @@ gimp_perspective_clone_tool_button_release (GimpTool              *tool,
 }
 
 static void
-gimp_perspective_clone_tool_prepare (GimpPerspectiveCloneTool *clone_tool,
-                                     GimpDisplay              *display)
+gimp_perspective_clone_tool_prepare (GimpPerspectiveCloneTool *clone_tool)
 {
   clone_tool->trans_info[X0] = clone_tool->x1;
   clone_tool->trans_info[Y0] = clone_tool->y1;
@@ -433,11 +420,8 @@ gimp_perspective_clone_tool_prepare (GimpPerspectiveCloneTool *clone_tool,
 }
 
 static void
-gimp_perspective_clone_tool_recalc (GimpPerspectiveCloneTool *clone_tool,
-                                    GimpDisplay              *display)
+gimp_perspective_clone_tool_recalc_matrix (GimpPerspectiveCloneTool *clone_tool)
 {
-  g_return_if_fail (GIMP_IS_DISPLAY (display));
-
   gimp_matrix3_identity (&clone_tool->transform);
   gimp_transform_matrix_perspective (&clone_tool->transform,
                                      clone_tool->x1,
@@ -475,14 +459,13 @@ gimp_perspective_clone_tool_motion (GimpTool         *tool,
       gdouble diff_x, diff_y;
 
       /*  if we are creating, there is nothing to be done so exit.  */
-      if (clone_tool->function == TRANSFORM_CREATING /*|| ! tr_tool->use_grid*/)
+      if (clone_tool->function == TRANSFORM_CREATING)
         return;
 
       gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
 
-      clone_tool->curx  = coords->x;
-      clone_tool->cury  = coords->y;
-      clone_tool->state = state;
+      clone_tool->curx = coords->x;
+      clone_tool->cury = coords->y;
 
       /*  recalculate the tool's transformation matrix  */
 
@@ -511,7 +494,7 @@ gimp_perspective_clone_tool_motion (GimpTool         *tool,
           break;
         }
 
-      gimp_perspective_clone_tool_recalc (clone_tool, display);
+      gimp_perspective_clone_tool_recalc_matrix (clone_tool);
 
       clone_tool->lastx = clone_tool->curx;
       clone_tool->lasty = clone_tool->cury;
@@ -567,30 +550,27 @@ gimp_perspective_clone_tool_cursor_update (GimpTool         *tool,
       /* perspective cursors */
       cursor = gimp_tool_control_get_cursor (tool->control);
 
-      if (clone_tool->use_handles)
+      switch (clone_tool->function)
         {
-          switch (clone_tool->function)
-            {
-            case TRANSFORM_HANDLE_NW:
-              cursor = GIMP_CURSOR_CORNER_TOP_LEFT;
-              break;
+        case TRANSFORM_HANDLE_NW:
+          cursor = GIMP_CURSOR_CORNER_TOP_LEFT;
+          break;
 
-            case TRANSFORM_HANDLE_NE:
-              cursor = GIMP_CURSOR_CORNER_TOP_RIGHT;
-              break;
+        case TRANSFORM_HANDLE_NE:
+          cursor = GIMP_CURSOR_CORNER_TOP_RIGHT;
+          break;
 
-            case TRANSFORM_HANDLE_SW:
-              cursor = GIMP_CURSOR_CORNER_BOTTOM_LEFT;
-              break;
+        case TRANSFORM_HANDLE_SW:
+          cursor = GIMP_CURSOR_CORNER_BOTTOM_LEFT;
+          break;
 
-            case TRANSFORM_HANDLE_SE:
-              cursor = GIMP_CURSOR_CORNER_BOTTOM_RIGHT;
-              break;
+        case TRANSFORM_HANDLE_SE:
+          cursor = GIMP_CURSOR_CORNER_BOTTOM_RIGHT;
+          break;
 
-            default:
-              cursor = GIMP_CURSOR_CROSSHAIR_SMALL;
-              break;
-            }
+        default:
+          cursor = GIMP_CURSOR_CROSSHAIR_SMALL;
+          break;
         }
     }
   else
@@ -638,53 +618,49 @@ gimp_perspective_clone_tool_oper_update (GimpTool         *tool,
   if (options->clone_mode == GIMP_PERSPECTIVE_CLONE_MODE_ADJUST)
     {
       GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
+      gdouble       closest_dist;
+      gdouble       dist;
 
       clone_tool->function = TRANSFORM_HANDLE_NONE;
 
       if (display != tool->display)
         return;
 
-      if (clone_tool->use_handles)
+      dist = gimp_draw_tool_calc_distance_square (draw_tool, display,
+                                                  coords->x, coords->y,
+                                                  clone_tool->tx1,
+                                                  clone_tool->ty1);
+      closest_dist = dist;
+      clone_tool->function = TRANSFORM_HANDLE_NW;
+
+      dist = gimp_draw_tool_calc_distance_square (draw_tool, display,
+                                                  coords->x, coords->y,
+                                                  clone_tool->tx2,
+                                                  clone_tool->ty2);
+      if (dist < closest_dist)
         {
-          gdouble closest_dist;
-          gdouble dist;
-
-          dist = gimp_draw_tool_calc_distance_square (draw_tool, display,
-                                                      coords->x, coords->y,
-                                                      clone_tool->tx1,
-                                                      clone_tool->ty1);
           closest_dist = dist;
-          clone_tool->function = TRANSFORM_HANDLE_NW;
-
-          dist = gimp_draw_tool_calc_distance_square (draw_tool, display,
-                                                      coords->x, coords->y,
-                                                      clone_tool->tx2,
-                                                      clone_tool->ty2);
-          if (dist < closest_dist)
-            {
-              closest_dist = dist;
-              clone_tool->function = TRANSFORM_HANDLE_NE;
-            }
+          clone_tool->function = TRANSFORM_HANDLE_NE;
+        }
 
-          dist = gimp_draw_tool_calc_distance_square (draw_tool, display,
-                                                      coords->x, coords->y,
-                                                      clone_tool->tx3,
-                                                      clone_tool->ty3);
-          if (dist < closest_dist)
-            {
-              closest_dist = dist;
-              clone_tool->function = TRANSFORM_HANDLE_SW;
-            }
+      dist = gimp_draw_tool_calc_distance_square (draw_tool, display,
+                                                  coords->x, coords->y,
+                                                  clone_tool->tx3,
+                                                  clone_tool->ty3);
+      if (dist < closest_dist)
+        {
+          closest_dist = dist;
+          clone_tool->function = TRANSFORM_HANDLE_SW;
+        }
 
-          dist = gimp_draw_tool_calc_distance_square (draw_tool, display,
-                                                      coords->x, coords->y,
-                                                      clone_tool->tx4,
-                                                      clone_tool->ty4);
-          if (dist < closest_dist)
-            {
-              closest_dist = dist;
-              clone_tool->function = TRANSFORM_HANDLE_SE;
-            }
+      dist = gimp_draw_tool_calc_distance_square (draw_tool, display,
+                                                  coords->x, coords->y,
+                                                  clone_tool->tx4,
+                                                  clone_tool->ty4);
+      if (dist < closest_dist)
+        {
+          closest_dist = dist;
+          clone_tool->function = TRANSFORM_HANDLE_SE;
         }
     }
   else
@@ -696,7 +672,6 @@ gimp_perspective_clone_tool_oper_update (GimpTool         *tool,
           proximity)
         {
           GimpPaintCore        *core        = GIMP_PAINT_TOOL (tool)->core;
-
           GimpPerspectiveClone *clone       = GIMP_PERSPECTIVE_CLONE (core);
           GimpSourceCore       *source_core = GIMP_SOURCE_CORE (core);
 
@@ -744,59 +719,55 @@ gimp_perspective_clone_tool_draw (GimpDrawTool *draw_tool)
   GimpPerspectiveClone        *clone       = GIMP_PERSPECTIVE_CLONE (GIMP_PAINT_TOOL (tool)->core);
   GimpSourceCore              *source_core = GIMP_SOURCE_CORE (clone);
   GimpPerspectiveCloneOptions *options;
+  GimpCanvasGroup             *stroke_group;
 
   options = GIMP_PERSPECTIVE_CLONE_TOOL_GET_OPTIONS (tool);
 
-  if (clone_tool->use_handles)
-    {
-      GimpCanvasGroup *stroke_group;
-
-      stroke_group = gimp_draw_tool_add_stroke_group (draw_tool);
-
-      /*  draw the bounding box  */
-      gimp_draw_tool_push_group (draw_tool, stroke_group);
-
-      gimp_draw_tool_add_line (draw_tool,
-                               clone_tool->tx1, clone_tool->ty1,
-                               clone_tool->tx2, clone_tool->ty2);
-      gimp_draw_tool_add_line (draw_tool,
-                               clone_tool->tx2, clone_tool->ty2,
-                               clone_tool->tx4, clone_tool->ty4);
-      gimp_draw_tool_add_line (draw_tool,
-                               clone_tool->tx3, clone_tool->ty3,
-                               clone_tool->tx4, clone_tool->ty4);
-      gimp_draw_tool_add_line (draw_tool,
-                               clone_tool->tx3, clone_tool->ty3,
-                               clone_tool->tx1, clone_tool->ty1);
-
-      gimp_draw_tool_pop_group (draw_tool);
-
-      /*  draw the tool handles  */
-      gimp_draw_tool_add_handle (draw_tool,
-                                 GIMP_HANDLE_SQUARE,
-                                 clone_tool->tx1, clone_tool->ty1,
-                                 GIMP_TOOL_HANDLE_SIZE_LARGE,
-                                 GIMP_TOOL_HANDLE_SIZE_LARGE,
-                                 GIMP_HANDLE_ANCHOR_CENTER);
-      gimp_draw_tool_add_handle (draw_tool,
-                                 GIMP_HANDLE_SQUARE,
-                                 clone_tool->tx2, clone_tool->ty2,
-                                 GIMP_TOOL_HANDLE_SIZE_LARGE,
-                                 GIMP_TOOL_HANDLE_SIZE_LARGE,
-                                 GIMP_HANDLE_ANCHOR_CENTER);
-      gimp_draw_tool_add_handle (draw_tool,
-                                 GIMP_HANDLE_SQUARE,
-                                 clone_tool->tx3, clone_tool->ty3,
-                                 GIMP_TOOL_HANDLE_SIZE_LARGE,
-                                 GIMP_TOOL_HANDLE_SIZE_LARGE,
-                                 GIMP_HANDLE_ANCHOR_CENTER);
-      gimp_draw_tool_add_handle (draw_tool,
-                                 GIMP_HANDLE_SQUARE,
-                                 clone_tool->tx4, clone_tool->ty4,
-                                 GIMP_TOOL_HANDLE_SIZE_LARGE,
-                                 GIMP_TOOL_HANDLE_SIZE_LARGE,
-                                 GIMP_HANDLE_ANCHOR_CENTER);
-    }
+  stroke_group = gimp_draw_tool_add_stroke_group (draw_tool);
+
+  /*  draw the bounding box  */
+  gimp_draw_tool_push_group (draw_tool, stroke_group);
+
+  gimp_draw_tool_add_line (draw_tool,
+                           clone_tool->tx1, clone_tool->ty1,
+                           clone_tool->tx2, clone_tool->ty2);
+  gimp_draw_tool_add_line (draw_tool,
+                           clone_tool->tx2, clone_tool->ty2,
+                           clone_tool->tx4, clone_tool->ty4);
+  gimp_draw_tool_add_line (draw_tool,
+                           clone_tool->tx3, clone_tool->ty3,
+                           clone_tool->tx4, clone_tool->ty4);
+  gimp_draw_tool_add_line (draw_tool,
+                           clone_tool->tx3, clone_tool->ty3,
+                           clone_tool->tx1, clone_tool->ty1);
+
+  gimp_draw_tool_pop_group (draw_tool);
+
+  /*  draw the tool handles  */
+  gimp_draw_tool_add_handle (draw_tool,
+                             GIMP_HANDLE_SQUARE,
+                             clone_tool->tx1, clone_tool->ty1,
+                             GIMP_TOOL_HANDLE_SIZE_LARGE,
+                             GIMP_TOOL_HANDLE_SIZE_LARGE,
+                             GIMP_HANDLE_ANCHOR_CENTER);
+  gimp_draw_tool_add_handle (draw_tool,
+                             GIMP_HANDLE_SQUARE,
+                             clone_tool->tx2, clone_tool->ty2,
+                             GIMP_TOOL_HANDLE_SIZE_LARGE,
+                             GIMP_TOOL_HANDLE_SIZE_LARGE,
+                             GIMP_HANDLE_ANCHOR_CENTER);
+  gimp_draw_tool_add_handle (draw_tool,
+                             GIMP_HANDLE_SQUARE,
+                             clone_tool->tx3, clone_tool->ty3,
+                             GIMP_TOOL_HANDLE_SIZE_LARGE,
+                             GIMP_TOOL_HANDLE_SIZE_LARGE,
+                             GIMP_HANDLE_ANCHOR_CENTER);
+  gimp_draw_tool_add_handle (draw_tool,
+                             GIMP_HANDLE_SQUARE,
+                             clone_tool->tx4, clone_tool->ty4,
+                             GIMP_TOOL_HANDLE_SIZE_LARGE,
+                             GIMP_TOOL_HANDLE_SIZE_LARGE,
+                             GIMP_HANDLE_ANCHOR_CENTER);
 
   if (GIMP_CLONE_OPTIONS (options)->clone_type == GIMP_IMAGE_CLONE &&
       source_core->src_drawable && clone_tool->src_display)
@@ -845,31 +816,6 @@ gimp_perspective_clone_tool_transform_bounding_box (GimpPerspectiveCloneTool *cl
                                 clone_tool->y2,
                                 &clone_tool->tx4,
                                 &clone_tool->ty4);
-
-#if 0
-  gimp_matrix3_transform_point (&tr_tool->transform,
-                                tr_tool->cx, tr_tool->cy,
-                                &tr_tool->tcx, &tr_tool->tcy);
-
-  if (tr_tool->grid_coords && tr_tool->tgrid_coords)
-    {
-      gint i, k;
-      gint gci;
-
-      gci = 0;
-      k   = (tr_tool->ngx + tr_tool->ngy) * 2;
-
-      for (i = 0; i < k; i++)
-        {
-          gimp_matrix3_transform_point (&tr_tool->transform,
-                                        tr_tool->grid_coords[gci],
-                                        tr_tool->grid_coords[gci + 1],
-                                        &tr_tool->tgrid_coords[gci],
-                                        &tr_tool->tgrid_coords[gci + 1]);
-          gci += 2;
-        }
-    }
-#endif
 }
 
 static void
diff --git a/app/tools/gimpperspectiveclonetool.h b/app/tools/gimpperspectiveclonetool.h
index 9f2395e..edf619e 100644
--- a/app/tools/gimpperspectiveclonetool.h
+++ b/app/tools/gimpperspectiveclonetool.h
@@ -45,20 +45,14 @@ struct _GimpPerspectiveCloneTool
   gint            src_x;
   gint            src_y;
 
-  gdouble         startx;         /*  starting x coord                 */
-  gdouble         starty;         /*  starting y coord                 */
-
   gdouble         curx;           /*  current x coord                  */
   gdouble         cury;           /*  current y coord                  */
 
   gdouble         lastx;          /*  last x coord                     */
   gdouble         lasty;          /*  last y coord                     */
 
-  GdkModifierType state;          /*  state of buttons and keys        */
-
   GimpMatrix3     transform;      /*  transformation matrix            */
   TransInfo       trans_info;     /*  transformation info              */
-
   TransInfo       old_trans_info; /*  for cancelling a drag operation  */
 
   gint            x1, y1;         /*  upper left hand coordinate       */
@@ -70,21 +64,7 @@ struct _GimpPerspectiveCloneTool
   gdouble         tx4, ty4;
   gdouble         tcx, tcy;
 
-  gboolean        use_grid;       /*  does the tool use the grid       */
-  gboolean        use_handles;    /*  uses the corner handles          */
-
   TransformAction function;       /*  current tool activity            */
-
-  /*gint            ngx, ngy;*/       /*  number of grid lines in original
-                                   *  x and y directions
-                                   */
-
-  /*gdouble        *grid_coords;*/    /*  x and y coordinates of the grid
-                                   *  endpoints (a total of (ngx+ngy)*2
-                                   *  coordinate pairs)
-                                  */
-  /*gdouble        *tgrid_coords;*/   /*  transformed grid_coords          */
-
 };
 
 struct _GimpPerspectiveCloneToolClass



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]