[gimp] plug-ins, PDB: remove edge-sobel and add a PDB compat procedure



commit e4171c5bff40ccbf3d8a6c5c997b99445b929426
Author: Michael Natterer <mitch gimp org>
Date:   Sat Oct 11 19:41:49 2014 +0200

    plug-ins, PDB: remove edge-sobel and add a PDB compat procedure

 app/pdb/internal-procs.c            |    2 +-
 app/pdb/plug-in-compat-cmds.c       |  102 ++++++++
 plug-ins/common/.gitignore          |    2 -
 plug-ins/common/Makefile.am         |   18 --
 plug-ins/common/edge-sobel.c        |  481 -----------------------------------
 plug-ins/common/gimprc.common       |    1 -
 plug-ins/common/plugin-defs.pl      |    1 -
 po-plug-ins/POTFILES.in             |    1 -
 tools/pdbgen/pdb/plug_in_compat.pdb |   61 +++++
 9 files changed, 164 insertions(+), 505 deletions(-)
---
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index 1639970..bcc4e4f 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
 #include "internal-procs.h"
 
 
-/* 732 procedures registered total */
+/* 733 procedures registered total */
 
 void
 internal_procs_init (GimpPDB *pdb)
diff --git a/app/pdb/plug-in-compat-cmds.c b/app/pdb/plug-in-compat-cmds.c
index ce23c3e..cf16508 100644
--- a/app/pdb/plug-in-compat-cmds.c
+++ b/app/pdb/plug-in-compat-cmds.c
@@ -2272,6 +2272,54 @@ plug_in_shift_invoker (GimpProcedure         *procedure,
 }
 
 static GimpValueArray *
+plug_in_sobel_invoker (GimpProcedure         *procedure,
+                       Gimp                  *gimp,
+                       GimpContext           *context,
+                       GimpProgress          *progress,
+                       const GimpValueArray  *args,
+                       GError               **error)
+{
+  gboolean success = TRUE;
+  GimpDrawable *drawable;
+  gboolean horizontal;
+  gboolean vertical;
+  gboolean keep_sign;
+
+  drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
+  horizontal = g_value_get_boolean (gimp_value_array_index (args, 3));
+  vertical = g_value_get_boolean (gimp_value_array_index (args, 4));
+  keep_sign = g_value_get_boolean (gimp_value_array_index (args, 5));
+
+  if (success)
+    {
+      if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
+                                     GIMP_PDB_ITEM_CONTENT, error) &&
+          gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
+        {
+          GeglNode *node =
+            gegl_node_new_child (NULL,
+                                 "operation",  "gegl:edge-sobel",
+                                 "horizontal", horizontal,
+                                 "vertical",   vertical,
+                                 "keep-sign",  keep_sign,
+                                 NULL);
+
+          node = wrap_in_gamma_cast (node, drawable);
+
+          gimp_drawable_apply_operation (drawable, progress,
+                                         C_("undo-type", "Sobel"),
+                                         node);
+          g_object_unref (node);
+        }
+      else
+        success = FALSE;
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
+static GimpValueArray *
 plug_in_spread_invoker (GimpProcedure         *procedure,
                         Gimp                  *gimp,
                         GimpContext           *context,
@@ -4657,6 +4705,60 @@ register_plug_in_compat_procs (GimpPDB *pdb)
   g_object_unref (procedure);
 
   /*
+   * gimp-plug-in-sobel
+   */
+  procedure = gimp_procedure_new (plug_in_sobel_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "plug-in-sobel");
+  gimp_procedure_set_static_strings (procedure,
+                                     "plug-in-sobel",
+                                     "Specialized direction-dependent edge detection",
+                                     "This plugin calculates the gradient with a sobel operator. The user 
can specify which direction to use. When both directions are used, the result is the RMS of the two 
gradients; if only one direction is used, the result either the absolute value of the gradient, or 127 + 
gradient (if the 'keep sign' switch is on). This way, information about the direction of the gradient is 
preserved. Resulting images are not autoscaled.\"",
+                                     "Compatibility procedure. Please see 'gegl:edge-sobel' for credits.",
+                                     "Compatibility procedure. Please see 'gegl:edge-sobel' for credits.",
+                                     "2014",
+                                     NULL);
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_enum ("run-mode",
+                                                  "run mode",
+                                                  "The run mode",
+                                                  GIMP_TYPE_RUN_MODE,
+                                                  GIMP_RUN_INTERACTIVE,
+                                                  GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_image_id ("image",
+                                                         "image",
+                                                         "Input image (unused)",
+                                                         pdb->gimp, FALSE,
+                                                         GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               gimp_param_spec_drawable_id ("drawable",
+                                                            "drawable",
+                                                            "Input drawable",
+                                                            pdb->gimp, FALSE,
+                                                            GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_boolean ("horizontal",
+                                                     "horizontal",
+                                                     "Sobel in horizontal direction",
+                                                     FALSE,
+                                                     GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_boolean ("vertical",
+                                                     "vertical",
+                                                     "Sobel in vertical direction",
+                                                     FALSE,
+                                                     GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_boolean ("keep-sign",
+                                                     "keep sign",
+                                                     "Keep sign of result (one direction only)",
+                                                     FALSE,
+                                                     GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
    * gimp-plug-in-spread
    */
   procedure = gimp_procedure_new (plug_in_spread_invoker);
diff --git a/plug-ins/common/.gitignore b/plug-ins/common/.gitignore
index 7de8a9b..c2aa878 100644
--- a/plug-ins/common/.gitignore
+++ b/plug-ins/common/.gitignore
@@ -62,8 +62,6 @@
 /edge-dog.exe
 /edge-neon
 /edge-neon.exe
-/edge-sobel
-/edge-sobel.exe
 /emboss
 /emboss.exe
 /engrave
diff --git a/plug-ins/common/Makefile.am b/plug-ins/common/Makefile.am
index 6ff1821..f2602b9 100644
--- a/plug-ins/common/Makefile.am
+++ b/plug-ins/common/Makefile.am
@@ -74,7 +74,6 @@ libexec_PROGRAMS = \
        edge \
        edge-dog \
        edge-neon \
-       edge-sobel \
        emboss \
        engrave \
        $(FILE_AA) \
@@ -698,23 +697,6 @@ edge_neon_LDADD = \
        $(INTLLIBS)             \
        $(edge_neon_RC)
 
-edge_sobel_SOURCES = \
-       edge-sobel.c
-
-edge_sobel_LDADD = \
-       $(libgimpui)            \
-       $(libgimpwidgets)       \
-       $(libgimpmodule)        \
-       $(libgimp)              \
-       $(libgimpmath)          \
-       $(libgimpconfig)        \
-       $(libgimpcolor)         \
-       $(libgimpbase)          \
-       $(GTK_LIBS)             \
-       $(RT_LIBS)              \
-       $(INTLLIBS)             \
-       $(edge_sobel_RC)
-
 emboss_SOURCES = \
        emboss.c
 
diff --git a/plug-ins/common/gimprc.common b/plug-ins/common/gimprc.common
index 421fb1e..f28ae08 100644
--- a/plug-ins/common/gimprc.common
+++ b/plug-ins/common/gimprc.common
@@ -28,7 +28,6 @@ displace_RC = displace.rc.o
 edge_RC = edge.rc.o
 edge_dog_RC = edge-dog.rc.o
 edge_neon_RC = edge-neon.rc.o
-edge_sobel_RC = edge-sobel.rc.o
 emboss_RC = emboss.rc.o
 engrave_RC = engrave.rc.o
 file_aa_RC = file-aa.rc.o
diff --git a/plug-ins/common/plugin-defs.pl b/plug-ins/common/plugin-defs.pl
index 47cf097..e5d9db6 100644
--- a/plug-ins/common/plugin-defs.pl
+++ b/plug-ins/common/plugin-defs.pl
@@ -29,7 +29,6 @@
     'edge' => { ui => 1 },
     'edge-dog' => { ui => 1 },
     'edge-neon' => { ui => 1 },
-    'edge-sobel' => { ui => 1 },
     'emboss' => { ui => 1 },
     'engrave' => { ui => 1 },
     'file-aa' => { ui => 1, gegl => 1, optional => 1, libs => 'AA_LIBS' },
diff --git a/po-plug-ins/POTFILES.in b/po-plug-ins/POTFILES.in
index 93dc7ff..58ce97c 100644
--- a/po-plug-ins/POTFILES.in
+++ b/po-plug-ins/POTFILES.in
@@ -33,7 +33,6 @@ plug-ins/common/displace.c
 plug-ins/common/edge.c
 plug-ins/common/edge-dog.c
 plug-ins/common/edge-neon.c
-plug-ins/common/edge-sobel.c
 plug-ins/common/emboss.c
 plug-ins/common/engrave.c
 plug-ins/common/file-aa.c
diff --git a/tools/pdbgen/pdb/plug_in_compat.pdb b/tools/pdbgen/pdb/plug_in_compat.pdb
index f7f587a..01064fc 100644
--- a/tools/pdbgen/pdb/plug_in_compat.pdb
+++ b/tools/pdbgen/pdb/plug_in_compat.pdb
@@ -2379,6 +2379,66 @@ CODE
     );
 }
 
+sub plug_in_sobel {
+    $blurb = 'Specialized direction-dependent edge detection';
+
+    $help = <<'HELP';
+This plugin calculates the gradient with a sobel operator. The user
+can specify which direction to use. When both directions are used, the
+result is the RMS of the two gradients; if only one direction is used,
+the result either the absolute value of the gradient, or 127 +
+gradient (if the 'keep sign' switch is on). This way, information
+about the direction of the gradient is preserved. Resulting images are
+not autoscaled."
+HELP
+
+    &std_pdb_compat('gegl:edge-sobel');
+    $date = '2014';
+
+    @inargs = (
+       { name => 'run_mode', type => 'enum GimpRunMode', dead => 1,
+         desc => 'The run mode' },
+       { name => 'image', type => 'image', dead => 1,
+         desc => 'Input image (unused)' },
+       { name => 'drawable', type => 'drawable',
+         desc => 'Input drawable' },
+       { name => 'horizontal', type => 'boolean',
+         desc => 'Sobel in horizontal direction' },
+       { name => 'vertical', type => 'boolean',
+         desc => 'Sobel in vertical direction' },
+       { name => 'keep_sign', type => 'boolean',
+         desc => 'Keep sign of result (one direction only)' },
+    );
+
+    %invoke = (
+       code => <<'CODE'
+{
+  if (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
+                                 GIMP_PDB_ITEM_CONTENT, error) &&
+      gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
+    {
+      GeglNode *node =
+        gegl_node_new_child (NULL,
+                             "operation",  "gegl:edge-sobel",
+                             "horizontal", horizontal,
+                             "vertical",   vertical,
+                             "keep-sign",  keep_sign,
+                             NULL);
+
+      node = wrap_in_gamma_cast (node, drawable);
+
+      gimp_drawable_apply_operation (drawable, progress,
+                                     C_("undo-type", "Sobel"),
+                                     node);
+      g_object_unref (node);
+    }
+  else
+    success = FALSE;
+}
+CODE
+    );
+}
+
 sub plug_in_spread {
     $blurb = 'Move pixels around randomly';
 
@@ -2856,6 +2916,7 @@ CODE
             plug_in_noisify
             plug_in_semiflatten
             plug_in_shift
+            plug_in_sobel
             plug_in_spread
             plug_in_threshold_alpha
             plug_in_vinvert


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