1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* 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 2 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, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
1999-06-07 10:21:31 +08:00
|
|
|
#include "config.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include "appenv.h"
|
|
|
|
#include "actionarea.h"
|
|
|
|
#include "buildmenu.h"
|
|
|
|
#include "drawable.h"
|
|
|
|
#include "general.h"
|
|
|
|
#include "gdisplay.h"
|
|
|
|
#include "histogram_tool.h"
|
|
|
|
#include "image_map.h"
|
|
|
|
#include "interface.h"
|
|
|
|
|
1998-12-16 08:37:09 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#define TEXT_WIDTH 45
|
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
/* the histogram structures */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
typedef struct _HistogramTool HistogramTool;
|
1997-11-25 06:05:25 +08:00
|
|
|
struct _HistogramTool
|
|
|
|
{
|
|
|
|
int x, y; /* coords for last mouse click */
|
|
|
|
};
|
|
|
|
|
1999-04-13 01:55:06 +08:00
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
/* the histogram tool options */
|
1999-06-22 06:12:07 +08:00
|
|
|
static ToolOptions * histogram_tool_options = NULL;
|
1999-04-09 06:25:54 +08:00
|
|
|
|
|
|
|
/* the histogram tool dialog */
|
1999-06-22 06:12:07 +08:00
|
|
|
static HistogramToolDialog * histogram_tool_dialog = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-04-13 01:55:06 +08:00
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
/* histogram_tool action functions */
|
1997-11-25 06:05:25 +08:00
|
|
|
static void histogram_tool_button_press (Tool *, GdkEventButton *, gpointer);
|
|
|
|
static void histogram_tool_button_release (Tool *, GdkEventButton *, gpointer);
|
|
|
|
static void histogram_tool_motion (Tool *, GdkEventMotion *, gpointer);
|
|
|
|
static void histogram_tool_cursor_update (Tool *, GdkEventMotion *, gpointer);
|
1999-06-22 06:12:07 +08:00
|
|
|
static void histogram_tool_control (Tool *, ToolAction, gpointer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-06-22 06:12:07 +08:00
|
|
|
static HistogramToolDialog * histogram_tool_new_dialog (void);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-06-22 06:12:07 +08:00
|
|
|
static void histogram_tool_close_callback (GtkWidget *, gpointer);
|
|
|
|
static gint histogram_tool_delete_callback (GtkWidget *, GdkEvent *, gpointer);
|
|
|
|
static void histogram_tool_value_callback (GtkWidget *, gpointer);
|
|
|
|
static void histogram_tool_red_callback (GtkWidget *, gpointer);
|
|
|
|
static void histogram_tool_green_callback (GtkWidget *, gpointer);
|
|
|
|
static void histogram_tool_blue_callback (GtkWidget *, gpointer);
|
|
|
|
|
|
|
|
static void histogram_tool_dialog_update (HistogramToolDialog *, int, int);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* histogram_tool machinery */
|
|
|
|
|
moved a bunch of PDB stuff here
* app/color_cmds.c: moved a bunch of PDB stuff here
* app/color_balance.[ch]: removed PDB proc, exported TransferMode
enum, ColorBalanceDialog, color_balance_create_lookup_tables, and
color_balance
* app/curves.[ch]: removed PDB procs, exported SMOOTH and GFREE
#defines, CurvesDialog, curves_lut_func and curves_calculate_curve
* app/desaturate.[ch]: removed PDB proc, exported desaturate
* app/equalize.[ch]: removed PDB proc, exported equalize
* app/histogram_tool.[ch]: removed PDB proc, exported HISTOGRAM_WIDTH
and HISTOGRAM_HEIGHT #defines, HistogramToolDialog,
histogram_tool_histogram_range
* app/hue_saturation.[ch]: removed PDB proc, exported HueRange enum,
HueSaturationDialog, hue_saturation_calculate_transfers,
hue_saturation
* app/invert.[ch]: remove PDB proc, export invert
* app/threshold.[ch]: remove PDB proc, export ThresholdDialog and
threshold_2
* internal_procs.c: changes for pdbgen
* app/gimprc.c: removed leftover declaration
* app/image_map.h: add #include "gimpdrawableF.h"
* app/lut_funcs.h: add ALPHA_LUT to ChannelLutType
-Yosh
1999-04-21 13:39:57 +08:00
|
|
|
void
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
histogram_tool_histogram_range (HistogramWidget *w,
|
|
|
|
int start,
|
1997-11-25 06:05:25 +08:00
|
|
|
int end,
|
|
|
|
void *user_data)
|
|
|
|
{
|
|
|
|
HistogramToolDialog *htd;
|
|
|
|
double pixels;
|
|
|
|
double count;
|
|
|
|
|
|
|
|
htd = (HistogramToolDialog *) user_data;
|
|
|
|
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
if (htd == NULL || htd->hist == NULL
|
|
|
|
|| gimp_histogram_nchannels(htd->hist) <= 0)
|
|
|
|
return;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
pixels = gimp_histogram_get_count(htd->hist, 0, 255);
|
|
|
|
count = gimp_histogram_get_count(htd->hist, start, end);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
htd->mean = gimp_histogram_get_mean(htd->hist, htd->channel, start, end);
|
|
|
|
htd->std_dev = gimp_histogram_get_std_dev(htd->hist, htd->channel,
|
|
|
|
start, end);
|
|
|
|
htd->median = gimp_histogram_get_median(htd->hist, htd->channel, start, end);
|
1997-11-25 06:05:25 +08:00
|
|
|
htd->pixels = pixels;
|
|
|
|
htd->count = count;
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
htd->percentile = count / pixels;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (htd->shell)
|
|
|
|
histogram_tool_dialog_update (htd, start, end);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
histogram_tool_dialog_update (HistogramToolDialog *htd,
|
|
|
|
int start,
|
|
|
|
int end)
|
|
|
|
{
|
|
|
|
char text[12];
|
|
|
|
|
|
|
|
/* mean */
|
|
|
|
sprintf (text, "%3.1f", htd->mean);
|
1999-01-11 05:54:02 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (htd->info_labels[0]), text);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* std dev */
|
|
|
|
sprintf (text, "%3.1f", htd->std_dev);
|
1999-01-11 05:54:02 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (htd->info_labels[1]), text);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* median */
|
|
|
|
sprintf (text, "%3.1f", htd->median);
|
1999-01-11 05:54:02 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (htd->info_labels[2]), text);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* pixels */
|
|
|
|
sprintf (text, "%8.1f", htd->pixels);
|
1999-01-11 05:54:02 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (htd->info_labels[3]), text);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* intensity */
|
|
|
|
if (start == end)
|
|
|
|
sprintf (text, "%d", start);
|
|
|
|
else
|
|
|
|
sprintf (text, "%d..%d", start, end);
|
1999-01-11 05:54:02 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (htd->info_labels[4]), text);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* count */
|
|
|
|
sprintf (text, "%8.1f", htd->count);
|
1999-01-11 05:54:02 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (htd->info_labels[5]), text);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* percentile */
|
|
|
|
sprintf (text, "%2.2f", htd->percentile * 100);
|
1999-01-11 05:54:02 +08:00
|
|
|
gtk_label_set_text (GTK_LABEL (htd->info_labels[6]), text);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* histogram_tool action functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
histogram_tool_button_press (Tool *tool,
|
|
|
|
GdkEventButton *bevent,
|
|
|
|
gpointer gdisp_ptr)
|
|
|
|
{
|
1998-04-02 12:51:44 +08:00
|
|
|
GDisplay *gdisp;
|
|
|
|
|
|
|
|
gdisp = gdisp_ptr;
|
|
|
|
tool->drawable = gimage_active_drawable (gdisp->gimage);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
histogram_tool_button_release (Tool *tool,
|
|
|
|
GdkEventButton *bevent,
|
|
|
|
gpointer gdisp_ptr)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
histogram_tool_motion (Tool *tool,
|
|
|
|
GdkEventMotion *mevent,
|
|
|
|
gpointer gdisp_ptr)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
histogram_tool_cursor_update (Tool *tool,
|
|
|
|
GdkEventMotion *mevent,
|
|
|
|
gpointer gdisp_ptr)
|
|
|
|
{
|
|
|
|
GDisplay *gdisp;
|
|
|
|
|
|
|
|
gdisp = (GDisplay *) gdisp_ptr;
|
|
|
|
gdisplay_install_tool_cursor (gdisp, GDK_TOP_LEFT_ARROW);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-06-22 06:12:07 +08:00
|
|
|
histogram_tool_control (Tool *tool,
|
|
|
|
ToolAction action,
|
|
|
|
gpointer gdisp_ptr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
switch (action)
|
|
|
|
{
|
1999-06-22 06:12:07 +08:00
|
|
|
case PAUSE:
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
1999-06-22 06:12:07 +08:00
|
|
|
|
|
|
|
case RESUME:
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
1999-06-22 06:12:07 +08:00
|
|
|
|
|
|
|
case HALT:
|
1997-11-25 06:05:25 +08:00
|
|
|
if (histogram_tool_dialog)
|
1998-04-14 05:59:28 +08:00
|
|
|
histogram_tool_close_callback (NULL, (gpointer) histogram_tool_dialog);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
1999-06-22 06:12:07 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Tool *
|
|
|
|
tools_new_histogram_tool ()
|
|
|
|
{
|
|
|
|
Tool * tool;
|
|
|
|
HistogramTool * private;
|
|
|
|
|
|
|
|
/* The tool options */
|
1999-04-13 01:55:06 +08:00
|
|
|
if (! histogram_tool_options)
|
1999-04-09 06:25:54 +08:00
|
|
|
{
|
1999-04-13 01:55:06 +08:00
|
|
|
histogram_tool_options = tool_options_new (_("Histogram Options"));
|
|
|
|
tools_register (HISTOGRAM, histogram_tool_options);
|
1999-04-09 06:25:54 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
tool = (Tool *) g_malloc (sizeof (Tool));
|
|
|
|
private = (HistogramTool *) g_malloc (sizeof (HistogramTool));
|
|
|
|
|
|
|
|
tool->type = HISTOGRAM;
|
|
|
|
tool->state = INACTIVE;
|
|
|
|
tool->scroll_lock = 1; /* Disallow scrolling */
|
|
|
|
tool->auto_snap_to = TRUE;
|
|
|
|
tool->private = (void *) private;
|
1999-04-09 06:25:54 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
tool->button_press_func = histogram_tool_button_press;
|
|
|
|
tool->button_release_func = histogram_tool_button_release;
|
|
|
|
tool->motion_func = histogram_tool_motion;
|
1999-06-22 06:12:07 +08:00
|
|
|
tool->arrow_keys_func = standard_arrow_keys_func;
|
|
|
|
tool->modifier_key_func = standard_modifier_key_func;
|
1997-11-25 06:05:25 +08:00
|
|
|
tool->cursor_update_func = histogram_tool_cursor_update;
|
|
|
|
tool->control_func = histogram_tool_control;
|
1998-03-31 15:23:50 +08:00
|
|
|
tool->preserve = FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return tool;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
tools_free_histogram_tool (Tool *tool)
|
|
|
|
{
|
|
|
|
HistogramTool * hist;
|
|
|
|
|
|
|
|
hist = (HistogramTool *) tool->private;
|
|
|
|
|
|
|
|
/* Close the histogram dialog */
|
|
|
|
if (histogram_tool_dialog)
|
1998-04-14 05:59:28 +08:00
|
|
|
histogram_tool_close_callback (NULL, (gpointer) histogram_tool_dialog);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
g_free (hist);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-06-22 04:17:21 +08:00
|
|
|
histogram_tool_initialize (GDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
PixelRegion PR;
|
1997-11-25 06:05:25 +08:00
|
|
|
if (drawable_indexed (gimage_active_drawable (gdisp->gimage)))
|
|
|
|
{
|
1999-06-07 10:21:31 +08:00
|
|
|
g_message (_("Histogram does not operate on indexed drawables."));
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The histogram_tool dialog */
|
|
|
|
if (!histogram_tool_dialog)
|
|
|
|
histogram_tool_dialog = histogram_tool_new_dialog ();
|
|
|
|
else if (!GTK_WIDGET_VISIBLE (histogram_tool_dialog->shell))
|
|
|
|
gtk_widget_show (histogram_tool_dialog->shell);
|
|
|
|
|
1998-01-22 15:02:57 +08:00
|
|
|
histogram_tool_dialog->drawable = gimage_active_drawable (gdisp->gimage);
|
|
|
|
histogram_tool_dialog->color = drawable_color (histogram_tool_dialog->drawable);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* hide or show the channel menu based on image type */
|
|
|
|
if (histogram_tool_dialog->color)
|
|
|
|
gtk_widget_show (histogram_tool_dialog->channel_menu);
|
|
|
|
else
|
|
|
|
gtk_widget_hide (histogram_tool_dialog->channel_menu);
|
|
|
|
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
/* calculate the histogram */
|
|
|
|
pixel_region_init(&PR, drawable_data (histogram_tool_dialog->drawable), 0, 0,
|
|
|
|
drawable_width(histogram_tool_dialog->drawable),
|
|
|
|
drawable_height(histogram_tool_dialog->drawable),
|
|
|
|
FALSE);
|
|
|
|
gimp_histogram_calculate(histogram_tool_dialog->hist, &PR, NULL);
|
|
|
|
|
|
|
|
histogram_widget_update (histogram_tool_dialog->histogram,
|
|
|
|
histogram_tool_dialog->hist);
|
|
|
|
histogram_widget_range (histogram_tool_dialog->histogram, 0, 255);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-04-14 05:59:28 +08:00
|
|
|
/***************************/
|
|
|
|
/* Histogram Tool dialog */
|
|
|
|
/***************************/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-03-19 06:35:31 +08:00
|
|
|
static HistogramToolDialog *
|
1997-11-25 06:05:25 +08:00
|
|
|
histogram_tool_new_dialog ()
|
|
|
|
{
|
|
|
|
HistogramToolDialog *htd;
|
|
|
|
GtkWidget *vbox;
|
1999-04-13 01:55:06 +08:00
|
|
|
GtkWidget *vbox2;
|
1997-11-25 06:05:25 +08:00
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *table;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *option_menu;
|
|
|
|
GtkWidget *menu;
|
|
|
|
int i;
|
|
|
|
int x, y;
|
|
|
|
|
1999-04-13 01:55:06 +08:00
|
|
|
static ActionAreaItem action_items[] =
|
|
|
|
{
|
1999-06-07 10:21:31 +08:00
|
|
|
{ N_("Close"), histogram_tool_close_callback, NULL, NULL }
|
1999-04-13 01:55:06 +08:00
|
|
|
};
|
|
|
|
static char * histogram_info_names[7] =
|
|
|
|
{
|
|
|
|
N_("Mean:"),
|
|
|
|
N_("Std Dev:"),
|
|
|
|
N_("Median:"),
|
|
|
|
N_("Pixels:"),
|
|
|
|
N_("Intensity:"),
|
|
|
|
N_("Count:"),
|
|
|
|
N_("Percentile:")
|
|
|
|
};
|
|
|
|
static MenuItem color_option_items[] =
|
|
|
|
{
|
1999-06-07 10:21:31 +08:00
|
|
|
{ N_("Value"), 0, 0, histogram_tool_value_callback, NULL, NULL, NULL },
|
|
|
|
{ N_("Red"), 0, 0, histogram_tool_red_callback, NULL, NULL, NULL },
|
|
|
|
{ N_("Green"), 0, 0, histogram_tool_green_callback, NULL, NULL, NULL },
|
|
|
|
{ N_("Blue"), 0, 0, histogram_tool_blue_callback, NULL, NULL, NULL },
|
1999-04-13 01:55:06 +08:00
|
|
|
{ NULL, 0, 0, NULL, NULL, NULL, NULL }
|
|
|
|
};
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
htd = (HistogramToolDialog *) g_malloc (sizeof (HistogramToolDialog));
|
|
|
|
htd->channel = HISTOGRAM_VALUE;
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
color_option_items [i].user_data = (gpointer) htd;
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
|
|
|
|
htd->hist = gimp_histogram_new();
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* The shell and main vbox */
|
|
|
|
htd->shell = gtk_dialog_new ();
|
1998-01-26 06:13:00 +08:00
|
|
|
gtk_window_set_wmclass (GTK_WINDOW (htd->shell), "histogram", "Gimp");
|
1999-06-07 10:21:31 +08:00
|
|
|
gtk_window_set_title (GTK_WINDOW (htd->shell), _("Histogram"));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* handle the wm close signal */
|
|
|
|
gtk_signal_connect (GTK_OBJECT (htd->shell), "delete_event",
|
|
|
|
(GtkSignalFunc) histogram_tool_delete_callback,
|
|
|
|
htd);
|
|
|
|
|
1999-04-13 01:55:06 +08:00
|
|
|
vbox = gtk_vbox_new (FALSE, 2);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (htd->shell)->vbox), vbox);
|
|
|
|
|
|
|
|
/* The vbox for the menu and histogram */
|
|
|
|
vbox2 = gtk_vbox_new (FALSE, 2);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* The option menu for selecting channels */
|
1999-04-13 01:55:06 +08:00
|
|
|
htd->channel_menu = gtk_hbox_new (FALSE, 6);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox2), htd->channel_menu, FALSE, FALSE, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-06-07 10:21:31 +08:00
|
|
|
label = gtk_label_new (_("Information on Channel:"));
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (htd->channel_menu), label, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
menu = build_menu (color_option_items, NULL);
|
|
|
|
option_menu = gtk_option_menu_new ();
|
1999-04-13 01:55:06 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (htd->channel_menu), option_menu, FALSE, FALSE, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
gtk_widget_show (label);
|
|
|
|
gtk_widget_show (option_menu);
|
|
|
|
gtk_widget_show (htd->channel_menu);
|
|
|
|
gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
|
|
|
|
|
|
|
|
/* The histogram tool histogram */
|
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
|
1999-04-13 01:55:06 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox2), frame, FALSE, FALSE, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
htd->histogram = histogram_widget_new (HISTOGRAM_WIDTH, HISTOGRAM_HEIGHT);
|
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT (htd->histogram), "rangechanged",
|
|
|
|
(GtkSignalFunc) histogram_tool_histogram_range,
|
|
|
|
(void*)htd);
|
|
|
|
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET(htd->histogram));
|
|
|
|
gtk_widget_show (GTK_WIDGET(htd->histogram));
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_widget_show (frame);
|
1999-04-13 01:55:06 +08:00
|
|
|
gtk_widget_show (vbox2);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* The table containing histogram information */
|
|
|
|
table = gtk_table_new (4, 4, TRUE);
|
1999-04-13 01:55:06 +08:00
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
/* the labels for histogram information */
|
|
|
|
for (i = 0; i < 7; i++)
|
|
|
|
{
|
|
|
|
y = (i % 4);
|
|
|
|
x = (i / 4) * 2;
|
|
|
|
|
1998-12-16 08:37:09 +08:00
|
|
|
label = gtk_label_new (gettext(histogram_info_names[i]));
|
1999-04-13 01:55:06 +08:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_table_attach (GTK_TABLE (table), label, x, x + 1, y, y + 1,
|
|
|
|
GTK_FILL, GTK_FILL, 2, 2);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
htd->info_labels[i] = gtk_label_new ("0");
|
1999-04-13 01:55:06 +08:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (htd->info_labels[i]), 0.0, 0.5);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), htd->info_labels[i],
|
|
|
|
x + 1, x + 2, y, y + 1,
|
1997-11-25 06:05:25 +08:00
|
|
|
GTK_FILL, GTK_FILL, 2, 2);
|
|
|
|
gtk_widget_show (htd->info_labels[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The action area */
|
|
|
|
action_items[0].user_data = htd;
|
1998-04-14 05:59:28 +08:00
|
|
|
build_action_area (GTK_DIALOG (htd->shell), action_items, 1, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
gtk_widget_show (table);
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
gtk_widget_show (htd->shell);
|
|
|
|
|
|
|
|
return htd;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1998-04-14 05:59:28 +08:00
|
|
|
histogram_tool_close_callback (GtkWidget *widget,
|
1997-11-25 06:05:25 +08:00
|
|
|
gpointer client_data)
|
|
|
|
{
|
|
|
|
HistogramToolDialog *htd;
|
|
|
|
|
|
|
|
htd = (HistogramToolDialog *) client_data;
|
|
|
|
if (GTK_WIDGET_VISIBLE (htd->shell))
|
|
|
|
gtk_widget_hide (htd->shell);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
histogram_tool_delete_callback (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
gpointer client_data)
|
|
|
|
{
|
1998-04-14 05:59:28 +08:00
|
|
|
histogram_tool_close_callback (widget, client_data);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-03-13 06:01:43 +08:00
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
histogram_tool_value_callback (GtkWidget *w,
|
|
|
|
gpointer client_data)
|
|
|
|
{
|
|
|
|
HistogramToolDialog *htd;
|
|
|
|
|
|
|
|
htd = (HistogramToolDialog *) client_data;
|
|
|
|
|
|
|
|
if (htd->channel != HISTOGRAM_VALUE)
|
|
|
|
{
|
|
|
|
htd->channel = HISTOGRAM_VALUE;
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
histogram_widget_channel (htd->histogram, htd->channel);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
histogram_tool_red_callback (GtkWidget *w,
|
|
|
|
gpointer client_data)
|
|
|
|
{
|
|
|
|
HistogramToolDialog *htd;
|
|
|
|
|
|
|
|
htd = (HistogramToolDialog *) client_data;
|
|
|
|
|
|
|
|
if (htd->channel != HISTOGRAM_RED)
|
|
|
|
{
|
|
|
|
htd->channel = HISTOGRAM_RED;
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
histogram_widget_channel (htd->histogram, htd->channel);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
histogram_tool_green_callback (GtkWidget *w,
|
|
|
|
gpointer client_data)
|
|
|
|
{
|
|
|
|
HistogramToolDialog *htd;
|
|
|
|
|
|
|
|
htd = (HistogramToolDialog *) client_data;
|
|
|
|
|
|
|
|
if (htd->channel != HISTOGRAM_GREEN)
|
|
|
|
{
|
|
|
|
htd->channel = HISTOGRAM_GREEN;
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
histogram_widget_channel (htd->histogram, htd->channel);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
histogram_tool_blue_callback (GtkWidget *w,
|
|
|
|
gpointer client_data)
|
|
|
|
{
|
|
|
|
HistogramToolDialog *htd;
|
|
|
|
|
|
|
|
htd = (HistogramToolDialog *) client_data;
|
|
|
|
|
|
|
|
if (htd->channel != HISTOGRAM_BLUE)
|
|
|
|
{
|
|
|
|
htd->channel = HISTOGRAM_BLUE;
|
added gimphistogram*, histogramwidget*, removed histogram.[ch]
* app/Makefile.am: added gimphistogram*, histogramwidget*,
removed histogram.[ch]
* app/histogram.[ch]: removed. replaced with histogramwidget.[ch].
* app/{gimphistogramP.h, gimphistogram.h, gimphistogram.c}: new
functions that calculate histograms in parallel and perform
calculations on them.
* app/histogramwidget.[ch]: Same as old histogram.[ch], only it is
now a real widget, and it uses GimpHistograms instead of arrays of
values.
* app/curves.c: #include gimphistogram.h instead of histogram.h.
* app/equalize.c: use GimpHistogram and GimpLut.
* app/gimpbrush.c, app/gimpimage.c, app/gimpset.c: use
GTK_RUN_FIRST in calls to gimp_signal_new.
* app/histogram_tool.c, app/levels.c, app/threshold.c: modified to
use the new HistogramWidget.
* app/paint_funcs.c: removed some unused variables.
* app/preferences_dialog.c: only display the num-processor field
if we are configured --with-mp
* plug-ins/gee/gee.c: removed a couple of c++ style comments.
1999-03-01 13:11:19 +08:00
|
|
|
histogram_widget_channel (htd->histogram, htd->channel);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|