gimp/app/pdb/paths_cmds.c

1462 lines
56 KiB
C

/* The GIMP -- an image manipulation program
* Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
*
* 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.
*/
/* NOTE: This file is autogenerated by pdbgen.pl. */
#include "config.h"
#include <string.h>
#include <glib-object.h>
#include "pdb-types.h"
#include "gimpargument.h"
#include "gimpprocedure.h"
#include "procedural_db.h"
#include "core/gimpparamspecs.h"
#include "core/gimp.h"
#include "core/gimpchannel-select.h"
#include "core/gimpimage.h"
#include "core/gimplist.h"
#include "core/gimpstrokedesc.h"
#include "gimp-intl.h"
#include "vectors/gimpanchor.h"
#include "vectors/gimpbezierstroke.h"
#include "vectors/gimpvectors-compat.h"
#include "vectors/gimpvectors-import.h"
#include "vectors/gimpvectors.h"
static GimpProcedure path_list_proc;
static GimpProcedure path_get_current_proc;
static GimpProcedure path_set_current_proc;
static GimpProcedure path_delete_proc;
static GimpProcedure path_get_points_proc;
static GimpProcedure path_set_points_proc;
static GimpProcedure path_stroke_current_proc;
static GimpProcedure path_get_point_at_dist_proc;
static GimpProcedure path_get_tattoo_proc;
static GimpProcedure path_set_tattoo_proc;
static GimpProcedure get_path_by_tattoo_proc;
static GimpProcedure path_get_locked_proc;
static GimpProcedure path_set_locked_proc;
static GimpProcedure path_to_selection_proc;
static GimpProcedure path_import_proc;
static GimpProcedure path_import_string_proc;
void
register_paths_procs (Gimp *gimp)
{
GimpProcedure *procedure;
/*
* path_list
*/
procedure = gimp_procedure_init (&path_list_proc, 1, 2);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image to list the paths from",
gimp,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("num-paths",
"num paths",
"The number of paths returned.",
0, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_STRINGARRAY,
g_param_spec_pointer ("path-list",
"path list",
"List of the paths belonging to this image.",
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* path_get_current
*/
procedure = gimp_procedure_init (&path_get_current_proc, 1, 1);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image to get the current path from",
gimp,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_STRING,
gimp_param_spec_string ("name",
"name",
"The name of the current path.",
FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* path_set_current
*/
procedure = gimp_procedure_init (&path_set_current_proc, 2, 0);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image in which a path will become current",
gimp,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_STRING,
gimp_param_spec_string ("name",
"name",
"The name of the path to make current.",
FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* path_delete
*/
procedure = gimp_procedure_init (&path_delete_proc, 2, 0);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image to delete the path from",
gimp,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_STRING,
gimp_param_spec_string ("name",
"name",
"The name of the path to delete.",
FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* path_get_points
*/
procedure = gimp_procedure_init (&path_get_points_proc, 2, 4);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image to list the paths from",
gimp,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_STRING,
gimp_param_spec_string ("name",
"name",
"The name of the path whose points should be listed.",
FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("path-type",
"path type",
"The type of the path. Currently only one type (1 = Bezier) is supported",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("path-closed",
"path closed",
"Return if the path is closed. (0 = path open, 1 = path closed)",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("num-path-point-details",
"num path point details",
"The number of points returned. Each point is made up of (x, y, pnt_type) of floats.",
0, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_FLOATARRAY,
g_param_spec_pointer ("points-pairs",
"points pairs",
"The points in the path represented as 3 floats. The first is the x pos, next is the y pos, last is the type of the pnt. The type field is dependant on the path type. For beziers (type 1 paths) the type can either be (1.0 = BEZIER_ANCHOR, 2.0 = BEZIER_CONTROL, 3.0 = BEZIER_MOVE). Note all points are returned in pixel resolution.",
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* path_set_points
*/
procedure = gimp_procedure_init (&path_set_points_proc, 5, 0);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image to set the paths in",
gimp,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_STRING,
gimp_param_spec_string ("name",
"name",
"The name of the path to create. If it exists then a unique name will be created - query the list of paths if you want to make sure that the name of the path you create is unique. This will be set as the current path.",
FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("ptype",
"ptype",
"The type of the path. Currently only one type (1 = Bezier) is supported.",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("num-path-points",
"num path points",
"The number of elements in the array, i.e. the number of points in the path * 3. Each point is made up of (x, y, type) of floats. Currently only the creation of bezier curves is allowed. The type parameter must be set to (1) to indicate a BEZIER type curve. Note that for BEZIER curves, points must be given in the following order: ACCACCAC... If the path is not closed the last control point is missed off. Points consist of three control points (control/anchor/control) so for a curve that is not closed there must be at least two points passed (2 x,y pairs). If (num_path_points/3) % 3 = 0 then the path is assumed to be closed and the points are ACCACCACCACC.",
0, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_FLOATARRAY,
g_param_spec_pointer ("points-pairs",
"points pairs",
"The points in the path represented as 3 floats. The first is the x pos, next is the y pos, last is the type of the pnt. The type field is dependant on the path type. For beziers (type 1 paths) the type can either be (1.0 = BEZIER_ANCHOR, 2.0 = BEZIER_CONTROL, 3.0= BEZIER_MOVE). Note all points are returned in pixel resolution.",
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* path_stroke_current
*/
procedure = gimp_procedure_init (&path_stroke_current_proc, 1, 0);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image which contains the path to stroke",
gimp,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* path_get_point_at_dist
*/
procedure = gimp_procedure_init (&path_get_point_at_dist_proc, 2, 3);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image the paths belongs to",
gimp,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_FLOAT,
g_param_spec_double ("distance",
"distance",
"The distance along the path.",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("x-point",
"x point",
"The x position of the point.",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("y-point",
"y point",
"The y position of the point.",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_FLOAT,
g_param_spec_double ("slope",
"slope",
"The slope (dy / dx) at the specified point.",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* path_get_tattoo
*/
procedure = gimp_procedure_init (&path_get_tattoo_proc, 2, 1);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image",
gimp,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_STRING,
gimp_param_spec_string ("name",
"name",
"The name of the path whose tattoo should be obtained.",
FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("tattoo",
"tattoo",
"The tattoo associated with the named path.",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* path_set_tattoo
*/
procedure = gimp_procedure_init (&path_set_tattoo_proc, 3, 0);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image",
gimp,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_STRING,
gimp_param_spec_string ("name",
"name",
"the name of the path whose tattoo should be set",
FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("tattovalue",
"tattovalue",
"The tattoo associated with the name path. Only values returned from 'path_get_tattoo' should be used here",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* get_path_by_tattoo
*/
procedure = gimp_procedure_init (&get_path_by_tattoo_proc, 2, 1);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image",
gimp,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("tattoo",
"tattoo",
"The tattoo of the required path.",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_STRING,
gimp_param_spec_string ("name",
"name",
"The name of the path with the specified tattoo.",
FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* path_get_locked
*/
procedure = gimp_procedure_init (&path_get_locked_proc, 2, 1);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image",
gimp,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_STRING,
gimp_param_spec_string ("name",
"name",
"The name of the path whose locked status should be obtained.",
FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
GIMP_PDB_INT32,
g_param_spec_boolean ("locked",
"locked",
"TRUE if the path is locked, FALSE otherwise",
FALSE,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* path_set_locked
*/
procedure = gimp_procedure_init (&path_set_locked_proc, 3, 0);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image",
gimp,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_STRING,
gimp_param_spec_string ("name",
"name",
"the name of the path whose locked status should be set",
FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_boolean ("locked",
"locked",
"Whether the path is locked",
FALSE,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* path_to_selection
*/
procedure = gimp_procedure_init (&path_to_selection_proc, 7, 0);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image",
gimp,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_STRING,
gimp_param_spec_string ("name",
"name",
"The name of the path which should be made into selection.",
FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_enum ("op",
"op",
"The desired operation with current selection: { GIMP_CHANNEL_OP_ADD (0), GIMP_CHANNEL_OP_SUBTRACT (1), GIMP_CHANNEL_OP_REPLACE (2), GIMP_CHANNEL_OP_INTERSECT (3) }",
GIMP_TYPE_CHANNEL_OPS,
GIMP_CHANNEL_OP_ADD,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_boolean ("antialias",
"antialias",
"Antialias selection.",
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_boolean ("feather",
"feather",
"Feather selection.",
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_FLOAT,
g_param_spec_double ("feather-radius-x",
"feather radius x",
"Feather radius x.",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_FLOAT,
g_param_spec_double ("feather-radius-y",
"feather radius y",
"Feather radius y.",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* path_import
*/
procedure = gimp_procedure_init (&path_import_proc, 4, 0);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image",
gimp,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_STRING,
gimp_param_spec_string ("filename",
"filename",
"The name of the SVG file to import.",
TRUE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_boolean ("merge",
"merge",
"Merge paths into a single vectors object.",
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_boolean ("scale",
"scale",
"Scale the SVG to image dimensions.",
FALSE,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
/*
* path_import_string
*/
procedure = gimp_procedure_init (&path_import_string_proc, 5, 0);
gimp_procedure_add_argument (procedure,
GIMP_PDB_IMAGE,
gimp_param_spec_image_id ("image",
"image",
"The image",
gimp,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_STRING,
gimp_param_spec_string ("string",
"string",
"A string that must be a complete and valid SVG document.",
TRUE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_int ("length",
"length",
"Number of bytes in string or -1 if the string is NULL terminated.",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_boolean ("merge",
"merge",
"Merge paths into a single vectors object.",
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
GIMP_PDB_INT32,
g_param_spec_boolean ("scale",
"scale",
"Scale the SVG to image dimensions.",
FALSE,
GIMP_PARAM_READWRITE));
procedural_db_register (gimp, procedure);
}
static Argument *
path_list_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_vals;
GimpImage *image;
gint32 num_paths = 0;
gchar **path_list = NULL;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
path_list = gimp_container_get_name_array (image->vectors, &num_paths);
}
return_vals = gimp_procedure_get_return_values (procedure, success);
if (success)
{
g_value_set_int (&return_vals[1].value, num_paths);
g_value_set_pointer (&return_vals[2].value, path_list);
}
return return_vals;
}
static GimpProcedure path_list_proc =
{
TRUE, TRUE,
"gimp-path-list",
"gimp-path-list",
"This procedure is deprecated! Use 'gimp-image-get-vectors' instead.",
"This procedure is deprecated! Use 'gimp-image-get-vectors' instead.",
"",
"",
"",
"gimp-image-get-vectors",
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { path_list_invoker } }
};
static Argument *
path_get_current_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_vals;
GimpImage *image;
gchar *name = NULL;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
GimpVectors *vectors = gimp_image_get_active_vectors (image);
if (vectors)
name = g_strdup (gimp_object_get_name (GIMP_OBJECT (vectors)));
else
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success);
if (success)
g_value_take_string (&return_vals[1].value, name);
return return_vals;
}
static GimpProcedure path_get_current_proc =
{
TRUE, TRUE,
"gimp-path-get-current",
"gimp-path-get-current",
"This procedure is deprecated! Use 'gimp-image-get-active-vectors' instead.",
"This procedure is deprecated! Use 'gimp-image-get-active-vectors' instead.",
"",
"",
"",
"gimp-image-get-active-vectors",
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { path_get_current_invoker } }
};
static Argument *
path_set_current_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpImage *image;
gchar *name;
image = gimp_value_get_image (&args[0].value, gimp);
name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
GimpVectors *vectors = gimp_image_get_vectors_by_name (image, name);
if (vectors)
gimp_image_set_active_vectors (image, vectors);
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success);
}
static GimpProcedure path_set_current_proc =
{
TRUE, TRUE,
"gimp-path-set-current",
"gimp-path-set-current",
"This procedure is deprecated! Use 'gimp-image-set-active-vectors' instead.",
"This procedure is deprecated! Use 'gimp-image-set-active-vectors' instead.",
"",
"",
"",
"gimp-image-set-active-vectors",
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { path_set_current_invoker } }
};
static Argument *
path_delete_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpImage *image;
gchar *name;
image = gimp_value_get_image (&args[0].value, gimp);
name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
GimpVectors *vectors = gimp_image_get_vectors_by_name (image, name);
if (vectors)
gimp_image_remove_vectors (image, vectors);
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success);
}
static GimpProcedure path_delete_proc =
{
TRUE, TRUE,
"gimp-path-delete",
"gimp-path-delete",
"This procedure is deprecated! Use 'gimp-image-remove-vectors' instead.",
"This procedure is deprecated! Use 'gimp-image-remove-vectors' instead.",
"",
"",
"",
"gimp-image-remove-vectors",
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { path_delete_invoker } }
};
static Argument *
path_get_points_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_vals;
GimpImage *image;
gchar *name;
gint32 path_type = 0;
gint32 path_closed = 0;
gint32 num_path_point_details = 0;
gdouble *points_pairs = NULL;
image = gimp_value_get_image (&args[0].value, gimp);
name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
GimpVectors *vectors = gimp_image_get_vectors_by_name (image, name);
if (vectors)
{
GimpVectorsCompatPoint *points;
gint num_points;
path_type = 1; /* BEZIER (1.2 compat) */
points = gimp_vectors_compat_get_points (vectors, &num_points,
&path_closed);
num_path_point_details = num_points * 3;
if (points)
{
gdouble *curr_point;
gint i;
points_pairs = g_new0 (gdouble, num_path_point_details);
for (i = 0, curr_point = points_pairs;
i < num_points;
i++, curr_point += 3)
{
curr_point[0] = points[i].x;
curr_point[1] = points[i].y;
curr_point[2] = points[i].type;
}
g_free (points);
}
else
success = FALSE;
}
else
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success);
if (success)
{
g_value_set_int (&return_vals[1].value, path_type);
g_value_set_int (&return_vals[2].value, path_closed);
g_value_set_int (&return_vals[3].value, num_path_point_details);
g_value_set_pointer (&return_vals[4].value, points_pairs);
}
return return_vals;
}
static GimpProcedure path_get_points_proc =
{
TRUE, TRUE,
"gimp-path-get-points",
"gimp-path-get-points",
"List the points associated with the named path.",
"List the points associated with the named path.",
"Andy Thomas",
"Andy Thomas",
"1999",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { path_get_points_invoker } }
};
static Argument *
path_set_points_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpImage *image;
gchar *name;
gint32 ptype;
gint32 num_path_points;
gdouble *points_pairs;
image = gimp_value_get_image (&args[0].value, gimp);
name = (gchar *) g_value_get_string (&args[1].value);
ptype = g_value_get_int (&args[2].value);
num_path_points = g_value_get_int (&args[3].value);
points_pairs = g_value_get_pointer (&args[4].value);
if (success)
{
gboolean closed = FALSE;
if ((num_path_points / 3) % 3 == 0)
closed = TRUE;
else if ((num_path_points / 3) % 3 != 2)
success = FALSE;
if (success)
{
GimpVectors *vectors;
gdouble *curr_point_pair;
GimpVectorsCompatPoint *points;
gint n_points;
gint i;
n_points = num_path_points / 3;
points = g_new0 (GimpVectorsCompatPoint, n_points);
for (i = 0, curr_point_pair = points_pairs;
i < n_points;
i++, curr_point_pair += 3)
{
points[i].x = curr_point_pair[0];
points[i].y = curr_point_pair[1];
points[i].type = curr_point_pair[2];
}
vectors = gimp_vectors_compat_new (image, name, points, n_points,
closed);
g_free (points);
if (vectors)
gimp_image_add_vectors (image, vectors, 0);
else
success = FALSE;
}
}
return gimp_procedure_get_return_values (procedure, success);
}
static GimpProcedure path_set_points_proc =
{
TRUE, TRUE,
"gimp-path-set-points",
"gimp-path-set-points",
"Set the points associated with the named path.",
"Set the points associated with the named path.",
"Andy Thomas",
"Andy Thomas",
"1999",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { path_set_points_invoker } }
};
static Argument *
path_stroke_current_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpImage *image;
image = gimp_value_get_image (&args[0].value, gimp);
if (success)
{
GimpVectors *vectors = gimp_image_get_active_vectors (image);
GimpDrawable *drawable = gimp_image_active_drawable (image);
if (vectors && drawable)
{
GimpStrokeDesc *desc = gimp_stroke_desc_new (gimp, context);
g_object_set (desc, "method", GIMP_STROKE_METHOD_PAINT_CORE, NULL);
success = gimp_item_stroke (GIMP_ITEM (vectors),
drawable, context, desc, TRUE);
g_object_unref (desc);
}
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success);
}
static GimpProcedure path_stroke_current_proc =
{
TRUE, TRUE,
"gimp-path-stroke-current",
"gimp-path-stroke-current",
"Stroke the current path in the passed image.",
"Stroke the current path in the passed image.",
"Andy Thomas",
"Andy Thomas",
"1999",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { path_stroke_current_invoker } }
};
static Argument *
path_get_point_at_dist_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_vals;
GimpImage *image;
gdouble distance;
gint32 x_point = 0;
gint32 y_point = 0;
gdouble slope = 0.0;
image = gimp_value_get_image (&args[0].value, gimp);
distance = g_value_get_double (&args[1].value);
if (success)
{
GimpVectors *vectors;
GimpStroke *stroke;
gdouble distance_along;
gdouble stroke_length;
gdouble stroke_distance;
GimpCoords position;
vectors = gimp_image_get_active_vectors (image);
if (vectors)
{
distance_along = 0.0;
stroke = gimp_vectors_stroke_get_next (vectors, NULL);
while (stroke != NULL )
{
stroke_length = gimp_stroke_get_length (stroke, 0.5);
if (distance_along + stroke_length < distance)
{
distance_along += stroke_length;
}
else
{
stroke_distance = distance - distance_along;
stroke_distance = stroke_distance < 0 ? 0: stroke_distance;
if (!gimp_stroke_get_point_at_dist (stroke, stroke_distance, 0.5,
&position, &slope))
{
success = FALSE;
break;
}
else
{
success = TRUE;
x_point = ROUND (position.x);
y_point = ROUND (position.y);
break;
}
}
stroke = gimp_vectors_stroke_get_next (vectors, stroke);
}
}
else
{
success = FALSE;
}
}
return_vals = gimp_procedure_get_return_values (procedure, success);
if (success)
{
g_value_set_int (&return_vals[1].value, x_point);
g_value_set_int (&return_vals[2].value, y_point);
g_value_set_double (&return_vals[3].value, slope);
}
return return_vals;
}
static GimpProcedure path_get_point_at_dist_proc =
{
TRUE, TRUE,
"gimp-path-get-point-at-dist",
"gimp-path-get-point-at-dist",
"This procedure is deprecated! Use 'gimp-vectors-stroke-get-point-at-dist' instead.",
"This will return the x,y position of a point at a given distance along the bezier curve. The distance will be obtained by first digitizing the curve internally and then walking along the curve. For a closed curve the start of the path is the first point on the path that was created. This might not be obvious. Note the current path is used.",
"Andy Thomas",
"Andy Thomas",
"1999",
"gimp-vectors-stroke-get-point-at-dist",
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { path_get_point_at_dist_invoker } }
};
static Argument *
path_get_tattoo_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_vals;
GimpImage *image;
gchar *name;
gint32 tattoo = 0;
image = gimp_value_get_image (&args[0].value, gimp);
name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
GimpVectors *vectors = gimp_image_get_vectors_by_name (image, name);
if (vectors)
tattoo = gimp_item_get_tattoo (GIMP_ITEM (vectors));
else
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success);
if (success)
g_value_set_int (&return_vals[1].value, tattoo);
return return_vals;
}
static GimpProcedure path_get_tattoo_proc =
{
TRUE, TRUE,
"gimp-path-get-tattoo",
"gimp-path-get-tattoo",
"This procedure is deprecated! Use 'gimp-vectors-get-tattoo' instead.",
"This procedure is deprecated! Use 'gimp-vectors-get-tattoo' instead.",
"",
"",
"",
"gimp-vectors-get-tattoo",
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { path_get_tattoo_invoker } }
};
static Argument *
path_set_tattoo_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpImage *image;
gchar *name;
gint32 tattovalue;
image = gimp_value_get_image (&args[0].value, gimp);
name = (gchar *) g_value_get_string (&args[1].value);
tattovalue = g_value_get_int (&args[2].value);
if (success)
{
GimpVectors *vectors = gimp_image_get_vectors_by_name (image, name);
if (vectors)
gimp_item_set_tattoo (GIMP_ITEM (vectors), tattovalue);
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success);
}
static GimpProcedure path_set_tattoo_proc =
{
TRUE, TRUE,
"gimp-path-set-tattoo",
"gimp-path-set-tattoo",
"This procedure is deprecated! Use 'gimp-vectors-set-tattoo' instead.",
"This procedure is deprecated! Use 'gimp-vectors-set-tattoo' instead.",
"",
"",
"",
"gimp-vectors-set-tattoo",
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { path_set_tattoo_invoker } }
};
static Argument *
get_path_by_tattoo_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_vals;
GimpImage *image;
gint32 tattoo;
gchar *name = NULL;
image = gimp_value_get_image (&args[0].value, gimp);
tattoo = g_value_get_int (&args[1].value);
if (success)
{
GimpVectors *vectors = gimp_image_get_vectors_by_tattoo (image, tattoo);
if (vectors)
name = g_strdup (gimp_object_get_name (GIMP_OBJECT (vectors)));
else
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success);
if (success)
g_value_take_string (&return_vals[1].value, name);
return return_vals;
}
static GimpProcedure get_path_by_tattoo_proc =
{
TRUE, TRUE,
"gimp-get-path-by-tattoo",
"gimp-get-path-by-tattoo",
"This procedure is deprecated! Use 'gimp-image-get-vectors-by-tattoo' instead.",
"This procedure is deprecated! Use 'gimp-image-get-vectors-by-tattoo' instead.",
"",
"",
"",
"gimp-image-get-vectors-by-tattoo",
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { get_path_by_tattoo_invoker } }
};
static Argument *
path_get_locked_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
Argument *return_vals;
GimpImage *image;
gchar *name;
gboolean locked = FALSE;
image = gimp_value_get_image (&args[0].value, gimp);
name = (gchar *) g_value_get_string (&args[1].value);
if (success)
{
GimpVectors *vectors = gimp_image_get_vectors_by_name (image, name);
if (vectors)
locked = gimp_item_get_linked (GIMP_ITEM (vectors));
else
success = FALSE;
}
return_vals = gimp_procedure_get_return_values (procedure, success);
if (success)
g_value_set_boolean (&return_vals[1].value, locked);
return return_vals;
}
static GimpProcedure path_get_locked_proc =
{
TRUE, TRUE,
"gimp-path-get-locked",
"gimp-path-get-locked",
"This procedure is deprecated! Use 'gimp-vectors-get-linked' instead.",
"This procedure is deprecated! Use 'gimp-vectors-get-linked' instead.",
"",
"",
"",
"gimp-vectors-get-linked",
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { path_get_locked_invoker } }
};
static Argument *
path_set_locked_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpImage *image;
gchar *name;
gboolean locked;
image = gimp_value_get_image (&args[0].value, gimp);
name = (gchar *) g_value_get_string (&args[1].value);
locked = g_value_get_boolean (&args[2].value);
if (success)
{
GimpVectors *vectors = gimp_image_get_vectors_by_name (image, name);
if (vectors)
gimp_item_set_linked (GIMP_ITEM (vectors), locked, TRUE);
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success);
}
static GimpProcedure path_set_locked_proc =
{
TRUE, TRUE,
"gimp-path-set-locked",
"gimp-path-set-locked",
"This procedure is deprecated! Use 'gimp-vectors-set-linked' instead.",
"This procedure is deprecated! Use 'gimp-vectors-set-linked' instead.",
"",
"",
"",
"gimp-vectors-set-linked",
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { path_set_locked_invoker } }
};
static Argument *
path_to_selection_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpImage *image;
gchar *name;
gint32 op;
gboolean antialias;
gboolean feather;
gdouble feather_radius_x;
gdouble feather_radius_y;
image = gimp_value_get_image (&args[0].value, gimp);
name = (gchar *) g_value_get_string (&args[1].value);
op = g_value_get_enum (&args[2].value);
antialias = g_value_get_boolean (&args[3].value);
feather = g_value_get_boolean (&args[4].value);
feather_radius_x = g_value_get_double (&args[5].value);
feather_radius_y = g_value_get_double (&args[6].value);
if (success)
{
GimpVectors *vectors = gimp_image_get_vectors_by_name (image, name);
if (vectors)
gimp_channel_select_vectors (gimp_image_get_mask (image),
_("Path to Selection"),
vectors,
op,
antialias,
feather,
feather_radius_x,
feather_radius_y);
else
success = FALSE;
}
return gimp_procedure_get_return_values (procedure, success);
}
static GimpProcedure path_to_selection_proc =
{
TRUE, TRUE,
"gimp-path-to-selection",
"gimp-path-to-selection",
"Transforms the active path into a selection",
"This procedure renders the desired path into the current selection.",
"Jo\xc3\xa3o S. O. Bueno Calligaris",
"Jo\xc3\xa3o S. O. Bueno Calligaris",
"2003",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { path_to_selection_invoker } }
};
static Argument *
path_import_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpImage *image;
gchar *filename;
gboolean merge;
gboolean scale;
image = gimp_value_get_image (&args[0].value, gimp);
filename = (gchar *) g_value_get_string (&args[1].value);
merge = g_value_get_boolean (&args[2].value);
scale = g_value_get_boolean (&args[3].value);
if (success)
{
success = gimp_vectors_import_file (image, filename, merge, scale, -1, NULL);
}
return gimp_procedure_get_return_values (procedure, success);
}
static GimpProcedure path_import_proc =
{
TRUE, TRUE,
"gimp-path-import",
"gimp-path-import",
"Import paths from an SVG file.",
"This procedure imports paths from an SVG file. SVG elements other than paths and basic shapes are ignored.",
"Sven Neumann <sven@gimp.org>",
"Sven Neumann",
"2003",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { path_import_invoker } }
};
static Argument *
path_import_string_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpImage *image;
gchar *string;
gint32 length;
gboolean merge;
gboolean scale;
image = gimp_value_get_image (&args[0].value, gimp);
string = (gchar *) g_value_get_string (&args[1].value);
length = g_value_get_int (&args[2].value);
merge = g_value_get_boolean (&args[3].value);
scale = g_value_get_boolean (&args[4].value);
if (success)
{
success = gimp_vectors_import_buffer (image, string, length,
merge, scale, -1, NULL);
}
return gimp_procedure_get_return_values (procedure, success);
}
static GimpProcedure path_import_string_proc =
{
TRUE, TRUE,
"gimp-path-import-string",
"gimp-path-import-string",
"Import paths from an SVG string.",
"This procedure works like gimp_path_import() but takes a string rather than reading the SVG from a file. This allows you to write scripts that generate SVG and feed it to GIMP.",
"Sven Neumann <sven@gimp.org>",
"Sven Neumann",
"2005",
NULL,
GIMP_INTERNAL,
0, NULL, 0, NULL,
{ { path_import_string_invoker } }
};