removed PDB access to the old paths and ported everything to GimpVectors.

2003-05-15  Michael Natterer  <mitch@gimp.org>

	* tools/pdbgen/pdb/paths.pdb: removed PDB access to the old paths
	and ported everything to GimpVectors. Note that everything except
	gimp_path_set_points() is untested and that
	gimp_path_get_point_at_dist() is currently unimplemented. Changed
	order of the generated functions and fixed some help texts.

	* tools/pdbgen/app.pl: removed $tools_eek and $paint_eek hacks
	because pdb/ doesn't include stuff from tools/ any more and paint/
	no longer depends on GTK+.

	* app/pdb/paint_tools_cmds.c
	* app/pdb/paths_cmds.c
	* libgimp/gimppaths_pdb.[ch]: regenerated.
This commit is contained in:
Michael Natterer 2003-05-15 21:15:00 +00:00 committed by Michael Natterer
parent 254cfb27ad
commit ecbbb96235
7 changed files with 863 additions and 900 deletions

View File

@ -1,3 +1,19 @@
2003-05-15 Michael Natterer <mitch@gimp.org>
* tools/pdbgen/pdb/paths.pdb: removed PDB access to the old paths
and ported everything to GimpVectors. Note that everything except
gimp_path_set_points() is untested and that
gimp_path_get_point_at_dist() is currently unimplemented. Changed
order of the generated functions and fixed some help texts.
* tools/pdbgen/app.pl: removed $tools_eek and $paint_eek hacks
because pdb/ doesn't include stuff from tools/ any more and paint/
no longer depends on GTK+.
* app/pdb/paint_tools_cmds.c
* app/pdb/paths_cmds.c
* libgimp/gimppaths_pdb.[ch]: regenerated.
2003-05-15 Sven Neumann <sven@gimp.org>
* app/core/gimpdrawable-transform.c
@ -16,10 +32,10 @@
vectors_selection_to_vectors() which invokes the sel2path Plug-In.
* app/gui/dialogs-constructors.c: make the new function known to
GimpVectorTreeView.
GimpVectorsTreeView.
* app/widgets/gimpvectorstreeview.[ch]: Added a "Selection to Path"
button anc call the new function.
button and call the new function.
2003-05-15 Michael Natterer <mitch@gimp.org>

View File

@ -21,7 +21,7 @@
#include "config.h"
#include <gtk/gtk.h>
#include <glib-object.h>
#include "libgimpbase/gimpbasetypes.h"
@ -47,6 +47,7 @@
#include "paint/gimpsmudge.h"
#include "paint/gimpsmudgeoptions.h"
#include "paint/paint-enums.h"
#include "paint/paint-types.h"
#include "libgimpmath/gimpmath.h"

File diff suppressed because it is too large Load Diff

View File

@ -67,54 +67,6 @@ gimp_path_list (gint32 image_ID,
return path_list;
}
/**
* gimp_path_get_points:
* @image_ID: The ID of the image to list the paths from.
* @pathname: the name of the path whose points should be listed.
* @path_closed: Return if the path is closed. {0=path open, 1= path closed}.
* @num_path_point_details: The number of points returned. Each point is made up of (x,y,pnt_type) of floats.
* @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}. Note all points are returned in pixel resolution.
*
* List the points associated with the named path.
*
* List the points associated with the named path.
*
* Returns: The type of the path. Currently only one type (1 = Bezier) is supported.
*/
gint
gimp_path_get_points (gint32 image_ID,
gchar *pathname,
gint *path_closed,
gint *num_path_point_details,
gdouble **points_pairs)
{
GimpParam *return_vals;
gint nreturn_vals;
gint path_type = 0;
return_vals = gimp_run_procedure ("gimp_path_get_points",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_STRING, pathname,
GIMP_PDB_END);
*num_path_point_details = 0;
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
{
path_type = return_vals[1].data.d_int32;
*path_closed = return_vals[2].data.d_int32;
*num_path_point_details = return_vals[3].data.d_int32;
*points_pairs = g_new (gdouble, *num_path_point_details);
memcpy (*points_pairs, return_vals[4].data.d_floatarray,
*num_path_point_details * sizeof (gdouble));
}
gimp_destroy_params (return_vals, nreturn_vals);
return path_type;
}
/**
* gimp_path_get_current:
* @image_ID: The ID of the image to get the current paths from.
@ -177,13 +129,93 @@ gimp_path_set_current (gint32 image_ID,
return success;
}
/**
* gimp_path_delete:
* @image_ID: The ID of the image to list delete the paths from.
* @path_name_to_del: The name of the path to delete.
*
* Delete the named paths associated with the passed image.
*
* Delete the named path.
*
* Returns: TRUE on success.
*/
gboolean
gimp_path_delete (gint32 image_ID,
gchar *path_name_to_del)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_path_delete",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_STRING, path_name_to_del,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_path_get_points:
* @image_ID: The ID of the image to list the paths from.
* @pathname: the name of the path whose points should be listed.
* @path_closed: Return if the path is closed. (0 = path open, 1 = path closed).
* @num_path_point_details: The number of points returned. Each point is made up of (x, y, pnt_type) of floats.
* @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). Note all points are returned in pixel resolution.
*
* List the points associated with the named path.
*
* List the points associated with the named path.
*
* Returns: The type of the path. Currently only one type (1 = Bezier) is supported.
*/
gint
gimp_path_get_points (gint32 image_ID,
gchar *pathname,
gint *path_closed,
gint *num_path_point_details,
gdouble **points_pairs)
{
GimpParam *return_vals;
gint nreturn_vals;
gint path_type = 0;
return_vals = gimp_run_procedure ("gimp_path_get_points",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_STRING, pathname,
GIMP_PDB_END);
*num_path_point_details = 0;
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
{
path_type = return_vals[1].data.d_int32;
*path_closed = return_vals[2].data.d_int32;
*num_path_point_details = return_vals[3].data.d_int32;
*points_pairs = g_new (gdouble, *num_path_point_details);
memcpy (*points_pairs, return_vals[4].data.d_floatarray,
*num_path_point_details * sizeof (gdouble));
}
gimp_destroy_params (return_vals, nreturn_vals);
return path_type;
}
/**
* gimp_path_set_points:
* @image_ID: The ID of the image to set the paths in.
* @pathname: 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.
* @ptype: The type of the path. Currently only one type (1 = Bezier) is supported.
* @num_path_points: The number of points in the path. 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. For BEZIERS. Note the that 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_pnts % 3 = 0 then the path is assumed to be closed and the points are ACCACCACCACC.
* @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}. Note all points are returned in pixel resolution.
* @num_path_points: The number of points in the path. 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. For BEZIERS. Note the that 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_pnts % 3 = 0 then the path is assumed to be closed and the points are ACCACCACCACC.
* @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). Note all points are returned in pixel resolution.
*
* Set the points associated with the named path.
*
@ -329,6 +361,45 @@ gimp_path_get_tattoo (gint32 image_ID,
return tattoo;
}
/**
* gimp_path_set_tattoo:
* @image_ID: The image.
* @pathname: the name of the path whose tattoo should be set.
* @tattovalue: The tattoo associated with the name path. Only values returned from 'path_get_tattoo' should be used here.
*
* Sets the tattoo associated with the name path.
*
* This procedure sets the tattoo associated with the specified path. A
* tattoo is a unique and permenant identifier attached to a path that
* can be used to uniquely identify a path within an image even between
* sessions. Note that the value passed to this function must have been
* obtained from a previous call to path_get_tattoo.
*
* Returns: TRUE on success.
*/
gboolean
gimp_path_set_tattoo (gint32 image_ID,
gchar *pathname,
gint tattovalue)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_path_set_tattoo",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_STRING, pathname,
GIMP_PDB_INT32, tattovalue,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_get_path_by_tattoo:
* @image_ID: The image.
@ -366,38 +437,6 @@ gimp_get_path_by_tattoo (gint32 image_ID,
return path_name;
}
/**
* gimp_path_delete:
* @image_ID: The ID of the image to list delete the paths from.
* @path_name_to_del: The name of the path to delete.
*
* Delete the named paths associated with the passed image.
*
* Delete the named path.
*
* Returns: TRUE on success.
*/
gboolean
gimp_path_delete (gint32 image_ID,
gchar *path_name_to_del)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_path_delete",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_STRING, path_name_to_del,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_path_get_locked:
* @image_ID: The image.
@ -469,42 +508,3 @@ gimp_path_set_locked (gint32 image_ID,
return success;
}
/**
* gimp_path_set_tattoo:
* @image_ID: The image.
* @pathname: the name of the path whose tattoo should be set.
* @tattovalue: The tattoo associated with the name path. Only values returned from 'path_get_tattoo' should be used here.
*
* Sets the tattoo associated with the name path.
*
* This procedure sets the tattoo associated with the specified path. A
* tattoo is a unique and permenant identifier attached to a path that
* can be used to uniquely identify a path within an image even between
* sessions. Note that the value passed to this function must have been
* obtained from a previous call to path_get_tattoo.
*
* Returns: TRUE on success.
*/
gboolean
gimp_path_set_tattoo (gint32 image_ID,
gchar *pathname,
gint tattovalue)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_path_set_tattoo",
&nreturn_vals,
GIMP_PDB_IMAGE, image_ID,
GIMP_PDB_STRING, pathname,
GIMP_PDB_INT32, tattovalue,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}

View File

@ -31,14 +31,16 @@ G_BEGIN_DECLS
gchar** gimp_path_list (gint32 image_ID,
gint *num_paths);
gchar* gimp_path_get_current (gint32 image_ID);
gboolean gimp_path_set_current (gint32 image_ID,
gchar *set_current_path_name);
gboolean gimp_path_delete (gint32 image_ID,
gchar *path_name_to_del);
gint gimp_path_get_points (gint32 image_ID,
gchar *pathname,
gint *path_closed,
gint *num_path_point_details,
gdouble **points_pairs);
gchar* gimp_path_get_current (gint32 image_ID);
gboolean gimp_path_set_current (gint32 image_ID,
gchar *set_current_path_name);
gboolean gimp_path_set_points (gint32 image_ID,
gchar *pathname,
gint ptype,
@ -51,18 +53,16 @@ gint gimp_path_get_point_at_dist (gint32 image_ID,
gdouble *gradient);
gint gimp_path_get_tattoo (gint32 image_ID,
gchar *pathname);
gboolean gimp_path_set_tattoo (gint32 image_ID,
gchar *pathname,
gint tattovalue);
gchar* gimp_get_path_by_tattoo (gint32 image_ID,
gint tattoo);
gboolean gimp_path_delete (gint32 image_ID,
gchar *path_name_to_del);
gint gimp_path_get_locked (gint32 image_ID,
gchar *pathname);
gboolean gimp_path_set_locked (gint32 image_ID,
gchar *pathname,
gint lockstatus);
gboolean gimp_path_set_tattoo (gint32 image_ID,
gchar *pathname,
gint tattovalue);
G_END_DECLS

View File

@ -676,8 +676,6 @@ GPL
foreach $group (@main::groups) {
my $out = $out{$group};
my $tool_eek = 0;
my $paint_eek = 0;
my $widgets_eek = 0;
my $display_eek = 0;
my $gui_eek = 0;
@ -686,16 +684,6 @@ GPL
delete $out->{headers}->{q/"procedural_db.h"/};
delete $out->{headers}->{q/"config.h"/};
if (exists $out->{headers}->{q|"tools/tools-types.h"|}) {
$tool_eek = 1;
delete $out->{headers}->{q|"tools/tools-types.h"|};
}
if (exists $out->{headers}->{q|"paint/paint-types.h"|}) {
$paint_eek = 1;
delete $out->{headers}->{q|"paint/paint-types.h"|};
}
if (exists $out->{headers}->{q|"widgets/widgets-types.h"|}) {
$widgets_eek = 1;
delete $out->{headers}->{q|"widgets/widgets-types.h"|};
@ -738,8 +726,7 @@ GPL
$eek = 1;
$headers .= "\n";
if ($tool_eek == 1 || $paint_eek == 1 || $widgets_eek == 1 ||
$display_eek == 1 || $gui_eek == 1) {
if ($widgets_eek == 1 || $display_eek == 1 || $gui_eek == 1) {
$headers .= '#include <gtk/gtk.h>';
} else {
$headers .= '#include <glib-object.h>';
@ -751,11 +738,6 @@ GPL
$headers .= '#include "pdb-types.h"';
$headers .= "\n";
if ($tool_eek == 1) {
$headers .= '#include "tools/tools-types.h"';
$headers .= "\n";
}
if ($widgets_eek == 1) {
$headers .= '#include "widgets/widgets-types.h"';
$headers .= "\n";

View File

@ -44,25 +44,24 @@ HELP
);
%invoke = (
vars => [ 'PathList *plist' ],
code => <<'CODE'
{
plist = gimage->paths;
num_paths = gimp_container_num_children (gimage->vectors);
if (plist && plist->bz_paths)
if (num_paths > 0)
{
gint count = 0;
GSList *pl = plist->bz_paths;
num_paths = g_slist_length (pl);
gint count = 0;
GList *list;
path_list = g_new (gchar *, num_paths);
while (pl)
{
Path *pptr = pl->data;
path_list[count++] = g_strdup (pptr->name);
pl = pl->next;
}
for (list = GIMP_LIST (gimage->vectors)->list;
list;
list = g_list_next (list))
{
path_list[count++] =
g_strdup (gimp_object_get_name (GIMP_OBJECT (list->data)));
}
}
}
CODE
@ -89,77 +88,106 @@ HELP
@outargs = (
{ name => 'path_type', type => 'int32',
desc => 'The type of the path. Currently only one type (1 = Bezier)
is supported',
alias => 'pptr->pathtype', no_declare => 1 },
is supported' },
{ name => 'path_closed', type => 'int32',
desc => 'Return if the path is closed. {0=path open, 1= path
closed}',
alias => 'pptr->closed', no_declare => 1 },
desc => 'Return if the path is closed. (0 = path open, 1 = path
closed)' },
{ name => 'points_pairs', type => 'floatarray',
desc => '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}. Note all points are returned in pixel
(type 1 paths) the type can either be (1.0 = BEZIER_ANCHOR,
2.0 = BEZIER_CONTROL). Note all points are returned in pixel
resolution',
alias => 'pnts', init => 1,
alias => 'points', init => 1,
array => { name => 'num_path_point_details',
desc => 'The number of points returned. Each point is
made up of (x,y,pnt_type) of floats',
alias => 'num_pdetails', init => 1 } }
made up of (x, y, pnt_type) of floats',
alias => 'num_points', init => 1 } }
);
%invoke = (
vars => [ 'PathList *plist', 'Path *pptr = NULL' ],
vars => [ 'GimpVectors *vectors' ],
code => <<'CODE'
{
/* Get the path with the given name */
plist = gimage->paths;
if (plist && plist->bz_paths)
vectors = gimp_image_get_active_vectors (gimage);
if (vectors)
{
GSList *pl = plist->bz_paths;
GList *list;
GimpStroke *stroke;
gdouble *curr_point;
while (pl)
{
pptr = pl->data;
path_type = 1;
path_closed = FALSE; /* FIXME */
if (!strcmp (pname, pptr->name))
break; /* Found the path */
for (list = vectors->strokes; list; list = g_list_next (list))
{
gint num_anchors;
pl = pl->next;
pptr = NULL;
}
stroke = (GimpStroke *) list->data;
if (pl && pptr)
{
GSList *points_list;
gint pcount = 0;
num_anchors = g_list_length (stroke->anchors);
points_list = pptr->path_details;
if (points_list)
{
num_pdetails = g_slist_length (points_list) * 3;
if (list->next && (num_anchors % 3) != 0)
num_anchors++;
pnts = g_new (gdouble, num_pdetails);
num_points += num_anchors;
}
/* fill points and types in */
while (points_list)
{
PathPoint *ppoint = points_list->data;
pnts[pcount] = ppoint->x;
pnts[pcount + 1] = ppoint->y;
pnts[pcount + 2] = (gfloat) ppoint->type; /* Bit of fiddle but should be understandable why it was done */
pcount += 3;
points_list = points_list->next;
}
}
else
success = FALSE;
}
else
success = FALSE;
points = g_new0 (gdouble, num_points * 3);
for (list = vectors->strokes; list; list = g_list_next (list))
{
GList *anchors;
stroke = (GimpStroke *) list->data;
for (anchors = stroke->anchors;
anchors;
anchors = g_list_next (anchors))
{
GimpAnchor *anchor = anchors->data;
gdouble anchor_type;
switch (anchor->type)
{
case GIMP_ANCHOR_ANCHOR:
if (list->prev)
anchor_type = 3.0; /* new stroke start */
else
anchor_type = 1.0; /* ordinary anchor */
break;
case GIMP_ANCHOR_CONTROL:
anchor_type = 2.0;
break;
}
curr_point[0] = anchor->position.x;
curr_point[1] = anchor->position.y;
curr_point[2] = anchor_type;
curr_point += 3;
/* FIXME */
if (! anchors->next && list->next)
{
/* create a fake closed segment */
anchor = (GimpAnchor *) stroke->anchors->data;
curr_point[0] = anchor->position.x;
curr_point[1] = anchor->position.y;
curr_point[2] = 2.0;
curr_point += 3;
}
}
}
}
else
success = FALSE;
}
CODE
);
@ -180,18 +208,17 @@ HELP
@outargs = (
{ name => 'current_path_name', type => 'string',
desc => 'The name of the current path',
alias => 'g_strdup (pptr->name)', no_declare => 1 }
alias => 'pname' }
);
%invoke = (
vars => [ 'PathList *plist', 'Path *pptr = NULL' ],
vars => [ 'GimpVectors *vectors' ],
code => <<'CODE'
{
/* Get the path with the given name */
plist = gimage->paths;
vectors = gimp_image_get_active_vectors (gimage);
if (plist && plist->bz_paths && plist->last_selected_row >= 0)
pptr = (Path*) g_slist_nth_data (plist->bz_paths, plist->last_selected_row);
if (vectors)
pname = g_strdup (gimp_object_get_name (GIMP_OBJECT (vectors)));
else
success = FALSE;
}
@ -216,7 +243,19 @@ HELP
);
$inargs[0]->{desc} = 'The ID of the image to list set the paths in';
%invoke = ( code => 'success = path_set_path (gimage, pname);' );
%invoke = (
vars => [ 'GimpVectors *vectors' ],
code => <<'CODE'
{
vectors = gimp_image_get_vectors_by_name (gimage, pname);
if (vectors)
gimp_image_set_active_vectors (gimage, vectors);
else
success = FALSE;
}
CODE
);
}
sub path_set_points {
@ -239,16 +278,16 @@ HELP
{ name => 'ptype', type => 'int32',
desc => 'The type of the path. Currently only one type (1 = Bezier)
is supported' },
{ name => 'points_pairs', type => 'floatarray', alias => 'pnts',
{ name => 'points_pairs', type => 'floatarray',
desc => '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}. Note all points are returned in pixel
(type 1 paths) the type can either be (1.0 = BEZIER_ANCHOR,
2.0 = BEZIER_CONTROL). Note all points are returned in pixel
resolution',
array => { name => 'num_path_points',
desc => 'The number of points in the path. Each point is
made up of (x,y,type) of floats. Currently only
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. For BEZIERS. Note the that points
@ -260,7 +299,7 @@ HELP
two points passed (2 x,y pairs). If num_path_pnts
% 3 = 0 then the path is assumed to be closed
and the points are ACCACCACCACC.',
alias => 'numpoints', init => 1 } }
init => 1 } }
);
$inargs[0]->{desc} = 'The ID of the image to set the paths in';
@ -268,14 +307,69 @@ HELP
vars => [ 'gboolean pclosed = FALSE' ],
code => <<'CODE'
{
if ((numpoints / 3) % 3 == 0)
if ((num_path_points / 3) % 3 == 0)
pclosed = TRUE;
else if ((numpoints / 3) % 3 != 2)
else if ((num_path_points / 3) % 3 != 2)
success = FALSE;
if (success && !path_set_path_points (gimage, pname, ptype, pclosed,
numpoints, pnts))
success = FALSE;
if (success)
{
GimpVectors *vectors;
GimpCoords *coords;
GimpCoords *curr_coord;
gint num_coords;
gdouble *curr_point_pair;
vectors = gimp_vectors_new (gimage, pname);
num_coords = num_path_points / 3;
coords = g_new0 (GimpCoords, num_coords);
/* FIXME */
if (pclosed)
num_coords--;
curr_coord = coords;
curr_point_pair = points_pairs;
while (num_coords > 0)
{
GimpStroke *stroke;
GimpCoords *next_stroke;
gint num_stroke_coords;
for (next_stroke = curr_coord;
num_coords > 0;
next_stroke++, num_coords--, curr_point_pair += 3)
{
next_stroke->x = curr_point_pair[0];
next_stroke->y = curr_point_pair[1];
next_stroke->pressure = 1.0;
next_stroke->xtilt = 1.0;
next_stroke->ytilt = 1.0;
if (next_stroke != curr_coord && curr_point_pair[2] == 3.0)
break;
}
num_stroke_coords = next_stroke - curr_coord;
/* FIXME */
if (num_coords > 0)
num_stroke_coords--;
stroke = gimp_bezier_stroke_new_from_coords (curr_coord,
num_stroke_coords);
gimp_vectors_stroke_add (vectors, stroke);
g_object_unref (stroke);
curr_coord = next_stroke;
}
g_free (coords);
gimp_image_add_vectors (gimage, vectors, 0);
}
}
CODE
);
@ -295,20 +389,34 @@ HELP
stroke';
%invoke = (
vars => [ 'PathList *plist', 'Path *pptr = NULL' ],
vars => [ 'GimpVectors *vectors', 'GimpDrawable *drawable' ],
code => <<'CODE'
{
/* Get the path with the given name */
plist = gimage->paths;
vectors = gimp_image_get_active_vectors (gimage);
drawable = gimp_image_active_drawable (gimage);
if (plist && plist->bz_paths && plist->last_selected_row >= 0)
if (vectors && drawable)
{
if ((pptr = (Path*) g_slist_nth_data (plist->bz_paths,
plist->last_selected_row)))
path_stroke (gimage, plist, pptr); /* Found the path to stroke.. */
else
success = FALSE;
GimpToolInfo *tool_info;
GimpPaintOptions *paint_options;
GimpPaintCore *core;
tool_info = gimp_context_get_tool (gimp_get_current_context (gimp));
if (! (tool_info && GIMP_IS_PAINT_OPTIONS (tool_info->tool_options)))
{
tool_info = (GimpToolInfo *)
gimp_container_get_child_by_name (gimp->tool_info_list,
"gimp-paintbrush-tool");
}
paint_options = GIMP_PAINT_OPTIONS (tool_info->tool_options);
core = g_object_new (tool_info->paint_info->paint_type, NULL);
gimp_paint_core_stroke_vectors (core, drawable, paint_options, vectors);
g_object_unref (core);
}
else
success = FALSE;
@ -347,18 +455,15 @@ HELP
);
%invoke = (
vars => [ 'PathList *plist', 'Path *pptr = NULL' ],
code => <<'CODE'
vars => [ 'GimpVectors *vectors' ],
code => <<'CODE'
{
/* Get the path with the given name */
plist = gimage->paths;
vectors = gimp_image_get_active_vectors (gimage);
if (plist && plist->bz_paths && plist->last_selected_row >= 0)
if (vectors)
{
pptr = (Path*) g_slist_nth_data (plist->bz_paths,
plist->last_selected_row);
success = path_distance (pptr, distance, &x_point, &y_point,
&gradient);
g_warning ("FIXME: path_get_point_at_dist() is unimplemented");
success = FALSE;
}
else
success = FALSE;
@ -389,32 +494,14 @@ HELP
);
%invoke = (
vars => [ 'PathList *plist', 'Path *pptr = NULL' ],
vars => [ 'GimpVectors *vectors' ],
code => <<'CODE'
{
/* Get the path with the given name */
plist = gimage->paths;
if (plist && plist->bz_paths)
{
GSList *pl = plist->bz_paths;
vectors = (GimpVectors *)
gimp_container_get_child_by_name (gimage->vectors, pname);
while (pl)
{
pptr = pl->data;
if (!strcmp (pname, pptr->name))
break; /* Found the path */
pl = pl->next;
pptr = NULL;
}
if (pl && pptr)
tattoo = path_get_tattoo (pptr);
else
success = FALSE;
}
if (vectors)
tattoo = gimp_item_get_tattoo (GIMP_ITEM (vectors));
else
success = FALSE;
}
@ -441,32 +528,14 @@ HELP
);
%invoke = (
vars => [ 'PathList *plist', 'Path *pptr = NULL' ],
vars => [ 'GimpVectors *vectors' ],
code => <<'CODE'
{
/* Get the path with the given name */
plist = gimage->paths;
if (plist && plist->bz_paths)
{
GSList *pl = plist->bz_paths;
vectors = (GimpVectors *)
gimp_container_get_child_by_name (gimage->vectors, pname);
while (pl)
{
pptr = pl->data;
if (!strcmp (pname, pptr->name))
break; /* Found the path */
pl = pl->next;
pptr = NULL;
}
if (pl && pptr)
pptr->tattoo = tattovalue ;
else
success = FALSE;
}
if (vectors)
gimp_item_set_tattoo (GIMP_ITEM (vectors), tattovalue);
else
success = FALSE;
}
@ -492,22 +561,17 @@ HELP
@outargs = (
{ name => 'path_name', type => 'string',
desc => 'The name of the path with the specified tattoo',
alias => 'g_strdup (pptr->name)', no_declare => 1 }
desc => 'The name of the path with the specified tattoo' }
);
%invoke = (
vars => [ 'PathList *plist', 'Path *pptr = NULL' ],
vars => [ 'GimpVectors *vectors' ],
code => <<'CODE'
{
/* Get the path with the given name */
plist = gimage->paths;
vectors = gimp_image_get_vectors_by_tattoo (gimage, tattoo);
if (plist && plist->bz_paths)
{
if ((pptr = path_get_path_by_tattoo (gimage, tattoo)) == NULL)
success = FALSE;
}
if (vectors)
path_name = g_strdup (gimp_object_get_name (GIMP_OBJECT (vectors)));
else
success = FALSE;
}
@ -532,7 +596,20 @@ HELP
);
$inargs[0]->{desc} = 'The ID of the image to list delete the paths from';
%invoke = ( code => 'success = path_delete_path (gimage, pname);' );
%invoke = (
vars => [ 'GimpVectors *vectors' ],
code => <<'CODE'
{
vectors = (GimpVectors *)
gimp_container_get_child_by_name (gimage->vectors, pname);
if (vectors)
gimp_image_remove_vectors (gimage, vectors);
else
success = FALSE;
}
CODE
);
}
sub path_get_locked {
@ -557,32 +634,14 @@ HELP
);
%invoke = (
vars => [ 'PathList *plist', 'Path *pptr = NULL' ],
vars => [ 'GimpVectors *vectors' ],
code => <<'CODE'
{
/* Get the path with the given name */
plist = gimage->paths;
if (plist && plist->bz_paths)
{
GSList *pl = plist->bz_paths;
vectors = (GimpVectors *)
gimp_container_get_child_by_name (gimage->vectors, pname);
while (pl)
{
pptr = pl->data;
if (!strcmp (pname, pptr->name))
break; /* Found the path */
pl = pl->next;
pptr = NULL;
}
if (pl && pptr)
lockstatus = pptr->locked;
else
success = FALSE;
}
if (vectors)
lockstatus = gimp_item_get_linked (GIMP_ITEM (vectors));
else
success = FALSE;
}
@ -609,32 +668,14 @@ HELP
);
%invoke = (
vars => [ 'PathList *plist', 'Path *pptr = NULL' ],
vars => [ 'GimpVectors *vectors' ],
code => <<'CODE'
{
/* Get the path with the given name */
plist = gimage->paths;
if (plist && plist->bz_paths)
{
GSList *pl = plist->bz_paths;
vectors = (GimpVectors *)
gimp_container_get_child_by_name (gimage->vectors, pname);
while (pl)
{
pptr = pl->data;
if (!strcmp (pname, pptr->name))
break; /* Found the path */
pl = pl->next;
pptr = NULL;
}
if (pl && pptr && lockstatus >=0 && lockstatus <= 1)
pptr->locked = lockstatus;
else
success = FALSE;
}
if (vectors)
gimp_item_set_linked (GIMP_ITEM (vectors), lockstatus, TRUE);
else
success = FALSE;
}
@ -642,133 +683,17 @@ CODE
);
}
# This PDB function (path_get_status) should not be generated.
# Currently it can easily introduce instability into the gimp if used
# with wrong values.
# I 'think' that path_set_points sets the status cirrectly for the path
# anyways.
@headers = qw(<string.h> "core/gimp.h" "core/gimpcontext.h" "core/gimplist.h"
"core/gimppaintinfo.h" "core/gimptoolinfo.h"
"paint/gimppaintcore-stroke.h" "paint/gimppaintoptions.h"
"vectors/gimpanchor.h" "vectors/gimpbezierstroke.h"
"vectors/gimpvectors.h");
sub path_get_status {
$blurb = 'Returns the edit status associated with the name path.';
$help = <<'HELP';
This procedure returns the edit status associated with the specified path. The value returned here should only be used in a corresponding 'path_set_status' call.
HELP
&pdb_misc;
@inargs = (
&std_image_arg,
{ name => 'pathname', type => 'string',
desc => 'the name of the path whose edit status should be obtained',
alias => 'pname' }
);
@outargs = (
{ name => 'editstatus', type => 'int32',
desc => 'The edit status associated with the name path.', init => 1 }
);
%invoke = (
vars => [ 'PathList *plist', 'Path *pptr = NULL' ],
code => <<'CODE'
{
/* Get the path with the given name */
plist = gimage->paths;
if (plist && plist->bz_paths)
{
GSList *pl = plist->bz_paths;
while (pl)
{
pptr = pl->data;
if (!strcmp (pname, pptr->name))
break; /* Found the path */
pl = pl->next;
pptr = NULL;
}
if (pl && pptr)
editstatus = pptr->state;
else
success = FALSE;
}
else
success = FALSE;
}
CODE
);
}
# This PDB function (path_set_status) should not be generated.
# Currently it can easily introduce instability into the gimp if used
# with wrong values.
# I 'think' that path_set_points sets the status cirrectly for the path
# anyways.
sub path_set_status {
$blurb = 'Set the edit status associated with the name path.';
$help = <<'HELP';
This procedure sets the edit status associated with the specified path. Caution must be exercised when using this function since an incorrect internal state of a path could result in undefined behaviour in the path tool. This method should only be used after a new path has been added (for example from a saved file) and then only values returned from 'path_get_status' called before the path was saved should be used.
HELP
&pdb_misc;
@inargs = (
&std_image_arg,
{ name => 'pathname', type => 'string',
desc => 'the name of the path whose locked status should be set',
alias => 'pname' },
{ name => 'editstatus', type => 'int32',
desc => 'The edit status associated with the name path. Only values returned from \'path_get_status\' should be used here', init => 1 }
);
%invoke = (
vars => [ 'PathList *plist', 'Path *pptr = NULL' ],
code => <<'CODE'
{
/* Get the path with the given name */
plist = gimage->paths;
if (plist && plist->bz_paths)
{
GSList *pl = plist->bz_paths;
while (pl)
{
pptr = pl->data;
if (!strcmp (pname, pptr->name))
break; /* Found the path */
pl = pl->next;
pptr = NULL;
}
if (pl && pptr)
pptr->state = editstatus;
else
success = FALSE;
}
else
success = FALSE;
}
CODE
);
}
@headers = qw(<string.h> "path.h" "pathP.h" "tools/tools-types.h");
@procs = qw(path_list path_get_points path_get_current path_set_current
path_set_points path_stroke_current path_get_point_at_dist
path_get_tattoo get_path_by_tattoo path_delete path_get_locked
path_set_locked path_set_tattoo);
@procs = qw(path_list path_get_current path_set_current path_delete
path_get_points path_set_points
path_stroke_current path_get_point_at_dist
path_get_tattoo path_set_tattoo get_path_by_tattoo
path_get_locked path_set_locked);
%exports = (app => [@procs], lib => [@procs]);
$desc = 'Paths';