mirror of https://github.com/GNOME/gimp.git
forgot to commit last time.
2001-11-19 Michael Natterer <mitch@gimp.org> * app/display/gimpdisplay-foreach.c: forgot to commit last time. Transform stuff cleanup: * app/core/Makefile.am * app/core/core-types.h * app/core/gimpdrawable-transform.[ch]: new files implementing the actual transform functions cut from tools/gimptransformtool.*. * app/core/gimpdrawable-transform-utils.[ch]: new files implementing transform matrix assembly utility functions. * app/tools/gimptransformtool.[ch]: removed the stuff here. cleanup. * app/tools/transform_options.[ch]: removed all stuff which does not belong here, e.g. the transform_tool_* functions and the global "transform_options" variable. Works like all other tool options now. * app/tools/gimpfliptool.[ch] * app/tools/gimpperspectivetool.[ch] * app/tools/gimprotatetool.[ch] * app/tools/gimpscaletool.[ch] * app/tools/gimpsheartool.[ch]: massive code removal because we can use core/gimpdrawable-fransform* functions now. cleanup. * tools/pdbgen/Makefile.am * tools/pdbgen/groups.pl: added new PDB group "transform_tools". * tools/pdbgen/pdb/tools.pdb: removed the transform stuff here... * tools/pdbgen/pdb/transform_tools.pdb: and added *much* simplified versions which use the new core/gimpdrawable-transform* utilities. * app/pdb/Makefile.am * app/pdb/transform_tools_cmds.c: new file. * app/pdb/internal_procs.c * app/pdb/tools_cmds.c: regenerated. * libgimp/Makefile.am * libgimp/gimp_pdb.h * libgimp/gimptransformtools_pdb.[ch]: new files. * libgimp/gimptools_pdb.[ch]: regenerated.
This commit is contained in:
parent
70cec44587
commit
57044c2f46
49
ChangeLog
49
ChangeLog
|
@ -1,3 +1,52 @@
|
|||
2001-11-19 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/display/gimpdisplay-foreach.c: forgot to commit last time.
|
||||
|
||||
Transform stuff cleanup:
|
||||
|
||||
* app/core/Makefile.am
|
||||
* app/core/core-types.h
|
||||
* app/core/gimpdrawable-transform.[ch]: new files implementing
|
||||
the actual transform functions cut from tools/gimptransformtool.*.
|
||||
|
||||
* app/core/gimpdrawable-transform-utils.[ch]: new files implementing
|
||||
transform matrix assembly utility functions.
|
||||
|
||||
* app/tools/gimptransformtool.[ch]: removed the stuff here. cleanup.
|
||||
|
||||
* app/tools/transform_options.[ch]: removed all stuff which does
|
||||
not belong here, e.g. the transform_tool_* functions and the
|
||||
global "transform_options" variable. Works like all other tool
|
||||
options now.
|
||||
|
||||
* app/tools/gimpfliptool.[ch]
|
||||
* app/tools/gimpperspectivetool.[ch]
|
||||
* app/tools/gimprotatetool.[ch]
|
||||
* app/tools/gimpscaletool.[ch]
|
||||
* app/tools/gimpsheartool.[ch]: massive code removal because
|
||||
we can use core/gimpdrawable-fransform* functions now. cleanup.
|
||||
|
||||
* tools/pdbgen/Makefile.am
|
||||
* tools/pdbgen/groups.pl: added new PDB group "transform_tools".
|
||||
|
||||
* tools/pdbgen/pdb/tools.pdb: removed the transform stuff here...
|
||||
|
||||
* tools/pdbgen/pdb/transform_tools.pdb: and added *much*
|
||||
simplified versions which use the new core/gimpdrawable-transform*
|
||||
utilities.
|
||||
|
||||
* app/pdb/Makefile.am
|
||||
* app/pdb/transform_tools_cmds.c: new file.
|
||||
|
||||
* app/pdb/internal_procs.c
|
||||
* app/pdb/tools_cmds.c: regenerated.
|
||||
|
||||
* libgimp/Makefile.am
|
||||
* libgimp/gimp_pdb.h
|
||||
* libgimp/gimptransformtools_pdb.[ch]: new files.
|
||||
|
||||
* libgimp/gimptools_pdb.[ch]: regenerated.
|
||||
|
||||
2001-11-19 Daniel Egger <degger@fhm.edu>
|
||||
|
||||
* app/paint-funcs/paint-funcs.c
|
||||
|
|
|
@ -64,6 +64,10 @@ libappcore_a_sources = @STRIP_BEGIN@ \
|
|||
gimpdrawable-offset.h \
|
||||
gimpdrawable-preview.c \
|
||||
gimpdrawable-preview.h \
|
||||
gimpdrawable-transform.c \
|
||||
gimpdrawable-transform.h \
|
||||
gimpdrawable-transform-utils.c \
|
||||
gimpdrawable-transform-utils.h \
|
||||
gimpedit.c \
|
||||
gimpedit.h \
|
||||
gimpgradient.c \
|
||||
|
|
|
@ -193,6 +193,12 @@ typedef enum
|
|||
REPEAT_TRIANGULAR
|
||||
} RepeatMode;
|
||||
|
||||
typedef enum /*< skip >*/
|
||||
{
|
||||
GIMP_TRANSFORM_FORWARD,
|
||||
GIMP_TRANSFORM_BACKWARD
|
||||
} GimpTransformDirection;
|
||||
|
||||
|
||||
/* base objects */
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,193 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995-2001 Spencer Kimball, Peter Mattis, and others
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "libgimpmath/gimpmath.h"
|
||||
|
||||
#include "core-types.h"
|
||||
|
||||
#include "gimpdrawable-transform-utils.h"
|
||||
|
||||
|
||||
void
|
||||
gimp_drawable_transform_matrix_rotate (gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2,
|
||||
gdouble angle,
|
||||
GimpMatrix3 result)
|
||||
{
|
||||
gdouble cx;
|
||||
gdouble cy;
|
||||
|
||||
cx = (gdouble) (x1 + x2) / 2.0;
|
||||
cy = (gdouble) (y1 + y2) / 2.0;
|
||||
|
||||
gimp_matrix3_identity (result);
|
||||
gimp_matrix3_translate (result, -cx, -cy);
|
||||
gimp_matrix3_rotate (result, angle);
|
||||
gimp_matrix3_translate (result, +cx, +cy);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_drawable_transform_matrix_scale (gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2,
|
||||
gdouble tx1,
|
||||
gdouble ty1,
|
||||
gdouble tx2,
|
||||
gdouble ty2,
|
||||
GimpMatrix3 result)
|
||||
{
|
||||
gdouble scalex;
|
||||
gdouble scaley;
|
||||
|
||||
scalex = scaley = 1.0;
|
||||
|
||||
if ((x2 - x1) > 0)
|
||||
scalex = (tx2 - tx1) / (gdouble) (x2 - x1);
|
||||
|
||||
if ((y2 - y1) > 0)
|
||||
scaley = (ty2 - ty1) / (gdouble) (y2 - y1);
|
||||
|
||||
gimp_matrix3_identity (result);
|
||||
gimp_matrix3_translate (result, -x1, -y1);
|
||||
gimp_matrix3_scale (result, scalex, scaley);
|
||||
gimp_matrix3_translate (result, tx1, ty1);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_drawable_transform_matrix_shear (gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2,
|
||||
InternalOrientationType orientation,
|
||||
gdouble amount,
|
||||
GimpMatrix3 result)
|
||||
{
|
||||
gint width;
|
||||
gint height;
|
||||
gdouble cx;
|
||||
gdouble cy;
|
||||
|
||||
width = x2 - x1;
|
||||
height = y2 - y1;
|
||||
|
||||
if (width == 0)
|
||||
width = 1;
|
||||
if (height == 0)
|
||||
height = 1;
|
||||
|
||||
cx = (gdouble) (x1 + x2) / 2.0;
|
||||
cy = (gdouble) (y1 + y2) / 2.0;
|
||||
|
||||
gimp_matrix3_identity (result);
|
||||
gimp_matrix3_translate (result, -cx, -cy);
|
||||
|
||||
if (orientation == ORIENTATION_HORIZONTAL)
|
||||
gimp_matrix3_xshear (result, amount / height);
|
||||
else
|
||||
gimp_matrix3_yshear (result, amount / width);
|
||||
|
||||
gimp_matrix3_translate (result, +cx, +cy);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_drawable_transform_matrix_perspective (gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2,
|
||||
gdouble tx1,
|
||||
gdouble ty1,
|
||||
gdouble tx2,
|
||||
gdouble ty2,
|
||||
gdouble tx3,
|
||||
gdouble ty3,
|
||||
gdouble tx4,
|
||||
gdouble ty4,
|
||||
GimpMatrix3 result)
|
||||
{
|
||||
GimpMatrix3 matrix;
|
||||
gdouble scalex;
|
||||
gdouble scaley;
|
||||
|
||||
scalex = scaley = 1.0;
|
||||
|
||||
if ((x2 - x1) > 0)
|
||||
scalex = 1.0 / (gdouble) (x2 - x1);
|
||||
|
||||
if ((y2 - y1) > 0)
|
||||
scaley = 1.0 / (gdouble) (y2 - y1);
|
||||
|
||||
/* Determine the perspective transform that maps from
|
||||
* the unit cube to the transformed coordinates
|
||||
*/
|
||||
{
|
||||
gdouble dx1, dx2, dx3, dy1, dy2, dy3;
|
||||
gdouble det1, det2;
|
||||
|
||||
dx1 = tx2 - tx4;
|
||||
dx2 = tx3 - tx4;
|
||||
dx3 = tx1 - tx2 + tx4 - tx3;
|
||||
|
||||
dy1 = ty2 - ty3;
|
||||
dy2 = ty3 - ty4;
|
||||
dy3 = ty1 - ty2 + ty4 - ty3;
|
||||
|
||||
/* Is the mapping affine? */
|
||||
if ((dx3 == 0.0) && (dy3 == 0.0))
|
||||
{
|
||||
matrix[0][0] = tx2 - tx1;
|
||||
matrix[0][1] = tx4 - tx2;
|
||||
matrix[0][2] = tx1;
|
||||
matrix[1][0] = ty2 - ty1;
|
||||
matrix[1][1] = ty4 - ty2;
|
||||
matrix[1][2] = ty1;
|
||||
matrix[2][0] = 0.0;
|
||||
matrix[2][1] = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
det1 = dx3 * dy2 - dy3 * dx2;
|
||||
det2 = dx1 * dy2 - dy1 * dx2;
|
||||
matrix[2][0] = det1 / det2;
|
||||
det1 = dx1 * dy3 - dy1 * dx3;
|
||||
det2 = dx1 * dy2 - dy1 * dx2;
|
||||
matrix[2][1] = det1 / det2;
|
||||
|
||||
matrix[0][0] = tx2 - tx1 + matrix[2][0] * tx2;
|
||||
matrix[0][1] = tx3 - tx1 + matrix[2][1] * tx3;
|
||||
matrix[0][2] = tx1;
|
||||
|
||||
matrix[1][0] = ty2 - ty1 + matrix[2][0] * ty2;
|
||||
matrix[1][1] = ty3 - ty1 + matrix[2][1] * ty3;
|
||||
matrix[1][2] = ty1;
|
||||
}
|
||||
|
||||
matrix[2][2] = 1.0;
|
||||
}
|
||||
|
||||
gimp_matrix3_identity (result);
|
||||
gimp_matrix3_translate (result, -x1, -y1);
|
||||
gimp_matrix3_scale (result, scalex, scaley);
|
||||
gimp_matrix3_mult (matrix, result);
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995-2001 Spencer Kimball, Peter Mattis, and others
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_DRAWABLE_TRANSFORM_UTILS_H__
|
||||
#define __GIMP_DRAWABLE_TRANSFORM_UTILS_H__
|
||||
|
||||
|
||||
void gimp_drawable_transform_matrix_rotate (gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2,
|
||||
gdouble angle,
|
||||
GimpMatrix3 result);
|
||||
void gimp_drawable_transform_matrix_scale (gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2,
|
||||
gdouble tx1,
|
||||
gdouble ty1,
|
||||
gdouble tx2,
|
||||
gdouble ty2,
|
||||
GimpMatrix3 result);
|
||||
void gimp_drawable_transform_matrix_shear (gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2,
|
||||
InternalOrientationType orientation,
|
||||
gdouble amount,
|
||||
GimpMatrix3 result);
|
||||
void gimp_drawable_transform_matrix_perspective (gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2,
|
||||
gdouble tx1,
|
||||
gdouble ty1,
|
||||
gdouble tx2,
|
||||
gdouble ty2,
|
||||
gdouble tx3,
|
||||
gdouble ty3,
|
||||
gdouble tx4,
|
||||
gdouble ty5,
|
||||
GimpMatrix3 result);
|
||||
|
||||
|
||||
#endif /* __GIMP_DRAWABLE_TRANSFORM_SHEAR_H__ */
|
|
@ -0,0 +1,193 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995-2001 Spencer Kimball, Peter Mattis, and others
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "libgimpmath/gimpmath.h"
|
||||
|
||||
#include "core-types.h"
|
||||
|
||||
#include "gimpdrawable-transform-utils.h"
|
||||
|
||||
|
||||
void
|
||||
gimp_drawable_transform_matrix_rotate (gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2,
|
||||
gdouble angle,
|
||||
GimpMatrix3 result)
|
||||
{
|
||||
gdouble cx;
|
||||
gdouble cy;
|
||||
|
||||
cx = (gdouble) (x1 + x2) / 2.0;
|
||||
cy = (gdouble) (y1 + y2) / 2.0;
|
||||
|
||||
gimp_matrix3_identity (result);
|
||||
gimp_matrix3_translate (result, -cx, -cy);
|
||||
gimp_matrix3_rotate (result, angle);
|
||||
gimp_matrix3_translate (result, +cx, +cy);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_drawable_transform_matrix_scale (gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2,
|
||||
gdouble tx1,
|
||||
gdouble ty1,
|
||||
gdouble tx2,
|
||||
gdouble ty2,
|
||||
GimpMatrix3 result)
|
||||
{
|
||||
gdouble scalex;
|
||||
gdouble scaley;
|
||||
|
||||
scalex = scaley = 1.0;
|
||||
|
||||
if ((x2 - x1) > 0)
|
||||
scalex = (tx2 - tx1) / (gdouble) (x2 - x1);
|
||||
|
||||
if ((y2 - y1) > 0)
|
||||
scaley = (ty2 - ty1) / (gdouble) (y2 - y1);
|
||||
|
||||
gimp_matrix3_identity (result);
|
||||
gimp_matrix3_translate (result, -x1, -y1);
|
||||
gimp_matrix3_scale (result, scalex, scaley);
|
||||
gimp_matrix3_translate (result, tx1, ty1);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_drawable_transform_matrix_shear (gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2,
|
||||
InternalOrientationType orientation,
|
||||
gdouble amount,
|
||||
GimpMatrix3 result)
|
||||
{
|
||||
gint width;
|
||||
gint height;
|
||||
gdouble cx;
|
||||
gdouble cy;
|
||||
|
||||
width = x2 - x1;
|
||||
height = y2 - y1;
|
||||
|
||||
if (width == 0)
|
||||
width = 1;
|
||||
if (height == 0)
|
||||
height = 1;
|
||||
|
||||
cx = (gdouble) (x1 + x2) / 2.0;
|
||||
cy = (gdouble) (y1 + y2) / 2.0;
|
||||
|
||||
gimp_matrix3_identity (result);
|
||||
gimp_matrix3_translate (result, -cx, -cy);
|
||||
|
||||
if (orientation == ORIENTATION_HORIZONTAL)
|
||||
gimp_matrix3_xshear (result, amount / height);
|
||||
else
|
||||
gimp_matrix3_yshear (result, amount / width);
|
||||
|
||||
gimp_matrix3_translate (result, +cx, +cy);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_drawable_transform_matrix_perspective (gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2,
|
||||
gdouble tx1,
|
||||
gdouble ty1,
|
||||
gdouble tx2,
|
||||
gdouble ty2,
|
||||
gdouble tx3,
|
||||
gdouble ty3,
|
||||
gdouble tx4,
|
||||
gdouble ty4,
|
||||
GimpMatrix3 result)
|
||||
{
|
||||
GimpMatrix3 matrix;
|
||||
gdouble scalex;
|
||||
gdouble scaley;
|
||||
|
||||
scalex = scaley = 1.0;
|
||||
|
||||
if ((x2 - x1) > 0)
|
||||
scalex = 1.0 / (gdouble) (x2 - x1);
|
||||
|
||||
if ((y2 - y1) > 0)
|
||||
scaley = 1.0 / (gdouble) (y2 - y1);
|
||||
|
||||
/* Determine the perspective transform that maps from
|
||||
* the unit cube to the transformed coordinates
|
||||
*/
|
||||
{
|
||||
gdouble dx1, dx2, dx3, dy1, dy2, dy3;
|
||||
gdouble det1, det2;
|
||||
|
||||
dx1 = tx2 - tx4;
|
||||
dx2 = tx3 - tx4;
|
||||
dx3 = tx1 - tx2 + tx4 - tx3;
|
||||
|
||||
dy1 = ty2 - ty3;
|
||||
dy2 = ty3 - ty4;
|
||||
dy3 = ty1 - ty2 + ty4 - ty3;
|
||||
|
||||
/* Is the mapping affine? */
|
||||
if ((dx3 == 0.0) && (dy3 == 0.0))
|
||||
{
|
||||
matrix[0][0] = tx2 - tx1;
|
||||
matrix[0][1] = tx4 - tx2;
|
||||
matrix[0][2] = tx1;
|
||||
matrix[1][0] = ty2 - ty1;
|
||||
matrix[1][1] = ty4 - ty2;
|
||||
matrix[1][2] = ty1;
|
||||
matrix[2][0] = 0.0;
|
||||
matrix[2][1] = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
det1 = dx3 * dy2 - dy3 * dx2;
|
||||
det2 = dx1 * dy2 - dy1 * dx2;
|
||||
matrix[2][0] = det1 / det2;
|
||||
det1 = dx1 * dy3 - dy1 * dx3;
|
||||
det2 = dx1 * dy2 - dy1 * dx2;
|
||||
matrix[2][1] = det1 / det2;
|
||||
|
||||
matrix[0][0] = tx2 - tx1 + matrix[2][0] * tx2;
|
||||
matrix[0][1] = tx3 - tx1 + matrix[2][1] * tx3;
|
||||
matrix[0][2] = tx1;
|
||||
|
||||
matrix[1][0] = ty2 - ty1 + matrix[2][0] * ty2;
|
||||
matrix[1][1] = ty3 - ty1 + matrix[2][1] * ty3;
|
||||
matrix[1][2] = ty1;
|
||||
}
|
||||
|
||||
matrix[2][2] = 1.0;
|
||||
}
|
||||
|
||||
gimp_matrix3_identity (result);
|
||||
gimp_matrix3_translate (result, -x1, -y1);
|
||||
gimp_matrix3_scale (result, scalex, scaley);
|
||||
gimp_matrix3_mult (matrix, result);
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995-2001 Spencer Kimball, Peter Mattis, and others
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_DRAWABLE_TRANSFORM_UTILS_H__
|
||||
#define __GIMP_DRAWABLE_TRANSFORM_UTILS_H__
|
||||
|
||||
|
||||
void gimp_drawable_transform_matrix_rotate (gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2,
|
||||
gdouble angle,
|
||||
GimpMatrix3 result);
|
||||
void gimp_drawable_transform_matrix_scale (gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2,
|
||||
gdouble tx1,
|
||||
gdouble ty1,
|
||||
gdouble tx2,
|
||||
gdouble ty2,
|
||||
GimpMatrix3 result);
|
||||
void gimp_drawable_transform_matrix_shear (gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2,
|
||||
InternalOrientationType orientation,
|
||||
gdouble amount,
|
||||
GimpMatrix3 result);
|
||||
void gimp_drawable_transform_matrix_perspective (gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2,
|
||||
gdouble tx1,
|
||||
gdouble ty1,
|
||||
gdouble tx2,
|
||||
gdouble ty2,
|
||||
gdouble tx3,
|
||||
gdouble ty3,
|
||||
gdouble tx4,
|
||||
gdouble ty5,
|
||||
GimpMatrix3 result);
|
||||
|
||||
|
||||
#endif /* __GIMP_DRAWABLE_TRANSFORM_SHEAR_H__ */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,64 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995-2001 Spencer Kimball, Peter Mattis, and others
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_DRAWABLE_TRANSFORM_H__
|
||||
#define __GIMP_DRAWABLE_TRANSFORM_H__
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
X0,
|
||||
Y0,
|
||||
X1,
|
||||
Y1,
|
||||
X2,
|
||||
Y2,
|
||||
X3,
|
||||
Y3
|
||||
} GimpTransformBoundingBox;
|
||||
|
||||
|
||||
TileManager * gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
gboolean clip_result,
|
||||
GimpMatrix3 matrix,
|
||||
GimpTransformDirection direction,
|
||||
GimpProgressFunc progress_callback,
|
||||
gpointer progress_data);
|
||||
TileManager * gimp_drawable_transform_tiles_flip (GimpDrawable *drawable,
|
||||
TileManager *orig,
|
||||
InternalOrientationType flip_type);
|
||||
|
||||
gboolean gimp_drawable_transform_affine (GimpDrawable *drawable,
|
||||
gboolean interpolation,
|
||||
gboolean clip_result,
|
||||
GimpMatrix3 matrix,
|
||||
GimpTransformDirection direction);
|
||||
gboolean gimp_drawable_transform_flip (GimpDrawable *drawable,
|
||||
InternalOrientationType flip_type);
|
||||
|
||||
|
||||
TileManager * gimp_drawable_transform_cut (GimpDrawable *drawable,
|
||||
gboolean *new_layer);
|
||||
gboolean gimp_drawable_transform_paste (GimpDrawable *drawable,
|
||||
TileManager *tiles,
|
||||
gboolean new_layer);
|
||||
|
||||
|
||||
#endif /* __GIMP_DRAWABLE_TRANSFORM_H__ */
|
|
@ -93,8 +93,8 @@ gdisplays_delete (void)
|
|||
{
|
||||
GimpDisplay *gdisp;
|
||||
|
||||
/* destroying the shell removes the GimpDisplay from the list, so
|
||||
* do a while loop "around" the first element to get them all
|
||||
/* this removes the GimpDisplay from the list, so do a while loop
|
||||
* "around" the first element to get them all
|
||||
*/
|
||||
while (display_list)
|
||||
{
|
||||
|
|
|
@ -27,15 +27,11 @@
|
|||
|
||||
#include "tools-types.h"
|
||||
|
||||
#include "base/pixel-region.h"
|
||||
#include "base/tile-manager.h"
|
||||
|
||||
#include "paint-funcs/paint-funcs.h"
|
||||
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpdrawable-transform.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-mask.h"
|
||||
#include "core/gimplayer.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
#include "display/gimpdisplay.h"
|
||||
#include "display/gimpdisplayshell.h"
|
||||
|
@ -44,7 +40,6 @@
|
|||
#include "tool_manager.h"
|
||||
#include "tool_options.h"
|
||||
|
||||
#include "undo.h"
|
||||
#include "path_transform.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
@ -54,8 +49,6 @@
|
|||
* the ORIENTATION_FOO constants.
|
||||
*/
|
||||
|
||||
#define FLIP_INFO 0
|
||||
|
||||
typedef struct _FlipOptions FlipOptions;
|
||||
|
||||
struct _FlipOptions
|
||||
|
@ -140,75 +133,6 @@ gimp_flip_tool_get_type (void)
|
|||
return tool_type;
|
||||
}
|
||||
|
||||
TileManager *
|
||||
flip_tool_flip (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
TileManager *orig,
|
||||
gint flip,
|
||||
InternalOrientationType type)
|
||||
{
|
||||
TileManager *new;
|
||||
PixelRegion srcPR, destPR;
|
||||
gint orig_width;
|
||||
gint orig_height;
|
||||
gint orig_bpp;
|
||||
gint orig_x, orig_y;
|
||||
gint i;
|
||||
|
||||
if (! orig)
|
||||
return NULL;
|
||||
|
||||
orig_width = tile_manager_width (orig);
|
||||
orig_height = tile_manager_height (orig);
|
||||
orig_bpp = tile_manager_bpp (orig);
|
||||
tile_manager_get_offsets (orig, &orig_x, &orig_y);
|
||||
|
||||
if (flip > 0)
|
||||
{
|
||||
new = tile_manager_new (orig_width, orig_height, orig_bpp);
|
||||
pixel_region_init (&srcPR, orig,
|
||||
0, 0, orig_width, orig_height, FALSE);
|
||||
pixel_region_init (&destPR, new,
|
||||
0, 0, orig_width, orig_height, TRUE);
|
||||
|
||||
copy_region (&srcPR, &destPR);
|
||||
tile_manager_set_offsets (new, orig_x, orig_y);
|
||||
}
|
||||
else
|
||||
{
|
||||
new = tile_manager_new (orig_width, orig_height, orig_bpp);
|
||||
tile_manager_set_offsets (new, orig_x, orig_y);
|
||||
|
||||
if (type == ORIENTATION_HORIZONTAL)
|
||||
for (i = 0; i < orig_width; i++)
|
||||
{
|
||||
pixel_region_init (&srcPR, orig, i, 0, 1, orig_height, FALSE);
|
||||
pixel_region_init (&destPR, new,
|
||||
(orig_width - i - 1), 0, 1, orig_height, TRUE);
|
||||
copy_region (&srcPR, &destPR);
|
||||
}
|
||||
else
|
||||
for (i = 0; i < orig_height; i++)
|
||||
{
|
||||
pixel_region_init (&srcPR, orig, 0, i, orig_width, 1, FALSE);
|
||||
pixel_region_init (&destPR, new,
|
||||
0, (orig_height - i - 1), orig_width, 1, TRUE);
|
||||
copy_region (&srcPR, &destPR);
|
||||
}
|
||||
|
||||
/* flip locked paths */
|
||||
/* Note that the undo structures etc are setup before we enter this
|
||||
* function.
|
||||
*/
|
||||
if (type == ORIENTATION_HORIZONTAL)
|
||||
path_transform_flip_horz (gimage);
|
||||
else
|
||||
path_transform_flip_vert (gimage);
|
||||
}
|
||||
|
||||
return new;
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
|
@ -237,10 +161,10 @@ static void
|
|||
gimp_flip_tool_init (GimpFlipTool *flip_tool)
|
||||
{
|
||||
GimpTool *tool;
|
||||
GimpTransformTool *tr_tool;
|
||||
GimpTransformTool *transform_tool;
|
||||
|
||||
tool = GIMP_TOOL (flip_tool);
|
||||
tr_tool = GIMP_TRANSFORM_TOOL (flip_tool);
|
||||
tool = GIMP_TOOL (flip_tool);
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (flip_tool);
|
||||
|
||||
/* The tool options */
|
||||
if (! flip_options)
|
||||
|
@ -251,12 +175,12 @@ gimp_flip_tool_init (GimpFlipTool *flip_tool)
|
|||
(GimpToolOptions *) flip_options);
|
||||
}
|
||||
|
||||
tr_tool->trans_info[FLIP_INFO] = -1.0;
|
||||
|
||||
tool->tool_cursor = GIMP_FLIP_HORIZONTAL_TOOL_CURSOR;
|
||||
tool->toggle_cursor = GIMP_FLIP_VERTICAL_TOOL_CURSOR;
|
||||
|
||||
tool->auto_snap_to = FALSE; /* Don't snap to guides */
|
||||
|
||||
transform_tool->use_grid = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -266,18 +190,22 @@ gimp_flip_tool_modifier_key (GimpTool *tool,
|
|||
GdkModifierType state,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
FlipOptions *options;
|
||||
|
||||
options = (FlipOptions *) tool->tool_info->tool_options;
|
||||
|
||||
if (key == GDK_CONTROL_MASK)
|
||||
{
|
||||
switch (flip_options->type)
|
||||
switch (options->type)
|
||||
{
|
||||
case ORIENTATION_HORIZONTAL:
|
||||
gtk_toggle_button_set_active
|
||||
(GTK_TOGGLE_BUTTON (flip_options->type_w[ORIENTATION_VERTICAL - 1]),
|
||||
(GTK_TOGGLE_BUTTON (options->type_w[ORIENTATION_VERTICAL - 1]),
|
||||
TRUE);
|
||||
break;
|
||||
case ORIENTATION_VERTICAL:
|
||||
gtk_toggle_button_set_active
|
||||
(GTK_TOGGLE_BUTTON (flip_options->type_w[ORIENTATION_HORIZONTAL - 1]),
|
||||
(GTK_TOGGLE_BUTTON (options->type_w[ORIENTATION_HORIZONTAL - 1]),
|
||||
TRUE);
|
||||
break;
|
||||
default:
|
||||
|
@ -296,9 +224,12 @@ gimp_flip_tool_cursor_update (GimpTool *tool,
|
|||
GimpDrawable *drawable;
|
||||
GdkCursorType ctype = GIMP_BAD_CURSOR;
|
||||
GimpToolCursorType tool_cursor = GIMP_FLIP_HORIZONTAL_TOOL_CURSOR;
|
||||
FlipOptions *options;
|
||||
|
||||
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
||||
|
||||
options = (FlipOptions *) tool->tool_info->tool_options;
|
||||
|
||||
if ((drawable = gimp_image_active_drawable (gdisp->gimage)))
|
||||
{
|
||||
gint off_x, off_y;
|
||||
|
@ -314,7 +245,7 @@ gimp_flip_tool_cursor_update (GimpTool *tool,
|
|||
if (gimage_mask_is_empty (gdisp->gimage) ||
|
||||
gimage_mask_value (gdisp->gimage, coords->x, coords->y))
|
||||
{
|
||||
if (flip_options->type == ORIENTATION_HORIZONTAL)
|
||||
if (options->type == ORIENTATION_HORIZONTAL)
|
||||
ctype = GDK_SB_H_DOUBLE_ARROW;
|
||||
else
|
||||
ctype = GDK_SB_V_DOUBLE_ARROW;
|
||||
|
@ -322,7 +253,7 @@ gimp_flip_tool_cursor_update (GimpTool *tool,
|
|||
}
|
||||
}
|
||||
|
||||
if (flip_options->type == ORIENTATION_HORIZONTAL)
|
||||
if (options->type == ORIENTATION_HORIZONTAL)
|
||||
tool_cursor = GIMP_FLIP_HORIZONTAL_TOOL_CURSOR;
|
||||
else
|
||||
tool_cursor = GIMP_FLIP_VERTICAL_TOOL_CURSOR;
|
||||
|
@ -338,9 +269,9 @@ gimp_flip_tool_transform (GimpTransformTool *trans_tool,
|
|||
GimpDisplay *gdisp,
|
||||
TransformState state)
|
||||
{
|
||||
GimpTool *tool;
|
||||
FlipOptions *options;
|
||||
|
||||
tool = GIMP_TOOL (trans_tool);
|
||||
options = (FlipOptions *) GIMP_TOOL (trans_tool)->tool_info->tool_options;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
|
@ -355,11 +286,9 @@ gimp_flip_tool_transform (GimpTransformTool *trans_tool,
|
|||
break;
|
||||
|
||||
case TRANSFORM_FINISH:
|
||||
return flip_tool_flip (gdisp->gimage,
|
||||
gimp_image_active_drawable (gdisp->gimage),
|
||||
trans_tool->original,
|
||||
(gint) trans_tool->trans_info[FLIP_INFO],
|
||||
flip_options->type);
|
||||
return gimp_drawable_transform_tiles_flip (gimp_image_active_drawable (gdisp->gimage),
|
||||
trans_tool->original,
|
||||
options->type);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -383,18 +312,20 @@ flip_options_new (void)
|
|||
vbox = options->tool_options.main_vbox;
|
||||
|
||||
/* tool toggle */
|
||||
frame =
|
||||
gimp_radio_group_new2 (TRUE, _("Tool Toggle"),
|
||||
G_CALLBACK (gimp_radio_button_update),
|
||||
&options->type,
|
||||
(gpointer) options->type,
|
||||
frame = gimp_radio_group_new2 (TRUE, _("Tool Toggle"),
|
||||
G_CALLBACK (gimp_radio_button_update),
|
||||
&options->type,
|
||||
GINT_TO_POINTER (options->type),
|
||||
|
||||
_("Horizontal"), (gpointer) ORIENTATION_HORIZONTAL,
|
||||
&options->type_w[0],
|
||||
_("Vertical"), (gpointer) ORIENTATION_VERTICAL,
|
||||
&options->type_w[1],
|
||||
_("Horizontal"),
|
||||
GINT_TO_POINTER (ORIENTATION_HORIZONTAL),
|
||||
&options->type_w[0],
|
||||
|
||||
NULL);
|
||||
_("Vertical"),
|
||||
GINT_TO_POINTER (ORIENTATION_VERTICAL),
|
||||
&options->type_w[1],
|
||||
|
||||
NULL);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
|
|
@ -45,15 +45,9 @@ struct _GimpFlipToolClass
|
|||
};
|
||||
|
||||
|
||||
void gimp_flip_tool_register (Gimp *gimp);
|
||||
void gimp_flip_tool_register (Gimp *gimp);
|
||||
|
||||
GType gimp_flip_tool_get_type (void);
|
||||
|
||||
TileManager * flip_tool_flip (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
TileManager *orig,
|
||||
gint flip,
|
||||
InternalOrientationType type);
|
||||
GType gimp_flip_tool_get_type (void);
|
||||
|
||||
|
||||
#endif /* __GIMP_FLIP_TOOL_H__ */
|
||||
|
|
|
@ -27,34 +27,35 @@
|
|||
#include "gui/gui-types.h"
|
||||
|
||||
#include "core/gimpimage.h"
|
||||
|
||||
#include "gui/info-dialog.h"
|
||||
#include "core/gimpdrawable-transform.h"
|
||||
#include "core/gimpdrawable-transform-utils.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
#include "display/gimpdisplay.h"
|
||||
|
||||
#include "gui/info-dialog.h"
|
||||
|
||||
#include "gimpperspectivetool.h"
|
||||
#include "tool_manager.h"
|
||||
#include "tool_options.h"
|
||||
#include "transform_options.h"
|
||||
|
||||
#include "gimpprogress.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
/* forward function declarations */
|
||||
static void gimp_perspective_tool_class_init (GimpPerspectiveToolClass *klass);
|
||||
static void gimp_perspective_tool_init (GimpPerspectiveTool *perspective_tool);
|
||||
/* local function prototypes */
|
||||
|
||||
static TileManager * gimp_perspective_tool_transform (GimpTransformTool *transform_tool,
|
||||
GimpDisplay *gdisp,
|
||||
TransformState state);
|
||||
static void perspective_tool_recalc (GimpTool *tool,
|
||||
GimpDisplay *gdisp);
|
||||
static void perspective_tool_motion (GimpTool *tool,
|
||||
GimpDisplay *gdisp);
|
||||
static void perspective_info_update (GimpTool *tool);
|
||||
static void gimp_perspective_tool_class_init (GimpPerspectiveToolClass *klass);
|
||||
static void gimp_perspective_tool_init (GimpPerspectiveTool *perspective_tool);
|
||||
|
||||
static TileManager * gimp_perspective_tool_transform (GimpTransformTool *transform_tool,
|
||||
GimpDisplay *gdisp,
|
||||
TransformState state);
|
||||
|
||||
static void perspective_tool_recalc (GimpTransformTool *tr_tool,
|
||||
GimpDisplay *gdisp);
|
||||
static void perspective_tool_motion (GimpTransformTool *tr_tool,
|
||||
GimpDisplay *gdisp);
|
||||
static void perspective_info_update (GimpTransformTool *tr_tool);
|
||||
|
||||
|
||||
/* storage for information dialog fields */
|
||||
|
@ -125,10 +126,10 @@ static void
|
|||
gimp_perspective_tool_init (GimpPerspectiveTool *perspective_tool)
|
||||
{
|
||||
GimpTool *tool;
|
||||
GimpTransformTool *tr_tool;
|
||||
GimpTransformTool *transform_tool;
|
||||
|
||||
tool = GIMP_TOOL (perspective_tool);
|
||||
tr_tool = GIMP_TRANSFORM_TOOL (perspective_tool);
|
||||
tool = GIMP_TOOL (perspective_tool);
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (perspective_tool);
|
||||
|
||||
if (! perspective_options)
|
||||
{
|
||||
|
@ -139,93 +140,7 @@ gimp_perspective_tool_init (GimpPerspectiveTool *perspective_tool)
|
|||
(GimpToolOptions *) perspective_options);
|
||||
}
|
||||
|
||||
tool->tool_cursor = GIMP_PERSPECTIVE_TOOL_CURSOR;
|
||||
|
||||
tr_tool->trans_info[X0] = 0;
|
||||
tr_tool->trans_info[Y0] = 0;
|
||||
tr_tool->trans_info[X1] = 0;
|
||||
tr_tool->trans_info[Y1] = 0;
|
||||
tr_tool->trans_info[X2] = 0;
|
||||
tr_tool->trans_info[Y2] = 0;
|
||||
tr_tool->trans_info[X3] = 0;
|
||||
tr_tool->trans_info[Y3] = 0;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix3_identity (tr_tool->transform);
|
||||
|
||||
}
|
||||
|
||||
TileManager *
|
||||
gimp_perspective_tool_perspective (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
GimpDisplay *gdisp,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix3 matrix)
|
||||
{
|
||||
GimpProgress *progress;
|
||||
TileManager *ret;
|
||||
|
||||
progress = progress_start (gdisp, _("Perspective..."), FALSE, NULL, NULL);
|
||||
|
||||
ret = gimp_transform_tool_do (gimage, drawable, float_tiles,
|
||||
interpolation, matrix,
|
||||
progress ? progress_update_and_flush :
|
||||
(GimpProgressFunc) NULL,
|
||||
progress);
|
||||
|
||||
if (progress)
|
||||
progress_end (progress);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_perspective_tool_find_transform (gdouble *coords,
|
||||
GimpMatrix3 matrix)
|
||||
{
|
||||
gdouble dx1, dx2, dx3, dy1, dy2, dy3;
|
||||
gdouble det1, det2;
|
||||
|
||||
dx1 = coords[X1] - coords[X3];
|
||||
dx2 = coords[X2] - coords[X3];
|
||||
dx3 = coords[X0] - coords[X1] + coords[X3] - coords[X2];
|
||||
|
||||
dy1 = coords[Y1] - coords[Y3];
|
||||
dy2 = coords[Y2] - coords[Y3];
|
||||
dy3 = coords[Y0] - coords[Y1] + coords[Y3] - coords[Y2];
|
||||
|
||||
/* Is the mapping affine? */
|
||||
if ((dx3 == 0.0) && (dy3 == 0.0))
|
||||
{
|
||||
matrix[0][0] = coords[X1] - coords[X0];
|
||||
matrix[0][1] = coords[X3] - coords[X1];
|
||||
matrix[0][2] = coords[X0];
|
||||
matrix[1][0] = coords[Y1] - coords[Y0];
|
||||
matrix[1][1] = coords[Y3] - coords[Y1];
|
||||
matrix[1][2] = coords[Y0];
|
||||
matrix[2][0] = 0.0;
|
||||
matrix[2][1] = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
det1 = dx3 * dy2 - dy3 * dx2;
|
||||
det2 = dx1 * dy2 - dy1 * dx2;
|
||||
matrix[2][0] = det1 / det2;
|
||||
det1 = dx1 * dy3 - dy1 * dx3;
|
||||
det2 = dx1 * dy2 - dy1 * dx2;
|
||||
matrix[2][1] = det1 / det2;
|
||||
|
||||
matrix[0][0] = coords[X1] - coords[X0] + matrix[2][0] * coords[X1];
|
||||
matrix[0][1] = coords[X2] - coords[X0] + matrix[2][1] * coords[X2];
|
||||
matrix[0][2] = coords[X0];
|
||||
|
||||
matrix[1][0] = coords[Y1] - coords[Y0] + matrix[2][0] * coords[Y1];
|
||||
matrix[1][1] = coords[Y2] - coords[Y0] + matrix[2][1] * coords[Y2];
|
||||
matrix[1][2] = coords[Y0];
|
||||
}
|
||||
|
||||
matrix[2][2] = 1.0;
|
||||
tool->tool_cursor = GIMP_PERSPECTIVE_TOOL_CURSOR;
|
||||
}
|
||||
|
||||
static TileManager *
|
||||
|
@ -233,57 +148,46 @@ gimp_perspective_tool_transform (GimpTransformTool *transform_tool,
|
|||
GimpDisplay *gdisp,
|
||||
TransformState state)
|
||||
{
|
||||
GimpTool *tool;
|
||||
|
||||
tool = GIMP_TOOL (transform_tool);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case TRANSFORM_INIT:
|
||||
if (!transform_info)
|
||||
if (! transform_info)
|
||||
{
|
||||
transform_info =
|
||||
info_dialog_new (_("Perspective Transform Information"),
|
||||
gimp_standard_help_func,
|
||||
"tools/transform_perspective.html");
|
||||
|
||||
info_dialog_add_label (transform_info, _("Matrix:"),
|
||||
matrix_row_buf[0]);
|
||||
info_dialog_add_label (transform_info, "", matrix_row_buf[1]);
|
||||
info_dialog_add_label (transform_info, "", matrix_row_buf[2]);
|
||||
}
|
||||
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), TRUE);
|
||||
|
||||
transform_tool->trans_info [X0] = (double) transform_tool->x1;
|
||||
transform_tool->trans_info [Y0] = (double) transform_tool->y1;
|
||||
transform_tool->trans_info [X1] = (double) transform_tool->x2;
|
||||
transform_tool->trans_info [Y1] = (double) transform_tool->y1;
|
||||
transform_tool->trans_info [X2] = (double) transform_tool->x1;
|
||||
transform_tool->trans_info [Y2] = (double) transform_tool->y2;
|
||||
transform_tool->trans_info [X3] = (double) transform_tool->x2;
|
||||
transform_tool->trans_info [Y3] = (double) transform_tool->y2;
|
||||
|
||||
return NULL;
|
||||
transform_tool->trans_info [X0] = (gdouble) transform_tool->x1;
|
||||
transform_tool->trans_info [Y0] = (gdouble) transform_tool->y1;
|
||||
transform_tool->trans_info [X1] = (gdouble) transform_tool->x2;
|
||||
transform_tool->trans_info [Y1] = (gdouble) transform_tool->y1;
|
||||
transform_tool->trans_info [X2] = (gdouble) transform_tool->x1;
|
||||
transform_tool->trans_info [Y2] = (gdouble) transform_tool->y2;
|
||||
transform_tool->trans_info [X3] = (gdouble) transform_tool->x2;
|
||||
transform_tool->trans_info [Y3] = (gdouble) transform_tool->y2;
|
||||
break;
|
||||
|
||||
case TRANSFORM_MOTION:
|
||||
perspective_tool_motion (tool, gdisp);
|
||||
perspective_tool_recalc (tool, gdisp);
|
||||
perspective_tool_motion (transform_tool, gdisp);
|
||||
perspective_tool_recalc (transform_tool, gdisp);
|
||||
break;
|
||||
|
||||
case TRANSFORM_RECALC:
|
||||
perspective_tool_recalc (tool, gdisp);
|
||||
perspective_tool_recalc (transform_tool, gdisp);
|
||||
break;
|
||||
|
||||
case TRANSFORM_FINISH:
|
||||
/* Let the transform tool handle the inverse mapping */
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), FALSE);
|
||||
return
|
||||
gimp_perspective_tool_perspective (gdisp->gimage,
|
||||
gimp_image_active_drawable (gdisp->gimage),
|
||||
gdisp,
|
||||
transform_tool->original,
|
||||
gimp_transform_tool_smoothing (),
|
||||
transform_tool->transform);
|
||||
return gimp_transform_tool_transform_tiles (transform_tool,
|
||||
_("Perspective..."));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -291,18 +195,15 @@ gimp_perspective_tool_transform (GimpTransformTool *transform_tool,
|
|||
}
|
||||
|
||||
static void
|
||||
perspective_info_update (GimpTool *tool)
|
||||
perspective_info_update (GimpTransformTool *transform_tool)
|
||||
{
|
||||
GimpTransformTool *transform_tool;
|
||||
gint i;
|
||||
gint i;
|
||||
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
gchar *p = matrix_row_buf[i];
|
||||
gint j;
|
||||
|
||||
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
p += g_snprintf (p, MAX_INFO_BUF - (p - matrix_row_buf[i]),
|
||||
|
@ -312,18 +213,13 @@ perspective_info_update (GimpTool *tool)
|
|||
|
||||
info_dialog_update (transform_info);
|
||||
info_dialog_popup (transform_info);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
perspective_tool_motion (GimpTool *tool,
|
||||
GimpDisplay *gdisp)
|
||||
perspective_tool_motion (GimpTransformTool *transform_tool,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
GimpTransformTool *transform_tool;
|
||||
gint diff_x, diff_y;
|
||||
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
||||
gint diff_x, diff_y;
|
||||
|
||||
diff_x = transform_tool->curx - transform_tool->lastx;
|
||||
diff_y = transform_tool->cury - transform_tool->lasty;
|
||||
|
@ -352,41 +248,26 @@ perspective_tool_motion (GimpTool *tool,
|
|||
}
|
||||
|
||||
static void
|
||||
perspective_tool_recalc (GimpTool *tool,
|
||||
GimpDisplay *gdisp)
|
||||
perspective_tool_recalc (GimpTransformTool *transform_tool,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
GimpTransformTool *transform_tool;
|
||||
GimpMatrix3 m;
|
||||
gdouble cx, cy;
|
||||
gdouble scalex, scaley;
|
||||
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
||||
|
||||
/* determine the perspective transform that maps from
|
||||
* the unit cube to the trans_info coordinates
|
||||
*/
|
||||
gimp_perspective_tool_find_transform (transform_tool->trans_info, m);
|
||||
|
||||
cx = transform_tool->x1;
|
||||
cy = transform_tool->y1;
|
||||
scalex = 1.0;
|
||||
scaley = 1.0;
|
||||
|
||||
if (transform_tool->x2 - transform_tool->x1)
|
||||
scalex = 1.0 / (transform_tool->x2 - transform_tool->x1);
|
||||
if (transform_tool->y2 - transform_tool->y1)
|
||||
scaley = 1.0 / (transform_tool->y2 - transform_tool->y1);
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix3_identity (transform_tool->transform);
|
||||
gimp_matrix3_translate (transform_tool->transform, -cx, -cy);
|
||||
gimp_matrix3_scale (transform_tool->transform, scalex, scaley);
|
||||
gimp_matrix3_mult (m, transform_tool->transform);
|
||||
gimp_drawable_transform_matrix_perspective (transform_tool->x1,
|
||||
transform_tool->y1,
|
||||
transform_tool->x2,
|
||||
transform_tool->y2,
|
||||
transform_tool->trans_info[X0],
|
||||
transform_tool->trans_info[Y0],
|
||||
transform_tool->trans_info[X1],
|
||||
transform_tool->trans_info[Y1],
|
||||
transform_tool->trans_info[X2],
|
||||
transform_tool->trans_info[Y2],
|
||||
transform_tool->trans_info[X3],
|
||||
transform_tool->trans_info[Y3],
|
||||
transform_tool->transform);
|
||||
|
||||
/* transform the bounding box */
|
||||
gimp_transform_tool_transform_bounding_box (transform_tool);
|
||||
|
||||
/* update the information dialog */
|
||||
perspective_info_update (tool);
|
||||
perspective_info_update (transform_tool);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,19 +45,9 @@ struct _GimpPerspectiveToolClass
|
|||
};
|
||||
|
||||
|
||||
void gimp_perspective_tool_register (Gimp *gimp);
|
||||
void gimp_perspective_tool_register (Gimp *gimp);
|
||||
|
||||
GType gimp_perspective_tool_get_type (void);
|
||||
|
||||
|
||||
TileManager * gimp_perspective_tool_perspective (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
GimpDisplay *gdisp,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix3 matrix);
|
||||
void gimp_perspective_tool_find_transform (gdouble *coords,
|
||||
GimpMatrix3 matrix);
|
||||
GType gimp_perspective_tool_get_type (void);
|
||||
|
||||
|
||||
#endif /* __GIMP_PERSPECTIVE_TOOL_H__ */
|
||||
|
|
|
@ -26,23 +26,19 @@
|
|||
#include "tools-types.h"
|
||||
#include "gui/gui-types.h"
|
||||
|
||||
#include "paint-funcs/paint-funcs.h"
|
||||
|
||||
#include "core/gimpimage.h"
|
||||
|
||||
#include "gui/info-dialog.h"
|
||||
#include "core/gimpdrawable-transform.h"
|
||||
#include "core/gimpdrawable-transform-utils.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
#include "display/gimpdisplay.h"
|
||||
|
||||
#include "gui/info-dialog.h"
|
||||
|
||||
#include "gimprotatetool.h"
|
||||
#include "tool_manager.h"
|
||||
#include "tool_options.h"
|
||||
#include "transform_options.h"
|
||||
|
||||
#include "gimpprogress.h"
|
||||
#include "undo.h"
|
||||
#include "path_transform.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
|
@ -56,24 +52,25 @@
|
|||
#define FIFTEEN_DEG (G_PI / 12.0)
|
||||
|
||||
|
||||
/* local function declarations */
|
||||
static void gimp_rotate_tool_class_init (GimpRotateToolClass *klass);
|
||||
static void gimp_rotate_tool_init (GimpRotateTool *rotate_tool);
|
||||
/* local function prototypes */
|
||||
|
||||
static TileManager * gimp_rotate_tool_transform (GimpTransformTool *transform_tool,
|
||||
static void gimp_rotate_tool_class_init (GimpRotateToolClass *klass);
|
||||
static void gimp_rotate_tool_init (GimpRotateTool *rotate_tool);
|
||||
|
||||
static TileManager * gimp_rotate_tool_transform (GimpTransformTool *tr_tool,
|
||||
GimpDisplay *gdisp,
|
||||
TransformState state);
|
||||
|
||||
static void rotate_tool_recalc (GimpTool *tool,
|
||||
GimpDisplay *gdisp);
|
||||
static void rotate_tool_motion (GimpTool *tool,
|
||||
GimpDisplay *gdisp);
|
||||
static void rotate_info_update (GimpTool *tool);
|
||||
static void rotate_tool_recalc (GimpTransformTool *tr_tool,
|
||||
GimpDisplay *gdisp);
|
||||
static void rotate_tool_motion (GimpTransformTool *tr_tool,
|
||||
GimpDisplay *gdisp);
|
||||
static void rotate_info_update (GimpTransformTool *tr_tool);
|
||||
|
||||
static void rotate_angle_changed (GtkWidget *entry,
|
||||
gpointer data);
|
||||
static void rotate_center_changed (GtkWidget *entry,
|
||||
gpointer data);
|
||||
static void rotate_angle_changed (GtkWidget *entry,
|
||||
gpointer data);
|
||||
static void rotate_center_changed (GtkWidget *entry,
|
||||
gpointer data);
|
||||
|
||||
|
||||
/* variables local to this file */
|
||||
|
@ -132,6 +129,9 @@ gimp_rotate_tool_get_type (void)
|
|||
return tool_type;
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
gimp_rotate_tool_class_init (GimpRotateToolClass *klass)
|
||||
{
|
||||
|
@ -148,10 +148,10 @@ static void
|
|||
gimp_rotate_tool_init (GimpRotateTool *rotate_tool)
|
||||
{
|
||||
GimpTool *tool;
|
||||
GimpTransformTool *tr_tool;
|
||||
GimpTransformTool *transform_tool;
|
||||
|
||||
tool = GIMP_TOOL (rotate_tool);
|
||||
tr_tool = GIMP_TRANSFORM_TOOL (rotate_tool);
|
||||
tool = GIMP_TOOL (rotate_tool);
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (rotate_tool);
|
||||
|
||||
if (! rotate_options)
|
||||
{
|
||||
|
@ -162,63 +162,26 @@ gimp_rotate_tool_init (GimpRotateTool *rotate_tool)
|
|||
(GimpToolOptions *) rotate_options);
|
||||
}
|
||||
|
||||
tool->tool_cursor = GIMP_ROTATE_TOOL_CURSOR;
|
||||
|
||||
tr_tool->trans_info[ANGLE] = 0.0;
|
||||
tr_tool->trans_info[REAL_ANGLE] = 0.0;
|
||||
tr_tool->trans_info[CENTER_X] = 0.0;
|
||||
tr_tool->trans_info[CENTER_Y] = 0.0;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix3_identity (tr_tool->transform);
|
||||
}
|
||||
|
||||
TileManager *
|
||||
gimp_rotate_tool_rotate (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
GimpDisplay *gdisp,
|
||||
gdouble angle,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix3 matrix)
|
||||
{
|
||||
GimpProgress *progress;
|
||||
TileManager *ret;
|
||||
|
||||
progress = progress_start (gdisp, _("Rotating..."), FALSE, NULL, NULL);
|
||||
|
||||
ret = gimp_transform_tool_do (gimage, drawable, float_tiles,
|
||||
interpolation, matrix,
|
||||
progress ? progress_update_and_flush :
|
||||
(GimpProgressFunc) NULL,
|
||||
progress);
|
||||
|
||||
if (progress)
|
||||
progress_end (progress);
|
||||
|
||||
return ret;
|
||||
tool->tool_cursor = GIMP_ROTATE_TOOL_CURSOR;
|
||||
}
|
||||
|
||||
static TileManager *
|
||||
gimp_rotate_tool_transform (GimpTransformTool *transform_tool,
|
||||
GimpDisplay *gdisp,
|
||||
TransformState state)
|
||||
gimp_rotate_tool_transform (GimpTransformTool *transform_tool,
|
||||
GimpDisplay *gdisp,
|
||||
TransformState state)
|
||||
{
|
||||
GimpTool *tool;
|
||||
GtkWidget *widget;
|
||||
GtkWidget *spinbutton2;
|
||||
|
||||
tool = GIMP_TOOL (transform_tool);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case TRANSFORM_INIT:
|
||||
angle_val = 0.0;
|
||||
angle_val = 0.0;
|
||||
center_vals[0] = transform_tool->cx;
|
||||
center_vals[1] = transform_tool->cy;
|
||||
|
||||
if (!transform_info)
|
||||
if (! transform_info)
|
||||
{
|
||||
GtkWidget *widget;
|
||||
GtkWidget *spinbutton2;
|
||||
|
||||
transform_info = info_dialog_new (_("Rotation Information"),
|
||||
gimp_standard_help_func,
|
||||
"tools/transform_rotate.html");
|
||||
|
@ -228,14 +191,14 @@ gimp_rotate_tool_transform (GimpTransformTool *transform_tool,
|
|||
&angle_val,
|
||||
-180, 180, 1, 15, 1, 1, 2,
|
||||
G_CALLBACK (rotate_angle_changed),
|
||||
tool);
|
||||
transform_tool);
|
||||
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (widget), TRUE);
|
||||
|
||||
/* this looks strange (-180, 181), but it works */
|
||||
widget = info_dialog_add_scale (transform_info, "", &angle_val,
|
||||
-180, 181, 0.01, 0.1, 1, -1,
|
||||
G_CALLBACK (rotate_angle_changed),
|
||||
tool);
|
||||
transform_tool);
|
||||
gtk_widget_set_usize (widget, 180, 0);
|
||||
|
||||
spinbutton2 =
|
||||
|
@ -248,7 +211,7 @@ gimp_rotate_tool_transform (GimpTransformTool *transform_tool,
|
|||
TRUE, TRUE, FALSE,
|
||||
GIMP_SIZE_ENTRY_UPDATE_SIZE,
|
||||
G_CALLBACK (rotate_center_changed),
|
||||
tool);
|
||||
transform_tool);
|
||||
|
||||
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (sizeentry),
|
||||
GTK_SPIN_BUTTON (spinbutton2), NULL);
|
||||
|
@ -261,7 +224,7 @@ gimp_rotate_tool_transform (GimpTransformTool *transform_tool,
|
|||
|
||||
g_signal_handlers_block_by_func (G_OBJECT (sizeentry),
|
||||
rotate_center_changed,
|
||||
tool);
|
||||
transform_tool);
|
||||
|
||||
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry),
|
||||
gdisp->gimage->unit);
|
||||
|
@ -290,38 +253,30 @@ gimp_rotate_tool_transform (GimpTransformTool *transform_tool,
|
|||
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 1,
|
||||
center_vals[1]);
|
||||
|
||||
gtk_widget_set_sensitive (transform_info->shell, TRUE);
|
||||
|
||||
g_signal_handlers_unblock_by_func (G_OBJECT (sizeentry),
|
||||
rotate_center_changed,
|
||||
tool);
|
||||
transform_tool);
|
||||
|
||||
gtk_widget_set_sensitive (transform_info->shell, TRUE);
|
||||
|
||||
transform_tool->trans_info[ANGLE] = angle_val;
|
||||
transform_tool->trans_info[REAL_ANGLE] = angle_val;
|
||||
transform_tool->trans_info[CENTER_X] = center_vals[0];
|
||||
transform_tool->trans_info[CENTER_Y] = center_vals[1];
|
||||
|
||||
return NULL;
|
||||
break;
|
||||
|
||||
case TRANSFORM_MOTION:
|
||||
rotate_tool_motion (tool, gdisp);
|
||||
rotate_tool_recalc (tool, gdisp);
|
||||
rotate_tool_motion (transform_tool, gdisp);
|
||||
rotate_tool_recalc (transform_tool, gdisp);
|
||||
break;
|
||||
|
||||
case TRANSFORM_RECALC:
|
||||
rotate_tool_recalc (tool, gdisp);
|
||||
rotate_tool_recalc (transform_tool, gdisp);
|
||||
break;
|
||||
|
||||
case TRANSFORM_FINISH:
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), FALSE);
|
||||
return gimp_rotate_tool_rotate (gdisp->gimage,
|
||||
gimp_image_active_drawable (gdisp->gimage),
|
||||
gdisp,
|
||||
transform_tool->trans_info[ANGLE],
|
||||
transform_tool->original,
|
||||
gimp_transform_tool_smoothing (),
|
||||
transform_tool->transform);
|
||||
return gimp_transform_tool_transform_tiles (transform_tool,
|
||||
_("Rotating..."));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -329,12 +284,8 @@ gimp_rotate_tool_transform (GimpTransformTool *transform_tool,
|
|||
}
|
||||
|
||||
static void
|
||||
rotate_info_update (GimpTool *tool)
|
||||
rotate_info_update (GimpTransformTool *transform_tool)
|
||||
{
|
||||
GimpTransformTool *transform_tool;
|
||||
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
||||
|
||||
angle_val = gimp_rad_to_deg (transform_tool->trans_info[ANGLE]);
|
||||
center_vals[0] = transform_tool->trans_info[CENTER_X];
|
||||
center_vals[1] = transform_tool->trans_info[CENTER_Y];
|
||||
|
@ -348,26 +299,23 @@ rotate_angle_changed (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
GimpTool *tool;
|
||||
GimpDrawTool *draw_tool;
|
||||
GimpTransformTool *transform_tool;
|
||||
gdouble value;
|
||||
|
||||
tool = (GimpTool *) data;
|
||||
tool = GIMP_TOOL (data);
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (data);
|
||||
|
||||
if (tool)
|
||||
value = gimp_deg_to_rad (GTK_ADJUSTMENT (widget)->value);
|
||||
|
||||
if (value != transform_tool->trans_info[ANGLE])
|
||||
{
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
||||
draw_tool = GIMP_DRAW_TOOL (tool);
|
||||
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
||||
|
||||
value = gimp_deg_to_rad (GTK_ADJUSTMENT (widget)->value);
|
||||
transform_tool->trans_info[ANGLE] = value;
|
||||
|
||||
if (value != transform_tool->trans_info[ANGLE])
|
||||
{
|
||||
gimp_draw_tool_pause (draw_tool);
|
||||
transform_tool->trans_info[ANGLE] = value;
|
||||
rotate_tool_recalc (tool, tool->gdisp);
|
||||
gimp_draw_tool_resume (draw_tool);
|
||||
}
|
||||
rotate_tool_recalc (transform_tool, tool->gdisp);
|
||||
|
||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -376,55 +324,46 @@ rotate_center_changed (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
GimpTool *tool;
|
||||
GimpDrawTool *draw_tool;
|
||||
GimpTransformTool *transform_tool;
|
||||
gint cx;
|
||||
gint cy;
|
||||
|
||||
tool = (GimpTool *) data;
|
||||
tool = GIMP_TOOL (data);
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (data);
|
||||
|
||||
if (tool)
|
||||
cx = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0));
|
||||
cy = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1));
|
||||
|
||||
if ((cx != transform_tool->trans_info[CENTER_X]) ||
|
||||
(cy != transform_tool->trans_info[CENTER_Y]))
|
||||
{
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
||||
draw_tool = GIMP_DRAW_TOOL (tool);
|
||||
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
||||
|
||||
cx = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0));
|
||||
cy = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1));
|
||||
transform_tool->trans_info[CENTER_X] = cx;
|
||||
transform_tool->trans_info[CENTER_Y] = cy;
|
||||
transform_tool->cx = cx;
|
||||
transform_tool->cy = cy;
|
||||
|
||||
if ((cx != transform_tool->trans_info[CENTER_X]) ||
|
||||
(cy != transform_tool->trans_info[CENTER_Y]))
|
||||
{
|
||||
gimp_draw_tool_pause (draw_tool);
|
||||
rotate_tool_recalc (transform_tool, tool->gdisp);
|
||||
|
||||
transform_tool->trans_info[CENTER_X] = cx;
|
||||
transform_tool->trans_info[CENTER_Y] = cy;
|
||||
transform_tool->cx = cx;
|
||||
transform_tool->cy = cy;
|
||||
|
||||
rotate_tool_recalc (tool, tool->gdisp);
|
||||
|
||||
gimp_draw_tool_resume (draw_tool);
|
||||
}
|
||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
rotate_tool_motion (GimpTool *tool,
|
||||
GimpDisplay *gdisp)
|
||||
rotate_tool_motion (GimpTransformTool *transform_tool,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
GimpTransformTool *transform_tool;
|
||||
gdouble angle1, angle2, angle;
|
||||
gdouble cx, cy;
|
||||
gdouble x1, y1, x2, y2;
|
||||
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
||||
gdouble angle1, angle2, angle;
|
||||
gdouble cx, cy;
|
||||
gdouble x1, y1, x2, y2;
|
||||
|
||||
if (transform_tool->function == TRANSFORM_HANDLE_CENTER)
|
||||
{
|
||||
transform_tool->trans_info[CENTER_X] = transform_tool->curx;
|
||||
transform_tool->trans_info[CENTER_Y] = transform_tool->cury;
|
||||
transform_tool->cx = transform_tool->curx;
|
||||
transform_tool->cy = transform_tool->cury;
|
||||
transform_tool->cx = transform_tool->curx;
|
||||
transform_tool->cy = transform_tool->cury;
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -470,13 +409,10 @@ rotate_tool_motion (GimpTool *tool,
|
|||
}
|
||||
|
||||
static void
|
||||
rotate_tool_recalc (GimpTool *tool,
|
||||
GimpDisplay *gdisp)
|
||||
rotate_tool_recalc (GimpTransformTool *transform_tool,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
GimpTransformTool *transform_tool;
|
||||
gdouble cx, cy;
|
||||
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
||||
gdouble cx, cy;
|
||||
|
||||
cx = transform_tool->trans_info[CENTER_X];
|
||||
cy = transform_tool->trans_info[CENTER_Y];
|
||||
|
@ -484,16 +420,16 @@ rotate_tool_recalc (GimpTool *tool,
|
|||
transform_tool->cx = cx;
|
||||
transform_tool->cy = cy;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix3_identity (transform_tool->transform);
|
||||
gimp_matrix3_translate (transform_tool->transform, -cx, -cy);
|
||||
gimp_matrix3_rotate (transform_tool->transform,
|
||||
transform_tool->trans_info[ANGLE]);
|
||||
gimp_matrix3_translate (transform_tool->transform, +cx, +cy);
|
||||
gimp_drawable_transform_matrix_rotate (transform_tool->cx,
|
||||
transform_tool->cy,
|
||||
transform_tool->cx,
|
||||
transform_tool->cy,
|
||||
transform_tool->trans_info[ANGLE],
|
||||
transform_tool->transform);
|
||||
|
||||
/* transform the bounding box */
|
||||
gimp_transform_tool_transform_bounding_box (transform_tool);
|
||||
|
||||
/* update the information dialog */
|
||||
rotate_info_update (tool);
|
||||
rotate_info_update (transform_tool);
|
||||
}
|
||||
|
|
|
@ -45,17 +45,9 @@ struct _GimpRotateToolClass
|
|||
};
|
||||
|
||||
|
||||
void gimp_rotate_tool_register (Gimp *gimp);
|
||||
void gimp_rotate_tool_register (Gimp *gimp);
|
||||
|
||||
GType gimp_rotate_tool_get_type (void);
|
||||
GType gimp_rotate_tool_get_type (void);
|
||||
|
||||
|
||||
TileManager * gimp_rotate_tool_rotate (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
GimpDisplay *gdisp,
|
||||
gdouble angle,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix3 matrix);
|
||||
|
||||
#endif /* __GIMP_ROTATE_TOOL_H__ */
|
||||
|
|
|
@ -28,39 +28,41 @@
|
|||
#include "gui/gui-types.h"
|
||||
|
||||
#include "core/gimpimage.h"
|
||||
|
||||
#include "gui/info-dialog.h"
|
||||
#include "core/gimpdrawable-transform.h"
|
||||
#include "core/gimpdrawable-transform-utils.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
#include "display/gimpdisplay.h"
|
||||
|
||||
#include "gui/info-dialog.h"
|
||||
|
||||
#include "gimpscaletool.h"
|
||||
#include "tool_manager.h"
|
||||
#include "tool_options.h"
|
||||
#include "transform_options.h"
|
||||
|
||||
#include "gimpprogress.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
/* forward function declarations */
|
||||
static TileManager * gimp_scale_tool_transform (GimpTransformTool *tool,
|
||||
GimpDisplay *gdisp,
|
||||
TransformState state);
|
||||
static void gimp_scale_tool_recalc (GimpScaleTool *tool,
|
||||
GimpDisplay *gdisp);
|
||||
static void gimp_scale_tool_motion (GimpScaleTool *tool,
|
||||
GimpDisplay *gdisp);
|
||||
static void gimp_scale_tool_info_update (GimpScaleTool *tool);
|
||||
/* local function prototypes */
|
||||
|
||||
static void gimp_scale_tool_size_changed (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void gimp_scale_tool_unit_changed (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void gimp_scale_tool_class_init (GimpScaleToolClass *klass);
|
||||
static void gimp_scale_tool_class_init (GimpScaleToolClass *klass);
|
||||
|
||||
static void gimp_scale_tool_init (GimpScaleTool *sc_tool);
|
||||
static void gimp_scale_tool_init (GimpScaleTool *sc_tool);
|
||||
|
||||
static TileManager * gimp_scale_tool_transform (GimpTransformTool *tr_tool,
|
||||
GimpDisplay *gdisp,
|
||||
TransformState state);
|
||||
|
||||
static void gimp_scale_tool_recalc (GimpTransformTool *tr_tool,
|
||||
GimpDisplay *gdisp);
|
||||
static void gimp_scale_tool_motion (GimpTransformTool *tr_tool,
|
||||
GimpDisplay *gdisp);
|
||||
static void gimp_scale_tool_info_update (GimpTransformTool *tr_tool);
|
||||
|
||||
static void gimp_scale_tool_size_changed (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void gimp_scale_tool_unit_changed (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
|
||||
/* storage for information dialog fields */
|
||||
|
@ -78,6 +80,8 @@ static GimpTransformToolClass *parent_class = NULL;
|
|||
static TransformOptions *scale_options = NULL;
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
void
|
||||
gimp_scale_tool_register (Gimp *gimp)
|
||||
{
|
||||
|
@ -120,6 +124,9 @@ gimp_scale_tool_get_type (void)
|
|||
return tool_type;
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
gimp_scale_tool_class_init (GimpScaleToolClass *klass)
|
||||
{
|
||||
|
@ -137,13 +144,13 @@ gimp_scale_tool_class_init (GimpScaleToolClass *klass)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_scale_tool_init (GimpScaleTool *sc_tool)
|
||||
gimp_scale_tool_init (GimpScaleTool *scale_tool)
|
||||
{
|
||||
GimpTool *tool;
|
||||
GimpTransformTool *tr_tool;
|
||||
GimpTransformTool *transform_tool;
|
||||
|
||||
tool = GIMP_TOOL (sc_tool);
|
||||
tr_tool = GIMP_TRANSFORM_TOOL (sc_tool);
|
||||
tool = GIMP_TOOL (scale_tool);
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (scale_tool);
|
||||
|
||||
if (! scale_options)
|
||||
{
|
||||
|
@ -155,38 +162,23 @@ gimp_scale_tool_init (GimpScaleTool *sc_tool)
|
|||
}
|
||||
|
||||
tool->tool_cursor = GIMP_RESIZE_TOOL_CURSOR;
|
||||
|
||||
/* set the scale specific transformation attributes */
|
||||
tr_tool->trans_info[X0] = 0.0;
|
||||
tr_tool->trans_info[Y0] = 0.0;
|
||||
tr_tool->trans_info[X1] = 0.0;
|
||||
tr_tool->trans_info[Y1] = 0.0;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix3_identity (tr_tool->transform); /* FIXME name is confusing */
|
||||
}
|
||||
|
||||
static TileManager *
|
||||
gimp_scale_tool_transform (GimpTransformTool *tr_tool,
|
||||
GimpDisplay *gdisp,
|
||||
TransformState state)
|
||||
gimp_scale_tool_transform (GimpTransformTool *transform_tool,
|
||||
GimpDisplay *gdisp,
|
||||
TransformState state)
|
||||
{
|
||||
GimpScaleTool *sc_tool;
|
||||
GtkWidget *spinbutton;
|
||||
GimpTool *tool;
|
||||
|
||||
sc_tool = GIMP_SCALE_TOOL (tr_tool);
|
||||
tool = GIMP_TOOL (sc_tool);
|
||||
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case TRANSFORM_INIT:
|
||||
size_vals[0] = tr_tool->x2 - tr_tool->x1;
|
||||
size_vals[1] = tr_tool->y2 - tr_tool->y1;
|
||||
size_vals[0] = transform_tool->x2 - transform_tool->x1;
|
||||
size_vals[1] = transform_tool->y2 - transform_tool->y1;
|
||||
|
||||
if (!transform_info)
|
||||
if (! transform_info)
|
||||
{
|
||||
GtkWidget *spinbutton;
|
||||
|
||||
transform_info = info_dialog_new (_("Scaling Information"),
|
||||
gimp_standard_help_func,
|
||||
"tools/transform_scale.html");
|
||||
|
@ -206,10 +198,10 @@ gimp_scale_tool_transform (GimpTransformTool *tr_tool,
|
|||
TRUE, TRUE, FALSE,
|
||||
GIMP_SIZE_ENTRY_UPDATE_SIZE,
|
||||
G_CALLBACK (gimp_scale_tool_size_changed),
|
||||
tool);
|
||||
transform_tool);
|
||||
g_signal_connect (G_OBJECT (sizeentry), "unit_changed",
|
||||
G_CALLBACK (gimp_scale_tool_unit_changed),
|
||||
tool);
|
||||
transform_tool);
|
||||
|
||||
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (sizeentry),
|
||||
GTK_SPIN_BUTTON (spinbutton), NULL);
|
||||
|
@ -227,10 +219,10 @@ gimp_scale_tool_transform (GimpTransformTool *tr_tool,
|
|||
|
||||
g_signal_handlers_block_by_func (G_OBJECT (sizeentry),
|
||||
gimp_scale_tool_size_changed,
|
||||
tool);
|
||||
transform_tool);
|
||||
g_signal_handlers_block_by_func (G_OBJECT (sizeentry),
|
||||
gimp_scale_tool_unit_changed,
|
||||
tool);
|
||||
transform_tool);
|
||||
|
||||
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry),
|
||||
gdisp->gimage->unit);
|
||||
|
@ -259,53 +251,43 @@ gimp_scale_tool_transform (GimpTransformTool *tr_tool,
|
|||
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 1,
|
||||
size_vals[1]);
|
||||
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), TRUE);
|
||||
|
||||
g_signal_handlers_unblock_by_func (G_OBJECT (sizeentry),
|
||||
gimp_scale_tool_size_changed,
|
||||
tool);
|
||||
transform_tool);
|
||||
g_signal_handlers_unblock_by_func (G_OBJECT (sizeentry),
|
||||
gimp_scale_tool_unit_changed,
|
||||
tool);
|
||||
transform_tool);
|
||||
|
||||
tr_tool->trans_info [X0] = (double) tr_tool->x1;
|
||||
tr_tool->trans_info [Y0] = (double) tr_tool->y1;
|
||||
tr_tool->trans_info [X1] = (double) tr_tool->x2;
|
||||
tr_tool->trans_info [Y1] = (double) tr_tool->y2;
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), TRUE);
|
||||
|
||||
return NULL;
|
||||
transform_tool->trans_info[X0] = (gdouble) transform_tool->x1;
|
||||
transform_tool->trans_info[Y0] = (gdouble) transform_tool->y1;
|
||||
transform_tool->trans_info[X1] = (gdouble) transform_tool->x2;
|
||||
transform_tool->trans_info[Y1] = (gdouble) transform_tool->y2;
|
||||
break;
|
||||
|
||||
case TRANSFORM_MOTION:
|
||||
gimp_scale_tool_motion (sc_tool, gdisp);
|
||||
gimp_scale_tool_recalc (sc_tool, gdisp);
|
||||
gimp_scale_tool_motion (transform_tool, gdisp);
|
||||
gimp_scale_tool_recalc (transform_tool, gdisp);
|
||||
break;
|
||||
|
||||
case TRANSFORM_RECALC:
|
||||
gimp_scale_tool_recalc (sc_tool, gdisp);
|
||||
gimp_scale_tool_recalc (transform_tool, gdisp);
|
||||
break;
|
||||
|
||||
case TRANSFORM_FINISH:
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), FALSE);
|
||||
return gimp_scale_tool_scale (gdisp->gimage,
|
||||
gimp_image_active_drawable (gdisp->gimage),
|
||||
gdisp,
|
||||
tr_tool->trans_info,
|
||||
tr_tool->original,
|
||||
gimp_transform_tool_smoothing (),
|
||||
tr_tool->transform);
|
||||
return gimp_transform_tool_transform_tiles (transform_tool,
|
||||
_("Scaling..."));
|
||||
break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gimp_scale_tool_info_update (GimpScaleTool *sc_tool)
|
||||
gimp_scale_tool_info_update (GimpTransformTool *transform_tool)
|
||||
{
|
||||
GimpTool *tool;
|
||||
GimpTransformTool *tr_tool;
|
||||
gdouble ratio_x, ratio_y;
|
||||
gint x1, y1, x2, y2, x3, y3, x4, y4;
|
||||
GimpUnit unit;
|
||||
|
@ -314,15 +296,15 @@ gimp_scale_tool_info_update (GimpScaleTool *sc_tool)
|
|||
|
||||
static GimpUnit label_unit = GIMP_UNIT_PIXEL;
|
||||
|
||||
tool = GIMP_TOOL (sc_tool);
|
||||
tr_tool = GIMP_TRANSFORM_TOOL (sc_tool);
|
||||
unit = gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (sizeentry));;
|
||||
tool = GIMP_TOOL (transform_tool);
|
||||
|
||||
unit = gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (sizeentry));;
|
||||
|
||||
/* Find original sizes */
|
||||
x1 = tr_tool->x1;
|
||||
y1 = tr_tool->y1;
|
||||
x2 = tr_tool->x2;
|
||||
y2 = tr_tool->y2;
|
||||
x1 = transform_tool->x1;
|
||||
y1 = transform_tool->y1;
|
||||
x2 = transform_tool->x2;
|
||||
y2 = transform_tool->y2;
|
||||
|
||||
if (unit != GIMP_UNIT_PERCENT)
|
||||
label_unit = unit;
|
||||
|
@ -346,10 +328,10 @@ gimp_scale_tool_info_update (GimpScaleTool *sc_tool)
|
|||
}
|
||||
|
||||
/* Find current sizes */
|
||||
x3 = (int) tr_tool->trans_info [X0];
|
||||
y3 = (int) tr_tool->trans_info [Y0];
|
||||
x4 = (int) tr_tool->trans_info [X1];
|
||||
y4 = (int) tr_tool->trans_info [Y1];
|
||||
x3 = (gint) transform_tool->trans_info [X0];
|
||||
y3 = (gint) transform_tool->trans_info [Y0];
|
||||
x4 = (gint) transform_tool->trans_info [X1];
|
||||
y4 = (gint) transform_tool->trans_info [Y1];
|
||||
|
||||
size_vals[0] = x4 - x3;
|
||||
size_vals[1] = y4 - y3;
|
||||
|
@ -361,8 +343,8 @@ gimp_scale_tool_info_update (GimpScaleTool *sc_tool)
|
|||
if (y2 - y1)
|
||||
ratio_y = (double) (y4 - y3) / (double) (y2 - y1);
|
||||
|
||||
g_snprintf (x_ratio_buf, MAX_INFO_BUF, "%0.2f", ratio_x);
|
||||
g_snprintf (y_ratio_buf, MAX_INFO_BUF, "%0.2f", ratio_y);
|
||||
g_snprintf (x_ratio_buf, sizeof (x_ratio_buf), "%0.2f", ratio_x);
|
||||
g_snprintf (y_ratio_buf, sizeof (y_ratio_buf), "%0.2f", ratio_y);
|
||||
|
||||
info_dialog_update (transform_info);
|
||||
info_dialog_popup (transform_info);
|
||||
|
@ -372,35 +354,30 @@ static void
|
|||
gimp_scale_tool_size_changed (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpTransformTool *transform_tool;
|
||||
GimpTool *tool;
|
||||
GimpTransformTool *tr_tool;
|
||||
GimpDrawTool *dr_tool;
|
||||
gint width;
|
||||
gint height;
|
||||
|
||||
tool = GIMP_TOOL(data);
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (data);
|
||||
tool = GIMP_TOOL (data);
|
||||
|
||||
if (tool)
|
||||
width = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0));
|
||||
height = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1));
|
||||
|
||||
if ((width != (transform_tool->trans_info[X1] -
|
||||
transform_tool->trans_info[X0])) ||
|
||||
(height != (transform_tool->trans_info[Y1] -
|
||||
transform_tool->trans_info[Y0])))
|
||||
{
|
||||
tr_tool = GIMP_TRANSFORM_TOOL(tool);
|
||||
dr_tool = GIMP_DRAW_TOOL(tool);
|
||||
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
||||
|
||||
width = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0));
|
||||
height = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1));
|
||||
transform_tool->trans_info[X1] = transform_tool->trans_info[X0] + width;
|
||||
transform_tool->trans_info[Y1] = transform_tool->trans_info[Y0] + height;
|
||||
|
||||
if ((width != (tr_tool->trans_info[X1] -
|
||||
tr_tool->trans_info[X0])) ||
|
||||
(height != (tr_tool->trans_info[Y1] -
|
||||
tr_tool->trans_info[Y0])))
|
||||
{
|
||||
gimp_draw_tool_pause (dr_tool);
|
||||
tr_tool->trans_info[X1] =
|
||||
tr_tool->trans_info[X0] + width;
|
||||
tr_tool->trans_info[Y1] =
|
||||
tr_tool->trans_info[Y0] + height;
|
||||
gimp_scale_tool_recalc (GIMP_SCALE_TOOL(tool), tool->gdisp);
|
||||
gimp_draw_tool_resume (dr_tool);
|
||||
}
|
||||
gimp_scale_tool_recalc (transform_tool, tool->gdisp);
|
||||
|
||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -408,58 +385,55 @@ static void
|
|||
gimp_scale_tool_unit_changed (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
gimp_scale_tool_info_update (GIMP_SCALE_TOOL (data));
|
||||
gimp_scale_tool_info_update (GIMP_TRANSFORM_TOOL (data));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_scale_tool_motion (GimpScaleTool *sc_tool,
|
||||
GimpDisplay *gdisp)
|
||||
gimp_scale_tool_motion (GimpTransformTool *transform_tool,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
GimpTransformTool *tr_tool;
|
||||
gdouble ratio;
|
||||
gdouble *x1;
|
||||
gdouble *y1;
|
||||
gdouble *x2;
|
||||
gdouble *y2;
|
||||
gint w, h;
|
||||
gint dir_x, dir_y;
|
||||
gint diff_x, diff_y;
|
||||
gdouble ratio;
|
||||
gdouble *x1;
|
||||
gdouble *y1;
|
||||
gdouble *x2;
|
||||
gdouble *y2;
|
||||
gint w, h;
|
||||
gint dir_x, dir_y;
|
||||
gint diff_x, diff_y;
|
||||
|
||||
tr_tool = GIMP_TRANSFORM_TOOL(sc_tool);
|
||||
diff_x = transform_tool->curx - transform_tool->lastx;
|
||||
diff_y = transform_tool->cury - transform_tool->lasty;
|
||||
|
||||
diff_x = tr_tool->curx - tr_tool->lastx;
|
||||
diff_y = tr_tool->cury - tr_tool->lasty;
|
||||
|
||||
switch (tr_tool->function)
|
||||
switch (transform_tool->function)
|
||||
{
|
||||
case TRANSFORM_HANDLE_1:
|
||||
x1 = &tr_tool->trans_info [X0];
|
||||
y1 = &tr_tool->trans_info [Y0];
|
||||
x2 = &tr_tool->trans_info [X1];
|
||||
y2 = &tr_tool->trans_info [Y1];
|
||||
x1 = &transform_tool->trans_info [X0];
|
||||
y1 = &transform_tool->trans_info [Y0];
|
||||
x2 = &transform_tool->trans_info [X1];
|
||||
y2 = &transform_tool->trans_info [Y1];
|
||||
dir_x = dir_y = 1;
|
||||
break;
|
||||
case TRANSFORM_HANDLE_2:
|
||||
x1 = &tr_tool->trans_info [X1];
|
||||
y1 = &tr_tool->trans_info [Y0];
|
||||
x2 = &tr_tool->trans_info [X0];
|
||||
y2 = &tr_tool->trans_info [Y1];
|
||||
x1 = &transform_tool->trans_info [X1];
|
||||
y1 = &transform_tool->trans_info [Y0];
|
||||
x2 = &transform_tool->trans_info [X0];
|
||||
y2 = &transform_tool->trans_info [Y1];
|
||||
dir_x = -1;
|
||||
dir_y = 1;
|
||||
break;
|
||||
case TRANSFORM_HANDLE_3:
|
||||
x1 = &tr_tool->trans_info [X0];
|
||||
y1 = &tr_tool->trans_info [Y1];
|
||||
x2 = &tr_tool->trans_info [X1];
|
||||
y2 = &tr_tool->trans_info [Y0];
|
||||
x1 = &transform_tool->trans_info [X0];
|
||||
y1 = &transform_tool->trans_info [Y1];
|
||||
x2 = &transform_tool->trans_info [X1];
|
||||
y2 = &transform_tool->trans_info [Y0];
|
||||
dir_x = 1;
|
||||
dir_y = -1;
|
||||
break;
|
||||
case TRANSFORM_HANDLE_4:
|
||||
x1 = &tr_tool->trans_info [X1];
|
||||
y1 = &tr_tool->trans_info [Y1];
|
||||
x2 = &tr_tool->trans_info [X0];
|
||||
y2 = &tr_tool->trans_info [Y0];
|
||||
x1 = &transform_tool->trans_info [X1];
|
||||
y1 = &transform_tool->trans_info [Y1];
|
||||
x2 = &transform_tool->trans_info [X0];
|
||||
y2 = &transform_tool->trans_info [Y0];
|
||||
dir_x = dir_y = -1;
|
||||
break;
|
||||
case TRANSFORM_HANDLE_CENTER:
|
||||
|
@ -469,12 +443,12 @@ gimp_scale_tool_motion (GimpScaleTool *sc_tool,
|
|||
}
|
||||
|
||||
/* if just the mod1 key is down, affect only the height */
|
||||
if (tr_tool->state & GDK_MOD1_MASK &&
|
||||
! (tr_tool->state & GDK_CONTROL_MASK))
|
||||
if (transform_tool->state & GDK_MOD1_MASK &&
|
||||
! (transform_tool->state & GDK_CONTROL_MASK))
|
||||
diff_x = 0;
|
||||
/* if just the control key is down, affect only the width */
|
||||
else if (tr_tool->state & GDK_CONTROL_MASK &&
|
||||
! (tr_tool->state & GDK_MOD1_MASK))
|
||||
else if (transform_tool->state & GDK_CONTROL_MASK &&
|
||||
! (transform_tool->state & GDK_MOD1_MASK))
|
||||
diff_y = 0;
|
||||
|
||||
*x1 += diff_x;
|
||||
|
@ -501,11 +475,11 @@ gimp_scale_tool_motion (GimpScaleTool *sc_tool,
|
|||
/* if both the control key & mod1 keys are down,
|
||||
* keep the aspect ratio intact
|
||||
*/
|
||||
if (tr_tool->state & GDK_CONTROL_MASK &&
|
||||
tr_tool->state & GDK_MOD1_MASK)
|
||||
if (transform_tool->state & GDK_CONTROL_MASK &&
|
||||
transform_tool->state & GDK_MOD1_MASK)
|
||||
{
|
||||
ratio = (double) (tr_tool->x2 - tr_tool->x1) /
|
||||
(double) (tr_tool->y2 - tr_tool->y1);
|
||||
ratio = ((gdouble) (transform_tool->x2 - transform_tool->x1) /
|
||||
(gdouble) (transform_tool->y2 - transform_tool->y1));
|
||||
|
||||
w = ABS ((*x2 - *x1));
|
||||
h = ABS ((*y2 - *y1));
|
||||
|
@ -521,96 +495,22 @@ gimp_scale_tool_motion (GimpScaleTool *sc_tool,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_scale_tool_recalc (GimpScaleTool *sc_tool,
|
||||
GimpDisplay *gdisp)
|
||||
gimp_scale_tool_recalc (GimpTransformTool *transform_tool,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
GimpTransformTool *tr_tool;
|
||||
gint x1, y1, x2, y2;
|
||||
gint diffx, diffy;
|
||||
gint cx, cy;
|
||||
gdouble scalex, scaley;
|
||||
|
||||
tr_tool = GIMP_TRANSFORM_TOOL (sc_tool);
|
||||
|
||||
x1 = (int) tr_tool->trans_info [X0];
|
||||
y1 = (int) tr_tool->trans_info [Y0];
|
||||
x2 = (int) tr_tool->trans_info [X1];
|
||||
y2 = (int) tr_tool->trans_info [Y1];
|
||||
|
||||
scalex = scaley = 1.0;
|
||||
if (tr_tool->x2 - tr_tool->x1)
|
||||
scalex = (double) (x2 - x1) / (double) (tr_tool->x2 - tr_tool->x1);
|
||||
if (tr_tool->y2 - tr_tool->y1)
|
||||
scaley = (double) (y2 - y1) / (double) (tr_tool->y2 - tr_tool->y1);
|
||||
|
||||
switch (tr_tool->function)
|
||||
{
|
||||
case TRANSFORM_HANDLE_1:
|
||||
cx = x2; cy = y2;
|
||||
diffx = x2 - tr_tool->x2;
|
||||
diffy = y2 - tr_tool->y2;
|
||||
break;
|
||||
case TRANSFORM_HANDLE_2:
|
||||
cx = x1; cy = y2;
|
||||
diffx = x1 - tr_tool->x1;
|
||||
diffy = y2 - tr_tool->y2;
|
||||
break;
|
||||
case TRANSFORM_HANDLE_3:
|
||||
cx = x2; cy = y1;
|
||||
diffx = x2 - tr_tool->x2;
|
||||
diffy = y1 - tr_tool->y1;
|
||||
break;
|
||||
case TRANSFORM_HANDLE_4:
|
||||
cx = x1; cy = y1;
|
||||
diffx = x1 - tr_tool->x1;
|
||||
diffy = y1 - tr_tool->y1;
|
||||
break;
|
||||
case TRANSFORM_HANDLE_CENTER:
|
||||
cx = x1; cy = y1;
|
||||
diffx = diffy = 0;
|
||||
break;
|
||||
default:
|
||||
cx = x1; cy = y1;
|
||||
diffx = diffy = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix3_identity (tr_tool->transform);
|
||||
gimp_matrix3_translate (tr_tool->transform,
|
||||
(double) -cx + diffx, (double) -cy + diffy);
|
||||
gimp_matrix3_scale (tr_tool->transform, scalex, scaley);
|
||||
gimp_matrix3_translate (tr_tool->transform, (double) cx, (double) cy);
|
||||
gimp_drawable_transform_matrix_scale (transform_tool->x1,
|
||||
transform_tool->y1,
|
||||
transform_tool->x2,
|
||||
transform_tool->y2,
|
||||
transform_tool->trans_info[X0],
|
||||
transform_tool->trans_info[Y0],
|
||||
transform_tool->trans_info[X1],
|
||||
transform_tool->trans_info[Y1],
|
||||
transform_tool->transform);
|
||||
|
||||
/* transform the bounding box */
|
||||
gimp_transform_tool_transform_bounding_box (tr_tool);
|
||||
gimp_transform_tool_transform_bounding_box (transform_tool);
|
||||
|
||||
/* update the information dialog */
|
||||
gimp_scale_tool_info_update (sc_tool);
|
||||
}
|
||||
|
||||
TileManager *
|
||||
gimp_scale_tool_scale (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
GimpDisplay *gdisp,
|
||||
gdouble *trans_info,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix3 matrix)
|
||||
{
|
||||
GimpProgress *progress;
|
||||
TileManager *ret;
|
||||
|
||||
progress = progress_start (gdisp, _("Scaling..."), FALSE, NULL, NULL);
|
||||
|
||||
ret = gimp_transform_tool_do (gimage, drawable, float_tiles,
|
||||
interpolation, matrix,
|
||||
progress ? progress_update_and_flush :
|
||||
(GimpProgressFunc) NULL,
|
||||
progress);
|
||||
|
||||
if (progress)
|
||||
progress_end (progress);
|
||||
|
||||
return ret;
|
||||
gimp_scale_tool_info_update (transform_tool);
|
||||
}
|
||||
|
|
|
@ -44,17 +44,9 @@ struct _GimpScaleToolClass
|
|||
};
|
||||
|
||||
|
||||
void gimp_scale_tool_register (Gimp *gimp);
|
||||
void gimp_scale_tool_register (Gimp *gimp);
|
||||
|
||||
GType gimp_scale_tool_get_type (void);
|
||||
|
||||
TileManager * gimp_scale_tool_scale (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
GimpDisplay *gdisp,
|
||||
gdouble *trans_info,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix3 matrix);
|
||||
GType gimp_scale_tool_get_type (void);
|
||||
|
||||
|
||||
#endif /* __GIMP_SCALE_TOOL_H__ */
|
||||
|
|
|
@ -29,20 +29,18 @@
|
|||
#include "gui/gui-types.h"
|
||||
|
||||
#include "core/gimpimage.h"
|
||||
|
||||
#include "gui/info-dialog.h"
|
||||
#include "core/gimpdrawable-transform.h"
|
||||
#include "core/gimpdrawable-transform-utils.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
#include "display/gimpdisplay.h"
|
||||
|
||||
#include "gui/info-dialog.h"
|
||||
|
||||
#include "gimpsheartool.h"
|
||||
#include "tool_manager.h"
|
||||
#include "tool_options.h"
|
||||
#include "transform_options.h"
|
||||
|
||||
#include "floating_sel.h"
|
||||
#include "gimpprogress.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
|
@ -58,22 +56,22 @@
|
|||
/* forward function declarations */
|
||||
|
||||
static void gimp_shear_tool_class_init (GimpShearToolClass *klass);
|
||||
static void gimp_shear_tool_init (GimpShearTool *shear_tool);
|
||||
static void gimp_shear_tool_init (GimpShearTool *shear_tool);
|
||||
|
||||
static TileManager * gimp_shear_tool_transform (GimpTransformTool *transform_tool,
|
||||
GimpDisplay *gdisp,
|
||||
TransformState state);
|
||||
static TileManager * gimp_shear_tool_transform (GimpTransformTool *tr_tool,
|
||||
GimpDisplay *gdisp,
|
||||
TransformState state);
|
||||
|
||||
static void shear_tool_recalc (GimpTool *tool,
|
||||
GimpDisplay *gdisp);
|
||||
static void shear_tool_motion (GimpTool *tool,
|
||||
GimpDisplay *gdisp);
|
||||
static void shear_info_update (GimpTool *tool);
|
||||
static void shear_tool_recalc (GimpTransformTool *tr_tool,
|
||||
GimpDisplay *gdisp);
|
||||
static void shear_tool_motion (GimpTransformTool *tr_tool,
|
||||
GimpDisplay *gdisp);
|
||||
static void shear_info_update (GimpTransformTool *tr_tool);
|
||||
|
||||
static void shear_x_mag_changed (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void shear_y_mag_changed (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void shear_x_mag_changed (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void shear_y_mag_changed (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
|
||||
/* variables local to this file */
|
||||
|
@ -145,64 +143,32 @@ static void
|
|||
gimp_shear_tool_init (GimpShearTool *shear_tool)
|
||||
{
|
||||
GimpTool *tool;
|
||||
GimpTransformTool *tr_tool;
|
||||
GimpTransformTool *transform_tool;
|
||||
|
||||
tool = GIMP_TOOL (shear_tool);
|
||||
tr_tool = GIMP_TRANSFORM_TOOL (shear_tool);
|
||||
tool = GIMP_TOOL (shear_tool);
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (shear_tool);
|
||||
|
||||
if (! shear_options)
|
||||
{
|
||||
shear_options = transform_options_new (GIMP_TYPE_SHEAR_TOOL,
|
||||
transform_options_reset);
|
||||
transform_options_reset);
|
||||
|
||||
tool_manager_register_tool_options (GIMP_TYPE_SHEAR_TOOL,
|
||||
(GimpToolOptions *) shear_options);
|
||||
}
|
||||
|
||||
tool->tool_cursor = GIMP_SHEAR_TOOL_CURSOR;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix3_identity (tr_tool->transform);
|
||||
|
||||
}
|
||||
|
||||
TileManager *
|
||||
gimp_shear_tool_shear (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
GimpDisplay *gdisp,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix3 matrix)
|
||||
{
|
||||
GimpProgress *progress;
|
||||
TileManager *ret;
|
||||
|
||||
progress = progress_start (gdisp, _("Shearing..."), FALSE, NULL, NULL);
|
||||
|
||||
ret = gimp_transform_tool_do (gimage, drawable, float_tiles,
|
||||
interpolation, matrix,
|
||||
progress ? progress_update_and_flush :
|
||||
(GimpProgressFunc) NULL,
|
||||
progress);
|
||||
|
||||
if (progress)
|
||||
progress_end (progress);
|
||||
|
||||
return ret;
|
||||
tool->tool_cursor = GIMP_SHEAR_TOOL_CURSOR;
|
||||
}
|
||||
|
||||
static TileManager *
|
||||
gimp_shear_tool_transform (GimpTransformTool *transform_tool,
|
||||
GimpDisplay *gdisp,
|
||||
TransformState state)
|
||||
gimp_shear_tool_transform (GimpTransformTool *transform_tool,
|
||||
GimpDisplay *gdisp,
|
||||
TransformState state)
|
||||
{
|
||||
GimpTool *tool;
|
||||
tool = GIMP_TOOL (transform_tool);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case TRANSFORM_INIT:
|
||||
if (!transform_info)
|
||||
if (! transform_info)
|
||||
{
|
||||
transform_info = info_dialog_new (_("Shear Information"),
|
||||
gimp_standard_help_func,
|
||||
|
@ -213,40 +179,35 @@ gimp_shear_tool_transform (GimpTransformTool *transform_tool,
|
|||
&xshear_val,
|
||||
-65536, 65536, 1, 15, 1, 1, 0,
|
||||
G_CALLBACK (shear_x_mag_changed),
|
||||
tool);
|
||||
transform_tool);
|
||||
|
||||
info_dialog_add_spinbutton (transform_info,
|
||||
_("Y:"),
|
||||
&yshear_val,
|
||||
-65536, 65536, 1, 15, 1, 1, 0,
|
||||
G_CALLBACK (shear_y_mag_changed),
|
||||
tool);
|
||||
transform_tool);
|
||||
}
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), TRUE);
|
||||
transform_tool->trans_info[HORZ_OR_VERT] = ORIENTATION_UNKNOWN;
|
||||
transform_tool->trans_info[XSHEAR] = 0.0;
|
||||
transform_tool->trans_info[YSHEAR] = 0.0;
|
||||
|
||||
return NULL;
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), TRUE);
|
||||
|
||||
transform_tool->trans_info[HORZ_OR_VERT] = ORIENTATION_UNKNOWN;
|
||||
transform_tool->trans_info[XSHEAR] = 0.0;
|
||||
transform_tool->trans_info[YSHEAR] = 0.0;
|
||||
break;
|
||||
|
||||
case TRANSFORM_MOTION:
|
||||
shear_tool_motion (tool, gdisp);
|
||||
shear_tool_recalc (tool, gdisp);
|
||||
shear_tool_motion (transform_tool, gdisp);
|
||||
shear_tool_recalc (transform_tool, gdisp);
|
||||
break;
|
||||
|
||||
case TRANSFORM_RECALC:
|
||||
shear_tool_recalc (tool, gdisp);
|
||||
shear_tool_recalc (transform_tool, gdisp);
|
||||
break;
|
||||
|
||||
case TRANSFORM_FINISH:
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), FALSE);
|
||||
return gimp_shear_tool_shear (gdisp->gimage,
|
||||
gimp_image_active_drawable (gdisp->gimage),
|
||||
gdisp,
|
||||
transform_tool->original,
|
||||
gimp_transform_tool_smoothing (),
|
||||
transform_tool->transform);
|
||||
return gimp_transform_tool_transform_tiles (transform_tool,
|
||||
_("Shearing..."));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -254,12 +215,8 @@ gimp_shear_tool_transform (GimpTransformTool *transform_tool,
|
|||
}
|
||||
|
||||
static void
|
||||
shear_info_update (GimpTool *tool)
|
||||
shear_info_update (GimpTransformTool *transform_tool)
|
||||
{
|
||||
GimpTransformTool *transform_tool;
|
||||
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
||||
|
||||
xshear_val = transform_tool->trans_info[XSHEAR];
|
||||
yshear_val = transform_tool->trans_info[YSHEAR];
|
||||
|
||||
|
@ -272,26 +229,23 @@ shear_x_mag_changed (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
GimpTool *tool;
|
||||
GimpDrawTool *draw_tool;
|
||||
GimpTransformTool *transform_tool;
|
||||
gint value;
|
||||
|
||||
tool = (GimpTool *) data;
|
||||
tool = GIMP_TOOL (data);
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (data);
|
||||
|
||||
if (tool)
|
||||
value = GTK_ADJUSTMENT (widget)->value;
|
||||
|
||||
if (value != transform_tool->trans_info[XSHEAR])
|
||||
{
|
||||
draw_tool = GIMP_DRAW_TOOL (tool);
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
||||
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
||||
|
||||
value = GTK_ADJUSTMENT (widget)->value;
|
||||
transform_tool->trans_info[XSHEAR] = value;
|
||||
|
||||
if (value != transform_tool->trans_info[XSHEAR])
|
||||
{
|
||||
gimp_draw_tool_pause (draw_tool);
|
||||
transform_tool->trans_info[XSHEAR] = value;
|
||||
shear_tool_recalc (tool, tool->gdisp);
|
||||
gimp_draw_tool_resume (draw_tool);
|
||||
}
|
||||
shear_tool_recalc (transform_tool, tool->gdisp);
|
||||
|
||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -300,38 +254,32 @@ shear_y_mag_changed (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
GimpTool *tool;
|
||||
GimpDrawTool *draw_tool;
|
||||
GimpTransformTool *transform_tool;
|
||||
gint value;
|
||||
|
||||
tool = (GimpTool *) data;
|
||||
tool = GIMP_TOOL (data);
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (data);
|
||||
|
||||
if (tool)
|
||||
value = GTK_ADJUSTMENT (widget)->value;
|
||||
|
||||
if (value != transform_tool->trans_info[YSHEAR])
|
||||
{
|
||||
draw_tool = GIMP_DRAW_TOOL (tool);
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
||||
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
||||
|
||||
value = GTK_ADJUSTMENT (widget)->value;
|
||||
transform_tool->trans_info[YSHEAR] = value;
|
||||
|
||||
if (value != transform_tool->trans_info[YSHEAR])
|
||||
{
|
||||
gimp_draw_tool_pause (draw_tool);
|
||||
transform_tool->trans_info[YSHEAR] = value;
|
||||
shear_tool_recalc (tool, tool->gdisp);
|
||||
gimp_draw_tool_resume (draw_tool);
|
||||
}
|
||||
shear_tool_recalc (transform_tool, tool->gdisp);
|
||||
|
||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
shear_tool_motion (GimpTool *tool,
|
||||
GimpDisplay *gdisp)
|
||||
shear_tool_motion (GimpTransformTool *transform_tool,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
GimpTransformTool *transform_tool;
|
||||
gint diffx, diffy;
|
||||
gint dir;
|
||||
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
||||
gint diffx, diffy;
|
||||
gint dir;
|
||||
|
||||
diffx = transform_tool->curx - transform_tool->lastx;
|
||||
diffy = transform_tool->cury - transform_tool->lasty;
|
||||
|
@ -400,43 +348,27 @@ shear_tool_motion (GimpTool *tool,
|
|||
}
|
||||
|
||||
static void
|
||||
shear_tool_recalc (GimpTool *tool,
|
||||
GimpDisplay *gdisp)
|
||||
shear_tool_recalc (GimpTransformTool *transform_tool,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
GimpTransformTool *transform_tool;
|
||||
gfloat width, height;
|
||||
gfloat cx, cy;
|
||||
gdouble amount;
|
||||
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
||||
|
||||
cx = (transform_tool->x1 + transform_tool->x2) / 2.0;
|
||||
cy = (transform_tool->y1 + transform_tool->y2) / 2.0;
|
||||
|
||||
width = transform_tool->x2 - transform_tool->x1;
|
||||
height = transform_tool->y2 - transform_tool->y1;
|
||||
|
||||
if (width == 0)
|
||||
width = 1;
|
||||
if (height == 0)
|
||||
height = 1;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix3_identity (transform_tool->transform);
|
||||
gimp_matrix3_translate (transform_tool->transform, -cx, -cy);
|
||||
|
||||
/* shear matrix */
|
||||
if (transform_tool->trans_info[HORZ_OR_VERT] == ORIENTATION_HORIZONTAL)
|
||||
gimp_matrix3_xshear (transform_tool->transform,
|
||||
(float) transform_tool->trans_info [XSHEAR] / height);
|
||||
amount = transform_tool->trans_info[XSHEAR];
|
||||
else
|
||||
gimp_matrix3_yshear (transform_tool->transform,
|
||||
(float) transform_tool->trans_info [YSHEAR] / width);
|
||||
amount = transform_tool->trans_info[YSHEAR];
|
||||
|
||||
gimp_matrix3_translate (transform_tool->transform, +cx, +cy);
|
||||
gimp_drawable_transform_matrix_shear (transform_tool->x1,
|
||||
transform_tool->y1,
|
||||
transform_tool->x2,
|
||||
transform_tool->y2,
|
||||
transform_tool->trans_info[HORZ_OR_VERT],
|
||||
amount,
|
||||
transform_tool->transform);
|
||||
|
||||
/* transform the bounding box */
|
||||
gimp_transform_tool_transform_bounding_box (transform_tool);
|
||||
|
||||
/* update the information dialog */
|
||||
shear_info_update (tool);
|
||||
shear_info_update (transform_tool);
|
||||
}
|
||||
|
|
|
@ -45,17 +45,9 @@ struct _GimpShearToolClass
|
|||
};
|
||||
|
||||
|
||||
void gimp_shear_tool_register (Gimp *gimp);
|
||||
void gimp_shear_tool_register (Gimp *gimp);
|
||||
|
||||
GType gimp_shear_tool_get_type (void);
|
||||
|
||||
|
||||
TileManager * gimp_shear_tool_shear (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
GimpDisplay *gdisp,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix3 matrix);
|
||||
GType gimp_shear_tool_get_type (void);
|
||||
|
||||
|
||||
#endif /* __GIMP_SHEAR_TOOL_H__ */
|
||||
|
|
|
@ -27,160 +27,38 @@
|
|||
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
#include "gimprc.h"
|
||||
|
||||
#include "gimptool.h"
|
||||
#include "gimptransformtool.h"
|
||||
#include "transform_options.h"
|
||||
#include "tool_manager.h"
|
||||
|
||||
#include "app_procs.h"
|
||||
#include "gimprc.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
static TransformOptions *transform_options = NULL;
|
||||
/* local function prototypes */
|
||||
|
||||
/* Callback functions - need prototypes */
|
||||
static void gimp_transform_tool_grid_density_update (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void gimp_transform_tool_show_grid_update (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void gimp_transform_tool_show_path_update (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
static void
|
||||
gimp_transform_tool_direction_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
long dir = (long) data;
|
||||
|
||||
if (dir == TRANSFORM_TRADITIONAL)
|
||||
transform_options->direction = TRANSFORM_TRADITIONAL;
|
||||
else
|
||||
transform_options->direction = TRANSFORM_CORRECTIVE;
|
||||
}
|
||||
/* public functions */
|
||||
|
||||
static void
|
||||
gimp_transform_tool_grid_density_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
transform_options->grid_size =
|
||||
(int) (pow (2.0, 7.0 - GTK_ADJUSTMENT (widget)->value) + 0.5);
|
||||
|
||||
gimp_transform_tool_grid_density_changed ();
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_tool_show_grid_update (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
static gboolean first_call = TRUE; /* eek, this hack avoids a segfault */
|
||||
|
||||
if (first_call)
|
||||
{
|
||||
first_call = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
gimp_toggle_button_update (widget, data);
|
||||
|
||||
gimp_transform_tool_grid_density_changed ();
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_tool_show_path_update (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
static gboolean first_call = TRUE; /* eek, this hack avoids a segfault */
|
||||
|
||||
if (first_call)
|
||||
{
|
||||
first_call = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
gimp_transform_tool_showpath_changed (1); /* pause */
|
||||
gimp_toggle_button_update (widget, data);
|
||||
gimp_transform_tool_showpath_changed (0); /* resume */
|
||||
}
|
||||
|
||||
/* Global functions. No magic needed yet. */
|
||||
|
||||
/* Unhappy with this - making this stuff global is wrong. */
|
||||
|
||||
gboolean
|
||||
gimp_transform_tool_smoothing (void)
|
||||
{
|
||||
if (!transform_options)
|
||||
return TRUE;
|
||||
else
|
||||
return transform_options->smoothing;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_transform_tool_showpath (void)
|
||||
{
|
||||
if (!transform_options)
|
||||
return TRUE;
|
||||
else
|
||||
return transform_options->showpath;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_transform_tool_clip (void)
|
||||
{
|
||||
if (!transform_options)
|
||||
return FALSE;
|
||||
else
|
||||
return transform_options->clip;
|
||||
}
|
||||
|
||||
gint
|
||||
gimp_transform_tool_direction (void)
|
||||
{
|
||||
if (!transform_options)
|
||||
return TRANSFORM_TRADITIONAL;
|
||||
else
|
||||
return transform_options->direction;
|
||||
}
|
||||
|
||||
gint
|
||||
gimp_transform_tool_grid_size (void)
|
||||
{
|
||||
if (!transform_options)
|
||||
return 32;
|
||||
else
|
||||
return transform_options->grid_size;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_transform_tool_show_grid (void)
|
||||
{
|
||||
if (!transform_options)
|
||||
return TRUE;
|
||||
else
|
||||
return transform_options->show_grid;
|
||||
}
|
||||
|
||||
/* Main options stuff - the rest doesn't need to be here (default
|
||||
* callbacks is good, but none of this stuff should depend on having
|
||||
* access to the options)
|
||||
*/
|
||||
|
||||
void
|
||||
transform_options_reset (GimpToolOptions *tool_options)
|
||||
TransformOptions *
|
||||
transform_options_new (GType tool_type,
|
||||
ToolOptionsResetFunc reset_func)
|
||||
{
|
||||
TransformOptions *options;
|
||||
|
||||
options = (TransformOptions *) tool_options;
|
||||
options = g_new (TransformOptions, 1);
|
||||
transform_options_init (options, tool_type, reset_func);
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->smoothing_w),
|
||||
options->smoothing_d);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->showpath_w),
|
||||
options->showpath_d);
|
||||
gtk_toggle_button_set_active (((options->direction_d == TRANSFORM_TRADITIONAL) ?
|
||||
GTK_TOGGLE_BUTTON (options->direction_w[0]) :
|
||||
GTK_TOGGLE_BUTTON (options->direction_w[1])),
|
||||
TRUE);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->show_grid_w),
|
||||
options->show_grid_d);
|
||||
gtk_adjustment_set_value (GTK_ADJUSTMENT (options->grid_size_w),
|
||||
7.0 - log (options->grid_size_d) / log (2.0));
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->clip_w),
|
||||
options->clip_d);
|
||||
return options;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -202,23 +80,26 @@ transform_options_init (TransformOptions *options,
|
|||
vbox = options->tool_options.main_vbox;
|
||||
|
||||
options->smoothing = options->smoothing_d = TRUE;
|
||||
options->showpath = options->showpath_d = TRUE;
|
||||
options->show_path = options->show_path_d = TRUE;
|
||||
options->clip = options->clip_d = FALSE;
|
||||
options->direction = options->direction_d = TRANSFORM_TRADITIONAL;
|
||||
options->direction = options->direction_d = GIMP_TRANSFORM_FORWARD;
|
||||
options->grid_size = options->grid_size_d = 32;
|
||||
options->show_grid = options->show_grid_d = TRUE;
|
||||
|
||||
frame = gimp_radio_group_new (TRUE, _("Tool Paradigm"),
|
||||
frame = gimp_radio_group_new2 (TRUE, _("Tool Paradigm"),
|
||||
G_CALLBACK (gimp_radio_button_update),
|
||||
&options->direction,
|
||||
GINT_TO_POINTER (options->direction),
|
||||
|
||||
_("Traditional"), gimp_transform_tool_direction_callback,
|
||||
TRANSFORM_TRADITIONAL, NULL,
|
||||
&options->direction_w[0], TRUE,
|
||||
_("Traditional"),
|
||||
GINT_TO_POINTER (GIMP_TRANSFORM_FORWARD),
|
||||
&options->direction_w[0],
|
||||
|
||||
_("Corrective"), gimp_transform_tool_direction_callback,
|
||||
TRANSFORM_CORRECTIVE, NULL,
|
||||
&options->direction_w[1], FALSE,
|
||||
_("Corrective"),
|
||||
GINT_TO_POINTER (GIMP_TRANSFORM_BACKWARD),
|
||||
&options->direction_w[1],
|
||||
|
||||
NULL);
|
||||
NULL);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
@ -257,24 +138,24 @@ transform_options_init (TransformOptions *options,
|
|||
gtk_spin_button_new (GTK_ADJUSTMENT (options->grid_size_w), 0, 0);
|
||||
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (grid_density), TRUE);
|
||||
g_signal_connect (G_OBJECT (options->grid_size_w), "value_changed",
|
||||
G_CALLBACK (gimp_transform_tool_grid_density_callback),
|
||||
&options->grid_size);
|
||||
G_CALLBACK (gimp_transform_tool_grid_density_update),
|
||||
options);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), grid_density, FALSE, FALSE, 0);
|
||||
gtk_widget_show (grid_density);
|
||||
|
||||
gtk_widget_set_sensitive (label, options->show_grid_d);
|
||||
gtk_widget_set_sensitive (grid_density, options->show_grid_d);
|
||||
g_object_set_data (G_OBJECT (options->show_grid_w), "set_sensitive",
|
||||
grid_density);
|
||||
grid_density);
|
||||
g_object_set_data (G_OBJECT (grid_density), "set_sensitive", label);
|
||||
|
||||
/* the showpath toggle button */
|
||||
options->showpath_w = gtk_check_button_new_with_label (_("Show Path"));
|
||||
g_signal_connect (G_OBJECT (options->showpath_w), "toggled",
|
||||
/* the show_path toggle button */
|
||||
options->show_path_w = gtk_check_button_new_with_label (_("Show Path"));
|
||||
g_signal_connect (G_OBJECT (options->show_path_w), "toggled",
|
||||
G_CALLBACK (gimp_transform_tool_show_path_update),
|
||||
&options->showpath);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), options->showpath_w, FALSE, FALSE, 0);
|
||||
gtk_widget_show (options->showpath_w);
|
||||
&options->show_path);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), options->show_path_w, FALSE, FALSE, 0);
|
||||
gtk_widget_show (options->show_path_w);
|
||||
|
||||
/* the smoothing toggle button */
|
||||
options->smoothing_w = gtk_check_button_new_with_label (_("Smoothing"));
|
||||
|
@ -296,21 +177,97 @@ transform_options_init (TransformOptions *options,
|
|||
transform_options_reset ((GimpToolOptions *) options);
|
||||
}
|
||||
|
||||
TransformOptions *
|
||||
transform_options_new (GType tool_type,
|
||||
ToolOptionsResetFunc reset_func)
|
||||
void
|
||||
transform_options_reset (GimpToolOptions *tool_options)
|
||||
{
|
||||
TransformOptions *options;
|
||||
|
||||
options = g_new (TransformOptions, 1);
|
||||
transform_options_init (options, tool_type, reset_func);
|
||||
options = (TransformOptions *) tool_options;
|
||||
|
||||
/* Set our local copy of the active tool's options (so that
|
||||
* the methods/functions to access them work) */
|
||||
transform_options = options;
|
||||
|
||||
return options;
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->smoothing_w),
|
||||
options->smoothing_d);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->show_path_w),
|
||||
options->show_path_d);
|
||||
gtk_toggle_button_set_active (((options->direction_d == GIMP_TRANSFORM_FORWARD) ?
|
||||
GTK_TOGGLE_BUTTON (options->direction_w[0]) :
|
||||
GTK_TOGGLE_BUTTON (options->direction_w[1])),
|
||||
TRUE);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->show_grid_w),
|
||||
options->show_grid_d);
|
||||
gtk_adjustment_set_value (GTK_ADJUSTMENT (options->grid_size_w),
|
||||
7.0 - log (options->grid_size_d) / log (2.0));
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->clip_w),
|
||||
options->clip_d);
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
gimp_transform_tool_grid_density_update (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
TransformOptions *options;
|
||||
GimpTool *active_tool;
|
||||
|
||||
options = (TransformOptions *) data;
|
||||
|
||||
options->grid_size =
|
||||
(gint) (pow (2.0, 7.0 - GTK_ADJUSTMENT (widget)->value) + 0.5);
|
||||
|
||||
active_tool = tool_manager_get_active (the_gimp);
|
||||
|
||||
if (GIMP_IS_TRANSFORM_TOOL (active_tool))
|
||||
gimp_transform_tool_grid_density_changed (GIMP_TRANSFORM_TOOL (active_tool));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_tool_show_grid_update (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
static gboolean first_call = TRUE; /* eek, this hack avoids a segfault */
|
||||
|
||||
GimpTool *active_tool;
|
||||
|
||||
if (first_call)
|
||||
{
|
||||
first_call = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
gimp_toggle_button_update (widget, data);
|
||||
|
||||
active_tool = tool_manager_get_active (the_gimp);
|
||||
|
||||
if (GIMP_IS_TRANSFORM_TOOL (active_tool))
|
||||
gimp_transform_tool_grid_density_changed (GIMP_TRANSFORM_TOOL (active_tool));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_tool_show_path_update (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
static gboolean first_call = TRUE; /* eek, this hack avoids a segfault */
|
||||
|
||||
GimpTool *active_tool;
|
||||
GimpTransformTool *transform_tool = NULL;
|
||||
|
||||
if (first_call)
|
||||
{
|
||||
first_call = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
active_tool = tool_manager_get_active (the_gimp);
|
||||
|
||||
if (GIMP_IS_TRANSFORM_TOOL (active_tool))
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (active_tool);
|
||||
|
||||
if (transform_tool)
|
||||
gimp_transform_tool_show_path_changed (transform_tool, 1); /* pause */
|
||||
|
||||
gimp_toggle_button_update (widget, data);
|
||||
|
||||
if (transform_tool)
|
||||
gimp_transform_tool_show_path_changed (transform_tool, 0); /* resume */
|
||||
}
|
||||
|
|
|
@ -19,37 +19,39 @@
|
|||
#ifndef __TRANSFORM_OPTIONS_H__
|
||||
#define __TRANSFORM_OPTIONS_H_
|
||||
|
||||
|
||||
#include "tool_options.h"
|
||||
|
||||
|
||||
typedef struct _TransformOptions TransformOptions;
|
||||
|
||||
struct _TransformOptions
|
||||
{
|
||||
GimpToolOptions tool_options;
|
||||
GimpToolOptions tool_options;
|
||||
|
||||
gboolean smoothing;
|
||||
gboolean smoothing_d;
|
||||
GtkWidget *smoothing_w;
|
||||
gboolean smoothing;
|
||||
gboolean smoothing_d;
|
||||
GtkWidget *smoothing_w;
|
||||
|
||||
gint direction;
|
||||
gint direction_d;
|
||||
GtkWidget *direction_w[2]; /* 2 radio buttons */
|
||||
GimpTransformDirection direction;
|
||||
GimpTransformDirection direction_d;
|
||||
GtkWidget *direction_w[2]; /* 2 radio buttons */
|
||||
|
||||
gboolean show_grid;
|
||||
gboolean show_grid_d;
|
||||
GtkWidget *show_grid_w;
|
||||
gboolean show_grid;
|
||||
gboolean show_grid_d;
|
||||
GtkWidget *show_grid_w;
|
||||
|
||||
gint grid_size;
|
||||
gint grid_size_d;
|
||||
GtkObject *grid_size_w;
|
||||
gint grid_size;
|
||||
gint grid_size_d;
|
||||
GtkObject *grid_size_w;
|
||||
|
||||
gboolean clip;
|
||||
gboolean clip_d;
|
||||
GtkWidget *clip_w;
|
||||
gboolean clip;
|
||||
gboolean clip_d;
|
||||
GtkWidget *clip_w;
|
||||
|
||||
gboolean showpath;
|
||||
gboolean showpath_d;
|
||||
GtkWidget *showpath_w;
|
||||
gboolean show_path;
|
||||
gboolean show_path_d;
|
||||
GtkWidget *show_path_w;
|
||||
};
|
||||
|
||||
|
||||
|
@ -61,12 +63,5 @@ void transform_options_init (TransformOptions *options,
|
|||
ToolOptionsResetFunc reset_func);
|
||||
void transform_options_reset (GimpToolOptions *tool_options);
|
||||
|
||||
gboolean gimp_transform_tool_smoothing (void);
|
||||
gboolean gimp_transform_tool_showpath (void);
|
||||
gboolean gimp_transform_tool_clip (void);
|
||||
gint gimp_transform_tool_direction (void);
|
||||
gint gimp_transform_tool_grid_size (void);
|
||||
gboolean gimp_transform_tool_show_grid (void);
|
||||
|
||||
|
||||
#endif /* __TRANSFORM_OPTIONS_H__ */
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -31,12 +31,8 @@
|
|||
#define MAX_INFO_BUF 40
|
||||
#define TRAN_INFO_SIZE 8
|
||||
|
||||
enum BoundingBox
|
||||
{
|
||||
X0, Y0, X1, Y1, X2, Y2, X3, Y3
|
||||
};
|
||||
|
||||
typedef gdouble TranInfo[TRAN_INFO_SIZE];
|
||||
typedef gdouble TransInfo[TRAN_INFO_SIZE];
|
||||
|
||||
|
||||
#define GIMP_TYPE_TRANSFORM_TOOL (gimp_transform_tool_get_type ())
|
||||
|
@ -75,13 +71,14 @@ struct _GimpTransformTool
|
|||
gdouble tcx, tcy; /* */
|
||||
|
||||
GimpMatrix3 transform; /* transformation matrix */
|
||||
TranInfo trans_info; /* transformation info */
|
||||
TransInfo trans_info; /* transformation info */
|
||||
|
||||
TileManager *original; /* pointer to original tiles */
|
||||
|
||||
TransformAction function; /* current tool activity */
|
||||
|
||||
gboolean interactive; /* tool is interactive */
|
||||
gboolean use_grid; /* does the tool use the grid */
|
||||
|
||||
gint ngx, ngy; /* number of grid lines in original
|
||||
* x and y directions
|
||||
*/
|
||||
|
@ -102,6 +99,7 @@ struct _GimpTransformToolClass
|
|||
|
||||
};
|
||||
|
||||
|
||||
/* Special undo type */
|
||||
typedef struct _TransformUndo TransformUndo;
|
||||
|
||||
|
@ -110,59 +108,26 @@ struct _TransformUndo
|
|||
gint tool_ID;
|
||||
GType tool_type;
|
||||
|
||||
TranInfo trans_info;
|
||||
TransInfo trans_info;
|
||||
TileManager *original;
|
||||
gpointer path_undo;
|
||||
};
|
||||
|
||||
/* transform directions */
|
||||
#define TRANSFORM_TRADITIONAL 0
|
||||
#define TRANSFORM_CORRECTIVE 1
|
||||
|
||||
|
||||
/* make this variable available to all */
|
||||
/* Do we still need to do this? -- rock */
|
||||
extern InfoDialog * transform_info;
|
||||
|
||||
/* transform tool functions */
|
||||
/* make PDB compile: ToolType doesn't exist any more
|
||||
Tool * gimp_transform_tool_new (GimpTransformToolType tool_type,
|
||||
gboolean interactive);
|
||||
*/
|
||||
|
||||
GType gimp_transform_tool_get_type (void);
|
||||
GType gimp_transform_tool_get_type (void);
|
||||
|
||||
void gimp_transform_tool_transform_bounding_box (GimpTransformTool *tool);
|
||||
void gimp_transform_tool_reset (GimpTransformTool *tool,
|
||||
GimpDisplay *gdisp);
|
||||
void gimp_transform_tool_grid_density_changed (void);
|
||||
void gimp_transform_tool_showpath_changed (gint type);
|
||||
TileManager * gimp_transform_tool_transform (GimpTransformTool *tool,
|
||||
GimpDisplay *gdisp,
|
||||
TransformState state);
|
||||
/* transform functions */
|
||||
/* FIXME this function needs to be renamed */
|
||||
TileManager * gimp_transform_tool_do (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix3 matrix,
|
||||
GimpProgressFunc progress_callback,
|
||||
gpointer progress_data);
|
||||
TileManager * gimp_transform_tool_cut (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
gboolean *new_layer);
|
||||
gboolean gimp_transform_tool_paste (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
TileManager *tiles,
|
||||
gboolean new_layer);
|
||||
TileManager * gimp_transform_tool_transform_tiles (GimpTransformTool *tr_tool,
|
||||
const gchar *progress_text);
|
||||
void gimp_transform_tool_transform_bounding_box (GimpTransformTool *tr_tool);
|
||||
|
||||
gboolean gimp_transform_tool_smoothing (void);
|
||||
gboolean gimp_transform_tool_showpath (void);
|
||||
gboolean gimp_transform_tool_clip (void);
|
||||
gint gimp_transform_tool_direction (void);
|
||||
gint gimp_transform_tool_grid_size (void);
|
||||
gboolean gimp_transform_tool_show_grid (void);
|
||||
void gimp_transform_tool_grid_density_changed (GimpTransformTool *tr_tool);
|
||||
void gimp_transform_tool_show_path_changed (GimpTransformTool *tr_tool,
|
||||
gint type);
|
||||
|
||||
|
||||
#endif /* __GIMP_TRANSFORM_TOOL_H__ */
|
||||
|
|
|
@ -27,160 +27,38 @@
|
|||
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
#include "gimprc.h"
|
||||
|
||||
#include "gimptool.h"
|
||||
#include "gimptransformtool.h"
|
||||
#include "transform_options.h"
|
||||
#include "tool_manager.h"
|
||||
|
||||
#include "app_procs.h"
|
||||
#include "gimprc.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
static TransformOptions *transform_options = NULL;
|
||||
/* local function prototypes */
|
||||
|
||||
/* Callback functions - need prototypes */
|
||||
static void gimp_transform_tool_grid_density_update (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void gimp_transform_tool_show_grid_update (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void gimp_transform_tool_show_path_update (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
static void
|
||||
gimp_transform_tool_direction_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
long dir = (long) data;
|
||||
|
||||
if (dir == TRANSFORM_TRADITIONAL)
|
||||
transform_options->direction = TRANSFORM_TRADITIONAL;
|
||||
else
|
||||
transform_options->direction = TRANSFORM_CORRECTIVE;
|
||||
}
|
||||
/* public functions */
|
||||
|
||||
static void
|
||||
gimp_transform_tool_grid_density_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
transform_options->grid_size =
|
||||
(int) (pow (2.0, 7.0 - GTK_ADJUSTMENT (widget)->value) + 0.5);
|
||||
|
||||
gimp_transform_tool_grid_density_changed ();
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_tool_show_grid_update (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
static gboolean first_call = TRUE; /* eek, this hack avoids a segfault */
|
||||
|
||||
if (first_call)
|
||||
{
|
||||
first_call = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
gimp_toggle_button_update (widget, data);
|
||||
|
||||
gimp_transform_tool_grid_density_changed ();
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_tool_show_path_update (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
static gboolean first_call = TRUE; /* eek, this hack avoids a segfault */
|
||||
|
||||
if (first_call)
|
||||
{
|
||||
first_call = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
gimp_transform_tool_showpath_changed (1); /* pause */
|
||||
gimp_toggle_button_update (widget, data);
|
||||
gimp_transform_tool_showpath_changed (0); /* resume */
|
||||
}
|
||||
|
||||
/* Global functions. No magic needed yet. */
|
||||
|
||||
/* Unhappy with this - making this stuff global is wrong. */
|
||||
|
||||
gboolean
|
||||
gimp_transform_tool_smoothing (void)
|
||||
{
|
||||
if (!transform_options)
|
||||
return TRUE;
|
||||
else
|
||||
return transform_options->smoothing;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_transform_tool_showpath (void)
|
||||
{
|
||||
if (!transform_options)
|
||||
return TRUE;
|
||||
else
|
||||
return transform_options->showpath;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_transform_tool_clip (void)
|
||||
{
|
||||
if (!transform_options)
|
||||
return FALSE;
|
||||
else
|
||||
return transform_options->clip;
|
||||
}
|
||||
|
||||
gint
|
||||
gimp_transform_tool_direction (void)
|
||||
{
|
||||
if (!transform_options)
|
||||
return TRANSFORM_TRADITIONAL;
|
||||
else
|
||||
return transform_options->direction;
|
||||
}
|
||||
|
||||
gint
|
||||
gimp_transform_tool_grid_size (void)
|
||||
{
|
||||
if (!transform_options)
|
||||
return 32;
|
||||
else
|
||||
return transform_options->grid_size;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_transform_tool_show_grid (void)
|
||||
{
|
||||
if (!transform_options)
|
||||
return TRUE;
|
||||
else
|
||||
return transform_options->show_grid;
|
||||
}
|
||||
|
||||
/* Main options stuff - the rest doesn't need to be here (default
|
||||
* callbacks is good, but none of this stuff should depend on having
|
||||
* access to the options)
|
||||
*/
|
||||
|
||||
void
|
||||
transform_options_reset (GimpToolOptions *tool_options)
|
||||
TransformOptions *
|
||||
transform_options_new (GType tool_type,
|
||||
ToolOptionsResetFunc reset_func)
|
||||
{
|
||||
TransformOptions *options;
|
||||
|
||||
options = (TransformOptions *) tool_options;
|
||||
options = g_new (TransformOptions, 1);
|
||||
transform_options_init (options, tool_type, reset_func);
|
||||
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->smoothing_w),
|
||||
options->smoothing_d);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->showpath_w),
|
||||
options->showpath_d);
|
||||
gtk_toggle_button_set_active (((options->direction_d == TRANSFORM_TRADITIONAL) ?
|
||||
GTK_TOGGLE_BUTTON (options->direction_w[0]) :
|
||||
GTK_TOGGLE_BUTTON (options->direction_w[1])),
|
||||
TRUE);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->show_grid_w),
|
||||
options->show_grid_d);
|
||||
gtk_adjustment_set_value (GTK_ADJUSTMENT (options->grid_size_w),
|
||||
7.0 - log (options->grid_size_d) / log (2.0));
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->clip_w),
|
||||
options->clip_d);
|
||||
return options;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -202,23 +80,26 @@ transform_options_init (TransformOptions *options,
|
|||
vbox = options->tool_options.main_vbox;
|
||||
|
||||
options->smoothing = options->smoothing_d = TRUE;
|
||||
options->showpath = options->showpath_d = TRUE;
|
||||
options->show_path = options->show_path_d = TRUE;
|
||||
options->clip = options->clip_d = FALSE;
|
||||
options->direction = options->direction_d = TRANSFORM_TRADITIONAL;
|
||||
options->direction = options->direction_d = GIMP_TRANSFORM_FORWARD;
|
||||
options->grid_size = options->grid_size_d = 32;
|
||||
options->show_grid = options->show_grid_d = TRUE;
|
||||
|
||||
frame = gimp_radio_group_new (TRUE, _("Tool Paradigm"),
|
||||
frame = gimp_radio_group_new2 (TRUE, _("Tool Paradigm"),
|
||||
G_CALLBACK (gimp_radio_button_update),
|
||||
&options->direction,
|
||||
GINT_TO_POINTER (options->direction),
|
||||
|
||||
_("Traditional"), gimp_transform_tool_direction_callback,
|
||||
TRANSFORM_TRADITIONAL, NULL,
|
||||
&options->direction_w[0], TRUE,
|
||||
_("Traditional"),
|
||||
GINT_TO_POINTER (GIMP_TRANSFORM_FORWARD),
|
||||
&options->direction_w[0],
|
||||
|
||||
_("Corrective"), gimp_transform_tool_direction_callback,
|
||||
TRANSFORM_CORRECTIVE, NULL,
|
||||
&options->direction_w[1], FALSE,
|
||||
_("Corrective"),
|
||||
GINT_TO_POINTER (GIMP_TRANSFORM_BACKWARD),
|
||||
&options->direction_w[1],
|
||||
|
||||
NULL);
|
||||
NULL);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
@ -257,24 +138,24 @@ transform_options_init (TransformOptions *options,
|
|||
gtk_spin_button_new (GTK_ADJUSTMENT (options->grid_size_w), 0, 0);
|
||||
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (grid_density), TRUE);
|
||||
g_signal_connect (G_OBJECT (options->grid_size_w), "value_changed",
|
||||
G_CALLBACK (gimp_transform_tool_grid_density_callback),
|
||||
&options->grid_size);
|
||||
G_CALLBACK (gimp_transform_tool_grid_density_update),
|
||||
options);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), grid_density, FALSE, FALSE, 0);
|
||||
gtk_widget_show (grid_density);
|
||||
|
||||
gtk_widget_set_sensitive (label, options->show_grid_d);
|
||||
gtk_widget_set_sensitive (grid_density, options->show_grid_d);
|
||||
g_object_set_data (G_OBJECT (options->show_grid_w), "set_sensitive",
|
||||
grid_density);
|
||||
grid_density);
|
||||
g_object_set_data (G_OBJECT (grid_density), "set_sensitive", label);
|
||||
|
||||
/* the showpath toggle button */
|
||||
options->showpath_w = gtk_check_button_new_with_label (_("Show Path"));
|
||||
g_signal_connect (G_OBJECT (options->showpath_w), "toggled",
|
||||
/* the show_path toggle button */
|
||||
options->show_path_w = gtk_check_button_new_with_label (_("Show Path"));
|
||||
g_signal_connect (G_OBJECT (options->show_path_w), "toggled",
|
||||
G_CALLBACK (gimp_transform_tool_show_path_update),
|
||||
&options->showpath);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), options->showpath_w, FALSE, FALSE, 0);
|
||||
gtk_widget_show (options->showpath_w);
|
||||
&options->show_path);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), options->show_path_w, FALSE, FALSE, 0);
|
||||
gtk_widget_show (options->show_path_w);
|
||||
|
||||
/* the smoothing toggle button */
|
||||
options->smoothing_w = gtk_check_button_new_with_label (_("Smoothing"));
|
||||
|
@ -296,21 +177,97 @@ transform_options_init (TransformOptions *options,
|
|||
transform_options_reset ((GimpToolOptions *) options);
|
||||
}
|
||||
|
||||
TransformOptions *
|
||||
transform_options_new (GType tool_type,
|
||||
ToolOptionsResetFunc reset_func)
|
||||
void
|
||||
transform_options_reset (GimpToolOptions *tool_options)
|
||||
{
|
||||
TransformOptions *options;
|
||||
|
||||
options = g_new (TransformOptions, 1);
|
||||
transform_options_init (options, tool_type, reset_func);
|
||||
options = (TransformOptions *) tool_options;
|
||||
|
||||
/* Set our local copy of the active tool's options (so that
|
||||
* the methods/functions to access them work) */
|
||||
transform_options = options;
|
||||
|
||||
return options;
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->smoothing_w),
|
||||
options->smoothing_d);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->show_path_w),
|
||||
options->show_path_d);
|
||||
gtk_toggle_button_set_active (((options->direction_d == GIMP_TRANSFORM_FORWARD) ?
|
||||
GTK_TOGGLE_BUTTON (options->direction_w[0]) :
|
||||
GTK_TOGGLE_BUTTON (options->direction_w[1])),
|
||||
TRUE);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->show_grid_w),
|
||||
options->show_grid_d);
|
||||
gtk_adjustment_set_value (GTK_ADJUSTMENT (options->grid_size_w),
|
||||
7.0 - log (options->grid_size_d) / log (2.0));
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->clip_w),
|
||||
options->clip_d);
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
gimp_transform_tool_grid_density_update (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
TransformOptions *options;
|
||||
GimpTool *active_tool;
|
||||
|
||||
options = (TransformOptions *) data;
|
||||
|
||||
options->grid_size =
|
||||
(gint) (pow (2.0, 7.0 - GTK_ADJUSTMENT (widget)->value) + 0.5);
|
||||
|
||||
active_tool = tool_manager_get_active (the_gimp);
|
||||
|
||||
if (GIMP_IS_TRANSFORM_TOOL (active_tool))
|
||||
gimp_transform_tool_grid_density_changed (GIMP_TRANSFORM_TOOL (active_tool));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_tool_show_grid_update (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
static gboolean first_call = TRUE; /* eek, this hack avoids a segfault */
|
||||
|
||||
GimpTool *active_tool;
|
||||
|
||||
if (first_call)
|
||||
{
|
||||
first_call = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
gimp_toggle_button_update (widget, data);
|
||||
|
||||
active_tool = tool_manager_get_active (the_gimp);
|
||||
|
||||
if (GIMP_IS_TRANSFORM_TOOL (active_tool))
|
||||
gimp_transform_tool_grid_density_changed (GIMP_TRANSFORM_TOOL (active_tool));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_tool_show_path_update (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
static gboolean first_call = TRUE; /* eek, this hack avoids a segfault */
|
||||
|
||||
GimpTool *active_tool;
|
||||
GimpTransformTool *transform_tool = NULL;
|
||||
|
||||
if (first_call)
|
||||
{
|
||||
first_call = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
active_tool = tool_manager_get_active (the_gimp);
|
||||
|
||||
if (GIMP_IS_TRANSFORM_TOOL (active_tool))
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (active_tool);
|
||||
|
||||
if (transform_tool)
|
||||
gimp_transform_tool_show_path_changed (transform_tool, 1); /* pause */
|
||||
|
||||
gimp_toggle_button_update (widget, data);
|
||||
|
||||
if (transform_tool)
|
||||
gimp_transform_tool_show_path_changed (transform_tool, 0); /* resume */
|
||||
}
|
||||
|
|
|
@ -19,37 +19,39 @@
|
|||
#ifndef __TRANSFORM_OPTIONS_H__
|
||||
#define __TRANSFORM_OPTIONS_H_
|
||||
|
||||
|
||||
#include "tool_options.h"
|
||||
|
||||
|
||||
typedef struct _TransformOptions TransformOptions;
|
||||
|
||||
struct _TransformOptions
|
||||
{
|
||||
GimpToolOptions tool_options;
|
||||
GimpToolOptions tool_options;
|
||||
|
||||
gboolean smoothing;
|
||||
gboolean smoothing_d;
|
||||
GtkWidget *smoothing_w;
|
||||
gboolean smoothing;
|
||||
gboolean smoothing_d;
|
||||
GtkWidget *smoothing_w;
|
||||
|
||||
gint direction;
|
||||
gint direction_d;
|
||||
GtkWidget *direction_w[2]; /* 2 radio buttons */
|
||||
GimpTransformDirection direction;
|
||||
GimpTransformDirection direction_d;
|
||||
GtkWidget *direction_w[2]; /* 2 radio buttons */
|
||||
|
||||
gboolean show_grid;
|
||||
gboolean show_grid_d;
|
||||
GtkWidget *show_grid_w;
|
||||
gboolean show_grid;
|
||||
gboolean show_grid_d;
|
||||
GtkWidget *show_grid_w;
|
||||
|
||||
gint grid_size;
|
||||
gint grid_size_d;
|
||||
GtkObject *grid_size_w;
|
||||
gint grid_size;
|
||||
gint grid_size_d;
|
||||
GtkObject *grid_size_w;
|
||||
|
||||
gboolean clip;
|
||||
gboolean clip_d;
|
||||
GtkWidget *clip_w;
|
||||
gboolean clip;
|
||||
gboolean clip_d;
|
||||
GtkWidget *clip_w;
|
||||
|
||||
gboolean showpath;
|
||||
gboolean showpath_d;
|
||||
GtkWidget *showpath_w;
|
||||
gboolean show_path;
|
||||
gboolean show_path_d;
|
||||
GtkWidget *show_path_w;
|
||||
};
|
||||
|
||||
|
||||
|
@ -61,12 +63,5 @@ void transform_options_init (TransformOptions *options,
|
|||
ToolOptionsResetFunc reset_func);
|
||||
void transform_options_reset (GimpToolOptions *tool_options);
|
||||
|
||||
gboolean gimp_transform_tool_smoothing (void);
|
||||
gboolean gimp_transform_tool_showpath (void);
|
||||
gboolean gimp_transform_tool_clip (void);
|
||||
gint gimp_transform_tool_direction (void);
|
||||
gint gimp_transform_tool_grid_size (void);
|
||||
gboolean gimp_transform_tool_show_grid (void);
|
||||
|
||||
|
||||
#endif /* __TRANSFORM_OPTIONS_H__ */
|
||||
|
|
|
@ -56,6 +56,7 @@ PDB_WRAPPERS_C = \
|
|||
gimpselectiontools_pdb.c \
|
||||
gimptexttool_pdb.c \
|
||||
gimptools_pdb.c \
|
||||
gimptransformtools_pdb.c \
|
||||
gimpundo_pdb.c \
|
||||
gimpunit_pdb.c
|
||||
|
||||
|
@ -91,6 +92,7 @@ PDB_WRAPPERS_H = \
|
|||
gimpselectiontools_pdb.h \
|
||||
gimptexttool_pdb.h \
|
||||
gimptools_pdb.h \
|
||||
gimptransformtools_pdb.h \
|
||||
gimpundo_pdb.h \
|
||||
gimpunit_pdb.h
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include <libgimp/gimpselectiontools_pdb.h>
|
||||
#include <libgimp/gimptexttool_pdb.h>
|
||||
#include <libgimp/gimptools_pdb.h>
|
||||
#include <libgimp/gimptransformtools_pdb.h>
|
||||
#include <libgimp/gimpundo_pdb.h>
|
||||
#include <libgimp/gimpunit_pdb.h>
|
||||
|
||||
|
|
|
@ -650,48 +650,6 @@ gimp_eraser_default (gint32 drawable_ID,
|
|||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_flip:
|
||||
* @drawable_ID: The affected drawable.
|
||||
* @flip_type: Type of flip.
|
||||
*
|
||||
* Flip the specified drawable about its center either vertically or
|
||||
* horizontally.
|
||||
*
|
||||
* This tool flips the specified drawable if no selection exists. If a
|
||||
* selection exists, the portion of the drawable which lies under the
|
||||
* selection is cut from the drawable and made into a floating
|
||||
* selection which is then flipd by the specified amount. The return
|
||||
* value is the ID of the flipped drawable. If there was no selection,
|
||||
* this will be equal to the drawable ID supplied as input. Otherwise,
|
||||
* this will be the newly created and flipped drawable. The flip type
|
||||
* parameter indicates whether the flip will be applied horizontally or
|
||||
* vertically.
|
||||
*
|
||||
* Returns: The flipped drawable.
|
||||
*/
|
||||
gint32
|
||||
gimp_flip (gint32 drawable_ID,
|
||||
GimpOrientationType flip_type)
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gint32 ret_drawable_ID = -1;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_flip",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_DRAWABLE, drawable_ID,
|
||||
GIMP_PDB_INT32, flip_type,
|
||||
GIMP_PDB_END);
|
||||
|
||||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
ret_drawable_ID = return_vals[1].data.d_drawable;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return ret_drawable_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_paintbrush:
|
||||
* @drawable_ID: The affected drawable.
|
||||
|
@ -834,233 +792,6 @@ gimp_pencil (gint32 drawable_ID,
|
|||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_perspective:
|
||||
* @drawable_ID: The affected drawable.
|
||||
* @interpolation: Whether to use interpolation.
|
||||
* @x0: The new x coordinate of upper-left corner of original bounding box.
|
||||
* @y0: The new y coordinate of upper-left corner of original bounding box.
|
||||
* @x1: The new x coordinate of upper-right corner of original bounding box.
|
||||
* @y1: The new y coordinate of upper-right corner of original bounding box.
|
||||
* @x2: The new x coordinate of lower-left corner of original bounding box.
|
||||
* @y2: The new y coordinate of lower-left corner of original bounding box.
|
||||
* @x3: The new x coordinate of lower-right corner of original bounding box.
|
||||
* @y3: The new y coordinate of lower-right corner of original bounding box.
|
||||
*
|
||||
* Perform a possibly non-affine transformation on the specified
|
||||
* drawable.
|
||||
*
|
||||
* This tool performs a possibly non-affine transformation on the
|
||||
* specified drawable by allowing the corners of the original bounding
|
||||
* box to be arbitrarily remapped to any values. The specified drawable
|
||||
* is remapped if no selection exists. However, if a selection exists,
|
||||
* the portion of the drawable which lies under the selection is cut
|
||||
* from the drawable and made into a floating selection which is then
|
||||
* remapped as specified. The interpolation parameter can be set to
|
||||
* TRUE to indicate that either linear or cubic interpolation should be
|
||||
* used to smooth the resulting remapped drawable. The return value is
|
||||
* the ID of the remapped drawable. If there was no selection, this
|
||||
* will be equal to the drawable ID supplied as input. Otherwise, this
|
||||
* will be the newly created and remapped drawable. The 4 coordinates
|
||||
* specify the new locations of each corner of the original bounding
|
||||
* box. By specifying these values, any affine transformation
|
||||
* (rotation, scaling, translation) can be affected. Additionally,
|
||||
* these values can be specified such that the resulting transformed
|
||||
* drawable will appear to have been projected via a perspective
|
||||
* transform.
|
||||
*
|
||||
* Returns: The newly mapped drawable.
|
||||
*/
|
||||
gint32
|
||||
gimp_perspective (gint32 drawable_ID,
|
||||
gboolean interpolation,
|
||||
gdouble x0,
|
||||
gdouble y0,
|
||||
gdouble x1,
|
||||
gdouble y1,
|
||||
gdouble x2,
|
||||
gdouble y2,
|
||||
gdouble x3,
|
||||
gdouble y3)
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gint32 ret_drawable_ID = -1;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_perspective",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_DRAWABLE, drawable_ID,
|
||||
GIMP_PDB_INT32, interpolation,
|
||||
GIMP_PDB_FLOAT, x0,
|
||||
GIMP_PDB_FLOAT, y0,
|
||||
GIMP_PDB_FLOAT, x1,
|
||||
GIMP_PDB_FLOAT, y1,
|
||||
GIMP_PDB_FLOAT, x2,
|
||||
GIMP_PDB_FLOAT, y2,
|
||||
GIMP_PDB_FLOAT, x3,
|
||||
GIMP_PDB_FLOAT, y3,
|
||||
GIMP_PDB_END);
|
||||
|
||||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
ret_drawable_ID = return_vals[1].data.d_drawable;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return ret_drawable_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_rotate:
|
||||
* @drawable_ID: The affected drawable.
|
||||
* @interpolation: Whether to use interpolation.
|
||||
* @angle: The angle of rotation (radians).
|
||||
*
|
||||
* Rotate the specified drawable about its center through the specified
|
||||
* angle.
|
||||
*
|
||||
* This tool rotates the specified drawable if no selection exists. If
|
||||
* a selection exists, the portion of the drawable which lies under the
|
||||
* selection is cut from the drawable and made into a floating
|
||||
* selection which is then rotated by the specified amount. The
|
||||
* interpolation parameter can be set to TRUE to indicate that either
|
||||
* linear or cubic interpolation should be used to smooth the resulting
|
||||
* rotated drawable. The return value is the ID of the rotated
|
||||
* drawable. If there was no selection, this will be equal to the
|
||||
* drawable ID supplied as input. Otherwise, this will be the newly
|
||||
* created and rotated drawable.
|
||||
*
|
||||
* Returns: The rotated drawable.
|
||||
*/
|
||||
gint32
|
||||
gimp_rotate (gint32 drawable_ID,
|
||||
gboolean interpolation,
|
||||
gdouble angle)
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gint32 ret_drawable_ID = -1;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_rotate",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_DRAWABLE, drawable_ID,
|
||||
GIMP_PDB_INT32, interpolation,
|
||||
GIMP_PDB_FLOAT, angle,
|
||||
GIMP_PDB_END);
|
||||
|
||||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
ret_drawable_ID = return_vals[1].data.d_drawable;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return ret_drawable_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_scale:
|
||||
* @drawable_ID: The affected drawable.
|
||||
* @interpolation: Whether to use interpolation.
|
||||
* @x0: The new x coordinate of upper-left corner of newly scaled region.
|
||||
* @y0: The new y coordinate of upper-left corner of newly scaled region.
|
||||
* @x1: The new x coordinate of lower-right corner of newly scaled region.
|
||||
* @y1: The new y coordinate of lower-right corner of newly scaled region.
|
||||
*
|
||||
* Scale the specified drawable.
|
||||
*
|
||||
* This tool scales the specified drawable if no selection exists. If a
|
||||
* selection exists, the portion of the drawable which lies under the
|
||||
* selection is cut from the drawable and made into a floating
|
||||
* selection which is then scaled by the specified amount. The
|
||||
* interpolation parameter can be set to TRUE to indicate that either
|
||||
* linear or cubic interpolation should be used to smooth the resulting
|
||||
* scaled drawable. The return value is the ID of the scaled drawable.
|
||||
* If there was no selection, this will be equal to the drawable ID
|
||||
* supplied as input. Otherwise, this will be the newly created and
|
||||
* scaled drawable.
|
||||
*
|
||||
* Returns: The scaled drawable.
|
||||
*/
|
||||
gint32
|
||||
gimp_scale (gint32 drawable_ID,
|
||||
gboolean interpolation,
|
||||
gdouble x0,
|
||||
gdouble y0,
|
||||
gdouble x1,
|
||||
gdouble y1)
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gint32 ret_drawable_ID = -1;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_scale",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_DRAWABLE, drawable_ID,
|
||||
GIMP_PDB_INT32, interpolation,
|
||||
GIMP_PDB_FLOAT, x0,
|
||||
GIMP_PDB_FLOAT, y0,
|
||||
GIMP_PDB_FLOAT, x1,
|
||||
GIMP_PDB_FLOAT, y1,
|
||||
GIMP_PDB_END);
|
||||
|
||||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
ret_drawable_ID = return_vals[1].data.d_drawable;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return ret_drawable_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_shear:
|
||||
* @drawable_ID: The affected drawable.
|
||||
* @interpolation: Whether to use interpolation.
|
||||
* @shear_type: Type of shear.
|
||||
* @magnitude: The magnitude of the shear.
|
||||
*
|
||||
* Shear the specified drawable about its center by the specified
|
||||
* magnitude.
|
||||
*
|
||||
* This tool shears the specified drawable if no selection exists. If a
|
||||
* selection exists, the portion of the drawable which lies under the
|
||||
* selection is cut from the drawable and made into a floating
|
||||
* selection which is then sheard by the specified amount. The
|
||||
* interpolation parameter can be set to TRUE to indicate that either
|
||||
* linear or cubic interpolation should be used to smooth the resulting
|
||||
* sheared drawable. The return value is the ID of the sheard drawable.
|
||||
* If there was no selection, this will be equal to the drawable ID
|
||||
* supplied as input. Otherwise, this will be the newly created and
|
||||
* sheard drawable. The shear type parameter indicates whether the
|
||||
* shear will be applied horizontally or vertically. The magnitude can
|
||||
* be either positive or negative and indicates the extent (in pixels)
|
||||
* to shear by.
|
||||
*
|
||||
* Returns: The sheared drawable.
|
||||
*/
|
||||
gint32
|
||||
gimp_shear (gint32 drawable_ID,
|
||||
gboolean interpolation,
|
||||
GimpOrientationType shear_type,
|
||||
gdouble magnitude)
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gint32 ret_drawable_ID = -1;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_shear",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_DRAWABLE, drawable_ID,
|
||||
GIMP_PDB_INT32, interpolation,
|
||||
GIMP_PDB_INT32, shear_type,
|
||||
GIMP_PDB_FLOAT, magnitude,
|
||||
GIMP_PDB_END);
|
||||
|
||||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
ret_drawable_ID = return_vals[1].data.d_drawable;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return ret_drawable_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_smudge:
|
||||
* @drawable_ID: The affected drawable.
|
||||
|
@ -1138,68 +869,3 @@ gimp_smudge_default (gint32 drawable_ID,
|
|||
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_transform_2d:
|
||||
* @drawable_ID: The affected drawable.
|
||||
* @interpolation: Whether to use interpolation.
|
||||
* @source_x: X coordinate of the transformation center.
|
||||
* @source_y: Y coordinate of the transformation center.
|
||||
* @scale_x: Amount to scale in x direction.
|
||||
* @scale_y: Amount to scale in y direction.
|
||||
* @angle: The angle of rotation (radians).
|
||||
* @dest_x: X coordinate of where the centre goes.
|
||||
* @dest_y: Y coordinate of where the centre goes.
|
||||
*
|
||||
* Transform the specified drawable in 2d.
|
||||
*
|
||||
* This tool transforms the specified drawable if no selection exists.
|
||||
* If a selection exists, the portion of the drawable which lies under
|
||||
* the selection is cut from the drawable and made into a floating
|
||||
* selection which is then transformed. The interpolation parameter can
|
||||
* be set to TRUE to indicate that either linear or cubic interpolation
|
||||
* should be used to smooth the resulting drawable. The transformation
|
||||
* is done by scaling the image by the x and y scale factors about the
|
||||
* point (source_x, source_y), then rotating around the same point,
|
||||
* then translating that point to the new position (dest_x, dest_y).
|
||||
* The return value is the ID of the rotated drawable. If there was no
|
||||
* selection, this will be equal to the drawable ID supplied as input.
|
||||
* Otherwise, this will be the newly created and transformed drawable.
|
||||
*
|
||||
* Returns: The transformed drawable.
|
||||
*/
|
||||
gint32
|
||||
gimp_transform_2d (gint32 drawable_ID,
|
||||
gboolean interpolation,
|
||||
gdouble source_x,
|
||||
gdouble source_y,
|
||||
gdouble scale_x,
|
||||
gdouble scale_y,
|
||||
gdouble angle,
|
||||
gdouble dest_x,
|
||||
gdouble dest_y)
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gint32 ret_drawable_ID = -1;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_transform_2d",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_DRAWABLE, drawable_ID,
|
||||
GIMP_PDB_INT32, interpolation,
|
||||
GIMP_PDB_FLOAT, source_x,
|
||||
GIMP_PDB_FLOAT, source_y,
|
||||
GIMP_PDB_FLOAT, scale_x,
|
||||
GIMP_PDB_FLOAT, scale_y,
|
||||
GIMP_PDB_FLOAT, angle,
|
||||
GIMP_PDB_FLOAT, dest_x,
|
||||
GIMP_PDB_FLOAT, dest_y,
|
||||
GIMP_PDB_END);
|
||||
|
||||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
ret_drawable_ID = return_vals[1].data.d_drawable;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return ret_drawable_ID;
|
||||
}
|
||||
|
|
|
@ -104,8 +104,6 @@ gboolean gimp_eraser (gint32 drawable_ID,
|
|||
gboolean gimp_eraser_default (gint32 drawable_ID,
|
||||
gint num_strokes,
|
||||
gdouble *strokes);
|
||||
gint32 gimp_flip (gint32 drawable_ID,
|
||||
GimpOrientationType flip_type);
|
||||
gboolean gimp_paintbrush (gint32 drawable_ID,
|
||||
gdouble fade_out,
|
||||
gint num_strokes,
|
||||
|
@ -118,29 +116,6 @@ gboolean gimp_paintbrush_default (gint32 drawable_ID,
|
|||
gboolean gimp_pencil (gint32 drawable_ID,
|
||||
gint num_strokes,
|
||||
gdouble *strokes);
|
||||
gint32 gimp_perspective (gint32 drawable_ID,
|
||||
gboolean interpolation,
|
||||
gdouble x0,
|
||||
gdouble y0,
|
||||
gdouble x1,
|
||||
gdouble y1,
|
||||
gdouble x2,
|
||||
gdouble y2,
|
||||
gdouble x3,
|
||||
gdouble y3);
|
||||
gint32 gimp_rotate (gint32 drawable_ID,
|
||||
gboolean interpolation,
|
||||
gdouble angle);
|
||||
gint32 gimp_scale (gint32 drawable_ID,
|
||||
gboolean interpolation,
|
||||
gdouble x0,
|
||||
gdouble y0,
|
||||
gdouble x1,
|
||||
gdouble y1);
|
||||
gint32 gimp_shear (gint32 drawable_ID,
|
||||
gboolean interpolation,
|
||||
GimpOrientationType shear_type,
|
||||
gdouble magnitude);
|
||||
gboolean gimp_smudge (gint32 drawable_ID,
|
||||
gdouble pressure,
|
||||
gint num_strokes,
|
||||
|
@ -148,15 +123,6 @@ gboolean gimp_smudge (gint32 drawable_ID,
|
|||
gboolean gimp_smudge_default (gint32 drawable_ID,
|
||||
gint num_strokes,
|
||||
gdouble *strokes);
|
||||
gint32 gimp_transform_2d (gint32 drawable_ID,
|
||||
gboolean interpolation,
|
||||
gdouble source_x,
|
||||
gdouble source_y,
|
||||
gdouble scale_x,
|
||||
gdouble scale_y,
|
||||
gdouble angle,
|
||||
gdouble dest_x,
|
||||
gdouble dest_y);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -0,0 +1,358 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimptransformtools_pdb.c
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* NOTE: This file is autogenerated by pdbgen.pl */
|
||||
|
||||
#include "gimp.h"
|
||||
|
||||
/**
|
||||
* gimp_flip:
|
||||
* @drawable_ID: The affected drawable.
|
||||
* @flip_type: Type of flip.
|
||||
*
|
||||
* Flip the specified drawable about its center either vertically or
|
||||
* horizontally.
|
||||
*
|
||||
* This tool flips the specified drawable if no selection exists. If a
|
||||
* selection exists, the portion of the drawable which lies under the
|
||||
* selection is cut from the drawable and made into a floating
|
||||
* selection which is then flipd by the specified amount. The return
|
||||
* value is the ID of the flipped drawable. If there was no selection,
|
||||
* this will be equal to the drawable ID supplied as input. Otherwise,
|
||||
* this will be the newly created and flipped drawable. The flip type
|
||||
* parameter indicates whether the flip will be applied horizontally or
|
||||
* vertically.
|
||||
*
|
||||
* Returns: The flipped drawable.
|
||||
*/
|
||||
gint32
|
||||
gimp_flip (gint32 drawable_ID,
|
||||
GimpOrientationType flip_type)
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gint32 ret_drawable_ID = -1;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_flip",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_DRAWABLE, drawable_ID,
|
||||
GIMP_PDB_INT32, flip_type,
|
||||
GIMP_PDB_END);
|
||||
|
||||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
ret_drawable_ID = return_vals[1].data.d_drawable;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return ret_drawable_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_perspective:
|
||||
* @drawable_ID: The affected drawable.
|
||||
* @interpolation: Whether to use interpolation.
|
||||
* @x0: The new x coordinate of upper-left corner of original bounding box.
|
||||
* @y0: The new y coordinate of upper-left corner of original bounding box.
|
||||
* @x1: The new x coordinate of upper-right corner of original bounding box.
|
||||
* @y1: The new y coordinate of upper-right corner of original bounding box.
|
||||
* @x2: The new x coordinate of lower-left corner of original bounding box.
|
||||
* @y2: The new y coordinate of lower-left corner of original bounding box.
|
||||
* @x3: The new x coordinate of lower-right corner of original bounding box.
|
||||
* @y3: The new y coordinate of lower-right corner of original bounding box.
|
||||
*
|
||||
* Perform a possibly non-affine transformation on the specified
|
||||
* drawable.
|
||||
*
|
||||
* This tool performs a possibly non-affine transformation on the
|
||||
* specified drawable by allowing the corners of the original bounding
|
||||
* box to be arbitrarily remapped to any values. The specified drawable
|
||||
* is remapped if no selection exists. However, if a selection exists,
|
||||
* the portion of the drawable which lies under the selection is cut
|
||||
* from the drawable and made into a floating selection which is then
|
||||
* remapped as specified. The interpolation parameter can be set to
|
||||
* TRUE to indicate that either linear or cubic interpolation should be
|
||||
* used to smooth the resulting remapped drawable. The return value is
|
||||
* the ID of the remapped drawable. If there was no selection, this
|
||||
* will be equal to the drawable ID supplied as input. Otherwise, this
|
||||
* will be the newly created and remapped drawable. The 4 coordinates
|
||||
* specify the new locations of each corner of the original bounding
|
||||
* box. By specifying these values, any affine transformation
|
||||
* (rotation, scaling, translation) can be affected. Additionally,
|
||||
* these values can be specified such that the resulting transformed
|
||||
* drawable will appear to have been projected via a perspective
|
||||
* transform.
|
||||
*
|
||||
* Returns: The newly mapped drawable.
|
||||
*/
|
||||
gint32
|
||||
gimp_perspective (gint32 drawable_ID,
|
||||
gboolean interpolation,
|
||||
gdouble x0,
|
||||
gdouble y0,
|
||||
gdouble x1,
|
||||
gdouble y1,
|
||||
gdouble x2,
|
||||
gdouble y2,
|
||||
gdouble x3,
|
||||
gdouble y3)
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gint32 ret_drawable_ID = -1;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_perspective",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_DRAWABLE, drawable_ID,
|
||||
GIMP_PDB_INT32, interpolation,
|
||||
GIMP_PDB_FLOAT, x0,
|
||||
GIMP_PDB_FLOAT, y0,
|
||||
GIMP_PDB_FLOAT, x1,
|
||||
GIMP_PDB_FLOAT, y1,
|
||||
GIMP_PDB_FLOAT, x2,
|
||||
GIMP_PDB_FLOAT, y2,
|
||||
GIMP_PDB_FLOAT, x3,
|
||||
GIMP_PDB_FLOAT, y3,
|
||||
GIMP_PDB_END);
|
||||
|
||||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
ret_drawable_ID = return_vals[1].data.d_drawable;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return ret_drawable_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_rotate:
|
||||
* @drawable_ID: The affected drawable.
|
||||
* @interpolation: Whether to use interpolation.
|
||||
* @angle: The angle of rotation (radians).
|
||||
*
|
||||
* Rotate the specified drawable about its center through the specified
|
||||
* angle.
|
||||
*
|
||||
* This tool rotates the specified drawable if no selection exists. If
|
||||
* a selection exists, the portion of the drawable which lies under the
|
||||
* selection is cut from the drawable and made into a floating
|
||||
* selection which is then rotated by the specified amount. The
|
||||
* interpolation parameter can be set to TRUE to indicate that either
|
||||
* linear or cubic interpolation should be used to smooth the resulting
|
||||
* rotated drawable. The return value is the ID of the rotated
|
||||
* drawable. If there was no selection, this will be equal to the
|
||||
* drawable ID supplied as input. Otherwise, this will be the newly
|
||||
* created and rotated drawable.
|
||||
*
|
||||
* Returns: The rotated drawable.
|
||||
*/
|
||||
gint32
|
||||
gimp_rotate (gint32 drawable_ID,
|
||||
gboolean interpolation,
|
||||
gdouble angle)
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gint32 ret_drawable_ID = -1;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_rotate",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_DRAWABLE, drawable_ID,
|
||||
GIMP_PDB_INT32, interpolation,
|
||||
GIMP_PDB_FLOAT, angle,
|
||||
GIMP_PDB_END);
|
||||
|
||||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
ret_drawable_ID = return_vals[1].data.d_drawable;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return ret_drawable_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_scale:
|
||||
* @drawable_ID: The affected drawable.
|
||||
* @interpolation: Whether to use interpolation.
|
||||
* @x0: The new x coordinate of upper-left corner of newly scaled region.
|
||||
* @y0: The new y coordinate of upper-left corner of newly scaled region.
|
||||
* @x1: The new x coordinate of lower-right corner of newly scaled region.
|
||||
* @y1: The new y coordinate of lower-right corner of newly scaled region.
|
||||
*
|
||||
* Scale the specified drawable.
|
||||
*
|
||||
* This tool scales the specified drawable if no selection exists. If a
|
||||
* selection exists, the portion of the drawable which lies under the
|
||||
* selection is cut from the drawable and made into a floating
|
||||
* selection which is then scaled by the specified amount. The
|
||||
* interpolation parameter can be set to TRUE to indicate that either
|
||||
* linear or cubic interpolation should be used to smooth the resulting
|
||||
* scaled drawable. The return value is the ID of the scaled drawable.
|
||||
* If there was no selection, this will be equal to the drawable ID
|
||||
* supplied as input. Otherwise, this will be the newly created and
|
||||
* scaled drawable.
|
||||
*
|
||||
* Returns: The scaled drawable.
|
||||
*/
|
||||
gint32
|
||||
gimp_scale (gint32 drawable_ID,
|
||||
gboolean interpolation,
|
||||
gdouble x0,
|
||||
gdouble y0,
|
||||
gdouble x1,
|
||||
gdouble y1)
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gint32 ret_drawable_ID = -1;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_scale",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_DRAWABLE, drawable_ID,
|
||||
GIMP_PDB_INT32, interpolation,
|
||||
GIMP_PDB_FLOAT, x0,
|
||||
GIMP_PDB_FLOAT, y0,
|
||||
GIMP_PDB_FLOAT, x1,
|
||||
GIMP_PDB_FLOAT, y1,
|
||||
GIMP_PDB_END);
|
||||
|
||||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
ret_drawable_ID = return_vals[1].data.d_drawable;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return ret_drawable_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_shear:
|
||||
* @drawable_ID: The affected drawable.
|
||||
* @interpolation: Whether to use interpolation.
|
||||
* @shear_type: Type of shear.
|
||||
* @magnitude: The magnitude of the shear.
|
||||
*
|
||||
* Shear the specified drawable about its center by the specified
|
||||
* magnitude.
|
||||
*
|
||||
* This tool shears the specified drawable if no selection exists. If a
|
||||
* selection exists, the portion of the drawable which lies under the
|
||||
* selection is cut from the drawable and made into a floating
|
||||
* selection which is then sheard by the specified amount. The
|
||||
* interpolation parameter can be set to TRUE to indicate that either
|
||||
* linear or cubic interpolation should be used to smooth the resulting
|
||||
* sheared drawable. The return value is the ID of the sheard drawable.
|
||||
* If there was no selection, this will be equal to the drawable ID
|
||||
* supplied as input. Otherwise, this will be the newly created and
|
||||
* sheard drawable. The shear type parameter indicates whether the
|
||||
* shear will be applied horizontally or vertically. The magnitude can
|
||||
* be either positive or negative and indicates the extent (in pixels)
|
||||
* to shear by.
|
||||
*
|
||||
* Returns: The sheared drawable.
|
||||
*/
|
||||
gint32
|
||||
gimp_shear (gint32 drawable_ID,
|
||||
gboolean interpolation,
|
||||
GimpOrientationType shear_type,
|
||||
gdouble magnitude)
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gint32 ret_drawable_ID = -1;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_shear",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_DRAWABLE, drawable_ID,
|
||||
GIMP_PDB_INT32, interpolation,
|
||||
GIMP_PDB_INT32, shear_type,
|
||||
GIMP_PDB_FLOAT, magnitude,
|
||||
GIMP_PDB_END);
|
||||
|
||||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
ret_drawable_ID = return_vals[1].data.d_drawable;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return ret_drawable_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_transform_2d:
|
||||
* @drawable_ID: The affected drawable.
|
||||
* @interpolation: Whether to use interpolation.
|
||||
* @source_x: X coordinate of the transformation center.
|
||||
* @source_y: Y coordinate of the transformation center.
|
||||
* @scale_x: Amount to scale in x direction.
|
||||
* @scale_y: Amount to scale in y direction.
|
||||
* @angle: The angle of rotation (radians).
|
||||
* @dest_x: X coordinate of where the centre goes.
|
||||
* @dest_y: Y coordinate of where the centre goes.
|
||||
*
|
||||
* Transform the specified drawable in 2d.
|
||||
*
|
||||
* This tool transforms the specified drawable if no selection exists.
|
||||
* If a selection exists, the portion of the drawable which lies under
|
||||
* the selection is cut from the drawable and made into a floating
|
||||
* selection which is then transformed. The interpolation parameter can
|
||||
* be set to TRUE to indicate that either linear or cubic interpolation
|
||||
* should be used to smooth the resulting drawable. The transformation
|
||||
* is done by scaling the image by the x and y scale factors about the
|
||||
* point (source_x, source_y), then rotating around the same point,
|
||||
* then translating that point to the new position (dest_x, dest_y).
|
||||
* The return value is the ID of the rotated drawable. If there was no
|
||||
* selection, this will be equal to the drawable ID supplied as input.
|
||||
* Otherwise, this will be the newly created and transformed drawable.
|
||||
*
|
||||
* Returns: The transformed drawable.
|
||||
*/
|
||||
gint32
|
||||
gimp_transform_2d (gint32 drawable_ID,
|
||||
gboolean interpolation,
|
||||
gdouble source_x,
|
||||
gdouble source_y,
|
||||
gdouble scale_x,
|
||||
gdouble scale_y,
|
||||
gdouble angle,
|
||||
gdouble dest_x,
|
||||
gdouble dest_y)
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gint32 ret_drawable_ID = -1;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_transform_2d",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_DRAWABLE, drawable_ID,
|
||||
GIMP_PDB_INT32, interpolation,
|
||||
GIMP_PDB_FLOAT, source_x,
|
||||
GIMP_PDB_FLOAT, source_y,
|
||||
GIMP_PDB_FLOAT, scale_x,
|
||||
GIMP_PDB_FLOAT, scale_y,
|
||||
GIMP_PDB_FLOAT, angle,
|
||||
GIMP_PDB_FLOAT, dest_x,
|
||||
GIMP_PDB_FLOAT, dest_y,
|
||||
GIMP_PDB_END);
|
||||
|
||||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
ret_drawable_ID = return_vals[1].data.d_drawable;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return ret_drawable_ID;
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimptransformtools_pdb.h
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* NOTE: This file is autogenerated by pdbgen.pl */
|
||||
|
||||
#ifndef __GIMP_TRANSFORM_TOOLS_PDB_H__
|
||||
#define __GIMP_TRANSFORM_TOOLS_PDB_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* For information look into the C source or the html documentation */
|
||||
|
||||
|
||||
gint32 gimp_flip (gint32 drawable_ID,
|
||||
GimpOrientationType flip_type);
|
||||
gint32 gimp_perspective (gint32 drawable_ID,
|
||||
gboolean interpolation,
|
||||
gdouble x0,
|
||||
gdouble y0,
|
||||
gdouble x1,
|
||||
gdouble y1,
|
||||
gdouble x2,
|
||||
gdouble y2,
|
||||
gdouble x3,
|
||||
gdouble y3);
|
||||
gint32 gimp_rotate (gint32 drawable_ID,
|
||||
gboolean interpolation,
|
||||
gdouble angle);
|
||||
gint32 gimp_scale (gint32 drawable_ID,
|
||||
gboolean interpolation,
|
||||
gdouble x0,
|
||||
gdouble y0,
|
||||
gdouble x1,
|
||||
gdouble y1);
|
||||
gint32 gimp_shear (gint32 drawable_ID,
|
||||
gboolean interpolation,
|
||||
GimpOrientationType shear_type,
|
||||
gdouble magnitude);
|
||||
gint32 gimp_transform_2d (gint32 drawable_ID,
|
||||
gboolean interpolation,
|
||||
gdouble source_x,
|
||||
gdouble source_y,
|
||||
gdouble scale_x,
|
||||
gdouble scale_y,
|
||||
gdouble angle,
|
||||
gdouble dest_x,
|
||||
gdouble dest_y);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __GIMP_TRANSFORM_TOOLS_PDB_H__ */
|
|
@ -32,6 +32,7 @@ pdb_sources = \
|
|||
pdb/selection_tools.pdb \
|
||||
pdb/text_tool.pdb \
|
||||
pdb/tools.pdb \
|
||||
pdb/transform_tools.pdb \
|
||||
pdb/undo.pdb \
|
||||
pdb/unit.pdb
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
selection_tools
|
||||
text_tool
|
||||
tools
|
||||
transform_tools
|
||||
undo
|
||||
unit
|
||||
);
|
||||
|
|
|
@ -544,79 +544,6 @@ CODE
|
|||
);
|
||||
}
|
||||
|
||||
sub flip {
|
||||
$blurb = <<'BLURB';
|
||||
Flip the specified drawable about its center either vertically or
|
||||
horizontally.
|
||||
BLURB
|
||||
|
||||
$help = <<'HELP';
|
||||
This tool flips the specified drawable if no selection exists. If a selection
|
||||
exists, the portion of the drawable which lies under the selection is cut from
|
||||
the drawable and made into a floating selection which is then flipd by the
|
||||
specified amount. The return value is the ID of the flipped drawable. If there
|
||||
was no selection, this will be equal to the drawable ID supplied as input.
|
||||
Otherwise, this will be the newly created and flipped drawable. The flip type
|
||||
parameter indicates whether the flip will be applied horizontally or
|
||||
vertically.
|
||||
HELP
|
||||
|
||||
&std_pdb_misc;
|
||||
|
||||
@inargs = (
|
||||
&drawable_arg,
|
||||
{ name => 'flip_type', type => &std_orientation_enum,
|
||||
desc => 'Type of flip: %%desc%%' }
|
||||
);
|
||||
|
||||
@outargs = ( &drawable_out_arg('flipped') );
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("tools/gimpfliptool.h" "tools/gimptransformtool.h"
|
||||
"undo.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'gboolean new_layer' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
||||
/* Start a transform undo group */
|
||||
undo_push_group_start (gimage, TRANSFORM_CORE_UNDO);
|
||||
|
||||
/* Cut/Copy from the specified drawable */
|
||||
float_tiles = gimp_transform_tool_cut (gimage, drawable, &new_layer);
|
||||
|
||||
flip_type = flip_type == HORIZONTAL ? ORIENTATION_HORIZONTAL :
|
||||
flip_type == VERTICAL ? ORIENTATION_VERTICAL :
|
||||
ORIENTATION_UNKNOWN;
|
||||
|
||||
/* flip the buffer */
|
||||
switch (flip_type)
|
||||
{
|
||||
case ORIENTATION_HORIZONTAL:
|
||||
case ORIENTATION_VERTICAL:
|
||||
new_tiles = flip_tool_flip (gimage, drawable, float_tiles, -1, flip_type);
|
||||
break;
|
||||
default:
|
||||
new_tiles = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
/* free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
||||
if (new_tiles)
|
||||
success = gimp_transform_tool_paste (gimage, drawable, new_tiles, new_layer);
|
||||
else
|
||||
success = FALSE;
|
||||
|
||||
/* push the undo group end */
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub paintbrush {
|
||||
$blurb = <<'BLURB';
|
||||
Paint in the current brush with optional fade out parameter and pull colors
|
||||
|
@ -716,442 +643,6 @@ HELP
|
|||
);
|
||||
}
|
||||
|
||||
sub perspective {
|
||||
$blurb = <<'BLURB';
|
||||
Perform a possibly non-affine transformation on the specified drawable.
|
||||
BLURB
|
||||
|
||||
$help = <<'HELP';
|
||||
This tool performs a possibly non-affine transformation on the specified
|
||||
drawable by allowing the corners of the original bounding box to be arbitrarily
|
||||
remapped to any values. The specified drawable is remapped if no selection
|
||||
exists. However, if a selection exists, the portion of the drawable which lies
|
||||
under the selection is cut from the drawable and made into a floating selection
|
||||
which is then remapped as specified. The interpolation parameter can be set to
|
||||
TRUE to indicate that either linear or cubic interpolation should be used to
|
||||
smooth the resulting remapped drawable. The return value is the ID of the
|
||||
remapped drawable. If there was no selection, this will be equal to the
|
||||
drawable ID supplied as input. Otherwise, this will be the newly created and
|
||||
remapped drawable. The 4 coordinates specify the new locations of each corner
|
||||
of the original bounding box. By specifying these values, any affine
|
||||
transformation (rotation, scaling, translation) can be affected. Additionally,
|
||||
these values can be specified such that the resulting transformed drawable will
|
||||
appear to have been projected via a perspective transform.
|
||||
HELP
|
||||
|
||||
&std_pdb_misc;
|
||||
|
||||
@inargs = (
|
||||
&drawable_arg,
|
||||
{ name => 'interpolation', type => 'boolean',
|
||||
desc => 'Whether to use interpolation' }
|
||||
);
|
||||
|
||||
my $pos = 0;
|
||||
foreach $where (qw(upper-left upper-right lower-left lower-right)) {
|
||||
foreach (qw(x y)) {
|
||||
push @inargs,
|
||||
{ name => "$_$pos", type => 'float',
|
||||
desc => "The new $_ coordinate of $where corner of original
|
||||
bounding box",
|
||||
alias => "trans_info[\U$_\E$pos]", no_declare => 1 }
|
||||
}
|
||||
$pos++;
|
||||
}
|
||||
|
||||
@outargs = ( &drawable_out_arg('newly mapped') );
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("tools/gimpperspectivetool.h" "tools/gimptransformtool.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'gboolean new_layer', 'gint offset_x, offset_y',
|
||||
'gdouble cx, cy', 'gdouble scalex, scaley',
|
||||
'gdouble trans_info[8]', 'GimpMatrix3 m, matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
||||
/* Start a transform undo group */
|
||||
undo_push_group_start (gimage, TRANSFORM_CORE_UNDO);
|
||||
|
||||
/* Cut/Copy from the specified drawable */
|
||||
float_tiles = gimp_transform_tool_cut (gimage, drawable, &new_layer);
|
||||
|
||||
/* Determine the perspective transform that maps from
|
||||
* the unit cube to the trans_info coordinates
|
||||
*/
|
||||
gimp_perspective_tool_find_transform (trans_info, m);
|
||||
|
||||
tile_manager_get_offsets (float_tiles, &offset_x, &offset_y);
|
||||
cx = (gdouble) offset_x;
|
||||
cy = (gdouble) offset_y;
|
||||
scalex = 1.0;
|
||||
scaley = 1.0;
|
||||
if (tile_manager_width (float_tiles))
|
||||
scalex = 1.0 / tile_manager_width (float_tiles);
|
||||
if (tile_manager_height (float_tiles))
|
||||
scaley = 1.0 / tile_manager_height (float_tiles);
|
||||
|
||||
/* Assemble the transformation matrix */
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, -cx, -cy);
|
||||
gimp_matrix3_scale (matrix, scalex, scaley);
|
||||
gimp_matrix3_mult (m, matrix);
|
||||
|
||||
/* Perspective the buffer */
|
||||
new_tiles = gimp_perspective_tool_perspective (gimage, drawable, NULL,
|
||||
float_tiles, interpolation,
|
||||
matrix);
|
||||
|
||||
/* Free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
||||
if (new_tiles)
|
||||
success = gimp_transform_tool_paste (gimage, drawable, new_tiles, new_layer);
|
||||
else
|
||||
success = FALSE;
|
||||
|
||||
/* push the undo group end */
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub rotate {
|
||||
$blurb = <<'BLURB';
|
||||
Rotate the specified drawable about its center through the specified angle.
|
||||
BLURB
|
||||
|
||||
$help = <<'HELP';
|
||||
This tool rotates the specified drawable if no selection exists. If a selection
|
||||
exists, the portion of the drawable which lies under the selection is cut from
|
||||
the drawable and made into a floating selection which is then rotated by the
|
||||
specified amount. The interpolation parameter can be set to TRUE to indicate
|
||||
that either linear or cubic interpolation should be used to smooth the
|
||||
resulting rotated drawable. The return value is the ID of the rotated drawable.
|
||||
If there was no selection, this will be equal to the drawable ID supplied as
|
||||
input. Otherwise, this will be the newly created and rotated drawable.
|
||||
HELP
|
||||
|
||||
&std_pdb_misc;
|
||||
|
||||
@inargs = (
|
||||
&drawable_arg,
|
||||
{ name => 'interpolation', type => 'boolean',
|
||||
desc => 'Whether to use interpolation' },
|
||||
{ name => 'angle', type => 'float',
|
||||
desc => 'The angle of rotation (radians)' }
|
||||
);
|
||||
|
||||
@outargs = ( &drawable_out_arg('rotated') );
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("tools/gimprotatetool.h" "tools/gimptransformtool.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'gboolean new_layer', 'gint offset_x, offset_y',
|
||||
'gdouble cx, cy', 'GimpMatrix3 matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
||||
/* Start a transform undo group */
|
||||
undo_push_group_start (gimage, TRANSFORM_CORE_UNDO);
|
||||
|
||||
/* Cut/Copy from the specified drawable */
|
||||
float_tiles = gimp_transform_tool_cut (gimage, drawable, &new_layer);
|
||||
|
||||
tile_manager_get_offsets (float_tiles, &offset_x, &offset_y);
|
||||
cx = offset_x + tile_manager_width (float_tiles) / 2.0;
|
||||
cy = offset_y + tile_manager_height (float_tiles) / 2.0;
|
||||
|
||||
/* Assemble the transformation matrix */
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, -cx, -cy);
|
||||
gimp_matrix3_rotate (matrix, angle);
|
||||
gimp_matrix3_translate (matrix, +cx, +cy);
|
||||
|
||||
/* Rotate the buffer */
|
||||
new_tiles = gimp_rotate_tool_rotate (gimage, drawable, NULL, angle,
|
||||
float_tiles, interpolation, matrix);
|
||||
|
||||
/* Free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
||||
if (new_tiles)
|
||||
success = gimp_transform_tool_paste (gimage, drawable, new_tiles, new_layer);
|
||||
else
|
||||
success = FALSE;
|
||||
|
||||
/* Push the undo group end */
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub scale {
|
||||
$blurb = 'Scale the specified drawable.';
|
||||
|
||||
$help = <<'HELP';
|
||||
This tool scales the specified drawable if no selection exists. If a selection
|
||||
exists, the portion of the drawable which lies under the selection is cut from
|
||||
the drawable and made into a floating selection which is then scaled by the
|
||||
specified amount. The interpolation parameter can be set to TRUE to indicate
|
||||
that either linear or cubic interpolation should be used to smooth the
|
||||
resulting scaled drawable. The return value is the ID of the scaled drawable.
|
||||
If there was no selection, this will be equal to the drawable ID supplied as
|
||||
input. Otherwise, this will be the newly created and scaled drawable.
|
||||
HELP
|
||||
|
||||
&std_pdb_misc;
|
||||
|
||||
@inargs = (
|
||||
&drawable_arg,
|
||||
{ name => 'interpolation', type => 'boolean',
|
||||
desc => 'Whether to use interpolation' }
|
||||
);
|
||||
|
||||
my $pos = 0;
|
||||
foreach $where (qw(upper-left lower-right)) {
|
||||
foreach (qw(x y)) {
|
||||
push @inargs,
|
||||
{ name => "$_$pos", type => 'float',
|
||||
desc => "The new $_ coordinate of $where corner of newly
|
||||
scaled region",
|
||||
alias => "trans_info[\U$_\E$pos]", no_declare => 1 }
|
||||
}
|
||||
$pos++;
|
||||
}
|
||||
|
||||
@outargs = ( &drawable_out_arg('scaled') );
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("tools/gimpscaletool.h" "tools/gimptransformtool.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'gboolean new_layer', 'gint offset_x, offset_y',
|
||||
'gdouble scalex, scaley', 'gdouble trans_info[4]',
|
||||
'GimpMatrix3 matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
if (trans_info[X0] < trans_info[X1] &&
|
||||
trans_info[Y0] < trans_info[X1])
|
||||
{
|
||||
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
||||
/* Start a transform undo group */
|
||||
undo_push_group_start (gimage, TRANSFORM_CORE_UNDO);
|
||||
|
||||
/* Cut/Copy from the specified drawable */
|
||||
float_tiles = gimp_transform_tool_cut (gimage, drawable, &new_layer);
|
||||
|
||||
scalex = scaley = 1.0;
|
||||
if (tile_manager_width (float_tiles))
|
||||
scalex = (trans_info[X1] - trans_info[X0]) /
|
||||
(gdouble) tile_manager_width (float_tiles);
|
||||
if (tile_manager_height (float_tiles))
|
||||
scaley = (trans_info[Y1] - trans_info[Y0]) /
|
||||
(gdouble) tile_manager_height (float_tiles);
|
||||
|
||||
tile_manager_get_offsets (float_tiles, &offset_x, &offset_y);
|
||||
|
||||
/* Assemble the transformation matrix */
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, offset_x, offset_y);
|
||||
gimp_matrix3_scale (matrix, scalex, scaley);
|
||||
gimp_matrix3_translate (matrix, trans_info[X0], trans_info[Y0]);
|
||||
|
||||
/* Scale the buffer */
|
||||
new_tiles = gimp_scale_tool_scale (gimage, drawable, NULL, trans_info,
|
||||
float_tiles, interpolation, matrix);
|
||||
|
||||
/* Free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
||||
if (new_tiles)
|
||||
success = gimp_transform_tool_paste (gimage, drawable, new_tiles, new_layer);
|
||||
else
|
||||
success = FALSE;
|
||||
|
||||
/* push the undo group end */
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub shear {
|
||||
$blurb = <<'BLURB';
|
||||
Shear the specified drawable about its center by the specified magnitude.
|
||||
BLURB
|
||||
|
||||
$help = <<'HELP';
|
||||
This tool shears the specified drawable if no selection exists. If a selection
|
||||
exists, the portion of the drawable which lies under the selection is cut from
|
||||
the drawable and made into a floating selection which is then sheard by the
|
||||
specified amount. The interpolation parameter can be set to TRUE to indicate
|
||||
that either linear or cubic interpolation should be used to smooth the
|
||||
resulting sheared drawable. The return value is the ID of the sheard drawable.
|
||||
If there was no selection, this will be equal to the drawable ID supplied as
|
||||
input. Otherwise, this will be the newly created and sheard drawable. The shear
|
||||
type parameter indicates whether the shear will be applied horizontally or
|
||||
vertically. The magnitude can be either positive or negative and indicates the
|
||||
extent (in pixels) to shear by.
|
||||
HELP
|
||||
|
||||
&std_pdb_misc;
|
||||
|
||||
@inargs = (
|
||||
&drawable_arg,
|
||||
{ name => 'interpolation', type => 'boolean',
|
||||
desc => 'Whether to use interpolation' },
|
||||
{ name => 'shear_type', type => &std_orientation_enum,
|
||||
desc => 'Type of shear: %%desc%%' },
|
||||
{ name => 'magnitude', type => 'float',
|
||||
desc => 'The magnitude of the shear' }
|
||||
);
|
||||
|
||||
@outargs = ( &drawable_out_arg('sheared') );
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("tools/gimpsheartool.h" "tools/gimptransformtool.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'gboolean new_layer', 'gdouble cx, cy',
|
||||
'gint offset_x, offset_y', 'GimpMatrix3 matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
||||
/* Start a transform undo group */
|
||||
undo_push_group_start (gimage, TRANSFORM_CORE_UNDO);
|
||||
|
||||
/* Cut/Copy from the specified drawable */
|
||||
float_tiles = gimp_transform_tool_cut (gimage, drawable, &new_layer);
|
||||
|
||||
tile_manager_get_offsets (float_tiles, &offset_x, &offset_y);
|
||||
|
||||
cx = offset_x + tile_manager_width (float_tiles) / 2.0;
|
||||
cy = offset_y + tile_manager_height (float_tiles) / 2.0;
|
||||
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, -cx, -cy);
|
||||
/* Shear matrix */
|
||||
shear_type = shear_type == HORIZONTAL ? ORIENTATION_HORIZONTAL :
|
||||
shear_type == VERTICAL ? ORIENTATION_VERTICAL :
|
||||
ORIENTATION_UNKNOWN;
|
||||
|
||||
if (shear_type == ORIENTATION_HORIZONTAL)
|
||||
gimp_matrix3_xshear (matrix, magnitude / tile_manager_height (float_tiles));
|
||||
else if (shear_type == ORIENTATION_VERTICAL)
|
||||
gimp_matrix3_yshear (matrix, magnitude / tile_manager_width (float_tiles));
|
||||
|
||||
gimp_matrix3_translate (matrix, +cx, +cy);
|
||||
|
||||
/* Shear the buffer */
|
||||
new_tiles = gimp_shear_tool_shear (gimage, drawable, NULL, float_tiles,
|
||||
interpolation, matrix);
|
||||
|
||||
/* Free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
||||
if (new_tiles)
|
||||
success = gimp_transform_tool_paste (gimage, drawable, new_tiles, new_layer);
|
||||
else
|
||||
success = FALSE;
|
||||
|
||||
/* Push the undo group end */
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub transform_2d {
|
||||
$blurb = <<'BLURB';
|
||||
Transform the specified drawable in 2d.
|
||||
BLURB
|
||||
|
||||
$help = <<'HELP';
|
||||
This tool transforms the specified drawable if no selection exists. If a
|
||||
selection exists, the portion of the drawable which lies under the
|
||||
selection is cut from the drawable and made into a floating selection which
|
||||
is then transformed. The interpolation parameter can be set to TRUE to
|
||||
indicate that either linear or cubic interpolation should be used to smooth
|
||||
the resulting drawable. The transformation is done by scaling the image by
|
||||
the x and y scale factors about the point (source_x, source_y), then rotating
|
||||
around the same point, then translating that point to the new position
|
||||
(dest_x, dest_y). The return value is the ID of the rotated drawable. If
|
||||
there was no selection, this will be equal to the drawable ID supplied as
|
||||
input. Otherwise, this will be the newly created and transformed drawable.
|
||||
HELP
|
||||
|
||||
&std_pdb_misc;
|
||||
|
||||
@inargs = (
|
||||
&drawable_arg,
|
||||
{ name => 'interpolation', type => 'boolean',
|
||||
desc => 'Whether to use interpolation' },
|
||||
{ name => 'source_x', type => 'float',
|
||||
desc => 'X coordinate of the transformation center' },
|
||||
{ name => 'source_y', type => 'float',
|
||||
desc => 'Y coordinate of the transformation center' },
|
||||
{ name => 'scale_x', type => 'float',
|
||||
desc => 'Amount to scale in x direction' },
|
||||
{ name => 'scale_y', type => 'float',
|
||||
desc => 'Amount to scale in y direction' },
|
||||
{ name => 'angle', type => 'float',
|
||||
desc => 'The angle of rotation (radians)' },
|
||||
{ name => 'dest_x', type => 'float',
|
||||
desc => 'X coordinate of where the centre goes' },
|
||||
{ name => 'dest_y', type => 'float',
|
||||
desc => 'Y coordinate of where the centre goes' }
|
||||
);
|
||||
|
||||
@outargs = ( &drawable_out_arg('transformed') );
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("tools/gimptransformtool.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'gboolean new_layer', 'GimpMatrix3 matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
||||
/* Start a transform undo group */
|
||||
undo_push_group_start (gimage, TRANSFORM_CORE_UNDO);
|
||||
|
||||
/* Cut/Copy from the specified drawable */
|
||||
float_tiles = gimp_transform_tool_cut (gimage, drawable, &new_layer);
|
||||
|
||||
/* Assemble the transformation matrix */
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, -source_x, -source_y);
|
||||
gimp_matrix3_scale (matrix, scale_x, scale_y);
|
||||
gimp_matrix3_rotate (matrix, angle);
|
||||
gimp_matrix3_translate (matrix, dest_x, dest_y);
|
||||
|
||||
/* Transform the buffer */
|
||||
new_tiles = gimp_transform_tool_do (gimage, drawable, float_tiles,
|
||||
interpolation, matrix, NULL, NULL);
|
||||
|
||||
/* Free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
||||
if (new_tiles)
|
||||
success = gimp_transform_tool_paste (gimage, drawable, new_tiles, new_layer);
|
||||
else
|
||||
success = FALSE;
|
||||
|
||||
/* Push the undo group end */
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub smudge {
|
||||
$blurb = <<'BLURB';
|
||||
Smudge image with varying pressure.
|
||||
|
@ -1288,9 +779,9 @@ sub ink {
|
|||
|
||||
@procs = qw(airbrush airbrush_default blend bucket_fill clone clone_default
|
||||
color_picker convolve convolve_default dodgeburn dodgeburn_default
|
||||
eraser eraser_default flip paintbrush paintbrush_default
|
||||
pencil perspective rotate scale shear smudge smudge_default
|
||||
transform_2d);
|
||||
eraser eraser_default paintbrush paintbrush_default
|
||||
pencil smudge smudge_default);
|
||||
|
||||
%exports = (app => [@procs], lib => [@procs]);
|
||||
|
||||
$desc = 'Tool procedures';
|
||||
|
|
|
@ -544,79 +544,6 @@ CODE
|
|||
);
|
||||
}
|
||||
|
||||
sub flip {
|
||||
$blurb = <<'BLURB';
|
||||
Flip the specified drawable about its center either vertically or
|
||||
horizontally.
|
||||
BLURB
|
||||
|
||||
$help = <<'HELP';
|
||||
This tool flips the specified drawable if no selection exists. If a selection
|
||||
exists, the portion of the drawable which lies under the selection is cut from
|
||||
the drawable and made into a floating selection which is then flipd by the
|
||||
specified amount. The return value is the ID of the flipped drawable. If there
|
||||
was no selection, this will be equal to the drawable ID supplied as input.
|
||||
Otherwise, this will be the newly created and flipped drawable. The flip type
|
||||
parameter indicates whether the flip will be applied horizontally or
|
||||
vertically.
|
||||
HELP
|
||||
|
||||
&std_pdb_misc;
|
||||
|
||||
@inargs = (
|
||||
&drawable_arg,
|
||||
{ name => 'flip_type', type => &std_orientation_enum,
|
||||
desc => 'Type of flip: %%desc%%' }
|
||||
);
|
||||
|
||||
@outargs = ( &drawable_out_arg('flipped') );
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("tools/gimpfliptool.h" "tools/gimptransformtool.h"
|
||||
"undo.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'gboolean new_layer' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
||||
/* Start a transform undo group */
|
||||
undo_push_group_start (gimage, TRANSFORM_CORE_UNDO);
|
||||
|
||||
/* Cut/Copy from the specified drawable */
|
||||
float_tiles = gimp_transform_tool_cut (gimage, drawable, &new_layer);
|
||||
|
||||
flip_type = flip_type == HORIZONTAL ? ORIENTATION_HORIZONTAL :
|
||||
flip_type == VERTICAL ? ORIENTATION_VERTICAL :
|
||||
ORIENTATION_UNKNOWN;
|
||||
|
||||
/* flip the buffer */
|
||||
switch (flip_type)
|
||||
{
|
||||
case ORIENTATION_HORIZONTAL:
|
||||
case ORIENTATION_VERTICAL:
|
||||
new_tiles = flip_tool_flip (gimage, drawable, float_tiles, -1, flip_type);
|
||||
break;
|
||||
default:
|
||||
new_tiles = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
/* free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
||||
if (new_tiles)
|
||||
success = gimp_transform_tool_paste (gimage, drawable, new_tiles, new_layer);
|
||||
else
|
||||
success = FALSE;
|
||||
|
||||
/* push the undo group end */
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub paintbrush {
|
||||
$blurb = <<'BLURB';
|
||||
Paint in the current brush with optional fade out parameter and pull colors
|
||||
|
@ -716,442 +643,6 @@ HELP
|
|||
);
|
||||
}
|
||||
|
||||
sub perspective {
|
||||
$blurb = <<'BLURB';
|
||||
Perform a possibly non-affine transformation on the specified drawable.
|
||||
BLURB
|
||||
|
||||
$help = <<'HELP';
|
||||
This tool performs a possibly non-affine transformation on the specified
|
||||
drawable by allowing the corners of the original bounding box to be arbitrarily
|
||||
remapped to any values. The specified drawable is remapped if no selection
|
||||
exists. However, if a selection exists, the portion of the drawable which lies
|
||||
under the selection is cut from the drawable and made into a floating selection
|
||||
which is then remapped as specified. The interpolation parameter can be set to
|
||||
TRUE to indicate that either linear or cubic interpolation should be used to
|
||||
smooth the resulting remapped drawable. The return value is the ID of the
|
||||
remapped drawable. If there was no selection, this will be equal to the
|
||||
drawable ID supplied as input. Otherwise, this will be the newly created and
|
||||
remapped drawable. The 4 coordinates specify the new locations of each corner
|
||||
of the original bounding box. By specifying these values, any affine
|
||||
transformation (rotation, scaling, translation) can be affected. Additionally,
|
||||
these values can be specified such that the resulting transformed drawable will
|
||||
appear to have been projected via a perspective transform.
|
||||
HELP
|
||||
|
||||
&std_pdb_misc;
|
||||
|
||||
@inargs = (
|
||||
&drawable_arg,
|
||||
{ name => 'interpolation', type => 'boolean',
|
||||
desc => 'Whether to use interpolation' }
|
||||
);
|
||||
|
||||
my $pos = 0;
|
||||
foreach $where (qw(upper-left upper-right lower-left lower-right)) {
|
||||
foreach (qw(x y)) {
|
||||
push @inargs,
|
||||
{ name => "$_$pos", type => 'float',
|
||||
desc => "The new $_ coordinate of $where corner of original
|
||||
bounding box",
|
||||
alias => "trans_info[\U$_\E$pos]", no_declare => 1 }
|
||||
}
|
||||
$pos++;
|
||||
}
|
||||
|
||||
@outargs = ( &drawable_out_arg('newly mapped') );
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("tools/gimpperspectivetool.h" "tools/gimptransformtool.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'gboolean new_layer', 'gint offset_x, offset_y',
|
||||
'gdouble cx, cy', 'gdouble scalex, scaley',
|
||||
'gdouble trans_info[8]', 'GimpMatrix3 m, matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
||||
/* Start a transform undo group */
|
||||
undo_push_group_start (gimage, TRANSFORM_CORE_UNDO);
|
||||
|
||||
/* Cut/Copy from the specified drawable */
|
||||
float_tiles = gimp_transform_tool_cut (gimage, drawable, &new_layer);
|
||||
|
||||
/* Determine the perspective transform that maps from
|
||||
* the unit cube to the trans_info coordinates
|
||||
*/
|
||||
gimp_perspective_tool_find_transform (trans_info, m);
|
||||
|
||||
tile_manager_get_offsets (float_tiles, &offset_x, &offset_y);
|
||||
cx = (gdouble) offset_x;
|
||||
cy = (gdouble) offset_y;
|
||||
scalex = 1.0;
|
||||
scaley = 1.0;
|
||||
if (tile_manager_width (float_tiles))
|
||||
scalex = 1.0 / tile_manager_width (float_tiles);
|
||||
if (tile_manager_height (float_tiles))
|
||||
scaley = 1.0 / tile_manager_height (float_tiles);
|
||||
|
||||
/* Assemble the transformation matrix */
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, -cx, -cy);
|
||||
gimp_matrix3_scale (matrix, scalex, scaley);
|
||||
gimp_matrix3_mult (m, matrix);
|
||||
|
||||
/* Perspective the buffer */
|
||||
new_tiles = gimp_perspective_tool_perspective (gimage, drawable, NULL,
|
||||
float_tiles, interpolation,
|
||||
matrix);
|
||||
|
||||
/* Free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
||||
if (new_tiles)
|
||||
success = gimp_transform_tool_paste (gimage, drawable, new_tiles, new_layer);
|
||||
else
|
||||
success = FALSE;
|
||||
|
||||
/* push the undo group end */
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub rotate {
|
||||
$blurb = <<'BLURB';
|
||||
Rotate the specified drawable about its center through the specified angle.
|
||||
BLURB
|
||||
|
||||
$help = <<'HELP';
|
||||
This tool rotates the specified drawable if no selection exists. If a selection
|
||||
exists, the portion of the drawable which lies under the selection is cut from
|
||||
the drawable and made into a floating selection which is then rotated by the
|
||||
specified amount. The interpolation parameter can be set to TRUE to indicate
|
||||
that either linear or cubic interpolation should be used to smooth the
|
||||
resulting rotated drawable. The return value is the ID of the rotated drawable.
|
||||
If there was no selection, this will be equal to the drawable ID supplied as
|
||||
input. Otherwise, this will be the newly created and rotated drawable.
|
||||
HELP
|
||||
|
||||
&std_pdb_misc;
|
||||
|
||||
@inargs = (
|
||||
&drawable_arg,
|
||||
{ name => 'interpolation', type => 'boolean',
|
||||
desc => 'Whether to use interpolation' },
|
||||
{ name => 'angle', type => 'float',
|
||||
desc => 'The angle of rotation (radians)' }
|
||||
);
|
||||
|
||||
@outargs = ( &drawable_out_arg('rotated') );
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("tools/gimprotatetool.h" "tools/gimptransformtool.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'gboolean new_layer', 'gint offset_x, offset_y',
|
||||
'gdouble cx, cy', 'GimpMatrix3 matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
||||
/* Start a transform undo group */
|
||||
undo_push_group_start (gimage, TRANSFORM_CORE_UNDO);
|
||||
|
||||
/* Cut/Copy from the specified drawable */
|
||||
float_tiles = gimp_transform_tool_cut (gimage, drawable, &new_layer);
|
||||
|
||||
tile_manager_get_offsets (float_tiles, &offset_x, &offset_y);
|
||||
cx = offset_x + tile_manager_width (float_tiles) / 2.0;
|
||||
cy = offset_y + tile_manager_height (float_tiles) / 2.0;
|
||||
|
||||
/* Assemble the transformation matrix */
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, -cx, -cy);
|
||||
gimp_matrix3_rotate (matrix, angle);
|
||||
gimp_matrix3_translate (matrix, +cx, +cy);
|
||||
|
||||
/* Rotate the buffer */
|
||||
new_tiles = gimp_rotate_tool_rotate (gimage, drawable, NULL, angle,
|
||||
float_tiles, interpolation, matrix);
|
||||
|
||||
/* Free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
||||
if (new_tiles)
|
||||
success = gimp_transform_tool_paste (gimage, drawable, new_tiles, new_layer);
|
||||
else
|
||||
success = FALSE;
|
||||
|
||||
/* Push the undo group end */
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub scale {
|
||||
$blurb = 'Scale the specified drawable.';
|
||||
|
||||
$help = <<'HELP';
|
||||
This tool scales the specified drawable if no selection exists. If a selection
|
||||
exists, the portion of the drawable which lies under the selection is cut from
|
||||
the drawable and made into a floating selection which is then scaled by the
|
||||
specified amount. The interpolation parameter can be set to TRUE to indicate
|
||||
that either linear or cubic interpolation should be used to smooth the
|
||||
resulting scaled drawable. The return value is the ID of the scaled drawable.
|
||||
If there was no selection, this will be equal to the drawable ID supplied as
|
||||
input. Otherwise, this will be the newly created and scaled drawable.
|
||||
HELP
|
||||
|
||||
&std_pdb_misc;
|
||||
|
||||
@inargs = (
|
||||
&drawable_arg,
|
||||
{ name => 'interpolation', type => 'boolean',
|
||||
desc => 'Whether to use interpolation' }
|
||||
);
|
||||
|
||||
my $pos = 0;
|
||||
foreach $where (qw(upper-left lower-right)) {
|
||||
foreach (qw(x y)) {
|
||||
push @inargs,
|
||||
{ name => "$_$pos", type => 'float',
|
||||
desc => "The new $_ coordinate of $where corner of newly
|
||||
scaled region",
|
||||
alias => "trans_info[\U$_\E$pos]", no_declare => 1 }
|
||||
}
|
||||
$pos++;
|
||||
}
|
||||
|
||||
@outargs = ( &drawable_out_arg('scaled') );
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("tools/gimpscaletool.h" "tools/gimptransformtool.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'gboolean new_layer', 'gint offset_x, offset_y',
|
||||
'gdouble scalex, scaley', 'gdouble trans_info[4]',
|
||||
'GimpMatrix3 matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
if (trans_info[X0] < trans_info[X1] &&
|
||||
trans_info[Y0] < trans_info[X1])
|
||||
{
|
||||
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
||||
/* Start a transform undo group */
|
||||
undo_push_group_start (gimage, TRANSFORM_CORE_UNDO);
|
||||
|
||||
/* Cut/Copy from the specified drawable */
|
||||
float_tiles = gimp_transform_tool_cut (gimage, drawable, &new_layer);
|
||||
|
||||
scalex = scaley = 1.0;
|
||||
if (tile_manager_width (float_tiles))
|
||||
scalex = (trans_info[X1] - trans_info[X0]) /
|
||||
(gdouble) tile_manager_width (float_tiles);
|
||||
if (tile_manager_height (float_tiles))
|
||||
scaley = (trans_info[Y1] - trans_info[Y0]) /
|
||||
(gdouble) tile_manager_height (float_tiles);
|
||||
|
||||
tile_manager_get_offsets (float_tiles, &offset_x, &offset_y);
|
||||
|
||||
/* Assemble the transformation matrix */
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, offset_x, offset_y);
|
||||
gimp_matrix3_scale (matrix, scalex, scaley);
|
||||
gimp_matrix3_translate (matrix, trans_info[X0], trans_info[Y0]);
|
||||
|
||||
/* Scale the buffer */
|
||||
new_tiles = gimp_scale_tool_scale (gimage, drawable, NULL, trans_info,
|
||||
float_tiles, interpolation, matrix);
|
||||
|
||||
/* Free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
||||
if (new_tiles)
|
||||
success = gimp_transform_tool_paste (gimage, drawable, new_tiles, new_layer);
|
||||
else
|
||||
success = FALSE;
|
||||
|
||||
/* push the undo group end */
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub shear {
|
||||
$blurb = <<'BLURB';
|
||||
Shear the specified drawable about its center by the specified magnitude.
|
||||
BLURB
|
||||
|
||||
$help = <<'HELP';
|
||||
This tool shears the specified drawable if no selection exists. If a selection
|
||||
exists, the portion of the drawable which lies under the selection is cut from
|
||||
the drawable and made into a floating selection which is then sheard by the
|
||||
specified amount. The interpolation parameter can be set to TRUE to indicate
|
||||
that either linear or cubic interpolation should be used to smooth the
|
||||
resulting sheared drawable. The return value is the ID of the sheard drawable.
|
||||
If there was no selection, this will be equal to the drawable ID supplied as
|
||||
input. Otherwise, this will be the newly created and sheard drawable. The shear
|
||||
type parameter indicates whether the shear will be applied horizontally or
|
||||
vertically. The magnitude can be either positive or negative and indicates the
|
||||
extent (in pixels) to shear by.
|
||||
HELP
|
||||
|
||||
&std_pdb_misc;
|
||||
|
||||
@inargs = (
|
||||
&drawable_arg,
|
||||
{ name => 'interpolation', type => 'boolean',
|
||||
desc => 'Whether to use interpolation' },
|
||||
{ name => 'shear_type', type => &std_orientation_enum,
|
||||
desc => 'Type of shear: %%desc%%' },
|
||||
{ name => 'magnitude', type => 'float',
|
||||
desc => 'The magnitude of the shear' }
|
||||
);
|
||||
|
||||
@outargs = ( &drawable_out_arg('sheared') );
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("tools/gimpsheartool.h" "tools/gimptransformtool.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'gboolean new_layer', 'gdouble cx, cy',
|
||||
'gint offset_x, offset_y', 'GimpMatrix3 matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
||||
/* Start a transform undo group */
|
||||
undo_push_group_start (gimage, TRANSFORM_CORE_UNDO);
|
||||
|
||||
/* Cut/Copy from the specified drawable */
|
||||
float_tiles = gimp_transform_tool_cut (gimage, drawable, &new_layer);
|
||||
|
||||
tile_manager_get_offsets (float_tiles, &offset_x, &offset_y);
|
||||
|
||||
cx = offset_x + tile_manager_width (float_tiles) / 2.0;
|
||||
cy = offset_y + tile_manager_height (float_tiles) / 2.0;
|
||||
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, -cx, -cy);
|
||||
/* Shear matrix */
|
||||
shear_type = shear_type == HORIZONTAL ? ORIENTATION_HORIZONTAL :
|
||||
shear_type == VERTICAL ? ORIENTATION_VERTICAL :
|
||||
ORIENTATION_UNKNOWN;
|
||||
|
||||
if (shear_type == ORIENTATION_HORIZONTAL)
|
||||
gimp_matrix3_xshear (matrix, magnitude / tile_manager_height (float_tiles));
|
||||
else if (shear_type == ORIENTATION_VERTICAL)
|
||||
gimp_matrix3_yshear (matrix, magnitude / tile_manager_width (float_tiles));
|
||||
|
||||
gimp_matrix3_translate (matrix, +cx, +cy);
|
||||
|
||||
/* Shear the buffer */
|
||||
new_tiles = gimp_shear_tool_shear (gimage, drawable, NULL, float_tiles,
|
||||
interpolation, matrix);
|
||||
|
||||
/* Free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
||||
if (new_tiles)
|
||||
success = gimp_transform_tool_paste (gimage, drawable, new_tiles, new_layer);
|
||||
else
|
||||
success = FALSE;
|
||||
|
||||
/* Push the undo group end */
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub transform_2d {
|
||||
$blurb = <<'BLURB';
|
||||
Transform the specified drawable in 2d.
|
||||
BLURB
|
||||
|
||||
$help = <<'HELP';
|
||||
This tool transforms the specified drawable if no selection exists. If a
|
||||
selection exists, the portion of the drawable which lies under the
|
||||
selection is cut from the drawable and made into a floating selection which
|
||||
is then transformed. The interpolation parameter can be set to TRUE to
|
||||
indicate that either linear or cubic interpolation should be used to smooth
|
||||
the resulting drawable. The transformation is done by scaling the image by
|
||||
the x and y scale factors about the point (source_x, source_y), then rotating
|
||||
around the same point, then translating that point to the new position
|
||||
(dest_x, dest_y). The return value is the ID of the rotated drawable. If
|
||||
there was no selection, this will be equal to the drawable ID supplied as
|
||||
input. Otherwise, this will be the newly created and transformed drawable.
|
||||
HELP
|
||||
|
||||
&std_pdb_misc;
|
||||
|
||||
@inargs = (
|
||||
&drawable_arg,
|
||||
{ name => 'interpolation', type => 'boolean',
|
||||
desc => 'Whether to use interpolation' },
|
||||
{ name => 'source_x', type => 'float',
|
||||
desc => 'X coordinate of the transformation center' },
|
||||
{ name => 'source_y', type => 'float',
|
||||
desc => 'Y coordinate of the transformation center' },
|
||||
{ name => 'scale_x', type => 'float',
|
||||
desc => 'Amount to scale in x direction' },
|
||||
{ name => 'scale_y', type => 'float',
|
||||
desc => 'Amount to scale in y direction' },
|
||||
{ name => 'angle', type => 'float',
|
||||
desc => 'The angle of rotation (radians)' },
|
||||
{ name => 'dest_x', type => 'float',
|
||||
desc => 'X coordinate of where the centre goes' },
|
||||
{ name => 'dest_y', type => 'float',
|
||||
desc => 'Y coordinate of where the centre goes' }
|
||||
);
|
||||
|
||||
@outargs = ( &drawable_out_arg('transformed') );
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("tools/gimptransformtool.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'gboolean new_layer', 'GimpMatrix3 matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
||||
/* Start a transform undo group */
|
||||
undo_push_group_start (gimage, TRANSFORM_CORE_UNDO);
|
||||
|
||||
/* Cut/Copy from the specified drawable */
|
||||
float_tiles = gimp_transform_tool_cut (gimage, drawable, &new_layer);
|
||||
|
||||
/* Assemble the transformation matrix */
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, -source_x, -source_y);
|
||||
gimp_matrix3_scale (matrix, scale_x, scale_y);
|
||||
gimp_matrix3_rotate (matrix, angle);
|
||||
gimp_matrix3_translate (matrix, dest_x, dest_y);
|
||||
|
||||
/* Transform the buffer */
|
||||
new_tiles = gimp_transform_tool_do (gimage, drawable, float_tiles,
|
||||
interpolation, matrix, NULL, NULL);
|
||||
|
||||
/* Free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
||||
if (new_tiles)
|
||||
success = gimp_transform_tool_paste (gimage, drawable, new_tiles, new_layer);
|
||||
else
|
||||
success = FALSE;
|
||||
|
||||
/* Push the undo group end */
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub smudge {
|
||||
$blurb = <<'BLURB';
|
||||
Smudge image with varying pressure.
|
||||
|
@ -1288,9 +779,9 @@ sub ink {
|
|||
|
||||
@procs = qw(airbrush airbrush_default blend bucket_fill clone clone_default
|
||||
color_picker convolve convolve_default dodgeburn dodgeburn_default
|
||||
eraser eraser_default flip paintbrush paintbrush_default
|
||||
pencil perspective rotate scale shear smudge smudge_default
|
||||
transform_2d);
|
||||
eraser eraser_default paintbrush paintbrush_default
|
||||
pencil smudge smudge_default);
|
||||
|
||||
%exports = (app => [@procs], lib => [@procs]);
|
||||
|
||||
$desc = 'Tool procedures';
|
||||
|
|
|
@ -544,79 +544,6 @@ CODE
|
|||
);
|
||||
}
|
||||
|
||||
sub flip {
|
||||
$blurb = <<'BLURB';
|
||||
Flip the specified drawable about its center either vertically or
|
||||
horizontally.
|
||||
BLURB
|
||||
|
||||
$help = <<'HELP';
|
||||
This tool flips the specified drawable if no selection exists. If a selection
|
||||
exists, the portion of the drawable which lies under the selection is cut from
|
||||
the drawable and made into a floating selection which is then flipd by the
|
||||
specified amount. The return value is the ID of the flipped drawable. If there
|
||||
was no selection, this will be equal to the drawable ID supplied as input.
|
||||
Otherwise, this will be the newly created and flipped drawable. The flip type
|
||||
parameter indicates whether the flip will be applied horizontally or
|
||||
vertically.
|
||||
HELP
|
||||
|
||||
&std_pdb_misc;
|
||||
|
||||
@inargs = (
|
||||
&drawable_arg,
|
||||
{ name => 'flip_type', type => &std_orientation_enum,
|
||||
desc => 'Type of flip: %%desc%%' }
|
||||
);
|
||||
|
||||
@outargs = ( &drawable_out_arg('flipped') );
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("tools/gimpfliptool.h" "tools/gimptransformtool.h"
|
||||
"undo.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'gboolean new_layer' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
||||
/* Start a transform undo group */
|
||||
undo_push_group_start (gimage, TRANSFORM_CORE_UNDO);
|
||||
|
||||
/* Cut/Copy from the specified drawable */
|
||||
float_tiles = gimp_transform_tool_cut (gimage, drawable, &new_layer);
|
||||
|
||||
flip_type = flip_type == HORIZONTAL ? ORIENTATION_HORIZONTAL :
|
||||
flip_type == VERTICAL ? ORIENTATION_VERTICAL :
|
||||
ORIENTATION_UNKNOWN;
|
||||
|
||||
/* flip the buffer */
|
||||
switch (flip_type)
|
||||
{
|
||||
case ORIENTATION_HORIZONTAL:
|
||||
case ORIENTATION_VERTICAL:
|
||||
new_tiles = flip_tool_flip (gimage, drawable, float_tiles, -1, flip_type);
|
||||
break;
|
||||
default:
|
||||
new_tiles = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
/* free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
||||
if (new_tiles)
|
||||
success = gimp_transform_tool_paste (gimage, drawable, new_tiles, new_layer);
|
||||
else
|
||||
success = FALSE;
|
||||
|
||||
/* push the undo group end */
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub paintbrush {
|
||||
$blurb = <<'BLURB';
|
||||
Paint in the current brush with optional fade out parameter and pull colors
|
||||
|
@ -716,442 +643,6 @@ HELP
|
|||
);
|
||||
}
|
||||
|
||||
sub perspective {
|
||||
$blurb = <<'BLURB';
|
||||
Perform a possibly non-affine transformation on the specified drawable.
|
||||
BLURB
|
||||
|
||||
$help = <<'HELP';
|
||||
This tool performs a possibly non-affine transformation on the specified
|
||||
drawable by allowing the corners of the original bounding box to be arbitrarily
|
||||
remapped to any values. The specified drawable is remapped if no selection
|
||||
exists. However, if a selection exists, the portion of the drawable which lies
|
||||
under the selection is cut from the drawable and made into a floating selection
|
||||
which is then remapped as specified. The interpolation parameter can be set to
|
||||
TRUE to indicate that either linear or cubic interpolation should be used to
|
||||
smooth the resulting remapped drawable. The return value is the ID of the
|
||||
remapped drawable. If there was no selection, this will be equal to the
|
||||
drawable ID supplied as input. Otherwise, this will be the newly created and
|
||||
remapped drawable. The 4 coordinates specify the new locations of each corner
|
||||
of the original bounding box. By specifying these values, any affine
|
||||
transformation (rotation, scaling, translation) can be affected. Additionally,
|
||||
these values can be specified such that the resulting transformed drawable will
|
||||
appear to have been projected via a perspective transform.
|
||||
HELP
|
||||
|
||||
&std_pdb_misc;
|
||||
|
||||
@inargs = (
|
||||
&drawable_arg,
|
||||
{ name => 'interpolation', type => 'boolean',
|
||||
desc => 'Whether to use interpolation' }
|
||||
);
|
||||
|
||||
my $pos = 0;
|
||||
foreach $where (qw(upper-left upper-right lower-left lower-right)) {
|
||||
foreach (qw(x y)) {
|
||||
push @inargs,
|
||||
{ name => "$_$pos", type => 'float',
|
||||
desc => "The new $_ coordinate of $where corner of original
|
||||
bounding box",
|
||||
alias => "trans_info[\U$_\E$pos]", no_declare => 1 }
|
||||
}
|
||||
$pos++;
|
||||
}
|
||||
|
||||
@outargs = ( &drawable_out_arg('newly mapped') );
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("tools/gimpperspectivetool.h" "tools/gimptransformtool.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'gboolean new_layer', 'gint offset_x, offset_y',
|
||||
'gdouble cx, cy', 'gdouble scalex, scaley',
|
||||
'gdouble trans_info[8]', 'GimpMatrix3 m, matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
||||
/* Start a transform undo group */
|
||||
undo_push_group_start (gimage, TRANSFORM_CORE_UNDO);
|
||||
|
||||
/* Cut/Copy from the specified drawable */
|
||||
float_tiles = gimp_transform_tool_cut (gimage, drawable, &new_layer);
|
||||
|
||||
/* Determine the perspective transform that maps from
|
||||
* the unit cube to the trans_info coordinates
|
||||
*/
|
||||
gimp_perspective_tool_find_transform (trans_info, m);
|
||||
|
||||
tile_manager_get_offsets (float_tiles, &offset_x, &offset_y);
|
||||
cx = (gdouble) offset_x;
|
||||
cy = (gdouble) offset_y;
|
||||
scalex = 1.0;
|
||||
scaley = 1.0;
|
||||
if (tile_manager_width (float_tiles))
|
||||
scalex = 1.0 / tile_manager_width (float_tiles);
|
||||
if (tile_manager_height (float_tiles))
|
||||
scaley = 1.0 / tile_manager_height (float_tiles);
|
||||
|
||||
/* Assemble the transformation matrix */
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, -cx, -cy);
|
||||
gimp_matrix3_scale (matrix, scalex, scaley);
|
||||
gimp_matrix3_mult (m, matrix);
|
||||
|
||||
/* Perspective the buffer */
|
||||
new_tiles = gimp_perspective_tool_perspective (gimage, drawable, NULL,
|
||||
float_tiles, interpolation,
|
||||
matrix);
|
||||
|
||||
/* Free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
||||
if (new_tiles)
|
||||
success = gimp_transform_tool_paste (gimage, drawable, new_tiles, new_layer);
|
||||
else
|
||||
success = FALSE;
|
||||
|
||||
/* push the undo group end */
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub rotate {
|
||||
$blurb = <<'BLURB';
|
||||
Rotate the specified drawable about its center through the specified angle.
|
||||
BLURB
|
||||
|
||||
$help = <<'HELP';
|
||||
This tool rotates the specified drawable if no selection exists. If a selection
|
||||
exists, the portion of the drawable which lies under the selection is cut from
|
||||
the drawable and made into a floating selection which is then rotated by the
|
||||
specified amount. The interpolation parameter can be set to TRUE to indicate
|
||||
that either linear or cubic interpolation should be used to smooth the
|
||||
resulting rotated drawable. The return value is the ID of the rotated drawable.
|
||||
If there was no selection, this will be equal to the drawable ID supplied as
|
||||
input. Otherwise, this will be the newly created and rotated drawable.
|
||||
HELP
|
||||
|
||||
&std_pdb_misc;
|
||||
|
||||
@inargs = (
|
||||
&drawable_arg,
|
||||
{ name => 'interpolation', type => 'boolean',
|
||||
desc => 'Whether to use interpolation' },
|
||||
{ name => 'angle', type => 'float',
|
||||
desc => 'The angle of rotation (radians)' }
|
||||
);
|
||||
|
||||
@outargs = ( &drawable_out_arg('rotated') );
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("tools/gimprotatetool.h" "tools/gimptransformtool.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'gboolean new_layer', 'gint offset_x, offset_y',
|
||||
'gdouble cx, cy', 'GimpMatrix3 matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
||||
/* Start a transform undo group */
|
||||
undo_push_group_start (gimage, TRANSFORM_CORE_UNDO);
|
||||
|
||||
/* Cut/Copy from the specified drawable */
|
||||
float_tiles = gimp_transform_tool_cut (gimage, drawable, &new_layer);
|
||||
|
||||
tile_manager_get_offsets (float_tiles, &offset_x, &offset_y);
|
||||
cx = offset_x + tile_manager_width (float_tiles) / 2.0;
|
||||
cy = offset_y + tile_manager_height (float_tiles) / 2.0;
|
||||
|
||||
/* Assemble the transformation matrix */
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, -cx, -cy);
|
||||
gimp_matrix3_rotate (matrix, angle);
|
||||
gimp_matrix3_translate (matrix, +cx, +cy);
|
||||
|
||||
/* Rotate the buffer */
|
||||
new_tiles = gimp_rotate_tool_rotate (gimage, drawable, NULL, angle,
|
||||
float_tiles, interpolation, matrix);
|
||||
|
||||
/* Free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
||||
if (new_tiles)
|
||||
success = gimp_transform_tool_paste (gimage, drawable, new_tiles, new_layer);
|
||||
else
|
||||
success = FALSE;
|
||||
|
||||
/* Push the undo group end */
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub scale {
|
||||
$blurb = 'Scale the specified drawable.';
|
||||
|
||||
$help = <<'HELP';
|
||||
This tool scales the specified drawable if no selection exists. If a selection
|
||||
exists, the portion of the drawable which lies under the selection is cut from
|
||||
the drawable and made into a floating selection which is then scaled by the
|
||||
specified amount. The interpolation parameter can be set to TRUE to indicate
|
||||
that either linear or cubic interpolation should be used to smooth the
|
||||
resulting scaled drawable. The return value is the ID of the scaled drawable.
|
||||
If there was no selection, this will be equal to the drawable ID supplied as
|
||||
input. Otherwise, this will be the newly created and scaled drawable.
|
||||
HELP
|
||||
|
||||
&std_pdb_misc;
|
||||
|
||||
@inargs = (
|
||||
&drawable_arg,
|
||||
{ name => 'interpolation', type => 'boolean',
|
||||
desc => 'Whether to use interpolation' }
|
||||
);
|
||||
|
||||
my $pos = 0;
|
||||
foreach $where (qw(upper-left lower-right)) {
|
||||
foreach (qw(x y)) {
|
||||
push @inargs,
|
||||
{ name => "$_$pos", type => 'float',
|
||||
desc => "The new $_ coordinate of $where corner of newly
|
||||
scaled region",
|
||||
alias => "trans_info[\U$_\E$pos]", no_declare => 1 }
|
||||
}
|
||||
$pos++;
|
||||
}
|
||||
|
||||
@outargs = ( &drawable_out_arg('scaled') );
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("tools/gimpscaletool.h" "tools/gimptransformtool.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'gboolean new_layer', 'gint offset_x, offset_y',
|
||||
'gdouble scalex, scaley', 'gdouble trans_info[4]',
|
||||
'GimpMatrix3 matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
if (trans_info[X0] < trans_info[X1] &&
|
||||
trans_info[Y0] < trans_info[X1])
|
||||
{
|
||||
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
||||
/* Start a transform undo group */
|
||||
undo_push_group_start (gimage, TRANSFORM_CORE_UNDO);
|
||||
|
||||
/* Cut/Copy from the specified drawable */
|
||||
float_tiles = gimp_transform_tool_cut (gimage, drawable, &new_layer);
|
||||
|
||||
scalex = scaley = 1.0;
|
||||
if (tile_manager_width (float_tiles))
|
||||
scalex = (trans_info[X1] - trans_info[X0]) /
|
||||
(gdouble) tile_manager_width (float_tiles);
|
||||
if (tile_manager_height (float_tiles))
|
||||
scaley = (trans_info[Y1] - trans_info[Y0]) /
|
||||
(gdouble) tile_manager_height (float_tiles);
|
||||
|
||||
tile_manager_get_offsets (float_tiles, &offset_x, &offset_y);
|
||||
|
||||
/* Assemble the transformation matrix */
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, offset_x, offset_y);
|
||||
gimp_matrix3_scale (matrix, scalex, scaley);
|
||||
gimp_matrix3_translate (matrix, trans_info[X0], trans_info[Y0]);
|
||||
|
||||
/* Scale the buffer */
|
||||
new_tiles = gimp_scale_tool_scale (gimage, drawable, NULL, trans_info,
|
||||
float_tiles, interpolation, matrix);
|
||||
|
||||
/* Free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
||||
if (new_tiles)
|
||||
success = gimp_transform_tool_paste (gimage, drawable, new_tiles, new_layer);
|
||||
else
|
||||
success = FALSE;
|
||||
|
||||
/* push the undo group end */
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub shear {
|
||||
$blurb = <<'BLURB';
|
||||
Shear the specified drawable about its center by the specified magnitude.
|
||||
BLURB
|
||||
|
||||
$help = <<'HELP';
|
||||
This tool shears the specified drawable if no selection exists. If a selection
|
||||
exists, the portion of the drawable which lies under the selection is cut from
|
||||
the drawable and made into a floating selection which is then sheard by the
|
||||
specified amount. The interpolation parameter can be set to TRUE to indicate
|
||||
that either linear or cubic interpolation should be used to smooth the
|
||||
resulting sheared drawable. The return value is the ID of the sheard drawable.
|
||||
If there was no selection, this will be equal to the drawable ID supplied as
|
||||
input. Otherwise, this will be the newly created and sheard drawable. The shear
|
||||
type parameter indicates whether the shear will be applied horizontally or
|
||||
vertically. The magnitude can be either positive or negative and indicates the
|
||||
extent (in pixels) to shear by.
|
||||
HELP
|
||||
|
||||
&std_pdb_misc;
|
||||
|
||||
@inargs = (
|
||||
&drawable_arg,
|
||||
{ name => 'interpolation', type => 'boolean',
|
||||
desc => 'Whether to use interpolation' },
|
||||
{ name => 'shear_type', type => &std_orientation_enum,
|
||||
desc => 'Type of shear: %%desc%%' },
|
||||
{ name => 'magnitude', type => 'float',
|
||||
desc => 'The magnitude of the shear' }
|
||||
);
|
||||
|
||||
@outargs = ( &drawable_out_arg('sheared') );
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("tools/gimpsheartool.h" "tools/gimptransformtool.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'gboolean new_layer', 'gdouble cx, cy',
|
||||
'gint offset_x, offset_y', 'GimpMatrix3 matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
||||
/* Start a transform undo group */
|
||||
undo_push_group_start (gimage, TRANSFORM_CORE_UNDO);
|
||||
|
||||
/* Cut/Copy from the specified drawable */
|
||||
float_tiles = gimp_transform_tool_cut (gimage, drawable, &new_layer);
|
||||
|
||||
tile_manager_get_offsets (float_tiles, &offset_x, &offset_y);
|
||||
|
||||
cx = offset_x + tile_manager_width (float_tiles) / 2.0;
|
||||
cy = offset_y + tile_manager_height (float_tiles) / 2.0;
|
||||
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, -cx, -cy);
|
||||
/* Shear matrix */
|
||||
shear_type = shear_type == HORIZONTAL ? ORIENTATION_HORIZONTAL :
|
||||
shear_type == VERTICAL ? ORIENTATION_VERTICAL :
|
||||
ORIENTATION_UNKNOWN;
|
||||
|
||||
if (shear_type == ORIENTATION_HORIZONTAL)
|
||||
gimp_matrix3_xshear (matrix, magnitude / tile_manager_height (float_tiles));
|
||||
else if (shear_type == ORIENTATION_VERTICAL)
|
||||
gimp_matrix3_yshear (matrix, magnitude / tile_manager_width (float_tiles));
|
||||
|
||||
gimp_matrix3_translate (matrix, +cx, +cy);
|
||||
|
||||
/* Shear the buffer */
|
||||
new_tiles = gimp_shear_tool_shear (gimage, drawable, NULL, float_tiles,
|
||||
interpolation, matrix);
|
||||
|
||||
/* Free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
||||
if (new_tiles)
|
||||
success = gimp_transform_tool_paste (gimage, drawable, new_tiles, new_layer);
|
||||
else
|
||||
success = FALSE;
|
||||
|
||||
/* Push the undo group end */
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub transform_2d {
|
||||
$blurb = <<'BLURB';
|
||||
Transform the specified drawable in 2d.
|
||||
BLURB
|
||||
|
||||
$help = <<'HELP';
|
||||
This tool transforms the specified drawable if no selection exists. If a
|
||||
selection exists, the portion of the drawable which lies under the
|
||||
selection is cut from the drawable and made into a floating selection which
|
||||
is then transformed. The interpolation parameter can be set to TRUE to
|
||||
indicate that either linear or cubic interpolation should be used to smooth
|
||||
the resulting drawable. The transformation is done by scaling the image by
|
||||
the x and y scale factors about the point (source_x, source_y), then rotating
|
||||
around the same point, then translating that point to the new position
|
||||
(dest_x, dest_y). The return value is the ID of the rotated drawable. If
|
||||
there was no selection, this will be equal to the drawable ID supplied as
|
||||
input. Otherwise, this will be the newly created and transformed drawable.
|
||||
HELP
|
||||
|
||||
&std_pdb_misc;
|
||||
|
||||
@inargs = (
|
||||
&drawable_arg,
|
||||
{ name => 'interpolation', type => 'boolean',
|
||||
desc => 'Whether to use interpolation' },
|
||||
{ name => 'source_x', type => 'float',
|
||||
desc => 'X coordinate of the transformation center' },
|
||||
{ name => 'source_y', type => 'float',
|
||||
desc => 'Y coordinate of the transformation center' },
|
||||
{ name => 'scale_x', type => 'float',
|
||||
desc => 'Amount to scale in x direction' },
|
||||
{ name => 'scale_y', type => 'float',
|
||||
desc => 'Amount to scale in y direction' },
|
||||
{ name => 'angle', type => 'float',
|
||||
desc => 'The angle of rotation (radians)' },
|
||||
{ name => 'dest_x', type => 'float',
|
||||
desc => 'X coordinate of where the centre goes' },
|
||||
{ name => 'dest_y', type => 'float',
|
||||
desc => 'Y coordinate of where the centre goes' }
|
||||
);
|
||||
|
||||
@outargs = ( &drawable_out_arg('transformed') );
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("tools/gimptransformtool.h") ],
|
||||
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
|
||||
'gboolean new_layer', 'GimpMatrix3 matrix' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
gimage = gimp_drawable_gimage (GIMP_DRAWABLE (drawable));
|
||||
|
||||
/* Start a transform undo group */
|
||||
undo_push_group_start (gimage, TRANSFORM_CORE_UNDO);
|
||||
|
||||
/* Cut/Copy from the specified drawable */
|
||||
float_tiles = gimp_transform_tool_cut (gimage, drawable, &new_layer);
|
||||
|
||||
/* Assemble the transformation matrix */
|
||||
gimp_matrix3_identity (matrix);
|
||||
gimp_matrix3_translate (matrix, -source_x, -source_y);
|
||||
gimp_matrix3_scale (matrix, scale_x, scale_y);
|
||||
gimp_matrix3_rotate (matrix, angle);
|
||||
gimp_matrix3_translate (matrix, dest_x, dest_y);
|
||||
|
||||
/* Transform the buffer */
|
||||
new_tiles = gimp_transform_tool_do (gimage, drawable, float_tiles,
|
||||
interpolation, matrix, NULL, NULL);
|
||||
|
||||
/* Free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
||||
if (new_tiles)
|
||||
success = gimp_transform_tool_paste (gimage, drawable, new_tiles, new_layer);
|
||||
else
|
||||
success = FALSE;
|
||||
|
||||
/* Push the undo group end */
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub smudge {
|
||||
$blurb = <<'BLURB';
|
||||
Smudge image with varying pressure.
|
||||
|
@ -1288,9 +779,9 @@ sub ink {
|
|||
|
||||
@procs = qw(airbrush airbrush_default blend bucket_fill clone clone_default
|
||||
color_picker convolve convolve_default dodgeburn dodgeburn_default
|
||||
eraser eraser_default flip paintbrush paintbrush_default
|
||||
pencil perspective rotate scale shear smudge smudge_default
|
||||
transform_2d);
|
||||
eraser eraser_default paintbrush paintbrush_default
|
||||
pencil smudge smudge_default);
|
||||
|
||||
%exports = (app => [@procs], lib => [@procs]);
|
||||
|
||||
$desc = 'Tool procedures';
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue