[gimp] plug-ins, pdb: remove the diffraction plug-in and add a PDB compat procedure



commit 9be37aaa91c38ee85517ce25dd6225d69780d32f
Author: Michael Natterer <mitch gimp org>
Date:   Wed Jan 21 22:51:49 2015 +0100

    plug-ins, pdb: remove the diffraction plug-in and add a PDB compat procedure

 app/pdb/internal-procs.c            |    2 +-
 app/pdb/plug-in-compat-cmds.c       |  187 +++++++++
 plug-ins/common/.gitignore          |    2 -
 plug-ins/common/Makefile.am         |   18 -
 plug-ins/common/diffraction.c       |  720 -----------------------------------
 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 |   86 +++++
 9 files changed, 274 insertions(+), 744 deletions(-)
---
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index 1cf8186..830e322 100644
--- a/app/pdb/internal-procs.c
+++ b/app/pdb/internal-procs.c
@@ -28,7 +28,7 @@
 #include "internal-procs.h"
 
 
-/* 749 procedures registered total */
+/* 750 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 34778f5..4d43dc0 100644
--- a/app/pdb/plug-in-compat-cmds.c
+++ b/app/pdb/plug-in-compat-cmds.c
@@ -954,6 +954,85 @@ plug_in_deinterlace_invoker (GimpProcedure         *procedure,
 }
 
 static GimpValueArray *
+plug_in_diffraction_invoker (GimpProcedure         *procedure,
+                             Gimp                  *gimp,
+                             GimpContext           *context,
+                             GimpProgress          *progress,
+                             const GimpValueArray  *args,
+                             GError               **error)
+{
+  gboolean success = TRUE;
+  GimpDrawable *drawable;
+  gdouble lam_r;
+  gdouble lam_g;
+  gdouble lam_b;
+  gdouble contour_r;
+  gdouble contour_g;
+  gdouble contour_b;
+  gdouble edges_r;
+  gdouble edges_g;
+  gdouble edges_b;
+  gdouble brightness;
+  gdouble scattering;
+  gdouble polarization;
+
+  drawable = gimp_value_get_drawable (gimp_value_array_index (args, 2), gimp);
+  lam_r = g_value_get_double (gimp_value_array_index (args, 3));
+  lam_g = g_value_get_double (gimp_value_array_index (args, 4));
+  lam_b = g_value_get_double (gimp_value_array_index (args, 5));
+  contour_r = g_value_get_double (gimp_value_array_index (args, 6));
+  contour_g = g_value_get_double (gimp_value_array_index (args, 7));
+  contour_b = g_value_get_double (gimp_value_array_index (args, 8));
+  edges_r = g_value_get_double (gimp_value_array_index (args, 9));
+  edges_g = g_value_get_double (gimp_value_array_index (args, 10));
+  edges_b = g_value_get_double (gimp_value_array_index (args, 11));
+  brightness = g_value_get_double (gimp_value_array_index (args, 12));
+  scattering = g_value_get_double (gimp_value_array_index (args, 13));
+  polarization = g_value_get_double (gimp_value_array_index (args, 14));
+
+  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;
+          gint      x, y, width, height;
+
+          gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height);
+
+          node = gegl_node_new_child (NULL,
+                                      "operation",       "gegl:diffraction-patterns",
+                                      "red-frequency",   lam_r,
+                                      "green-frequency", lam_g,
+                                      "blue-frequency",  lam_b,
+                                      "red-contours",    contour_r,
+                                      "green-contours",  contour_g,
+                                      "blue-contours",   contour_b,
+                                      "red-sedges",      edges_r,
+                                      "green-sedges",    edges_g,
+                                      "blue-sedges",     edges_b,
+                                      "brightness",      brightness,
+                                      "scattering",      scattering,
+                                      "polarization",    polarization,
+                                      "width",           width,
+                                      "height",          height,
+                                      NULL);
+
+          gimp_drawable_apply_operation (drawable, progress,
+                                         C_("undo-type", "Diffraction Patterns"),
+                                         node);
+          g_object_unref (node);
+        }
+      else
+        success = FALSE;
+    }
+
+  return gimp_procedure_get_return_values (procedure, success,
+                                           error ? *error : NULL);
+}
+
+static GimpValueArray *
 plug_in_engrave_invoker (GimpProcedure         *procedure,
                          Gimp                  *gimp,
                          GimpContext           *context,
@@ -3752,6 +3831,114 @@ register_plug_in_compat_procs (GimpPDB *pdb)
   g_object_unref (procedure);
 
   /*
+   * gimp-plug-in-diffraction
+   */
+  procedure = gimp_procedure_new (plug_in_diffraction_invoker);
+  gimp_object_set_static_name (GIMP_OBJECT (procedure),
+                               "plug-in-diffraction");
+  gimp_procedure_set_static_strings (procedure,
+                                     "plug-in-diffraction",
+                                     "Generate diffraction patterns",
+                                     "Help? What help?",
+                                     "Compatibility procedure. Please see 'gegl:diffraction-patterns' for 
credits.",
+                                     "Compatibility procedure. Please see 'gegl:diffraction-patterns' for 
credits.",
+                                     "2015",
+                                     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_double ("lam-r",
+                                                    "lam r",
+                                                    "Light frequency (red)",
+                                                    0.0, 20.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("lam-g",
+                                                    "lam g",
+                                                    "Light frequency (green)",
+                                                    0.0, 20.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("lam-b",
+                                                    "lam b",
+                                                    "Light frequency (blue)",
+                                                    0.0, 20.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("contour-r",
+                                                    "contour r",
+                                                    "Number of contours (red)",
+                                                    0.0, 10.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("contour-g",
+                                                    "contour g",
+                                                    "Number of contours (green)",
+                                                    0.0, 10.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("contour-b",
+                                                    "contour b",
+                                                    "Number of contours (blue)",
+                                                    0.0, 10.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("edges-r",
+                                                    "edges r",
+                                                    "Number of sharp edges (red)",
+                                                    0.0, 1.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("edges-g",
+                                                    "edges g",
+                                                    "Number of sharp edges (green)",
+                                                    0.0, 1.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("edges-b",
+                                                    "edges b",
+                                                    "Number of sharp edges (blue)",
+                                                    0.0, 1.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("brightness",
+                                                    "brightness",
+                                                    "Brightness and shifting/fattening of contours",
+                                                    0.0, 1.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("scattering",
+                                                    "scattering",
+                                                    "Scattering (Speed vs. quality)",
+                                                    0.0, 100.0, 0.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_procedure_add_argument (procedure,
+                               g_param_spec_double ("polarization",
+                                                    "polarization",
+                                                    "Polarization",
+                                                    -1.0, 1.0, -1.0,
+                                                    GIMP_PARAM_READWRITE));
+  gimp_pdb_register_procedure (pdb, procedure);
+  g_object_unref (procedure);
+
+  /*
    * gimp-plug-in-engrave
    */
   procedure = gimp_procedure_new (plug_in_engrave_invoker);
diff --git a/plug-ins/common/.gitignore b/plug-ins/common/.gitignore
index 771e6ff..9c4ad11 100644
--- a/plug-ins/common/.gitignore
+++ b/plug-ins/common/.gitignore
@@ -50,8 +50,6 @@
 /despeckle.exe
 /destripe
 /destripe.exe
-/diffraction
-/diffraction.exe
 /displace
 /displace.exe
 /edge
diff --git a/plug-ins/common/Makefile.am b/plug-ins/common/Makefile.am
index 70d237c..a2d6e97 100644
--- a/plug-ins/common/Makefile.am
+++ b/plug-ins/common/Makefile.am
@@ -68,7 +68,6 @@ libexec_PROGRAMS = \
        depth-merge \
        despeckle \
        destripe \
-       diffraction \
        displace \
        edge \
        edge-dog \
@@ -587,23 +586,6 @@ destripe_LDADD = \
        $(INTLLIBS)             \
        $(destripe_RC)
 
-diffraction_SOURCES = \
-       diffraction.c
-
-diffraction_LDADD = \
-       $(libgimpui)            \
-       $(libgimpwidgets)       \
-       $(libgimpmodule)        \
-       $(libgimp)              \
-       $(libgimpmath)          \
-       $(libgimpconfig)        \
-       $(libgimpcolor)         \
-       $(libgimpbase)          \
-       $(GTK_LIBS)             \
-       $(RT_LIBS)              \
-       $(INTLLIBS)             \
-       $(diffraction_RC)
-
 displace_SOURCES = \
        displace.c
 
diff --git a/plug-ins/common/gimprc.common b/plug-ins/common/gimprc.common
index 101f3dc..d0d8278 100644
--- a/plug-ins/common/gimprc.common
+++ b/plug-ins/common/gimprc.common
@@ -22,7 +22,6 @@ decompose_RC = decompose.rc.o
 depth_merge_RC = depth-merge.rc.o
 despeckle_RC = despeckle.rc.o
 destripe_RC = destripe.rc.o
-diffraction_RC = diffraction.rc.o
 displace_RC = displace.rc.o
 edge_RC = edge.rc.o
 edge_dog_RC = edge-dog.rc.o
diff --git a/plug-ins/common/plugin-defs.pl b/plug-ins/common/plugin-defs.pl
index 1873baf..6a480f6 100644
--- a/plug-ins/common/plugin-defs.pl
+++ b/plug-ins/common/plugin-defs.pl
@@ -23,7 +23,6 @@
     'depth-merge' => { ui => 1 },
     'despeckle' => { ui => 1 },
     'destripe' => { ui => 1 },
-    'diffraction' => { ui => 1 },
     'displace' => { ui => 1 },
     'edge' => { ui => 1 },
     'edge-dog' => { ui => 1 },
diff --git a/po-plug-ins/POTFILES.in b/po-plug-ins/POTFILES.in
index df083d8..013d64b 100644
--- a/po-plug-ins/POTFILES.in
+++ b/po-plug-ins/POTFILES.in
@@ -27,7 +27,6 @@ plug-ins/common/decompose.c
 plug-ins/common/depth-merge.c
 plug-ins/common/despeckle.c
 plug-ins/common/destripe.c
-plug-ins/common/diffraction.c
 plug-ins/common/displace.c
 plug-ins/common/edge.c
 plug-ins/common/edge-dog.c
diff --git a/tools/pdbgen/pdb/plug_in_compat.pdb b/tools/pdbgen/pdb/plug_in_compat.pdb
index 4027712..d8531c9 100644
--- a/tools/pdbgen/pdb/plug_in_compat.pdb
+++ b/tools/pdbgen/pdb/plug_in_compat.pdb
@@ -857,6 +857,91 @@ CODE
     );
 }
 
+sub plug_in_diffraction {
+    $blurb = 'Generate diffraction patterns';
+
+    $help = <<'HELP';
+Help?  What help?
+HELP
+
+    &std_pdb_compat('gegl:diffraction-patterns');
+    $date = '2015';
+
+    @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 => 'lam_r', type => '0.0 <= float <= 20.0',
+         desc => 'Light frequency (red)' },
+       { name => 'lam_g', type => '0.0 <= float <= 20.0',
+         desc => 'Light frequency (green)' },
+       { name => 'lam_b', type => '0.0 <= float <= 20.0',
+         desc => 'Light frequency (blue)' },
+       { name => 'contour_r', type => '0.0 <= float <= 10.0',
+         desc => 'Number of contours (red)' },
+       { name => 'contour_g', type => '0.0 <= float <= 10.0',
+         desc => 'Number of contours (green)' },
+       { name => 'contour_b', type => '0.0 <= float <= 10.0',
+         desc => 'Number of contours (blue)' },
+       { name => 'edges_r', type => '0.0 <= float <= 1.0',
+         desc => 'Number of sharp edges (red)' },
+       { name => 'edges_g', type => '0.0 <= float <= 1.0',
+         desc => 'Number of sharp edges (green)' },
+       { name => 'edges_b', type => '0.0 <= float <= 1.0',
+         desc => 'Number of sharp edges (blue)' },
+        { name => 'brightness', type => '0.0 <= float <= 1.0',
+         desc => 'Brightness and shifting/fattening of contours' },
+       { name => 'scattering', type => '0.0 <= float <= 100.0',
+         desc => 'Scattering (Speed vs. quality)' },
+       { name => 'polarization', type => '-1.0 <= float <= 1.0',
+         desc => 'Polarization' }
+    );
+
+    %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;
+      gint      x, y, width, height;
+
+      gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height);
+
+      node = gegl_node_new_child (NULL,
+                                  "operation",       "gegl:diffraction-patterns",
+                                  "red-frequency",   lam_r,
+                                  "green-frequency", lam_g,
+                                  "blue-frequency",  lam_b,
+                                  "red-contours",    contour_r,
+                                  "green-contours",  contour_g,
+                                  "blue-contours",   contour_b,
+                                  "red-sedges",      edges_r,
+                                  "green-sedges",    edges_g,
+                                  "blue-sedges",     edges_b,
+                                  "brightness",      brightness,
+                                  "scattering",      scattering,
+                                  "polarization",    polarization,
+                                  "width",           width,
+                                  "height",          height,
+                                  NULL);
+
+      gimp_drawable_apply_operation (drawable, progress,
+                                     C_("undo-type", "Diffraction Patterns"),
+                                     node);
+      g_object_unref (node);
+    }
+  else
+    success = FALSE;
+}
+CODE
+    );
+}
+
 sub plug_in_engrave {
     $blurb = 'Simulate an antique engraving';
 
@@ -3435,6 +3520,7 @@ CODE
             plug_in_convmatrix
             plug_in_cubism
             plug_in_deinterlace
+            plug_in_diffraction
             plug_in_engrave
             plug_in_exchange
             plug_in_flarefx


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