make gimp_perspective_clone_get_matrix() static and add

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.


svn path=/trunk/; revision=26673
This commit is contained in:
Michael Natterer 2008-08-20 09:49:40 +00:00 committed by Michael Natterer
parent e650b579a7
commit 4c356fe42b
4 changed files with 67 additions and 38 deletions

View File

@ -1,3 +1,17 @@
2008-08-20 Michael Natterer <mitch@gimp.org>
* app/paint/gimpperspectiveclone.[ch]: make
gimp_perspective_clone_get_matrix() static, 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.
2008-08-20 Michael Natterer <mitch@gimp.org>
* app/tools/gimpperspectiveclonetool.[ch]: formatting.

View File

@ -76,6 +76,9 @@ static gboolean gimp_perspective_clone_get_source (GimpSourceCore *source_core
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 @@ gimp_perspective_clone_get_source (GimpSourceCore *source_core,
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 @@ gimp_perspective_clone_get_source_point (GimpPerspectiveClone *clone,
{
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 @@ gimp_perspective_clone_get_source_point (GimpPerspectiveClone *clone,
temp_x, temp_y, newx, newy);
}
void
/* private functions */
static void
gimp_perspective_clone_get_matrix (GimpPerspectiveClone *clone,
GimpMatrix3 *matrix)
{

View File

@ -56,18 +56,18 @@ struct _GimpPerspectiveCloneClass
};
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__ */

View File

@ -91,7 +91,7 @@ static void gimp_perspective_clone_tool_oper_update (GimpTool
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 @@ gimp_perspective_clone_tool_constructor (GType type,
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 @@ gimp_perspective_clone_tool_bounds (GimpPerspectiveCloneTool *tool,
}
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
{