1997-11-24 22:05:25 +00:00
/*
2001-01-17 20:29:42 +00:00
* Written 1997 Jens Ch . Restemeier < jrestemeier @ currantbun . com >
1997-11-24 22:05:25 +00:00
* This program is based on an algorithm / article by
* J <EFBFBD> rn Loviscach .
1998-03-09 01:45:26 +00:00
*
2003-08-23 19:35:05 +00:00
* It appeared in c ' t 10 / 95 , page 326 and is called
2001-09-03 00:26:06 +00:00
* " Ausgew<EFBFBD> rfelt - Moderne Kunst algorithmisch erzeugen "
* ( ~ modern art created with algorithms ) .
2003-08-23 19:35:05 +00:00
*
1997-11-24 22:05:25 +00:00
* It generates one main formula ( the middle button ) and 8 variations of it .
* If you select a variation it becomes the new main formula . If you
* press " OK " the main formula will be applied to the image .
*
* 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 .
*
2003-08-23 19:35:05 +00:00
* This program is distributed in the hope that it will be useful ,
1997-11-24 22:05:25 +00:00
* 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
1998-04-13 05:44:11 +00:00
* Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
1997-11-24 22:05:25 +00:00
*
*/
/*
* History :
* 1.0 first release
* 1.2 now handles RGB *
* 1.5 fixed a small bug
* 1.6 fixed a bug that was added by v1 .5 : - (
2003-08-23 19:35:05 +00:00
* 1.7 added patch from Art Haas to make it compile with HP - UX , a small
2001-01-17 20:29:42 +00:00
* clean - up
2003-08-23 19:35:05 +00:00
* 1.8 Dscho added transform file load / save , bug - fixes
1997-11-24 22:05:25 +00:00
* 1.9 rewrote renderloop .
1997-12-08 21:37:39 +00:00
* 1.9 a fixed a bug .
1998-03-09 01:45:26 +00:00
* 1.9 b fixed MAIN ( )
* 1.10 added optimizer
2003-08-23 19:35:05 +00:00
* 1.11 uses tile iterator , antialiasing thanks to Simon Thum , compiles
2001-01-17 20:29:42 +00:00
* outside GIMP - tree
2003-08-23 19:35:05 +00:00
* 1.12 small fix to behave more like the original , button to control
2001-01-17 20:29:42 +00:00
* antialaising , remeber last used filename , bugfixes + cleanups
1997-11-24 22:05:25 +00:00
*/
2001-01-17 20:29:42 +00:00
# ifdef HAVE_CONFIG_H
2000-01-06 22:26:10 +00:00
# include "config.h"
2001-01-17 20:29:42 +00:00
# endif
2000-01-06 22:26:10 +00:00
1997-11-24 22:05:25 +00:00
# include <stdio.h>
# include <stdlib.h>
1999-05-29 01:28:24 +00:00
# include <string.h>
1997-11-24 22:05:25 +00:00
# include <time.h>
2002-01-30 14:54:27 +00:00
# ifdef __GNUC__
# warning GTK_DISABLE_DEPRECATED
# endif
# undef GTK_DISABLE_DEPRECATED
2000-01-06 22:26:10 +00:00
# include <gtk/gtk.h>
2000-01-25 17:46:56 +00:00
# include <libgimp/gimp.h>
# include <libgimp/gimpui.h>
2000-01-06 22:26:10 +00:00
1999-12-25 21:49:51 +00:00
# include "libgimp/stdplugins-intl.h"
1997-11-24 22:05:25 +00:00
2001-03-16 23:51:50 +00:00
# ifndef PATH_MAX
# define PATH_MAX _MAX_PATH
# endif
1997-11-24 22:05:25 +00:00
/** qbist renderer ***********************************************************/
# define MAX_TRANSFORMS 36
2001-01-18 14:41:35 +00:00
# define NUM_REGISTERS 6
# define PREVIEW_SIZE 64
1997-11-24 22:05:25 +00:00
2001-01-18 14:41:35 +00:00
# define PLUG_IN_NAME "plug_in_qbist"
2001-01-17 20:29:42 +00:00
# define PLUG_IN_VERSION "January 2001, 1.12"
1997-11-24 22:05:25 +00:00
/** types *******************************************************************/
2001-01-17 20:29:42 +00:00
/* experiment with this */
1997-11-24 22:05:25 +00:00
typedef gfloat vreg [ 3 ] ;
2001-01-18 14:41:35 +00:00
typedef enum
{
PROJECTION ,
SHIFT ,
SHIFTBACK ,
ROTATE ,
ROTATE2 ,
MULTIPLY ,
SINE ,
CONDITIONAL ,
COMPLEMENT
} TransformType ;
# define NUM_TRANSFORMS (COMPLEMENT + 1)
2001-01-17 20:29:42 +00:00
typedef struct
2001-01-18 14:41:35 +00:00
{
TransformType transformSequence [ MAX_TRANSFORMS ] ;
gint source [ MAX_TRANSFORMS ] ;
gint control [ MAX_TRANSFORMS ] ;
gint dest [ MAX_TRANSFORMS ] ;
}
ExpInfo ;
2001-01-17 20:29:42 +00:00
typedef struct
2001-01-18 14:41:35 +00:00
{
ExpInfo info ;
gint oversampling ;
gchar path [ PATH_MAX ] ;
}
QbistInfo ;
1997-11-24 22:05:25 +00:00
/** prototypes **************************************************************/
2000-01-25 17:46:56 +00:00
static void query ( void ) ;
2003-07-02 11:07:41 +00:00
static void run ( const gchar * name ,
gint nparams ,
const GimpParam * param ,
gint * nreturn_vals ,
GimpParam * * return_vals ) ;
2001-01-18 14:41:35 +00:00
static gint dialog_create ( void ) ;
static void dialog_new_variations ( GtkWidget * widget ,
gpointer data ) ;
static void dialog_update_previews ( GtkWidget * widget ,
gpointer data ) ;
static void dialog_select_preview ( GtkWidget * widget ,
ExpInfo * n_info ) ;
static QbistInfo qbist_info ;
1997-11-24 22:05:25 +00:00
/** qbist functions *********************************************************/
2000-01-25 17:46:56 +00:00
static void
2001-01-18 14:41:35 +00:00
create_info ( ExpInfo * info )
1997-11-24 22:05:25 +00:00
{
2001-01-18 14:41:35 +00:00
gint k ;
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c
2002-11-20 Dave Neary <bolsh@gimp.org>
* configure.in
* app/core/gimpbrushpipe.c
* app/gui/about-dialog.c
* app/paint-funcs/paint-funcs-generic.h
* app/paint-funcs/paint-funcs.c
* libgimpmath/gimpmath.h
* libgimpwidgets/gimpwidgets.c
* plug-ins/common/CML_explorer.c
* plug-ins/common/blur.c
* plug-ins/common/cubism.c
* plug-ins/common/gee.c
* plug-ins/common/gee_zoom.c
* plug-ins/common/gqbist.c
* plug-ins/common/jigsaw.c
* plug-ins/common/lic.c
* plug-ins/common/noisify.c
* plug-ins/common/nova.c
* plug-ins/common/papertile.c
* plug-ins/common/plasma.c
* plug-ins/common/randomize.c
* plug-ins/common/sample_colorize.c
* plug-ins/common/scatter_hsv.c
* plug-ins/common/shift.c
* plug-ins/common/sinus.c
* plug-ins/common/smooth_palette.c
* plug-ins/common/snoise.c
* plug-ins/common/sparkle.c
* plug-ins/common/spheredesigner.c
* plug-ins/common/spread.c
* plug-ins/common/warp.c
* plug-ins/common/wind.c
* plug-ins/flame/cmap.c
* plug-ins/flame/flame.c
* plug-ins/flame/libifs.c
* plug-ins/gflare/gflare.c
* plug-ins/gimpressionist/gimpressionist.c
* plug-ins/gimpressionist/gimpressionist.h
* plug-ins/gimpressionist/plasma.c
* plug-ins/gimpressionist/repaint.c
* plug-ins/ifscompose/ifscompose_utils.c
* plug-ins/maze/algorithms.c
* plug-ins/maze/maze.c
* plug-ins/maze/maze.h
* plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX,
G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(),
srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand*
equivalent. Programs which require seed setting for reproducible
results, and anything in the core, gets a dedicated GRand * for
the lifetime required. Programs which only ever used random
numbers for tossing a coin, rolling a dice, etc use g_random
functions. For the rest, judgement was used. Where it was easy, a
GRand * object was used and g_rand_* functions were
preferred. This fixes bug #67386 in HEAD.
2002-11-20 09:27:48 +00:00
GRand * gr ;
gr = g_rand_new ( ) ;
2001-01-18 14:41:35 +00:00
2001-01-17 20:29:42 +00:00
for ( k = 0 ; k < MAX_TRANSFORMS ; k + + )
2000-01-06 22:26:10 +00:00
{
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c
2002-11-20 Dave Neary <bolsh@gimp.org>
* configure.in
* app/core/gimpbrushpipe.c
* app/gui/about-dialog.c
* app/paint-funcs/paint-funcs-generic.h
* app/paint-funcs/paint-funcs.c
* libgimpmath/gimpmath.h
* libgimpwidgets/gimpwidgets.c
* plug-ins/common/CML_explorer.c
* plug-ins/common/blur.c
* plug-ins/common/cubism.c
* plug-ins/common/gee.c
* plug-ins/common/gee_zoom.c
* plug-ins/common/gqbist.c
* plug-ins/common/jigsaw.c
* plug-ins/common/lic.c
* plug-ins/common/noisify.c
* plug-ins/common/nova.c
* plug-ins/common/papertile.c
* plug-ins/common/plasma.c
* plug-ins/common/randomize.c
* plug-ins/common/sample_colorize.c
* plug-ins/common/scatter_hsv.c
* plug-ins/common/shift.c
* plug-ins/common/sinus.c
* plug-ins/common/smooth_palette.c
* plug-ins/common/snoise.c
* plug-ins/common/sparkle.c
* plug-ins/common/spheredesigner.c
* plug-ins/common/spread.c
* plug-ins/common/warp.c
* plug-ins/common/wind.c
* plug-ins/flame/cmap.c
* plug-ins/flame/flame.c
* plug-ins/flame/libifs.c
* plug-ins/gflare/gflare.c
* plug-ins/gimpressionist/gimpressionist.c
* plug-ins/gimpressionist/gimpressionist.h
* plug-ins/gimpressionist/plasma.c
* plug-ins/gimpressionist/repaint.c
* plug-ins/ifscompose/ifscompose_utils.c
* plug-ins/maze/algorithms.c
* plug-ins/maze/maze.c
* plug-ins/maze/maze.h
* plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX,
G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(),
srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand*
equivalent. Programs which require seed setting for reproducible
results, and anything in the core, gets a dedicated GRand * for
the lifetime required. Programs which only ever used random
numbers for tossing a coin, rolling a dice, etc use g_random
functions. For the rest, judgement was used. Where it was easy, a
GRand * object was used and g_rand_* functions were
preferred. This fixes bug #67386 in HEAD.
2002-11-20 09:27:48 +00:00
info - > transformSequence [ k ] = g_rand_int_range ( gr , 0 , NUM_TRANSFORMS ) ;
info - > source [ k ] = g_rand_int_range ( gr , 0 , NUM_REGISTERS ) ;
info - > control [ k ] = g_rand_int_range ( gr , 0 , NUM_REGISTERS ) ;
info - > dest [ k ] = g_rand_int_range ( gr , 0 , NUM_REGISTERS ) ;
2000-01-06 22:26:10 +00:00
}
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c
2002-11-20 Dave Neary <bolsh@gimp.org>
* configure.in
* app/core/gimpbrushpipe.c
* app/gui/about-dialog.c
* app/paint-funcs/paint-funcs-generic.h
* app/paint-funcs/paint-funcs.c
* libgimpmath/gimpmath.h
* libgimpwidgets/gimpwidgets.c
* plug-ins/common/CML_explorer.c
* plug-ins/common/blur.c
* plug-ins/common/cubism.c
* plug-ins/common/gee.c
* plug-ins/common/gee_zoom.c
* plug-ins/common/gqbist.c
* plug-ins/common/jigsaw.c
* plug-ins/common/lic.c
* plug-ins/common/noisify.c
* plug-ins/common/nova.c
* plug-ins/common/papertile.c
* plug-ins/common/plasma.c
* plug-ins/common/randomize.c
* plug-ins/common/sample_colorize.c
* plug-ins/common/scatter_hsv.c
* plug-ins/common/shift.c
* plug-ins/common/sinus.c
* plug-ins/common/smooth_palette.c
* plug-ins/common/snoise.c
* plug-ins/common/sparkle.c
* plug-ins/common/spheredesigner.c
* plug-ins/common/spread.c
* plug-ins/common/warp.c
* plug-ins/common/wind.c
* plug-ins/flame/cmap.c
* plug-ins/flame/flame.c
* plug-ins/flame/libifs.c
* plug-ins/gflare/gflare.c
* plug-ins/gimpressionist/gimpressionist.c
* plug-ins/gimpressionist/gimpressionist.h
* plug-ins/gimpressionist/plasma.c
* plug-ins/gimpressionist/repaint.c
* plug-ins/ifscompose/ifscompose_utils.c
* plug-ins/maze/algorithms.c
* plug-ins/maze/maze.c
* plug-ins/maze/maze.h
* plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX,
G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(),
srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand*
equivalent. Programs which require seed setting for reproducible
results, and anything in the core, gets a dedicated GRand * for
the lifetime required. Programs which only ever used random
numbers for tossing a coin, rolling a dice, etc use g_random
functions. For the rest, judgement was used. Where it was easy, a
GRand * object was used and g_rand_* functions were
preferred. This fixes bug #67386 in HEAD.
2002-11-20 09:27:48 +00:00
g_rand_free ( gr ) ;
1997-11-24 22:05:25 +00:00
}
2000-01-25 17:46:56 +00:00
static void
2001-01-18 14:41:35 +00:00
modify_info ( ExpInfo * o_info ,
ExpInfo * n_info )
1997-11-24 22:05:25 +00:00
{
2001-01-18 14:41:35 +00:00
gint k , n ;
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c
2002-11-20 Dave Neary <bolsh@gimp.org>
* configure.in
* app/core/gimpbrushpipe.c
* app/gui/about-dialog.c
* app/paint-funcs/paint-funcs-generic.h
* app/paint-funcs/paint-funcs.c
* libgimpmath/gimpmath.h
* libgimpwidgets/gimpwidgets.c
* plug-ins/common/CML_explorer.c
* plug-ins/common/blur.c
* plug-ins/common/cubism.c
* plug-ins/common/gee.c
* plug-ins/common/gee_zoom.c
* plug-ins/common/gqbist.c
* plug-ins/common/jigsaw.c
* plug-ins/common/lic.c
* plug-ins/common/noisify.c
* plug-ins/common/nova.c
* plug-ins/common/papertile.c
* plug-ins/common/plasma.c
* plug-ins/common/randomize.c
* plug-ins/common/sample_colorize.c
* plug-ins/common/scatter_hsv.c
* plug-ins/common/shift.c
* plug-ins/common/sinus.c
* plug-ins/common/smooth_palette.c
* plug-ins/common/snoise.c
* plug-ins/common/sparkle.c
* plug-ins/common/spheredesigner.c
* plug-ins/common/spread.c
* plug-ins/common/warp.c
* plug-ins/common/wind.c
* plug-ins/flame/cmap.c
* plug-ins/flame/flame.c
* plug-ins/flame/libifs.c
* plug-ins/gflare/gflare.c
* plug-ins/gimpressionist/gimpressionist.c
* plug-ins/gimpressionist/gimpressionist.h
* plug-ins/gimpressionist/plasma.c
* plug-ins/gimpressionist/repaint.c
* plug-ins/ifscompose/ifscompose_utils.c
* plug-ins/maze/algorithms.c
* plug-ins/maze/maze.c
* plug-ins/maze/maze.h
* plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX,
G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(),
srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand*
equivalent. Programs which require seed setting for reproducible
results, and anything in the core, gets a dedicated GRand * for
the lifetime required. Programs which only ever used random
numbers for tossing a coin, rolling a dice, etc use g_random
functions. For the rest, judgement was used. Where it was easy, a
GRand * object was used and g_rand_* functions were
preferred. This fixes bug #67386 in HEAD.
2002-11-20 09:27:48 +00:00
GRand * gr ;
2001-01-18 14:41:35 +00:00
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c
2002-11-20 Dave Neary <bolsh@gimp.org>
* configure.in
* app/core/gimpbrushpipe.c
* app/gui/about-dialog.c
* app/paint-funcs/paint-funcs-generic.h
* app/paint-funcs/paint-funcs.c
* libgimpmath/gimpmath.h
* libgimpwidgets/gimpwidgets.c
* plug-ins/common/CML_explorer.c
* plug-ins/common/blur.c
* plug-ins/common/cubism.c
* plug-ins/common/gee.c
* plug-ins/common/gee_zoom.c
* plug-ins/common/gqbist.c
* plug-ins/common/jigsaw.c
* plug-ins/common/lic.c
* plug-ins/common/noisify.c
* plug-ins/common/nova.c
* plug-ins/common/papertile.c
* plug-ins/common/plasma.c
* plug-ins/common/randomize.c
* plug-ins/common/sample_colorize.c
* plug-ins/common/scatter_hsv.c
* plug-ins/common/shift.c
* plug-ins/common/sinus.c
* plug-ins/common/smooth_palette.c
* plug-ins/common/snoise.c
* plug-ins/common/sparkle.c
* plug-ins/common/spheredesigner.c
* plug-ins/common/spread.c
* plug-ins/common/warp.c
* plug-ins/common/wind.c
* plug-ins/flame/cmap.c
* plug-ins/flame/flame.c
* plug-ins/flame/libifs.c
* plug-ins/gflare/gflare.c
* plug-ins/gimpressionist/gimpressionist.c
* plug-ins/gimpressionist/gimpressionist.h
* plug-ins/gimpressionist/plasma.c
* plug-ins/gimpressionist/repaint.c
* plug-ins/ifscompose/ifscompose_utils.c
* plug-ins/maze/algorithms.c
* plug-ins/maze/maze.c
* plug-ins/maze/maze.h
* plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX,
G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(),
srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand*
equivalent. Programs which require seed setting for reproducible
results, and anything in the core, gets a dedicated GRand * for
the lifetime required. Programs which only ever used random
numbers for tossing a coin, rolling a dice, etc use g_random
functions. For the rest, judgement was used. Where it was easy, a
GRand * object was used and g_rand_* functions were
preferred. This fixes bug #67386 in HEAD.
2002-11-20 09:27:48 +00:00
gr = g_rand_new ( ) ;
2002-06-13 20:32:21 +00:00
* n_info = * o_info ;
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c
2002-11-20 Dave Neary <bolsh@gimp.org>
* configure.in
* app/core/gimpbrushpipe.c
* app/gui/about-dialog.c
* app/paint-funcs/paint-funcs-generic.h
* app/paint-funcs/paint-funcs.c
* libgimpmath/gimpmath.h
* libgimpwidgets/gimpwidgets.c
* plug-ins/common/CML_explorer.c
* plug-ins/common/blur.c
* plug-ins/common/cubism.c
* plug-ins/common/gee.c
* plug-ins/common/gee_zoom.c
* plug-ins/common/gqbist.c
* plug-ins/common/jigsaw.c
* plug-ins/common/lic.c
* plug-ins/common/noisify.c
* plug-ins/common/nova.c
* plug-ins/common/papertile.c
* plug-ins/common/plasma.c
* plug-ins/common/randomize.c
* plug-ins/common/sample_colorize.c
* plug-ins/common/scatter_hsv.c
* plug-ins/common/shift.c
* plug-ins/common/sinus.c
* plug-ins/common/smooth_palette.c
* plug-ins/common/snoise.c
* plug-ins/common/sparkle.c
* plug-ins/common/spheredesigner.c
* plug-ins/common/spread.c
* plug-ins/common/warp.c
* plug-ins/common/wind.c
* plug-ins/flame/cmap.c
* plug-ins/flame/flame.c
* plug-ins/flame/libifs.c
* plug-ins/gflare/gflare.c
* plug-ins/gimpressionist/gimpressionist.c
* plug-ins/gimpressionist/gimpressionist.h
* plug-ins/gimpressionist/plasma.c
* plug-ins/gimpressionist/repaint.c
* plug-ins/ifscompose/ifscompose_utils.c
* plug-ins/maze/algorithms.c
* plug-ins/maze/maze.c
* plug-ins/maze/maze.h
* plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX,
G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(),
srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand*
equivalent. Programs which require seed setting for reproducible
results, and anything in the core, gets a dedicated GRand * for
the lifetime required. Programs which only ever used random
numbers for tossing a coin, rolling a dice, etc use g_random
functions. For the rest, judgement was used. Where it was easy, a
GRand * object was used and g_rand_* functions were
preferred. This fixes bug #67386 in HEAD.
2002-11-20 09:27:48 +00:00
n = g_rand_int_range ( gr , 0 , MAX_TRANSFORMS ) ;
2001-01-17 20:29:42 +00:00
for ( k = 0 ; k < n ; k + + )
2000-01-06 22:26:10 +00:00
{
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c
2002-11-20 Dave Neary <bolsh@gimp.org>
* configure.in
* app/core/gimpbrushpipe.c
* app/gui/about-dialog.c
* app/paint-funcs/paint-funcs-generic.h
* app/paint-funcs/paint-funcs.c
* libgimpmath/gimpmath.h
* libgimpwidgets/gimpwidgets.c
* plug-ins/common/CML_explorer.c
* plug-ins/common/blur.c
* plug-ins/common/cubism.c
* plug-ins/common/gee.c
* plug-ins/common/gee_zoom.c
* plug-ins/common/gqbist.c
* plug-ins/common/jigsaw.c
* plug-ins/common/lic.c
* plug-ins/common/noisify.c
* plug-ins/common/nova.c
* plug-ins/common/papertile.c
* plug-ins/common/plasma.c
* plug-ins/common/randomize.c
* plug-ins/common/sample_colorize.c
* plug-ins/common/scatter_hsv.c
* plug-ins/common/shift.c
* plug-ins/common/sinus.c
* plug-ins/common/smooth_palette.c
* plug-ins/common/snoise.c
* plug-ins/common/sparkle.c
* plug-ins/common/spheredesigner.c
* plug-ins/common/spread.c
* plug-ins/common/warp.c
* plug-ins/common/wind.c
* plug-ins/flame/cmap.c
* plug-ins/flame/flame.c
* plug-ins/flame/libifs.c
* plug-ins/gflare/gflare.c
* plug-ins/gimpressionist/gimpressionist.c
* plug-ins/gimpressionist/gimpressionist.h
* plug-ins/gimpressionist/plasma.c
* plug-ins/gimpressionist/repaint.c
* plug-ins/ifscompose/ifscompose_utils.c
* plug-ins/maze/algorithms.c
* plug-ins/maze/maze.c
* plug-ins/maze/maze.h
* plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX,
G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(),
srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand*
equivalent. Programs which require seed setting for reproducible
results, and anything in the core, gets a dedicated GRand * for
the lifetime required. Programs which only ever used random
numbers for tossing a coin, rolling a dice, etc use g_random
functions. For the rest, judgement was used. Where it was easy, a
GRand * object was used and g_rand_* functions were
preferred. This fixes bug #67386 in HEAD.
2002-11-20 09:27:48 +00:00
switch ( g_rand_int_range ( gr , 0 , 4 ) )
2000-01-06 22:26:10 +00:00
{
2001-01-17 20:29:42 +00:00
case 0 :
2003-08-23 19:35:05 +00:00
n_info - > transformSequence [ g_rand_int_range ( gr , 0 , MAX_TRANSFORMS ) ] =
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c
2002-11-20 Dave Neary <bolsh@gimp.org>
* configure.in
* app/core/gimpbrushpipe.c
* app/gui/about-dialog.c
* app/paint-funcs/paint-funcs-generic.h
* app/paint-funcs/paint-funcs.c
* libgimpmath/gimpmath.h
* libgimpwidgets/gimpwidgets.c
* plug-ins/common/CML_explorer.c
* plug-ins/common/blur.c
* plug-ins/common/cubism.c
* plug-ins/common/gee.c
* plug-ins/common/gee_zoom.c
* plug-ins/common/gqbist.c
* plug-ins/common/jigsaw.c
* plug-ins/common/lic.c
* plug-ins/common/noisify.c
* plug-ins/common/nova.c
* plug-ins/common/papertile.c
* plug-ins/common/plasma.c
* plug-ins/common/randomize.c
* plug-ins/common/sample_colorize.c
* plug-ins/common/scatter_hsv.c
* plug-ins/common/shift.c
* plug-ins/common/sinus.c
* plug-ins/common/smooth_palette.c
* plug-ins/common/snoise.c
* plug-ins/common/sparkle.c
* plug-ins/common/spheredesigner.c
* plug-ins/common/spread.c
* plug-ins/common/warp.c
* plug-ins/common/wind.c
* plug-ins/flame/cmap.c
* plug-ins/flame/flame.c
* plug-ins/flame/libifs.c
* plug-ins/gflare/gflare.c
* plug-ins/gimpressionist/gimpressionist.c
* plug-ins/gimpressionist/gimpressionist.h
* plug-ins/gimpressionist/plasma.c
* plug-ins/gimpressionist/repaint.c
* plug-ins/ifscompose/ifscompose_utils.c
* plug-ins/maze/algorithms.c
* plug-ins/maze/maze.c
* plug-ins/maze/maze.h
* plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX,
G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(),
srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand*
equivalent. Programs which require seed setting for reproducible
results, and anything in the core, gets a dedicated GRand * for
the lifetime required. Programs which only ever used random
numbers for tossing a coin, rolling a dice, etc use g_random
functions. For the rest, judgement was used. Where it was easy, a
GRand * object was used and g_rand_* functions were
preferred. This fixes bug #67386 in HEAD.
2002-11-20 09:27:48 +00:00
g_rand_int_range ( gr , 0 , NUM_TRANSFORMS ) ;
2001-01-17 20:29:42 +00:00
break ;
2001-01-18 14:41:35 +00:00
2001-01-17 20:29:42 +00:00
case 1 :
2003-08-23 19:35:05 +00:00
n_info - > source [ g_rand_int_range ( gr , 0 , MAX_TRANSFORMS ) ] =
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c
2002-11-20 Dave Neary <bolsh@gimp.org>
* configure.in
* app/core/gimpbrushpipe.c
* app/gui/about-dialog.c
* app/paint-funcs/paint-funcs-generic.h
* app/paint-funcs/paint-funcs.c
* libgimpmath/gimpmath.h
* libgimpwidgets/gimpwidgets.c
* plug-ins/common/CML_explorer.c
* plug-ins/common/blur.c
* plug-ins/common/cubism.c
* plug-ins/common/gee.c
* plug-ins/common/gee_zoom.c
* plug-ins/common/gqbist.c
* plug-ins/common/jigsaw.c
* plug-ins/common/lic.c
* plug-ins/common/noisify.c
* plug-ins/common/nova.c
* plug-ins/common/papertile.c
* plug-ins/common/plasma.c
* plug-ins/common/randomize.c
* plug-ins/common/sample_colorize.c
* plug-ins/common/scatter_hsv.c
* plug-ins/common/shift.c
* plug-ins/common/sinus.c
* plug-ins/common/smooth_palette.c
* plug-ins/common/snoise.c
* plug-ins/common/sparkle.c
* plug-ins/common/spheredesigner.c
* plug-ins/common/spread.c
* plug-ins/common/warp.c
* plug-ins/common/wind.c
* plug-ins/flame/cmap.c
* plug-ins/flame/flame.c
* plug-ins/flame/libifs.c
* plug-ins/gflare/gflare.c
* plug-ins/gimpressionist/gimpressionist.c
* plug-ins/gimpressionist/gimpressionist.h
* plug-ins/gimpressionist/plasma.c
* plug-ins/gimpressionist/repaint.c
* plug-ins/ifscompose/ifscompose_utils.c
* plug-ins/maze/algorithms.c
* plug-ins/maze/maze.c
* plug-ins/maze/maze.h
* plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX,
G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(),
srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand*
equivalent. Programs which require seed setting for reproducible
results, and anything in the core, gets a dedicated GRand * for
the lifetime required. Programs which only ever used random
numbers for tossing a coin, rolling a dice, etc use g_random
functions. For the rest, judgement was used. Where it was easy, a
GRand * object was used and g_rand_* functions were
preferred. This fixes bug #67386 in HEAD.
2002-11-20 09:27:48 +00:00
g_rand_int_range ( gr , 0 , NUM_REGISTERS ) ;
2001-01-17 20:29:42 +00:00
break ;
2001-01-18 14:41:35 +00:00
2001-01-17 20:29:42 +00:00
case 2 :
2003-08-23 19:35:05 +00:00
n_info - > control [ g_rand_int_range ( gr , 0 , MAX_TRANSFORMS ) ] =
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c
2002-11-20 Dave Neary <bolsh@gimp.org>
* configure.in
* app/core/gimpbrushpipe.c
* app/gui/about-dialog.c
* app/paint-funcs/paint-funcs-generic.h
* app/paint-funcs/paint-funcs.c
* libgimpmath/gimpmath.h
* libgimpwidgets/gimpwidgets.c
* plug-ins/common/CML_explorer.c
* plug-ins/common/blur.c
* plug-ins/common/cubism.c
* plug-ins/common/gee.c
* plug-ins/common/gee_zoom.c
* plug-ins/common/gqbist.c
* plug-ins/common/jigsaw.c
* plug-ins/common/lic.c
* plug-ins/common/noisify.c
* plug-ins/common/nova.c
* plug-ins/common/papertile.c
* plug-ins/common/plasma.c
* plug-ins/common/randomize.c
* plug-ins/common/sample_colorize.c
* plug-ins/common/scatter_hsv.c
* plug-ins/common/shift.c
* plug-ins/common/sinus.c
* plug-ins/common/smooth_palette.c
* plug-ins/common/snoise.c
* plug-ins/common/sparkle.c
* plug-ins/common/spheredesigner.c
* plug-ins/common/spread.c
* plug-ins/common/warp.c
* plug-ins/common/wind.c
* plug-ins/flame/cmap.c
* plug-ins/flame/flame.c
* plug-ins/flame/libifs.c
* plug-ins/gflare/gflare.c
* plug-ins/gimpressionist/gimpressionist.c
* plug-ins/gimpressionist/gimpressionist.h
* plug-ins/gimpressionist/plasma.c
* plug-ins/gimpressionist/repaint.c
* plug-ins/ifscompose/ifscompose_utils.c
* plug-ins/maze/algorithms.c
* plug-ins/maze/maze.c
* plug-ins/maze/maze.h
* plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX,
G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(),
srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand*
equivalent. Programs which require seed setting for reproducible
results, and anything in the core, gets a dedicated GRand * for
the lifetime required. Programs which only ever used random
numbers for tossing a coin, rolling a dice, etc use g_random
functions. For the rest, judgement was used. Where it was easy, a
GRand * object was used and g_rand_* functions were
preferred. This fixes bug #67386 in HEAD.
2002-11-20 09:27:48 +00:00
g_rand_int_range ( gr , 0 , NUM_REGISTERS ) ;
2001-01-17 20:29:42 +00:00
break ;
2001-01-18 14:41:35 +00:00
2001-01-17 20:29:42 +00:00
case 3 :
2003-08-23 19:35:05 +00:00
n_info - > dest [ g_rand_int_range ( gr , 0 , MAX_TRANSFORMS ) ] =
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c
2002-11-20 Dave Neary <bolsh@gimp.org>
* configure.in
* app/core/gimpbrushpipe.c
* app/gui/about-dialog.c
* app/paint-funcs/paint-funcs-generic.h
* app/paint-funcs/paint-funcs.c
* libgimpmath/gimpmath.h
* libgimpwidgets/gimpwidgets.c
* plug-ins/common/CML_explorer.c
* plug-ins/common/blur.c
* plug-ins/common/cubism.c
* plug-ins/common/gee.c
* plug-ins/common/gee_zoom.c
* plug-ins/common/gqbist.c
* plug-ins/common/jigsaw.c
* plug-ins/common/lic.c
* plug-ins/common/noisify.c
* plug-ins/common/nova.c
* plug-ins/common/papertile.c
* plug-ins/common/plasma.c
* plug-ins/common/randomize.c
* plug-ins/common/sample_colorize.c
* plug-ins/common/scatter_hsv.c
* plug-ins/common/shift.c
* plug-ins/common/sinus.c
* plug-ins/common/smooth_palette.c
* plug-ins/common/snoise.c
* plug-ins/common/sparkle.c
* plug-ins/common/spheredesigner.c
* plug-ins/common/spread.c
* plug-ins/common/warp.c
* plug-ins/common/wind.c
* plug-ins/flame/cmap.c
* plug-ins/flame/flame.c
* plug-ins/flame/libifs.c
* plug-ins/gflare/gflare.c
* plug-ins/gimpressionist/gimpressionist.c
* plug-ins/gimpressionist/gimpressionist.h
* plug-ins/gimpressionist/plasma.c
* plug-ins/gimpressionist/repaint.c
* plug-ins/ifscompose/ifscompose_utils.c
* plug-ins/maze/algorithms.c
* plug-ins/maze/maze.c
* plug-ins/maze/maze.h
* plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX,
G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(),
srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand*
equivalent. Programs which require seed setting for reproducible
results, and anything in the core, gets a dedicated GRand * for
the lifetime required. Programs which only ever used random
numbers for tossing a coin, rolling a dice, etc use g_random
functions. For the rest, judgement was used. Where it was easy, a
GRand * object was used and g_rand_* functions were
preferred. This fixes bug #67386 in HEAD.
2002-11-20 09:27:48 +00:00
g_rand_int_range ( gr , 0 , NUM_REGISTERS ) ;
2001-01-17 20:29:42 +00:00
break ;
1997-11-24 22:05:25 +00:00
}
2000-01-06 22:26:10 +00:00
}
configure.in app/core/gimpbrushpipe.c app/gui/about-dialog.c
2002-11-20 Dave Neary <bolsh@gimp.org>
* configure.in
* app/core/gimpbrushpipe.c
* app/gui/about-dialog.c
* app/paint-funcs/paint-funcs-generic.h
* app/paint-funcs/paint-funcs.c
* libgimpmath/gimpmath.h
* libgimpwidgets/gimpwidgets.c
* plug-ins/common/CML_explorer.c
* plug-ins/common/blur.c
* plug-ins/common/cubism.c
* plug-ins/common/gee.c
* plug-ins/common/gee_zoom.c
* plug-ins/common/gqbist.c
* plug-ins/common/jigsaw.c
* plug-ins/common/lic.c
* plug-ins/common/noisify.c
* plug-ins/common/nova.c
* plug-ins/common/papertile.c
* plug-ins/common/plasma.c
* plug-ins/common/randomize.c
* plug-ins/common/sample_colorize.c
* plug-ins/common/scatter_hsv.c
* plug-ins/common/shift.c
* plug-ins/common/sinus.c
* plug-ins/common/smooth_palette.c
* plug-ins/common/snoise.c
* plug-ins/common/sparkle.c
* plug-ins/common/spheredesigner.c
* plug-ins/common/spread.c
* plug-ins/common/warp.c
* plug-ins/common/wind.c
* plug-ins/flame/cmap.c
* plug-ins/flame/flame.c
* plug-ins/flame/libifs.c
* plug-ins/gflare/gflare.c
* plug-ins/gimpressionist/gimpressionist.c
* plug-ins/gimpressionist/gimpressionist.h
* plug-ins/gimpressionist/plasma.c
* plug-ins/gimpressionist/repaint.c
* plug-ins/ifscompose/ifscompose_utils.c
* plug-ins/maze/algorithms.c
* plug-ins/maze/maze.c
* plug-ins/maze/maze.h
* plug-ins/mosaic/mosaic.c: Change all occurrences of RAND_MAX,
G_MAXRAND, rand(), srand(), lrand48(), srand48(), random(),
srandom(), RAND_FUNC and SRAND_FUNC to the appropriate g_rand*
equivalent. Programs which require seed setting for reproducible
results, and anything in the core, gets a dedicated GRand * for
the lifetime required. Programs which only ever used random
numbers for tossing a coin, rolling a dice, etc use g_random
functions. For the rest, judgement was used. Where it was easy, a
GRand * object was used and g_rand_* functions were
preferred. This fixes bug #67386 in HEAD.
2002-11-20 09:27:48 +00:00
g_rand_free ( gr ) ;
1997-11-24 22:05:25 +00:00
}
1998-03-09 01:45:26 +00:00
/*
* Optimizer
*/
2000-01-25 17:46:56 +00:00
static gint used_trans_flag [ MAX_TRANSFORMS ] ;
static gint used_reg_flag [ NUM_REGISTERS ] ;
1998-03-09 01:45:26 +00:00
2000-01-25 17:46:56 +00:00
static void
2002-06-13 20:32:21 +00:00
check_last_modified ( ExpInfo * info ,
2001-01-18 14:41:35 +00:00
gint p ,
gint n )
1998-03-09 01:45:26 +00:00
{
2000-01-06 22:26:10 +00:00
p - - ;
2002-06-13 20:32:21 +00:00
while ( ( p > = 0 ) & & ( info - > dest [ p ] ! = n ) )
2001-01-17 20:29:42 +00:00
p - - ;
if ( p < 0 )
used_reg_flag [ n ] = 1 ;
2000-01-06 22:26:10 +00:00
else
{
2001-01-17 20:29:42 +00:00
used_trans_flag [ p ] = 1 ;
2002-06-13 20:32:21 +00:00
check_last_modified ( info , p , info - > source [ p ] ) ;
check_last_modified ( info , p , info - > control [ p ] ) ;
2000-01-06 22:26:10 +00:00
}
1998-03-09 01:45:26 +00:00
}
2000-01-25 17:46:56 +00:00
static void
2002-06-13 20:32:21 +00:00
optimize ( ExpInfo * info )
1998-03-09 01:45:26 +00:00
{
2001-01-18 14:41:35 +00:00
gint i ;
2000-01-06 22:26:10 +00:00
/* double-arg fix: */
2001-01-17 20:29:42 +00:00
for ( i = 0 ; i < MAX_TRANSFORMS ; i + + )
2000-01-06 22:26:10 +00:00
{
2001-01-17 20:29:42 +00:00
used_trans_flag [ i ] = 0 ;
if ( i < NUM_REGISTERS )
used_reg_flag [ i ] = 0 ;
2000-01-06 22:26:10 +00:00
/* double-arg fix: */
2002-06-13 20:32:21 +00:00
switch ( info - > transformSequence [ i ] )
2000-01-06 22:26:10 +00:00
{
2001-01-17 20:29:42 +00:00
case ROTATE :
case ROTATE2 :
case COMPLEMENT :
2002-06-13 20:32:21 +00:00
info - > control [ i ] = info - > dest [ i ] ;
2000-01-06 22:26:10 +00:00
break ;
2001-01-18 14:41:35 +00:00
default :
break ;
1998-03-09 01:45:26 +00:00
}
2000-01-06 22:26:10 +00:00
}
/* check for last modified item */
2001-01-17 20:29:42 +00:00
check_last_modified ( info , MAX_TRANSFORMS , 0 ) ;
1998-03-09 01:45:26 +00:00
}
2000-01-25 17:46:56 +00:00
static void
2002-06-13 20:32:21 +00:00
qbist ( ExpInfo * info ,
2003-07-03 13:26:06 +00:00
guchar * buffer ,
2001-01-18 14:41:35 +00:00
gint xp ,
gint yp ,
gint num ,
gint width ,
gint height ,
gint bpp ,
gint oversampling )
1997-11-24 22:05:25 +00:00
{
2001-01-17 20:29:42 +00:00
gint gx ;
2001-01-18 14:41:35 +00:00
2001-01-17 20:29:42 +00:00
vreg reg [ NUM_REGISTERS ] ;
2000-01-06 22:26:10 +00:00
2001-01-17 20:29:42 +00:00
for ( gx = 0 ; gx < num ; gx + + )
2000-01-06 22:26:10 +00:00
{
2001-01-17 20:29:42 +00:00
gint accum [ 3 ] , yy , i ;
for ( i = 0 ; i < 3 ; i + + )
2000-01-06 22:26:10 +00:00
{
2001-01-17 20:29:42 +00:00
accum [ i ] = 0 ;
2000-01-06 22:26:10 +00:00
}
2001-01-18 14:41:35 +00:00
2001-01-17 20:29:42 +00:00
for ( yy = 0 ; yy < oversampling ; yy + + )
2000-01-06 22:26:10 +00:00
{
2001-01-18 14:41:35 +00:00
gint xx ;
2000-01-06 22:26:10 +00:00
2001-01-17 20:29:42 +00:00
for ( xx = 0 ; xx < oversampling ; xx + + )
2000-01-06 22:26:10 +00:00
{
2001-01-17 20:29:42 +00:00
for ( i = 0 ; i < NUM_REGISTERS ; i + + )
{
if ( used_reg_flag [ i ] )
{
reg [ i ] [ 0 ] = ( ( gfloat ) ( ( gx + xp ) * oversampling + xx ) ) / ( ( gfloat ) ( width * oversampling ) ) ;
reg [ i ] [ 1 ] = ( ( gfloat ) ( yp * oversampling + yy ) ) / ( ( gfloat ) ( height * oversampling ) ) ;
reg [ i ] [ 2 ] = ( ( gfloat ) i ) / ( ( gfloat ) NUM_REGISTERS ) ;
}
}
2001-01-18 14:41:35 +00:00
2001-01-17 20:29:42 +00:00
for ( i = 0 ; i < MAX_TRANSFORMS ; i + + )
2000-01-06 22:26:10 +00:00
{
2001-01-17 20:29:42 +00:00
gushort sr , cr , dr ;
2002-06-13 20:32:21 +00:00
sr = info - > source [ i ] ;
cr = info - > control [ i ] ;
dr = info - > dest [ i ] ;
2001-01-17 20:29:42 +00:00
if ( used_trans_flag [ i ] )
2002-06-13 20:32:21 +00:00
switch ( info - > transformSequence [ i ] )
2001-01-17 20:29:42 +00:00
{
case PROJECTION :
{
gfloat scalarProd ;
2001-01-18 14:41:35 +00:00
2003-08-23 19:35:05 +00:00
scalarProd = ( reg [ sr ] [ 0 ] * reg [ cr ] [ 0 ] ) +
2001-01-18 14:41:35 +00:00
( reg [ sr ] [ 1 ] * reg [ cr ] [ 1 ] ) + ( reg [ sr ] [ 2 ] * reg [ cr ] [ 2 ] ) ;
2003-08-23 19:35:05 +00:00
2001-01-17 20:29:42 +00:00
reg [ dr ] [ 0 ] = scalarProd * reg [ sr ] [ 0 ] ;
reg [ dr ] [ 1 ] = scalarProd * reg [ sr ] [ 1 ] ;
reg [ dr ] [ 2 ] = scalarProd * reg [ sr ] [ 2 ] ;
break ;
}
2001-01-18 14:41:35 +00:00
2001-01-17 20:29:42 +00:00
case SHIFT :
reg [ dr ] [ 0 ] = reg [ sr ] [ 0 ] + reg [ cr ] [ 0 ] ;
if ( reg [ dr ] [ 0 ] > = 1.0 )
reg [ dr ] [ 0 ] - = 1.0 ;
reg [ dr ] [ 1 ] = reg [ sr ] [ 1 ] + reg [ cr ] [ 1 ] ;
if ( reg [ dr ] [ 1 ] > = 1.0 )
reg [ dr ] [ 1 ] - = 1.0 ;
reg [ dr ] [ 2 ] = reg [ sr ] [ 2 ] + reg [ cr ] [ 2 ] ;
if ( reg [ dr ] [ 2 ] > = 1.0 )
reg [ dr ] [ 2 ] - = 1.0 ;
break ;
2001-01-18 14:41:35 +00:00
2001-01-17 20:29:42 +00:00
case SHIFTBACK :
reg [ dr ] [ 0 ] = reg [ sr ] [ 0 ] - reg [ cr ] [ 0 ] ;
if ( reg [ dr ] [ 0 ] < = 0.0 )
reg [ dr ] [ 0 ] + = 1.0 ;
reg [ dr ] [ 1 ] = reg [ sr ] [ 1 ] - reg [ cr ] [ 1 ] ;
if ( reg [ dr ] [ 1 ] < = 0.0 )
reg [ dr ] [ 1 ] + = 1.0 ;
reg [ dr ] [ 2 ] = reg [ sr ] [ 2 ] - reg [ cr ] [ 2 ] ;
if ( reg [ dr ] [ 2 ] < = 0.0 )
reg [ dr ] [ 2 ] + = 1.0 ;
break ;
2001-01-18 14:41:35 +00:00
2001-01-17 20:29:42 +00:00
case ROTATE :
reg [ dr ] [ 0 ] = reg [ sr ] [ 1 ] ;
reg [ dr ] [ 1 ] = reg [ sr ] [ 2 ] ;
reg [ dr ] [ 2 ] = reg [ sr ] [ 0 ] ;
break ;
2001-01-18 14:41:35 +00:00
2001-01-17 20:29:42 +00:00
case ROTATE2 :
reg [ dr ] [ 0 ] = reg [ sr ] [ 2 ] ;
reg [ dr ] [ 1 ] = reg [ sr ] [ 0 ] ;
reg [ dr ] [ 2 ] = reg [ sr ] [ 1 ] ;
break ;
2001-01-18 14:41:35 +00:00
2001-01-17 20:29:42 +00:00
case MULTIPLY :
reg [ dr ] [ 0 ] = reg [ sr ] [ 0 ] * reg [ cr ] [ 0 ] ;
reg [ dr ] [ 1 ] = reg [ sr ] [ 1 ] * reg [ cr ] [ 1 ] ;
reg [ dr ] [ 2 ] = reg [ sr ] [ 2 ] * reg [ cr ] [ 2 ] ;
break ;
2001-01-18 14:41:35 +00:00
2001-01-17 20:29:42 +00:00
case SINE :
reg [ dr ] [ 0 ] = 0.5 + ( 0.5 * sin ( 20.0 * reg [ sr ] [ 0 ] * reg [ cr ] [ 0 ] ) ) ;
reg [ dr ] [ 1 ] = 0.5 + ( 0.5 * sin ( 20.0 * reg [ sr ] [ 1 ] * reg [ cr ] [ 1 ] ) ) ;
reg [ dr ] [ 2 ] = 0.5 + ( 0.5 * sin ( 20.0 * reg [ sr ] [ 2 ] * reg [ cr ] [ 2 ] ) ) ;
break ;
2001-01-18 14:41:35 +00:00
2001-01-17 20:29:42 +00:00
case CONDITIONAL :
if ( ( reg [ cr ] [ 0 ] + reg [ cr ] [ 1 ] + reg [ cr ] [ 2 ] ) > 0.5 )
{
reg [ dr ] [ 0 ] = reg [ sr ] [ 0 ] ;
reg [ dr ] [ 1 ] = reg [ sr ] [ 1 ] ;
reg [ dr ] [ 2 ] = reg [ sr ] [ 2 ] ;
}
else
{
reg [ dr ] [ 0 ] = reg [ cr ] [ 0 ] ;
reg [ dr ] [ 1 ] = reg [ cr ] [ 1 ] ;
reg [ dr ] [ 2 ] = reg [ cr ] [ 2 ] ;
}
break ;
2001-01-18 14:41:35 +00:00
2001-01-17 20:29:42 +00:00
case COMPLEMENT :
reg [ dr ] [ 0 ] = 1.0 - reg [ sr ] [ 0 ] ;
reg [ dr ] [ 1 ] = 1.0 - reg [ sr ] [ 1 ] ;
reg [ dr ] [ 2 ] = 1.0 - reg [ sr ] [ 2 ] ;
break ;
}
1997-11-24 22:05:25 +00:00
}
2001-01-17 20:29:42 +00:00
for ( i = 0 ; i < 3 ; i + + )
2000-01-06 22:26:10 +00:00
{
2001-01-17 20:29:42 +00:00
accum [ i ] + = ( unsigned char ) ( reg [ 0 ] [ i ] * 255.0 + 0.5 ) ;
1997-11-24 22:05:25 +00:00
}
2000-01-06 22:26:10 +00:00
}
}
2001-01-18 14:41:35 +00:00
2001-01-17 20:29:42 +00:00
for ( i = 0 ; i < bpp ; i + + )
2000-01-06 22:26:10 +00:00
{
2001-01-17 20:29:42 +00:00
if ( i < 3 )
{
2003-08-23 19:35:05 +00:00
buffer [ i ] = ( guchar ) ( ( ( gfloat ) accum [ i ] /
2001-01-18 14:41:35 +00:00
( gfloat ) ( oversampling * oversampling ) ) + 0.5 ) ;
2000-01-06 22:26:10 +00:00
}
else
{
2001-01-17 20:29:42 +00:00
buffer [ i ] = 255 ;
2000-01-06 22:26:10 +00:00
}
1997-11-24 22:05:25 +00:00
}
2001-01-18 14:41:35 +00:00
2001-01-17 20:29:42 +00:00
buffer + = bpp ;
2000-01-06 22:26:10 +00:00
}
1997-11-24 22:05:25 +00:00
}
/** Plugin interface *********************************************************/
2000-08-22 01:26:57 +00:00
GimpPlugInInfo PLUG_IN_INFO =
2000-01-06 22:26:10 +00:00
{
2001-01-17 20:29:42 +00:00
NULL , /* init_proc */
NULL , /* quit_proc */
query , /* query_proc */
run /* run_proc */
1997-11-24 22:05:25 +00:00
} ;
2000-04-30 21:03:44 +00:00
MAIN ( )
1997-11-24 22:05:25 +00:00
2001-01-18 14:41:35 +00:00
static void
query ( void )
1997-11-24 22:05:25 +00:00
{
2000-08-22 01:26:57 +00:00
GimpParamDef args [ ] =
2000-01-25 17:46:56 +00:00
{
2001-01-18 14:41:35 +00:00
{ GIMP_PDB_INT32 , " run_mode " , " Interactive, non-interactive " } ,
{ GIMP_PDB_IMAGE , " image " , " Input image (unused) " } ,
{ GIMP_PDB_DRAWABLE , " drawable " , " Input drawable " }
2000-01-25 17:46:56 +00:00
} ;
gimp_install_procedure ( PLUG_IN_NAME ,
2000-02-13 09:29:59 +00:00
" Create images based on a random genetic formula " ,
2001-09-03 00:26:06 +00:00
" This Plug-in is based on an article by Jörn Loviscach (appeared in c't 10/95, page 326). It generates modern art pictures from a random genetic formula. " ,
" Jörn Loviscach, Jens Ch. Restemeier " ,
" Jörn Loviscach, Jens Ch. Restemeier " ,
2000-01-25 17:46:56 +00:00
PLUG_IN_VERSION ,
2003-07-17 15:47:18 +00:00
N_ ( " <Image>/Filters/Render/Pattern/_Qbist... " ) ,
2000-01-25 17:46:56 +00:00
" RGB* " ,
2000-08-22 01:26:57 +00:00
GIMP_PLUGIN ,
2001-12-06 02:28:58 +00:00
G_N_ELEMENTS ( args ) , 0 ,
2000-01-25 17:46:56 +00:00
args , NULL ) ;
1997-11-24 22:05:25 +00:00
}
2000-01-25 17:46:56 +00:00
static void
2003-07-02 11:07:41 +00:00
run ( const gchar * name ,
gint nparams ,
const GimpParam * param ,
gint * nreturn_vals ,
GimpParam * * return_vals )
1997-11-24 22:05:25 +00:00
{
2000-08-22 01:26:57 +00:00
static GimpParam values [ 1 ] ;
2000-01-06 22:26:10 +00:00
gint sel_x1 , sel_y1 , sel_x2 , sel_y2 ;
gint img_height , img_width , img_bpp , img_has_alpha ;
2001-01-18 14:41:35 +00:00
GimpDrawable * drawable ;
2003-07-02 11:07:41 +00:00
GimpRunMode run_mode ;
2001-01-18 14:41:35 +00:00
GimpPDBStatusType status ;
2000-01-06 22:26:10 +00:00
* nreturn_vals = 1 ;
2001-01-17 20:29:42 +00:00
* return_vals = values ;
2000-01-06 22:26:10 +00:00
2000-08-22 01:26:57 +00:00
status = GIMP_PDB_SUCCESS ;
2000-01-06 22:26:10 +00:00
2001-01-17 20:29:42 +00:00
if ( param [ 0 ] . type ! = GIMP_PDB_INT32 )
status = GIMP_PDB_CALLING_ERROR ;
2000-01-06 22:26:10 +00:00
run_mode = param [ 0 ] . data . d_int32 ;
2003-03-25 16:38:19 +00:00
INIT_I18N ( ) ;
2000-01-06 22:26:10 +00:00
2001-01-17 20:29:42 +00:00
if ( param [ 2 ] . type ! = GIMP_PDB_DRAWABLE )
status = GIMP_PDB_CALLING_ERROR ;
2001-01-18 14:41:35 +00:00
2001-01-17 20:29:42 +00:00
drawable = gimp_drawable_get ( param [ 2 ] . data . d_drawable ) ;
2000-01-06 22:26:10 +00:00
2001-06-14 20:07:38 +00:00
img_width = gimp_drawable_width ( drawable - > drawable_id ) ;
img_height = gimp_drawable_height ( drawable - > drawable_id ) ;
img_bpp = gimp_drawable_bpp ( drawable - > drawable_id ) ;
img_has_alpha = gimp_drawable_has_alpha ( drawable - > drawable_id ) ;
gimp_drawable_mask_bounds ( drawable - > drawable_id ,
& sel_x1 , & sel_y1 , & sel_x2 , & sel_y2 ) ;
if ( ! gimp_drawable_is_rgb ( drawable - > drawable_id ) )
2001-01-17 20:29:42 +00:00
status = GIMP_PDB_CALLING_ERROR ;
if ( status = = GIMP_PDB_SUCCESS )
2000-01-06 22:26:10 +00:00
{
2001-01-17 20:29:42 +00:00
memset ( & qbist_info , 0 , sizeof ( qbist_info ) ) ;
create_info ( & qbist_info . info ) ;
qbist_info . oversampling = 4 ;
2001-01-18 14:41:35 +00:00
2000-01-06 22:26:10 +00:00
switch ( run_mode )
{
2000-08-22 01:26:57 +00:00
case GIMP_RUN_INTERACTIVE :
2000-01-06 22:26:10 +00:00
/* Possibly retrieve data */
2001-01-17 20:29:42 +00:00
gimp_get_data ( PLUG_IN_NAME , & qbist_info ) ;
2000-01-06 22:26:10 +00:00
2001-01-17 20:29:42 +00:00
/* Get information from the dialog */
if ( dialog_create ( ) )
2000-01-06 22:26:10 +00:00
{
2001-01-17 20:29:42 +00:00
status = GIMP_PDB_SUCCESS ;
2001-01-18 14:41:35 +00:00
gimp_set_data ( PLUG_IN_NAME , & qbist_info , sizeof ( QbistInfo ) ) ;
2000-01-06 22:26:10 +00:00
}
else
2001-01-17 20:29:42 +00:00
status = GIMP_PDB_EXECUTION_ERROR ;
2000-01-06 22:26:10 +00:00
break ;
2000-08-22 01:26:57 +00:00
case GIMP_RUN_NONINTERACTIVE :
2001-01-17 20:29:42 +00:00
status = GIMP_PDB_CALLING_ERROR ;
2000-01-06 22:26:10 +00:00
break ;
2000-08-22 01:26:57 +00:00
case GIMP_RUN_WITH_LAST_VALS :
2000-01-06 22:26:10 +00:00
/* Possibly retrieve data */
2001-01-17 20:29:42 +00:00
gimp_get_data ( PLUG_IN_NAME , & qbist_info ) ;
status = GIMP_PDB_SUCCESS ;
2000-01-06 22:26:10 +00:00
break ;
2001-01-18 14:41:35 +00:00
2000-01-06 22:26:10 +00:00
default :
2001-01-17 20:29:42 +00:00
status = GIMP_PDB_CALLING_ERROR ;
2000-01-06 22:26:10 +00:00
break ;
2001-01-17 20:29:42 +00:00
}
2001-01-18 14:41:35 +00:00
2000-08-22 01:26:57 +00:00
if ( status = = GIMP_PDB_SUCCESS )
2000-01-06 22:26:10 +00:00
{
2000-08-22 01:26:57 +00:00
GimpPixelRgn imagePR ;
2001-01-18 14:41:35 +00:00
gpointer pr ;
2000-01-06 22:26:10 +00:00
2001-01-18 14:41:35 +00:00
gimp_tile_cache_ntiles ( ( drawable - > width + gimp_tile_width ( ) - 1 ) /
gimp_tile_width ( ) ) ;
2003-08-23 19:35:05 +00:00
gimp_pixel_rgn_init ( & imagePR , drawable ,
2001-01-18 14:41:35 +00:00
0 , 0 , img_width , img_height , TRUE , TRUE ) ;
2000-01-06 22:26:10 +00:00
2002-06-13 20:32:21 +00:00
optimize ( & qbist_info . info ) ;
2000-01-06 22:26:10 +00:00
2001-07-31 23:28:56 +00:00
gimp_progress_init ( _ ( " Qbist ... " ) ) ;
2001-01-17 20:29:42 +00:00
2003-08-23 19:35:05 +00:00
for ( pr = gimp_pixel_rgns_register ( 1 , & imagePR ) ;
pr ! = NULL ;
2001-01-18 14:41:35 +00:00
pr = gimp_pixel_rgns_process ( pr ) )
2000-01-06 22:26:10 +00:00
{
2001-01-17 20:29:42 +00:00
gint row ;
2001-01-18 14:41:35 +00:00
2001-01-17 20:29:42 +00:00
for ( row = 0 ; row < imagePR . h ; row + + )
{
2003-08-23 19:35:05 +00:00
qbist ( & qbist_info . info ,
imagePR . data + row * imagePR . rowstride ,
imagePR . x ,
imagePR . y + row ,
imagePR . w ,
sel_x2 - sel_x1 ,
sel_y2 - sel_y1 ,
imagePR . bpp ,
2001-01-18 14:41:35 +00:00
qbist_info . oversampling ) ;
2001-01-17 20:29:42 +00:00
}
2001-01-18 14:41:35 +00:00
2003-08-23 19:35:05 +00:00
gimp_progress_update ( ( gfloat ) ( imagePR . y - sel_y1 ) /
2001-01-18 14:41:35 +00:00
( gfloat ) ( sel_y2 - sel_y1 ) ) ;
2000-01-06 22:26:10 +00:00
}
gimp_drawable_flush ( drawable ) ;
2001-06-14 20:07:38 +00:00
gimp_drawable_merge_shadow ( drawable - > drawable_id , TRUE ) ;
2003-08-23 19:35:05 +00:00
gimp_drawable_update ( drawable - > drawable_id ,
sel_x1 , sel_y1 ,
2001-01-18 14:41:35 +00:00
( sel_x2 - sel_x1 ) , ( sel_y2 - sel_y1 ) ) ;
2000-01-06 22:26:10 +00:00
2001-01-17 20:29:42 +00:00
gimp_displays_flush ( ) ;
}
2000-01-06 22:26:10 +00:00
}
2001-01-18 14:41:35 +00:00
values [ 0 ] . type = GIMP_PDB_STATUS ;
2000-01-06 22:26:10 +00:00
values [ 0 ] . data . d_status = status ;
2001-01-18 14:41:35 +00:00
2001-01-17 20:29:42 +00:00
gimp_drawable_detach ( drawable ) ;
1997-11-24 22:05:25 +00:00
}
/** User interface ***********************************************************/
2000-01-25 17:46:56 +00:00
static GtkWidget * preview [ 9 ] ;
2001-01-18 14:41:35 +00:00
static ExpInfo info [ 9 ] ;
1997-11-24 22:05:25 +00:00
2000-01-25 17:46:56 +00:00
static void
2001-01-18 14:41:35 +00:00
dialog_new_variations ( GtkWidget * widget ,
gpointer data )
1997-11-24 22:05:25 +00:00
{
2000-01-06 22:26:10 +00:00
gint i ;
for ( i = 1 ; i < 9 ; i + + )
modify_info ( & ( info [ 0 ] ) , & ( info [ i ] ) ) ;
1997-11-24 22:05:25 +00:00
}
2000-01-25 17:46:56 +00:00
static void
2001-01-18 14:41:35 +00:00
dialog_update_previews ( GtkWidget * widget ,
gpointer data )
1997-11-24 22:05:25 +00:00
{
2000-01-06 22:26:10 +00:00
gint i , j ;
guchar buf [ PREVIEW_SIZE * 3 ] ;
2001-01-17 20:29:42 +00:00
for ( j = 0 ; j < 9 ; j + + )
2000-01-06 22:26:10 +00:00
{
2002-06-13 20:32:21 +00:00
optimize ( & info [ ( j + 5 ) % 9 ] ) ;
2000-01-06 22:26:10 +00:00
for ( i = 0 ; i < PREVIEW_SIZE ; i + + )
{
2003-07-03 13:26:06 +00:00
qbist ( & info [ ( j + 5 ) % 9 ] , buf ,
2001-01-17 20:29:42 +00:00
0 , i , PREVIEW_SIZE , PREVIEW_SIZE , PREVIEW_SIZE , 3 , 1 ) ;
2000-01-06 22:26:10 +00:00
gtk_preview_draw_row ( GTK_PREVIEW ( preview [ j ] ) , buf ,
0 , i , PREVIEW_SIZE ) ;
1997-11-24 22:05:25 +00:00
}
2001-12-29 13:26:29 +00:00
gtk_widget_queue_draw ( preview [ j ] ) ;
2000-01-06 22:26:10 +00:00
}
1997-11-24 22:05:25 +00:00
}
2000-01-25 17:46:56 +00:00
static void
2001-01-18 14:41:35 +00:00
dialog_select_preview ( GtkWidget * widget ,
ExpInfo * n_info )
1997-11-24 22:05:25 +00:00
{
2002-06-13 20:32:21 +00:00
info [ 0 ] = * n_info ;
2000-01-06 22:26:10 +00:00
dialog_new_variations ( widget , NULL ) ;
dialog_update_previews ( widget , NULL ) ;
1997-11-24 22:05:25 +00:00
}
/* File I/O stuff */
2001-01-17 20:29:42 +00:00
static guint16
2001-01-18 14:41:35 +00:00
get_be16 ( guint8 * buf )
2001-01-17 20:29:42 +00:00
{
return ( guint16 ) buf [ 0 ] < < 8 | buf [ 1 ] ;
}
static void
2003-08-23 19:35:05 +00:00
set_be16 ( guint8 * buf ,
2001-01-18 14:41:35 +00:00
guint16 val )
2001-01-17 20:29:42 +00:00
{
buf [ 0 ] = val > > 8 ;
buf [ 1 ] = val & 0xFF ;
}
1997-11-24 22:05:25 +00:00
2001-01-18 14:41:35 +00:00
static gboolean
load_data ( gchar * name )
1997-11-24 22:05:25 +00:00
{
2001-01-18 14:41:35 +00:00
gint i ;
FILE * f ;
guint8 buf [ 288 ] ;
2000-01-06 22:26:10 +00:00
2001-01-17 20:29:42 +00:00
f = fopen ( name , " rb " ) ;
if ( f = = NULL )
{
2001-01-18 14:41:35 +00:00
return FALSE ;
2001-01-17 20:29:42 +00:00
}
if ( fread ( buf , 1 , sizeof ( buf ) , f ) ! = sizeof ( buf ) )
{
fclose ( f ) ;
2001-01-18 14:41:35 +00:00
return FALSE ;
2001-01-17 20:29:42 +00:00
}
2000-01-06 22:26:10 +00:00
fclose ( f ) ;
2001-01-17 20:29:42 +00:00
for ( i = 0 ; i < MAX_TRANSFORMS ; i + + )
2003-08-23 19:35:05 +00:00
info [ 0 ] . transformSequence [ i ] =
2001-01-18 14:41:35 +00:00
get_be16 ( buf + i * 2 + MAX_TRANSFORMS * 2 * 0 ) ;
2001-01-17 20:29:42 +00:00
for ( i = 0 ; i < MAX_TRANSFORMS ; i + + )
info [ 0 ] . source [ i ] = get_be16 ( buf + i * 2 + MAX_TRANSFORMS * 2 * 1 ) ;
2001-01-18 14:41:35 +00:00
2001-01-17 20:29:42 +00:00
for ( i = 0 ; i < MAX_TRANSFORMS ; i + + )
info [ 0 ] . control [ i ] = get_be16 ( buf + i * 2 + MAX_TRANSFORMS * 2 * 2 ) ;
2001-01-18 14:41:35 +00:00
2001-01-17 20:29:42 +00:00
for ( i = 0 ; i < MAX_TRANSFORMS ; i + + )
info [ 0 ] . dest [ i ] = get_be16 ( buf + i * 2 + MAX_TRANSFORMS * 2 * 3 ) ;
2001-01-18 14:41:35 +00:00
return TRUE ;
1997-11-24 22:05:25 +00:00
}
2001-01-18 14:41:35 +00:00
static gboolean
save_data ( gchar * name )
1997-11-24 22:05:25 +00:00
{
2001-01-18 14:41:35 +00:00
gint i = 0 ;
FILE * f ;
guint8 buf [ 288 ] ;
2000-01-06 22:26:10 +00:00
f = fopen ( name , " wb " ) ;
2001-01-17 20:29:42 +00:00
if ( f = = NULL )
{
2001-01-18 14:41:35 +00:00
return FALSE ;
2001-01-17 20:29:42 +00:00
}
2000-01-06 22:26:10 +00:00
2001-01-17 20:29:42 +00:00
for ( i = 0 ; i < MAX_TRANSFORMS ; i + + )
2003-08-23 19:35:05 +00:00
set_be16 ( buf + i * 2 + MAX_TRANSFORMS * 2 * 0 ,
2001-01-18 14:41:35 +00:00
info [ 0 ] . transformSequence [ i ] ) ;
2001-01-17 20:29:42 +00:00
for ( i = 0 ; i < MAX_TRANSFORMS ; i + + )
set_be16 ( buf + i * 2 + MAX_TRANSFORMS * 2 * 1 , info [ 0 ] . source [ i ] ) ;
2001-01-18 14:41:35 +00:00
2001-01-17 20:29:42 +00:00
for ( i = 0 ; i < MAX_TRANSFORMS ; i + + )
set_be16 ( buf + i * 2 + MAX_TRANSFORMS * 2 * 2 , info [ 0 ] . control [ i ] ) ;
2001-01-18 14:41:35 +00:00
2001-01-17 20:29:42 +00:00
for ( i = 0 ; i < MAX_TRANSFORMS ; i + + )
set_be16 ( buf + i * 2 + MAX_TRANSFORMS * 2 * 3 , info [ 0 ] . dest [ i ] ) ;
2000-01-06 22:26:10 +00:00
2001-01-17 20:29:42 +00:00
fwrite ( buf , 1 , sizeof ( buf ) , f ) ;
2000-01-06 22:26:10 +00:00
fclose ( f ) ;
2001-01-17 20:29:42 +00:00
2001-01-18 14:41:35 +00:00
return TRUE ;
1997-11-24 22:05:25 +00:00
}
2000-01-25 17:46:56 +00:00
static void
2003-11-19 14:51:52 +00:00
file_selection_save_response ( GtkFileSelection * fs ,
gint response_id ,
gpointer data )
1997-11-24 22:05:25 +00:00
{
2003-11-19 14:51:52 +00:00
if ( response_id = = GTK_RESPONSE_OK )
{
strcpy ( qbist_info . path , gtk_file_selection_get_filename ( fs ) ) ;
save_data ( qbist_info . path ) ;
}
2001-01-17 20:29:42 +00:00
2003-11-19 14:51:52 +00:00
gtk_widget_destroy ( GTK_WIDGET ( fs ) ) ;
1997-11-24 22:05:25 +00:00
}
2000-01-25 17:46:56 +00:00
static void
2003-11-19 14:51:52 +00:00
file_selection_load_response ( GtkFileSelection * fs ,
gint response_id ,
gpointer data )
1997-11-24 22:05:25 +00:00
{
2003-11-19 14:51:52 +00:00
if ( response_id = = GTK_RESPONSE_OK )
{
strcpy ( qbist_info . path , gtk_file_selection_get_filename ( fs ) ) ;
load_data ( qbist_info . path ) ;
dialog_new_variations ( NULL , NULL ) ;
dialog_update_previews ( NULL , NULL ) ;
}
gtk_widget_destroy ( GTK_WIDGET ( fs ) ) ;
1997-11-24 22:05:25 +00:00
}
2000-01-25 17:46:56 +00:00
static void
2001-01-18 14:41:35 +00:00
dialog_load ( GtkWidget * widget ,
gpointer data )
1997-11-24 22:05:25 +00:00
{
2000-01-06 22:26:10 +00:00
GtkWidget * file_select ;
2001-07-31 23:28:56 +00:00
file_select = gtk_file_selection_new ( _ ( " Load QBE file... " ) ) ;
2000-01-06 22:26:10 +00:00
2003-11-09 22:44:45 +00:00
gtk_window_set_transient_for ( GTK_WINDOW ( file_select ) ,
GTK_WINDOW ( gtk_widget_get_toplevel ( widget ) ) ) ;
2001-07-31 23:28:56 +00:00
gimp_help_connect ( file_select , gimp_standard_help_func ,
2003-08-23 19:35:05 +00:00
" filters/gqbist.html " , NULL ) ;
2000-01-06 22:26:10 +00:00
2001-12-29 13:26:29 +00:00
gtk_file_selection_set_filename ( GTK_FILE_SELECTION ( file_select ) ,
qbist_info . path ) ;
2003-11-19 14:51:52 +00:00
g_signal_connect ( file_select , " response " ,
G_CALLBACK ( file_selection_load_response ) ,
NULL ) ;
2000-01-06 22:26:10 +00:00
gtk_widget_show ( file_select ) ;
1997-11-24 22:05:25 +00:00
}
2000-01-25 17:46:56 +00:00
static void
2001-01-18 14:41:35 +00:00
dialog_save ( GtkWidget * widget ,
gpointer data )
1997-11-24 22:05:25 +00:00
{
2000-01-06 22:26:10 +00:00
GtkWidget * file_select ;
file_select =
2001-07-31 23:28:56 +00:00
gtk_file_selection_new ( _ ( " Save (middle transform) as QBE file... " ) ) ;
2000-01-06 22:26:10 +00:00
2003-11-09 22:44:45 +00:00
gtk_window_set_transient_for ( GTK_WINDOW ( file_select ) ,
GTK_WINDOW ( gtk_widget_get_toplevel ( widget ) ) ) ;
2001-07-31 23:28:56 +00:00
gimp_help_connect ( file_select , gimp_standard_help_func ,
2003-08-23 19:35:05 +00:00
" filters/gqbist.html " , NULL ) ;
1997-11-24 22:05:25 +00:00
2003-08-23 19:35:05 +00:00
gtk_file_selection_set_filename ( GTK_FILE_SELECTION ( file_select ) ,
2001-01-18 14:41:35 +00:00
qbist_info . path ) ;
2001-12-29 13:26:29 +00:00
2003-11-19 14:51:52 +00:00
g_signal_connect ( file_select , " response " ,
G_CALLBACK ( file_selection_save_response ) ,
NULL ) ;
2000-01-06 22:26:10 +00:00
gtk_widget_show ( file_select ) ;
}
1997-11-24 22:05:25 +00:00
2001-01-17 20:29:42 +00:00
static void
2001-01-18 14:41:35 +00:00
dialog_toggle_antialaising ( GtkWidget * widget ,
gpointer data )
2001-01-17 20:29:42 +00:00
{
2003-08-23 19:35:05 +00:00
qbist_info . oversampling =
2001-01-18 14:41:35 +00:00
gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( widget ) ) ? 4 : 1 ;
2001-01-17 20:29:42 +00:00
}
2000-01-25 17:46:56 +00:00
static gint
2000-01-06 22:26:10 +00:00
dialog_create ( void )
1997-11-24 22:05:25 +00:00
{
2000-01-06 22:26:10 +00:00
GtkWidget * dialog ;
2000-01-25 17:46:56 +00:00
GtkWidget * vbox ;
GtkWidget * bbox ;
2000-01-06 22:26:10 +00:00
GtkWidget * button ;
GtkWidget * table ;
2001-01-18 14:41:35 +00:00
gint i ;
2003-11-06 15:27:05 +00:00
gboolean run ;
2000-01-06 22:26:10 +00:00
2000-04-30 21:03:44 +00:00
gimp_ui_init ( " gqbist " , TRUE ) ;
2000-01-06 22:26:10 +00:00
2003-10-18 20:33:31 +00:00
dialog = gimp_dialog_new ( _ ( " G-Qbist " ) , " gqbist " ,
2003-11-06 15:27:05 +00:00
NULL , 0 ,
2000-05-22 17:10:28 +00:00
gimp_standard_help_func , " filters/gqbist.html " ,
2000-01-06 22:26:10 +00:00
2003-11-06 15:27:05 +00:00
GTK_STOCK_CANCEL , GTK_RESPONSE_CANCEL ,
GTK_STOCK_OK , GTK_RESPONSE_OK ,
2000-01-06 22:26:10 +00:00
NULL ) ;
2000-01-25 17:46:56 +00:00
vbox = gtk_vbox_new ( FALSE , 6 ) ;
gtk_container_set_border_width ( GTK_CONTAINER ( vbox ) , 6 ) ;
gtk_box_pack_start ( GTK_BOX ( GTK_DIALOG ( dialog ) - > vbox ) , vbox ,
FALSE , FALSE , 0 ) ;
gtk_widget_show ( vbox ) ;
2000-01-06 22:26:10 +00:00
table = gtk_table_new ( 3 , 3 , FALSE ) ;
gtk_table_set_row_spacings ( GTK_TABLE ( table ) , 5 ) ;
gtk_table_set_col_spacings ( GTK_TABLE ( table ) , 5 ) ;
2000-01-25 17:46:56 +00:00
gtk_box_pack_start ( GTK_BOX ( vbox ) , table , FALSE , FALSE , 0 ) ;
2000-01-06 22:26:10 +00:00
gtk_widget_show ( table ) ;
2002-06-13 20:32:21 +00:00
info [ 0 ] = qbist_info . info ;
2000-01-06 22:26:10 +00:00
dialog_new_variations ( NULL , NULL ) ;
for ( i = 0 ; i < 9 ; i + + )
{
2000-01-25 17:46:56 +00:00
button = gtk_button_new ( ) ;
2003-08-23 19:35:05 +00:00
gtk_table_attach ( GTK_TABLE ( table ) ,
2001-01-18 14:41:35 +00:00
button , i % 3 , ( i % 3 ) + 1 , i / 3 , ( i / 3 ) + 1 ,
2000-01-25 17:46:56 +00:00
GTK_SHRINK | GTK_FILL , GTK_SHRINK | GTK_FILL , 0 , 0 ) ;
2000-01-06 22:26:10 +00:00
gtk_widget_show ( button ) ;
1997-11-24 22:05:25 +00:00
2003-01-07 06:16:02 +00:00
g_signal_connect ( button , " clicked " ,
2001-12-29 13:26:29 +00:00
G_CALLBACK ( dialog_select_preview ) ,
( gpointer ) & ( info [ ( i + 5 ) % 9 ] ) ) ;
2000-01-06 22:26:10 +00:00
preview [ i ] = gtk_preview_new ( GTK_PREVIEW_COLOR ) ;
gtk_preview_size ( GTK_PREVIEW ( preview [ i ] ) , PREVIEW_SIZE , PREVIEW_SIZE ) ;
gtk_container_add ( GTK_CONTAINER ( button ) , preview [ i ] ) ;
gtk_widget_show ( preview [ i ] ) ;
}
2002-06-13 20:32:21 +00:00
button = gtk_check_button_new_with_mnemonic ( _ ( " _Antialiasing " ) ) ;
2003-08-23 19:35:05 +00:00
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( button ) ,
2001-01-18 14:41:35 +00:00
qbist_info . oversampling > 1 ) ;
2001-01-17 20:29:42 +00:00
gtk_box_pack_start ( GTK_BOX ( vbox ) , button , FALSE , FALSE , 0 ) ;
gtk_widget_show ( button ) ;
2003-01-07 06:16:02 +00:00
g_signal_connect ( button , " toggled " ,
2001-12-29 13:26:29 +00:00
G_CALLBACK ( dialog_toggle_antialaising ) ,
NULL ) ;
2000-01-25 17:46:56 +00:00
bbox = gtk_hbutton_box_new ( ) ;
gtk_box_pack_start ( GTK_BOX ( vbox ) , bbox , FALSE , FALSE , 0 ) ;
gtk_widget_show ( bbox ) ;
2001-07-31 23:28:56 +00:00
button = gtk_button_new_from_stock ( GTK_STOCK_OPEN ) ;
2000-01-25 17:46:56 +00:00
GTK_WIDGET_SET_FLAGS ( button , GTK_CAN_DEFAULT ) ;
gtk_container_add ( GTK_CONTAINER ( bbox ) , button ) ;
gtk_widget_show ( button ) ;
2003-01-07 06:16:02 +00:00
g_signal_connect ( button , " clicked " ,
2001-12-29 13:26:29 +00:00
G_CALLBACK ( dialog_load ) ,
NULL ) ;
2001-07-31 23:28:56 +00:00
button = gtk_button_new_from_stock ( GTK_STOCK_SAVE ) ;
2000-01-25 17:46:56 +00:00
GTK_WIDGET_SET_FLAGS ( button , GTK_CAN_DEFAULT ) ;
gtk_container_add ( GTK_CONTAINER ( bbox ) , button ) ;
gtk_widget_show ( button ) ;
2003-01-07 06:16:02 +00:00
g_signal_connect ( button , " clicked " ,
2001-12-29 13:26:29 +00:00
G_CALLBACK ( dialog_save ) ,
NULL ) ;
2000-01-06 22:26:10 +00:00
dialog_update_previews ( NULL , NULL ) ;
gtk_widget_show ( dialog ) ;
2003-11-11 18:11:56 +00:00
run = ( gimp_dialog_run ( GIMP_DIALOG ( dialog ) ) = = GTK_RESPONSE_OK ) ;
2000-01-06 22:26:10 +00:00
2003-11-06 15:27:05 +00:00
if ( run )
2002-06-13 20:32:21 +00:00
qbist_info . info = info [ 0 ] ;
1997-11-24 22:05:25 +00:00
2003-11-06 15:27:05 +00:00
gtk_widget_destroy ( dialog ) ;
return run ;
1997-11-24 22:05:25 +00:00
}