[gimp/soc-2009-siox-drb] 6.29 error alter
- From: Jie Ding <jieding src gnome org>
- To: svn-commits-list gnome org
- Subject: [gimp/soc-2009-siox-drb] 6.29 error alter
- Date: Mon, 29 Jun 2009 06:49:57 +0000 (UTC)
commit 63f1bb6d6fb2402c4de940f4a1212f4c66f68b98
Author: Jie Ding <jieding src gnome org>
Date: Mon Jun 29 14:48:40 2009 +0800
6.29 error alter
app/base/base-enums.h | 10 +
app/base/siox.h | 1 +
app/core/gimpdrawable-foreground-extract.c | 131 +++++++++++-
app/core/gimpdrawable-foreground-extract.h | 29 +++-
app/tools/gimpforegroundselectoptions.c | 66 ++++++-
app/tools/gimpforegroundselectoptions.h | 3 +
app/tools/gimpforegroundselecttool.c | 302 +++++++++++++++++++++-------
app/tools/gimpforegroundselecttool.h | 7 +
libgimpwidgets/gimppropwidgets.c | 55 +++++
libgimpwidgets/gimppropwidgets.h | 7 +-
10 files changed, 523 insertions(+), 88 deletions(-)
---
diff --git a/app/base/base-enums.h b/app/base/base-enums.h
index cfd5ce8..72a6536 100644
--- a/app/base/base-enums.h
+++ b/app/base/base-enums.h
@@ -130,7 +130,17 @@ typedef enum /*< pdb-skip, skip >*/
SIOX_REFINEMENT_CHANGE_SENSITIVITY = (1 << 2),
SIOX_REFINEMENT_CHANGE_SMOOTHNESS = (1 << 3),
SIOX_REFINEMENT_CHANGE_MULTIBLOB = (1 << 4),
+ SIOX_REFINEMENT_CHANGE_THRESHOLD = (1 << 5),//(new)
SIOX_REFINEMENT_RECALCULATE = 0xFF
} SioxRefinementType;
+typedef enum /*< pdb-skip, skip >*///(new)
+{
+ SIOX_DRB_NO_CHANGE = 0,//(new)
+ SIOX_DRB_ADD = (1 << 0),//(new)
+ SIOX_DRB_SUBTRACT = (1 << 1),//(new)
+ SIOX_DRB_RECALCULATE = 0xFF//(new)
+} SioxDRBType;//(new)
+
#endif /* __BASE_ENUMS_H__ */
+
diff --git a/app/base/siox.h b/app/base/siox.h
index 18d9f99..5be96d1 100644
--- a/app/base/siox.h
+++ b/app/base/siox.h
@@ -36,6 +36,7 @@
#define SIOX_DEFAULT_SMOOTHNESS 3
+#define SIOX_DEFAULT_THRESHOLD 1.0
#define SIOX_DEFAULT_SENSITIVITY_L 0.64
#define SIOX_DEFAULT_SENSITIVITY_A 1.28
diff --git a/app/core/gimpdrawable-foreground-extract.c b/app/core/gimpdrawable-foreground-extract.c
index 42971ca..d58d168 100644
--- a/app/core/gimpdrawable-foreground-extract.c
+++ b/app/core/gimpdrawable-foreground-extract.c
@@ -34,7 +34,9 @@
#include "gimpprogress.h"
#include "gimp-intl.h"
-
+#include "/usr/include/gtk-1.2/gdk/gdkkeysyms.h"
+#include "base/base-types.h"
+#include "base/siox.c"
/* public functions */
@@ -43,7 +45,7 @@ gimp_drawable_foreground_extract (GimpDrawable *drawable,
GimpForegroundExtractMode mode,
GimpDrawable *mask,
GimpProgress *progress)
-{
+{printf("===========gimp_drawable_foreground_extract \n");
SioxState *state;
const gdouble sensitivity[3] = { SIOX_DEFAULT_SENSITIVITY_L,
SIOX_DEFAULT_SENSITIVITY_A,
@@ -59,7 +61,7 @@ gimp_drawable_foreground_extract (GimpDrawable *drawable,
gimp_item_get_height (GIMP_ITEM (mask)));
if (state)
- {
+ { printf("===========gimp_drawable_foreground_extract_statu \n");
gimp_drawable_foreground_extract_siox (mask, state,
SIOX_REFINEMENT_RECALCULATE,
SIOX_DEFAULT_SMOOTHNESS,
@@ -77,7 +79,7 @@ gimp_drawable_foreground_extract_siox_init (GimpDrawable *drawable,
gint y,
gint width,
gint height)
-{
+{printf("===========gimp_drawable_foreground_extract_siox_init \n");
const guchar *colormap = NULL;
gboolean intersect;
gint offset_x;
@@ -118,10 +120,14 @@ gimp_drawable_foreground_extract_siox (GimpDrawable *mask,
const gdouble sensitivity[3],
gboolean multiblob,
GimpProgress *progress)
-{
+{printf("===========gimp_drawable_foreground_extract_siox \n");
+
gint x1, y1;
gint x2, y2;
+
+
+
g_return_if_fail (GIMP_IS_DRAWABLE (mask));
g_return_if_fail (gimp_drawable_bytes (mask) == 1);
@@ -149,17 +155,126 @@ gimp_drawable_foreground_extract_siox (GimpDrawable *mask,
smoothness, sensitivity, multiblob,
(SioxProgressFunc) gimp_progress_set_value,
progress);
-
- if (progress)
+
+ if (progress)
gimp_progress_end (progress);
gimp_drawable_update (mask, x1, y1, x2, y2);
}
+
+
+
+
void
gimp_drawable_foreground_extract_siox_done (SioxState *state)
-{
+{printf("===========gimp_drawable_foreground_extract_siox_done \n");
g_return_if_fail (state != NULL);
siox_done (state);
}
+
+
+
+
+void //(new)
+gimp_drawable_foreground_extract_siox_drb(GimpDrawable *mask,
+ SioxState *state,
+ gboolean optionsrefinement,
+ gint optionsthreshold,//( �为float)
+ gint radius,
+ GimpProgress *progress)
+{ printf("===========gimp_drawable_foreground_extract_siox_drb\n");
+
+ gint x = (state->x);
+ gint y = (state->y);
+ g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
+ if (progress)
+ gimp_progress_start (progress, _("Detail Refinement Brush"), FALSE);
+
+ siox_forefound_drb(state,gimp_drawable_get_tiles(mask),
+ optionsrefinement,x,y,//(ç±»å??ä¸?å?¹é??)
+ radius,optionsthreshold);
+ if (progress)
+ gimp_progress_end (progress);
+
+}
+
+
+/*
+void printstate(SioxState *state)
+{
+ gint x = state->x;
+ gint y = 1;
+ printf("state->x=:%d",x);
+ printf("state->y=:%d",y);
+
+}
+*/
+
+void
+siox_forefound_drb (SioxState *state,
+ TileManager *mask,
+ gboolean options,
+ gint x,
+ gint y,
+ gint brushradius,
+ gfloat threshold)//
+ {printf("===========siox_forefound_drb \n");
+ SioxDRBType drbbrush_mode;//
+
+ gint sioxdrboptions = options;
+ TileManager *drbmask = mask;
+ SioxState *drbstate = state;
+ gfloat drbthreshold = threshold;
+ gint drbbrush_radius = brushradius;
+ gint drbx = x;
+ gint drby = y;
+
+ if(sioxdrboptions == 0)//
+ drbbrush_mode = (1<<0);//
+ else if(sioxdrboptions == 1)//
+ drbbrush_mode = (1<<1);//
+
+ siox_drb(drbstate,//
+ drbmask,//
+ drbx,drby,
+ drbbrush_radius,
+ drbbrush_mode, //
+ drbthreshold);
+
+ }
+
+ /* GimpForegroundSelectTool *fg_select;
+ GimpImage *image;
+
+ gint x;
+ gint y;
+ gfloat threshold;
+ GimpChannel *mask;
+ TileManager *maskdrb;
+ GimpFreeSelectTool *free_sel;
+ GimpForegroundSelectOptions *options;
+ SioxState *state;
+
+ fg_select = GIMP_FOREGROUND_SELECT_TOOL (tool);
+ state = fg_select->state;
+ image = display->image;
+
+ // free_sel = fg_select->parent_instance;
+
+ options = GIMP_FOREGROUND_SELECT_TOOL_GET_OPTIONS (tool);
+ //sioxdrbdate.options = options->refinement;
+ printf("=========soptions=%d",options->refinement);
+ mask = gimp_channel_new(image,gimp_image_get_width(image),gimp_image_get_height(image),"foreground-extraction",NULL);
+ maskdrb = gimp_drawable_get_tiles(mask);
+ x = 45;//state.x ;
+ y = 56;//state.y;
+ threshold = options->threshold;
+ /*GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (draw_tool->display->shell);
+ gint x = fg_select->last_coords.x;
+ gint y = fg_select->last_coords.y;
+ gdouble radius;
+ radius = (options->stroke_width / shell->scale_y) / 2;
+*/
+
diff --git a/app/core/gimpdrawable-foreground-extract.h b/app/core/gimpdrawable-foreground-extract.h
index 74c78d6..1fd88d5 100644
--- a/app/core/gimpdrawable-foreground-extract.h
+++ b/app/core/gimpdrawable-foreground-extract.h
@@ -17,8 +17,13 @@
#ifndef __GIMP_DRAWABLE_FOREGROUND_EXTRACT_H__
#define __GIMP_DRAWABLE_FOREGROUND_EXTRACT_H__
-
-
+/*typedef struct _GimpSioxDrb//(new)
+{
+ SioxState *state;//(new)
+ gboolean options;//(new)
+ GimpDrawable *mask;//(new)
+}SioxDrbState;//(new)
+*/
/* general API (as seen from the PDB) */
void gimp_drawable_foreground_extract (GimpDrawable *drawable,
@@ -36,11 +41,31 @@ SioxState * gimp_drawable_foreground_extract_siox_init (GimpDrawable *drawable
void gimp_drawable_foreground_extract_siox (GimpDrawable *mask,
SioxState *state,
SioxRefinementType refinemane,
+ //GArray *stroke,//(new)
+ //gboolean sioxdrboption,//(new)
gint smoothness,
const gdouble sensitivity[3],
gboolean multiblob,
GimpProgress *progress);
void gimp_drawable_foreground_extract_siox_done (SioxState *state);
+
+void gimp_drawable_foreground_extract_siox_drb(GimpDrawable *mask,//(new)
+ SioxState *state,
+ gboolean optionsrefinement,
+ gint optionsthreshold,//(should be float)
+ gint radius,
+ GimpProgress *progress);
+
+void siox_forefound_drb (SioxState *state,//(new)
+ TileManager *mask,
+ gboolean options,
+ gint x,
+ gint y,
+ gint brushradius,
+ gfloat threshold);//(new)
+void printstate(SioxState *state);
#endif /* __GIMP_DRAWABLE_FOREGROUND_EXTRACT_H__ */
+
+
diff --git a/app/tools/gimpforegroundselectoptions.c b/app/tools/gimpforegroundselectoptions.c
index 8404880..390ac94 100644
--- a/app/tools/gimpforegroundselectoptions.c
+++ b/app/tools/gimpforegroundselectoptions.c
@@ -40,8 +40,10 @@ enum
PROP_ANTIALIAS,
PROP_CONTIGUOUS,
PROP_BACKGROUND,
+ PROP_REFINEMENT,//(new)
PROP_STROKE_WIDTH,
PROP_SMOOTHNESS,
+ PROP_THRESHOLD,//(new)
PROP_MASK_COLOR,
PROP_EXPANDED,
PROP_SENSITIVITY_L,
@@ -89,6 +91,11 @@ gimp_foreground_select_options_class_init (GimpForegroundSelectOptionsClass *kla
"background", NULL,
FALSE,
GIMP_PARAM_STATIC_STRINGS);
+
+ GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_REFINEMENT,//(new)
+ "refinement", NULL,//(new)
+ FALSE,//(new)
+ GIMP_PARAM_STATIC_STRINGS);//(new)
GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_STROKE_WIDTH,
"stroke-width",
@@ -103,6 +110,13 @@ gimp_foreground_select_options_class_init (GimpForegroundSelectOptionsClass *kla
"in the selection"),
0, 8, SIOX_DEFAULT_SMOOTHNESS,
GIMP_PARAM_STATIC_STRINGS);
+
+ GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_THRESHOLD,//(new)
+ "threshold",//(new)
+ _("Range for SIOX_DRB_ADD:1.0"//(new)
+ "Range for SIOX_DRB_ADD:0.0"),//(new)
+ 0.0, 1.0, SIOX_DEFAULT_THRESHOLD,//(new)
+ GIMP_PARAM_STATIC_STRINGS); //(new)
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_MASK_COLOR,
"mask-color", NULL,
@@ -161,6 +175,10 @@ gimp_foreground_select_options_set_property (GObject *object,
options->background = g_value_get_boolean (value);
break;
+ case PROP_REFINEMENT://(new)
+ options->refinement = g_value_get_boolean (value);//(new)
+ break;//(new)
+
case PROP_STROKE_WIDTH:
options->stroke_width = g_value_get_int (value);
break;
@@ -169,6 +187,10 @@ gimp_foreground_select_options_set_property (GObject *object,
options->smoothness = g_value_get_int (value);
break;
+ case PROP_THRESHOLD://(new)
+ options->threshold = g_value_get_int (value);//(new)
+ break;//(new)
+
case PROP_MASK_COLOR:
options->mask_color = g_value_get_enum (value);
break;
@@ -216,6 +238,10 @@ gimp_foreground_select_options_get_property (GObject *object,
case PROP_BACKGROUND:
g_value_set_boolean (value, options->background);
break;
+
+ case PROP_REFINEMENT://(new)
+ g_value_set_boolean (value, options->refinement);//(new)
+ break;//(new)
case PROP_STROKE_WIDTH:
g_value_set_int (value, options->stroke_width);
@@ -225,6 +251,10 @@ gimp_foreground_select_options_get_property (GObject *object,
g_value_set_int (value, options->smoothness);
break;
+ case PROP_THRESHOLD://(new)//(should be float )
+ g_value_set_int (value, options->threshold);//(new)
+ break;//(new)
+
case PROP_MASK_COLOR:
g_value_set_enum (value, options->mask_color);
break;
@@ -259,11 +289,14 @@ gimp_foreground_select_options_gui (GimpToolOptions *tool_options)
GtkWidget *hbox;
GtkWidget *button;
GtkWidget *frame;
+ GtkWidget *frame_drb;//(new)
GtkWidget *scale;
+ GtkWidget *scale_t;//(new)
GtkWidget *label;
GtkWidget *menu;
GtkWidget *inner_frame;
GtkWidget *table;
+ GtkWidget *table_t;//(new)
GtkObject *adj;
gchar *title;
gint row = 0;
@@ -278,7 +311,7 @@ gimp_foreground_select_options_gui (GimpToolOptions *tool_options)
/* foreground / background */
title = g_strdup_printf (_("Interactive refinement (%s)"),
- gimp_get_mod_string (GDK_CONTROL_MASK));
+ gimp_get_mod_string (GDK_CONTROL_MASK));
frame = gimp_prop_boolean_radio_frame_new (config, "background", title,
_("Mark background"),
@@ -288,6 +321,20 @@ gimp_foreground_select_options_gui (GimpToolOptions *tool_options)
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
+ /* add / subtract */
+ title = g_strdup_printf (_("Detail Refinement Brush (%s)"),//(new)
+ gimp_get_mod_string (GDK_CONTROL_MASK));//(new)
+
+ frame_drb = gimp_prop_boolean_radio_frame_drb_new (config, "refinement", title,//(new)
+ _("Subtract"),//(new)
+ _("Add"));//(new)
+
+ g_free (title);//(new)
+
+ gtk_box_pack_start (GTK_BOX (vbox), frame_drb, FALSE, FALSE, 0);//(new)
+ gtk_widget_show (frame_drb);//(new)
+
+
/* stroke width */
inner_frame = gtk_vbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (gtk_bin_get_child (GTK_BIN (frame))),
@@ -318,7 +365,7 @@ gimp_foreground_select_options_gui (GimpToolOptions *tool_options)
gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
gtk_box_pack_start (GTK_BOX (inner_frame), scale, FALSE, FALSE, 0);
gtk_widget_show (scale);
-
+
/* smoothness */
table = gtk_table_new (2, 3, FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
@@ -331,7 +378,19 @@ gimp_foreground_select_options_gui (GimpToolOptions *tool_options)
gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_RIGHT);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("Smoothing:"), 0.0, 0.5, scale, 2, FALSE);
-
+ /* threshold */ //(new)
+ table_t = gtk_table_new (2, 3, FALSE);//(new)
+ gtk_table_set_row_spacings (GTK_TABLE (table_t), 2);//(new)
+ gtk_table_set_col_spacings (GTK_TABLE (table_t), 2);//(new)
+ gtk_box_pack_start (GTK_BOX (vbox), table_t, FALSE, FALSE, 0);//(new)
+ gtk_widget_show (table_t);//(new)
+
+ scale_t = gimp_prop_hscale_new (config, "threshold", 0.01, 0.1, 0);//(new)
+ gtk_range_set_update_policy (GTK_RANGE (scale_t), GTK_UPDATE_DELAYED);//(new)
+ gtk_scale_set_value_pos (GTK_SCALE (scale_t), GTK_POS_RIGHT);//(new)
+ gimp_table_attach_aligned (GTK_TABLE (table_t), 0, 0,//(new)
+ _("Threshold:"), 0.0, 0.5, scale_t, 2, FALSE);//(new)
+
/* mask color */
menu = gimp_prop_enum_combo_box_new (config, "mask-color",
GIMP_RED_CHANNEL, GIMP_BLUE_CHANNEL);
@@ -370,3 +429,4 @@ gimp_foreground_select_options_gui (GimpToolOptions *tool_options)
return vbox;
}
+
diff --git a/app/tools/gimpforegroundselectoptions.h b/app/tools/gimpforegroundselectoptions.h
index be6d947..b6e381e 100644
--- a/app/tools/gimpforegroundselectoptions.h
+++ b/app/tools/gimpforegroundselectoptions.h
@@ -39,8 +39,10 @@ struct _GimpForegroundSelectOptions
gboolean contiguous;
gboolean background;
+ gboolean refinement;//(new)
gint stroke_width;
gint smoothness;
+ gint threshold;//(new)
GimpChannelType mask_color;
gboolean expanded;
gdouble sensitivity[3];
@@ -53,3 +55,4 @@ GtkWidget * gimp_foreground_select_options_gui (GimpToolOptions *tool_optio
#endif /* __GIMP_FOREGROUND_SELECT_OPTIONS_H__ */
+
diff --git a/app/tools/gimpforegroundselecttool.c b/app/tools/gimpforegroundselecttool.c
index b6e612b..0a93f27 100644
--- a/app/tools/gimpforegroundselecttool.c
+++ b/app/tools/gimpforegroundselecttool.c
@@ -51,6 +51,8 @@
#include "gimptoolcontrol.h"
#include "gimp-intl.h"
+#include "base/siox.h"
+#include "gdk/gdkkeysyms.h"//
typedef struct
@@ -91,7 +93,6 @@ static void gimp_foreground_select_tool_button_press (GimpTool *tool
const GimpCoords *coords,
guint32 time,
GdkModifierType state,
- GimpButtonPressType press_type,
GimpDisplay *display);
static void gimp_foreground_select_tool_button_release (GimpTool *tool,
const GimpCoords *coords,
@@ -126,8 +127,14 @@ static void gimp_foreground_select_tool_push_stroke (GimpForegroundSelectTool
static void gimp_foreground_select_options_notify (GimpForegroundSelectOptions *options,
GParamSpec *pspec,
GimpForegroundSelectTool *fg_select);
+/*----new 2009-6-28*/
+//static void gimp_foreground_select_siox_drb(GimpTool *tool,
+ // GimpDisplay *display);
+static gboolean gimp_forground_select_tool_drbsignal(gboolean drbsignal);
+static gboolean mark_drb = FALSE;
+/*----end*/
G_DEFINE_TYPE (GimpForegroundSelectTool, gimp_foreground_select_tool,
GIMP_TYPE_FREE_SELECT_TOOL)
@@ -137,7 +144,7 @@ G_DEFINE_TYPE (GimpForegroundSelectTool, gimp_foreground_select_tool,
void
gimp_foreground_select_tool_register (GimpToolRegisterCallback callback,
gpointer data)
-{
+{printf("=============gimp_foreground_select_tool_register");
(* callback) (GIMP_TYPE_FOREGROUND_SELECT_TOOL,
GIMP_TYPE_FOREGROUND_SELECT_OPTIONS,
gimp_foreground_select_options_gui,
@@ -153,7 +160,7 @@ gimp_foreground_select_tool_register (GimpToolRegisterCallback callback,
static void
gimp_foreground_select_tool_class_init (GimpForegroundSelectToolClass *klass)
-{
+{printf("=============gimp_foreground_select_tool_class_init");
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
@@ -180,7 +187,7 @@ gimp_foreground_select_tool_class_init (GimpForegroundSelectToolClass *klass)
static void
gimp_foreground_select_tool_init (GimpForegroundSelectTool *fg_select)
-{
+{printf("===========gimp_foreground_select_tool_init\n");
GimpTool *tool = GIMP_TOOL (fg_select);
gimp_tool_control_set_scroll_lock (tool->control, FALSE);
@@ -198,13 +205,14 @@ gimp_foreground_select_tool_init (GimpForegroundSelectTool *fg_select)
fg_select->stroke = NULL;
fg_select->strokes = NULL;
fg_select->mask = NULL;
+ fg_select->drbsignal = FALSE; //(new)
}
static GObject *
gimp_foreground_select_tool_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
-{
+{printf("===========tool_constructor\n");
GObject *object;
GimpToolOptions *options;
@@ -221,7 +229,7 @@ gimp_foreground_select_tool_constructor (GType type,
static void
gimp_foreground_select_tool_finalize (GObject *object)
-{
+{printf("===========tool_finalize\n");
GimpForegroundSelectTool *fg_select = GIMP_FOREGROUND_SELECT_TOOL (object);
if (fg_select->stroke)
@@ -243,17 +251,17 @@ static void
gimp_foreground_select_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *display)
-{
+{printf("===========gimp_foreground_select_tool_control\n");
GimpForegroundSelectTool *fg_select = GIMP_FOREGROUND_SELECT_TOOL (tool);
switch (action)
- {
+ {printf("===========action\n");
case GIMP_TOOL_ACTION_PAUSE:
case GIMP_TOOL_ACTION_RESUME:
break;
case GIMP_TOOL_ACTION_HALT:
- {
+ {printf("===========action_halt\n");
GList *list;
gimp_foreground_select_tool_set_mask (fg_select, display, NULL);
@@ -270,7 +278,7 @@ gimp_foreground_select_tool_control (GimpTool *tool,
fg_select->strokes = NULL;
if (fg_select->state)
- {
+ {printf("===========switch action state\n");
gimp_drawable_foreground_extract_siox_done (fg_select->state);
fg_select->state = NULL;
}
@@ -289,7 +297,7 @@ gimp_foreground_select_tool_oper_update (GimpTool *tool,
GdkModifierType state,
gboolean proximity,
GimpDisplay *display)
-{
+{printf("===========gimp_foreground_select_tool_oper_update\n");
GimpForegroundSelectTool *fg_select = GIMP_FOREGROUND_SELECT_TOOL (tool);
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
const gchar *status = NULL;
@@ -303,7 +311,7 @@ gimp_foreground_select_tool_oper_update (GimpTool *tool,
display);
if (fg_select->mask)
- {
+ {printf("===========11\n");
switch (GIMP_SELECTION_TOOL (tool)->function)
{
case SELECTION_SELECT:
@@ -312,7 +320,12 @@ gimp_foreground_select_tool_oper_update (GimpTool *tool,
case SELECTION_MOVE_COPY:
case SELECTION_ANCHOR:
if (fg_select->strokes)
- status = _("Add more strokes or press Enter to accept the selection");
+ {printf("===========12\n");
+ if(!fg_select->drbsignal)//(new)
+ status = _("Add more strokes or press Shift to drb");
+ else
+ status = _("Add more drb or press Enter to accept the selection");
+ }
else
status = _("Mark foreground by painting on the object to extract");
break;
@@ -321,7 +334,7 @@ gimp_foreground_select_tool_oper_update (GimpTool *tool,
}
}
else
- {
+ {printf("===========13\n");
switch (GIMP_SELECTION_TOOL (tool)->function)
{
case SELECTION_SELECT:
@@ -333,23 +346,25 @@ gimp_foreground_select_tool_oper_update (GimpTool *tool,
}
if (proximity)
- {
+ {printf("===========14\n");
if (status)
- gimp_tool_replace_status (tool, display, "%s", status);
-
+ {gimp_tool_replace_status (tool, display, "%s", status);
+ printf("===========15\n");
+ }
gimp_draw_tool_start (draw_tool, display);
}
}
+
static void
gimp_foreground_select_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *display)
-{
+{printf("===========tool_modifier_key\n");
if (key == GDK_CONTROL_MASK)
- {
+ {printf("===========tool_modifier_key_key\n");
GimpForegroundSelectOptions *options;
options = GIMP_FOREGROUND_SELECT_TOOL_GET_OPTIONS (tool);
@@ -357,7 +372,19 @@ gimp_foreground_select_tool_modifier_key (GimpTool *tool,
g_object_set (options,
"background", ! options->background,
NULL);
- }
+ }
+ /*----new----
+ GimpForegroundSelectTool *fg_select = GIMP_FOREGROUND_SELECT_TOOL (tool);
+ gimp_forground_select_tool_drbsignal(fg_select->drbsignal);
+ printf("fg_select->drbsignal=%d\n",fg_select->drbsignal);
+ ----end----*/
+ if(key == GDK_SHIFT_MASK)
+ {
+ mark_drb = TRUE;
+ //gimp_foreground_select_tool_select (GimpFreeSelectTool *free_sel,display);//(修�)
+
+ }
+
}
static void
@@ -365,11 +392,11 @@ gimp_foreground_select_tool_cursor_update (GimpTool *tool,
const GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display)
-{
+{printf("===========gimp_foreground_select_tool_cursor_update\n");
GimpForegroundSelectTool *fg_select = GIMP_FOREGROUND_SELECT_TOOL (tool);
if (fg_select->mask)
- {
+ {printf("===========16\n");
GimpForegroundSelectOptions *options;
options = GIMP_FOREGROUND_SELECT_TOOL_GET_OPTIONS (tool);
@@ -382,12 +409,13 @@ gimp_foreground_select_tool_cursor_update (GimpTool *tool,
case SELECTION_MOVE:
case SELECTION_MOVE_COPY:
case SELECTION_ANCHOR:
+ printf("===========17\n");
return;
default:
break;
}
}
-
+printf("===========18\n");
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
}
@@ -395,12 +423,13 @@ static gboolean
gimp_foreground_select_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *display)
-{
+{printf("===========tool_key_press\n");
GimpForegroundSelectTool *fg_select = GIMP_FOREGROUND_SELECT_TOOL (tool);
-
+
+
if (display != tool->display)
return FALSE;
-
+
if (fg_select->state)
{
switch (kevent->keyval)
@@ -414,42 +443,74 @@ gimp_foreground_select_tool_key_press (GimpTool *tool,
case GDK_Escape:
gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, display);
return TRUE;
-
+ /*---------------add
+ case GDK_SHIFT_MASK:
+ mark_drb = TRUE;
+ /*-----------------end*/
default:
return FALSE;
}
- }
+ }
+/*==============new================
+ if (fg_select->state)
+ {
+ if(fg_select->drbsignal)
+
+ switch (kevent->keyval)
+ {
+ case GDK_Return:
+ case GDK_KP_Enter:
+ case GDK_ISO_Enter:
+ gimp_foreground_select_tool_apply (fg_select, display);
+ return TRUE;
+
+ case GDK_Escape:
+ gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, display);
+ return TRUE;
+
+ default:
+ return FALSE;
+ }
+ else
+ {if (kevent->keyval == GDK_Return)//(new)
+ gimp_forground_select_tool_drbsignal(fg_select->drbsignal);//
+ }
+ }
+ ===============end===========*/
else
{
return GIMP_TOOL_CLASS (parent_class)->key_press (tool,
kevent,
display);
+ printf("===========tool_key_press_return\n");
}
}
static void
-gimp_foreground_select_tool_button_press (GimpTool *tool,
- const GimpCoords *coords,
- guint32 time,
- GdkModifierType state,
- GimpButtonPressType press_type,
- GimpDisplay *display)
-{
+gimp_foreground_select_tool_button_press (GimpTool *tool,
+ const GimpCoords *coords,
+ guint32 time,
+ GdkModifierType state,
+ GimpDisplay *display)
+{printf("===========tool_button_press\n");
GimpForegroundSelectTool *fg_select = GIMP_FOREGROUND_SELECT_TOOL (tool);
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
- if (fg_select->mask)
- {
+ if (fg_select->mask && (!fg_select->drbsignal))//(new)
+ {printf("===========3\n");
GimpVector2 point = gimp_vector2_new (coords->x, coords->y);
gimp_draw_tool_pause (draw_tool);
if (gimp_draw_tool_is_active (draw_tool) && draw_tool->display != display)
- gimp_draw_tool_stop (draw_tool);
+ { gimp_draw_tool_stop (draw_tool);
+ printf("===========4\n");
+ }
if (! gimp_tool_control_is_active (tool->control))
- gimp_tool_control_activate (tool->control);
-
+ { gimp_tool_control_activate (tool->control);
+ printf("===========5\n");
+ }
fg_select->last_coords = *coords;
g_return_if_fail (fg_select->stroke == NULL);
@@ -458,14 +519,43 @@ gimp_foreground_select_tool_button_press (GimpTool *tool,
g_array_append_val (fg_select->stroke, point);
if (! gimp_draw_tool_is_active (draw_tool))
- gimp_draw_tool_start (draw_tool, display);
-
+ { gimp_draw_tool_start (draw_tool, display);
+ printf("===========6\n");
+ }
gimp_draw_tool_resume (draw_tool);
}
- else
+ /*---------------add*/ //ç??ç??å¦?ä½?ä¿®æ?¹
+ else if (fg_select->drbsignal)
+ {
+ GimpVector2 point = gimp_vector2_new (coords->x, coords->y);
+
+ gimp_draw_tool_pause (draw_tool);
+
+ if (gimp_draw_tool_is_active (draw_tool) && draw_tool->display != display)
+ gimp_draw_tool_stop (draw_tool);
+
+
+ if (! gimp_tool_control_is_active (tool->control))
+ gimp_tool_control_activate (tool->control);
+
+ fg_select->last_coords = *coords;
+
+ g_return_if_fail (fg_select->stroke == NULL);
+ fg_select->stroke = g_array_new (FALSE, FALSE, sizeof (GimpVector2));
+
+ g_array_append_val (fg_select->stroke, point);
+
+ if (! gimp_draw_tool_is_active (draw_tool))
+ gimp_draw_tool_start (draw_tool, display);
+
+ gimp_draw_tool_resume (draw_tool);
+
+ }
+ /*---------------end*/
+ else
{
- GIMP_TOOL_CLASS (parent_class)->button_press (tool, coords, time, state,
- press_type, display);
+ GIMP_TOOL_CLASS (parent_class)->button_press (tool,
+ coords, time, state, display);
}
}
@@ -476,11 +566,11 @@ gimp_foreground_select_tool_button_release (GimpTool *tool,
GdkModifierType state,
GimpButtonReleaseType release_type,
GimpDisplay *display)
-{
+{printf("===========tool_button_release\n");
GimpForegroundSelectTool *fg_select = GIMP_FOREGROUND_SELECT_TOOL (tool);
- if (fg_select->mask)
- {
+ if (fg_select->mask && (!fg_select->drbsignal))//
+ {printf("===========0\n");
GimpForegroundSelectOptions *options;
options = GIMP_FOREGROUND_SELECT_TOOL_GET_OPTIONS (tool);
@@ -492,11 +582,17 @@ gimp_foreground_select_tool_button_release (GimpTool *tool,
gimp_foreground_select_tool_push_stroke (fg_select, display, options);
gimp_free_select_tool_select (GIMP_FREE_SELECT_TOOL (tool), display);
-
+ printf("===========1\n");
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
}
- else
- {
+ /*-------------add*/
+ else if (fg_select->drbsignal)
+ {
+
+ }
+ /*--------------end*/
+ else
+ {printf("===========2\n");
GIMP_TOOL_CLASS (parent_class)->button_release (tool,
coords, time, state,
release_type,
@@ -545,7 +641,7 @@ gimp_foreground_select_tool_get_area (GimpChannel *mask,
gint *y1,
gint *x2,
gint *y2)
-{
+{printf("===========tool_get_area\n");
gint width;
gint height;
@@ -621,7 +717,7 @@ gimp_foreground_select_tool_draw (GimpDrawTool *draw_tool)
static void
gimp_foreground_select_tool_select (GimpFreeSelectTool *free_sel,
GimpDisplay *display)
-{
+{printf("===========gimp_foreground_select_tool_select\n");
GimpForegroundSelectTool *fg_select;
GimpForegroundSelectOptions *options;
GimpImage *image = display->image;
@@ -630,20 +726,27 @@ gimp_foreground_select_tool_select (GimpFreeSelectTool *free_sel,
GimpChannel *mask;
const GimpVector2 *points;
gint n_points;
-
- drawable = gimp_image_get_active_drawable (image);
+ gint radius;
+
+
+ drawable = gimp_image_get_active_drawable (image);
fg_select = GIMP_FOREGROUND_SELECT_TOOL (free_sel);
- options = GIMP_FOREGROUND_SELECT_TOOL_GET_OPTIONS (free_sel);
-
+ options = GIMP_FOREGROUND_SELECT_TOOL_GET_OPTIONS (free_sel);
+/*-----new-----*/
+ GimpTool *tool =GIMP_TOOL(fg_select);
+ GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell);
+ radius = (options->stroke_width / shell->scale_y) / 2;
+/*----end----*/
if (fg_select->idle_id)
- {
+ {printf("===========7\n");
g_source_remove (fg_select->idle_id);
fg_select->idle_id = 0;
}
if (! drawable)
- return;
-
+ {printf("===========return\n");
+ return;
+ }
scan_convert = gimp_scan_convert_new ();
gimp_free_select_tool_get_points (free_sel,
@@ -664,10 +767,25 @@ gimp_foreground_select_tool_select (GimpFreeSelectTool *free_sel,
gimp_drawable_get_tiles (GIMP_DRAWABLE (mask)),
0, 0, 128);
gimp_scan_convert_free (scan_convert);
-
- if (fg_select->strokes)
- {
- GList *list;
+ /*==new===*/
+ if(fg_select->strokes)
+ {
+ printf("GDK_SHIFT_MASK=%d",GDK_SHIFT_MASK);
+ /*
+ fg_select->drbsignal = gimp_foreground_select_tool_modifier_key(tool,//(åº?该æ??ä¹?å??ï¼?)
+ GDK_SHIFT_MASK,
+ TRUE,
+ GDK_SHIFT_MASK,
+ display
+ );*/
+ fg_select->drbsignal = mark_drb;
+ printf("===========fg_select->drbsignal=%d\n",fg_select->drbsignal);
+ }
+ /*-----------end------------*/
+ if (fg_select->strokes && (!fg_select->drbsignal))
+
+ {printf("===========8\n");
+ GList *list;
gimp_set_busy (image->gimp);
@@ -676,20 +794,43 @@ gimp_foreground_select_tool_select (GimpFreeSelectTool *free_sel,
gimp_foreground_select_tool_stroke (mask, list->data);
if (fg_select->state)
- gimp_drawable_foreground_extract_siox (GIMP_DRAWABLE (mask),
+ {gimp_drawable_foreground_extract_siox (GIMP_DRAWABLE (mask),
fg_select->state,
fg_select->refinement,
options->smoothness,
options->sensitivity,
! options->contiguous,
GIMP_PROGRESS (display));
-
+ printf("===========tool_select_extract_siox\n");
+ }
fg_select->refinement = SIOX_REFINEMENT_NO_CHANGE;
gimp_unset_busy (image->gimp);
- }
- else
- {
+ }
+ /*-----new-------*/
+ else if (fg_select->drbsignal)
+
+
+ { printf("===========9\n");
+ gimp_set_busy (image->gimp);
+
+ fg_select->drbsignal = gimp_forground_select_tool_drbsignal(fg_select->drbsignal);
+ gimp_drawable_foreground_extract_siox_drb(GIMP_DRAWABLE (mask),
+ fg_select->state,
+ options->refinement,
+ options->threshold,
+ radius,
+ GIMP_PROGRESS (display));
+
+
+ options->refinement = SIOX_DRB_NO_CHANGE ;
+
+ gimp_unset_busy (image->gimp);
+ }
+ /*------end-------*/
+
+ else
+ {printf("===========10\n");
gint x1, y1;
gint x2, y2;
@@ -704,17 +845,25 @@ gimp_foreground_select_tool_select (GimpFreeSelectTool *free_sel,
gimp_drawable_foreground_extract_siox_init (drawable,
x1, y1, x2 - x1, y2 - y1);
}
+
+
gimp_foreground_select_tool_set_mask (fg_select, display, mask);
g_object_unref (mask);
}
+/*----new */
+static gboolean gimp_forground_select_tool_drbsignal(gboolean drbsignal)
+{
+ return drbsignal = TRUE;
+}
+/*----new end*/
static void
gimp_foreground_select_tool_set_mask (GimpForegroundSelectTool *fg_select,
GimpDisplay *display,
GimpChannel *mask)
-{
+{printf("===========tool_set_mask\n");
GimpTool *tool = GIMP_TOOL (fg_select);
GimpForegroundSelectOptions *options;
@@ -758,7 +907,7 @@ gimp_foreground_select_tool_set_mask (GimpForegroundSelectTool *fg_select,
static void
gimp_foreground_select_tool_apply (GimpForegroundSelectTool *fg_select,
GimpDisplay *display)
-{
+{printf("===========select_tool_apply\n");
GimpTool *tool = GIMP_TOOL (fg_select);
GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool);
@@ -780,7 +929,7 @@ gimp_foreground_select_tool_apply (GimpForegroundSelectTool *fg_select,
static void
gimp_foreground_select_tool_stroke (GimpChannel *mask,
FgSelectStroke *stroke)
-{
+{printf("===========select_tool_stroke\n");
GimpScanConvert *scan_convert = gimp_scan_convert_new ();
if (stroke->num_points == 1)
@@ -815,7 +964,7 @@ static void
gimp_foreground_select_tool_push_stroke (GimpForegroundSelectTool *fg_select,
GimpDisplay *display,
GimpForegroundSelectOptions *options)
-{
+{printf("===========select_tool_push_stroke\n");
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell);
FgSelectStroke *stroke;
@@ -854,7 +1003,7 @@ static void
gimp_foreground_select_options_notify (GimpForegroundSelectOptions *options,
GParamSpec *pspec,
GimpForegroundSelectTool *fg_select)
-{
+{printf("===========select_options_notify\n");
SioxRefinementType refinement = 0;
if (! fg_select->mask)
@@ -872,6 +1021,10 @@ gimp_foreground_select_options_notify (GimpForegroundSelectOptions *options,
{
refinement = SIOX_REFINEMENT_CHANGE_SENSITIVITY;
}
+ else if (strcmp (pspec->name, "threshold"))//(new)
+ {
+ refinement = SIOX_REFINEMENT_CHANGE_THRESHOLD;
+ }
if (refinement)
{
@@ -896,3 +1049,4 @@ gimp_foreground_select_options_notify (GimpForegroundSelectOptions *options,
options->mask_color);
}
}
+
diff --git a/app/tools/gimpforegroundselecttool.h b/app/tools/gimpforegroundselecttool.h
index 5c24719..1fd845d 100644
--- a/app/tools/gimpforegroundselecttool.h
+++ b/app/tools/gimpforegroundselecttool.h
@@ -43,6 +43,7 @@ struct _GimpForegroundSelectTool
guint idle_id;
GArray *stroke;
GList *strokes;
+ gboolean drbsignal;//(new)
GimpChannel *mask;
SioxState *state;
SioxRefinementType refinement;
@@ -56,8 +57,14 @@ struct _GimpForegroundSelectToolClass
void gimp_foreground_select_tool_register (GimpToolRegisterCallback callback,
gpointer data);
+
+/*static void //(new)
+gimp_foreground_select_siox_drb (GimpTool *tool,//(new)
+ GimpDisplay *display); */
GType gimp_foreground_select_tool_get_type (void) G_GNUC_CONST;
+static gboolean gimp_forground_select_tool_drbsignal(gboolean drbsignal); //
#endif /* __GIMP_FOREGROUND_SELECT_TOOL_H__ */
+
diff --git a/libgimpwidgets/gimppropwidgets.c b/libgimpwidgets/gimppropwidgets.c
index ed6fef3..a0d80ff 100644
--- a/libgimpwidgets/gimppropwidgets.c
+++ b/libgimpwidgets/gimppropwidgets.c
@@ -853,6 +853,7 @@ gimp_prop_boolean_radio_frame_new (GObject *config,
if (! param_spec)
return NULL;
+
g_object_get (config,
property_name, &value,
NULL);
@@ -877,6 +878,59 @@ gimp_prop_boolean_radio_frame_new (GObject *config,
return frame;
}
+/**
+ *gimp_prop_boolean_radio_frame_drb_new:
+ * @config: Object to which property is attached.
+ * @property_name: Name of boolean property controlled by the radio buttons.
+ * @title: Label for the frame.
+ * @true_text: Label for the button corresponding to %TRUE.
+ * @false_text: Label for the button corresponding to %FALSE.
+**/
+ GtkWidget * //new
+gimp_prop_boolean_radio_frame_drb_new (GObject *config,//new
+ const gchar *property_name,//new
+ const gchar *title,//new
+ const gchar *true_text,//new
+ const gchar *false_text)//new
+{ //new
+ GParamSpec *param_spec; //new
+ GtkWidget *frame_drb; //new
+ GtkWidget *button; //new
+ gboolean value; //new
+
+ g_return_val_if_fail (G_IS_OBJECT (config), NULL); //new
+ g_return_val_if_fail (property_name != NULL, NULL); //new
+
+ param_spec = check_param_spec_w (config, property_name,//new
+ G_TYPE_PARAM_BOOLEAN, G_STRFUNC);//new
+ if (! param_spec) //new
+ return NULL; //new
+
+ g_object_get (config, //new
+ property_name, &value, //new
+ NULL); //new
+
+ frame_drb = //new
+ gimp_int_radio_group_new (TRUE, title,//new(é??è¦?ä¿®æ?¹)
+ G_CALLBACK (gimp_prop_radio_button_callback),//new
+ config, value, //new
+
+ false_text, FALSE, &button,//new
+ true_text, TRUE, NULL, //new
+
+ NULL); //new
+
+ set_radio_spec (G_OBJECT (button), param_spec); //new
+
+ connect_notify (config, property_name, //new
+ G_CALLBACK (gimp_prop_radio_button_notify), //new
+ button); //new
+
+ g_object_set_data (G_OBJECT (frame_drb), "radio-button", button);//new
+
+ return frame_drb; //new
+} //new
+
/**
* gimp_prop_enum_stock_box_new:
@@ -3836,3 +3890,4 @@ connect_notify (GObject *config,
g_free (notify_name);
}
+
diff --git a/libgimpwidgets/gimppropwidgets.h b/libgimpwidgets/gimppropwidgets.h
index 6a55aba..4956bd4 100644
--- a/libgimpwidgets/gimppropwidgets.h
+++ b/libgimpwidgets/gimppropwidgets.h
@@ -39,7 +39,11 @@ GtkWidget * gimp_prop_boolean_radio_frame_new (GObject *config,
const gchar *title,
const gchar *true_text,
const gchar *false_text);
-
+GtkWidget * gimp_prop_boolean_radio_frame_drb_new (GObject *config,//new
+ const gchar *property_name,//new
+ const gchar *title,//new
+ const gchar *true_text,//new
+ const gchar *false_text);//new
GtkWidget * gimp_prop_expander_new (GObject *config,
const gchar *property_name,
const gchar *label);
@@ -217,3 +221,4 @@ GtkWidget * gimp_prop_stock_image_new (GObject *config,
G_END_DECLS
#endif /* __GIMP_PROP_WIDGETS_H__ */
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]