Commit 2e21005a authored by Michael Natterer's avatar Michael Natterer
Browse files

oops, forgot this dorectory...

parent 57044c2f
......@@ -39,6 +39,7 @@ libapppdb_a_SOURCES = @STRIP_BEGIN@ \
selection_tools_cmds.c \
text_tool_cmds.c \
tools_cmds.c \
transform_tools_cmds.c \
undo_cmds.c \
unit_cmds.c \
@STRIP_END@
......
......@@ -60,6 +60,7 @@ void register_selection_procs (Gimp *gimp);
void register_selection_tools_procs (Gimp *gimp);
void register_text_tool_procs (Gimp *gimp);
void register_tools_procs (Gimp *gimp);
void register_transform_tools_procs (Gimp *gimp);
void register_undo_procs (Gimp *gimp);
void register_unit_procs (Gimp *gimp);
......@@ -162,6 +163,9 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Tool procedures"), 0.885);
register_tools_procs (gimp);
(* status_callback) (NULL, _("Tool procedures"), 0.939);
register_transform_tools_procs (gimp);
(* status_callback) (NULL, _("Undo"), 0.958);
register_undo_procs (gimp);
......
......@@ -43,16 +43,9 @@
#include "tools/gimpconvolvetool.h"
#include "tools/gimpdodgeburntool.h"
#include "tools/gimperasertool.h"
#include "tools/gimpfliptool.h"
#include "tools/gimppaintbrushtool.h"
#include "tools/gimppenciltool.h"
#include "tools/gimpperspectivetool.h"
#include "tools/gimprotatetool.h"
#include "tools/gimpscaletool.h"
#include "tools/gimpsheartool.h"
#include "tools/gimpsmudgetool.h"
#include "tools/gimptransformtool.h"
#include "undo.h"
#include "libgimpcolor/gimpcolor.h"
#include "libgimpmath/gimpmath.h"
......@@ -70,17 +63,11 @@ static ProcRecord dodgeburn_proc;
static ProcRecord dodgeburn_default_proc;
static ProcRecord eraser_proc;
static ProcRecord eraser_default_proc;
static ProcRecord flip_proc;
static ProcRecord paintbrush_proc;
static ProcRecord paintbrush_default_proc;
static ProcRecord pencil_proc;
static ProcRecord perspective_proc;
static ProcRecord rotate_proc;
static ProcRecord scale_proc;
static ProcRecord shear_proc;
static ProcRecord smudge_proc;
static ProcRecord smudge_default_proc;
static ProcRecord transform_2d_proc;
void
register_tools_procs (Gimp *gimp)
......@@ -98,17 +85,11 @@ register_tools_procs (Gimp *gimp)
procedural_db_register (gimp, &dodgeburn_default_proc);
procedural_db_register (gimp, &eraser_proc);
procedural_db_register (gimp, &eraser_default_proc);
procedural_db_register (gimp, &flip_proc);
procedural_db_register (gimp, &paintbrush_proc);
procedural_db_register (gimp, &paintbrush_default_proc);
procedural_db_register (gimp, &pencil_proc);
procedural_db_register (gimp, &perspective_proc);
procedural_db_register (gimp, &rotate_proc);
procedural_db_register (gimp, &scale_proc);
procedural_db_register (gimp, &shear_proc);
procedural_db_register (gimp, &smudge_proc);
procedural_db_register (gimp, &smudge_default_proc);
procedural_db_register (gimp, &transform_2d_proc);
}
static Argument *
......@@ -1278,111 +1259,6 @@ static ProcRecord eraser_default_proc =
{ { eraser_default_invoker } }
};
static Argument *
flip_invoker (Gimp *gimp,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
GimpDrawable *drawable;
gint32 flip_type;
GimpImage *gimage;
TileManager *float_tiles, *new_tiles;
gboolean new_layer;
drawable = gimp_drawable_get_by_ID (gimp, args[0].value.pdb_int);
if (drawable == NULL)
success = FALSE;
flip_type = args[1].value.pdb_int;
if (flip_type < HORIZONTAL || flip_type > VERTICAL)
success = FALSE;
if (success)
{
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);
}
return_args = procedural_db_return_args (&flip_proc, success);
if (success)
return_args[1].value.pdb_int = gimp_drawable_get_ID (GIMP_DRAWABLE (drawable));
return return_args;
}
static ProcArg flip_inargs[] =
{
{
GIMP_PDB_DRAWABLE,
"drawable",
"The affected drawable"
},
{
GIMP_PDB_INT32,
"flip_type",
"Type of flip: HORIZONTAL (0) or VERTICAL (1)"
}
};
static ProcArg flip_outargs[] =
{
{
GIMP_PDB_DRAWABLE,
"drawable",
"The flipped drawable"
}
};
static ProcRecord flip_proc =
{
"gimp_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.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
GIMP_INTERNAL,
2,
flip_inargs,
1,
flip_outargs,
{ { flip_invoker } }
};
static Argument *
paintbrush_invoker (Gimp *gimp,
Argument *args)
......@@ -1600,569 +1476,6 @@ static ProcRecord pencil_proc =
{ { pencil_invoker } }
};
static Argument *
perspective_invoker (Gimp *gimp,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
GimpDrawable *drawable;
gboolean interpolation;
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;
drawable = gimp_drawable_get_by_ID (gimp, args[0].value.pdb_int);
if (drawable == NULL)
success = FALSE;
interpolation = args[1].value.pdb_int ? TRUE : FALSE;
trans_info[X0] = args[2].value.pdb_float;
trans_info[Y0] = args[3].value.pdb_float;
trans_info[X1] = args[4].value.pdb_float;
trans_info[Y1] = args[5].value.pdb_float;
trans_info[X2] = args[6].value.pdb_float;
trans_info[Y2] = args[7].value.pdb_float;
trans_info[X3] = args[8].value.pdb_float;
trans_info[Y3] = args[9].value.pdb_float;
if (success)
{
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);
}
return_args = procedural_db_return_args (&perspective_proc, success);
if (success)
return_args[1].value.pdb_int = gimp_drawable_get_ID (GIMP_DRAWABLE (drawable));
return return_args;
}
static ProcArg perspective_inargs[] =
{
{
GIMP_PDB_DRAWABLE,
"drawable",
"The affected drawable"
},
{
GIMP_PDB_INT32,
"interpolation",
"Whether to use interpolation"
},
{
GIMP_PDB_FLOAT,
"x0",
"The new x coordinate of upper-left corner of original bounding box"
},
{
GIMP_PDB_FLOAT,
"y0",
"The new y coordinate of upper-left corner of original bounding box"
},
{
GIMP_PDB_FLOAT,
"x1",
"The new x coordinate of upper-right corner of original bounding box"
},
{
GIMP_PDB_FLOAT,
"y1",
"The new y coordinate of upper-right corner of original bounding box"
},
{
GIMP_PDB_FLOAT,
"x2",
"The new x coordinate of lower-left corner of original bounding box"
},
{
GIMP_PDB_FLOAT,
"y2",
"The new y coordinate of lower-left corner of original bounding box"
},
{
GIMP_PDB_FLOAT,
"x3",
"The new x coordinate of lower-right corner of original bounding box"
},
{
GIMP_PDB_FLOAT,
"y3",
"The new y coordinate of lower-right corner of original bounding box"
}
};
static ProcArg perspective_outargs[] =
{
{
GIMP_PDB_DRAWABLE,
"drawable",
"The newly mapped drawable"
}
};
static ProcRecord perspective_proc =
{
"gimp_perspective",
"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.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
GIMP_INTERNAL,
10,
perspective_inargs,
1,
perspective_outargs,
{ { perspective_invoker } }
};
static Argument *
rotate_invoker (Gimp *gimp,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
GimpDrawable *drawable;
gboolean interpolation;
gdouble angle;
GimpImage *gimage;
TileManager *float_tiles, *new_tiles;
gboolean new_layer;
gint offset_x, offset_y;
gdouble cx, cy;
GimpMatrix3 matrix;
drawable = gimp_drawable_get_by_ID (gimp, args[0].value.pdb_int);
if (drawable == NULL)
success = FALSE;
interpolation = args[1].value.pdb_int ? TRUE : FALSE;
angle = args[2].value.pdb_float;
if (success)
{
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);
}
return_args = procedural_db_return_args (&rotate_proc, success);
if (success)
return_args[1].value.pdb_int = gimp_drawable_get_ID (GIMP_DRAWABLE (drawable));
return return_args;
}
static ProcArg rotate_inargs[] =
{
{
GIMP_PDB_DRAWABLE,
"drawable",
"The affected drawable"
},
{
GIMP_PDB_INT32,
"interpolation",
"Whether to use interpolation"
},
{
GIMP_PDB_FLOAT,
"angle",
"The angle of rotation (radians)"
}
};
static ProcArg rotate_outargs[] =
{
{
GIMP_PDB_DRAWABLE,
"drawable",
"The rotated drawable"
}
};
static ProcRecord rotate_proc =
{
"gimp_rotate",
"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.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
GIMP_INTERNAL,
3,
rotate_inargs,
1,
rotate_outargs,
{ { rotate_invoker } }
};
static Argument *
scale_invoker (Gimp *gimp,
Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
GimpDrawable *drawable;
gboolean interpolation;
GimpImage *gimage;
TileManager *float_tiles, *new_tiles;
gboolean new_layer;
gint offset_x, offset_y;
gdouble scalex, scaley;
gdouble trans_info[4];
GimpMatrix3 matrix;
drawable = gimp_drawable_get_by_ID (gimp, args[0].value.pdb_int);
if (drawable == NULL)
success = FALSE;
interpolation = args[1].value.pdb_int ? TRUE : FALSE;
trans_info[X0] = args[2].value.pdb_float;
trans_info[Y0] = args[3].value.pdb_float;
trans_info[X1] = args[4].value.pdb_float;
trans_info[Y1] = args[5].value.pdb_float;
if (success)
{
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;
}
return_args = procedural_db_return_args (&scale_proc, success);
if (success)
return_args[1].value.pdb_int = gimp_drawable_get_ID (GIMP_DRAWABLE (drawable));
return return_args;
}
static ProcArg scale_inargs[] =
{
{
GIMP_PDB_DRAWABLE,
"drawable",
"The affected drawable"
},
{
GIMP_PDB_INT32,
"interpolation",
"Whether to use interpolation"
},
{
GIMP_PDB_FLOAT,
"x0",
"The new x coordinate of upper-left corner of newly scaled region"
},
{
GIMP_PDB_FLOAT,
"y0",
"The new y coordinate of upper-left corner of newly scaled region"
},
{
GIMP_PDB_FLOAT,
"x1",
"The new x coordinate of lower-right corner of newly scaled region"
},
{
GIMP_PDB_FLOAT,
"y1",
"The new y coordinate of lower-right corner of newly scaled region"
}
};
static ProcArg scale_outargs[] =
{
{
GIMP_PDB_DRAWABLE,
"drawable",
"The scaled drawable"
}
};
static ProcRecord scale_proc =
{
"gimp_scale",
"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.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
GIMP_INTERNAL,
6,
scale_inargs,
1,
scale_outargs,
{ { scale_invoker } }
};