Commit 41b549a7 authored by Simon Budig's avatar Simon Budig Committed by Simon Budig
Browse files

cosmetic change: Make the stroke IDs start from 1.

2005-06-01  Simon Budig  <simon@gimp.org>

	* app/vectors/gimpvectors.c: cosmetic change: Make the stroke IDs
	start from 1.

	* tools/pdbgen/pdb/vectors.pdb: Two more wrappers:
	vectors_stroke_remove and vectors_stroke_interpolate. Undo still
	unsolved.

	* app/pdb/internal_procs.c
	* app/pdb/vectors_cmds.c
	* libgimp/gimpvectors_pdb.[ch]: regenerated.
parent e70f5dcd
2005-06-01 Simon Budig <simon@gimp.org>
* app/vectors/gimpvectors.c: cosmetic change: Make the stroke IDs
start from 1.
* tools/pdbgen/pdb/vectors.pdb: Two more wrappers:
vectors_stroke_remove and vectors_stroke_interpolate. Undo still
unsolved.
* app/pdb/internal_procs.c
* app/pdb/vectors_cmds.c
* libgimp/gimpvectors_pdb.[ch]: regenerated.
2005-05-31 Bill Skaggs <weskaggs@primate.ucdavis.edu>
* app/tools/gimpbrightnesscontrasttool.[ch]: Allow tool to be
......
......@@ -75,7 +75,7 @@ void register_undo_procs (Gimp *gimp);
void register_unit_procs (Gimp *gimp);
void register_vectors_procs (Gimp *gimp);
/* 460 procedures registered total */
/* 462 procedures registered total */
void
internal_procs_init (Gimp *gimp,
......@@ -99,121 +99,121 @@ internal_procs_init (Gimp *gimp,
(* status_callback) (NULL, _("Color"), 0.089);
register_color_procs (gimp);
(* status_callback) (NULL, _("Context"), 0.124);
(* status_callback) (NULL, _("Context"), 0.123);
register_context_procs (gimp);
(* status_callback) (NULL, _("Convert"), 0.172);
(* status_callback) (NULL, _("Convert"), 0.171);
register_convert_procs (gimp);
(* status_callback) (NULL, _("Display procedures"), 0.178);
(* status_callback) (NULL, _("Display procedures"), 0.177);
register_display_procs (gimp);
(* status_callback) (NULL, _("Drawable procedures"), 0.187);
(* status_callback) (NULL, _("Drawable procedures"), 0.186);
register_drawable_procs (gimp);
(* status_callback) (NULL, _("Transformation procedures"), 0.261);
(* status_callback) (NULL, _("Transformation procedures"), 0.26);
register_drawable_transform_procs (gimp);
(* status_callback) (NULL, _("Edit procedures"), 0.296);
(* status_callback) (NULL, _("Edit procedures"), 0.294);
register_edit_procs (gimp);
(* status_callback) (NULL, _("File Operations"), 0.315);
(* status_callback) (NULL, _("File Operations"), 0.314);
register_fileops_procs (gimp);
(* status_callback) (NULL, _("Floating selections"), 0.337);
(* status_callback) (NULL, _("Floating selections"), 0.335);
register_floating_sel_procs (gimp);
(* status_callback) (NULL, _("Font UI"), 0.35);
(* status_callback) (NULL, _("Font UI"), 0.348);
register_font_select_procs (gimp);
(* status_callback) (NULL, _("Fonts"), 0.357);
(* status_callback) (NULL, _("Fonts"), 0.355);
register_fonts_procs (gimp);
(* status_callback) (NULL, _("Gimprc procedures"), 0.361);
(* status_callback) (NULL, _("Gimprc procedures"), 0.359);
register_gimprc_procs (gimp);
(* status_callback) (NULL, _("Gradient"), 0.374);
(* status_callback) (NULL, _("Gradient"), 0.372);
register_gradient_procs (gimp);
(* status_callback) (NULL, _("Gradient UI"), 0.439);
(* status_callback) (NULL, _("Gradient UI"), 0.437);
register_gradient_select_procs (gimp);
(* status_callback) (NULL, _("Gradients"), 0.446);
(* status_callback) (NULL, _("Gradients"), 0.444);
register_gradients_procs (gimp);
(* status_callback) (NULL, _("Guide procedures"), 0.457);
(* status_callback) (NULL, _("Guide procedures"), 0.455);
register_guides_procs (gimp);
(* status_callback) (NULL, _("Help procedures"), 0.47);
(* status_callback) (NULL, _("Help procedures"), 0.468);
register_help_procs (gimp);
(* status_callback) (NULL, _("Image"), 0.472);
(* status_callback) (NULL, _("Image"), 0.47);
register_image_procs (gimp);
(* status_callback) (NULL, _("Layer"), 0.609);
(* status_callback) (NULL, _("Layer"), 0.606);
register_layer_procs (gimp);
(* status_callback) (NULL, _("Message procedures"), 0.667);
(* status_callback) (NULL, _("Message procedures"), 0.665);
register_message_procs (gimp);
(* status_callback) (NULL, _("Miscellaneous"), 0.674);
(* status_callback) (NULL, _("Miscellaneous"), 0.671);
register_misc_procs (gimp);
(* status_callback) (NULL, _("Paint Tool procedures"), 0.678);
(* status_callback) (NULL, _("Paint Tool procedures"), 0.675);
register_paint_tools_procs (gimp);
(* status_callback) (NULL, _("Palette"), 0.711);
(* status_callback) (NULL, _("Palette"), 0.708);
register_palette_procs (gimp);
(* status_callback) (NULL, _("Palette UI"), 0.741);
(* status_callback) (NULL, _("Palette UI"), 0.738);
register_palette_select_procs (gimp);
(* status_callback) (NULL, _("Palettes"), 0.748);
(* status_callback) (NULL, _("Palettes"), 0.745);
register_palettes_procs (gimp);
(* status_callback) (NULL, _("Parasite procedures"), 0.757);
(* status_callback) (NULL, _("Parasite procedures"), 0.753);
register_parasite_procs (gimp);
(* status_callback) (NULL, _("Paths"), 0.783);
(* status_callback) (NULL, _("Paths"), 0.779);
register_paths_procs (gimp);
(* status_callback) (NULL, _("Pattern"), 0.817);
(* status_callback) (NULL, _("Pattern"), 0.814);
register_pattern_procs (gimp);
(* status_callback) (NULL, _("Pattern UI"), 0.822);
(* status_callback) (NULL, _("Pattern UI"), 0.818);
register_pattern_select_procs (gimp);
(* status_callback) (NULL, _("Patterns"), 0.828);
(* status_callback) (NULL, _("Patterns"), 0.825);
register_patterns_procs (gimp);
(* status_callback) (NULL, _("Plug-in"), 0.837);
(* status_callback) (NULL, _("Plug-in"), 0.833);
register_plug_in_procs (gimp);
(* status_callback) (NULL, _("Procedural database"), 0.85);
(* status_callback) (NULL, _("Procedural database"), 0.846);
register_procedural_db_procs (gimp);
(* status_callback) (NULL, _("Progress"), 0.87);
(* status_callback) (NULL, _("Progress"), 0.866);
register_progress_procs (gimp);
(* status_callback) (NULL, _("Image mask"), 0.885);
(* status_callback) (NULL, _("Image mask"), 0.881);
register_selection_procs (gimp);
(* status_callback) (NULL, _("Selection Tool procedures"), 0.922);
(* status_callback) (NULL, _("Selection Tool procedures"), 0.918);
register_selection_tools_procs (gimp);
(* status_callback) (NULL, _("Text procedures"), 0.933);
(* status_callback) (NULL, _("Text procedures"), 0.929);
register_text_tool_procs (gimp);
(* status_callback) (NULL, _("Transform Tool procedures"), 0.941);
(* status_callback) (NULL, _("Transform Tool procedures"), 0.937);
register_transform_tools_procs (gimp);
(* status_callback) (NULL, _("Undo"), 0.954);
(* status_callback) (NULL, _("Undo"), 0.95);
register_undo_procs (gimp);
(* status_callback) (NULL, _("Units"), 0.97);
(* status_callback) (NULL, _("Units"), 0.965);
register_unit_procs (gimp);
(* status_callback) (NULL, _("Paths"), 0.996);
(* status_callback) (NULL, _("Paths"), 0.991);
register_vectors_procs (gimp);
}
......@@ -37,13 +37,17 @@
#include "vectors/gimpvectors.h"
static ProcRecord vectors_get_strokes_proc;
static ProcRecord vectors_stroke_remove_proc;
static ProcRecord vectors_stroke_translate_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_stroke_remove_proc);
procedural_db_register (gimp, &vectors_stroke_translate_proc);
procedural_db_register (gimp, &vectors_stroke_interpolate_proc);
}
static Argument *
......@@ -133,6 +137,67 @@ static ProcRecord vectors_get_strokes_proc =
{ { vectors_get_strokes_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",
"return coordinates along the given stroke.",
"Returns a lot of coordinates along the passed stroke.",
"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,
......@@ -208,8 +273,8 @@ static ProcArg vectors_stroke_translate_inargs[] =
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.",
"translate the given stroke.",
"Translate the given stroke.",
"Simon Budig",
"Simon Budig",
"2005",
......@@ -221,3 +286,129 @@ static ProcRecord vectors_stroke_translate_proc =
NULL,
{ { vectors_stroke_translate_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",
"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 } }
};
......@@ -666,8 +666,9 @@ gimp_vectors_add_strokes (const GimpVectors *src_vectors,
while (current_lstroke)
{
current_lstroke->data = gimp_stroke_duplicate (current_lstroke->data);
dest_vectors->last_stroke_ID ++;
gimp_stroke_set_ID (current_lstroke->data,
dest_vectors->last_stroke_ID++);
dest_vectors->last_stroke_ID);
current_lstroke = g_list_next (current_lstroke);
}
......@@ -698,7 +699,8 @@ gimp_vectors_real_stroke_add (GimpVectors *vectors,
/* Don't g_list_prepend() here. See ChangeLog 2003-05-21 --Mitch */
vectors->strokes = g_list_append (vectors->strokes, stroke);
gimp_stroke_set_ID (stroke, vectors->last_stroke_ID++);
vectors->last_stroke_ID ++;
gimp_stroke_set_ID (stroke, vectors->last_stroke_ID);
g_object_ref (stroke);
}
......
......@@ -9,13 +9,11 @@ gimpvectors
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
</para>
<!-- ##### FUNCTION gimp_vectors_get_strokes ##### -->
<para>
......
......@@ -69,6 +69,40 @@ gimp_vectors_get_strokes (gint32 vectors_ID,
return stroke_ids;
}
/**
* gimp_vectors_stroke_remove:
* @vectors_ID: The vectors object.
* @stroke_id: The stroke ID.
*
* 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_remove (gint32 vectors_ID,
gint stroke_id)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp_vectors_stroke_remove",
&nreturn_vals,
GIMP_PDB_PATH, vectors_ID,
GIMP_PDB_INT32, stroke_id,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_vectors_stroke_translate:
* @vectors_ID: The vectors object.
......@@ -76,9 +110,9 @@ gimp_vectors_get_strokes (gint32 vectors_ID,
* @offx: Offset in x direction.
* @offy: Offset in y direction.
*
* return coordinates along the given stroke.
* translate the given stroke.
*
* Returns a lot of coordinates along the passed stroke.
* Translate the given stroke.
*
* Returns: TRUE on success.
*
......@@ -108,3 +142,53 @@ gimp_vectors_stroke_translate (gint32 vectors_ID,
return success;
}
/**
* gimp_vectors_stroke_interpolate:
* @vectors_ID: The vectors object.
* @stroke_id: The stroke ID.
* @prescision: The prescision used for the approximation.
* @num_coords: The number of floats returned.
* @coords: List of the coords along the path (x0, y0, x1, y1, ...).
*
* returns polygonal approximation of the stroke.
*
* returns polygonal approximation of the stroke.
*
* Returns: List of the strokes belonging to the path.
*
* Since: GIMP 2.4
*/
gboolean
gimp_vectors_stroke_interpolate (gint32 vectors_ID,
gint stroke_id,
gdouble prescision,
gint *num_coords,
gdouble **coords)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean closed = FALSE;
return_vals = gimp_run_procedure ("gimp_vectors_stroke_interpolate",
&nreturn_vals,
GIMP_PDB_PATH, vectors_ID,
GIMP_PDB_INT32, stroke_id,
GIMP_PDB_FLOAT, prescision,
GIMP_PDB_END);
*num_coords = 0;
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
{
closed = return_vals[1].data.d_int32;
*num_coords = return_vals[2].data.d_int32;
*coords = g_new (gdouble, *num_coords);
memcpy (*coords, return_vals[3].data.d_floatarray,
*num_coords * sizeof (gdouble));
}
gimp_destroy_params (return_vals, nreturn_vals);
return closed;
}
......@@ -29,12 +29,19 @@ 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);
gboolean gimp_vectors_stroke_translate (gint32 vectors_ID,
gint stroke_id,
gint offx,
gint offy);
gint* gimp_vectors_get_strokes (gint32 vectors_ID,
gint *num_strokes);
gboolean gimp_vectors_stroke_remove (gint32 vectors_ID,
gint stroke_id);
gboolean gimp_vectors_stroke_translate (gint32 vectors_ID,
gint stroke_id,
gint offx,
gint offy);
gboolean gimp_vectors_stroke_interpolate (gint32 vectors_ID,
gint stroke_id,
gdouble prescision,
gint *num_coords,
gdouble **coords);
G_END_DECLS
......
......@@ -81,7 +81,8 @@ CODE
);
}
sub vectors_stroke_translate {
sub vectors_stroke_remove {
$blurb = 'return coordinates along the given stroke.';
$help = <<'HELP';
......@@ -90,6 +91,33 @@ HELP
&pdb_misc;
@inargs = ( &stroke_arg );
%invoke = (
vars => [ 'GimpStroke *stroke' ],
code => <<"CODE"
{
stroke = gimp_vectors_stroke_get_by_ID (vectors, stroke_id);
if (stroke)
gimp_vectors_stroke_remove (vectors, stroke);
else
success = FALSE;
}
CODE
);
}
sub vectors_stroke_translate {
$blurb = 'translate the given stroke.';
$help = <<'HELP';
Translate the given stroke.