2005-03-04 21:23:32 +08:00
|
|
|
/**********************************************************************
|
2006-12-10 05:33:38 +08:00
|
|
|
GIMP - The GNU Image Manipulation Program
|
2005-03-04 21:23:32 +08:00
|
|
|
Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
|
2009-01-18 06:28:01 +08:00
|
|
|
This program is free software: you can redistribute it and/or modify
|
2005-03-04 21:23:32 +08:00
|
|
|
it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
2005-03-04 21:23:32 +08:00
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
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
|
2018-07-12 05:27:07 +08:00
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2005-03-04 21:23:32 +08:00
|
|
|
*********************************************************************/
|
|
|
|
|
2000-01-06 06:37:07 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2003-06-13 22:37:00 +08:00
|
|
|
#include <errno.h>
|
1999-09-09 10:51:57 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2005-03-04 21:23:32 +08:00
|
|
|
#include <glib/gstdio.h>
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include <libgimp/gimp.h>
|
2000-01-29 11:19:53 +08:00
|
|
|
#include <libgimp/gimpui.h>
|
|
|
|
|
2008-03-25 04:27:34 +08:00
|
|
|
#include "fractal-explorer.h"
|
|
|
|
#include "fractal-explorer-dialogs.h"
|
2000-01-29 11:19:53 +08:00
|
|
|
|
2000-01-06 06:37:07 +08:00
|
|
|
#include "libgimp/stdplugins-intl.h"
|
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2004-01-12 01:39:28 +08:00
|
|
|
#define ZOOM_UNDO_SIZE 100
|
2003-11-06 23:27:05 +08:00
|
|
|
|
|
|
|
|
2004-10-06 07:28:17 +08:00
|
|
|
static gint n_gradient_samples = 0;
|
2003-12-14 07:58:33 +08:00
|
|
|
static gdouble *gradient_samples = NULL;
|
2022-09-06 07:28:35 +08:00
|
|
|
static GimpGradient *gradient = NULL;
|
2003-10-02 05:47:49 +08:00
|
|
|
static gboolean ready_now = FALSE;
|
2003-12-14 07:58:33 +08:00
|
|
|
static gchar *tpath = NULL;
|
2003-10-02 05:47:49 +08:00
|
|
|
static DialogElements *elements = NULL;
|
|
|
|
static GtkWidget *cmap_preview;
|
|
|
|
static GtkWidget *maindlg;
|
|
|
|
|
2004-01-12 01:39:28 +08:00
|
|
|
static explorer_vals_t zooms[ZOOM_UNDO_SIZE];
|
|
|
|
static gint zoomindex = 0;
|
|
|
|
static gint zoommax = 0;
|
2003-10-02 05:47:49 +08:00
|
|
|
|
2003-12-14 07:58:33 +08:00
|
|
|
static gint oldxpos = -1;
|
|
|
|
static gint oldypos = -1;
|
2003-10-02 05:47:49 +08:00
|
|
|
static gdouble x_press = -1.0;
|
|
|
|
static gdouble y_press = -1.0;
|
|
|
|
|
|
|
|
static explorer_vals_t standardvals =
|
|
|
|
{
|
|
|
|
0,
|
|
|
|
-2.0,
|
|
|
|
2.0,
|
|
|
|
-1.5,
|
|
|
|
1.5,
|
|
|
|
50.0,
|
|
|
|
-0.75,
|
|
|
|
-0.2,
|
|
|
|
0,
|
|
|
|
1.0,
|
|
|
|
1.0,
|
|
|
|
1.0,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
1,
|
|
|
|
256,
|
|
|
|
0
|
|
|
|
};
|
2000-01-29 11:19:53 +08:00
|
|
|
|
1999-09-09 10:51:57 +08:00
|
|
|
/**********************************************************************
|
2000-01-29 11:19:53 +08:00
|
|
|
FORWARD DECLARATIONS
|
1999-09-09 10:51:57 +08:00
|
|
|
*********************************************************************/
|
|
|
|
|
2004-04-16 00:58:21 +08:00
|
|
|
static void load_file_chooser_response (GtkFileChooser *chooser,
|
|
|
|
gint response_id,
|
|
|
|
gpointer data);
|
|
|
|
static void save_file_chooser_response (GtkFileChooser *chooser,
|
|
|
|
gint response_id,
|
|
|
|
gpointer data);
|
|
|
|
static void create_load_file_chooser (GtkWidget *widget,
|
|
|
|
GtkWidget *dialog);
|
|
|
|
static void create_save_file_chooser (GtkWidget *widget,
|
|
|
|
GtkWidget *dialog);
|
|
|
|
|
2004-07-30 04:52:56 +08:00
|
|
|
static void cmap_preview_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation);
|
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
/**********************************************************************
|
|
|
|
CALLBACKS
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
static void
|
2003-11-06 23:27:05 +08:00
|
|
|
dialog_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
gpointer data)
|
2000-01-29 11:19:53 +08:00
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
switch (response_id)
|
|
|
|
{
|
|
|
|
case GTK_RESPONSE_OK:
|
|
|
|
wint.run = TRUE;
|
|
|
|
gtk_widget_destroy (widget);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
gtk_widget_destroy (widget);
|
|
|
|
break;
|
|
|
|
}
|
2000-01-29 11:19:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dialog_reset_callback (GtkWidget *widget,
|
2003-12-14 07:58:33 +08:00
|
|
|
gpointer data)
|
2000-01-29 11:19:53 +08:00
|
|
|
{
|
|
|
|
wvals.xmin = standardvals.xmin;
|
|
|
|
wvals.xmax = standardvals.xmax;
|
|
|
|
wvals.ymin = standardvals.ymin;
|
|
|
|
wvals.ymax = standardvals.ymax;
|
|
|
|
wvals.iter = standardvals.iter;
|
2000-12-29 23:22:01 +08:00
|
|
|
wvals.cx = standardvals.cx;
|
|
|
|
wvals.cy = standardvals.cy;
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
dialog_change_scale ();
|
|
|
|
set_cmap_preview ();
|
|
|
|
dialog_update_preview ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dialog_redraw_callback (GtkWidget *widget,
|
2003-12-14 07:58:33 +08:00
|
|
|
gpointer data)
|
2000-01-29 11:19:53 +08:00
|
|
|
{
|
|
|
|
gint alwaysprev = wvals.alwayspreview;
|
|
|
|
|
|
|
|
wvals.alwayspreview = TRUE;
|
2000-12-29 23:22:01 +08:00
|
|
|
set_cmap_preview ();
|
|
|
|
dialog_update_preview ();
|
2000-01-29 11:19:53 +08:00
|
|
|
wvals.alwayspreview = alwaysprev;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dialog_undo_zoom_callback (GtkWidget *widget,
|
2003-12-14 07:58:33 +08:00
|
|
|
gpointer data)
|
2000-01-29 11:19:53 +08:00
|
|
|
{
|
2004-01-12 01:39:28 +08:00
|
|
|
if (zoomindex > 0)
|
2000-01-29 11:19:53 +08:00
|
|
|
{
|
|
|
|
zooms[zoomindex] = wvals;
|
|
|
|
zoomindex--;
|
|
|
|
wvals = zooms[zoomindex];
|
|
|
|
dialog_change_scale ();
|
|
|
|
set_cmap_preview ();
|
|
|
|
dialog_update_preview ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dialog_redo_zoom_callback (GtkWidget *widget,
|
2003-12-14 07:58:33 +08:00
|
|
|
gpointer data)
|
2000-01-29 11:19:53 +08:00
|
|
|
{
|
|
|
|
if (zoomindex < zoommax)
|
|
|
|
{
|
|
|
|
zoomindex++;
|
|
|
|
wvals = zooms[zoomindex];
|
|
|
|
dialog_change_scale ();
|
|
|
|
set_cmap_preview ();
|
|
|
|
dialog_update_preview ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dialog_step_in_callback (GtkWidget *widget,
|
2003-12-14 07:58:33 +08:00
|
|
|
gpointer data)
|
2000-01-29 11:19:53 +08:00
|
|
|
{
|
|
|
|
double xdifferenz;
|
|
|
|
double ydifferenz;
|
|
|
|
|
2004-01-12 01:39:28 +08:00
|
|
|
if (zoomindex < ZOOM_UNDO_SIZE - 1)
|
2000-01-29 11:19:53 +08:00
|
|
|
{
|
|
|
|
zooms[zoomindex]=wvals;
|
|
|
|
zoomindex++;
|
|
|
|
}
|
2004-01-12 01:39:28 +08:00
|
|
|
zoommax = zoomindex;
|
2000-01-29 11:19:53 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
xdifferenz = wvals.xmax - wvals.xmin;
|
|
|
|
ydifferenz = wvals.ymax - wvals.ymin;
|
|
|
|
wvals.xmin += 1.0 / 6.0 * xdifferenz;
|
|
|
|
wvals.ymin += 1.0 / 6.0 * ydifferenz;
|
|
|
|
wvals.xmax -= 1.0 / 6.0 * xdifferenz;
|
|
|
|
wvals.ymax -= 1.0 / 6.0 * ydifferenz;
|
2000-01-29 11:19:53 +08:00
|
|
|
zooms[zoomindex] = wvals;
|
|
|
|
|
|
|
|
dialog_change_scale ();
|
|
|
|
set_cmap_preview ();
|
|
|
|
dialog_update_preview ();
|
2000-12-29 23:22:01 +08:00
|
|
|
}
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
dialog_step_out_callback (GtkWidget *widget,
|
2003-12-14 07:58:33 +08:00
|
|
|
gpointer data)
|
2000-01-29 11:19:53 +08:00
|
|
|
{
|
2000-12-29 23:22:01 +08:00
|
|
|
gdouble xdifferenz;
|
|
|
|
gdouble ydifferenz;
|
2000-01-29 11:19:53 +08:00
|
|
|
|
2004-01-12 01:39:28 +08:00
|
|
|
if (zoomindex < ZOOM_UNDO_SIZE - 1)
|
2000-01-29 11:19:53 +08:00
|
|
|
{
|
|
|
|
zooms[zoomindex]=wvals;
|
|
|
|
zoomindex++;
|
|
|
|
}
|
2004-01-12 01:39:28 +08:00
|
|
|
zoommax = zoomindex;
|
2000-01-29 11:19:53 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
xdifferenz = wvals.xmax - wvals.xmin;
|
|
|
|
ydifferenz = wvals.ymax - wvals.ymin;
|
|
|
|
wvals.xmin -= 1.0 / 4.0 * xdifferenz;
|
|
|
|
wvals.ymin -= 1.0 / 4.0 * ydifferenz;
|
|
|
|
wvals.xmax += 1.0 / 4.0 * xdifferenz;
|
|
|
|
wvals.ymax += 1.0 / 4.0 * ydifferenz;
|
2000-01-29 11:19:53 +08:00
|
|
|
zooms[zoomindex] = wvals;
|
|
|
|
|
|
|
|
dialog_change_scale ();
|
|
|
|
set_cmap_preview ();
|
|
|
|
dialog_update_preview ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
explorer_toggle_update (GtkWidget *widget,
|
2003-12-14 07:58:33 +08:00
|
|
|
gpointer data)
|
2000-01-29 11:19:53 +08:00
|
|
|
{
|
|
|
|
gimp_toggle_button_update (widget, data);
|
|
|
|
|
|
|
|
set_cmap_preview ();
|
|
|
|
dialog_update_preview ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
explorer_radio_update (GtkWidget *widget,
|
2003-12-14 07:58:33 +08:00
|
|
|
gpointer data)
|
2000-01-29 11:19:53 +08:00
|
|
|
{
|
2006-10-06 18:38:20 +08:00
|
|
|
gboolean c_sensitive;
|
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
gimp_radio_button_update (widget, data);
|
|
|
|
|
2006-10-06 18:38:20 +08:00
|
|
|
switch (wvals.fractaltype)
|
|
|
|
{
|
|
|
|
case TYPE_MANDELBROT:
|
|
|
|
case TYPE_SIERPINSKI:
|
|
|
|
c_sensitive = FALSE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
c_sensitive = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-10-31 04:30:16 +08:00
|
|
|
gtk_widget_set_sensitive (elements->cx, c_sensitive);
|
|
|
|
gtk_widget_set_sensitive (elements->cy, c_sensitive);
|
2006-10-06 18:38:20 +08:00
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
set_cmap_preview ();
|
|
|
|
dialog_update_preview ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-11-06 00:37:15 +08:00
|
|
|
explorer_double_adjustment_update (GimpLabelSpin *entry,
|
|
|
|
gdouble *value)
|
2000-01-29 11:19:53 +08:00
|
|
|
{
|
2020-11-06 00:37:15 +08:00
|
|
|
*value = gimp_label_spin_get_value (entry);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
set_cmap_preview ();
|
|
|
|
dialog_update_preview ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
explorer_number_of_colors_callback (GtkAdjustment *adjustment,
|
2003-12-14 07:58:33 +08:00
|
|
|
gpointer data)
|
2000-01-29 11:19:53 +08:00
|
|
|
{
|
|
|
|
gimp_int_adjustment_update (adjustment, data);
|
|
|
|
|
|
|
|
g_free (gradient_samples);
|
|
|
|
|
2022-09-06 07:28:35 +08:00
|
|
|
if (! gradient)
|
|
|
|
gradient = gimp_context_get_gradient ();
|
2000-01-29 11:19:53 +08:00
|
|
|
|
2022-09-06 07:28:35 +08:00
|
|
|
gimp_gradient_get_uniform_samples (gradient,
|
2004-10-06 07:28:17 +08:00
|
|
|
wvals.ncolors,
|
|
|
|
wvals.gradinvert,
|
|
|
|
&n_gradient_samples,
|
|
|
|
&gradient_samples);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
set_cmap_preview ();
|
|
|
|
dialog_update_preview ();
|
|
|
|
}
|
|
|
|
|
2022-09-06 07:28:35 +08:00
|
|
|
/* Same signature as all GimpResourceSelectButton */
|
2000-01-29 11:19:53 +08:00
|
|
|
static void
|
2022-09-06 07:28:35 +08:00
|
|
|
explorer_gradient_select_callback (gpointer data, /* widget */
|
|
|
|
GimpGradient *gradient,
|
|
|
|
gboolean dialog_closing)
|
2000-01-29 11:19:53 +08:00
|
|
|
{
|
|
|
|
g_free (gradient_samples);
|
|
|
|
|
2022-09-06 07:28:35 +08:00
|
|
|
gimp_gradient_get_uniform_samples (gradient,
|
2004-10-06 07:28:17 +08:00
|
|
|
wvals.ncolors,
|
|
|
|
wvals.gradinvert,
|
|
|
|
&n_gradient_samples,
|
|
|
|
&gradient_samples);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
if (wvals.colormode == 1)
|
|
|
|
{
|
2000-12-29 23:22:01 +08:00
|
|
|
set_cmap_preview ();
|
2003-08-18 20:17:21 +08:00
|
|
|
dialog_update_preview ();
|
2000-01-29 11:19:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-02 05:47:49 +08:00
|
|
|
static void
|
2004-10-06 07:28:17 +08:00
|
|
|
preview_draw_crosshair (gint px,
|
|
|
|
gint py)
|
2003-10-02 05:47:49 +08:00
|
|
|
{
|
|
|
|
gint x, y;
|
|
|
|
guchar *p_ul;
|
|
|
|
|
|
|
|
p_ul = wint.wimage + 3 * (preview_width * py + 0);
|
2003-11-10 06:44:45 +08:00
|
|
|
|
2003-10-02 05:47:49 +08:00
|
|
|
for (x = 0; x < preview_width; x++)
|
|
|
|
{
|
|
|
|
p_ul[0] ^= 254;
|
|
|
|
p_ul[1] ^= 254;
|
|
|
|
p_ul[2] ^= 254;
|
|
|
|
p_ul += 3;
|
|
|
|
}
|
2003-11-10 06:44:45 +08:00
|
|
|
|
2003-10-02 05:47:49 +08:00
|
|
|
p_ul = wint.wimage + 3 * (preview_width * 0 + px);
|
2003-11-10 06:44:45 +08:00
|
|
|
|
2003-10-02 05:47:49 +08:00
|
|
|
for (y = 0; y < preview_height; y++)
|
|
|
|
{
|
|
|
|
p_ul[0] ^= 254;
|
|
|
|
p_ul[1] ^= 254;
|
|
|
|
p_ul[2] ^= 254;
|
|
|
|
p_ul += 3 * preview_width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
preview_redraw (void)
|
|
|
|
{
|
2004-07-30 04:52:56 +08:00
|
|
|
gimp_preview_area_draw (GIMP_PREVIEW_AREA (wint.preview),
|
|
|
|
0, 0, preview_width, preview_height,
|
|
|
|
GIMP_RGB_IMAGE,
|
|
|
|
wint.wimage, preview_width * 3);
|
2003-11-10 06:44:45 +08:00
|
|
|
|
2003-10-02 05:47:49 +08:00
|
|
|
gtk_widget_queue_draw (wint.preview);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
preview_button_press_event (GtkWidget *widget,
|
2003-12-14 07:58:33 +08:00
|
|
|
GdkEventButton *event)
|
2003-10-02 05:47:49 +08:00
|
|
|
{
|
|
|
|
if (event->button == 1)
|
|
|
|
{
|
|
|
|
x_press = event->x;
|
|
|
|
y_press = event->y;
|
|
|
|
xbild = preview_width;
|
|
|
|
ybild = preview_height;
|
|
|
|
xdiff = (xmax - xmin) / xbild;
|
|
|
|
ydiff = (ymax - ymin) / ybild;
|
|
|
|
|
|
|
|
preview_draw_crosshair (x_press, y_press);
|
|
|
|
preview_redraw ();
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
preview_motion_notify_event (GtkWidget *widget,
|
2003-12-14 07:58:33 +08:00
|
|
|
GdkEventButton *event)
|
2003-10-02 05:47:49 +08:00
|
|
|
{
|
|
|
|
if (oldypos != -1)
|
|
|
|
{
|
|
|
|
preview_draw_crosshair (oldxpos, oldypos);
|
|
|
|
}
|
|
|
|
|
|
|
|
oldxpos = event->x;
|
|
|
|
oldypos = event->y;
|
|
|
|
|
|
|
|
if ((oldxpos >= 0.0) &&
|
|
|
|
(oldypos >= 0.0) &&
|
|
|
|
(oldxpos < preview_width) &&
|
|
|
|
(oldypos < preview_height))
|
|
|
|
{
|
|
|
|
preview_draw_crosshair (oldxpos, oldypos);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
oldypos = -1;
|
|
|
|
oldxpos = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
preview_redraw ();
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
preview_leave_notify_event (GtkWidget *widget,
|
2003-12-14 07:58:33 +08:00
|
|
|
GdkEventButton *event)
|
2003-10-02 05:47:49 +08:00
|
|
|
{
|
|
|
|
if (oldypos != -1)
|
|
|
|
{
|
|
|
|
preview_draw_crosshair (oldxpos, oldypos);
|
|
|
|
}
|
|
|
|
oldxpos = -1;
|
|
|
|
oldypos = -1;
|
|
|
|
|
|
|
|
preview_redraw ();
|
|
|
|
|
2009-10-09 23:11:19 +08:00
|
|
|
gdk_window_set_cursor (gtk_widget_get_window (maindlg), NULL);
|
2003-10-02 05:47:49 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
preview_enter_notify_event (GtkWidget *widget,
|
2003-12-14 07:58:33 +08:00
|
|
|
GdkEventButton *event)
|
2003-10-02 05:47:49 +08:00
|
|
|
{
|
2004-05-20 21:32:35 +08:00
|
|
|
static GdkCursor *cursor = NULL;
|
|
|
|
|
|
|
|
if (! cursor)
|
|
|
|
{
|
|
|
|
GdkDisplay *display = gtk_widget_get_display (maindlg);
|
|
|
|
|
|
|
|
cursor = gdk_cursor_new_for_display (display, GDK_TCROSS);
|
|
|
|
|
|
|
|
}
|
2003-11-02 04:06:01 +08:00
|
|
|
|
2009-10-09 23:11:19 +08:00
|
|
|
gdk_window_set_cursor (gtk_widget_get_window (maindlg), cursor);
|
2003-10-02 05:47:49 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
preview_button_release_event (GtkWidget *widget,
|
2003-12-14 07:58:33 +08:00
|
|
|
GdkEventButton *event)
|
2003-10-02 05:47:49 +08:00
|
|
|
{
|
|
|
|
gdouble l_xmin;
|
|
|
|
gdouble l_xmax;
|
|
|
|
gdouble l_ymin;
|
|
|
|
gdouble l_ymax;
|
|
|
|
|
|
|
|
if (event->button == 1)
|
|
|
|
{
|
|
|
|
gdouble x_release, y_release;
|
|
|
|
|
|
|
|
x_release = event->x;
|
|
|
|
y_release = event->y;
|
|
|
|
|
|
|
|
if ((x_press >= 0.0) && (y_press >= 0.0) &&
|
2003-12-14 07:58:33 +08:00
|
|
|
(x_release >= 0.0) && (y_release >= 0.0) &&
|
|
|
|
(x_press < preview_width) && (y_press < preview_height) &&
|
|
|
|
(x_release < preview_width) && (y_release < preview_height))
|
|
|
|
{
|
|
|
|
l_xmin = (wvals.xmin +
|
|
|
|
(wvals.xmax - wvals.xmin) * (x_press / preview_width));
|
|
|
|
l_xmax = (wvals.xmin +
|
|
|
|
(wvals.xmax - wvals.xmin) * (x_release / preview_width));
|
|
|
|
l_ymin = (wvals.ymin +
|
|
|
|
(wvals.ymax - wvals.ymin) * (y_press / preview_height));
|
|
|
|
l_ymax = (wvals.ymin +
|
|
|
|
(wvals.ymax - wvals.ymin) * (y_release / preview_height));
|
|
|
|
|
2004-01-12 01:39:28 +08:00
|
|
|
if (zoomindex < ZOOM_UNDO_SIZE - 1)
|
|
|
|
{
|
|
|
|
zooms[zoomindex] = wvals;
|
|
|
|
zoomindex++;
|
|
|
|
}
|
2003-12-14 07:58:33 +08:00
|
|
|
zoommax = zoomindex;
|
|
|
|
wvals.xmin = l_xmin;
|
|
|
|
wvals.xmax = l_xmax;
|
|
|
|
wvals.ymin = l_ymin;
|
|
|
|
wvals.ymax = l_ymax;
|
|
|
|
dialog_change_scale ();
|
|
|
|
dialog_update_preview ();
|
|
|
|
oldypos = oldxpos = -1;
|
|
|
|
}
|
2003-10-02 05:47:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
/**********************************************************************
|
|
|
|
FUNCTION: explorer_dialog
|
|
|
|
*********************************************************************/
|
1999-09-09 10:51:57 +08:00
|
|
|
|
|
|
|
gint
|
2000-01-29 11:19:53 +08:00
|
|
|
explorer_dialog (void)
|
1999-09-09 10:51:57 +08:00
|
|
|
{
|
2000-01-29 11:19:53 +08:00
|
|
|
GtkWidget *dialog;
|
|
|
|
GtkWidget *top_hbox;
|
|
|
|
GtkWidget *left_vbox;
|
|
|
|
GtkWidget *vbox;
|
2020-10-31 04:30:16 +08:00
|
|
|
GtkWidget *vbox2;
|
2006-06-13 21:25:57 +08:00
|
|
|
GtkWidget *bbox;
|
2000-01-29 11:19:53 +08:00
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *toggle;
|
|
|
|
GtkWidget *toggle_vbox;
|
|
|
|
GtkWidget *toggle_vbox2;
|
|
|
|
GtkWidget *toggle_vbox3;
|
|
|
|
GtkWidget *notebook;
|
|
|
|
GtkWidget *hbox;
|
2018-05-05 23:19:33 +08:00
|
|
|
GtkWidget *grid;
|
2000-01-29 11:19:53 +08:00
|
|
|
GtkWidget *button;
|
2022-09-06 07:28:35 +08:00
|
|
|
GtkWidget *gradient_button;
|
2005-03-05 01:07:34 +08:00
|
|
|
gchar *path;
|
2022-09-06 07:28:35 +08:00
|
|
|
GimpGradient *gradient;
|
2004-05-20 21:32:35 +08:00
|
|
|
GSList *group = NULL;
|
|
|
|
gint i;
|
2000-01-29 11:19:53 +08:00
|
|
|
|
2019-09-21 01:39:00 +08:00
|
|
|
gimp_ui_init (PLUG_IN_BINARY);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
2005-03-05 01:07:34 +08:00
|
|
|
path = gimp_gimprc_query ("fractalexplorer-path");
|
2003-12-14 07:58:33 +08:00
|
|
|
|
2005-03-05 01:07:34 +08:00
|
|
|
if (path)
|
|
|
|
{
|
|
|
|
fractalexplorer_path = g_filename_from_utf8 (path, -1, NULL, NULL, NULL);
|
|
|
|
g_free (path);
|
|
|
|
}
|
|
|
|
else
|
2003-12-14 07:58:33 +08:00
|
|
|
{
|
2019-09-22 00:08:13 +08:00
|
|
|
GFile *gimprc = gimp_directory_file ("gimprc", NULL);
|
2005-04-08 01:10:05 +08:00
|
|
|
gchar *full_path = gimp_config_build_data_path ("fractalexplorer");
|
|
|
|
gchar *esc_path = g_strescape (full_path, NULL);
|
2003-12-14 07:58:33 +08:00
|
|
|
g_free (full_path);
|
|
|
|
|
|
|
|
g_message (_("No %s in gimprc:\n"
|
|
|
|
"You need to add an entry like\n"
|
|
|
|
"(%s \"%s\")\n"
|
|
|
|
"to your %s file."),
|
|
|
|
"fractalexplorer-path",
|
2005-04-08 01:10:05 +08:00
|
|
|
"fractalexplorer-path",
|
2019-09-22 00:08:13 +08:00
|
|
|
esc_path, gimp_file_get_utf8_name (gimprc));
|
2003-12-14 07:58:33 +08:00
|
|
|
|
2019-09-22 00:08:13 +08:00
|
|
|
g_object_unref (gimprc);
|
2003-12-14 07:58:33 +08:00
|
|
|
g_free (esc_path);
|
|
|
|
}
|
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
wint.wimage = g_new (guchar, preview_width * preview_height * 3);
|
|
|
|
elements = g_new (DialogElements, 1);
|
|
|
|
|
|
|
|
dialog = maindlg =
|
2011-04-09 02:31:34 +08:00
|
|
|
gimp_dialog_new (_("Fractal Explorer"), PLUG_IN_ROLE,
|
2003-11-06 23:27:05 +08:00
|
|
|
NULL, 0,
|
2008-08-12 03:42:08 +08:00
|
|
|
gimp_standard_help_func, PLUG_IN_PROC,
|
2000-01-29 11:19:53 +08:00
|
|
|
|
2017-02-12 23:18:24 +08:00
|
|
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
|
|
|
_("_OK"), GTK_RESPONSE_OK,
|
2002-02-05 21:29:46 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
NULL);
|
2003-10-02 05:47:49 +08:00
|
|
|
|
2018-05-10 23:04:37 +08:00
|
|
|
gimp_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
|
2005-09-06 05:40:29 +08:00
|
|
|
GTK_RESPONSE_OK,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1);
|
|
|
|
|
2005-09-10 02:07:31 +08:00
|
|
|
gimp_window_set_transient (GTK_WINDOW (dialog));
|
2005-09-06 05:40:29 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
g_signal_connect (dialog, "response",
|
|
|
|
G_CALLBACK (dialog_response),
|
|
|
|
NULL);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (dialog, "destroy",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gtk_main_quit),
|
|
|
|
NULL);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
2011-09-30 18:17:53 +08:00
|
|
|
top_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
|
2018-05-05 23:19:33 +08:00
|
|
|
gtk_widget_set_vexpand (top_hbox, FALSE);
|
2004-05-20 21:32:35 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (top_hbox), 12);
|
2009-07-16 00:57:12 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
|
|
|
|
top_hbox, FALSE, FALSE, 0);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_widget_show (top_hbox);
|
|
|
|
|
2011-09-30 18:17:53 +08:00
|
|
|
left_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (top_hbox), left_vbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (left_vbox);
|
|
|
|
|
|
|
|
/* Preview */
|
2011-09-30 18:17:53 +08:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
2004-05-20 21:32:35 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (left_vbox), vbox, FALSE, FALSE, 0);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
2004-05-20 21:32:35 +08:00
|
|
|
frame = gtk_frame_new (NULL);
|
2018-10-22 20:47:54 +08:00
|
|
|
gtk_widget_set_halign (frame, GTK_ALIGN_START);
|
2004-05-20 21:32:35 +08:00
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
2018-10-22 20:47:54 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
2004-05-20 21:32:35 +08:00
|
|
|
gtk_widget_show (frame);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
2004-07-30 04:52:56 +08:00
|
|
|
wint.preview = gimp_preview_area_new ();
|
|
|
|
gtk_widget_set_size_request (wint.preview, preview_width, preview_height);
|
2004-05-20 21:32:35 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), wint.preview);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (wint.preview, "button-press-event",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (preview_button_press_event),
|
|
|
|
NULL);
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (wint.preview, "button-release-event",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (preview_button_release_event),
|
2003-12-14 07:58:33 +08:00
|
|
|
NULL);
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (wint.preview, "motion-notify-event",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (preview_motion_notify_event),
|
|
|
|
NULL);
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (wint.preview, "leave-notify-event",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (preview_leave_notify_event),
|
|
|
|
NULL);
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (wint.preview, "enter-notify-event",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (preview_enter_notify_event),
|
|
|
|
NULL);
|
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_widget_set_events (wint.preview, (GDK_BUTTON_PRESS_MASK |
|
2003-12-14 07:58:33 +08:00
|
|
|
GDK_BUTTON_RELEASE_MASK |
|
|
|
|
GDK_POINTER_MOTION_MASK |
|
|
|
|
GDK_LEAVE_NOTIFY_MASK |
|
|
|
|
GDK_ENTER_NOTIFY_MASK));
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_widget_show (wint.preview);
|
|
|
|
|
Missing mnemonics on several dialogs
paste as brush, paste as pattern, select to new brush, select to new pattern
fill selection outline, fill path, stroke selection, distort, rounded rectangle
indexed color conversion, merge visible layers, new guide, new guide (by percent)
image properties, newsprint, fractal explorer, sample colorize, new layer
metadata editor (just a button), spyroplus (only common buttons)
2019-09-05 20:44:17 +08:00
|
|
|
toggle = gtk_check_button_new_with_mnemonic (_("Re_altime preview"));
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), toggle, FALSE, FALSE, 0);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (toggle, "toggled",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (explorer_toggle_update),
|
|
|
|
&wvals.alwayspreview);
|
2006-06-13 21:25:57 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
|
|
|
|
wvals.alwayspreview);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_widget_show (toggle);
|
2006-06-13 21:25:57 +08:00
|
|
|
gimp_help_set_help_data (toggle, _("If enabled the preview will "
|
|
|
|
"be redrawn automatically"), NULL);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
2006-06-13 21:25:57 +08:00
|
|
|
button = gtk_button_new_with_mnemonic (_("R_edraw preview"));
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (dialog_redraw_callback),
|
|
|
|
dialog);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_widget_show (button);
|
|
|
|
|
|
|
|
/* Zoom Options */
|
2004-05-20 21:32:35 +08:00
|
|
|
frame = gimp_frame_new (_("Zoom"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (left_vbox), frame, FALSE, FALSE, 0);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2011-09-30 18:17:53 +08:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
2011-09-30 18:17:53 +08:00
|
|
|
bbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
|
|
|
gtk_box_set_homogeneous (GTK_BOX (bbox), TRUE);
|
2006-06-13 21:25:57 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (bbox);
|
|
|
|
|
2017-03-05 23:01:59 +08:00
|
|
|
button = gtk_button_new_with_mnemonic (_("Zoom _In"));
|
2006-06-13 21:25:57 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (bbox), button, TRUE, TRUE, 0);
|
2002-09-08 00:31:32 +08:00
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
2004-05-20 21:32:35 +08:00
|
|
|
G_CALLBACK (dialog_step_in_callback),
|
2001-12-29 21:26:29 +08:00
|
|
|
dialog);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
2017-03-05 23:01:59 +08:00
|
|
|
button = gtk_button_new_with_mnemonic (_("Zoom _Out"));
|
2006-06-13 21:25:57 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (bbox), button, TRUE, TRUE, 0);
|
2002-09-08 00:31:32 +08:00
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
2004-05-20 21:32:35 +08:00
|
|
|
G_CALLBACK (dialog_step_out_callback),
|
2001-12-29 21:26:29 +08:00
|
|
|
dialog);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
2011-09-30 18:17:53 +08:00
|
|
|
bbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
|
|
|
gtk_box_set_homogeneous (GTK_BOX (bbox), TRUE);
|
2006-06-13 21:25:57 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (bbox);
|
|
|
|
|
2017-03-05 23:01:59 +08:00
|
|
|
button = gtk_button_new_with_mnemonic (_("_Undo"));
|
2006-06-13 21:25:57 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (bbox), button, TRUE, TRUE, 0);
|
2002-09-08 00:31:32 +08:00
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2006-06-13 21:25:57 +08:00
|
|
|
gimp_help_set_help_data (button, _("Undo last zoom change"), NULL);
|
2004-05-20 21:32:35 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
2004-05-20 21:32:35 +08:00
|
|
|
G_CALLBACK (dialog_undo_zoom_callback),
|
2001-12-29 21:26:29 +08:00
|
|
|
dialog);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
2017-03-05 23:01:59 +08:00
|
|
|
button = gtk_button_new_with_mnemonic (_("_Redo"));
|
2006-06-13 21:25:57 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (bbox), button, TRUE, TRUE, 0);
|
2002-09-08 00:31:32 +08:00
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2006-06-13 21:25:57 +08:00
|
|
|
gimp_help_set_help_data (button, _("Redo last zoom change"), NULL);
|
2004-05-20 21:32:35 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
2004-05-20 21:32:35 +08:00
|
|
|
G_CALLBACK (dialog_redo_zoom_callback),
|
2001-12-29 21:26:29 +08:00
|
|
|
dialog);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
/* Create notebook */
|
|
|
|
notebook = gtk_notebook_new ();
|
2018-05-05 23:19:33 +08:00
|
|
|
gtk_widget_set_halign (notebook, GTK_ALIGN_START);
|
|
|
|
gtk_widget_set_hexpand (notebook, FALSE);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (top_hbox), notebook, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (notebook);
|
|
|
|
|
|
|
|
/* "Parameters" page */
|
2011-09-30 18:17:53 +08:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
2004-05-20 21:32:35 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox,
|
2003-12-14 07:58:33 +08:00
|
|
|
gtk_label_new_with_mnemonic (_("_Parameters")));
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
2004-05-20 21:32:35 +08:00
|
|
|
frame = gimp_frame_new (_("Fractal Parameters"));
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2020-10-31 04:30:16 +08:00
|
|
|
vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), vbox2);
|
|
|
|
gtk_widget_show (vbox2);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
elements->xmin =
|
2020-11-01 09:35:03 +08:00
|
|
|
gimp_scale_entry_new (_("Left:"), wvals.xmin, -3, 3, 5);
|
2020-11-06 00:37:15 +08:00
|
|
|
gimp_label_spin_set_increments (GIMP_LABEL_SPIN (elements->xmin), 0.001, 0.01);
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (elements->xmin, "value-changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (explorer_double_adjustment_update),
|
|
|
|
&wvals.xmin);
|
2020-10-31 04:30:16 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox2), elements->xmin, TRUE, TRUE, 2);
|
|
|
|
gtk_widget_show (elements->xmin);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
elements->xmax =
|
2020-11-01 09:35:03 +08:00
|
|
|
gimp_scale_entry_new (_("Right:"), wvals.xmax, -3, 3, 5);
|
2020-11-06 00:37:15 +08:00
|
|
|
gimp_label_spin_set_increments (GIMP_LABEL_SPIN (elements->xmax), 0.001, 0.01);
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (elements->xmax, "value-changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (explorer_double_adjustment_update),
|
|
|
|
&wvals.xmax);
|
2020-10-31 04:30:16 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox2), elements->xmax, TRUE, TRUE, 2);
|
|
|
|
gtk_widget_show (elements->xmax);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
elements->ymin =
|
2020-11-01 09:35:03 +08:00
|
|
|
gimp_scale_entry_new (_("Top:"), wvals.ymin, -3, 3, 5);
|
2020-11-06 00:37:15 +08:00
|
|
|
gimp_label_spin_set_increments (GIMP_LABEL_SPIN (elements->ymin), 0.001, 0.01);
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (elements->ymin, "value-changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (explorer_double_adjustment_update),
|
|
|
|
&wvals.ymin);
|
2020-10-31 04:30:16 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox2), elements->ymin, TRUE, TRUE, 2);
|
|
|
|
gtk_widget_show (elements->ymin);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
elements->ymax =
|
2020-11-01 09:35:03 +08:00
|
|
|
gimp_scale_entry_new (_("Bottom:"), wvals.ymax, -3, 3, 5);
|
2020-11-06 00:37:15 +08:00
|
|
|
gimp_label_spin_set_increments (GIMP_LABEL_SPIN (elements->ymax), 0.001, 0.01);
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (elements->ymax, "value-changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (explorer_double_adjustment_update),
|
|
|
|
&wvals.ymax);
|
2020-10-31 04:30:16 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox2), elements->ymax, TRUE, TRUE, 2);
|
|
|
|
gtk_widget_show (elements->ymax);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
elements->iter =
|
2020-11-01 09:35:03 +08:00
|
|
|
gimp_scale_entry_new (_("Iterations:"), wvals.iter, 1, 1000, 0);
|
2020-10-31 04:30:16 +08:00
|
|
|
gimp_help_set_help_data (elements->iter,
|
|
|
|
_("The higher the number of iterations, "
|
|
|
|
"the more details will be calculated"),
|
|
|
|
NULL);
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (elements->iter, "value-changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (explorer_double_adjustment_update),
|
|
|
|
&wvals.iter);
|
2020-10-31 04:30:16 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox2), elements->iter, TRUE, TRUE, 2);
|
|
|
|
gtk_widget_show (elements->iter);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
elements->cx =
|
2020-11-01 09:35:03 +08:00
|
|
|
gimp_scale_entry_new (_("CX:"), wvals.cx, -2.5, 2.5, 5);
|
2020-11-06 00:37:15 +08:00
|
|
|
gimp_label_spin_set_increments (GIMP_LABEL_SPIN (elements->cx), 0.001, 0.01);
|
2020-10-31 04:30:16 +08:00
|
|
|
gimp_help_set_help_data (elements->cx,
|
|
|
|
_("Changes aspect of fractal"), NULL);
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (elements->cx, "value-changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (explorer_double_adjustment_update),
|
|
|
|
&wvals.cx);
|
2020-10-31 04:30:16 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox2), elements->cx, TRUE, TRUE, 2);
|
|
|
|
gtk_widget_show (elements->cx);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
elements->cy =
|
2020-11-01 09:35:03 +08:00
|
|
|
gimp_scale_entry_new (_("CY:"), wvals.cy, -2.5, 2.5, 5);
|
2020-11-06 00:37:15 +08:00
|
|
|
gimp_label_spin_set_increments (GIMP_LABEL_SPIN (elements->cy), 0.001, 0.01);
|
2020-10-31 04:30:16 +08:00
|
|
|
gimp_help_set_help_data (elements->cy,
|
|
|
|
_("Changes aspect of fractal"), NULL);
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (elements->cy, "value-changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (explorer_double_adjustment_update),
|
|
|
|
&wvals.cy);
|
2020-10-31 04:30:16 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox2), elements->cy, TRUE, TRUE, 2);
|
|
|
|
gtk_widget_show (elements->cy);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
2011-09-30 18:17:53 +08:00
|
|
|
bbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
2018-05-05 23:19:33 +08:00
|
|
|
gtk_widget_set_margin_top (bbox, 12);
|
2011-09-30 18:17:53 +08:00
|
|
|
gtk_box_set_homogeneous (GTK_BOX (bbox), TRUE);
|
2020-10-31 04:30:16 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox2), bbox, TRUE, TRUE, 2);
|
2006-06-13 21:25:57 +08:00
|
|
|
gtk_widget_show (bbox);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
2017-03-05 23:01:59 +08:00
|
|
|
button = gtk_button_new_with_mnemonic (_("_Open"));
|
2006-06-13 21:25:57 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (bbox), button, TRUE, TRUE, 0);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
2004-04-16 00:58:21 +08:00
|
|
|
G_CALLBACK (create_load_file_chooser),
|
2001-12-29 21:26:29 +08:00
|
|
|
dialog);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_widget_show (button);
|
|
|
|
gimp_help_set_help_data (button, _("Load a fractal from file"), NULL);
|
|
|
|
|
2017-03-05 23:01:59 +08:00
|
|
|
button = gtk_button_new_with_mnemonic (_("_Reset"));
|
2006-06-13 21:25:57 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (bbox), button, TRUE, TRUE, 0);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
2006-10-17 20:17:53 +08:00
|
|
|
G_CALLBACK (dialog_reset_callback),
|
2001-12-29 21:26:29 +08:00
|
|
|
dialog);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_widget_show (button);
|
|
|
|
gimp_help_set_help_data (button, _("Reset parameters to default values"),
|
2003-12-14 07:58:33 +08:00
|
|
|
NULL);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
2017-03-05 23:01:59 +08:00
|
|
|
button = gtk_button_new_with_mnemonic (_("_Save"));
|
2006-06-13 21:25:57 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (bbox), button, TRUE, TRUE, 0);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
2004-04-16 00:58:21 +08:00
|
|
|
G_CALLBACK (create_save_file_chooser),
|
2001-12-29 21:26:29 +08:00
|
|
|
dialog);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_widget_show (button);
|
|
|
|
gimp_help_set_help_data (button, _("Save active fractal to file"), NULL);
|
2003-08-18 20:17:21 +08:00
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
/* Fractal type toggle box */
|
2004-05-20 21:32:35 +08:00
|
|
|
frame = gimp_frame_new (_("Fractal Type"));
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
2004-05-20 21:32:35 +08:00
|
|
|
gtk_widget_show (frame);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
2011-09-30 18:17:53 +08:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), hbox);
|
2004-05-20 21:32:35 +08:00
|
|
|
gtk_widget_show (hbox);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
toggle_vbox =
|
2003-11-15 02:05:39 +08:00
|
|
|
gimp_int_radio_group_new (FALSE, NULL,
|
2003-12-14 07:58:33 +08:00
|
|
|
G_CALLBACK (explorer_radio_update),
|
2020-01-15 20:51:55 +08:00
|
|
|
&wvals.fractaltype, NULL, wvals.fractaltype,
|
2003-12-14 07:58:33 +08:00
|
|
|
|
|
|
|
_("Mandelbrot"), TYPE_MANDELBROT,
|
|
|
|
&(elements->type[TYPE_MANDELBROT]),
|
|
|
|
_("Julia"), TYPE_JULIA,
|
|
|
|
&(elements->type[TYPE_JULIA]),
|
|
|
|
_("Barnsley 1"), TYPE_BARNSLEY_1,
|
|
|
|
&(elements->type[TYPE_BARNSLEY_1]),
|
|
|
|
_("Barnsley 2"), TYPE_BARNSLEY_2,
|
|
|
|
&(elements->type[TYPE_BARNSLEY_2]),
|
|
|
|
_("Barnsley 3"), TYPE_BARNSLEY_3,
|
|
|
|
&(elements->type[TYPE_BARNSLEY_3]),
|
|
|
|
_("Spider"), TYPE_SPIDER,
|
|
|
|
&(elements->type[TYPE_SPIDER]),
|
|
|
|
_("Man'o'war"), TYPE_MAN_O_WAR,
|
|
|
|
&(elements->type[TYPE_MAN_O_WAR]),
|
|
|
|
_("Lambda"), TYPE_LAMBDA,
|
|
|
|
&(elements->type[TYPE_LAMBDA]),
|
|
|
|
_("Sierpinski"), TYPE_SIERPINSKI,
|
|
|
|
&(elements->type[TYPE_SIERPINSKI]),
|
|
|
|
|
|
|
|
NULL);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
2011-09-30 18:17:53 +08:00
|
|
|
toggle_vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
|
2000-01-29 11:19:53 +08:00
|
|
|
for (i = TYPE_BARNSLEY_2; i <= TYPE_SPIDER; i++)
|
|
|
|
{
|
2003-01-07 14:16:02 +08:00
|
|
|
g_object_ref (elements->type[i]);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_widget_hide (elements->type[i]);
|
|
|
|
gtk_container_remove (GTK_CONTAINER (toggle_vbox), elements->type[i]);
|
|
|
|
gtk_box_pack_start (GTK_BOX (toggle_vbox2), elements->type[i],
|
2003-12-14 07:58:33 +08:00
|
|
|
FALSE, FALSE, 0);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_widget_show (elements->type[i]);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_object_unref (elements->type[i]);
|
2000-01-29 11:19:53 +08:00
|
|
|
}
|
1999-09-09 10:51:57 +08:00
|
|
|
|
2011-09-30 18:17:53 +08:00
|
|
|
toggle_vbox3 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
|
2000-01-29 11:19:53 +08:00
|
|
|
for (i = TYPE_MAN_O_WAR; i <= TYPE_SIERPINSKI; i++)
|
|
|
|
{
|
2003-01-07 14:16:02 +08:00
|
|
|
g_object_ref (elements->type[i]);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_widget_hide (elements->type[i]);
|
|
|
|
gtk_container_remove (GTK_CONTAINER (toggle_vbox), elements->type[i]);
|
|
|
|
gtk_box_pack_start (GTK_BOX (toggle_vbox3), elements->type[i],
|
2003-12-14 07:58:33 +08:00
|
|
|
FALSE, FALSE, 0);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_widget_show (elements->type[i]);
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_object_unref (elements->type[i]);
|
2000-01-29 11:19:53 +08:00
|
|
|
}
|
1999-09-09 10:51:57 +08:00
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), toggle_vbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (toggle_vbox);
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), toggle_vbox2, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (toggle_vbox2);
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), toggle_vbox3, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (toggle_vbox3);
|
|
|
|
|
|
|
|
/* Color page */
|
2011-09-30 18:17:53 +08:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
2004-05-20 21:32:35 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox,
|
2003-12-14 07:58:33 +08:00
|
|
|
gtk_label_new_with_mnemonic (_("Co_lors")));
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
|
|
|
/* Number of Colors frame */
|
2004-05-20 21:32:35 +08:00
|
|
|
frame = gimp_frame_new (_("Number of Colors"));
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2020-10-31 04:30:16 +08:00
|
|
|
grid = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
2018-05-05 23:19:33 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), grid);
|
|
|
|
gtk_widget_show (grid);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
elements->ncol =
|
2020-11-01 09:35:03 +08:00
|
|
|
gimp_scale_entry_new (_("Number of colors:"), wvals.ncolors, 2, MAXNCOLORS, 0);
|
2020-10-31 04:30:16 +08:00
|
|
|
gimp_help_set_help_data (elements->ncol,
|
|
|
|
_("Change the number of colors in the mapping"),
|
|
|
|
NULL);
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (elements->ncol, "value-changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (explorer_number_of_colors_callback),
|
|
|
|
&wvals.ncolors);
|
2020-10-31 04:30:16 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (grid), elements->ncol, TRUE, TRUE, 2);
|
|
|
|
gtk_widget_show (elements->ncol);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
elements->useloglog = toggle =
|
2003-10-02 05:47:49 +08:00
|
|
|
gtk_check_button_new_with_label (_("Use loglog smoothing"));
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (toggle, "toggled",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (explorer_toggle_update),
|
|
|
|
&wvals.useloglog);
|
2000-08-28 08:42:32 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), wvals.useloglog);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_widget_show (toggle);
|
|
|
|
gimp_help_set_help_data (toggle, _("Use log log smoothing to eliminate "
|
2003-12-14 07:58:33 +08:00
|
|
|
"\"banding\" in the result"), NULL);
|
2020-10-31 04:30:16 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (grid), elements->useloglog, TRUE, TRUE, 2);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
/* Color Density frame */
|
2004-05-20 21:32:35 +08:00
|
|
|
frame = gimp_frame_new (_("Color Density"));
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2020-10-31 04:30:16 +08:00
|
|
|
grid = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
2018-05-05 23:19:33 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), grid);
|
|
|
|
gtk_widget_show (grid);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
elements->red =
|
2020-11-01 09:35:03 +08:00
|
|
|
gimp_scale_entry_new (_("Red:"), wvals.redstretch, 0, 1, 2);
|
2020-10-31 04:30:16 +08:00
|
|
|
gimp_help_set_help_data (elements->red,
|
|
|
|
_("Change the intensity of the red channel"), NULL);
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (elements->red, "value-changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (explorer_double_adjustment_update),
|
|
|
|
&wvals.redstretch);
|
2020-10-31 04:30:16 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (grid), elements->red, TRUE, TRUE, 2);
|
|
|
|
gtk_widget_show (elements->red);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
elements->green =
|
2020-11-01 09:35:03 +08:00
|
|
|
gimp_scale_entry_new (_("Green:"), wvals.greenstretch, 0, 1, 2);
|
2020-10-31 04:30:16 +08:00
|
|
|
gimp_help_set_help_data (elements->green,
|
|
|
|
_("Change the intensity of the green channel"), NULL);
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (elements->green, "value-changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (explorer_double_adjustment_update),
|
|
|
|
&wvals.greenstretch);
|
2020-10-31 04:30:16 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (grid), elements->green, TRUE, TRUE, 2);
|
|
|
|
gtk_widget_show (elements->green);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
elements->blue =
|
2020-11-01 09:35:03 +08:00
|
|
|
gimp_scale_entry_new (_("Blue:"), wvals.bluestretch, 0, 1, 2);
|
2020-10-31 04:30:16 +08:00
|
|
|
gimp_help_set_help_data (elements->blue,
|
|
|
|
_("Change the intensity of the blue channel"), NULL);
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (elements->blue, "value-changed",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (explorer_double_adjustment_update),
|
|
|
|
&wvals.bluestretch);
|
2020-10-31 04:30:16 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (grid), elements->blue, TRUE, TRUE, 2);
|
|
|
|
gtk_widget_show (elements->blue);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
/* Color Function frame */
|
2004-05-20 21:32:35 +08:00
|
|
|
frame = gimp_frame_new (_("Color Function"));
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2011-09-30 18:17:53 +08:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), hbox);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
/* Redmode radio frame */
|
2003-11-15 02:05:39 +08:00
|
|
|
frame = gimp_int_radio_group_new (TRUE, _("Red"),
|
2003-12-14 07:58:33 +08:00
|
|
|
G_CALLBACK (explorer_radio_update),
|
2020-01-15 20:51:55 +08:00
|
|
|
&wvals.redmode, NULL, wvals.redmode,
|
2003-11-15 02:05:39 +08:00
|
|
|
|
2011-11-17 06:13:03 +08:00
|
|
|
_("Sine"), SINUS,
|
2003-12-14 07:58:33 +08:00
|
|
|
&elements->redmode[SINUS],
|
2011-11-17 06:13:03 +08:00
|
|
|
_("Cosine"), COSINUS,
|
2003-12-14 07:58:33 +08:00
|
|
|
&elements->redmode[COSINUS],
|
2011-11-17 06:13:03 +08:00
|
|
|
C_("color-function", "None"), NONE,
|
2003-12-14 07:58:33 +08:00
|
|
|
&elements->redmode[NONE],
|
2003-11-15 02:05:39 +08:00
|
|
|
|
2003-12-14 07:58:33 +08:00
|
|
|
NULL);
|
2000-01-29 11:19:53 +08:00
|
|
|
gimp_help_set_help_data (elements->redmode[SINUS],
|
2003-12-14 07:58:33 +08:00
|
|
|
_("Use sine-function for this color component"),
|
|
|
|
NULL);
|
2000-01-29 11:19:53 +08:00
|
|
|
gimp_help_set_help_data (elements->redmode[COSINUS],
|
2003-12-14 07:58:33 +08:00
|
|
|
_("Use cosine-function for this color "
|
|
|
|
"component"), NULL);
|
2000-01-29 11:19:53 +08:00
|
|
|
gimp_help_set_help_data (elements->redmode[NONE],
|
2003-12-14 07:58:33 +08:00
|
|
|
_("Use linear mapping instead of any "
|
|
|
|
"trigonometrical function for this color "
|
|
|
|
"channel"), NULL);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2009-10-09 23:11:19 +08:00
|
|
|
toggle_vbox = gtk_bin_get_child (GTK_BIN (frame));
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
elements->redinvert = toggle =
|
|
|
|
gtk_check_button_new_with_label (_("Inversion"));
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), wvals.redinvert);
|
|
|
|
gtk_box_pack_start (GTK_BOX (toggle_vbox), toggle, FALSE, FALSE, 0);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (toggle, "toggled",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (explorer_toggle_update),
|
|
|
|
&wvals.redinvert);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_widget_show (toggle);
|
|
|
|
gimp_help_set_help_data (toggle,
|
2003-12-14 07:58:33 +08:00
|
|
|
_("If you enable this option higher color values "
|
|
|
|
"will be swapped with lower ones and vice "
|
|
|
|
"versa"), NULL);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
/* Greenmode radio frame */
|
2003-11-15 02:05:39 +08:00
|
|
|
frame = gimp_int_radio_group_new (TRUE, _("Green"),
|
2003-12-14 07:58:33 +08:00
|
|
|
G_CALLBACK (explorer_radio_update),
|
2020-01-15 20:51:55 +08:00
|
|
|
&wvals.greenmode, NULL, wvals.greenmode,
|
2003-11-15 02:05:39 +08:00
|
|
|
|
2011-11-17 06:13:03 +08:00
|
|
|
_("Sine"), SINUS,
|
2003-12-14 07:58:33 +08:00
|
|
|
&elements->greenmode[SINUS],
|
2011-11-17 06:13:03 +08:00
|
|
|
_("Cosine"), COSINUS,
|
2003-12-14 07:58:33 +08:00
|
|
|
&elements->greenmode[COSINUS],
|
2011-11-17 06:13:03 +08:00
|
|
|
C_("color-function", "None"), NONE,
|
2003-12-14 07:58:33 +08:00
|
|
|
&elements->greenmode[NONE],
|
2003-11-15 02:05:39 +08:00
|
|
|
|
2003-12-14 07:58:33 +08:00
|
|
|
NULL);
|
2000-01-29 11:19:53 +08:00
|
|
|
gimp_help_set_help_data (elements->greenmode[SINUS],
|
2003-12-14 07:58:33 +08:00
|
|
|
_("Use sine-function for this color component"),
|
|
|
|
NULL);
|
2000-01-29 11:19:53 +08:00
|
|
|
gimp_help_set_help_data (elements->greenmode[COSINUS],
|
2003-12-14 07:58:33 +08:00
|
|
|
_("Use cosine-function for this color "
|
|
|
|
"component"), NULL);
|
2000-01-29 11:19:53 +08:00
|
|
|
gimp_help_set_help_data (elements->greenmode[NONE],
|
2003-12-14 07:58:33 +08:00
|
|
|
_("Use linear mapping instead of any "
|
|
|
|
"trigonometrical function for this color "
|
|
|
|
"channel"), NULL);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2009-10-09 23:11:19 +08:00
|
|
|
toggle_vbox = gtk_bin_get_child (GTK_BIN (frame));
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
elements->greeninvert = toggle =
|
|
|
|
gtk_check_button_new_with_label (_("Inversion"));
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), wvals.greeninvert);
|
|
|
|
gtk_box_pack_start (GTK_BOX (toggle_vbox), toggle, FALSE, FALSE, 0);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (toggle, "toggled",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (explorer_toggle_update),
|
|
|
|
&wvals.greeninvert);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_widget_show (toggle);
|
|
|
|
gimp_help_set_help_data (toggle,
|
2003-12-14 07:58:33 +08:00
|
|
|
_("If you enable this option higher color values "
|
|
|
|
"will be swapped with lower ones and vice "
|
|
|
|
"versa"), NULL);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
/* Bluemode radio frame */
|
2003-11-15 02:05:39 +08:00
|
|
|
frame = gimp_int_radio_group_new (TRUE, _("Blue"),
|
2003-12-14 07:58:33 +08:00
|
|
|
G_CALLBACK (explorer_radio_update),
|
2020-01-15 20:51:55 +08:00
|
|
|
&wvals.bluemode, NULL, wvals.bluemode,
|
2003-11-15 02:05:39 +08:00
|
|
|
|
2011-11-17 06:13:03 +08:00
|
|
|
_("Sine"), SINUS,
|
2003-12-14 07:58:33 +08:00
|
|
|
&elements->bluemode[SINUS],
|
2011-11-17 06:13:03 +08:00
|
|
|
_("Cosine"), COSINUS,
|
2003-12-14 07:58:33 +08:00
|
|
|
&elements->bluemode[COSINUS],
|
2011-11-17 06:13:03 +08:00
|
|
|
C_("color-function", "None"), NONE,
|
2003-12-14 07:58:33 +08:00
|
|
|
&elements->bluemode[NONE],
|
2003-11-15 02:05:39 +08:00
|
|
|
|
2003-12-14 07:58:33 +08:00
|
|
|
NULL);
|
2000-01-29 11:19:53 +08:00
|
|
|
gimp_help_set_help_data (elements->bluemode[SINUS],
|
2003-12-14 07:58:33 +08:00
|
|
|
_("Use sine-function for this color component"),
|
|
|
|
NULL);
|
2000-01-29 11:19:53 +08:00
|
|
|
gimp_help_set_help_data (elements->bluemode[COSINUS],
|
2003-12-14 07:58:33 +08:00
|
|
|
_("Use cosine-function for this color "
|
|
|
|
"component"), NULL);
|
2000-01-29 11:19:53 +08:00
|
|
|
gimp_help_set_help_data (elements->bluemode[NONE],
|
2003-12-14 07:58:33 +08:00
|
|
|
_("Use linear mapping instead of any "
|
|
|
|
"trigonometrical function for this color "
|
|
|
|
"channel"), NULL);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2009-10-09 23:11:19 +08:00
|
|
|
toggle_vbox = gtk_bin_get_child (GTK_BIN (frame));
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
elements->blueinvert = toggle =
|
|
|
|
gtk_check_button_new_with_label (_("Inversion"));
|
2000-08-28 08:42:32 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON( toggle), wvals.blueinvert);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (toggle_vbox), toggle, FALSE, FALSE, 0);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (toggle, "toggled",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (explorer_toggle_update),
|
|
|
|
&wvals.blueinvert);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_widget_show (toggle);
|
|
|
|
gimp_help_set_help_data (toggle,
|
2003-12-14 07:58:33 +08:00
|
|
|
_("If you enable this option higher color values "
|
|
|
|
"will be swapped with lower ones and vice "
|
|
|
|
"versa"), NULL);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
/* Colormode toggle box */
|
2004-05-20 21:32:35 +08:00
|
|
|
frame = gimp_frame_new (_("Color Mode"));
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2011-09-30 18:17:53 +08:00
|
|
|
toggle_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), toggle_vbox);
|
|
|
|
gtk_widget_show (toggle_vbox);
|
|
|
|
|
|
|
|
toggle = elements->colormode[0] =
|
2003-10-02 05:47:49 +08:00
|
|
|
gtk_radio_button_new_with_label (group, _("As specified above"));
|
2001-12-29 21:26:29 +08:00
|
|
|
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (toggle));
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (toggle_vbox), toggle, FALSE, FALSE, 0);
|
2001-12-29 21:26:29 +08:00
|
|
|
g_object_set_data (G_OBJECT (toggle), "gimp-item-data",
|
|
|
|
GINT_TO_POINTER (0));
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (toggle, "toggled",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (explorer_radio_update),
|
|
|
|
&wvals.colormode);
|
2000-08-28 08:42:32 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
|
2003-12-14 07:58:33 +08:00
|
|
|
wvals.colormode == 0);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_widget_show (toggle);
|
|
|
|
gimp_help_set_help_data (toggle,
|
2003-12-14 07:58:33 +08:00
|
|
|
_("Create a color-map with the options you "
|
|
|
|
"specified above (color density/function). The "
|
|
|
|
"result is visible in the preview image"), NULL);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
2011-09-30 18:17:53 +08:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (toggle_vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
toggle = elements->colormode[1] =
|
|
|
|
gtk_radio_button_new_with_label (group,
|
2003-12-14 07:58:33 +08:00
|
|
|
_("Apply active gradient to final image"));
|
2001-12-29 21:26:29 +08:00
|
|
|
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (toggle));
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), toggle, TRUE, TRUE, 0);
|
2001-12-29 21:26:29 +08:00
|
|
|
g_object_set_data (G_OBJECT (toggle), "gimp-item-data",
|
|
|
|
GINT_TO_POINTER (1));
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (toggle, "toggled",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (explorer_radio_update),
|
|
|
|
&wvals.colormode);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
|
2003-12-14 07:58:33 +08:00
|
|
|
wvals.colormode == 1);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_widget_show (toggle);
|
|
|
|
gimp_help_set_help_data (toggle,
|
2003-12-14 07:58:33 +08:00
|
|
|
_("Create a color-map using a gradient from "
|
|
|
|
"the gradient editor"), NULL);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
2022-09-06 07:28:35 +08:00
|
|
|
gradient = gimp_context_get_gradient ();
|
2004-10-06 07:28:17 +08:00
|
|
|
|
2022-09-06 07:28:35 +08:00
|
|
|
gimp_gradient_get_uniform_samples (gradient,
|
2004-10-06 07:28:17 +08:00
|
|
|
wvals.ncolors,
|
|
|
|
wvals.gradinvert,
|
|
|
|
&n_gradient_samples,
|
|
|
|
&gradient_samples);
|
|
|
|
|
2022-09-06 07:28:35 +08:00
|
|
|
gradient_button = gimp_gradient_select_button_new (_("FractalExplorer Gradient"),
|
|
|
|
GIMP_RESOURCE (gradient));
|
|
|
|
g_signal_connect (gradient_button, "resource-set",
|
2006-06-26 09:47:22 +08:00
|
|
|
G_CALLBACK (explorer_gradient_select_callback), NULL);
|
2022-09-06 07:28:35 +08:00
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), gradient_button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (gradient_button);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
2018-10-22 20:47:54 +08:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
2000-01-29 11:19:53 +08:00
|
|
|
{
|
|
|
|
gint xsize, ysize;
|
2000-01-29 23:38:26 +08:00
|
|
|
for (ysize = 1; ysize * ysize * ysize < 8192; ysize++) /**/;
|
2000-01-29 11:19:53 +08:00
|
|
|
xsize = wvals.ncolors / ysize;
|
2000-01-29 23:38:26 +08:00
|
|
|
while (xsize * ysize < 8192) xsize++;
|
2018-10-22 20:47:54 +08:00
|
|
|
gtk_widget_set_size_request (hbox, xsize, ysize * 4);
|
2000-01-29 11:19:53 +08:00
|
|
|
}
|
2018-10-22 20:47:54 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (toggle_vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
1999-09-09 10:51:57 +08:00
|
|
|
|
2004-07-30 04:52:56 +08:00
|
|
|
cmap_preview = gimp_preview_area_new ();
|
2018-10-22 20:47:54 +08:00
|
|
|
gtk_widget_set_halign (cmap_preview, GTK_ALIGN_CENTER);
|
|
|
|
gtk_widget_set_valign (cmap_preview, GTK_ALIGN_CENTER);
|
2004-07-30 04:52:56 +08:00
|
|
|
gtk_widget_set_size_request (cmap_preview, 32, 32);
|
2018-10-22 20:47:54 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), cmap_preview, TRUE, TRUE, 0);
|
2008-08-12 22:45:59 +08:00
|
|
|
g_signal_connect (cmap_preview, "size-allocate",
|
2004-07-30 04:52:56 +08:00
|
|
|
G_CALLBACK (cmap_preview_size_allocate), NULL);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_widget_show (cmap_preview);
|
1999-09-09 10:51:57 +08:00
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
frame = add_objects_list ();
|
2003-08-18 20:17:21 +08:00
|
|
|
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), frame,
|
2003-12-14 07:58:33 +08:00
|
|
|
gtk_label_new_with_mnemonic (_("_Fractals")));
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_widget_show (frame);
|
1999-09-09 10:51:57 +08:00
|
|
|
|
2006-10-06 16:33:02 +08:00
|
|
|
gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), 0);
|
1999-09-09 10:51:57 +08:00
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_widget_show (dialog);
|
|
|
|
ready_now = TRUE;
|
1999-09-09 10:51:57 +08:00
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
set_cmap_preview ();
|
|
|
|
dialog_update_preview ();
|
|
|
|
|
|
|
|
gtk_main ();
|
|
|
|
|
|
|
|
g_free (wint.wimage);
|
|
|
|
|
|
|
|
return wint.run;
|
|
|
|
}
|
1999-09-09 10:51:57 +08:00
|
|
|
|
2003-10-02 05:47:49 +08:00
|
|
|
|
1999-09-09 10:51:57 +08:00
|
|
|
/**********************************************************************
|
|
|
|
FUNCTION: dialog_update_preview
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
void
|
2000-01-29 11:19:53 +08:00
|
|
|
dialog_update_preview (void)
|
1999-09-09 10:51:57 +08:00
|
|
|
{
|
2000-01-29 11:19:53 +08:00
|
|
|
gint ycoord;
|
|
|
|
guchar *p_ul;
|
2003-08-18 20:17:21 +08:00
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
if (NULL == wint.preview)
|
|
|
|
return;
|
|
|
|
|
2003-10-02 05:47:49 +08:00
|
|
|
if (ready_now && wvals.alwayspreview)
|
2000-01-29 11:19:53 +08:00
|
|
|
{
|
|
|
|
xmin = wvals.xmin;
|
|
|
|
xmax = wvals.xmax;
|
|
|
|
ymin = wvals.ymin;
|
|
|
|
ymax = wvals.ymax;
|
|
|
|
xbild = preview_width;
|
|
|
|
ybild = preview_height;
|
|
|
|
xdiff = (xmax - xmin) / xbild;
|
|
|
|
ydiff = (ymax - ymin) / ybild;
|
|
|
|
|
|
|
|
p_ul = wint.wimage;
|
2006-11-15 03:44:21 +08:00
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
for (ycoord = 0; ycoord < preview_height; ycoord++)
|
2003-12-14 07:58:33 +08:00
|
|
|
{
|
2006-11-16 01:35:12 +08:00
|
|
|
explorer_render_row (NULL,
|
|
|
|
p_ul,
|
|
|
|
ycoord,
|
|
|
|
preview_width,
|
|
|
|
3);
|
|
|
|
p_ul += preview_width * 3;
|
2006-10-06 17:05:52 +08:00
|
|
|
}
|
2000-01-29 11:19:53 +08:00
|
|
|
|
2003-10-02 05:47:49 +08:00
|
|
|
preview_redraw ();
|
2000-01-29 11:19:53 +08:00
|
|
|
}
|
|
|
|
}
|
1999-09-09 10:51:57 +08:00
|
|
|
|
|
|
|
/**********************************************************************
|
2004-07-30 04:52:56 +08:00
|
|
|
FUNCTION: cmap_preview_size_allocate()
|
1999-09-09 10:51:57 +08:00
|
|
|
*********************************************************************/
|
|
|
|
|
2004-07-30 04:52:56 +08:00
|
|
|
static void
|
|
|
|
cmap_preview_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation)
|
1999-09-09 10:51:57 +08:00
|
|
|
{
|
2004-07-30 04:52:56 +08:00
|
|
|
gint i;
|
|
|
|
gint x;
|
|
|
|
gint y;
|
|
|
|
gint j;
|
|
|
|
guchar *b;
|
|
|
|
GimpPreviewArea *preview = GIMP_PREVIEW_AREA (widget);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
2004-07-30 04:52:56 +08:00
|
|
|
b = g_new (guchar, allocation->width * allocation->height * 3);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
2004-07-30 04:52:56 +08:00
|
|
|
for (y = 0; y < allocation->height; y++)
|
2000-01-29 11:19:53 +08:00
|
|
|
{
|
2004-07-30 04:52:56 +08:00
|
|
|
for (x = 0; x < allocation->width; x++)
|
2003-12-14 07:58:33 +08:00
|
|
|
{
|
2004-07-30 04:52:56 +08:00
|
|
|
i = x + (y / 4) * allocation->width;
|
2003-12-14 07:58:33 +08:00
|
|
|
if (i > wvals.ncolors)
|
|
|
|
{
|
|
|
|
for (j = 0; j < 3; j++)
|
2004-07-30 04:52:56 +08:00
|
|
|
b[(y*allocation->width + x) * 3 + j] = 0;
|
2003-12-14 07:58:33 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-06-13 01:00:02 +08:00
|
|
|
b[(y*allocation->width + x) * 3] = colormap[i].r;
|
|
|
|
b[(y*allocation->width + x) * 3 + 1] = colormap[i].g;
|
|
|
|
b[(y*allocation->width + x) * 3 + 2] = colormap[i].b;
|
2003-12-14 07:58:33 +08:00
|
|
|
}
|
|
|
|
}
|
1999-09-09 10:51:57 +08:00
|
|
|
}
|
2004-07-30 04:52:56 +08:00
|
|
|
gimp_preview_area_draw (preview,
|
|
|
|
0, 0, allocation->width, allocation->height,
|
|
|
|
GIMP_RGB_IMAGE, b, allocation->width*3);
|
2001-12-29 21:26:29 +08:00
|
|
|
gtk_widget_queue_draw (cmap_preview);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
g_free (b);
|
2004-07-30 04:52:56 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
FUNCTION: set_cmap_preview()
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
void
|
|
|
|
set_cmap_preview (void)
|
|
|
|
{
|
|
|
|
gint xsize, ysize;
|
|
|
|
|
|
|
|
if (NULL == cmap_preview)
|
|
|
|
return;
|
|
|
|
|
|
|
|
make_color_map ();
|
|
|
|
|
|
|
|
for (ysize = 1; ysize * ysize * ysize < wvals.ncolors; ysize++)
|
|
|
|
/**/;
|
|
|
|
xsize = wvals.ncolors / ysize;
|
|
|
|
while (xsize * ysize < wvals.ncolors)
|
|
|
|
xsize++;
|
|
|
|
|
|
|
|
gtk_widget_set_size_request (cmap_preview, xsize, ysize * 4);
|
1999-09-09 10:51:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
FUNCTION: make_color_map()
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
void
|
2000-01-29 11:19:53 +08:00
|
|
|
make_color_map (void)
|
1999-09-09 10:51:57 +08:00
|
|
|
{
|
2000-01-29 11:19:53 +08:00
|
|
|
gint i;
|
|
|
|
gint r;
|
|
|
|
gint gr;
|
|
|
|
gint bl;
|
|
|
|
gdouble redstretch;
|
|
|
|
gdouble greenstretch;
|
|
|
|
gdouble bluestretch;
|
|
|
|
gdouble pi = atan (1) * 4;
|
|
|
|
|
2003-04-07 00:06:03 +08:00
|
|
|
/* get gradient samples if they don't exist -- fixes gradient color
|
|
|
|
* mode for noninteractive use (bug #103470).
|
|
|
|
*/
|
|
|
|
if (gradient_samples == NULL)
|
2004-10-06 07:28:17 +08:00
|
|
|
{
|
2022-09-06 07:28:35 +08:00
|
|
|
GimpGradient *gradient = gimp_context_get_gradient ();
|
2004-10-06 07:28:17 +08:00
|
|
|
|
2022-09-06 07:28:35 +08:00
|
|
|
gimp_gradient_get_uniform_samples (gradient,
|
2004-10-06 07:28:17 +08:00
|
|
|
wvals.ncolors,
|
|
|
|
wvals.gradinvert,
|
|
|
|
&n_gradient_samples,
|
|
|
|
&gradient_samples);
|
|
|
|
}
|
2003-04-07 00:06:03 +08:00
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
redstretch = wvals.redstretch * 127.5;
|
|
|
|
greenstretch = wvals.greenstretch * 127.5;
|
|
|
|
bluestretch = wvals.bluestretch * 127.5;
|
|
|
|
|
|
|
|
for (i = 0; i < wvals.ncolors; i++)
|
|
|
|
if (wvals.colormode == 1)
|
|
|
|
{
|
2006-06-13 01:00:02 +08:00
|
|
|
colormap[i].r = (guchar)(gradient_samples[i * 4] * 255.9);
|
|
|
|
colormap[i].g = (guchar)(gradient_samples[i * 4 + 1] * 255.9);
|
|
|
|
colormap[i].b = (guchar)(gradient_samples[i * 4 + 2] * 255.9);
|
2000-01-29 11:19:53 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-12-14 07:58:33 +08:00
|
|
|
double x = (i*2.0) / wvals.ncolors;
|
|
|
|
r = gr = bl = 0;
|
|
|
|
|
|
|
|
switch (wvals.redmode)
|
|
|
|
{
|
|
|
|
case SINUS:
|
|
|
|
r = (int) redstretch *(1.0 + sin((x - 1) * pi));
|
|
|
|
break;
|
|
|
|
case COSINUS:
|
|
|
|
r = (int) redstretch *(1.0 + cos((x - 1) * pi));
|
|
|
|
break;
|
|
|
|
case NONE:
|
|
|
|
r = (int)(redstretch *(x));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (wvals.greenmode)
|
|
|
|
{
|
|
|
|
case SINUS:
|
|
|
|
gr = (int) greenstretch *(1.0 + sin((x - 1) * pi));
|
|
|
|
break;
|
|
|
|
case COSINUS:
|
|
|
|
gr = (int) greenstretch *(1.0 + cos((x - 1) * pi));
|
|
|
|
break;
|
|
|
|
case NONE:
|
|
|
|
gr = (int)(greenstretch *(x));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (wvals.bluemode)
|
|
|
|
{
|
|
|
|
case SINUS:
|
|
|
|
bl = (int) bluestretch * (1.0 + sin ((x - 1) * pi));
|
|
|
|
break;
|
|
|
|
case COSINUS:
|
|
|
|
bl = (int) bluestretch * (1.0 + cos ((x - 1) * pi));
|
|
|
|
break;
|
|
|
|
case NONE:
|
|
|
|
bl = (int) (bluestretch * x);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
r = MIN (r, 255);
|
|
|
|
gr = MIN (gr, 255);
|
|
|
|
bl = MIN (bl, 255);
|
|
|
|
|
|
|
|
if (wvals.redinvert)
|
|
|
|
r = 255 - r;
|
|
|
|
|
|
|
|
if (wvals.greeninvert)
|
|
|
|
gr = 255 - gr;
|
|
|
|
|
|
|
|
if (wvals.blueinvert)
|
|
|
|
bl = 255 - bl;
|
|
|
|
|
2006-06-13 01:00:02 +08:00
|
|
|
colormap[i].r = r;
|
|
|
|
colormap[i].g = gr;
|
|
|
|
colormap[i].b = bl;
|
2000-01-29 11:19:53 +08:00
|
|
|
}
|
1999-09-09 10:51:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
FUNCTION: dialog_change_scale
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
void
|
2000-01-29 11:19:53 +08:00
|
|
|
dialog_change_scale (void)
|
1999-09-09 10:51:57 +08:00
|
|
|
{
|
2000-01-29 11:19:53 +08:00
|
|
|
ready_now = FALSE;
|
|
|
|
|
2020-11-06 00:37:15 +08:00
|
|
|
gimp_label_spin_set_value (GIMP_LABEL_SPIN (elements->xmin), wvals.xmin);
|
|
|
|
gimp_label_spin_set_value (GIMP_LABEL_SPIN (elements->xmax), wvals.xmax);
|
|
|
|
gimp_label_spin_set_value (GIMP_LABEL_SPIN (elements->ymin), wvals.ymin);
|
|
|
|
gimp_label_spin_set_value (GIMP_LABEL_SPIN (elements->ymax), wvals.ymax);
|
|
|
|
gimp_label_spin_set_value (GIMP_LABEL_SPIN (elements->iter), wvals.iter);
|
|
|
|
gimp_label_spin_set_value (GIMP_LABEL_SPIN (elements->cx), wvals.cx);
|
|
|
|
gimp_label_spin_set_value (GIMP_LABEL_SPIN (elements->cy), wvals.cy);
|
|
|
|
|
|
|
|
gimp_label_spin_set_value (GIMP_LABEL_SPIN (elements->red), wvals.redstretch);
|
|
|
|
gimp_label_spin_set_value (GIMP_LABEL_SPIN (elements->green), wvals.greenstretch);
|
|
|
|
gimp_label_spin_set_value (GIMP_LABEL_SPIN (elements->blue), wvals.bluestretch);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
gtk_toggle_button_set_active
|
|
|
|
(GTK_TOGGLE_BUTTON (elements->type[wvals.fractaltype]), TRUE);
|
|
|
|
|
|
|
|
gtk_toggle_button_set_active
|
|
|
|
(GTK_TOGGLE_BUTTON (elements->redmode[wvals.redmode]), TRUE);
|
|
|
|
gtk_toggle_button_set_active
|
|
|
|
(GTK_TOGGLE_BUTTON (elements->greenmode[wvals.greenmode]), TRUE);
|
|
|
|
gtk_toggle_button_set_active
|
|
|
|
(GTK_TOGGLE_BUTTON (elements->bluemode[wvals.bluemode]), TRUE);
|
|
|
|
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (elements->redinvert),
|
2003-12-14 07:58:33 +08:00
|
|
|
wvals.redinvert);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (elements->greeninvert),
|
2003-12-14 07:58:33 +08:00
|
|
|
wvals.greeninvert);
|
2000-01-29 11:19:53 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (elements->blueinvert),
|
2003-12-14 07:58:33 +08:00
|
|
|
wvals.blueinvert);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
gtk_toggle_button_set_active
|
|
|
|
(GTK_TOGGLE_BUTTON (elements->colormode[wvals.colormode]), TRUE);
|
|
|
|
|
|
|
|
ready_now = TRUE;
|
1999-09-09 10:51:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
FUNCTION: save_options
|
|
|
|
*********************************************************************/
|
|
|
|
|
2003-10-02 05:47:49 +08:00
|
|
|
static void
|
2000-01-29 11:19:53 +08:00
|
|
|
save_options (FILE * fp)
|
1999-09-09 10:51:57 +08:00
|
|
|
{
|
2006-10-06 16:33:02 +08:00
|
|
|
gchar buf[64];
|
|
|
|
|
1999-09-09 10:51:57 +08:00
|
|
|
/* Save options */
|
2003-08-18 20:17:21 +08:00
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
fprintf (fp, "fractaltype: %i\n", wvals.fractaltype);
|
2006-10-06 16:33:02 +08:00
|
|
|
|
2019-07-30 21:57:36 +08:00
|
|
|
g_ascii_dtostr (buf, sizeof (buf), wvals.xmin);
|
2006-10-06 16:33:02 +08:00
|
|
|
fprintf (fp, "xmin: %s\n", buf);
|
|
|
|
|
2019-07-30 21:57:36 +08:00
|
|
|
g_ascii_dtostr (buf, sizeof (buf), wvals.xmax);
|
2006-10-06 16:33:02 +08:00
|
|
|
fprintf (fp, "xmax: %s\n", buf);
|
|
|
|
|
2019-07-30 21:57:36 +08:00
|
|
|
g_ascii_dtostr (buf, sizeof (buf), wvals.ymin);
|
2006-10-06 16:33:02 +08:00
|
|
|
fprintf (fp, "ymin: %s\n", buf);
|
|
|
|
|
2019-07-30 21:57:36 +08:00
|
|
|
g_ascii_dtostr (buf, sizeof (buf), wvals.ymax);
|
2006-10-06 16:33:02 +08:00
|
|
|
fprintf (fp, "ymax: %s\n", buf);
|
|
|
|
|
2019-07-30 21:57:36 +08:00
|
|
|
g_ascii_dtostr (buf, sizeof (buf), wvals.iter);
|
2006-10-06 16:33:02 +08:00
|
|
|
fprintf (fp, "iter: %s\n", buf);
|
|
|
|
|
2019-07-30 21:57:36 +08:00
|
|
|
g_ascii_dtostr (buf, sizeof (buf), wvals.cx);
|
2006-10-06 16:33:02 +08:00
|
|
|
fprintf (fp, "cx: %s\n", buf);
|
|
|
|
|
2019-07-30 21:57:36 +08:00
|
|
|
g_ascii_dtostr (buf, sizeof (buf), wvals.cy);
|
2006-10-06 16:33:02 +08:00
|
|
|
fprintf (fp, "cy: %s\n", buf);
|
|
|
|
|
2019-07-30 21:57:36 +08:00
|
|
|
g_ascii_dtostr (buf, sizeof (buf), wvals.redstretch * 128.0);
|
2006-10-06 16:33:02 +08:00
|
|
|
fprintf (fp, "redstretch: %s\n", buf);
|
|
|
|
|
2019-07-30 21:57:36 +08:00
|
|
|
g_ascii_dtostr (buf, sizeof (buf), wvals.greenstretch * 128.0);
|
2006-10-06 16:33:02 +08:00
|
|
|
fprintf (fp, "greenstretch: %s\n", buf);
|
|
|
|
|
2019-07-30 21:57:36 +08:00
|
|
|
g_ascii_dtostr (buf, sizeof (buf), wvals.bluestretch * 128.0);
|
2006-10-06 16:33:02 +08:00
|
|
|
fprintf (fp, "bluestretch: %s\n", buf);
|
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
fprintf (fp, "redmode: %i\n", wvals.redmode);
|
|
|
|
fprintf (fp, "greenmode: %i\n", wvals.greenmode);
|
|
|
|
fprintf (fp, "bluemode: %i\n", wvals.bluemode);
|
|
|
|
fprintf (fp, "redinvert: %i\n", wvals.redinvert);
|
|
|
|
fprintf (fp, "greeninvert: %i\n", wvals.greeninvert);
|
|
|
|
fprintf (fp, "blueinvert: %i\n", wvals.blueinvert);
|
|
|
|
fprintf (fp, "colormode: %i\n", wvals.colormode);
|
|
|
|
fputs ("#**********************************************************************\n", fp);
|
|
|
|
fprintf(fp, "<EOF>\n");
|
|
|
|
fputs ("#**********************************************************************\n", fp);
|
1999-09-09 10:51:57 +08:00
|
|
|
}
|
|
|
|
|
2003-10-02 05:47:49 +08:00
|
|
|
static void
|
2000-01-29 11:19:53 +08:00
|
|
|
save_callback (void)
|
1999-09-09 10:51:57 +08:00
|
|
|
{
|
2005-03-04 21:23:32 +08:00
|
|
|
FILE *fp;
|
|
|
|
const gchar *savename = filename;
|
1999-09-09 10:51:57 +08:00
|
|
|
|
2005-03-04 21:23:32 +08:00
|
|
|
fp = g_fopen (savename, "wt+");
|
1999-09-09 10:51:57 +08:00
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
if (!fp)
|
2000-01-29 11:19:53 +08:00
|
|
|
{
|
2003-11-15 21:53:33 +08:00
|
|
|
g_message (_("Could not open '%s' for writing: %s"),
|
2004-01-19 11:06:04 +08:00
|
|
|
gimp_filename_to_utf8 (savename), g_strerror (errno));
|
2000-01-29 11:19:53 +08:00
|
|
|
return;
|
|
|
|
}
|
2003-06-13 22:37:00 +08:00
|
|
|
|
1999-09-09 10:51:57 +08:00
|
|
|
/* Write header out */
|
2000-01-29 11:19:53 +08:00
|
|
|
fputs (FRACTAL_HEADER, fp);
|
|
|
|
fputs ("#**********************************************************************\n", fp);
|
2007-06-06 16:44:52 +08:00
|
|
|
fputs ("# This is a data file for the Fractal Explorer plug-in for GIMP *\n", fp);
|
2000-01-29 11:19:53 +08:00
|
|
|
fputs ("#**********************************************************************\n", fp);
|
1999-09-09 10:51:57 +08:00
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
save_options (fp);
|
1999-09-09 10:51:57 +08:00
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
if (ferror (fp))
|
2003-11-15 21:53:33 +08:00
|
|
|
g_message (_("Could not write '%s': %s"),
|
2004-01-19 11:06:04 +08:00
|
|
|
gimp_filename_to_utf8 (savename), g_strerror (ferror (fp)));
|
2003-06-13 22:37:00 +08:00
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
fclose (fp);
|
1999-09-09 10:51:57 +08:00
|
|
|
}
|
|
|
|
|
2003-10-02 05:47:49 +08:00
|
|
|
static void
|
2004-04-16 00:58:21 +08:00
|
|
|
save_file_chooser_response (GtkFileChooser *chooser,
|
|
|
|
gint response_id,
|
|
|
|
gpointer data)
|
1999-09-09 10:51:57 +08:00
|
|
|
{
|
2003-11-19 22:51:52 +08:00
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
2000-01-29 11:19:53 +08:00
|
|
|
{
|
2004-04-16 00:58:21 +08:00
|
|
|
filename = gtk_file_chooser_get_filename (chooser);
|
2003-11-19 22:51:52 +08:00
|
|
|
|
|
|
|
save_callback ();
|
1999-09-09 10:51:57 +08:00
|
|
|
}
|
2000-01-29 11:19:53 +08:00
|
|
|
|
2004-04-16 00:58:21 +08:00
|
|
|
gtk_widget_destroy (GTK_WIDGET (chooser));
|
1999-09-09 10:51:57 +08:00
|
|
|
}
|
|
|
|
|
2006-10-06 16:33:02 +08:00
|
|
|
static void
|
|
|
|
file_chooser_set_default_folder (GtkFileChooser *chooser)
|
|
|
|
{
|
|
|
|
GList *path_list;
|
|
|
|
gchar *dir;
|
|
|
|
|
|
|
|
if (! fractalexplorer_path)
|
|
|
|
return;
|
|
|
|
|
2012-09-27 05:29:51 +08:00
|
|
|
path_list = gimp_path_parse (fractalexplorer_path, 256, FALSE, NULL);
|
2006-10-06 16:33:02 +08:00
|
|
|
|
|
|
|
dir = gimp_path_get_user_writable_dir (path_list);
|
|
|
|
|
|
|
|
if (! dir)
|
|
|
|
dir = g_strdup (gimp_directory ());
|
|
|
|
|
|
|
|
gtk_file_chooser_set_current_folder (chooser, dir);
|
|
|
|
|
|
|
|
g_free (dir);
|
|
|
|
gimp_path_free (path_list);
|
|
|
|
}
|
|
|
|
|
2003-10-02 05:47:49 +08:00
|
|
|
static void
|
2004-04-16 00:58:21 +08:00
|
|
|
load_file_chooser_response (GtkFileChooser *chooser,
|
|
|
|
gint response_id,
|
|
|
|
gpointer data)
|
1999-09-09 10:51:57 +08:00
|
|
|
{
|
2003-11-19 22:51:52 +08:00
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
2000-01-29 11:19:53 +08:00
|
|
|
{
|
2004-04-16 00:58:21 +08:00
|
|
|
filename = gtk_file_chooser_get_filename (chooser);
|
2003-11-19 22:51:52 +08:00
|
|
|
|
|
|
|
if (g_file_test (filename, G_FILE_TEST_IS_REGULAR))
|
|
|
|
{
|
|
|
|
explorer_load ();
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_show (maindlg);
|
|
|
|
dialog_change_scale ();
|
|
|
|
set_cmap_preview ();
|
|
|
|
dialog_update_preview ();
|
1999-09-09 10:51:57 +08:00
|
|
|
}
|
|
|
|
|
2004-04-16 00:58:21 +08:00
|
|
|
gtk_widget_destroy (GTK_WIDGET (chooser));
|
2000-01-29 11:19:53 +08:00
|
|
|
}
|
1999-09-09 10:51:57 +08:00
|
|
|
|
2003-10-02 05:47:49 +08:00
|
|
|
static void
|
2004-04-16 00:58:21 +08:00
|
|
|
create_load_file_chooser (GtkWidget *widget,
|
|
|
|
GtkWidget *dialog)
|
1999-09-09 10:51:57 +08:00
|
|
|
{
|
2000-01-29 11:19:53 +08:00
|
|
|
static GtkWidget *window = NULL;
|
1999-09-09 10:51:57 +08:00
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
if (!window)
|
|
|
|
{
|
2004-04-16 00:58:21 +08:00
|
|
|
window =
|
|
|
|
gtk_file_chooser_dialog_new (_("Load Fractal Parameters"),
|
|
|
|
GTK_WINDOW (dialog),
|
|
|
|
GTK_FILE_CHOOSER_ACTION_OPEN,
|
|
|
|
|
2017-02-12 23:18:24 +08:00
|
|
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
|
|
|
_("_Open"), GTK_RESPONSE_OK,
|
2004-04-16 00:58:21 +08:00
|
|
|
|
|
|
|
NULL);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
2004-04-16 00:58:21 +08:00
|
|
|
gtk_dialog_set_default_response (GTK_DIALOG (window), GTK_RESPONSE_OK);
|
2003-11-10 06:44:45 +08:00
|
|
|
|
2018-05-10 23:04:37 +08:00
|
|
|
gimp_dialog_set_alternative_button_order (GTK_DIALOG (window),
|
2005-04-08 01:10:05 +08:00
|
|
|
GTK_RESPONSE_OK,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1);
|
|
|
|
|
2006-10-06 16:33:02 +08:00
|
|
|
file_chooser_set_default_folder (GTK_FILE_CHOOSER (window));
|
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (window, "destroy",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gtk_widget_destroyed),
|
|
|
|
&window);
|
2003-11-19 22:51:52 +08:00
|
|
|
g_signal_connect (window, "response",
|
2004-04-16 00:58:21 +08:00
|
|
|
G_CALLBACK (load_file_chooser_response),
|
2001-12-29 21:26:29 +08:00
|
|
|
window);
|
2000-01-29 11:19:53 +08:00
|
|
|
}
|
1999-09-09 10:51:57 +08:00
|
|
|
|
2003-11-19 22:51:52 +08:00
|
|
|
gtk_window_present (GTK_WINDOW (window));
|
2000-01-29 11:19:53 +08:00
|
|
|
}
|
1999-09-09 10:51:57 +08:00
|
|
|
|
2003-10-02 05:47:49 +08:00
|
|
|
static void
|
2004-04-16 00:58:21 +08:00
|
|
|
create_save_file_chooser (GtkWidget *widget,
|
|
|
|
GtkWidget *dialog)
|
1999-09-09 10:51:57 +08:00
|
|
|
{
|
2000-01-29 11:19:53 +08:00
|
|
|
static GtkWidget *window = NULL;
|
|
|
|
|
2004-04-16 00:58:21 +08:00
|
|
|
if (! window)
|
2000-01-29 11:19:53 +08:00
|
|
|
{
|
2004-04-16 00:58:21 +08:00
|
|
|
window =
|
|
|
|
gtk_file_chooser_dialog_new (_("Save Fractal Parameters"),
|
|
|
|
GTK_WINDOW (dialog),
|
|
|
|
GTK_FILE_CHOOSER_ACTION_SAVE,
|
|
|
|
|
2017-02-12 23:18:24 +08:00
|
|
|
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
|
|
|
_("_Save"), GTK_RESPONSE_OK,
|
2004-04-16 00:58:21 +08:00
|
|
|
|
|
|
|
NULL);
|
2000-01-29 11:19:53 +08:00
|
|
|
|
2018-05-10 23:04:37 +08:00
|
|
|
gimp_dialog_set_alternative_button_order (GTK_DIALOG (window),
|
2005-04-08 01:10:05 +08:00
|
|
|
GTK_RESPONSE_OK,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1);
|
2007-02-02 16:57:15 +08:00
|
|
|
gtk_dialog_set_default_response (GTK_DIALOG (window), GTK_RESPONSE_OK);
|
2005-04-08 01:10:05 +08:00
|
|
|
|
2007-02-02 16:57:15 +08:00
|
|
|
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (window),
|
|
|
|
TRUE);
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (window, "destroy",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gtk_widget_destroyed),
|
|
|
|
&window);
|
2003-11-19 22:51:52 +08:00
|
|
|
g_signal_connect (window, "response",
|
2004-04-16 00:58:21 +08:00
|
|
|
G_CALLBACK (save_file_chooser_response),
|
2001-12-29 21:26:29 +08:00
|
|
|
window);
|
1999-09-09 10:51:57 +08:00
|
|
|
}
|
2000-12-29 23:22:01 +08:00
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
if (tpath)
|
|
|
|
{
|
2004-04-16 00:58:21 +08:00
|
|
|
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (window), tpath);
|
2000-01-29 11:19:53 +08:00
|
|
|
}
|
|
|
|
else
|
2000-12-29 23:22:01 +08:00
|
|
|
{
|
2006-10-06 16:33:02 +08:00
|
|
|
file_chooser_set_default_folder (GTK_FILE_CHOOSER (window));
|
2000-12-29 23:22:01 +08:00
|
|
|
}
|
1999-09-09 10:51:57 +08:00
|
|
|
|
2003-11-19 22:51:52 +08:00
|
|
|
gtk_window_present (GTK_WINDOW (window));
|
1999-09-09 10:51:57 +08:00
|
|
|
}
|
|
|
|
|
2003-10-02 05:47:49 +08:00
|
|
|
gchar*
|
2000-01-29 11:19:53 +08:00
|
|
|
get_line (gchar *buf,
|
2003-12-14 07:58:33 +08:00
|
|
|
gint s,
|
|
|
|
FILE *from,
|
|
|
|
gint init)
|
1999-09-09 10:51:57 +08:00
|
|
|
{
|
2000-01-29 11:19:53 +08:00
|
|
|
gint slen;
|
|
|
|
gchar *ret;
|
1999-09-09 10:51:57 +08:00
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
if (init)
|
|
|
|
line_no = 1;
|
|
|
|
else
|
|
|
|
line_no++;
|
1999-09-09 10:51:57 +08:00
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
do
|
|
|
|
{
|
|
|
|
ret = fgets (buf, s, from);
|
1999-09-09 10:51:57 +08:00
|
|
|
}
|
2000-01-29 11:19:53 +08:00
|
|
|
while (!ferror (from) && buf[0] == '#');
|
1999-09-09 10:51:57 +08:00
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
slen = strlen (buf);
|
1999-09-09 10:51:57 +08:00
|
|
|
|
|
|
|
/* The last newline is a pain */
|
2000-01-29 11:19:53 +08:00
|
|
|
if (slen > 0)
|
|
|
|
buf[slen - 1] = '\0';
|
1999-09-09 10:51:57 +08:00
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
if (ferror (from))
|
|
|
|
{
|
|
|
|
g_warning ("Error reading file");
|
|
|
|
return NULL;
|
1999-09-09 10:51:57 +08:00
|
|
|
}
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
return ret;
|
1999-09-09 10:51:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
2000-01-29 11:19:53 +08:00
|
|
|
load_options (fractalexplorerOBJ *xxx,
|
2003-12-14 07:58:33 +08:00
|
|
|
FILE *fp)
|
1999-09-09 10:51:57 +08:00
|
|
|
{
|
2000-01-29 11:19:53 +08:00
|
|
|
gchar load_buf[MAX_LOAD_LINE];
|
|
|
|
gchar str_buf[MAX_LOAD_LINE];
|
|
|
|
gchar opt_buf[MAX_LOAD_LINE];
|
|
|
|
|
|
|
|
/* default values */
|
2003-10-02 05:47:49 +08:00
|
|
|
xxx->opts = standardvals;
|
2003-08-18 20:17:21 +08:00
|
|
|
xxx->opts.gradinvert = FALSE;
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
get_line (load_buf, MAX_LOAD_LINE, fp, 0);
|
|
|
|
|
|
|
|
while (!feof (fp) && strcmp (load_buf, "<EOF>"))
|
|
|
|
{
|
1999-09-09 10:51:57 +08:00
|
|
|
/* Get option name */
|
2007-05-31 18:35:06 +08:00
|
|
|
sscanf (load_buf, "%255s %255s", str_buf, opt_buf);
|
1999-09-09 10:51:57 +08:00
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
if (!strcmp (str_buf, "fractaltype:"))
|
2003-12-14 07:58:33 +08:00
|
|
|
{
|
|
|
|
gint sp = 0;
|
|
|
|
|
|
|
|
sp = atoi (opt_buf);
|
|
|
|
if (sp < 0)
|
|
|
|
return -1;
|
|
|
|
xxx->opts.fractaltype = sp;
|
|
|
|
}
|
2000-01-29 11:19:53 +08:00
|
|
|
else if (!strcmp (str_buf, "xmin:"))
|
2003-12-14 07:58:33 +08:00
|
|
|
{
|
|
|
|
xxx->opts.xmin = g_ascii_strtod (opt_buf, NULL);
|
|
|
|
}
|
2000-01-29 11:19:53 +08:00
|
|
|
else if (!strcmp (str_buf, "xmax:"))
|
2003-12-14 07:58:33 +08:00
|
|
|
{
|
|
|
|
xxx->opts.xmax = g_ascii_strtod (opt_buf, NULL);
|
|
|
|
}
|
2000-01-29 11:19:53 +08:00
|
|
|
else if (!strcmp(str_buf, "ymin:"))
|
2003-12-14 07:58:33 +08:00
|
|
|
{
|
|
|
|
xxx->opts.ymin = g_ascii_strtod (opt_buf, NULL);
|
|
|
|
}
|
2000-01-29 11:19:53 +08:00
|
|
|
else if (!strcmp (str_buf, "ymax:"))
|
2003-12-14 07:58:33 +08:00
|
|
|
{
|
|
|
|
xxx->opts.ymax = g_ascii_strtod (opt_buf, NULL);
|
|
|
|
}
|
2000-01-29 11:19:53 +08:00
|
|
|
else if (!strcmp(str_buf, "redstretch:"))
|
2003-12-14 07:58:33 +08:00
|
|
|
{
|
|
|
|
gdouble sp = g_ascii_strtod (opt_buf, NULL);
|
|
|
|
xxx->opts.redstretch = sp / 128.0;
|
|
|
|
}
|
2000-01-29 11:19:53 +08:00
|
|
|
else if (!strcmp(str_buf, "greenstretch:"))
|
2003-12-14 07:58:33 +08:00
|
|
|
{
|
|
|
|
gdouble sp = g_ascii_strtod (opt_buf, NULL);
|
|
|
|
xxx->opts.greenstretch = sp / 128.0;
|
|
|
|
}
|
2000-01-29 11:19:53 +08:00
|
|
|
else if (!strcmp (str_buf, "bluestretch:"))
|
2003-12-14 07:58:33 +08:00
|
|
|
{
|
|
|
|
gdouble sp = g_ascii_strtod (opt_buf, NULL);
|
|
|
|
xxx->opts.bluestretch = sp / 128.0;
|
|
|
|
}
|
2000-01-29 11:19:53 +08:00
|
|
|
else if (!strcmp (str_buf, "iter:"))
|
2003-12-14 07:58:33 +08:00
|
|
|
{
|
|
|
|
xxx->opts.iter = g_ascii_strtod (opt_buf, NULL);
|
|
|
|
}
|
2000-01-29 11:19:53 +08:00
|
|
|
else if (!strcmp(str_buf, "cx:"))
|
2003-12-14 07:58:33 +08:00
|
|
|
{
|
|
|
|
xxx->opts.cx = g_ascii_strtod (opt_buf, NULL);
|
|
|
|
}
|
2000-01-29 11:19:53 +08:00
|
|
|
else if (!strcmp (str_buf, "cy:"))
|
2003-12-14 07:58:33 +08:00
|
|
|
{
|
|
|
|
xxx->opts.cy = g_ascii_strtod (opt_buf, NULL);
|
|
|
|
}
|
2000-01-29 11:19:53 +08:00
|
|
|
else if (!strcmp(str_buf, "redmode:"))
|
2003-12-14 07:58:33 +08:00
|
|
|
{
|
|
|
|
xxx->opts.redmode = atoi (opt_buf);
|
|
|
|
}
|
2000-01-29 11:19:53 +08:00
|
|
|
else if (!strcmp(str_buf, "greenmode:"))
|
2003-12-14 07:58:33 +08:00
|
|
|
{
|
|
|
|
xxx->opts.greenmode = atoi (opt_buf);
|
|
|
|
}
|
2000-01-29 11:19:53 +08:00
|
|
|
else if (!strcmp(str_buf, "bluemode:"))
|
2003-12-14 07:58:33 +08:00
|
|
|
{
|
|
|
|
xxx->opts.bluemode = atoi (opt_buf);
|
|
|
|
}
|
2000-01-29 11:19:53 +08:00
|
|
|
else if (!strcmp (str_buf, "redinvert:"))
|
2003-12-14 07:58:33 +08:00
|
|
|
{
|
|
|
|
xxx->opts.redinvert = atoi (opt_buf);
|
|
|
|
}
|
2000-01-29 11:19:53 +08:00
|
|
|
else if (!strcmp (str_buf, "greeninvert:"))
|
2003-12-14 07:58:33 +08:00
|
|
|
{
|
|
|
|
xxx->opts.greeninvert = atoi (opt_buf);
|
|
|
|
}
|
2000-01-29 11:19:53 +08:00
|
|
|
else if (!strcmp(str_buf, "blueinvert:"))
|
2003-12-14 07:58:33 +08:00
|
|
|
{
|
|
|
|
xxx->opts.blueinvert = atoi (opt_buf);
|
|
|
|
}
|
2000-01-29 11:19:53 +08:00
|
|
|
else if (!strcmp (str_buf, "colormode:"))
|
2003-12-14 07:58:33 +08:00
|
|
|
{
|
|
|
|
xxx->opts.colormode = atoi (opt_buf);
|
|
|
|
}
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
get_line (load_buf, MAX_LOAD_LINE, fp, 0);
|
1999-09-09 10:51:57 +08:00
|
|
|
}
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
return 0;
|
1999-09-09 10:51:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-01-29 11:19:53 +08:00
|
|
|
explorer_load (void)
|
1999-09-09 10:51:57 +08:00
|
|
|
{
|
2000-01-29 11:19:53 +08:00
|
|
|
FILE *fp;
|
|
|
|
gchar load_buf[MAX_LOAD_LINE];
|
|
|
|
|
2003-08-18 20:17:21 +08:00
|
|
|
g_assert (filename != NULL);
|
2005-03-04 21:23:32 +08:00
|
|
|
|
|
|
|
fp = g_fopen (filename, "rt");
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
if (!fp)
|
|
|
|
{
|
2003-11-15 21:53:33 +08:00
|
|
|
g_message (_("Could not open '%s' for reading: %s"),
|
2004-01-19 11:06:04 +08:00
|
|
|
gimp_filename_to_utf8 (filename), g_strerror (errno));
|
2000-01-29 11:19:53 +08:00
|
|
|
return;
|
1999-09-09 10:51:57 +08:00
|
|
|
}
|
2000-01-29 11:19:53 +08:00
|
|
|
get_line (load_buf, MAX_LOAD_LINE, fp, 1);
|
1999-09-09 10:51:57 +08:00
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
if (strncmp (FRACTAL_HEADER, load_buf, strlen (load_buf)))
|
|
|
|
{
|
2004-01-19 11:06:04 +08:00
|
|
|
g_message (_("'%s' is not a FractalExplorer file"),
|
|
|
|
gimp_filename_to_utf8 (filename));
|
2010-11-10 02:03:47 +08:00
|
|
|
fclose (fp);
|
2000-01-29 11:19:53 +08:00
|
|
|
return;
|
1999-09-09 10:51:57 +08:00
|
|
|
}
|
2000-01-29 11:19:53 +08:00
|
|
|
if (load_options (current_obj,fp))
|
|
|
|
{
|
2003-11-15 21:53:33 +08:00
|
|
|
g_message (_("'%s' is corrupt. Line %d Option section incorrect"),
|
2004-01-19 11:06:04 +08:00
|
|
|
gimp_filename_to_utf8 (filename), line_no);
|
2010-11-10 02:03:47 +08:00
|
|
|
fclose (fp);
|
2000-01-29 11:19:53 +08:00
|
|
|
return;
|
1999-09-09 10:51:57 +08:00
|
|
|
}
|
2000-01-29 11:19:53 +08:00
|
|
|
|
|
|
|
wvals = current_obj->opts;
|
2003-06-13 22:37:00 +08:00
|
|
|
|
2000-01-29 11:19:53 +08:00
|
|
|
fclose (fp);
|
1999-09-09 10:51:57 +08:00
|
|
|
}
|