gimp/plug-ins/gimpressionist/orientation.c

200 lines
7.2 KiB
C
Raw Normal View History

/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (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
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
1999-08-27 06:29:37 +08:00
#include "config.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 <gtk/gtk.h>
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
1999-08-27 06:29:37 +08:00
#include "gimpressionist.h"
#include "orientation.h"
#include "orientmap.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
static GtkWidget *orient_radio[NUMORIENTRADIO];
static GtkWidget *orient_num_adjust = NULL;
static GtkWidget *orient_first_adjust = NULL;
static GtkWidget *orient_last_adjust = NULL;
1999-08-27 06:29:37 +08:00
static void
orientation_store (GtkWidget *wg, void *d)
{
pcvals.orient_type = GPOINTER_TO_INT (d);
}
1999-08-27 06:29:37 +08:00
int orientation_type_input (int in)
{
return CLAMP_UP_TO (in, NUMORIENTRADIO);
}
void orientation_restore (void)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (orient_radio[pcvals.orient_type]),
TRUE);
gimp_scale_entry_set_value (GIMP_SCALE_ENTRY (orient_num_adjust),
pcvals.orient_num);
gimp_scale_entry_set_value (GIMP_SCALE_ENTRY (orient_first_adjust),
pcvals.orient_first);
gimp_scale_entry_set_value (GIMP_SCALE_ENTRY (orient_last_adjust),
pcvals.orient_last);
}
1999-08-27 06:29:37 +08:00
static void
create_orientmap_dialog_helper (GtkWidget *widget)
1999-08-27 06:29:37 +08:00
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (orient_radio[7]), TRUE);
create_orientmap_dialog (widget);
}
static void
create_orientradio_button (GtkWidget *box,
int orient_type,
const gchar *label,
const gchar *help_string,
GSList **radio_group)
{
create_radio_button (box, orient_type, orientation_store, label,
help_string, radio_group, orient_radio);
1999-08-27 06:29:37 +08:00
}
void
create_orientationpage (GtkNotebook *notebook)
1999-08-27 06:29:37 +08:00
{
GtkWidget *box2, *box3, *box4, *thispage;
GtkWidget *label, *tmpw, *grid;
GSList *radio_group = NULL;
1999-08-27 06:29:37 +08:00
label = gtk_label_new_with_mnemonic (_("Or_ientation"));
1999-08-27 06:29:37 +08:00
2011-09-30 18:17:53 +08:00
thispage = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_container_set_border_width (GTK_CONTAINER (thispage), 12);
gtk_widget_show (thispage);
1999-08-27 06:29:37 +08:00
grid = gtk_grid_new ();
gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
gtk_box_pack_start (GTK_BOX (thispage), grid, FALSE, FALSE, 0);
gtk_widget_show (grid);
orient_num_adjust =
gimp_scale_entry_new (_("Directions:"), pcvals.orient_num, 1.0, 30.0, 0);
gimp_help_set_help_data (orient_num_adjust,
_("The number of directions (i.e. brushes) to use"),
NULL);
g_signal_connect (orient_num_adjust, "value-changed",
G_CALLBACK (gimpressionist_scale_entry_update_int),
&pcvals.orient_num);
gtk_grid_attach (GTK_GRID (grid), orient_num_adjust, 0, 0, 3, 1);
gtk_widget_show (orient_num_adjust);
orient_first_adjust =
gimp_scale_entry_new (_("Start angle:"), pcvals.orient_first, 0.0, 360.0, 0);
gimp_help_set_help_data (orient_first_adjust,
_("The starting angle of the first brush to create"),
NULL);
g_signal_connect (orient_first_adjust, "value-changed",
G_CALLBACK (gimpressionist_scale_entry_update_double),
&pcvals.orient_first);
gtk_grid_attach (GTK_GRID (grid), orient_first_adjust, 0, 1, 3, 1);
gtk_widget_show (orient_first_adjust);
orient_last_adjust =
gimp_scale_entry_new (_("Angle span:"), pcvals.orient_last, 0.0, 360.0, 0);
gimp_help_set_help_data (orient_last_adjust,
_("The angle span of the first brush to create"),
NULL);
g_signal_connect (orient_last_adjust, "value-changed",
G_CALLBACK (gimpressionist_scale_entry_update_double),
&pcvals.orient_last);
gtk_grid_attach (GTK_GRID (grid), orient_last_adjust, 0, 2, 3, 1);
gtk_widget_show (orient_last_adjust);
1999-08-27 06:29:37 +08:00
2011-09-30 18:17:53 +08:00
box2 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
gtk_box_pack_start (GTK_BOX (thispage), box2, FALSE, FALSE, 0);
1999-08-27 06:29:37 +08:00
gtk_widget_show (box2);
2011-09-30 18:17:53 +08:00
box3 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_box_pack_start (GTK_BOX (box2), box3, FALSE, FALSE, 0);
gtk_widget_show (box3);
tmpw = gtk_label_new (_("Orientation:"));
gtk_box_pack_start (GTK_BOX (box3), tmpw, FALSE, FALSE, 0);
1999-08-27 06:29:37 +08:00
gtk_widget_show (tmpw);
2011-09-30 18:17:53 +08:00
box3 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_box_pack_start (GTK_BOX (box2), box3, FALSE, FALSE, 0);
gtk_widget_show (box3);
1999-08-27 06:29:37 +08:00
create_orientradio_button (box3, ORIENTATION_VALUE, _("Value"),
_("Let the value (brightness) of the region determine the direction of the stroke"),
&radio_group);
create_orientradio_button (box3, ORIENTATION_RADIUS, _("Radius"),
_("The distance from the center of the image determines the direction of the stroke"),
&radio_group);
create_orientradio_button (box3, ORIENTATION_RANDOM, _("Random"),
_("Selects a random direction of each stroke"),
&radio_group);
create_orientradio_button (box3, ORIENTATION_RADIAL, _("Radial"),
_("Let the direction from the center determine the direction of the stroke"),
&radio_group);
2011-09-30 18:17:53 +08:00
box3 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_box_pack_start (GTK_BOX (box2), box3, FALSE, FALSE, 0);
gtk_widget_show (box3);
create_orientradio_button (box3, ORIENTATION_FLOWING, _("Flowing"),
_("The strokes follow a \"flowing\" pattern"),
&radio_group);
create_orientradio_button (box3, ORIENTATION_HUE, _("Hue"),
_("The hue of the region determines the direction of the stroke"),
&radio_group);
create_orientradio_button (box3, ORIENTATION_ADAPTIVE, _("Adaptive"),
_("The direction that matches the original image the closest is selected"),
&radio_group);
2011-09-30 18:17:53 +08:00
box4 = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_box_pack_start (GTK_BOX (box3), box4, FALSE, FALSE, 0);
gtk_widget_show (box4);
create_orientradio_button (box4, ORIENTATION_MANUAL, _("Manual"),
_("Manually specify the stroke orientation"),
&radio_group);
1999-08-27 06:29:37 +08:00
orientation_restore ();
tmpw = gtk_button_new_with_mnemonic (_("_Edit"));
gtk_box_pack_start (GTK_BOX (box4), tmpw, FALSE, FALSE, 0);
gtk_widget_show (tmpw);
g_signal_connect (tmpw, "clicked",
G_CALLBACK (create_orientmap_dialog_helper), NULL);
gimp_help_set_help_data
(tmpw, _("Opens up the Orientation Map Editor"), NULL);
1999-08-27 06:29:37 +08:00
gtk_notebook_append_page_menu (notebook, thispage, label, NULL);
1999-08-27 06:29:37 +08:00
}