[gimp/soc-2009-siox-drb] 7.2.3



commit fc796fd98c50e50fc6defcda0bdee214dfdf7867
Author: Jie Ding <jieding src gnome org>
Date:   Fri Jul 3 00:16:23 2009 +0800

    7.2.3

 app/base/siox.c                            |   30 +++++++++-
 app/base/siox.h                            |    7 ++-
 app/core/gimpdrawable-foreground-extract.c |   23 +++++--
 app/core/gimpdrawable-foreground-extract.h |    8 ++-
 app/tools/gimpforegroundselecttool.c       |   93 ++++++++++++++++------------
 app/tools/gimpforegroundselecttool.h       |    2 +-
 6 files changed, 114 insertions(+), 49 deletions(-)
---
diff --git a/app/base/siox.c b/app/base/siox.c
index 852d1f4..08a1745 100644
--- a/app/base/siox.c
+++ b/app/base/siox.c
@@ -103,6 +103,9 @@ struct _SioxState
   gint          xsbpp;
 };
 
+static SioxState  *drbstate;//
+static TileManager  *drbmask;//
+
 /* A struct that holds the classification result */
 typedef struct
 {
@@ -824,8 +827,14 @@ siox_foreground_extract (SioxState          *state,
                          const gdouble       sensitivity[3],
                          gboolean            multiblob,
                          SioxProgressFunc    progress_callback,
+                         gfloat              sioxdrbthreshold,//(new)
+                         gboolean	     sioxdrboptions,//(new) 
+                         gboolean            drbsignal,//(new)
+                         gint                brush_radius,//(new)
                          gpointer            progress_data)
 {
+if(!drbsignal)
+{
   PixelRegion  srcPR;
   PixelRegion  mapPR;
   gpointer     pr;
@@ -1256,6 +1265,24 @@ siox_foreground_extract (SioxState          *state,
   dilate_mask (mask, x, y, width, height);
 
   siox_progress_update (progress_callback, progress_data, 1.0);
+  drbstate = state;//	
+  drbmask  = mask;//	 
+}
+else
+{
+    gint	 brush_mode;
+    gfloat    threshold = sioxdrbthreshold;
+    gint         x, y;
+    x = drbstate->x;
+    y = drbstate->y;
+
+    brush_mode |= (sioxdrboptions ?
+                    SIOX_DRB_ADD   :
+                    SIOX_DRB_SUBTRACT);
+    drbstate = siox_drb (drbstate,drbmask,x,y,
+                        brush_radius,brush_mode,
+                        threshold);
+}  
 }
 
 
@@ -1278,7 +1305,8 @@ siox_foreground_extract (SioxState          *state,
  * TODO: This is still an experimental method. There are more tests
  * needed to evaluate performance of this!
  */
-void
+//void
+SioxState *
 siox_drb (SioxState   *state,
           TileManager *mask,
           gint         x,
diff --git a/app/base/siox.h b/app/base/siox.h
index 5be96d1..ca05e0f 100644
--- a/app/base/siox.h
+++ b/app/base/siox.h
@@ -69,10 +69,15 @@ void        siox_foreground_extract (SioxState          *state,
                                      const gdouble       sensitivity[3],
                                      gboolean            multiblob,
                                      SioxProgressFunc    progress_callback,
+                                     gfloat              sioxdrbthreshold,//(new)
+                                     gboolean	 	 sioxdrboptions,//(new) 
+                                     gboolean            drbsignal,//(new)
+                                     gint                brush_radius,//(new)
                                      gpointer            progress_data);
 void        siox_done               (SioxState          *state);
 
-void        siox_drb                (SioxState          *state,
+//void
+SioxState * siox_drb                (SioxState          *state,
                                      TileManager        *mask,
                                      gint                x,
                                      gint                y,
diff --git a/app/core/gimpdrawable-foreground-extract.c b/app/core/gimpdrawable-foreground-extract.c
index 82a5532..7bc41a1 100644
--- a/app/core/gimpdrawable-foreground-extract.c
+++ b/app/core/gimpdrawable-foreground-extract.c
@@ -63,11 +63,15 @@ gimp_drawable_foreground_extract (GimpDrawable              *drawable,
 
   if (state)
     {
-      gimp_drawable_foreground_extract_siox (mask, state,
+          gimp_drawable_foreground_extract_siox (mask, state,
                                              SIOX_REFINEMENT_RECALCULATE,
-                                             SIOX_DEFAULT_SMOOTHNESS,
+					     SIOX_DEFAULT_SMOOTHNESS,
+					     SIOX_DEFAULT_THRESHOLD  ,//
+					     SIOX_DRB_RECALCULATE  ,//
                                              sensitivity,
                                              FALSE,
+                                             FALSE,//(new)
+                                             18,//
                                              progress);
 
       gimp_drawable_foreground_extract_siox_done (state);
@@ -118,8 +122,12 @@ gimp_drawable_foreground_extract_siox (GimpDrawable       *mask,
                                        SioxState          *state,
                                        SioxRefinementType  refinement,
                                        gint                smoothness,
+                                       gfloat              sioxdrbthreshold,//(new)				
+                                       gboolean	 	   sioxdrboption,//(new)   
                                        const gdouble       sensitivity[3],
                                        gboolean            multiblob,
+                                       gboolean            drbsignal,//(new)
+                                       gint                brush_radius,//(new)
                                        GimpProgress       *progress)
 {
   gint x1, y1;
@@ -134,7 +142,8 @@ gimp_drawable_foreground_extract_siox (GimpDrawable       *mask,
 
   if (progress)
     gimp_progress_start (progress, _("Foreground Extraction"), FALSE);
-
+  if (progress && (drbsignal))//(new)
+    gimp_progress_start (progress, _("DRB Extraction"), FALSE);
   if (GIMP_IS_CHANNEL (mask))
     {
       gimp_channel_bounds (GIMP_CHANNEL (mask), &x1, &y1, &x2, &y2);
@@ -151,6 +160,10 @@ gimp_drawable_foreground_extract_siox (GimpDrawable       *mask,
                            gimp_drawable_get_tiles (mask), x1, y1, x2, y2,
                            smoothness, sensitivity, multiblob,
                            (SioxProgressFunc) gimp_progress_set_value,
+                           sioxdrbthreshold,//(new)
+                           sioxdrboption,//(new)  
+                           drbsignal,//(new)
+                           brush_radius,//(new)
                            progress);
 
   if (progress)
@@ -166,7 +179,7 @@ gimp_drawable_foreground_extract_siox_done (SioxState *state)
 
   siox_done (state);
 }
-
+/*
 void                                                   //(new)
 gimp_drawable_foreground_extract_siox_drb(GimpDrawable      *mask,
 					  SioxState         *state,
@@ -220,5 +233,5 @@ siox_foreground_drb (SioxState   *state,
 	      drbbrush_mode,  //
 	      drbthreshold);
 	 
- }
+ }*/
  
diff --git a/app/core/gimpdrawable-foreground-extract.h b/app/core/gimpdrawable-foreground-extract.h
index b19e4ac..fdf41b4 100644
--- a/app/core/gimpdrawable-foreground-extract.h
+++ b/app/core/gimpdrawable-foreground-extract.h
@@ -37,11 +37,15 @@ void        gimp_drawable_foreground_extract_siox  (GimpDrawable       *mask,
                                                     SioxState          *state,
                                                     SioxRefinementType  refinemane,
                                                     gint                smoothness,
+                                                    gfloat              sioxdrbthreshold,//(new)	
+                                                    gboolean	 	sioxdrboption,//(new)   
                                                     const gdouble       sensitivity[3],
                                                     gboolean            multiblob,
+                                                    gboolean            drbsignal,//
+                                                    gint                brush_radius,//(new)
                                                     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,
@@ -55,5 +59,5 @@ void siox_foreground_drb (SioxState    *state,//(new)
 			 gint          x,
 			 gint          y,
 			 gint          brushradius,
-			 gfloat        threshold);//(new)
+			 gfloat        threshold);//(new)*/
 #endif  /*  __GIMP_DRAWABLE_FOREGROUND_EXTRACT_H__  */
diff --git a/app/tools/gimpforegroundselecttool.c b/app/tools/gimpforegroundselecttool.c
index ca098fd..e2f67b9 100644
--- a/app/tools/gimpforegroundselecttool.c
+++ b/app/tools/gimpforegroundselecttool.c
@@ -241,6 +241,9 @@ gimp_foreground_select_tool_finalize (GObject *object)
 
   if (fg_select->strokes)
     g_warning ("%s: strokes should be NULL at this point", G_STRLOC);
+  	
+  if (fg_select->drbsignal)//
+    g_warning ("%s: drbsignal should be NULL at this point", G_STRLOC);  
 
   if (fg_select->state)
     g_warning ("%s: state should be NULL at this point", G_STRLOC);
@@ -285,6 +288,8 @@ gimp_foreground_select_tool_control (GimpTool       *tool,
           {
             gimp_drawable_foreground_extract_siox_done (fg_select->state);
             fg_select->state = NULL;
+            fg_select->drbsignal = NULL;//(new)
+	    mark_drb = FALSE;  //(new)
           }
 
         tool->display = NULL;
@@ -325,11 +330,11 @@ gimp_foreground_select_tool_oper_update (GimpTool         *tool,
         case SELECTION_ANCHOR:
           if (fg_select->strokes)
             {
-				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");
-			}
+		if(!fg_select->drbsignal)//(new)
+		status = _("Add more strokes or press Up 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;
@@ -375,12 +380,12 @@ gimp_foreground_select_tool_modifier_key (GimpTool        *tool,
                     "background", ! options->background,
                     NULL);
     }
-  if (key == GDK_SHIFT_MASK)
+ /* if (key == GDK_SHIFT_MASK)
 	{
 	  mark_drb = TRUE;
 	   // gimp_foreground_select_tool_select (free_sel_drb, display_drb);//(alter)
 	  //gimp_foreground_select_tool_select (GIMP_FREE_SELECT_TOOL (tool), display);//(alter)  
-	}
+	}*/
 }
 
 static void
@@ -428,6 +433,10 @@ gimp_foreground_select_tool_key_press (GimpTool    *tool,
     {
       switch (kevent->keyval)
         {
+        case GDK_Up:	//(new)
+	  mark_drb = TRUE;	
+	  return  FALSE;	
+	  
         case GDK_Return:
         case GDK_KP_Enter:
         case GDK_ISO_Enter:
@@ -485,7 +494,7 @@ gimp_foreground_select_tool_button_press (GimpTool            *tool,
 
       gimp_draw_tool_resume (draw_tool);
     }
-  else if (fg_select->drbsignal)
+  else if (fg_select->drbsignal)//
 	{
 		GimpVector2 point = gimp_vector2_new (coords->x, coords->y);
 		printf("----------------------drb brush");
@@ -544,7 +553,7 @@ gimp_foreground_select_tool_button_release (GimpTool              *tool,
 
       gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
     }
-  else if (fg_select->drbsignal)
+  else if (fg_select->drbsignal)//
 	{
 	  GimpForegroundSelectOptions *options;
 
@@ -634,7 +643,7 @@ gimp_foreground_select_tool_draw (GimpDrawTool *draw_tool)
 
   options = GIMP_FOREGROUND_SELECT_TOOL_GET_OPTIONS (tool);
 
-  if (fg_select->stroke)
+  if (fg_select->stroke && (!fg_select->drbsignal))//
     {
       gimp_display_shell_draw_pen (GIMP_DISPLAY_SHELL (draw_tool->display->shell),
                                    (const GimpVector2 *)fg_select->stroke->data,
@@ -645,7 +654,16 @@ gimp_foreground_select_tool_draw (GimpDrawTool *draw_tool)
                                     GIMP_ACTIVE_COLOR_FOREGROUND),
                                    options->stroke_width);
     }
-
+  if (fg_select->drbsignal)	//
+    {
+      gimp_display_shell_draw_pen (GIMP_DISPLAY_SHELL (draw_tool->display->shell),
+                                   (const GimpVector2 *)fg_select->stroke->data,
+                                   fg_select->stroke->len,
+                                   GIMP_CONTEXT (options),
+                                   (options->background ?
+                                    GIMP_ACTIVE_COLOR_BACKGROUND :
+                                    GIMP_ACTIVE_COLOR_BACKGROUND),
+                                   options->stroke_width);
   if (fg_select->mask)
     {
       GimpDisplayShell   *shell = GIMP_DISPLAY_SHELL (draw_tool->display->shell);
@@ -701,11 +719,6 @@ gimp_foreground_select_tool_select (GimpFreeSelectTool *free_sel,
   fg_select = GIMP_FOREGROUND_SELECT_TOOL (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)
     {
       g_source_remove (fg_select->idle_id);
@@ -737,10 +750,10 @@ gimp_foreground_select_tool_select (GimpFreeSelectTool *free_sel,
   gimp_scan_convert_free (scan_convert);
   if (fg_select->strokes)
     {
-	  fg_select->drbsignal = mark_drb;//(should be a function to push)
+	  fg_select->drbsignal = mark_drb;
     }
 	
-  if (fg_select->strokes && (!fg_select->drbsignal))
+  if (fg_select->strokes)
     {
       GList *list;
 
@@ -751,31 +764,24 @@ 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),
-                                               fg_select->state,
-                                               fg_select->refinement,
-                                               options->smoothness,
-                                               options->sensitivity,
-                                               ! options->contiguous,
-                                               GIMP_PROGRESS (display));
+	{
+	  gimp_drawable_foreground_extract_siox (GIMP_DRAWABLE (mask),
+						  fg_select->state,
+						  fg_select->refinement,
+						  options->smoothness,
+				                  options->threshold,//(new)
+						  options->refinement,//					
+						  options->sensitivity,
+						  ! options->contiguous,
+						  fg_select->drbsignal,//
+						  options->stroke_width,//(new)	
+						  GIMP_PROGRESS (display));
 
       fg_select->refinement = SIOX_REFINEMENT_NO_CHANGE;
 
       gimp_unset_busy (image->gimp);
     }
-  else if (fg_select->drbsignal)
-    {
-	  //gtk_widget_set_sensitive (,FALSE);
-	  gimp_set_busy (image->gimp);
-	  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);
-     }
+  
   else
     {
       gint x1, y1;
@@ -823,7 +829,7 @@ gimp_foreground_select_tool_set_mask (GimpForegroundSelectTool *fg_select,
   gimp_display_shell_set_mask (GIMP_DISPLAY_SHELL (display->shell),
                                GIMP_DRAWABLE (mask), options->mask_color);
 
-  if (mask)
+  if (mask && (!fg_select->drbsignal))
     {
       gimp_tool_control_set_tool_cursor        (tool->control,
                                                 GIMP_TOOL_CURSOR_PAINTBRUSH);
@@ -832,6 +838,15 @@ gimp_foreground_select_tool_set_mask (GimpForegroundSelectTool *fg_select,
 
       gimp_tool_control_set_toggled (tool->control, options->background);
     }
+  else if (mask && fg_select->drbsignal)//(new)
+    {
+      gimp_tool_control_set_tool_cursor        (tool->control,
+                                                GIMP_TOOL_CURSOR_PAINTBRUSH);
+      gimp_tool_control_set_toggle_tool_cursor (tool->control,
+                                                GIMP_TOOL_CURSOR_ERASER);
+
+      gimp_tool_control_set_toggled (tool->control, options->background);
+    }	  
   else
     {
       gimp_tool_control_set_tool_cursor        (tool->control,
diff --git a/app/tools/gimpforegroundselecttool.h b/app/tools/gimpforegroundselecttool.h
index 88b8bbb..2ce8b30 100644
--- a/app/tools/gimpforegroundselecttool.h
+++ b/app/tools/gimpforegroundselecttool.h
@@ -43,7 +43,7 @@ struct _GimpForegroundSelectTool
   guint               idle_id;
   GArray             *stroke;
   GList              *strokes;
-  GArray             *drbsignal;//(new)
+  gboolean           *drbsignal;//(new)
   GimpChannel        *mask;
   SioxState          *state;
   SioxRefinementType  refinement;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]