mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-22 12:32:37 +00:00
cbea67912b
2005-12-28 Simon Budig <simon@gimp.org> * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/vectors.pdb: Added new functions for the vectors PDB API. Minor cleanups. Please try to use them and test: gimp_image_get_active_vectors gimp_image_set_active_vectors gimp_image_get_vectors_by_tattoo gimp_image_lower_vectors gimp_image_lower_vectors_to_bottom gimp_image_raise_vectors gimp_image_raise_vectors_to_top gimp_image_remove_vectors gimp_vectors_get_locked gimp_vectors_set_locked gimp_vectors_get_name gimp_vectors_set_name gimp_vectors_get_visible gimp_vectors_set_visible gimp_vectors_stroke_get_length gimp_vectors_stroke_remove gimp_vectors_stroke_scale * libgimp/gimp.[ch]: renamed the unused d_path to d_vectors and use it. Untabbified. * devel-docs/libgimp/tmpl/gimpvectors.sgml * app/pdb/image_cmds.c * app/pdb/internal_procs.c * app/pdb/vectors_cmds.c * libgimp/gimpimage_pdb.[ch] * libgimp/gimpvectors_pdb.[ch]: Regenerated * app/vectors/gimpstroke.h: minor cleanup.
979 lines
23 KiB
C
979 lines
23 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 "procedural_db.h"
|
|
|
|
#include "core/gimp.h"
|
|
#include "core/gimpimage-undo.h"
|
|
#include "core/gimpimage.h"
|
|
#include "core/gimplist.h"
|
|
#include "gimp-intl.h"
|
|
#include "vectors/gimpanchor.h"
|
|
#include "vectors/gimpbezierstroke.h"
|
|
#include "vectors/gimpvectors-compat.h"
|
|
#include "vectors/gimpvectors.h"
|
|
|
|
static ProcRecord vectors_get_strokes_proc;
|
|
static ProcRecord vectors_get_locked_proc;
|
|
static ProcRecord vectors_set_locked_proc;
|
|
static ProcRecord vectors_get_visible_proc;
|
|
static ProcRecord vectors_set_visible_proc;
|
|
static ProcRecord vectors_get_name_proc;
|
|
static ProcRecord vectors_set_name_proc;
|
|
static ProcRecord vectors_stroke_get_length_proc;
|
|
static ProcRecord vectors_stroke_remove_proc;
|
|
static ProcRecord vectors_stroke_translate_proc;
|
|
static ProcRecord vectors_stroke_scale_proc;
|
|
static ProcRecord vectors_stroke_interpolate_proc;
|
|
|
|
void
|
|
register_vectors_procs (Gimp *gimp)
|
|
{
|
|
procedural_db_register (gimp, &vectors_get_strokes_proc);
|
|
procedural_db_register (gimp, &vectors_get_locked_proc);
|
|
procedural_db_register (gimp, &vectors_set_locked_proc);
|
|
procedural_db_register (gimp, &vectors_get_visible_proc);
|
|
procedural_db_register (gimp, &vectors_set_visible_proc);
|
|
procedural_db_register (gimp, &vectors_get_name_proc);
|
|
procedural_db_register (gimp, &vectors_set_name_proc);
|
|
procedural_db_register (gimp, &vectors_stroke_get_length_proc);
|
|
procedural_db_register (gimp, &vectors_stroke_remove_proc);
|
|
procedural_db_register (gimp, &vectors_stroke_translate_proc);
|
|
procedural_db_register (gimp, &vectors_stroke_scale_proc);
|
|
procedural_db_register (gimp, &vectors_stroke_interpolate_proc);
|
|
}
|
|
|
|
static Argument *
|
|
vectors_get_strokes_invoker (Gimp *gimp,
|
|
GimpContext *context,
|
|
GimpProgress *progress,
|
|
Argument *args)
|
|
{
|
|
gboolean success = TRUE;
|
|
Argument *return_args;
|
|
GimpVectors *vectors;
|
|
gint32 num_strokes = 0;
|
|
gint32 *stroke_ids = NULL;
|
|
gint i = 0;
|
|
GimpStroke *cur_stroke = NULL;
|
|
|
|
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
|
|
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
|
|
success = FALSE;
|
|
|
|
if (success)
|
|
{
|
|
num_strokes = gimp_vectors_get_n_strokes (vectors);
|
|
|
|
if (num_strokes)
|
|
{
|
|
stroke_ids = g_new (gint32, num_strokes);
|
|
|
|
for (cur_stroke = gimp_vectors_stroke_get_next (vectors, NULL);
|
|
cur_stroke;
|
|
cur_stroke = gimp_vectors_stroke_get_next (vectors, cur_stroke))
|
|
{
|
|
stroke_ids[i] = gimp_stroke_get_ID (cur_stroke);
|
|
i++;
|
|
}
|
|
}
|
|
}
|
|
|
|
return_args = procedural_db_return_args (&vectors_get_strokes_proc, success);
|
|
|
|
if (success)
|
|
{
|
|
return_args[1].value.pdb_int = num_strokes;
|
|
return_args[2].value.pdb_pointer = stroke_ids;
|
|
}
|
|
|
|
return return_args;
|
|
}
|
|
|
|
static ProcArg vectors_get_strokes_inargs[] =
|
|
{
|
|
{
|
|
GIMP_PDB_PATH,
|
|
"vectors",
|
|
"The vectors object"
|
|
}
|
|
};
|
|
|
|
static ProcArg vectors_get_strokes_outargs[] =
|
|
{
|
|
{
|
|
GIMP_PDB_INT32,
|
|
"num-strokes",
|
|
"The number of strokes returned."
|
|
},
|
|
{
|
|
GIMP_PDB_INT32ARRAY,
|
|
"stroke-ids",
|
|
"List of the strokes belonging to the path."
|
|
}
|
|
};
|
|
|
|
static ProcRecord vectors_get_strokes_proc =
|
|
{
|
|
"gimp-vectors-get-strokes",
|
|
"gimp-vectors-get-strokes",
|
|
"List the strokes associated with the passed path.",
|
|
"Returns an Array with the stroke-IDs associated with the passed path.",
|
|
"Simon Budig",
|
|
"Simon Budig",
|
|
"2005",
|
|
NULL,
|
|
GIMP_INTERNAL,
|
|
1,
|
|
vectors_get_strokes_inargs,
|
|
2,
|
|
vectors_get_strokes_outargs,
|
|
{ { vectors_get_strokes_invoker } }
|
|
};
|
|
|
|
static Argument *
|
|
vectors_get_locked_invoker (Gimp *gimp,
|
|
GimpContext *context,
|
|
GimpProgress *progress,
|
|
Argument *args)
|
|
{
|
|
gboolean success = TRUE;
|
|
Argument *return_args;
|
|
GimpVectors *vectors;
|
|
gboolean locked = FALSE;
|
|
|
|
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
|
|
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
|
|
success = FALSE;
|
|
|
|
if (success)
|
|
{
|
|
locked = gimp_item_get_linked (GIMP_ITEM (vectors));
|
|
}
|
|
|
|
return_args = procedural_db_return_args (&vectors_get_locked_proc, success);
|
|
|
|
if (success)
|
|
return_args[1].value.pdb_int = locked;
|
|
|
|
return return_args;
|
|
}
|
|
|
|
static ProcArg vectors_get_locked_inargs[] =
|
|
{
|
|
{
|
|
GIMP_PDB_PATH,
|
|
"vectors",
|
|
"The vectors object"
|
|
}
|
|
};
|
|
|
|
static ProcArg vectors_get_locked_outargs[] =
|
|
{
|
|
{
|
|
GIMP_PDB_INT32,
|
|
"locked",
|
|
"TRUE if the path is locked, FALSE otherwise"
|
|
}
|
|
};
|
|
|
|
static ProcRecord vectors_get_locked_proc =
|
|
{
|
|
"gimp-vectors-get-locked",
|
|
"gimp-vectors-get-locked",
|
|
"Gets the locking state of the vectors object.",
|
|
"Gets the locking state of the vectors object.",
|
|
"Simon Budig",
|
|
"Simon Budig",
|
|
"2005",
|
|
NULL,
|
|
GIMP_INTERNAL,
|
|
1,
|
|
vectors_get_locked_inargs,
|
|
1,
|
|
vectors_get_locked_outargs,
|
|
{ { vectors_get_locked_invoker } }
|
|
};
|
|
|
|
static Argument *
|
|
vectors_set_locked_invoker (Gimp *gimp,
|
|
GimpContext *context,
|
|
GimpProgress *progress,
|
|
Argument *args)
|
|
{
|
|
gboolean success = TRUE;
|
|
GimpVectors *vectors;
|
|
gboolean locked = FALSE;
|
|
|
|
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
|
|
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
|
|
success = FALSE;
|
|
|
|
locked = args[1].value.pdb_int ? TRUE : FALSE;
|
|
|
|
if (success)
|
|
{
|
|
gimp_item_set_linked (GIMP_ITEM (vectors), locked, TRUE);
|
|
}
|
|
|
|
return procedural_db_return_args (&vectors_set_locked_proc, success);
|
|
}
|
|
|
|
static ProcArg vectors_set_locked_inargs[] =
|
|
{
|
|
{
|
|
GIMP_PDB_PATH,
|
|
"vectors",
|
|
"The vectors object"
|
|
},
|
|
{
|
|
GIMP_PDB_INT32,
|
|
"locked",
|
|
"Whether the path is locked"
|
|
}
|
|
};
|
|
|
|
static ProcRecord vectors_set_locked_proc =
|
|
{
|
|
"gimp-vectors-set-locked",
|
|
"gimp-vectors-set-locked",
|
|
"Sets the locking state of the vectors object.",
|
|
"Sets the locking state of the vectors object.",
|
|
"Simon Budig",
|
|
"Simon Budig",
|
|
"2005",
|
|
NULL,
|
|
GIMP_INTERNAL,
|
|
2,
|
|
vectors_set_locked_inargs,
|
|
0,
|
|
NULL,
|
|
{ { vectors_set_locked_invoker } }
|
|
};
|
|
|
|
static Argument *
|
|
vectors_get_visible_invoker (Gimp *gimp,
|
|
GimpContext *context,
|
|
GimpProgress *progress,
|
|
Argument *args)
|
|
{
|
|
gboolean success = TRUE;
|
|
Argument *return_args;
|
|
GimpVectors *vectors;
|
|
gboolean visible = FALSE;
|
|
|
|
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
|
|
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
|
|
success = FALSE;
|
|
|
|
if (success)
|
|
{
|
|
visible = gimp_item_get_visible (GIMP_ITEM (vectors));
|
|
}
|
|
|
|
return_args = procedural_db_return_args (&vectors_get_visible_proc, success);
|
|
|
|
if (success)
|
|
return_args[1].value.pdb_int = visible;
|
|
|
|
return return_args;
|
|
}
|
|
|
|
static ProcArg vectors_get_visible_inargs[] =
|
|
{
|
|
{
|
|
GIMP_PDB_PATH,
|
|
"vectors",
|
|
"The vectors object"
|
|
}
|
|
};
|
|
|
|
static ProcArg vectors_get_visible_outargs[] =
|
|
{
|
|
{
|
|
GIMP_PDB_INT32,
|
|
"visible",
|
|
"TRUE if the path is visible, FALSE otherwise"
|
|
}
|
|
};
|
|
|
|
static ProcRecord vectors_get_visible_proc =
|
|
{
|
|
"gimp-vectors-get-visible",
|
|
"gimp-vectors-get-visible",
|
|
"Gets the visibility of the vectors object.",
|
|
"Gets the visibility of the vectors object.",
|
|
"Simon Budig",
|
|
"Simon Budig",
|
|
"2005",
|
|
NULL,
|
|
GIMP_INTERNAL,
|
|
1,
|
|
vectors_get_visible_inargs,
|
|
1,
|
|
vectors_get_visible_outargs,
|
|
{ { vectors_get_visible_invoker } }
|
|
};
|
|
|
|
static Argument *
|
|
vectors_set_visible_invoker (Gimp *gimp,
|
|
GimpContext *context,
|
|
GimpProgress *progress,
|
|
Argument *args)
|
|
{
|
|
gboolean success = TRUE;
|
|
GimpVectors *vectors;
|
|
gboolean visible = FALSE;
|
|
|
|
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
|
|
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
|
|
success = FALSE;
|
|
|
|
visible = args[1].value.pdb_int ? TRUE : FALSE;
|
|
|
|
if (success)
|
|
{
|
|
gimp_item_set_visible (GIMP_ITEM (vectors), visible, TRUE);
|
|
}
|
|
|
|
return procedural_db_return_args (&vectors_set_visible_proc, success);
|
|
}
|
|
|
|
static ProcArg vectors_set_visible_inargs[] =
|
|
{
|
|
{
|
|
GIMP_PDB_PATH,
|
|
"vectors",
|
|
"The vectors object"
|
|
},
|
|
{
|
|
GIMP_PDB_INT32,
|
|
"visible",
|
|
"Whether the path is visible"
|
|
}
|
|
};
|
|
|
|
static ProcRecord vectors_set_visible_proc =
|
|
{
|
|
"gimp-vectors-set-visible",
|
|
"gimp-vectors-set-visible",
|
|
"Sets the visibility of the vectors object.",
|
|
"Sets the visibility of the vectors object.",
|
|
"Simon Budig",
|
|
"Simon Budig",
|
|
"2005",
|
|
NULL,
|
|
GIMP_INTERNAL,
|
|
2,
|
|
vectors_set_visible_inargs,
|
|
0,
|
|
NULL,
|
|
{ { vectors_set_visible_invoker } }
|
|
};
|
|
|
|
static Argument *
|
|
vectors_get_name_invoker (Gimp *gimp,
|
|
GimpContext *context,
|
|
GimpProgress *progress,
|
|
Argument *args)
|
|
{
|
|
gboolean success = TRUE;
|
|
Argument *return_args;
|
|
GimpVectors *vectors;
|
|
gchar *name = NULL;
|
|
|
|
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
|
|
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
|
|
success = FALSE;
|
|
|
|
if (success)
|
|
{
|
|
name = g_strdup (gimp_object_get_name (GIMP_OBJECT (vectors)));
|
|
}
|
|
|
|
return_args = procedural_db_return_args (&vectors_get_name_proc, success);
|
|
|
|
if (success)
|
|
return_args[1].value.pdb_pointer = name;
|
|
|
|
return return_args;
|
|
}
|
|
|
|
static ProcArg vectors_get_name_inargs[] =
|
|
{
|
|
{
|
|
GIMP_PDB_PATH,
|
|
"vectors",
|
|
"The vectors object"
|
|
}
|
|
};
|
|
|
|
static ProcArg vectors_get_name_outargs[] =
|
|
{
|
|
{
|
|
GIMP_PDB_STRING,
|
|
"name",
|
|
"The name of the vectors object"
|
|
}
|
|
};
|
|
|
|
static ProcRecord vectors_get_name_proc =
|
|
{
|
|
"gimp-vectors-get-name",
|
|
"gimp-vectors-get-name",
|
|
"Gets the name of the vectors object.",
|
|
"Gets the name of the vectors object.",
|
|
"Simon Budig",
|
|
"Simon Budig",
|
|
"2005",
|
|
NULL,
|
|
GIMP_INTERNAL,
|
|
1,
|
|
vectors_get_name_inargs,
|
|
1,
|
|
vectors_get_name_outargs,
|
|
{ { vectors_get_name_invoker } }
|
|
};
|
|
|
|
static Argument *
|
|
vectors_set_name_invoker (Gimp *gimp,
|
|
GimpContext *context,
|
|
GimpProgress *progress,
|
|
Argument *args)
|
|
{
|
|
gboolean success = TRUE;
|
|
GimpVectors *vectors;
|
|
gchar *name = NULL;
|
|
|
|
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
|
|
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
|
|
success = FALSE;
|
|
|
|
name = (gchar *) args[1].value.pdb_pointer;
|
|
if (name == NULL || !g_utf8_validate (name, -1, NULL))
|
|
success = FALSE;
|
|
|
|
if (success)
|
|
{
|
|
if (!gimp_item_rename (GIMP_ITEM (vectors), name))
|
|
success = FALSE;
|
|
}
|
|
|
|
return procedural_db_return_args (&vectors_set_name_proc, success);
|
|
}
|
|
|
|
static ProcArg vectors_set_name_inargs[] =
|
|
{
|
|
{
|
|
GIMP_PDB_PATH,
|
|
"vectors",
|
|
"The vectors object"
|
|
},
|
|
{
|
|
GIMP_PDB_STRING,
|
|
"name",
|
|
"the new name of the path"
|
|
}
|
|
};
|
|
|
|
static ProcRecord vectors_set_name_proc =
|
|
{
|
|
"gimp-vectors-set-name",
|
|
"gimp-vectors-set-name",
|
|
"Sets the name of the vectors object.",
|
|
"Sets the name of the vectors object.",
|
|
"Simon Budig",
|
|
"Simon Budig",
|
|
"2005",
|
|
NULL,
|
|
GIMP_INTERNAL,
|
|
2,
|
|
vectors_set_name_inargs,
|
|
0,
|
|
NULL,
|
|
{ { vectors_set_name_invoker } }
|
|
};
|
|
|
|
static Argument *
|
|
vectors_stroke_get_length_invoker (Gimp *gimp,
|
|
GimpContext *context,
|
|
GimpProgress *progress,
|
|
Argument *args)
|
|
{
|
|
gboolean success = TRUE;
|
|
Argument *return_args;
|
|
GimpVectors *vectors;
|
|
gint32 stroke_id;
|
|
gdouble prescision;
|
|
gdouble length;
|
|
GimpStroke *stroke;
|
|
|
|
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
|
|
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
|
|
success = FALSE;
|
|
|
|
stroke_id = args[1].value.pdb_int;
|
|
|
|
prescision = args[2].value.pdb_float;
|
|
|
|
if (success)
|
|
{
|
|
stroke = gimp_vectors_stroke_get_by_ID (vectors, stroke_id);
|
|
|
|
if (!stroke)
|
|
{
|
|
success = FALSE;
|
|
}
|
|
else
|
|
{
|
|
length = gimp_stroke_get_length (stroke, prescision);
|
|
}
|
|
}
|
|
|
|
return_args = procedural_db_return_args (&vectors_stroke_get_length_proc, success);
|
|
|
|
if (success)
|
|
return_args[1].value.pdb_float = length;
|
|
|
|
return return_args;
|
|
}
|
|
|
|
static ProcArg vectors_stroke_get_length_inargs[] =
|
|
{
|
|
{
|
|
GIMP_PDB_PATH,
|
|
"vectors",
|
|
"The vectors object"
|
|
},
|
|
{
|
|
GIMP_PDB_INT32,
|
|
"stroke-id",
|
|
"The stroke ID"
|
|
},
|
|
{
|
|
GIMP_PDB_FLOAT,
|
|
"prescision",
|
|
"The prescision used for the approximation"
|
|
}
|
|
};
|
|
|
|
static ProcArg vectors_stroke_get_length_outargs[] =
|
|
{
|
|
{
|
|
GIMP_PDB_FLOAT,
|
|
"length",
|
|
"The length (in pixels) of the given stroke."
|
|
}
|
|
};
|
|
|
|
static ProcRecord vectors_stroke_get_length_proc =
|
|
{
|
|
"gimp-vectors-stroke-get-length",
|
|
"gimp-vectors-stroke-get-length",
|
|
"measures the length of the given stroke.",
|
|
"Measure the length of the given stroke.",
|
|
"Simon Budig",
|
|
"Simon Budig",
|
|
"2005",
|
|
NULL,
|
|
GIMP_INTERNAL,
|
|
3,
|
|
vectors_stroke_get_length_inargs,
|
|
1,
|
|
vectors_stroke_get_length_outargs,
|
|
{ { vectors_stroke_get_length_invoker } }
|
|
};
|
|
|
|
static Argument *
|
|
vectors_stroke_remove_invoker (Gimp *gimp,
|
|
GimpContext *context,
|
|
GimpProgress *progress,
|
|
Argument *args)
|
|
{
|
|
gboolean success = TRUE;
|
|
GimpVectors *vectors;
|
|
gint32 stroke_id;
|
|
GimpStroke *stroke;
|
|
|
|
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
|
|
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
|
|
success = FALSE;
|
|
|
|
stroke_id = args[1].value.pdb_int;
|
|
|
|
if (success)
|
|
{
|
|
stroke = gimp_vectors_stroke_get_by_ID (vectors, stroke_id);
|
|
|
|
if (stroke)
|
|
gimp_vectors_stroke_remove (vectors, stroke);
|
|
else
|
|
success = FALSE;
|
|
}
|
|
|
|
return procedural_db_return_args (&vectors_stroke_remove_proc, success);
|
|
}
|
|
|
|
static ProcArg vectors_stroke_remove_inargs[] =
|
|
{
|
|
{
|
|
GIMP_PDB_PATH,
|
|
"vectors",
|
|
"The vectors object"
|
|
},
|
|
{
|
|
GIMP_PDB_INT32,
|
|
"stroke-id",
|
|
"The stroke ID"
|
|
}
|
|
};
|
|
|
|
static ProcRecord vectors_stroke_remove_proc =
|
|
{
|
|
"gimp-vectors-stroke-remove",
|
|
"gimp-vectors-stroke-remove",
|
|
"remove the stroke from a vectors object.",
|
|
"Remove the stroke from a vectors object.",
|
|
"Simon Budig",
|
|
"Simon Budig",
|
|
"2005",
|
|
NULL,
|
|
GIMP_INTERNAL,
|
|
2,
|
|
vectors_stroke_remove_inargs,
|
|
0,
|
|
NULL,
|
|
{ { vectors_stroke_remove_invoker } }
|
|
};
|
|
|
|
static Argument *
|
|
vectors_stroke_translate_invoker (Gimp *gimp,
|
|
GimpContext *context,
|
|
GimpProgress *progress,
|
|
Argument *args)
|
|
{
|
|
gboolean success = TRUE;
|
|
GimpVectors *vectors;
|
|
gint32 stroke_id;
|
|
gint32 off_x;
|
|
gint32 off_y;
|
|
GimpStroke *stroke;
|
|
|
|
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
|
|
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
|
|
success = FALSE;
|
|
|
|
stroke_id = args[1].value.pdb_int;
|
|
|
|
off_x = args[2].value.pdb_int;
|
|
|
|
off_y = args[3].value.pdb_int;
|
|
|
|
if (success)
|
|
{
|
|
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (vectors));
|
|
stroke = gimp_vectors_stroke_get_by_ID (vectors, stroke_id);
|
|
|
|
if (!stroke)
|
|
{
|
|
success = FALSE;
|
|
}
|
|
else
|
|
{
|
|
/* need to figure out how undo is supposed to work */
|
|
|
|
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_ITEM_DISPLACE,
|
|
_("Modify Path"));
|
|
gimp_vectors_freeze (vectors);
|
|
gimp_stroke_translate (stroke, off_x, off_y);
|
|
gimp_vectors_thaw (vectors);
|
|
gimp_image_undo_group_end (gimage);
|
|
}
|
|
}
|
|
|
|
return procedural_db_return_args (&vectors_stroke_translate_proc, success);
|
|
}
|
|
|
|
static ProcArg vectors_stroke_translate_inargs[] =
|
|
{
|
|
{
|
|
GIMP_PDB_PATH,
|
|
"vectors",
|
|
"The vectors object"
|
|
},
|
|
{
|
|
GIMP_PDB_INT32,
|
|
"stroke-id",
|
|
"The stroke ID"
|
|
},
|
|
{
|
|
GIMP_PDB_INT32,
|
|
"off-x",
|
|
"Offset in x direction"
|
|
},
|
|
{
|
|
GIMP_PDB_INT32,
|
|
"off-y",
|
|
"Offset in y direction"
|
|
}
|
|
};
|
|
|
|
static ProcRecord vectors_stroke_translate_proc =
|
|
{
|
|
"gimp-vectors-stroke-translate",
|
|
"gimp-vectors-stroke-translate",
|
|
"translate the given stroke.",
|
|
"Translate the given stroke.",
|
|
"Simon Budig",
|
|
"Simon Budig",
|
|
"2005",
|
|
NULL,
|
|
GIMP_INTERNAL,
|
|
4,
|
|
vectors_stroke_translate_inargs,
|
|
0,
|
|
NULL,
|
|
{ { vectors_stroke_translate_invoker } }
|
|
};
|
|
|
|
static Argument *
|
|
vectors_stroke_scale_invoker (Gimp *gimp,
|
|
GimpContext *context,
|
|
GimpProgress *progress,
|
|
Argument *args)
|
|
{
|
|
gboolean success = TRUE;
|
|
GimpVectors *vectors;
|
|
gint32 stroke_id;
|
|
gdouble scale_x;
|
|
gdouble scale_y;
|
|
GimpStroke *stroke;
|
|
|
|
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
|
|
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
|
|
success = FALSE;
|
|
|
|
stroke_id = args[1].value.pdb_int;
|
|
|
|
scale_x = args[2].value.pdb_float;
|
|
|
|
scale_y = args[3].value.pdb_float;
|
|
|
|
if (success)
|
|
{
|
|
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (vectors));
|
|
stroke = gimp_vectors_stroke_get_by_ID (vectors, stroke_id);
|
|
|
|
if (!stroke)
|
|
{
|
|
success = FALSE;
|
|
}
|
|
else
|
|
{
|
|
/* need to figure out how undo is supposed to work */
|
|
|
|
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_ITEM_DISPLACE,
|
|
_("Modify Path"));
|
|
gimp_vectors_freeze (vectors);
|
|
gimp_stroke_scale (stroke, scale_x, scale_y);
|
|
gimp_vectors_thaw (vectors);
|
|
gimp_image_undo_group_end (gimage);
|
|
}
|
|
}
|
|
|
|
return procedural_db_return_args (&vectors_stroke_scale_proc, success);
|
|
}
|
|
|
|
static ProcArg vectors_stroke_scale_inargs[] =
|
|
{
|
|
{
|
|
GIMP_PDB_PATH,
|
|
"vectors",
|
|
"The vectors object"
|
|
},
|
|
{
|
|
GIMP_PDB_INT32,
|
|
"stroke-id",
|
|
"The stroke ID"
|
|
},
|
|
{
|
|
GIMP_PDB_FLOAT,
|
|
"scale-x",
|
|
"Scale factor in x direction"
|
|
},
|
|
{
|
|
GIMP_PDB_FLOAT,
|
|
"scale-y",
|
|
"Scale factor in y direction"
|
|
}
|
|
};
|
|
|
|
static ProcRecord vectors_stroke_scale_proc =
|
|
{
|
|
"gimp-vectors-stroke-scale",
|
|
"gimp-vectors-stroke-scale",
|
|
"scales the given stroke.",
|
|
"Scale the given stroke.",
|
|
"Simon Budig",
|
|
"Simon Budig",
|
|
"2005",
|
|
NULL,
|
|
GIMP_INTERNAL,
|
|
4,
|
|
vectors_stroke_scale_inargs,
|
|
0,
|
|
NULL,
|
|
{ { vectors_stroke_scale_invoker } }
|
|
};
|
|
|
|
static Argument *
|
|
vectors_stroke_interpolate_invoker (Gimp *gimp,
|
|
GimpContext *context,
|
|
GimpProgress *progress,
|
|
Argument *args)
|
|
{
|
|
gboolean success = TRUE;
|
|
Argument *return_args;
|
|
GimpVectors *vectors;
|
|
gint32 stroke_id;
|
|
gdouble prescision;
|
|
gboolean closed;
|
|
gint32 num_coords = 0;
|
|
gdouble *coords = NULL;
|
|
GimpStroke *stroke;
|
|
GArray *coords_array;
|
|
gint i;
|
|
|
|
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
|
|
if (! (GIMP_IS_VECTORS (vectors) && ! gimp_item_is_removed (GIMP_ITEM (vectors))))
|
|
success = FALSE;
|
|
|
|
stroke_id = args[1].value.pdb_int;
|
|
|
|
prescision = args[2].value.pdb_float;
|
|
|
|
if (success)
|
|
{
|
|
stroke = gimp_vectors_stroke_get_by_ID (vectors, stroke_id);
|
|
|
|
if (stroke)
|
|
{
|
|
/* need to figure out how undo is supposed to work */
|
|
|
|
coords_array = gimp_stroke_interpolate (stroke, prescision, &closed);
|
|
if (coords_array)
|
|
{
|
|
num_coords = coords_array->len;
|
|
coords = g_new (gdouble, num_coords * 2);
|
|
|
|
for (i = 0; i < num_coords; i++)
|
|
{
|
|
coords[2*i] = g_array_index (coords_array, GimpCoords, i).x;
|
|
coords[2*i+1] = g_array_index (coords_array, GimpCoords, i).y;
|
|
}
|
|
g_array_free (coords_array, TRUE);
|
|
num_coords *= 2;
|
|
}
|
|
else
|
|
{
|
|
success = FALSE;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
success = FALSE;
|
|
}
|
|
}
|
|
|
|
return_args = procedural_db_return_args (&vectors_stroke_interpolate_proc, success);
|
|
|
|
if (success)
|
|
{
|
|
return_args[1].value.pdb_int = closed;
|
|
return_args[2].value.pdb_int = num_coords;
|
|
return_args[3].value.pdb_pointer = coords;
|
|
}
|
|
|
|
return return_args;
|
|
}
|
|
|
|
static ProcArg vectors_stroke_interpolate_inargs[] =
|
|
{
|
|
{
|
|
GIMP_PDB_PATH,
|
|
"vectors",
|
|
"The vectors object"
|
|
},
|
|
{
|
|
GIMP_PDB_INT32,
|
|
"stroke-id",
|
|
"The stroke ID"
|
|
},
|
|
{
|
|
GIMP_PDB_FLOAT,
|
|
"prescision",
|
|
"The prescision used for the approximation"
|
|
}
|
|
};
|
|
|
|
static ProcArg vectors_stroke_interpolate_outargs[] =
|
|
{
|
|
{
|
|
GIMP_PDB_INT32,
|
|
"closed",
|
|
"List of the strokes belonging to the path."
|
|
},
|
|
{
|
|
GIMP_PDB_INT32,
|
|
"num-coords",
|
|
"The number of floats returned."
|
|
},
|
|
{
|
|
GIMP_PDB_FLOATARRAY,
|
|
"coords",
|
|
"List of the coords along the path (x0, y0, x1, y1, ...)."
|
|
}
|
|
};
|
|
|
|
static ProcRecord vectors_stroke_interpolate_proc =
|
|
{
|
|
"gimp-vectors-stroke-interpolate",
|
|
"gimp-vectors-stroke-interpolate",
|
|
"returns polygonal approximation of the stroke.",
|
|
"returns polygonal approximation of the stroke.",
|
|
"Simon Budig",
|
|
"Simon Budig",
|
|
"2005",
|
|
NULL,
|
|
GIMP_INTERNAL,
|
|
3,
|
|
vectors_stroke_interpolate_inargs,
|
|
3,
|
|
vectors_stroke_interpolate_outargs,
|
|
{ { vectors_stroke_interpolate_invoker } }
|
|
};
|