gimp r26673 - in trunk: . app/paint app/tools



Author: mitch
Date: Wed Aug 20 09:49:40 2008
New Revision: 26673
URL: http://svn.gnome.org/viewvc/gimp?rev=26673&view=rev

Log:
2008-08-20  Michael Natterer  <mitch gimp org>

	* app/paint/gimpperspectiveclone.[ch]: make
	gimp_perspective_clone_get_matrix() static and add
	gimp_perspective_clone_set_transform().

	* app/tools/gimpperspectiveclonetool.c
	(gimp_perspective_clone_tool_mode_notify): use above set_transform()
	API instead of poking into the object.

	(gimp_perspective_clone_tool_constructor): call
	gimp_perspective_clone_tool_mode_notify() to set up things instead
	of duplicating code.



Modified:
   trunk/ChangeLog
   trunk/app/paint/gimpperspectiveclone.c
   trunk/app/paint/gimpperspectiveclone.h
   trunk/app/tools/gimpperspectiveclonetool.c

Modified: trunk/app/paint/gimpperspectiveclone.c
==============================================================================
--- trunk/app/paint/gimpperspectiveclone.c	(original)
+++ trunk/app/paint/gimpperspectiveclone.c	Wed Aug 20 09:49:40 2008
@@ -76,6 +76,9 @@
                                                    gint             *paint_area_height,
                                                    PixelRegion      *srcPR);
 
+static void     gimp_perspective_clone_get_matrix (GimpPerspectiveClone *clone,
+                                                   GimpMatrix3          *matrix);
+
 
 G_DEFINE_TYPE (GimpPerspectiveClone, gimp_perspective_clone,
                GIMP_TYPE_CLONE)
@@ -408,6 +411,35 @@
   return TRUE;
 }
 
+
+/*  public functions  */
+
+void
+gimp_perspective_clone_set_transform (GimpPerspectiveClone *clone,
+                                      GimpMatrix3          *transform)
+{
+  g_return_if_fail (GIMP_IS_PERSPECTIVE_CLONE (clone));
+  g_return_if_fail (transform != NULL);
+
+  clone->transform = *transform;
+
+  clone->transform_inv = clone->transform;
+  gimp_matrix3_invert (&clone->transform_inv);
+
+#if 0
+  g_printerr ("%f\t%f\t%f\n%f\t%f\t%f\n%f\t%f\t%f\n\n",
+              clone->transform.coeff[0][0],
+              clone->transform.coeff[0][1],
+              clone->transform.coeff[0][2],
+              clone->transform.coeff[1][0],
+              clone->transform.coeff[1][1],
+              clone->transform.coeff[1][2],
+              clone->transform.coeff[2][0],
+              clone->transform.coeff[2][1],
+              clone->transform.coeff[2][2]);
+#endif
+}
+
 void
 gimp_perspective_clone_get_source_point (GimpPerspectiveClone *clone,
                                          gdouble               x,
@@ -417,6 +449,10 @@
 {
   gdouble temp_x, temp_y;
 
+  g_return_if_fail (GIMP_IS_PERSPECTIVE_CLONE (clone));
+  g_return_if_fail (newx != NULL);
+  g_return_if_fail (newy != NULL);
+
   gimp_matrix3_transform_point (&clone->transform_inv,
                                 x, y, &temp_x, &temp_y);
 
@@ -440,7 +476,10 @@
                                 temp_x, temp_y, newx, newy);
 }
 
-void
+
+/*  private functions  */
+
+static void
 gimp_perspective_clone_get_matrix (GimpPerspectiveClone *clone,
                                    GimpMatrix3          *matrix)
 {

Modified: trunk/app/paint/gimpperspectiveclone.h
==============================================================================
--- trunk/app/paint/gimpperspectiveclone.h	(original)
+++ trunk/app/paint/gimpperspectiveclone.h	Wed Aug 20 09:49:40 2008
@@ -56,18 +56,18 @@
 };
 
 
-void    gimp_perspective_clone_register   (Gimp                      *gimp,
-                                           GimpPaintRegisterCallback  callback);
+void    gimp_perspective_clone_register      (Gimp                      *gimp,
+                                              GimpPaintRegisterCallback  callback);
 
 GType   gimp_perspective_clone_get_type         (void) G_GNUC_CONST;
 
+void    gimp_perspective_clone_set_transform    (GimpPerspectiveClone   *clone,
+                                                 GimpMatrix3            *transform);
 void    gimp_perspective_clone_get_source_point (GimpPerspectiveClone   *clone,
                                                  gdouble                 x,
                                                  gdouble                 y,
-                                                 gdouble                 *newx,
-                                                 gdouble                 *newy);
-void    gimp_perspective_clone_get_matrix       (GimpPerspectiveClone    *clone,
-                                                 GimpMatrix3             *matrix);
+                                                 gdouble                *newx,
+                                                 gdouble                *newy);
 
 
 #endif  /*  __GIMP_PERSPECTIVE_CLONE_H__  */

Modified: trunk/app/tools/gimpperspectiveclonetool.c
==============================================================================
--- trunk/app/tools/gimpperspectiveclonetool.c	(original)
+++ trunk/app/tools/gimpperspectiveclonetool.c	Wed Aug 20 09:49:40 2008
@@ -91,7 +91,7 @@
                                                                 gboolean         proximity,
                                                                 GimpDisplay     *display);
 
-static void          gimp_perspective_clone_tool_mode_notify   (GObject          *config,
+static void          gimp_perspective_clone_tool_mode_notify   (GimpPerspectiveCloneOptions *options,
                                                                 GParamSpec       *pspec,
                                                                 GimpPerspectiveCloneTool *clone_tool);
 
@@ -203,12 +203,7 @@
                            G_CALLBACK (gimp_perspective_clone_tool_mode_notify),
                            clone_tool, 0);
 
-  if (options->clone_mode == GIMP_PERSPECTIVE_CLONE_MODE_ADJUST)
-    gimp_tool_control_set_tool_cursor (tool->control,
-                                       GIMP_TOOL_CURSOR_PERSPECTIVE);
-  else
-    gimp_tool_control_set_tool_cursor (tool->control,
-                                       GIMP_TOOL_CURSOR_CLONE);
+  gimp_perspective_clone_tool_mode_notify (options, NULL, clone_tool);
 
   return object;
 }
@@ -877,39 +872,20 @@
 }
 
 static void
-gimp_perspective_clone_tool_mode_notify (GObject                  *config,
-                                         GParamSpec               *pspec,
-                                         GimpPerspectiveCloneTool *clone_tool)
+gimp_perspective_clone_tool_mode_notify (GimpPerspectiveCloneOptions *options,
+                                         GParamSpec                  *pspec,
+                                         GimpPerspectiveCloneTool    *clone_tool)
 {
-  GimpPerspectiveClone        *clone;
-  GimpPerspectiveCloneOptions *options;
+  GimpPerspectiveClone *clone;
 
   clone = GIMP_PERSPECTIVE_CLONE (GIMP_PAINT_TOOL (clone_tool)->core);
-  options = GIMP_PERSPECTIVE_CLONE_OPTIONS (config);
 
   if (options->clone_mode == GIMP_PERSPECTIVE_CLONE_MODE_PAINT)
     {
       gimp_tool_control_set_tool_cursor (GIMP_TOOL (clone_tool)->control,
                                          GIMP_TOOL_CURSOR_CLONE);
 
-      clone->transform = clone_tool->transform;
-
-      clone->transform_inv = clone_tool->transform;
-      gimp_matrix3_invert (&clone->transform_inv);
-
-#if 0
-      /* print the matrix */
-
-      g_printerr ("%f\t",   (clone_tool->transform).coeff[0][0]);
-      g_printerr ("%f\t",   (clone_tool->transform).coeff[0][1]);
-      g_printerr ("%f\n",   (clone_tool->transform).coeff[0][2]);
-      g_printerr ("%f\t",   (clone_tool->transform).coeff[1][0]);
-      g_printerr ("%f\t",   (clone_tool->transform).coeff[1][1]);
-      g_printerr ("%f\n",   (clone_tool->transform).coeff[1][2]);
-      g_printerr ("%f\t",   (clone_tool->transform).coeff[2][0]);
-      g_printerr ("%f\t",   (clone_tool->transform).coeff[2][1]);
-      g_printerr ("%f\n\n", (clone_tool->transform).coeff[2][2]);
-#endif
+      gimp_perspective_clone_set_transform (clone, &clone_tool->transform);
     }
   else
     {



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