Commit cd47aac4 authored by Michael Natterer's avatar Michael Natterer 😴

app: remove GimpThresholdConfig

The new more general GimpImageMapTool code handles this case
completely automatically now.
parent 8c09210d
......@@ -37,8 +37,6 @@ libappoperations_generic_a_sources = \
gimphuesaturationconfig.h \
gimplevelsconfig.c \
gimplevelsconfig.h \
gimpthresholdconfig.c \
gimpthresholdconfig.h \
\
gimpoperationblend.c \
gimpoperationblend.h \
......
......@@ -61,7 +61,6 @@
#include "gimpcurvesconfig.h"
#include "gimphuesaturationconfig.h"
#include "gimplevelsconfig.h"
#include "gimpthresholdconfig.h"
#include "gimpoperationpointlayermode.h"
#include "gimpoperationnormalmode.h"
......@@ -168,6 +167,4 @@ gimp_operations_init (void)
GIMP_TYPE_HUE_SATURATION_CONFIG);
gimp_gegl_config_register ("gimp:levels",
GIMP_TYPE_LEVELS_CONFIG);
gimp_gegl_config_register ("gimp:threshold",
GIMP_TYPE_THRESHOLD_CONFIG);
}
......@@ -24,11 +24,31 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gegl.h>
#include "libgimpconfig/gimpconfig.h"
#include "operations-types.h"
#include "gimpoperationthreshold.h"
#include "gimpthresholdconfig.h"
#include "gimp-intl.h"
enum
{
PROP_0,
PROP_LOW,
PROP_HIGH
};
static void gimp_operation_threshold_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_operation_threshold_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static gboolean gimp_operation_threshold_process (GeglOperation *operation,
void *in_buf,
......@@ -51,8 +71,10 @@ gimp_operation_threshold_class_init (GimpOperationThresholdClass *klass)
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
object_class->set_property = gimp_operation_point_filter_set_property;
object_class->get_property = gimp_operation_point_filter_get_property;
object_class->set_property = gimp_operation_threshold_set_property;
object_class->get_property = gimp_operation_threshold_get_property;
point_class->process = gimp_operation_threshold_process;
gegl_operation_class_set_keys (operation_class,
"name", "gimp:threshold",
......@@ -60,16 +82,19 @@ gimp_operation_threshold_class_init (GimpOperationThresholdClass *klass)
"description", "GIMP Threshold operation",
NULL);
point_class->process = gimp_operation_threshold_process;
g_object_class_install_property (object_class,
GIMP_OPERATION_POINT_FILTER_PROP_CONFIG,
g_param_spec_object ("config",
"Config",
"The config object",
GIMP_TYPE_THRESHOLD_CONFIG,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_LOW,
g_param_spec_double ("low",
_("Low threshold"),
NULL,
0.0, 1.0, 0.5,
GIMP_CONFIG_PARAM_FLAGS));
g_object_class_install_property (object_class, PROP_HIGH,
g_param_spec_double ("high",
_("High threshold"),
NULL,
0.0, 1.0, 1.0,
GIMP_CONFIG_PARAM_FLAGS));
}
static void
......@@ -77,7 +102,55 @@ gimp_operation_threshold_init (GimpOperationThreshold *self)
{
}
static gboolean
static void
gimp_operation_threshold_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpOperationThreshold *self = GIMP_OPERATION_THRESHOLD (object);
switch (property_id)
{
case PROP_LOW:
g_value_set_double (value, self->low);
break;
case PROP_HIGH:
g_value_set_double (value, self->high);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_operation_threshold_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpOperationThreshold *self = GIMP_OPERATION_THRESHOLD (object);
switch (property_id)
{
case PROP_LOW:
self->low = g_value_get_double (value);
break;
case PROP_HIGH:
self->high = g_value_get_double (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static gboolean
gimp_operation_threshold_process (GeglOperation *operation,
void *in_buf,
void *out_buf,
......@@ -85,13 +158,9 @@ gimp_operation_threshold_process (GeglOperation *operation,
const GeglRectangle *roi,
gint level)
{
GimpOperationPointFilter *point = GIMP_OPERATION_POINT_FILTER (operation);
GimpThresholdConfig *config = GIMP_THRESHOLD_CONFIG (point->config);
gfloat *src = in_buf;
gfloat *dest = out_buf;
if (! config)
return FALSE;
GimpOperationThreshold *threshold = GIMP_OPERATION_THRESHOLD (operation);
gfloat *src = in_buf;
gfloat *dest = out_buf;
while (samples--)
{
......@@ -100,7 +169,7 @@ gimp_operation_threshold_process (GeglOperation *operation,
value = MAX (src[RED], src[GREEN]);
value = MAX (value, src[BLUE]);
value = (value >= config->low && value <= config->high) ? 1.0 : 0.0;
value = (value >= threshold->low && value <= threshold->high) ? 1.0 : 0.0;
dest[RED] = value;
dest[GREEN] = value;
......
......@@ -39,6 +39,9 @@ typedef struct _GimpOperationThresholdClass GimpOperationThresholdClass;
struct _GimpOperationThreshold
{
GimpOperationPointFilter parent_instance;
gdouble low;
gdouble high;
};
struct _GimpOperationThresholdClass
......
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpthresholdconfig.c
* Copyright (C) 2007 Michael Natterer <mitch@gimp.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gegl.h>
#include "libgimpconfig/gimpconfig.h"
#include "operations-types.h"
#include "gimpthresholdconfig.h"
#include "gimp-intl.h"
enum
{
PROP_0,
PROP_LOW,
PROP_HIGH
};
static void gimp_threshold_config_iface_init (GimpConfigInterface *iface);
static void gimp_threshold_config_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_threshold_config_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static gboolean gimp_threshold_config_equal (GimpConfig *a,
GimpConfig *b);
G_DEFINE_TYPE_WITH_CODE (GimpThresholdConfig, gimp_threshold_config,
GIMP_TYPE_SETTINGS,
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG,
gimp_threshold_config_iface_init))
#define parent_class gimp_threshold_config_parent_class
static void
gimp_threshold_config_class_init (GimpThresholdConfigClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpViewableClass *viewable_class = GIMP_VIEWABLE_CLASS (klass);
object_class->set_property = gimp_threshold_config_set_property;
object_class->get_property = gimp_threshold_config_get_property;
viewable_class->default_icon_name = "gimp-tool-threshold";
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_LOW,
"low",
_("Low threshold"),
0.0, 1.0, 0.5, 0);
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_HIGH,
"high",
_("High threshold"),
0.0, 1.0, 1.0, 0);
}
static void
gimp_threshold_config_iface_init (GimpConfigInterface *iface)
{
iface->equal = gimp_threshold_config_equal;
}
static void
gimp_threshold_config_init (GimpThresholdConfig *self)
{
}
static void
gimp_threshold_config_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpThresholdConfig *self = GIMP_THRESHOLD_CONFIG (object);
switch (property_id)
{
case PROP_LOW:
g_value_set_double (value, self->low);
break;
case PROP_HIGH:
g_value_set_double (value, self->high);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_threshold_config_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpThresholdConfig *self = GIMP_THRESHOLD_CONFIG (object);
switch (property_id)
{
case PROP_LOW:
self->low = g_value_get_double (value);
break;
case PROP_HIGH:
self->high = g_value_get_double (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static gboolean
gimp_threshold_config_equal (GimpConfig *a,
GimpConfig *b)
{
GimpThresholdConfig *config_a = GIMP_THRESHOLD_CONFIG (a);
GimpThresholdConfig *config_b = GIMP_THRESHOLD_CONFIG (b);
if (config_a->low != config_b->low ||
config_a->high != config_b->high)
{
return FALSE;
}
return TRUE;
}
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpthresholdconfig.h
* Copyright (C) 2007 Michael Natterer <mitch@gimp.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_THRESHOLD_CONFIG_H__
#define __GIMP_THRESHOLD_CONFIG_H__
#include "core/gimpsettings.h"
#define GIMP_TYPE_THRESHOLD_CONFIG (gimp_threshold_config_get_type ())
#define GIMP_THRESHOLD_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_THRESHOLD_CONFIG, GimpThresholdConfig))
#define GIMP_THRESHOLD_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_THRESHOLD_CONFIG, GimpThresholdConfigClass))
#define GIMP_IS_THRESHOLD_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_THRESHOLD_CONFIG))
#define GIMP_IS_THRESHOLD_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_THRESHOLD_CONFIG))
#define GIMP_THRESHOLD_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_THRESHOLD_CONFIG, GimpThresholdConfigClass))
typedef struct _GimpThresholdConfigClass GimpThresholdConfigClass;
struct _GimpThresholdConfig
{
GimpSettings parent_instance;
gdouble low;
gdouble high;
};
struct _GimpThresholdConfigClass
{
GimpSettingsClass parent_class;
};
GType gimp_threshold_config_get_type (void) G_GNUC_CONST;
#endif /* __GIMP_THRESHOLD_CONFIG_H__ */
......@@ -43,7 +43,6 @@
#include "operations/gimpcurvesconfig.h"
#include "operations/gimphuesaturationconfig.h"
#include "operations/gimplevelsconfig.h"
#include "operations/gimpthresholdconfig.h"
#include "plug-in/gimpplugin.h"
#include "plug-in/gimppluginmanager.h"
......@@ -757,16 +756,17 @@ threshold_invoker (GimpProcedure *procedure,
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GObject *config = g_object_new (GIMP_TYPE_THRESHOLD_CONFIG,
"low", low_threshold / 255.0,
"high", high_threshold / 255.0,
NULL);
GeglNode *node =
gegl_node_new_child (NULL,
"operation", "gimp:threshold",
"low", low_threshold / 255.0,
"high", high_threshold / 255.0,
NULL);
gimp_drawable_apply_operation_by_name (drawable, progress,
_("Threshold"),
"gimp:threshold",
config);
g_object_unref (config);
gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Threshold"),
node);
g_object_unref (node);
}
else
success = FALSE;
......
......@@ -43,7 +43,6 @@
#include "operations/gimpcurvesconfig.h"
#include "operations/gimphuesaturationconfig.h"
#include "operations/gimplevelsconfig.h"
#include "operations/gimpthresholdconfig.h"
#include "plug-in/gimpplugin.h"
#include "plug-in/gimppluginmanager.h"
......@@ -693,16 +692,17 @@ drawable_threshold_invoker (GimpProcedure *procedure,
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GObject *config = g_object_new (GIMP_TYPE_THRESHOLD_CONFIG,
"low", low_threshold / 255.0,
"high", high_threshold / 255.0,
NULL);
GeglNode *node =
gegl_node_new_child (NULL,
"operation", "gimp:threshold",
"low", low_threshold / 255.0,
"high", high_threshold / 255.0,
NULL);
gimp_drawable_apply_operation_by_name (drawable, progress,
C_("undo-type", "Threshold"),
"gimp:threshold",
config);
g_object_unref (config);
gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Threshold"),
node);
g_object_unref (node);
}
else
success = FALSE;
......
......@@ -256,8 +256,8 @@ app/operations/gimpoperationcagetransform.c
app/operations/gimpoperationdesaturate.c
app/operations/gimpoperationposterize.c
app/operations/gimpoperationsemiflatten.c
app/operations/gimpoperationthreshold.c
app/operations/gimpoperationthresholdalpha.c
app/operations/gimpthresholdconfig.c
app/gui/gui.c
app/gui/gui-message.c
......
......@@ -697,23 +697,23 @@ HELP
);
%invoke = (
headers => [ qw("operations/gimpthresholdconfig.h") ],
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))
{
GObject *config = g_object_new (GIMP_TYPE_THRESHOLD_CONFIG,
"low", low_threshold / 255.0,
"high", high_threshold / 255.0,
NULL);
GeglNode *node =
gegl_node_new_child (NULL,
"operation", "gimp:threshold",
"low", low_threshold / 255.0,
"high", high_threshold / 255.0,
NULL);
gimp_drawable_apply_operation_by_name (drawable, progress,
_("Threshold"),
"gimp:threshold",
config);
g_object_unref (config);
gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Threshold"),
node);
g_object_unref (node);
}
else
success = FALSE;
......
......@@ -757,23 +757,23 @@ HELP
);
%invoke = (
headers => [ qw("operations/gimpthresholdconfig.h") ],
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))
{
GObject *config = g_object_new (GIMP_TYPE_THRESHOLD_CONFIG,
"low", low_threshold / 255.0,
"high", high_threshold / 255.0,
NULL);
GeglNode *node =
gegl_node_new_child (NULL,
"operation", "gimp:threshold",
"low", low_threshold / 255.0,
"high", high_threshold / 255.0,
NULL);
gimp_drawable_apply_operation_by_name (drawable, progress,
C_("undo-type", "Threshold"),
"gimp:threshold",
config);
g_object_unref (config);
gimp_drawable_apply_operation (drawable, progress,
C_("undo-type", "Threshold"),
node);
g_object_unref (node);
}
else
success = FALSE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment