plug-ins: port map-object to gimp_image_procedure_new2()

...and to GimpProcedureDialog.
Also resolves #25 by adding the missing PDB parameters to the GUI.
Note that there are a few remaining tasks:
* The config values are being copied to mapvals. 
Eventually the rest of the code needs to be updated
to directly use the config.
* The material tab uses icons from the Lighting plug-in. They didn't show up before the port; this needs to be fixed.
* The drawable buttons are huge compared to the original plug-in. The styling needs to be looked at.
This commit is contained in:
Alx Sa 2023-09-17 15:40:39 +00:00 committed by Jehan
parent 640b0cffe0
commit faae47a9a8
7 changed files with 845 additions and 1224 deletions

View File

@ -326,3 +326,90 @@ compute_image (void)
gimp_image_undo_group_end (new_image); gimp_image_undo_group_end (new_image);
} }
void
copy_from_config (GimpProcedureConfig *config)
{
GimpDrawable *box_front = NULL;
GimpDrawable *box_back = NULL;
GimpDrawable *box_top = NULL;
GimpDrawable *box_bottom = NULL;
GimpDrawable *box_left = NULL;
GimpDrawable *box_right = NULL;
GimpDrawable *cyl_top = NULL;
GimpDrawable *cyl_bottom = NULL;
mapvals.maptype = gimp_procedure_config_get_choice_id (config, "map-type");
mapvals.lightsource.type =
gimp_procedure_config_get_choice_id (config, "light-type");
g_object_get (config,
"viewpoint-x", &mapvals.viewpoint.x,
"viewpoint-y", &mapvals.viewpoint.y,
"viewpoint-z", &mapvals.viewpoint.z,
"position-x", &mapvals.position.x,
"position-y", &mapvals.position.y,
"position-z", &mapvals.position.z,
"first-axis-x", &mapvals.firstaxis.x,
"first-axis-y", &mapvals.firstaxis.y,
"first-axis-z", &mapvals.firstaxis.z,
"second-axis-x", &mapvals.secondaxis.x,
"second-axis-y", &mapvals.secondaxis.y,
"second-axis-z", &mapvals.secondaxis.z,
"rotation-angle-x", &mapvals.alpha,
"rotation-angle-y", &mapvals.beta,
"rotation-angle-z", &mapvals.gamma,
"light-color", &mapvals.lightsource.color,
"light-position-x", &mapvals.lightsource.position.x,
"light-position-y", &mapvals.lightsource.position.y,
"light-position-z", &mapvals.lightsource.position.z,
"light-direction-x", &mapvals.lightsource.direction.x,
"light-direction-y", &mapvals.lightsource.direction.y,
"light-direction-z", &mapvals.lightsource.direction.z,
"ambient-intensity", &mapvals.material.ambient_int,
"diffuse-intensity", &mapvals.material.diffuse_int,
"diffuse-reflectivity", &mapvals.material.diffuse_ref,
"specular-reflectivity", &mapvals.material.specular_ref,
"highlight", &mapvals.material.highlight,
"antialiasing", &mapvals.antialiasing,
"depth", &mapvals.maxdepth,
"threshold", &mapvals.pixelthreshold,
"tiled", &mapvals.tiled,
"new-image", &mapvals.create_new_image,
"new-layer", &mapvals.create_new_layer,
"transparent-background", &mapvals.transparent_background,
"sphere-radius", &mapvals.radius,
"box-front-drawable", &box_front,
"box-back-drawable", &box_back,
"box-top-drawable", &box_top,
"box-bottom-drawable", &box_bottom,
"box-left-drawable", &box_left,
"box-right-drawable", &box_right,
"x-scale", &mapvals.scale.x,
"y-scale", &mapvals.scale.y,
"z-scale", &mapvals.scale.z,
"cyl-top-drawable", &cyl_top,
"cyl-bottom-drawable", &cyl_bottom,
"cylinder-radius", &mapvals.cylinder_radius,
"cylinder-length", &mapvals.cylinder_length,
NULL);
if (box_front)
mapvals.boxmap_id[0] = gimp_item_get_id (GIMP_ITEM (box_front));
if (box_back)
mapvals.boxmap_id[1] = gimp_item_get_id (GIMP_ITEM (box_back));
if (box_top)
mapvals.boxmap_id[2] = gimp_item_get_id (GIMP_ITEM (box_top));
if (box_bottom)
mapvals.boxmap_id[3] = gimp_item_get_id (GIMP_ITEM (box_bottom));
if (box_left)
mapvals.boxmap_id[4] = gimp_item_get_id (GIMP_ITEM (box_left));
if (box_right)
mapvals.boxmap_id[5] = gimp_item_get_id (GIMP_ITEM (box_right));
if (cyl_top)
mapvals.cylindermap_id[0] = gimp_item_get_id (GIMP_ITEM (cyl_top));
if (cyl_bottom)
mapvals.cylindermap_id[0] = gimp_item_get_id (GIMP_ITEM (cyl_bottom));
}

View File

@ -4,7 +4,8 @@
extern gdouble imat[4][4]; extern gdouble imat[4][4];
extern gfloat rotmat[16]; extern gfloat rotmat[16];
void init_compute (void); void init_compute (void);
void compute_image (void); void compute_image (void);
void copy_from_config (GimpProcedureConfig *config);
#endif /* __MAPOBJECT_APPLY_H__ */ #endif /* __MAPOBJECT_APPLY_H__ */

View File

@ -311,12 +311,19 @@ get_cylinder_image_color (gint image,
/****************************************/ /****************************************/
gint gint
image_setup (GimpDrawable *drawable, image_setup (GimpDrawable *drawable,
gint interactive) gint interactive,
GimpProcedureConfig *config)
{ {
gboolean transparent_background;
input_drawable = drawable; input_drawable = drawable;
output_drawable = drawable; output_drawable = drawable;
g_object_get (config,
"transparent_background", &transparent_background,
NULL);
if (! gimp_drawable_mask_intersect (drawable, &border_x, &border_y, if (! gimp_drawable_mask_intersect (drawable, &border_x, &border_y,
&border_w, &border_h)) &border_w, &border_h))
return FALSE; return FALSE;
@ -328,7 +335,7 @@ image_setup (GimpDrawable *drawable,
maxcounter = (glong) width * (glong) height; maxcounter = (glong) width * (glong) height;
if (mapvals.transparent_background == TRUE) if (transparent_background == TRUE)
{ {
gimp_rgba_set (&background, 0.0, 0.0, 0.0, 0.0); gimp_rgba_set (&background, 0.0, 0.0, 0.0, 0.0);
} }

View File

@ -31,7 +31,9 @@ extern gint border_x1, border_y1, border_x2, border_y2;
/* ============================ */ /* ============================ */
extern gint image_setup (GimpDrawable *drawable, extern gint image_setup (GimpDrawable *drawable,
gint interactive); gint interactive,
GimpProcedureConfig
*config);
extern glong in_xy_to_index (gint x, extern glong in_xy_to_index (gint x,
gint y); gint y);
extern glong out_xy_to_index (gint x, extern glong out_xy_to_index (gint x,

View File

@ -66,7 +66,7 @@ static GimpValueArray * map_run (GimpProcedure *procedure,
GimpImage *image, GimpImage *image,
gint n_drawables, gint n_drawables,
GimpDrawable **drawables, GimpDrawable **drawables,
const GimpValueArray *args, GimpProcedureConfig *config,
gpointer run_data); gpointer run_data);
static void set_default_settings (void); static void set_default_settings (void);
@ -110,9 +110,9 @@ map_create_procedure (GimpPlugIn *plug_in,
{ {
GimpRGB white = { 1.0, 1.0, 1.0, 1.0 }; GimpRGB white = { 1.0, 1.0, 1.0, 1.0 };
procedure = gimp_image_procedure_new (plug_in, name, procedure = gimp_image_procedure_new2 (plug_in, name,
GIMP_PDB_PROC_TYPE_PLUGIN, GIMP_PDB_PROC_TYPE_PLUGIN,
map_run, NULL, NULL); map_run, NULL, NULL);
gimp_procedure_set_image_types (procedure, "RGB*"); gimp_procedure_set_image_types (procedure, "RGB*");
gimp_procedure_set_sensitivity_mask (procedure, gimp_procedure_set_sensitivity_mask (procedure,
@ -131,261 +131,298 @@ map_create_procedure (GimpPlugIn *plug_in,
"Tom Bech & Federico Mena Quintero", "Tom Bech & Federico Mena Quintero",
"Version 1.2.0, July 16 1998"); "Version 1.2.0, July 16 1998");
GIMP_PROC_ARG_INT (procedure, "map-type", GIMP_PROC_ARG_CHOICE (procedure, "map-type",
"Map type", _("Ma_p to"),
"Type of mapping (0=plane, 1=sphere, 2=box, " _("Type of mapping"),
"3=cylinder)", gimp_choice_new_with_values ("map-plane", MAP_PLANE, _("Plane"), NULL,
0, 2, MAP_PLANE, "map-sphere", MAP_SPHERE, _("Sphere"), NULL,
G_PARAM_READWRITE); "map-box", MAP_BOX, _("Box"), NULL,
"map-cylinder", MAP_CYLINDER, _("Cylinder"), NULL,
NULL),
"map-plane",
G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "viewpoint-x", GIMP_PROC_ARG_DOUBLE (procedure, "viewpoint-x",
"Viewpoint X", _("X"),
"Position of viewpoint (x,y,z)", _("Position of viewpoint (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 0.5, -G_MAXDOUBLE, G_MAXDOUBLE, 0.5,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "viewpoint-y", GIMP_PROC_ARG_DOUBLE (procedure, "viewpoint-y",
"Viewpoint Y", _("Y"),
"Position of viewpoint (x,y,z)", _("Position of viewpoint (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 0.5, -G_MAXDOUBLE, G_MAXDOUBLE, 0.5,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "viewpoint-z", GIMP_PROC_ARG_DOUBLE (procedure, "viewpoint-z",
"Viewpoint Z", _("Z"),
"Position of viewpoint (x,y,z)", _("Position of viewpoint (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 2.0, -G_MAXDOUBLE, G_MAXDOUBLE, 2.0,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "position-x", GIMP_PROC_ARG_DOUBLE (procedure, "position-x",
"Position X", _("Position X"),
"Object position (x,y,z)", _("Object position (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 0.5, -1.0, 2.0, 0.5,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "position-y", GIMP_PROC_ARG_DOUBLE (procedure, "position-y",
"Position Y", _("Position Y"),
"Object position (x,y,z)", _("Object position (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 0.5, -1.0, 2.0, 0.5,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "position-z", GIMP_PROC_ARG_DOUBLE (procedure, "position-z",
"Position Z", _("Position Z"),
"Object position (x,y,z)", _("Object position (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 0.0, -1.0, 2.0, 0.0,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "first-axis-x", GIMP_PROC_ARG_DOUBLE (procedure, "first-axis-x",
"First axis X", _("X"),
"First axis of object (x,y,z)", _("First axis of object (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 1.0, -1.0, 2.0, 1.0,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "first-axis-y", GIMP_PROC_ARG_DOUBLE (procedure, "first-axis-y",
"First axis y", _("y"),
"First axis of object (x,y,z)", _("First axis of object (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 0.0, -1.0, 2.0, 0.0,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "first-axis-z", GIMP_PROC_ARG_DOUBLE (procedure, "first-axis-z",
"First axis Z", _("Z"),
"First axis of object (x,y,z)", _("First axis of object (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 0.0, -1.0, 2.0, 0.0,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "second-axis-x", GIMP_PROC_ARG_DOUBLE (procedure, "second-axis-x",
"Second axis X", _("X"),
"Second axis of object (x,y,z)", _("Second axis of object (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 0.0, -1.0, 2.0, 0.0,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "second-axis-y", GIMP_PROC_ARG_DOUBLE (procedure, "second-axis-y",
"Second axis Y", _("Y"),
"Second axis of object (x,y,z)", _("Second axis of object (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 1.0, -1.0, 2.0, 1.0,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "second-axis-z", GIMP_PROC_ARG_DOUBLE (procedure, "second-axis-z",
"Second axis Z", _("Z"),
"Second axis of object (x,y,z)", _("Second axis of object (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 0.0, -1.0, 2.0, 0.0,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "rotation-angle-x", GIMP_PROC_ARG_DOUBLE (procedure, "rotation-angle-x",
"Rotation angle X", _("Angle X"),
"Rotation about X axis in degrees", _("Rotation about X axis in degrees"),
-G_MAXDOUBLE, G_MAXDOUBLE, 0.0, -180, 180, 0.0,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "rotation-angle-y", GIMP_PROC_ARG_DOUBLE (procedure, "rotation-angle-y",
"Rotation angle Y", _("Angle Y"),
"Rotation about Y axis in degrees", _("Rotation about Y axis in degrees"),
-G_MAXDOUBLE, G_MAXDOUBLE, 0.0, -180, 180, 0.0,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "rotation-angle-z", GIMP_PROC_ARG_DOUBLE (procedure, "rotation-angle-z",
"Rotation angle Z", _("Angle Z"),
"Rotation about Z axis in degrees", _("Rotation about Z axis in degrees"),
-G_MAXDOUBLE, G_MAXDOUBLE, 0.0, -180, 180, 0.0,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_INT (procedure, "light-type", GIMP_PROC_ARG_CHOICE (procedure, "light-type",
"Light type", _("Light source type"),
"Type of lightsource (0=point, 1=directional, 2=none)", _("Type of lightsource"),
0, 2, POINT_LIGHT, gimp_choice_new_with_values ("point-light", POINT_LIGHT, _("Point Light"), NULL,
G_PARAM_READWRITE); "directional-light", DIRECTIONAL_LIGHT, _("Directional Light"), NULL,
"no-light", NO_LIGHT, _("No Light"), NULL,
NULL),
"point-light",
G_PARAM_READWRITE);
GIMP_PROC_ARG_RGB (procedure, "light-color", GIMP_PROC_ARG_RGB (procedure, "light-color",
"Light color", _("Light source color"),
"Light source color", _("Light source color"),
TRUE, &white, TRUE, &white,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "light-position-x", GIMP_PROC_ARG_DOUBLE (procedure, "light-position-x",
"Light position X", _("Light position X"),
"Light source position (x,y,z)", _("Light source position (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, -0.5, -G_MAXDOUBLE, G_MAXDOUBLE, -0.5,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "light-position-y", GIMP_PROC_ARG_DOUBLE (procedure, "light-position-y",
"Light position Y", _("Light position Y"),
"Light source position (x,y,z)", _("Light source position (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, -0.5, -G_MAXDOUBLE, G_MAXDOUBLE, -0.5,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "light-position-z", GIMP_PROC_ARG_DOUBLE (procedure, "light-position-z",
"Light position Z", _("Light position Z"),
"Light source position (x,y,z)", _("Light source position (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 2.0, -G_MAXDOUBLE, G_MAXDOUBLE, 2.0,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "light-direction-x", GIMP_PROC_ARG_DOUBLE (procedure, "light-direction-x",
"Light direction X", _("Light direction X"),
"Light source direction (x,y,z)", _("Light source direction (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, -1.0, -G_MAXDOUBLE, G_MAXDOUBLE, -1.0,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "light-direction-y", GIMP_PROC_ARG_DOUBLE (procedure, "light-direction-y",
"Light direction Y", _("Light direction Y"),
"Light source direction (x,y,z)", _("Light source direction (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, -1.0, -G_MAXDOUBLE, G_MAXDOUBLE, -1.0,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "light-direction-z", GIMP_PROC_ARG_DOUBLE (procedure, "light-direction-z",
"Light direction Z", _("Light direction Z"),
"Light source direction (x,y,z)", _("Light source direction (x,y,z)"),
-G_MAXDOUBLE, G_MAXDOUBLE, 1.0, -G_MAXDOUBLE, G_MAXDOUBLE, 1.0,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "ambient-intensity", GIMP_PROC_ARG_DOUBLE (procedure, "ambient-intensity",
"Ambient intensity", _("Ambient"),
"Material ambient intensity", _("Material ambient intensity"),
0, 1, 0.3, 0, 1, 0.3,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "diffuse-intensity", GIMP_PROC_ARG_DOUBLE (procedure, "diffuse-intensity",
"Diffuse intensity", _("Diffuse"),
"Material diffuse intensity", _("Material diffuse intensity"),
0, 1, 1.0, 0, 1, 1.0,
G_PARAM_READWRITE); G_PARAM_READWRITE);
/* Reflectivity */
GIMP_PROC_ARG_DOUBLE (procedure, "diffuse-reflectivity", GIMP_PROC_ARG_DOUBLE (procedure, "diffuse-reflectivity",
"Diffuse reflectivity", _("Diffuse"),
"Material diffuse reflectivity", _("Material diffuse reflectivity"),
0, 1, 0.5, 0, 1, 0.5,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "specular-reflectivity", GIMP_PROC_ARG_DOUBLE (procedure, "specular-reflectivity",
"Specular reflectivity", _("Specular"),
"Material specular reflectivity", _("Material specular reflectivity"),
0, 1, 0.5, 0, 1, 0.5,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "highlight", GIMP_PROC_ARG_DOUBLE (procedure, "highlight",
"Highlight", _("Highlight"),
"Material highlight (note, it's exponential)", _("Material highlight "
"(note, it's exponential)"),
0, G_MAXDOUBLE, 27.0, 0, G_MAXDOUBLE, 27.0,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_BOOLEAN (procedure, "antialiasing", GIMP_PROC_ARG_BOOLEAN (procedure, "antialiasing",
"Antialiasing", _("Antialia_sing"),
"Apply antialiasing", _("Apply antialiasing"),
TRUE, TRUE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "depth",
_("Depth"),
_("Antialiasing quality. Higher is better, "
"but slower"),
1.0, 5.0, 3.0,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "threshold",
_("Threshold"),
_("Stop when pixel differences are smaller than "
"this value"),
0.001, 1000.0, 0.250,
G_PARAM_READWRITE);
GIMP_PROC_ARG_BOOLEAN (procedure, "tiled", GIMP_PROC_ARG_BOOLEAN (procedure, "tiled",
"Tiled", _("Tile so_urce image"),
"Tile source image", _("Tile source image"),
FALSE, FALSE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_BOOLEAN (procedure, "new-image", GIMP_PROC_ARG_BOOLEAN (procedure, "new-image",
"New image", _("Create new ima_ge"),
"Create a new image", _("Create a new image"),
FALSE,
G_PARAM_READWRITE);
GIMP_PROC_ARG_BOOLEAN (procedure, "new-layer",
_("Create new layer"),
_("Create a new layer when applying filter"),
FALSE, FALSE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_BOOLEAN (procedure, "transparent-background", GIMP_PROC_ARG_BOOLEAN (procedure, "transparent-background",
"Transparent background", _("_Transparent background"),
"Make background transparent", _("Make background transparent"),
FALSE, FALSE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "radius", /* Sphere Options */
"Radius", GIMP_PROC_ARG_DOUBLE (procedure, "sphere-radius",
"Sphere/cylinder radius (only used when " _("R_adius"),
"maptype=1 or 3)", _("Sphere radius"),
0, G_MAXDOUBLE, 0.25,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "x-scale",
"X scale",
"Box X size",
0, G_MAXDOUBLE, 0.5,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "y-scale",
"Y scale",
"Box Y size",
0, G_MAXDOUBLE, 0.5,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "z-scale",
"Z scale",
"Box Z size",
0, G_MAXDOUBLE, 0.5,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "cylinder-length",
"Cylinder length",
"Cylinder length",
0, G_MAXDOUBLE, 0.25, 0, G_MAXDOUBLE, 0.25,
G_PARAM_READWRITE); G_PARAM_READWRITE);
/* Box Options */
GIMP_PROC_ARG_DRAWABLE (procedure, "box-front-drawable", GIMP_PROC_ARG_DRAWABLE (procedure, "box-front-drawable",
"Box front drawable", _("Fro_nt"),
"Box front face (set these to NULL if not used)", _("Box front face "
"(set this to NULL if not used)"),
TRUE, TRUE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DRAWABLE (procedure, "box-back-drawable", GIMP_PROC_ARG_DRAWABLE (procedure, "box-back-drawable",
"Box back drawable", _("B_ack"),
"Box back face", _("Box back face"),
TRUE, TRUE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DRAWABLE (procedure, "box-top-drawable", GIMP_PROC_ARG_DRAWABLE (procedure, "box-top-drawable",
"Box top drawable", _("To_p"),
"Box top face", _("Box top face"),
TRUE, TRUE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DRAWABLE (procedure, "box-bottom-drawable", GIMP_PROC_ARG_DRAWABLE (procedure, "box-bottom-drawable",
"Box bottom drawable", _("Bo_ttom"),
"Box bottom face", _("Box bottom face"),
TRUE, TRUE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DRAWABLE (procedure, "box-left-drawable", GIMP_PROC_ARG_DRAWABLE (procedure, "box-left-drawable",
"Box left drawable", _("Le_ft"),
"Box left face", _("Box left face"),
TRUE, TRUE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DRAWABLE (procedure, "box-right-drawable", GIMP_PROC_ARG_DRAWABLE (procedure, "box-right-drawable",
"Box right drawable", _("Ri_ght"),
"Box right face", _("Box right face"),
TRUE, TRUE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "x-scale",
_("Scale X"),
_("Box X size"),
0, G_MAXDOUBLE, 0.5,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "y-scale",
_("Scale Y"),
_("Box Y size"),
0, G_MAXDOUBLE, 0.5,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "z-scale",
_("Scale Z"),
_("Box Z size"),
0, G_MAXDOUBLE, 0.5,
G_PARAM_READWRITE);
/* Cylinder options */
GIMP_PROC_ARG_DRAWABLE (procedure, "cyl-top-drawable", GIMP_PROC_ARG_DRAWABLE (procedure, "cyl-top-drawable",
"Cyl top drawable", _("_Top"),
"Cylinder top face (set these to NULL if not used)", _("Cylinder top face "
"(set this to NULL if not used)"),
TRUE, TRUE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DRAWABLE (procedure, "cyl-bottom-drawable", GIMP_PROC_ARG_DRAWABLE (procedure, "cyl-bottom-drawable",
"Cyl bottom drawable", _("_Bottom"),
"Cylinder bottom face", _("Cylinder bottom face "
"(set this to NULL if not used)"),
TRUE, TRUE,
G_PARAM_READWRITE); G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "cylinder-radius",
_("R_adius"),
_("Cylinder radius"),
0, G_MAXDOUBLE, 0.25,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "cylinder-length",
_("Cylinder length"),
_("Cylinder length"),
0, G_MAXDOUBLE, 0.25,
G_PARAM_READWRITE);
} }
return procedure; return procedure;
@ -478,7 +515,7 @@ map_run (GimpProcedure *procedure,
GimpImage *_image, GimpImage *_image,
gint n_drawables, gint n_drawables,
GimpDrawable **drawables, GimpDrawable **drawables,
const GimpValueArray *args, GimpProcedureConfig *config,
gpointer run_data) gpointer run_data)
{ {
GimpDrawable *drawable; GimpDrawable *drawable;
@ -510,97 +547,44 @@ map_run (GimpProcedure *procedure,
switch (run_mode) switch (run_mode)
{ {
case GIMP_RUN_INTERACTIVE: case GIMP_RUN_INTERACTIVE:
gimp_get_data (PLUG_IN_PROC, &mapvals);
check_drawables (drawable); check_drawables (drawable);
if (! main_dialog (drawable)) if (! main_dialog (procedure, config, drawable))
{ {
return gimp_procedure_new_return_values (procedure, return gimp_procedure_new_return_values (procedure,
GIMP_PDB_CANCEL, GIMP_PDB_CANCEL,
NULL); NULL);
} }
copy_from_config (config);
compute_image (); compute_image ();
gimp_set_data (PLUG_IN_PROC, &mapvals, sizeof (MapObjectValues));
break; break;
case GIMP_RUN_WITH_LAST_VALS: case GIMP_RUN_WITH_LAST_VALS:
gimp_get_data (PLUG_IN_PROC, &mapvals);
check_drawables (drawable); check_drawables (drawable);
if (! image_setup (drawable, FALSE)) if (! image_setup (drawable, FALSE, config))
{ {
return gimp_procedure_new_return_values (procedure, return gimp_procedure_new_return_values (procedure,
GIMP_PDB_SUCCESS, GIMP_PDB_SUCCESS,
NULL); NULL);
} }
copy_from_config (config);
compute_image (); compute_image ();
break; break;
case GIMP_RUN_NONINTERACTIVE: case GIMP_RUN_NONINTERACTIVE:
mapvals.maptype = GIMP_VALUES_GET_INT (args, 0);
mapvals.viewpoint.x = GIMP_VALUES_GET_DOUBLE (args, 1);
mapvals.viewpoint.y = GIMP_VALUES_GET_DOUBLE (args, 2);
mapvals.viewpoint.z = GIMP_VALUES_GET_DOUBLE (args, 3);
mapvals.position.x = GIMP_VALUES_GET_DOUBLE (args, 4);
mapvals.position.y = GIMP_VALUES_GET_DOUBLE (args, 5);
mapvals.position.z = GIMP_VALUES_GET_DOUBLE (args, 6);
mapvals.firstaxis.x = GIMP_VALUES_GET_DOUBLE (args, 7);
mapvals.firstaxis.y = GIMP_VALUES_GET_DOUBLE (args, 8);
mapvals.firstaxis.z = GIMP_VALUES_GET_DOUBLE (args, 9);
mapvals.secondaxis.x = GIMP_VALUES_GET_DOUBLE (args, 10);
mapvals.secondaxis.y = GIMP_VALUES_GET_DOUBLE (args, 11);
mapvals.secondaxis.z = GIMP_VALUES_GET_DOUBLE (args, 12);
mapvals.alpha = GIMP_VALUES_GET_DOUBLE (args, 13);
mapvals.beta = GIMP_VALUES_GET_DOUBLE (args, 14);
mapvals.gamma = GIMP_VALUES_GET_DOUBLE (args, 15);
mapvals.lightsource.type = GIMP_VALUES_GET_INT (args, 16);
GIMP_VALUES_GET_RGB (args, 17, &mapvals.lightsource.color);
mapvals.lightsource.position.x = GIMP_VALUES_GET_DOUBLE (args, 18);
mapvals.lightsource.position.y = GIMP_VALUES_GET_DOUBLE (args, 19);
mapvals.lightsource.position.z = GIMP_VALUES_GET_DOUBLE (args, 20);
mapvals.lightsource.direction.x = GIMP_VALUES_GET_DOUBLE (args, 21);
mapvals.lightsource.direction.y = GIMP_VALUES_GET_DOUBLE (args, 22);
mapvals.lightsource.direction.z = GIMP_VALUES_GET_DOUBLE (args, 23);
mapvals.material.ambient_int = GIMP_VALUES_GET_DOUBLE (args, 24);
mapvals.material.diffuse_int = GIMP_VALUES_GET_DOUBLE (args, 25);
mapvals.material.diffuse_ref = GIMP_VALUES_GET_DOUBLE (args, 26);
mapvals.material.specular_ref = GIMP_VALUES_GET_DOUBLE (args, 27);
mapvals.material.highlight = GIMP_VALUES_GET_DOUBLE (args, 28);
mapvals.antialiasing = GIMP_VALUES_GET_BOOLEAN (args, 29);
mapvals.tiled = GIMP_VALUES_GET_BOOLEAN (args, 30);
mapvals.create_new_image = GIMP_VALUES_GET_BOOLEAN (args, 31);
mapvals.transparent_background = GIMP_VALUES_GET_BOOLEAN (args, 32);
mapvals.radius =
mapvals.cylinder_radius = GIMP_VALUES_GET_DOUBLE (args, 33);
mapvals.scale.x = GIMP_VALUES_GET_DOUBLE (args, 34);
mapvals.scale.y = GIMP_VALUES_GET_DOUBLE (args, 35);
mapvals.scale.z = GIMP_VALUES_GET_DOUBLE (args, 36);
mapvals.cylinder_length = GIMP_VALUES_GET_DOUBLE (args, 37);
for (i = 0; i < 6; i++)
{
mapvals.boxmap_id[i] = GIMP_VALUES_GET_DRAWABLE_ID (args, 38 + i);
}
for (i = 0; i < 2; i++)
{
mapvals.cylindermap_id[i] = GIMP_VALUES_GET_DRAWABLE_ID (args, 44 + i);
}
check_drawables (drawable); check_drawables (drawable);
if (! image_setup (drawable, FALSE)) if (! image_setup (drawable, FALSE, config))
{ {
return gimp_procedure_new_return_values (procedure, return gimp_procedure_new_return_values (procedure,
GIMP_PDB_SUCCESS, GIMP_PDB_SUCCESS,
NULL); NULL);
} }
copy_from_config (config);
compute_image (); compute_image ();
break; break;
} }

File diff suppressed because it is too large Load Diff

View File

@ -9,6 +9,8 @@ extern GtkWidget *previewarea;
/* Externally visible functions */ /* Externally visible functions */
/* ============================ */ /* ============================ */
gboolean main_dialog (GimpDrawable *drawable); gboolean main_dialog (GimpProcedure *procedure,
GimpProcedureConfig *config,
GimpDrawable *drawable);
#endif /* __MAPOBJECT_UI_H__ */ #endif /* __MAPOBJECT_UI_H__ */