Commit caa989ef authored by Simon Budig's avatar Simon Budig Committed by Simon Budig
Browse files

Make gimp_vectors_get_strokes() work, add gimp_vectors_stroke_translate()

2005-05-17  Simon Budig  <simon@gimp.org>

	* tools/pdbgen/pdb/vectors.pdb: Make gimp_vectors_get_strokes()
	work, add gimp_vectors_stroke_translate()  (I am not sure if this
	stays in the API, I am currently testing undo and freeze/thaw
	issues...)

	* app/pdb/internal_procs.c
	* app/pdb/vectors_cmds.c
	* libgimp/gimpvectors_pdb.[ch]: regenerated.
parent 13618e91
2005-05-17 Simon Budig <simon@gimp.org>
* tools/pdbgen/pdb/vectors.pdb: Make gimp_vectors_get_strokes()
work, add gimp_vectors_stroke_translate() (I am not sure if this
stays in the API, I am currently testing undo and freeze/thaw
issues...)
* app/pdb/internal_procs.c
* app/pdb/vectors_cmds.c
* libgimp/gimpvectors_pdb.[ch]: regenerated.
2005-05-17 Simon Budig <simon@gimp.org>
* app/vectors/gimpvectors.[ch]: added gimp_vectors_get_n_strokes ();
......
......@@ -75,7 +75,7 @@ void register_undo_procs (Gimp *gimp);
void register_unit_procs (Gimp *gimp);
void register_vectors_procs (Gimp *gimp);
/* 459 procedures registered total */
/* 460 procedures registered total */
void
internal_procs_init (Gimp *gimp,
......@@ -93,7 +93,7 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Brushes"), 0.054);
register_brushes_procs (gimp);
(* status_callback) (NULL, _("Channel"), 0.068);
(* status_callback) (NULL, _("Channel"), 0.067);
register_channel_procs (gimp);
(* status_callback) (NULL, _("Color"), 0.089);
......@@ -105,7 +105,7 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Convert"), 0.172);
register_convert_procs (gimp);
(* status_callback) (NULL, _("Display procedures"), 0.179);
(* status_callback) (NULL, _("Display procedures"), 0.178);
register_display_procs (gimp);
(* status_callback) (NULL, _("Drawable procedures"), 0.187);
......@@ -117,103 +117,103 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Edit procedures"), 0.296);
register_edit_procs (gimp);
(* status_callback) (NULL, _("File Operations"), 0.316);
(* status_callback) (NULL, _("File Operations"), 0.315);
register_fileops_procs (gimp);
(* status_callback) (NULL, _("Floating selections"), 0.338);
(* status_callback) (NULL, _("Floating selections"), 0.337);
register_floating_sel_procs (gimp);
(* status_callback) (NULL, _("Font UI"), 0.351);
(* status_callback) (NULL, _("Font UI"), 0.35);
register_font_select_procs (gimp);
(* status_callback) (NULL, _("Fonts"), 0.357);
register_fonts_procs (gimp);
(* status_callback) (NULL, _("Gimprc procedures"), 0.362);
(* status_callback) (NULL, _("Gimprc procedures"), 0.361);
register_gimprc_procs (gimp);
(* status_callback) (NULL, _("Gradient"), 0.375);
(* status_callback) (NULL, _("Gradient"), 0.374);
register_gradient_procs (gimp);
(* status_callback) (NULL, _("Gradient UI"), 0.44);
(* status_callback) (NULL, _("Gradient UI"), 0.439);
register_gradient_select_procs (gimp);
(* status_callback) (NULL, _("Gradients"), 0.447);
(* status_callback) (NULL, _("Gradients"), 0.446);
register_gradients_procs (gimp);
(* status_callback) (NULL, _("Guide procedures"), 0.458);
(* status_callback) (NULL, _("Guide procedures"), 0.457);
register_guides_procs (gimp);
(* status_callback) (NULL, _("Help procedures"), 0.471);
(* status_callback) (NULL, _("Help procedures"), 0.47);
register_help_procs (gimp);
(* status_callback) (NULL, _("Image"), 0.473);
(* status_callback) (NULL, _("Image"), 0.472);
register_image_procs (gimp);
(* status_callback) (NULL, _("Layer"), 0.61);
(* status_callback) (NULL, _("Layer"), 0.609);
register_layer_procs (gimp);
(* status_callback) (NULL, _("Message procedures"), 0.669);
(* status_callback) (NULL, _("Message procedures"), 0.667);
register_message_procs (gimp);
(* status_callback) (NULL, _("Miscellaneous"), 0.675);
(* status_callback) (NULL, _("Miscellaneous"), 0.674);
register_misc_procs (gimp);
(* status_callback) (NULL, _("Paint Tool procedures"), 0.68);
(* status_callback) (NULL, _("Paint Tool procedures"), 0.678);
register_paint_tools_procs (gimp);
(* status_callback) (NULL, _("Palette"), 0.712);
(* status_callback) (NULL, _("Palette"), 0.711);
register_palette_procs (gimp);
(* status_callback) (NULL, _("Palette UI"), 0.743);
(* status_callback) (NULL, _("Palette UI"), 0.741);
register_palette_select_procs (gimp);
(* status_callback) (NULL, _("Palettes"), 0.749);
(* status_callback) (NULL, _("Palettes"), 0.748);
register_palettes_procs (gimp);
(* status_callback) (NULL, _("Parasite procedures"), 0.758);
(* status_callback) (NULL, _("Parasite procedures"), 0.757);
register_parasite_procs (gimp);
(* status_callback) (NULL, _("Paths"), 0.784);
(* status_callback) (NULL, _("Paths"), 0.783);
register_paths_procs (gimp);
(* status_callback) (NULL, _("Pattern"), 0.819);
(* status_callback) (NULL, _("Pattern"), 0.817);
register_pattern_procs (gimp);
(* status_callback) (NULL, _("Pattern UI"), 0.824);
(* status_callback) (NULL, _("Pattern UI"), 0.822);
register_pattern_select_procs (gimp);
(* status_callback) (NULL, _("Patterns"), 0.83);
(* status_callback) (NULL, _("Patterns"), 0.828);
register_patterns_procs (gimp);
(* status_callback) (NULL, _("Plug-in"), 0.839);
(* status_callback) (NULL, _("Plug-in"), 0.837);
register_plug_in_procs (gimp);
(* status_callback) (NULL, _("Procedural database"), 0.852);
(* status_callback) (NULL, _("Procedural database"), 0.85);
register_procedural_db_procs (gimp);
(* status_callback) (NULL, _("Progress"), 0.871);
(* status_callback) (NULL, _("Progress"), 0.87);
register_progress_procs (gimp);
(* status_callback) (NULL, _("Image mask"), 0.887);
(* status_callback) (NULL, _("Image mask"), 0.885);
register_selection_procs (gimp);
(* status_callback) (NULL, _("Selection Tool procedures"), 0.924);
(* status_callback) (NULL, _("Selection Tool procedures"), 0.922);
register_selection_tools_procs (gimp);
(* status_callback) (NULL, _("Text procedures"), 0.935);
(* status_callback) (NULL, _("Text procedures"), 0.933);
register_text_tool_procs (gimp);
(* status_callback) (NULL, _("Transform Tool procedures"), 0.943);
(* status_callback) (NULL, _("Transform Tool procedures"), 0.941);
register_transform_tools_procs (gimp);
(* status_callback) (NULL, _("Undo"), 0.956);
(* status_callback) (NULL, _("Undo"), 0.954);
register_undo_procs (gimp);
(* status_callback) (NULL, _("Units"), 0.972);
(* status_callback) (NULL, _("Units"), 0.97);
register_unit_procs (gimp);
(* status_callback) (NULL, _("Paths"), 0.998);
(* status_callback) (NULL, _("Paths"), 0.996);
register_vectors_procs (gimp);
}
......@@ -28,6 +28,7 @@
#include "procedural_db.h"
#include "core/gimp.h"
#include "core/gimpimage-undo.h"
#include "core/gimplist.h"
#include "gimp-intl.h"
#include "vectors/gimpanchor.h"
......@@ -36,11 +37,13 @@
#include "vectors/gimpvectors.h"
static ProcRecord vectors_get_strokes_proc;
static ProcRecord vectors_stroke_translate_proc;
void
register_vectors_procs (Gimp *gimp)
{
procedural_db_register (gimp, &vectors_get_strokes_proc);
procedural_db_register (gimp, &vectors_stroke_translate_proc);
}
static Argument *
......@@ -54,7 +57,7 @@ vectors_get_strokes_invoker (Gimp *gimp,
GimpVectors *vectors;
gint32 num_strokes = 0;
gint32 *stroke_ids = NULL;
gint i;
gint i = 0;
GimpStroke *cur_stroke = NULL;
vectors = (GimpVectors *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
......@@ -74,9 +77,8 @@ vectors_get_strokes_invoker (Gimp *gimp,
cur_stroke = gimp_vectors_stroke_get_next (vectors, cur_stroke))
{
stroke_ids[i] = gimp_stroke_get_ID (cur_stroke);
g_printerr ("%d ", gimp_stroke_get_ID (cur_stroke));
i++;
}
g_printerr ("\n");
}
}
......@@ -130,3 +132,92 @@ static ProcRecord vectors_get_strokes_proc =
vectors_get_strokes_outargs,
{ { vectors_get_strokes_invoker } }
};
static Argument *
vectors_stroke_translate_invoker (Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
Argument *args)
{
gboolean success = TRUE;
GimpVectors *vectors;
gint32 stroke_id;
gint32 offx;
gint32 offy;
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;
offx = args[2].value.pdb_int;
offy = 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, offx, offy);
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,
"offx",
"Offset in x direction"
},
{
GIMP_PDB_INT32,
"offy",
"Offset in y direction"
}
};
static ProcRecord vectors_stroke_translate_proc =
{
"gimp_vectors_stroke_translate",
"return coordinates along the given stroke.",
"Returns a lot of coordinates along the passed stroke.",
"Simon Budig",
"Simon Budig",
"2005",
NULL,
GIMP_INTERNAL,
4,
vectors_stroke_translate_inargs,
0,
NULL,
{ { vectors_stroke_translate_invoker } }
};
......@@ -68,3 +68,43 @@ gimp_vectors_get_strokes (gint32 vectors_ID,
return stroke_ids;
}
/**
* gimp_vectors_stroke_translate:
* @vectors_ID: The vectors object.
* @stroke_id: The stroke ID.
* @offx: Offset in x direction.
* @offy: Offset in y direction.
*
* return coordinates along the given stroke.
*
* Returns a lot of coordinates along the passed stroke.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.4
*/
gboolean
gimp_vectors_stroke_translate (gint32 vectors_ID,
gint stroke_id,
gint offx,
gint offy)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_vectors_stroke_translate",
&nreturn_vals,
GIMP_PDB_PATH, vectors_ID,
GIMP_PDB_INT32, stroke_id,
GIMP_PDB_INT32, offx,
GIMP_PDB_INT32, offy,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
......@@ -29,8 +29,12 @@ G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gint* gimp_vectors_get_strokes (gint32 vectors_ID,
gint *num_strokes);
gint* gimp_vectors_get_strokes (gint32 vectors_ID,
gint *num_strokes);
gboolean gimp_vectors_stroke_translate (gint32 vectors_ID,
gint stroke_id,
gint offx,
gint offy);
G_END_DECLS
......
......@@ -30,6 +30,14 @@ sub vectors_arg () {{
desc => 'The vectors object'
}}
sub stroke_arg () {
&vectors_arg,
{
name => 'stroke_id',
type => 'int32',
desc => 'The stroke ID'
}}
sub vectors_get_strokes {
$blurb = 'List the strokes associated with the passed path.';
......@@ -51,7 +59,7 @@ HELP
);
%invoke = (
vars => ['gint i', 'GimpStroke *cur_stroke = NULL'],
vars => ['gint i = 0', 'GimpStroke *cur_stroke = NULL'],
code => <<"CODE"
{
num_strokes = gimp_vectors_get_n_strokes (vectors);
......@@ -65,22 +73,66 @@ HELP
cur_stroke = gimp_vectors_stroke_get_next (vectors, cur_stroke))
{
stroke_ids[i] = gimp_stroke_get_ID (cur_stroke);
g_printerr ("%d ", gimp_stroke_get_ID (cur_stroke));
i++;
}
g_printerr ("\\n");
}
}
CODE
);
}
sub vectors_stroke_translate {
$blurb = 'return coordinates along the given stroke.';
$help = <<'HELP';
Returns a lot of coordinates along the passed stroke.
HELP
&pdb_misc;
@inargs = ( &stroke_arg );
foreach (qw(x y)) {
push @inargs, { name => "off$_", type => 'int32',
desc => "Offset in $_ direction" }
}
%invoke = (
vars => [ 'GimpStroke *stroke' ],
code => <<"CODE"
{
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, offx, offy);
gimp_vectors_thaw (vectors);
gimp_image_undo_group_end (gimage);
}
}
CODE
);
}
@headers = qw(<string.h> "core/gimp.h" "core/gimplist.h"
"core/gimpimage-undo.h"
"vectors/gimpanchor.h" "vectors/gimpbezierstroke.h"
"vectors/gimpvectors.h" "vectors/gimpvectors-compat.h"
"gimp-intl.h");
@procs = qw(vectors_get_strokes
vectors_stroke_translate
);
%exports = (app => [@procs], lib => [@procs]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment