gimp/plug-ins/gimpressionist/sizemap.c

535 lines
14 KiB
C
Raw Normal View History

app/gimpprogress.c app/nav_window.c app/ops_buttons.c app/undo_history.c 2001-12-29 Michael Natterer <mitch@gimp.org> * app/gimpprogress.c * app/nav_window.c * app/ops_buttons.c * app/undo_history.c * app/display/gimpdisplayshell.c * app/gui/about-dialog.c * app/gui/brush-editor.c * app/gui/channels-commands.c * app/gui/color-area.c * app/gui/color-notebook.c * app/gui/color-select.c * app/gui/colormap-dialog.c * app/gui/convert-dialog.c * app/gui/device-status-dialog.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/info-dialog.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-editor.c * app/gui/palettes-commands.c * app/gui/paths-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/splash.c * app/gui/tips-dialog.c * app/gui/toolbox.c * app/gui/user-install-dialog.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpposterizetool.c * app/tools/gimprotatetool.c * app/tools/gimpthresholdtool.c * app/tools/paint_options.c * app/tools/selection_options.c * app/widgets/gimpchannellistview.c * app/widgets/gimpcolorpanel.c * app/widgets/gimpcomponentlistitem.c * app/widgets/gimpconstrainedhwrapbox.c * app/widgets/gimpcontainergridview.c * app/widgets/gimpcontainerlistview.c * app/widgets/gimpcontainermenuimpl.c * app/widgets/gimpdialogfactory.c * app/widgets/gimpdnd.c * app/widgets/gimpdock.c * app/widgets/gimpdockbook.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimpdrawablelistview.c * app/widgets/gimpfontselection-dialog.c * app/widgets/gimphistogramview.c * app/widgets/gimpitemfactory.c * app/widgets/gimplayerlistitem.c * app/widgets/gimplistitem.[ch] * app/widgets/gimpmenuitem.c * app/widgets/gimppreview.[ch] * app/widgets/gtkhwrapbox.c * app/widgets/gtkvwrapbox.c * app/widgets/gtkwrapbox.c * libgimp/gimpbrushmenu.c * libgimp/gimpexport.c * libgimp/gimpgradientmenu.c * libgimp/gimpmenu.c * libgimp/gimppatternmenu.c * libgimpwidgets/gimpbutton.c * libgimpwidgets/gimpchainbutton.[ch] * libgimpwidgets/gimpcolorarea.h * libgimpwidgets/gimpcolorbutton.c * libgimpwidgets/gimpfileselection.c * libgimpwidgets/gimphelpui.c * libgimpwidgets/gimpoffsetarea.c * libgimpwidgets/gimppatheditor.c * libgimpwidgets/gimppixmap.h * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpstock.[ch] * libgimpwidgets/gimpwidgets.h * plug-ins/FractalExplorer/Dialogs.c * plug-ins/FractalExplorer/Events.c * plug-ins/FractalExplorer/FractalExplorer.c * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_ui.c * plug-ins/bmp/bmpwrite.c * plug-ins/dbbrowser/dbbrowser_utils.c * plug-ins/fits/fits.c * plug-ins/flame/flame.c * plug-ins/fp/fp_gtk.c * plug-ins/fp/fp_misc.c * plug-ins/gfig/gfig.c * plug-ins/gflare/gflare.c * plug-ins/gfli/gfli.c * plug-ins/gimpressionist/*.c * plug-ins/imagemap/*.[ch] * plug-ins/maze/maze_face.c * plug-ins/mosaic/mosaic.c * plug-ins/pagecurl/pagecurl.c * plug-ins/print/print_gimp.h * plug-ins/rcm/rcm_callback.c * plug-ins/rcm/rcm_dialog.c * plug-ins/rcm/rcm_misc.c * plug-ins/script-fu/script-fu-console.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu-server.c * plug-ins/sel2path/sel2path.c * plug-ins/sel2path/sel2path_adv_dialog.c * plug-ins/sgi/sgi.c * plug-ins/webbrowser/webbrowser.c * plug-ins/xjt/xjt.c * plug-ins/common/[A-n]*.c: compile with GTK_DISABLE_DEPRECATED defined. Not everything is fully ported yet, had to #undef GTK_DISABLE_DEPRECATED in many places and added #warnings when doing so. * pixmaps/Makefile.am * pixmaps/chain.xpm: removed. * themes/Default/Makefile.am * themes/Default/images/Makefile.am * themes/Default/images/stock-button-hchain-broken.png * themes/Default/images/stock-button-hchain.png * themes/Default/images/stock-button-vchain-broken.png * themes/Default/images/stock-button-vchain.png: new stock icons.
2001-12-29 21:26:29 +08:00
#include "config.h"
1999-08-27 06:29:37 +08:00
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
app/gimpprogress.c app/nav_window.c app/ops_buttons.c app/undo_history.c 2001-12-29 Michael Natterer <mitch@gimp.org> * app/gimpprogress.c * app/nav_window.c * app/ops_buttons.c * app/undo_history.c * app/display/gimpdisplayshell.c * app/gui/about-dialog.c * app/gui/brush-editor.c * app/gui/channels-commands.c * app/gui/color-area.c * app/gui/color-notebook.c * app/gui/color-select.c * app/gui/colormap-dialog.c * app/gui/convert-dialog.c * app/gui/device-status-dialog.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/info-dialog.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-editor.c * app/gui/palettes-commands.c * app/gui/paths-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/splash.c * app/gui/tips-dialog.c * app/gui/toolbox.c * app/gui/user-install-dialog.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpposterizetool.c * app/tools/gimprotatetool.c * app/tools/gimpthresholdtool.c * app/tools/paint_options.c * app/tools/selection_options.c * app/widgets/gimpchannellistview.c * app/widgets/gimpcolorpanel.c * app/widgets/gimpcomponentlistitem.c * app/widgets/gimpconstrainedhwrapbox.c * app/widgets/gimpcontainergridview.c * app/widgets/gimpcontainerlistview.c * app/widgets/gimpcontainermenuimpl.c * app/widgets/gimpdialogfactory.c * app/widgets/gimpdnd.c * app/widgets/gimpdock.c * app/widgets/gimpdockbook.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimpdrawablelistview.c * app/widgets/gimpfontselection-dialog.c * app/widgets/gimphistogramview.c * app/widgets/gimpitemfactory.c * app/widgets/gimplayerlistitem.c * app/widgets/gimplistitem.[ch] * app/widgets/gimpmenuitem.c * app/widgets/gimppreview.[ch] * app/widgets/gtkhwrapbox.c * app/widgets/gtkvwrapbox.c * app/widgets/gtkwrapbox.c * libgimp/gimpbrushmenu.c * libgimp/gimpexport.c * libgimp/gimpgradientmenu.c * libgimp/gimpmenu.c * libgimp/gimppatternmenu.c * libgimpwidgets/gimpbutton.c * libgimpwidgets/gimpchainbutton.[ch] * libgimpwidgets/gimpcolorarea.h * libgimpwidgets/gimpcolorbutton.c * libgimpwidgets/gimpfileselection.c * libgimpwidgets/gimphelpui.c * libgimpwidgets/gimpoffsetarea.c * libgimpwidgets/gimppatheditor.c * libgimpwidgets/gimppixmap.h * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpstock.[ch] * libgimpwidgets/gimpwidgets.h * plug-ins/FractalExplorer/Dialogs.c * plug-ins/FractalExplorer/Events.c * plug-ins/FractalExplorer/FractalExplorer.c * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_ui.c * plug-ins/bmp/bmpwrite.c * plug-ins/dbbrowser/dbbrowser_utils.c * plug-ins/fits/fits.c * plug-ins/flame/flame.c * plug-ins/fp/fp_gtk.c * plug-ins/fp/fp_misc.c * plug-ins/gfig/gfig.c * plug-ins/gflare/gflare.c * plug-ins/gfli/gfli.c * plug-ins/gimpressionist/*.c * plug-ins/imagemap/*.[ch] * plug-ins/maze/maze_face.c * plug-ins/mosaic/mosaic.c * plug-ins/pagecurl/pagecurl.c * plug-ins/print/print_gimp.h * plug-ins/rcm/rcm_callback.c * plug-ins/rcm/rcm_dialog.c * plug-ins/rcm/rcm_misc.c * plug-ins/script-fu/script-fu-console.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu-server.c * plug-ins/sel2path/sel2path.c * plug-ins/sel2path/sel2path_adv_dialog.c * plug-ins/sgi/sgi.c * plug-ins/webbrowser/webbrowser.c * plug-ins/xjt/xjt.c * plug-ins/common/[A-n]*.c: compile with GTK_DISABLE_DEPRECATED defined. Not everything is fully ported yet, had to #undef GTK_DISABLE_DEPRECATED in many places and added #warnings when doing so. * pixmaps/Makefile.am * pixmaps/chain.xpm: removed. * themes/Default/Makefile.am * themes/Default/images/Makefile.am * themes/Default/images/stock-button-hchain-broken.png * themes/Default/images/stock-button-hchain.png * themes/Default/images/stock-button-vchain-broken.png * themes/Default/images/stock-button-vchain.png: new stock icons.
2001-12-29 21:26:29 +08:00
#ifdef __GNUC__
#warning GTK_DISABLE_DEPRECATED
#endif
#undef GTK_DISABLE_DEPRECATED
1999-08-27 06:29:37 +08:00
#include <gtk/gtk.h>
app/gimpprogress.c app/nav_window.c app/ops_buttons.c app/undo_history.c 2001-12-29 Michael Natterer <mitch@gimp.org> * app/gimpprogress.c * app/nav_window.c * app/ops_buttons.c * app/undo_history.c * app/display/gimpdisplayshell.c * app/gui/about-dialog.c * app/gui/brush-editor.c * app/gui/channels-commands.c * app/gui/color-area.c * app/gui/color-notebook.c * app/gui/color-select.c * app/gui/colormap-dialog.c * app/gui/convert-dialog.c * app/gui/device-status-dialog.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/info-dialog.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-editor.c * app/gui/palettes-commands.c * app/gui/paths-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/splash.c * app/gui/tips-dialog.c * app/gui/toolbox.c * app/gui/user-install-dialog.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpposterizetool.c * app/tools/gimprotatetool.c * app/tools/gimpthresholdtool.c * app/tools/paint_options.c * app/tools/selection_options.c * app/widgets/gimpchannellistview.c * app/widgets/gimpcolorpanel.c * app/widgets/gimpcomponentlistitem.c * app/widgets/gimpconstrainedhwrapbox.c * app/widgets/gimpcontainergridview.c * app/widgets/gimpcontainerlistview.c * app/widgets/gimpcontainermenuimpl.c * app/widgets/gimpdialogfactory.c * app/widgets/gimpdnd.c * app/widgets/gimpdock.c * app/widgets/gimpdockbook.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimpdrawablelistview.c * app/widgets/gimpfontselection-dialog.c * app/widgets/gimphistogramview.c * app/widgets/gimpitemfactory.c * app/widgets/gimplayerlistitem.c * app/widgets/gimplistitem.[ch] * app/widgets/gimpmenuitem.c * app/widgets/gimppreview.[ch] * app/widgets/gtkhwrapbox.c * app/widgets/gtkvwrapbox.c * app/widgets/gtkwrapbox.c * libgimp/gimpbrushmenu.c * libgimp/gimpexport.c * libgimp/gimpgradientmenu.c * libgimp/gimpmenu.c * libgimp/gimppatternmenu.c * libgimpwidgets/gimpbutton.c * libgimpwidgets/gimpchainbutton.[ch] * libgimpwidgets/gimpcolorarea.h * libgimpwidgets/gimpcolorbutton.c * libgimpwidgets/gimpfileselection.c * libgimpwidgets/gimphelpui.c * libgimpwidgets/gimpoffsetarea.c * libgimpwidgets/gimppatheditor.c * libgimpwidgets/gimppixmap.h * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpstock.[ch] * libgimpwidgets/gimpwidgets.h * plug-ins/FractalExplorer/Dialogs.c * plug-ins/FractalExplorer/Events.c * plug-ins/FractalExplorer/FractalExplorer.c * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_ui.c * plug-ins/bmp/bmpwrite.c * plug-ins/dbbrowser/dbbrowser_utils.c * plug-ins/fits/fits.c * plug-ins/flame/flame.c * plug-ins/fp/fp_gtk.c * plug-ins/fp/fp_misc.c * plug-ins/gfig/gfig.c * plug-ins/gflare/gflare.c * plug-ins/gfli/gfli.c * plug-ins/gimpressionist/*.c * plug-ins/imagemap/*.[ch] * plug-ins/maze/maze_face.c * plug-ins/mosaic/mosaic.c * plug-ins/pagecurl/pagecurl.c * plug-ins/print/print_gimp.h * plug-ins/rcm/rcm_callback.c * plug-ins/rcm/rcm_dialog.c * plug-ins/rcm/rcm_misc.c * plug-ins/script-fu/script-fu-console.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu-server.c * plug-ins/sel2path/sel2path.c * plug-ins/sel2path/sel2path_adv_dialog.c * plug-ins/sgi/sgi.c * plug-ins/webbrowser/webbrowser.c * plug-ins/xjt/xjt.c * plug-ins/common/[A-n]*.c: compile with GTK_DISABLE_DEPRECATED defined. Not everything is fully ported yet, had to #undef GTK_DISABLE_DEPRECATED in many places and added #warnings when doing so. * pixmaps/Makefile.am * pixmaps/chain.xpm: removed. * themes/Default/Makefile.am * themes/Default/images/Makefile.am * themes/Default/images/stock-button-hchain-broken.png * themes/Default/images/stock-button-hchain.png * themes/Default/images/stock-button-vchain-broken.png * themes/Default/images/stock-button-vchain.png: new stock icons.
2001-12-29 21:26:29 +08:00
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
1999-08-27 06:29:37 +08:00
#include "gimpressionist.h"
#include "ppmtool.h"
app/gimpprogress.c app/nav_window.c app/ops_buttons.c app/undo_history.c 2001-12-29 Michael Natterer <mitch@gimp.org> * app/gimpprogress.c * app/nav_window.c * app/ops_buttons.c * app/undo_history.c * app/display/gimpdisplayshell.c * app/gui/about-dialog.c * app/gui/brush-editor.c * app/gui/channels-commands.c * app/gui/color-area.c * app/gui/color-notebook.c * app/gui/color-select.c * app/gui/colormap-dialog.c * app/gui/convert-dialog.c * app/gui/device-status-dialog.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gradient-editor.c * app/gui/info-dialog.c * app/gui/layers-commands.c * app/gui/module-browser.c * app/gui/offset-dialog.c * app/gui/palette-editor.c * app/gui/palettes-commands.c * app/gui/paths-dialog.c * app/gui/qmask-commands.c * app/gui/resize-dialog.c * app/gui/resolution-calibrate-dialog.c * app/gui/splash.c * app/gui/tips-dialog.c * app/gui/toolbox.c * app/gui/user-install-dialog.c * app/tools/gimpbrightnesscontrasttool.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpcolorbalancetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpcurvestool.c * app/tools/gimphuesaturationtool.c * app/tools/gimpinktool.c * app/tools/gimplevelstool.c * app/tools/gimpposterizetool.c * app/tools/gimprotatetool.c * app/tools/gimpthresholdtool.c * app/tools/paint_options.c * app/tools/selection_options.c * app/widgets/gimpchannellistview.c * app/widgets/gimpcolorpanel.c * app/widgets/gimpcomponentlistitem.c * app/widgets/gimpconstrainedhwrapbox.c * app/widgets/gimpcontainergridview.c * app/widgets/gimpcontainerlistview.c * app/widgets/gimpcontainermenuimpl.c * app/widgets/gimpdialogfactory.c * app/widgets/gimpdnd.c * app/widgets/gimpdock.c * app/widgets/gimpdockbook.c * app/widgets/gimpdrawablelistitem.c * app/widgets/gimpdrawablelistview.c * app/widgets/gimpfontselection-dialog.c * app/widgets/gimphistogramview.c * app/widgets/gimpitemfactory.c * app/widgets/gimplayerlistitem.c * app/widgets/gimplistitem.[ch] * app/widgets/gimpmenuitem.c * app/widgets/gimppreview.[ch] * app/widgets/gtkhwrapbox.c * app/widgets/gtkvwrapbox.c * app/widgets/gtkwrapbox.c * libgimp/gimpbrushmenu.c * libgimp/gimpexport.c * libgimp/gimpgradientmenu.c * libgimp/gimpmenu.c * libgimp/gimppatternmenu.c * libgimpwidgets/gimpbutton.c * libgimpwidgets/gimpchainbutton.[ch] * libgimpwidgets/gimpcolorarea.h * libgimpwidgets/gimpcolorbutton.c * libgimpwidgets/gimpfileselection.c * libgimpwidgets/gimphelpui.c * libgimpwidgets/gimpoffsetarea.c * libgimpwidgets/gimppatheditor.c * libgimpwidgets/gimppixmap.h * libgimpwidgets/gimpquerybox.c * libgimpwidgets/gimpstock.[ch] * libgimpwidgets/gimpwidgets.h * plug-ins/FractalExplorer/Dialogs.c * plug-ins/FractalExplorer/Events.c * plug-ins/FractalExplorer/FractalExplorer.c * plug-ins/Lighting/lighting_ui.c * plug-ins/MapObject/mapobject_ui.c * plug-ins/bmp/bmpwrite.c * plug-ins/dbbrowser/dbbrowser_utils.c * plug-ins/fits/fits.c * plug-ins/flame/flame.c * plug-ins/fp/fp_gtk.c * plug-ins/fp/fp_misc.c * plug-ins/gfig/gfig.c * plug-ins/gflare/gflare.c * plug-ins/gfli/gfli.c * plug-ins/gimpressionist/*.c * plug-ins/imagemap/*.[ch] * plug-ins/maze/maze_face.c * plug-ins/mosaic/mosaic.c * plug-ins/pagecurl/pagecurl.c * plug-ins/print/print_gimp.h * plug-ins/rcm/rcm_callback.c * plug-ins/rcm/rcm_dialog.c * plug-ins/rcm/rcm_misc.c * plug-ins/script-fu/script-fu-console.c * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/script-fu-server.c * plug-ins/sel2path/sel2path.c * plug-ins/sel2path/sel2path_adv_dialog.c * plug-ins/sgi/sgi.c * plug-ins/webbrowser/webbrowser.c * plug-ins/xjt/xjt.c * plug-ins/common/[A-n]*.c: compile with GTK_DISABLE_DEPRECATED defined. Not everything is fully ported yet, had to #undef GTK_DISABLE_DEPRECATED in many places and added #warnings when doing so. * pixmaps/Makefile.am * pixmaps/chain.xpm: removed. * themes/Default/Makefile.am * themes/Default/images/Makefile.am * themes/Default/images/stock-button-hchain-broken.png * themes/Default/images/stock-button-hchain.png * themes/Default/images/stock-button-vchain-broken.png * themes/Default/images/stock-button-vchain.png: new stock icons.
2001-12-29 21:26:29 +08:00
#include "libgimp/stdplugins-intl.h"
1999-08-27 06:29:37 +08:00
#define MAPFILE "data.out"
static GtkWidget *smwindow;
2002-12-10 18:39:23 +08:00
static GtkWidget *smvectorprev;
static GtkWidget *smpreviewprev;
static GtkWidget *prev_button;
static GtkWidget *next_button;
static GtkWidget *add_button;
static GtkWidget *kill_button;
1999-08-27 06:29:37 +08:00
GtkObject *smvectprevbrightadjust = NULL;
GtkObject *sizadjust = NULL;
GtkObject *smstradjust = NULL;
GtkObject *smstrexpadjust = NULL;
GtkWidget *sizevoronoi = NULL;
#define OMWIDTH 150
#define OMHEIGHT 150
2002-12-10 18:39:23 +08:00
static smvector_t smvector[MAXSIZEVECT];
static int numsmvect = 0;
1999-08-27 06:29:37 +08:00
double dist(double x, double y, double dx, double dy);
double getsiz(double x, double y, int from)
{
int i;
int n;
int voronoi;
double sum, ssum, dst;
smvector_t *vec;
1999-08-27 06:29:37 +08:00
double smstrexp;
int first = 0, last;
if((x < 0.0) || (x > 1.0)) printf("HUH? x = %f\n",x);
if(from == 0) {
n = numsmvect;
vec = smvector;
smstrexp = GTK_ADJUSTMENT(smstrexpadjust)->value;
voronoi = GTK_TOGGLE_BUTTON(sizevoronoi)->active;
} else {
n = pcvals.numsizevector;
vec = pcvals.sizevector;
smstrexp = pcvals.sizestrexp;
voronoi = pcvals.sizevoronoi;
}
if(voronoi) {
double bestdist = -1.0;
for(i = 0; i < n; i++) {
dst = dist(x,y,vec[i].x,vec[i].y);
if((bestdist < 0.0) || (dst < bestdist)) {
bestdist = dst;
first = i;
}
}
last = first+1;
} else {
first = 0;
last = n;
}
sum = ssum = 0.0;
for(i = first; i < last; i++) {
double s = vec[i].str;
dst = dist(x,y,vec[i].x,vec[i].y);
dst = pow(dst, smstrexp);
if(dst < 0.0001) dst = 0.0001;
s = s / dst;
sum += vec[i].siz * s;
ssum += 1.0/dst;
}
sum = sum / ssum / 100.0;
2002-12-10 18:39:23 +08:00
return CLAMP(sum, 0.0, 1.0);
1999-08-27 06:29:37 +08:00
}
void updatesmpreviewprev(void)
{
int x, y;
static ppm_t nsbuffer = {0,0,NULL};
1999-08-30 05:06:26 +08:00
guchar black[3] = {0,0,0};
guchar gray[3] = {120,120,120};
1999-08-27 06:29:37 +08:00
if(!nsbuffer.col) {
newppm(&nsbuffer,OMWIDTH,OMHEIGHT);
}
1999-08-30 05:06:26 +08:00
fill(&nsbuffer, black);
1999-08-27 06:29:37 +08:00
for(y = 6; y < OMHEIGHT-4; y += 10)
for(x = 6; x < OMWIDTH-4; x += 10) {
double siz = 5 * getsiz(x/(double)OMWIDTH,y/(double)OMHEIGHT,0);
1999-08-30 05:06:26 +08:00
drawline(&nsbuffer, x-siz, y-siz, x+siz, y-siz, gray);
drawline(&nsbuffer, x+siz, y-siz, x+siz, y+siz, gray);
drawline(&nsbuffer, x+siz, y+siz, x-siz, y+siz, gray);
drawline(&nsbuffer, x-siz, y+siz, x-siz, y-siz, gray);
1999-08-27 06:29:37 +08:00
}
for(y = 0; y < OMHEIGHT; y++)
1999-08-30 05:06:26 +08:00
gtk_preview_draw_row(GTK_PREVIEW(smpreviewprev), &nsbuffer.col[y*nsbuffer.width*3], 0, y, OMWIDTH);
1999-08-27 06:29:37 +08:00
gtk_widget_draw(smpreviewprev,NULL);
}
2002-12-10 18:39:23 +08:00
static gint selectedsmvector = 0;
1999-08-27 06:29:37 +08:00
void updatesmvectorprev(void)
{
static ppm_t backup = {0,0,NULL};
static ppm_t sbuffer = {0,0,NULL};
1999-08-27 06:29:37 +08:00
static int ok = 0;
int i, x, y;
double val;
static double lastval = 0.0;
1999-08-30 05:06:26 +08:00
guchar gray[3] = {120,120,120};
guchar red[3] = {255,0,0};
guchar white[3] = {255,255,255};
1999-08-27 06:29:37 +08:00
if (smvectprevbrightadjust)
2002-12-10 18:39:23 +08:00
val = 1.0 - GTK_ADJUSTMENT(smvectprevbrightadjust)->value / 100.0;
else
2002-12-10 18:39:23 +08:00
val = 0.5;
1999-08-27 06:29:37 +08:00
if(!ok || (val != lastval)) {
if(!infile.col)
updatepreviewprev(NULL, (void *)2); /* Force grabarea() */
copyppm(&infile, &backup);
ppmbrightness(&backup, val, 1,1,1);
if((backup.width != OMWIDTH) || (backup.height != OMHEIGHT))
resize_fast(&backup, OMWIDTH, OMHEIGHT);
ok = 1;
}
copyppm(&backup, &sbuffer);
for(i = 0; i < numsmvect; i++) {
x = smvector[i].x * OMWIDTH;
y = smvector[i].y * OMHEIGHT;
if(i == selectedsmvector) {
1999-08-30 05:06:26 +08:00
drawline(&sbuffer, x-5, y, x+5, y, red);
drawline(&sbuffer, x, y-5, x, y+5, red);
1999-08-27 06:29:37 +08:00
} else {
1999-08-30 05:06:26 +08:00
drawline(&sbuffer, x-5, y, x+5, y, gray);
drawline(&sbuffer, x, y-5, x, y+5, gray);
1999-08-27 06:29:37 +08:00
}
1999-08-30 05:06:26 +08:00
putrgb(&sbuffer, x, y, white);
1999-08-27 06:29:37 +08:00
}
for(y = 0; y < OMHEIGHT; y++)
1999-08-30 05:06:26 +08:00
gtk_preview_draw_row(GTK_PREVIEW(smvectorprev), &sbuffer.col[y*sbuffer.width*3], 0, y, OMWIDTH);
1999-08-27 06:29:37 +08:00
gtk_widget_draw(smvectorprev,NULL);
gtk_widget_set_sensitive (prev_button, (numsmvect > 1));
gtk_widget_set_sensitive (next_button, (numsmvect > 1));
2002-12-10 18:39:23 +08:00
gtk_widget_set_sensitive (add_button, (numsmvect < MAXORIENTVECT));
gtk_widget_set_sensitive (kill_button, (numsmvect > 1));
1999-08-27 06:29:37 +08:00
}
static gboolean smadjignore = FALSE;
1999-08-27 06:29:37 +08:00
void updatesmsliders(void)
{
smadjignore = TRUE;
1999-08-27 06:29:37 +08:00
gtk_adjustment_set_value(GTK_ADJUSTMENT(sizadjust),
smvector[selectedsmvector].siz);
gtk_adjustment_set_value(GTK_ADJUSTMENT(smstradjust),
smvector[selectedsmvector].str);
smadjignore = FALSE;
1999-08-27 06:29:37 +08:00
}
void smprevclick(GtkWidget *w, gpointer data)
{
selectedsmvector--;
if(selectedsmvector < 0) selectedsmvector = numsmvect-1;
updatesmsliders();
updatesmvectorprev();
}
void smnextclick(GtkWidget *w, gpointer data)
{
selectedsmvector++;
if(selectedsmvector == numsmvect) selectedsmvector = 0;
updatesmsliders();
updatesmvectorprev();
}
static void smaddclick(GtkWidget *w, gpointer data)
1999-08-27 06:29:37 +08:00
{
smvector[numsmvect].x = 0.5;
smvector[numsmvect].y = 0.5;
smvector[numsmvect].siz = 50.0;
smvector[numsmvect].str = 1.0;
selectedsmvector = numsmvect;
numsmvect++;
updatesmsliders();
updatesmvectorprev();
updatesmpreviewprev();
}
static void smdeleteclick(GtkWidget *w, gpointer data)
1999-08-27 06:29:37 +08:00
{
int i;
for (i = selectedsmvector; i < numsmvect-1; i++)
{
smvector[i] = smvector[i+1];
}
1999-08-27 06:29:37 +08:00
numsmvect--;
if(selectedsmvector >= numsmvect) selectedsmvector = 0;
updatesmsliders();
updatesmvectorprev();
updatesmpreviewprev();
}
static void smmapclick(GtkWidget *w, GdkEventButton *event)
1999-08-27 06:29:37 +08:00
{
if(event->button == 1) {
smvector[selectedsmvector].x = event->x / (double)OMWIDTH;
smvector[selectedsmvector].y = event->y / (double)OMHEIGHT;
} else if(event->button == 2) {
if(numsmvect + 1 == MAXSIZEVECT) return;
smvector[numsmvect].x = event->x / (double)OMWIDTH;
smvector[numsmvect].y = event->y / (double)OMHEIGHT;
smvector[numsmvect].siz = 0.0;
smvector[numsmvect].str = 1.0;
selectedsmvector = numsmvect;
numsmvect++;
updatesmsliders();
/*
} else if(event->button == 3) {
double d;
d = atan2(OMWIDTH * smvector[selectedsmvector].x - event->x,
OMHEIGHT * smvector[selectedsmvector].y - event->y);
smvector[selectedsmvector].dir = radtodeg(d);
updatesmsliders();
*/
}
updatesmvectorprev();
updatesmpreviewprev();
}
static void angsmadjmove(GtkWidget *w, gpointer data)
1999-08-27 06:29:37 +08:00
{
if (!smadjignore)
{
smvector[selectedsmvector].siz = GTK_ADJUSTMENT(sizadjust)->value;
updatesmvectorprev();
updatesmpreviewprev();
}
1999-08-27 06:29:37 +08:00
}
static void strsmadjmove(GtkWidget *w, gpointer data)
1999-08-27 06:29:37 +08:00
{
if (!smadjignore)
{
smvector[selectedsmvector].str = GTK_ADJUSTMENT(smstradjust)->value;
updatesmvectorprev();
updatesmpreviewprev();
}
1999-08-27 06:29:37 +08:00
}
static void smstrexpsmadjmove(GtkWidget *w, gpointer data)
1999-08-27 06:29:37 +08:00
{
if (!smadjignore)
{
updatesmvectorprev();
updatesmpreviewprev();
}
1999-08-27 06:29:37 +08:00
}
2002-12-10 18:39:23 +08:00
static void smapplyclick(GtkWidget *w, GtkWidget *win)
1999-08-27 06:29:37 +08:00
{
int i;
for (i = 0; i < numsmvect; i++)
{
pcvals.sizevector[i] = smvector[i];
}
1999-08-27 06:29:37 +08:00
pcvals.numsizevector = numsmvect;
pcvals.sizestrexp = GTK_ADJUSTMENT(smstrexpadjust)->value;
pcvals.sizevoronoi = GTK_TOGGLE_BUTTON(sizevoronoi)->active;
2002-12-10 18:39:23 +08:00
}
static void smokclick(GtkWidget *w, GtkWidget *win)
{
smapplyclick(NULL, NULL);
gtk_widget_hide(w);
1999-08-27 06:29:37 +08:00
}
void initsmvectors(void)
{
if (pcvals.numsizevector)
{
int i;
numsmvect = pcvals.numsizevector;
for(i = 0; i < numsmvect; i++)
{
smvector[i] = pcvals.sizevector[i];
}
}
else
{
/* Shouldn't happen */
numsmvect = 1;
smvector[0].x = 0.5;
smvector[0].y = 0.5;
smvector[0].siz = 0.0;
smvector[0].str = 1.0;
1999-08-27 06:29:37 +08:00
}
if(selectedsmvector >= numsmvect)
selectedsmvector = numsmvect-1;
}
#if 0
static void update_sizemap_dialog(void)
1999-08-27 06:29:37 +08:00
{
if (smwindow)
{
initsmvectors();
1999-08-27 06:29:37 +08:00
gtk_adjustment_set_value(GTK_ADJUSTMENT(smstrexpadjust),
pcvals.sizestrexp);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(sizevoronoi),
pcvals.sizevoronoi);
1999-08-27 06:29:37 +08:00
updatesmvectorprev();
updatesmpreviewprev();
}
1999-08-27 06:29:37 +08:00
}
#endif
1999-08-27 06:29:37 +08:00
void create_sizemap_dialog(void)
{
GtkWidget *tmpw, *tmpw2;
GtkWidget *table1;
GtkWidget *table2;
GtkWidget *hbox;
2000-08-30 16:20:24 +08:00
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sizeradio[7]), TRUE);
1999-08-27 06:29:37 +08:00
initsmvectors();
if(smwindow) {
updatesmvectorprev();
updatesmpreviewprev();
gtk_widget_show(smwindow);
return;
}
smwindow =
2002-12-10 18:39:23 +08:00
gimp_dialog_new (_("Size Map Editor"), "gimpressionist",
gimp_standard_help_func, "filters/gimpressionst.html",
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
1999-08-27 06:29:37 +08:00
2002-12-10 18:39:23 +08:00
GTK_STOCK_APPLY, smapplyclick,
NULL, NULL, NULL, FALSE, FALSE,
GTK_STOCK_CANCEL, gtk_widget_hide,
NULL, 1, NULL, FALSE, FALSE,
1999-08-27 06:29:37 +08:00
2002-12-10 18:39:23 +08:00
GTK_STOCK_OK, smokclick,
NULL, 1, NULL, TRUE, FALSE,
1999-08-27 06:29:37 +08:00
2002-12-10 18:39:23 +08:00
NULL);
1999-08-27 06:29:37 +08:00
g_signal_connect (smwindow, "destroy",
2002-12-10 18:39:23 +08:00
G_CALLBACK(gtk_widget_destroyed), &smwindow);
g_signal_connect (smwindow, "delete_event",
2002-12-10 18:39:23 +08:00
G_CALLBACK(gtk_widget_hide_on_delete), &smwindow);
table1 = gtk_table_new(2, 5, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (table1), 6);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (smwindow)->vbox), table1);
gtk_widget_show(table1);
1999-08-27 06:29:37 +08:00
tmpw2 = tmpw = gtk_frame_new( _("Smvectors"));
2000-08-30 16:20:24 +08:00
gtk_container_set_border_width (GTK_CONTAINER (tmpw), 2);
1999-08-27 06:29:37 +08:00
gtk_table_attach(GTK_TABLE(table1), tmpw, 0,1,0,1,GTK_EXPAND,GTK_EXPAND,0,0);
gtk_widget_show(tmpw);
tmpw = hbox = gtk_hbox_new(FALSE,0);
gtk_container_add(GTK_CONTAINER(tmpw2), tmpw);
gtk_widget_show(tmpw);
tmpw = gtk_event_box_new();
gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), tmpw, _("The smvector-field. Left-click to move selected smvector, Right-click to point it towards mouse, Middle-click to add a new smvector."), NULL);
1999-08-27 06:29:37 +08:00
gtk_box_pack_start(GTK_BOX(hbox), tmpw, FALSE, FALSE, 0);
tmpw2 = tmpw;
tmpw = smvectorprev = gtk_preview_new(GTK_PREVIEW_COLOR);
gtk_preview_size(GTK_PREVIEW(tmpw), OMWIDTH, OMHEIGHT);
gtk_container_add(GTK_CONTAINER(tmpw2), tmpw);
gtk_widget_show(tmpw);
gtk_widget_add_events (tmpw2, GDK_BUTTON_PRESS_MASK);
g_signal_connect(tmpw2, "button_press_event",
G_CALLBACK (smmapclick), NULL);
1999-08-27 06:29:37 +08:00
gtk_widget_show(tmpw2);
smvectprevbrightadjust = gtk_adjustment_new(50.0, 0.0, 100.0, 1.0, 1.0, 1.0);
tmpw = gtk_vscale_new(GTK_ADJUSTMENT(smvectprevbrightadjust));
gtk_scale_set_draw_value (GTK_SCALE (tmpw), FALSE);
gtk_box_pack_start(GTK_BOX(hbox), tmpw,FALSE,FALSE,0);
gtk_widget_show(tmpw);
g_signal_connect (smvectprevbrightadjust, "value_changed",
G_CALLBACK (updatesmvectorprev), NULL);
gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), tmpw, _("Adjust the preview's brightness"), NULL);
1999-08-27 06:29:37 +08:00
tmpw2 = tmpw = gtk_frame_new( _("Preview"));
2000-08-30 16:20:24 +08:00
gtk_container_set_border_width (GTK_CONTAINER (tmpw), 2);
1999-08-27 06:29:37 +08:00
gtk_table_attach(GTK_TABLE(table1), tmpw, 1,2,0,1,GTK_EXPAND,GTK_EXPAND,0,0);
gtk_widget_show(tmpw);
tmpw = smpreviewprev = gtk_preview_new(GTK_PREVIEW_COLOR);
gtk_preview_size(GTK_PREVIEW(tmpw), OMWIDTH, OMHEIGHT);
gtk_container_add(GTK_CONTAINER(tmpw2), tmpw);
gtk_widget_show(tmpw);
2002-12-10 18:39:23 +08:00
hbox = gtk_hbox_new(TRUE,0);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 2);
gtk_table_attach_defaults(GTK_TABLE(table1), hbox, 0, 1, 1, 2);
gtk_widget_show(hbox);
1999-08-27 06:29:37 +08:00
2002-12-10 18:39:23 +08:00
prev_button = tmpw = gtk_button_new_with_mnemonic("_<<");
1999-08-27 06:29:37 +08:00
gtk_box_pack_start(GTK_BOX(hbox),tmpw,FALSE,TRUE,0);
gtk_widget_show(tmpw);
g_signal_connect (tmpw, "clicked",
G_CALLBACK (smprevclick), NULL);
gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), tmpw,
2002-12-10 18:39:23 +08:00
_("Select previous smvector"), NULL);
1999-08-27 06:29:37 +08:00
2002-12-10 18:39:23 +08:00
next_button = tmpw = gtk_button_new_with_mnemonic("_>>");
1999-08-27 06:29:37 +08:00
gtk_box_pack_start(GTK_BOX(hbox),tmpw,FALSE,TRUE,0);
gtk_widget_show(tmpw);
g_signal_connect (tmpw, "clicked",
2002-12-10 18:39:23 +08:00
G_CALLBACK(smnextclick), NULL);
gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), tmpw,
2002-12-10 18:39:23 +08:00
_("Select next smvector"), NULL);
1999-08-27 06:29:37 +08:00
2002-12-10 18:39:23 +08:00
add_button = tmpw = gtk_button_new_with_mnemonic( _("A_dd"));
1999-08-27 06:29:37 +08:00
gtk_box_pack_start(GTK_BOX(hbox),tmpw,FALSE,TRUE,0);
gtk_widget_show(tmpw);
g_signal_connect (tmpw, "clicked",
2002-12-10 18:39:23 +08:00
G_CALLBACK(smaddclick), NULL);
gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), tmpw,
2002-12-10 18:39:23 +08:00
_("Add new smvector"), NULL);
1999-08-27 06:29:37 +08:00
2002-12-10 18:39:23 +08:00
kill_button = tmpw = gtk_button_new_with_mnemonic( _("_Kill"));
1999-08-27 06:29:37 +08:00
gtk_box_pack_start(GTK_BOX(hbox),tmpw,FALSE,TRUE,0);
gtk_widget_show(tmpw);
g_signal_connect (tmpw, "clicked",
2002-12-10 18:39:23 +08:00
G_CALLBACK(smdeleteclick), NULL);
gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), tmpw,
2002-12-10 18:39:23 +08:00
_("Delete selected smvector"), NULL);
table2 = gtk_table_new(3, 4, FALSE);
gtk_table_set_col_spacings (GTK_TABLE(table2), 4);
gtk_table_attach_defaults(GTK_TABLE(table1), table2, 0, 2, 2, 3);
gtk_widget_show(table2);
sizadjust =
gimp_scale_entry_new (GTK_TABLE(table2), 0, 0,
2002-12-10 18:39:23 +08:00
_("_Size:"),
150, 6, 50.0,
0.0, 100.0, 1.0, 10.0, 1,
2002-12-10 18:39:23 +08:00
TRUE, 0, 0,
_("Change the angle of the selected smvector"),
NULL);
g_signal_connect (sizadjust, "value_changed", G_CALLBACK(angsmadjmove),
2002-12-10 18:39:23 +08:00
NULL);
smstradjust =
gimp_scale_entry_new (GTK_TABLE(table2), 0, 1,
2002-12-10 18:39:23 +08:00
_("S_trength:"),
150, 6, 1.0,
0.1, 5.0, 0.1, 0.5, 1,
2002-12-10 18:39:23 +08:00
TRUE, 0, 0,
_("Change the strength of the selected smvector"),
NULL);
g_signal_connect (smstradjust, "value_changed", G_CALLBACK(strsmadjmove),
2002-12-10 18:39:23 +08:00
NULL);
smstrexpadjust =
gimp_scale_entry_new (GTK_TABLE(table2), 0, 2,
2002-12-10 18:39:23 +08:00
_("St_rength exp.:"),
150, 6, 1.0,
0.1, 10.9, 0.1, 0.5, 1,
2002-12-10 18:39:23 +08:00
TRUE, 0, 0,
_("Change the exponent of the strength"),
NULL);
g_signal_connect (smstrexpadjust, "value_changed",
2002-12-10 18:39:23 +08:00
G_CALLBACK(smstrexpsmadjmove), NULL);
sizevoronoi = tmpw = gtk_check_button_new_with_mnemonic( _("_Voronoi"));
gtk_table_attach_defaults(GTK_TABLE(table2), tmpw, 3, 4, 0, 1);
2000-08-30 16:20:24 +08:00
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tmpw), FALSE);
1999-08-27 06:29:37 +08:00
gtk_widget_show (tmpw);
2002-12-10 18:39:23 +08:00
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tmpw), pcvals.sizevoronoi);
g_signal_connect(tmpw, "clicked",
2002-12-10 18:39:23 +08:00
G_CALLBACK(smstrexpsmadjmove), NULL);
gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltips), tmpw, _("Voronoi-mode makes only the smvector closest to the given point have any influence"), NULL);
1999-08-27 06:29:37 +08:00
gtk_widget_show(smwindow);
updatesmvectorprev();
updatesmpreviewprev();
}