added transform_2d PDB procedure as suggested

by David Hodson <hodsond@ozemail.com.au>


--Sven
This commit is contained in:
Sven Neumann 2000-04-24 15:22:57 +00:00
parent 24bcbd1ab5
commit f2c3ad960c
7 changed files with 527 additions and 28 deletions

View File

@ -1,3 +1,10 @@
2000-04-24 Sven Neumann <sven@gimp.org>
* app/internal_procs.c
* app/tools_cmds.c
* tools/pdbgen/pdb/tools.pdb: added transform_2d PDB procedure as
suggested by David Hodson <hodsond@ozemail.com.au>
2000-04-24 Tuomas Kuosmanen <tigert@gimp.org>
* gimp_splash.ppm: Prepare for the 1.2.. Let us celebrate that

View File

@ -60,7 +60,7 @@ void register_tools_procs (void);
void register_undo_procs (void);
void register_unit_procs (void);
/* 321 procedures registered total */
/* 322 procedures registered total */
void
internal_procs_init (void)
@ -71,13 +71,13 @@ internal_procs_init (void)
app_init_update_status (NULL, _("Brushes"), 0.009);
register_brushes_procs ();
app_init_update_status (NULL, _("Channel"), 0.044);
app_init_update_status (NULL, _("Channel"), 0.043);
register_channel_procs ();
app_init_update_status (NULL, _("Channel Ops"), 0.09);
register_channel_ops_procs ();
app_init_update_status (NULL, _("Color"), 0.097);
app_init_update_status (NULL, _("Color"), 0.096);
register_color_procs ();
app_init_update_status (NULL, _("Convert"), 0.134);
@ -86,73 +86,73 @@ internal_procs_init (void)
app_init_update_status (NULL, _("Drawable procedures"), 0.143);
register_drawable_procs ();
app_init_update_status (NULL, _("Edit procedures"), 0.212);
app_init_update_status (NULL, _("Edit procedures"), 0.211);
register_edit_procs ();
app_init_update_status (NULL, _("File Operations"), 0.231);
app_init_update_status (NULL, _("File Operations"), 0.23);
register_fileops_procs ();
app_init_update_status (NULL, _("Floating selections"), 0.255);
register_floating_sel_procs ();
app_init_update_status (NULL, _("GDisplay procedures"), 0.274);
app_init_update_status (NULL, _("GDisplay procedures"), 0.273);
register_gdisplay_procs ();
app_init_update_status (NULL, _("Image"), 0.283);
register_gimage_procs ();
app_init_update_status (NULL, _("Image mask"), 0.467);
app_init_update_status (NULL, _("Image mask"), 0.466);
register_gimage_mask_procs ();
app_init_update_status (NULL, _("Gimprc procedures"), 0.52);
app_init_update_status (NULL, _("Gimprc procedures"), 0.519);
register_gimprc_procs ();
app_init_update_status (NULL, _("Help procedures"), 0.53);
app_init_update_status (NULL, _("Help procedures"), 0.528);
register_gimphelp_procs ();
app_init_update_status (NULL, _("Gradients"), 0.533);
app_init_update_status (NULL, _("Gradients"), 0.531);
register_gradient_procs ();
app_init_update_status (NULL, _("Gradient UI"), 0.548);
app_init_update_status (NULL, _("Gradient UI"), 0.547);
register_gradient_select_procs ();
app_init_update_status (NULL, _("Guide procedures"), 0.561);
app_init_update_status (NULL, _("Guide procedures"), 0.559);
register_guides_procs ();
app_init_update_status (NULL, _("Interface"), 0.579);
app_init_update_status (NULL, _("Interface"), 0.578);
register_interface_procs ();
app_init_update_status (NULL, _("Layer"), 0.589);
app_init_update_status (NULL, _("Layer"), 0.587);
register_layer_procs ();
app_init_update_status (NULL, _("Miscellaneous"), 0.685);
app_init_update_status (NULL, _("Miscellaneous"), 0.683);
register_misc_procs ();
app_init_update_status (NULL, _("Palette"), 0.692);
app_init_update_status (NULL, _("Palette"), 0.689);
register_palette_procs ();
app_init_update_status (NULL, _("Parasite procedures"), 0.713);
app_init_update_status (NULL, _("Parasite procedures"), 0.711);
register_parasite_procs ();
app_init_update_status (NULL, _("Paths"), 0.754);
app_init_update_status (NULL, _("Paths"), 0.752);
register_paths_procs ();
app_init_update_status (NULL, _("Pattern UI"), 0.794);
app_init_update_status (NULL, _("Pattern UI"), 0.792);
register_pattern_select_procs ();
app_init_update_status (NULL, _("Patterns"), 0.804);
app_init_update_status (NULL, _("Patterns"), 0.801);
register_patterns_procs ();
app_init_update_status (NULL, _("Plug-in"), 0.816);
app_init_update_status (NULL, _("Plug-in"), 0.814);
register_plug_in_procs ();
app_init_update_status (NULL, _("Procedural database"), 0.832);
app_init_update_status (NULL, _("Procedural database"), 0.829);
register_procedural_db_procs ();
app_init_update_status (NULL, _("Text procedures"), 0.857);
app_init_update_status (NULL, _("Text procedures"), 0.854);
register_text_tool_procs ();
app_init_update_status (NULL, _("Tool procedures"), 0.869);
app_init_update_status (NULL, _("Tool procedures"), 0.866);
register_tools_procs ();
app_init_update_status (NULL, _("Undo"), 0.96);

View File

@ -79,6 +79,7 @@ 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 (void)
@ -112,6 +113,7 @@ register_tools_procs (void)
procedural_db_register (&shear_proc);
procedural_db_register (&smudge_proc);
procedural_db_register (&smudge_default_proc);
procedural_db_register (&transform_2d_proc);
}
static Argument *
@ -2877,3 +2879,157 @@ static ProcRecord smudge_default_proc =
NULL,
{ { smudge_default_invoker } }
};
static Argument *
transform_2d_invoker (Argument *args)
{
gboolean success = TRUE;
Argument *return_args;
GimpDrawable *drawable;
gboolean interpolation;
gdouble source_x;
gdouble source_y;
gdouble scale_x;
gdouble scale_y;
gdouble angle;
gdouble dest_x;
gdouble dest_y;
GimpImage *gimage;
TileManager *float_tiles, *new_tiles;
gboolean new_layer;
GimpMatrix3 matrix;
drawable = gimp_drawable_get_ID (args[0].value.pdb_int);
if (drawable == NULL)
success = FALSE;
interpolation = args[1].value.pdb_int ? TRUE : FALSE;
source_x = args[2].value.pdb_float;
source_y = args[3].value.pdb_float;
scale_x = args[4].value.pdb_float;
scale_y = args[5].value.pdb_float;
angle = args[6].value.pdb_float;
dest_x = args[7].value.pdb_float;
dest_y = args[8].value.pdb_float;
if (success)
{
gimage = 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 = transform_core_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 = transform_core_do (gimage, drawable, float_tiles,
interpolation, matrix, NULL, NULL);
/* Free the cut/copied buffer */
tile_manager_destroy (float_tiles);
if (new_tiles)
success = transform_core_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 (&transform_2d_proc, success);
if (success)
return_args[1].value.pdb_int = drawable_ID (GIMP_DRAWABLE (drawable));
return return_args;
}
static ProcArg transform_2d_inargs[] =
{
{
PDB_DRAWABLE,
"drawable",
"The affected drawable"
},
{
PDB_INT32,
"interpolation",
"Whether to use interpolation"
},
{
PDB_FLOAT,
"source_x",
"X coordinate of the transformation center"
},
{
PDB_FLOAT,
"source_y",
"Y coordinate of the transformation center"
},
{
PDB_FLOAT,
"scale_x",
"Amount to scale in x direction"
},
{
PDB_FLOAT,
"scale_y",
"Amount to scale in y direction"
},
{
PDB_FLOAT,
"angle",
"The angle of rotation (radians)"
},
{
PDB_FLOAT,
"dest_x",
"X coordinate of where the centre goes"
},
{
PDB_FLOAT,
"dest_y",
"Y coordinate of where the centre goes"
}
};
static ProcArg transform_2d_outargs[] =
{
{
PDB_DRAWABLE,
"drawable",
"The transformed drawable"
}
};
static ProcRecord transform_2d_proc =
{
"gimp_transform_2d",
"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.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
PDB_INTERNAL,
9,
transform_2d_inargs,
1,
transform_2d_outargs,
{ { transform_2d_invoker } }
};

View File

@ -1314,6 +1314,90 @@ 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("transform_core.h"
"tile_manager_pvt.h") ],
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
'gboolean new_layer', 'GimpMatrix3 matrix' ],
code => <<'CODE'
{
gimage = 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 = transform_core_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 = transform_core_do (gimage, drawable, float_tiles,
interpolation, matrix, NULL, NULL);
/* Free the cut/copied buffer */
tile_manager_destroy (float_tiles);
if (new_tiles)
success = transform_core_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';
@ -1452,7 +1536,7 @@ sub ink {
flip free_select fuzzy_select
paintbrush paintbrush_default
pencil perspective rect_select rotate scale shear
smudge smudge_default);
smudge smudge_default transform_2d);
%exports = (app => [@procs]);
$desc = 'Tool procedures';

View File

@ -1314,6 +1314,90 @@ 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("transform_core.h"
"tile_manager_pvt.h") ],
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
'gboolean new_layer', 'GimpMatrix3 matrix' ],
code => <<'CODE'
{
gimage = 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 = transform_core_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 = transform_core_do (gimage, drawable, float_tiles,
interpolation, matrix, NULL, NULL);
/* Free the cut/copied buffer */
tile_manager_destroy (float_tiles);
if (new_tiles)
success = transform_core_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';
@ -1452,7 +1536,7 @@ sub ink {
flip free_select fuzzy_select
paintbrush paintbrush_default
pencil perspective rect_select rotate scale shear
smudge smudge_default);
smudge smudge_default transform_2d);
%exports = (app => [@procs]);
$desc = 'Tool procedures';

View File

@ -1314,6 +1314,90 @@ 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("transform_core.h"
"tile_manager_pvt.h") ],
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
'gboolean new_layer', 'GimpMatrix3 matrix' ],
code => <<'CODE'
{
gimage = 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 = transform_core_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 = transform_core_do (gimage, drawable, float_tiles,
interpolation, matrix, NULL, NULL);
/* Free the cut/copied buffer */
tile_manager_destroy (float_tiles);
if (new_tiles)
success = transform_core_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';
@ -1452,7 +1536,7 @@ sub ink {
flip free_select fuzzy_select
paintbrush paintbrush_default
pencil perspective rect_select rotate scale shear
smudge smudge_default);
smudge smudge_default transform_2d);
%exports = (app => [@procs]);
$desc = 'Tool procedures';

View File

@ -1314,6 +1314,90 @@ 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("transform_core.h"
"tile_manager_pvt.h") ],
vars => [ 'GimpImage *gimage', 'TileManager *float_tiles, *new_tiles',
'gboolean new_layer', 'GimpMatrix3 matrix' ],
code => <<'CODE'
{
gimage = 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 = transform_core_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 = transform_core_do (gimage, drawable, float_tiles,
interpolation, matrix, NULL, NULL);
/* Free the cut/copied buffer */
tile_manager_destroy (float_tiles);
if (new_tiles)
success = transform_core_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';
@ -1452,7 +1536,7 @@ sub ink {
flip free_select fuzzy_select
paintbrush paintbrush_default
pencil perspective rect_select rotate scale shear
smudge smudge_default);
smudge smudge_default transform_2d);
%exports = (app => [@procs]);
$desc = 'Tool procedures';