diff --git a/plug-ins/selection-to-path/fit.c b/plug-ins/selection-to-path/fit.c
index 8ee57ae4a6..6ab247b74b 100644
--- a/plug-ins/selection-to-path/fit.c
+++ b/plug-ins/selection-to-path/fit.c
@@ -217,53 +217,30 @@ fitted_splines (pixel_outline_list_type pixel_outline_list)
/* Set up the internal parameters from the external ones */
void
-fit_set_params(SELVALS *selVals)
+fit_set_params (GimpProcedureConfig *config)
{
- align_threshold = selVals->align_threshold;
- corner_always_threshold = selVals->corner_always_threshold;
- corner_surround = selVals->corner_surround;
- corner_threshold = selVals->corner_threshold;
- error_threshold = selVals->error_threshold;
- filter_alternative_surround = selVals->filter_alternative_surround;
- filter_epsilon = selVals->filter_epsilon;
- filter_iteration_count = selVals->filter_iteration_count;
- filter_percent = selVals->filter_percent;
- filter_secondary_surround = selVals->filter_secondary_surround;
- filter_surround = selVals->filter_surround;
- keep_knees = selVals->keep_knees;
- line_reversion_threshold = selVals->line_reversion_threshold;
- line_threshold = selVals->line_threshold;
- reparameterize_improvement = selVals->reparameterize_improvement;
- reparameterize_threshold = selVals->reparameterize_threshold;
- subdivide_search = selVals->subdivide_search;
- subdivide_surround = selVals->subdivide_surround;
- subdivide_threshold = selVals->subdivide_threshold;
- tangent_surround = selVals->tangent_surround;
-}
-
-void
-fit_set_default_params(SELVALS *selVals)
-{
- selVals->align_threshold = align_threshold;
- selVals->corner_always_threshold = corner_always_threshold;
- selVals->corner_surround = corner_surround;
- selVals->corner_threshold = corner_threshold;
- selVals->error_threshold = error_threshold;
- selVals->filter_alternative_surround = filter_alternative_surround;
- selVals->filter_epsilon = filter_epsilon;
- selVals->filter_iteration_count = filter_iteration_count;
- selVals->filter_percent = filter_percent;
- selVals->filter_secondary_surround = filter_secondary_surround;
- selVals->filter_surround = filter_surround;
- selVals->keep_knees = keep_knees;
- selVals->line_reversion_threshold = line_reversion_threshold;
- selVals->line_threshold = line_threshold;
- selVals->reparameterize_improvement = reparameterize_improvement;
- selVals->reparameterize_threshold = reparameterize_threshold;
- selVals->subdivide_search = subdivide_search;
- selVals->subdivide_surround = subdivide_surround;
- selVals->subdivide_threshold = subdivide_threshold;
- selVals->tangent_surround = tangent_surround;
+ g_object_get (config,
+ "align-threshold", &align_threshold,
+ "corner-always-threshold", &corner_always_threshold,
+ "corner-surround", &corner_surround,
+ "corner-threshold", &corner_threshold,
+ "error-threshold", &error_threshold,
+ "filter-alternative-surround", &filter_alternative_surround,
+ "filter-epsilon", &filter_epsilon,
+ "filter-iteration-count", &filter_iteration_count,
+ "filter-percent", &filter_percent,
+ "filter-secondary-surround", &filter_secondary_surround,
+ "filter-surround", &filter_surround,
+ "keep-knees", &keep_knees,
+ "line-reversion-threshold", &line_reversion_threshold,
+ "line-threshold", &line_threshold,
+ "reparametrize-improvement", &reparameterize_improvement,
+ "reparametrize-threshold", &reparameterize_threshold,
+ "subdivide-search", &subdivide_search,
+ "subdivide-surround", &subdivide_surround,
+ "subdivide-threshold", &subdivide_threshold,
+ "tangent-surround", &tangent_surround,
+ NULL);
}
/* Fit the list of curves CURVE_LIST to a list of splines, and return
diff --git a/plug-ins/selection-to-path/fit.h b/plug-ins/selection-to-path/fit.h
index f009c9afcc..59f649afad 100644
--- a/plug-ins/selection-to-path/fit.h
+++ b/plug-ins/selection-to-path/fit.h
@@ -19,6 +19,8 @@
#ifndef FIT_H
#define FIT_H
+#include "libgimp/gimp.h"
+
#include "pxl-outline.h"
#include "spline.h"
@@ -47,8 +49,7 @@ extern unsigned tangent_surround;
/* Fit splines and lines to LIST. */
-extern spline_list_array_type fitted_splines (pixel_outline_list_type list);
-void fit_set_params(SELVALS *);
-void fit_set_default_params(SELVALS *);
+extern spline_list_array_type fitted_splines (pixel_outline_list_type list);
+void fit_set_params (GimpProcedureConfig *config);
#endif /* not FIT_H */
diff --git a/plug-ins/selection-to-path/meson.build b/plug-ins/selection-to-path/meson.build
index 697d680ae7..c58192186d 100644
--- a/plug-ins/selection-to-path/meson.build
+++ b/plug-ins/selection-to-path/meson.build
@@ -6,7 +6,6 @@ plugin_sources = [
'fit.c',
'math.c',
'pxl-outline.c',
- 'selection-to-path-dialog.c',
'selection-to-path.c',
'spline.c',
'vector.c',
diff --git a/plug-ins/selection-to-path/selection-to-path-dialog.c b/plug-ins/selection-to-path/selection-to-path-dialog.c
deleted file mode 100644
index 917a93ca19..0000000000
--- a/plug-ins/selection-to-path/selection-to-path-dialog.c
+++ /dev/null
@@ -1,387 +0,0 @@
-/*
- * Copyright (C) 1995 Spencer Kimball and Peter Mattis
- *
- * This is a plug-in for GIMP.
- *
- * Plugin to convert a selection to a path.
- *
- * Copyright (C) 1999 Andy Thomas alt@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 .
- *
- */
-
-/* Change log:-
- * 0.1 First version.
- */
-
-#include "config.h"
-
-#include
-#include
-
-#include "types.h"
-
-#include "selection-to-path.h"
-
-#include "libgimp/stdplugins-intl.h"
-
-
-static GSList * adjust_widgets = NULL;
-
-void scale_entry_update_double (GimpLabelSpin *entry,
- gdouble *value);
-
-/* Reset to recommended defaults */
-void
-reset_adv_dialog (void)
-{
- GSList *list;
- GObject *widget;
- gdouble *value;
-
- for (list = adjust_widgets; list; list = g_slist_next (list))
- {
- widget = G_OBJECT (list->data);
- value = (gdouble *) g_object_get_data (G_OBJECT (widget),
- "default_value");
-
- if (GTK_IS_ADJUSTMENT (widget))
- {
- gtk_adjustment_set_value (GTK_ADJUSTMENT (widget),
- *value);
- }
- else if (GTK_IS_TOGGLE_BUTTON (widget))
- {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget),
- (gboolean)(*value));
- }
- else if (GIMP_IS_SCALE_ENTRY (widget))
- {
- gimp_label_spin_set_value (GIMP_LABEL_SPIN (widget),
- *value);
- }
- else
- g_warning ("Internal widget list error");
- }
-}
-
-static gpointer
-def_val (gdouble default_value)
-{
- gdouble *value = g_new0 (gdouble, 1);
- *value = default_value;
- return (value);
-}
-
-GtkWidget *
-dialog_create_selection_area (SELVALS *sels)
-{
- GtkWidget *scrolled_win;
- GtkWidget *grid;
- GtkWidget *check;
- GtkWidget *scale;
- gint row;
-
- scrolled_win = gtk_scrolled_window_new (NULL, NULL);
- gtk_widget_set_size_request (scrolled_win, -1, 400);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win),
- GTK_SHADOW_NONE);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
- GTK_POLICY_NEVER,
- GTK_POLICY_ALWAYS);
- gtk_scrolled_window_set_overlay_scrolling (GTK_SCROLLED_WINDOW (scrolled_win),
- FALSE);
-
- grid = gtk_grid_new ();
- gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
- gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
- gtk_container_add (GTK_CONTAINER (scrolled_win), grid);
- gtk_widget_show (grid);
- row = 0;
-
- scale = gimp_scale_entry_new (_("Align Threshold:"), sels->align_threshold, 0.2, 2.0, 2);
- gimp_help_set_help_data (scale,
- _("If two endpoints are closer than this, "
- "they are made to be equal."), NULL);
- g_signal_connect (scale, "value-changed",
- G_CALLBACK (scale_entry_update_double),
- &sels->align_threshold);
- adjust_widgets = g_slist_append (adjust_widgets, scale);
- g_object_set_data (G_OBJECT (scale), "default_value", def_val (0.5));
- gtk_grid_attach (GTK_GRID (grid), scale, 0, row++, 3, 1);
- gtk_widget_show (scale);
-
- scale = gimp_scale_entry_new (_("Corner Always Threshold:"), sels->corner_always_threshold, 30, 180, 2);
- gimp_help_set_help_data (scale,
- _("If the angle defined by a point and its predecessors "
- "and successors is smaller than this, it's a corner, "
- "even if it's within 'corner_surround' pixels of a "
- "point with a smaller angle."), NULL);
- g_signal_connect (scale, "value-changed",
- G_CALLBACK (scale_entry_update_double),
- &sels->corner_always_threshold);
- adjust_widgets = g_slist_append (adjust_widgets, scale);
- g_object_set_data (G_OBJECT (scale), "default_value", def_val (60.0));
- gtk_grid_attach (GTK_GRID (grid), scale, 0, row++, 3, 1);
- gtk_widget_show (scale);
-
- scale = gimp_scale_entry_new (_("Corner Surround:"), sels->corner_surround, 3, 8, 0);
- gimp_help_set_help_data (scale,
- _("Number of points to consider when determining if a "
- "point is a corner or not."), NULL);
- g_signal_connect (scale, "value-changed",
- G_CALLBACK (scale_entry_update_double),
- &sels->corner_surround);
- adjust_widgets = g_slist_append (adjust_widgets, scale);
- g_object_set_data (G_OBJECT (scale), "default_value", def_val (4.0));
- gtk_grid_attach (GTK_GRID (grid), scale, 0, row++, 3, 1);
- gtk_widget_show (scale);
-
- scale = gimp_scale_entry_new (_("Corner Threshold:"), sels->corner_threshold, 0, 180, 2);
- gimp_help_set_help_data (scale,
- _("If a point, its predecessors, and its successors "
- "define an angle smaller than this, it's a corner."),
- NULL);
- g_signal_connect (scale, "value-changed",
- G_CALLBACK (scale_entry_update_double),
- &sels->corner_threshold);
- adjust_widgets = g_slist_append (adjust_widgets, scale);
- g_object_set_data (G_OBJECT (scale), "default_value", def_val (100.0));
- gtk_grid_attach (GTK_GRID (grid), scale, 0, row++, 3, 1);
- gtk_widget_show (scale);
-
- scale = gimp_scale_entry_new (_("Error Threshold:"), sels->error_threshold, 0.2, 10, 2);
- gimp_help_set_help_data (scale,
- _("Amount of error at which a fitted spline is "
- "unacceptable. If any pixel is further away "
- "than this from the fitted curve, we try again."),
- NULL);
- g_signal_connect (scale, "value-changed",
- G_CALLBACK (scale_entry_update_double),
- &sels->error_threshold);
- adjust_widgets = g_slist_append (adjust_widgets, scale);
- g_object_set_data (G_OBJECT (scale), "default_value", def_val (0.40));
- gtk_grid_attach (GTK_GRID (grid), scale, 0, row++, 3, 1);
- gtk_widget_show (scale);
-
- scale = gimp_scale_entry_new (_("Filter Alternative Surround:"), sels->filter_alternative_surround, 1, 10, 0);
- gimp_help_set_help_data (scale,
- _("A second number of adjacent points to consider "
- "when filtering."), NULL);
- g_signal_connect (scale, "value-changed",
- G_CALLBACK (scale_entry_update_double),
- &sels->filter_alternative_surround);
- adjust_widgets = g_slist_append (adjust_widgets, scale);
- g_object_set_data (G_OBJECT (scale), "default_value", def_val (1.0));
- gtk_grid_attach (GTK_GRID (grid), scale, 0, row++, 3, 1);
- gtk_widget_show (scale);
-
- scale = gimp_scale_entry_new (_("Filter Epsilon:"), sels->filter_epsilon, 5, 40, 2);
- gimp_help_set_help_data (scale,
- _("If the angles between the vectors produced by "
- "filter_surround and filter_alternative_surround "
- "points differ by more than this, use the one from "
- "filter_alternative_surround."), NULL);
- g_signal_connect (scale, "value-changed",
- G_CALLBACK (scale_entry_update_double),
- &sels->filter_epsilon);
- adjust_widgets = g_slist_append (adjust_widgets, scale);
- g_object_set_data (G_OBJECT (scale), "default_value", def_val (10.0));
- gtk_grid_attach (GTK_GRID (grid), scale, 0, row++, 3, 1);
- gtk_widget_show (scale);
-
- scale = gimp_scale_entry_new (_("Filter Iteration Count:"), sels->filter_iteration_count, 4, 70, 0);
- gimp_help_set_help_data (scale,
- _("Number of times to smooth original data points. "
- "Increasing this number dramatically --- to 50 or "
- "so --- can produce vastly better results. But if "
- "any points that 'should' be corners aren't found, "
- "the curve goes to hell around that point."), NULL);
- g_signal_connect (scale, "value-changed",
- G_CALLBACK (scale_entry_update_double),
- &sels->filter_iteration_count);
- adjust_widgets = g_slist_append (adjust_widgets, scale);
- g_object_set_data (G_OBJECT (scale), "default_value", def_val (4.0));
- gtk_grid_attach (GTK_GRID (grid), scale, 0, row++, 3, 1);
- gtk_widget_show (scale);
-
- scale = gimp_scale_entry_new (_("Filter Percent:"), sels->filter_percent, 0, 1, 2);
- gimp_help_set_help_data (scale,
- _("To produce the new point, use the old point plus "
- "this times the neighbors."), NULL);
- g_signal_connect (scale, "value-changed",
- G_CALLBACK (scale_entry_update_double),
- &sels->filter_percent);
- adjust_widgets = g_slist_append (adjust_widgets, scale);
- g_object_set_data (G_OBJECT (scale), "default_value", def_val (0.33));
- gtk_grid_attach (GTK_GRID (grid), scale, 0, row++, 3, 1);
- gtk_widget_show (scale);
-
- scale = gimp_scale_entry_new (_("Filter Secondary Surround:"), sels->filter_secondary_surround, 3, 10, 0);
- gimp_help_set_help_data (scale,
- _("Number of adjacent points to consider if "
- "'filter_surround' points defines a straight line."),
- NULL);
- g_signal_connect (scale, "value-changed",
- G_CALLBACK (scale_entry_update_double),
- &sels->filter_secondary_surround);
- adjust_widgets = g_slist_append (adjust_widgets, scale);
- g_object_set_data (G_OBJECT (scale), "default_value", def_val (3.0));
- gtk_grid_attach (GTK_GRID (grid), scale, 0, row++, 3, 1);
- gtk_widget_show (scale);
-
- scale = gimp_scale_entry_new (_("Filter Surround:"), sels->filter_surround, 2, 10, 0);
- gimp_help_set_help_data (scale,
- _("Number of adjacent points to consider when filtering."),
- NULL);
- g_signal_connect (scale, "value-changed",
- G_CALLBACK (scale_entry_update_double),
- &sels->filter_surround);
- adjust_widgets = g_slist_append (adjust_widgets, scale);
- g_object_set_data (G_OBJECT (scale), "default_value", def_val (2.0));
- gtk_grid_attach (GTK_GRID (grid), scale, 0, row++, 3, 1);
- gtk_widget_show (scale);
-
- check = gtk_check_button_new_with_label (_("Keep Knees"));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), sels->keep_knees);
- gtk_grid_attach (GTK_GRID (grid), check, 1, row, 2, 1);
- gimp_help_set_help_data (GTK_WIDGET (check),
- _("Says whether or not to remove 'knee' "
- "points after finding the outline."), NULL);
- g_signal_connect (check, "toggled",
- G_CALLBACK (gimp_toggle_button_update),
- &sels->keep_knees);
- gtk_widget_show (check);
- adjust_widgets = g_slist_append (adjust_widgets, check);
- g_object_set_data (G_OBJECT (check), "default_value", def_val ((gdouble)FALSE));
- row++;
-
- scale = gimp_scale_entry_new (_("Line Reversion Threshold:"), sels->line_reversion_threshold, 0.01, 0.2, 3);
- gimp_help_set_help_data (scale,
- _("If a spline is closer to a straight line than this, "
- "it remains a straight line, even if it would otherwise "
- "be changed back to a curve. This is weighted by the "
- "square of the curve length, to make shorter curves "
- "more likely to be reverted."), NULL);
- g_signal_connect (scale, "value-changed",
- G_CALLBACK (scale_entry_update_double),
- &sels->line_reversion_threshold);
- adjust_widgets = g_slist_append (adjust_widgets, scale);
- g_object_set_data (G_OBJECT (scale), "default_value", def_val (0.01));
- gtk_grid_attach (GTK_GRID (grid), scale, 0, row++, 3, 1);
- gtk_widget_show (scale);
-
- scale = gimp_scale_entry_new (_("Line Threshold:"), sels->line_threshold, 0.2, 4, 2);
- gimp_help_set_help_data (scale,
- _("How many pixels (on the average) a spline can "
- "diverge from the line determined by its endpoints "
- "before it is changed to a straight line."), NULL);
- g_signal_connect (scale, "value-changed",
- G_CALLBACK (scale_entry_update_double),
- &sels->line_threshold);
- adjust_widgets = g_slist_append (adjust_widgets, scale);
- g_object_set_data (G_OBJECT (scale), "default_value", def_val (0.5));
- gtk_grid_attach (GTK_GRID (grid), scale, 0, row++, 3, 1);
- gtk_widget_show (scale);
-
- scale = gimp_scale_entry_new (_("Reparametrize Improvement:"), sels->reparameterize_improvement, 0, 1, 2);
- gimp_help_set_help_data (scale,
- _("If reparameterization doesn't improve the fit by this "
- "much percent, stop doing it. ""Amount of error at which "
- "it is pointless to reparameterize."), NULL);
- g_signal_connect (scale, "value-changed",
- G_CALLBACK (scale_entry_update_double),
- &sels->reparameterize_improvement);
- adjust_widgets = g_slist_append (adjust_widgets, scale);
- g_object_set_data (G_OBJECT (scale), "default_value", def_val (0.01));
- gtk_grid_attach (GTK_GRID (grid), scale, 0, row++, 3, 1);
- gtk_widget_show (scale);
-
- scale = gimp_scale_entry_new (_("Reparametrize Threshold:"), sels->reparameterize_threshold, 1, 50, 2);
- gimp_help_set_help_data (scale,
- _("Amount of error at which it is pointless to reparameterize. "
- "This happens, for example, when we are trying to fit the "
- "outline of the outside of an 'O' with a single spline. "
- "The initial fit is not good enough for the Newton-Raphson "
- "iteration to improve it. It may be that it would be better "
- "to detect the cases where we didn't find any corners."), NULL);
- g_signal_connect (scale, "value-changed",
- G_CALLBACK (scale_entry_update_double),
- &sels->reparameterize_threshold);
- adjust_widgets = g_slist_append (adjust_widgets, scale);
- g_object_set_data (G_OBJECT (scale), "default_value", def_val (1.0));
- gtk_grid_attach (GTK_GRID (grid), scale, 0, row++, 3, 1);
- gtk_widget_show (scale);
-
- scale = gimp_scale_entry_new (_("Subdivide Search:"), sels->subdivide_search, 0.05, 1, 2);
- gimp_help_set_help_data (scale,
- _("Percentage of the curve away from the worst point "
- "to look for a better place to subdivide."), NULL);
- g_signal_connect (scale, "value-changed",
- G_CALLBACK (scale_entry_update_double),
- &sels->subdivide_search);
- adjust_widgets = g_slist_append (adjust_widgets, scale);
- g_object_set_data (G_OBJECT (scale), "default_value", def_val (0.1));
- gtk_grid_attach (GTK_GRID (grid), scale, 0, row++, 3, 1);
- gtk_widget_show (scale);
-
- scale = gimp_scale_entry_new (_("Subdivide Surround:"), sels->subdivide_surround, 2, 10, 0);
- gimp_help_set_help_data (scale,
- _("Number of points to consider when deciding whether "
- "a given point is a better place to subdivide."),
- NULL);
- g_signal_connect (scale, "value-changed",
- G_CALLBACK (scale_entry_update_double),
- &sels->subdivide_surround);
- adjust_widgets = g_slist_append (adjust_widgets, scale);
- g_object_set_data (G_OBJECT (scale), "default_value", def_val (4.0));
- gtk_grid_attach (GTK_GRID (grid), scale, 0, row++, 3, 1);
- gtk_widget_show (scale);
-
- scale = gimp_scale_entry_new (_("Subdivide Threshold:"), sels->subdivide_threshold, 0.01, 1, 2);
- gimp_help_set_help_data (scale,
- _("How many pixels a point can diverge from a straight "
- "line and still be considered a better place to "
- "subdivide."), NULL);
- g_signal_connect (scale, "value-changed",
- G_CALLBACK (scale_entry_update_double),
- &sels->subdivide_threshold);
- adjust_widgets = g_slist_append (adjust_widgets, scale);
- g_object_set_data (G_OBJECT (scale), "default_value", def_val (0.03));
- gtk_grid_attach (GTK_GRID (grid), scale, 0, row++, 3, 1);
- gtk_widget_show (scale);
-
- scale = gimp_scale_entry_new (_("Tangent Surround:"), sels->tangent_surround, 2, 10, 0);
- gimp_help_set_help_data (scale,
- _("Number of points to look at on either side of a "
- "point when computing the approximation to the "
- "tangent at that point."), NULL);
- g_signal_connect (scale, "value-changed",
- G_CALLBACK (scale_entry_update_double),
- &sels->tangent_surround);
- adjust_widgets = g_slist_append (adjust_widgets, scale);
- g_object_set_data (G_OBJECT (scale), "default_value", def_val (3.0));
- gtk_grid_attach (GTK_GRID (grid), scale, 0, row++, 3, 1);
- gtk_widget_show (scale);
-
- return scrolled_win;
-}
-
-void
-scale_entry_update_double (GimpLabelSpin *entry,
- gdouble *value)
-{
- *value = gimp_label_spin_get_value (entry);
-}
diff --git a/plug-ins/selection-to-path/selection-to-path.c b/plug-ins/selection-to-path/selection-to-path.c
index d5a9403edd..025d270645 100644
--- a/plug-ins/selection-to-path/selection-to-path.c
+++ b/plug-ins/selection-to-path/selection-to-path.c
@@ -81,14 +81,11 @@ static GimpValueArray * sel2path_run (GimpProcedure *procedu
GimpImage *image,
gint n_drawables,
GimpDrawable **drawables,
- const GimpValueArray *args,
+ GimpProcedureConfig *config,
gpointer run_data);
-static gint sel2path_dialog (SELVALS *sels);
-static void sel2path_response (GtkWidget *widget,
- gint response_id,
- gpointer data);
-static void dialog_print_selVals (SELVALS *sels);
+static gint sel2path_dialog (GimpProcedure *procedure,
+ GimpProcedureConfig *config);
static gboolean sel2path (GimpImage *image);
@@ -100,9 +97,7 @@ DEFINE_STD_SET_I18N
static gint sel_x1, sel_y1, sel_x2, sel_y2;
static gint has_sel, sel_width, sel_height;
-static SELVALS selVals;
static GeglSampler *sel_sampler;
-static gboolean retVal = TRUE; /* Toggle if cancel button clicked */
static void
@@ -134,9 +129,9 @@ sel2path_create_procedure (GimpPlugIn *plug_in,
if (! strcmp (name, PLUG_IN_PROC))
{
- procedure = gimp_image_procedure_new (plug_in, name,
- GIMP_PDB_PROC_TYPE_PLUGIN,
- sel2path_run, NULL, NULL);
+ procedure = gimp_image_procedure_new2 (plug_in, name,
+ GIMP_PDB_PROC_TYPE_PLUGIN,
+ sel2path_run, NULL, NULL);
gimp_procedure_set_image_types (procedure, "*");
gimp_procedure_set_sensitivity_mask (procedure,
@@ -145,8 +140,8 @@ sel2path_create_procedure (GimpPlugIn *plug_in,
GIMP_PROCEDURE_SENSITIVE_NO_DRAWABLES);
gimp_procedure_set_documentation (procedure,
- "Converts a selection to a path",
- "Converts a selection to a path",
+ _("Converts a selection to a path"),
+ _("Converts a selection to a path"),
name);
gimp_procedure_set_attribution (procedure,
"Andy Thomas",
@@ -154,122 +149,160 @@ sel2path_create_procedure (GimpPlugIn *plug_in,
"1999");
GIMP_PROC_ARG_DOUBLE (procedure, "align-threshold",
- "Align threshold",
- "Align threshold",
+ _("_Align Threshold"),
+ _("If two endpoints are closer than this, "
+ "they are made to be equal."),
0.2, 2.0, 0.5,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "corner-always-threshold",
- "Corner always threshold",
- "Corner always threshold",
+ _("Corner Al_ways Threshold"),
+ _("If the angle defined by a point and its predecessors "
+ "and successors is smaller than this, it's a corner, "
+ "even if it's within 'corner_surround' pixels of a "
+ "point with a smaller angle."),
30, 180, 60.0,
G_PARAM_READWRITE);
GIMP_PROC_ARG_INT (procedure, "corner-surround",
- "Corner surround",
- "Corner surround",
+ _("Corner _Surround"),
+ _("Number of points to consider when determining if a "
+ "point is a corner or not."),
3, 8, 4,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "corner-threshold",
- "Corner threshold",
- "Corner threshold",
+ _("Cor_ner Threshold"),
+ _("If a point, its predecessors, and its successors "
+ "define an angle smaller than this, it's a corner."),
0, 180, 100.0,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "error-threshold",
- "Error threshold",
- "Error threshold",
+ _("Error Thres_hold"),
+ _("Amount of error at which a fitted spline is "
+ "unacceptable. If any pixel is further away "
+ "than this from the fitted curve, we try again."),
0.2, 10, 0.4,
G_PARAM_READWRITE);
GIMP_PROC_ARG_INT (procedure, "filter-alternative-surround",
- "Filter alternative surround",
- "Filter alternative surround",
+ _("_Filter Alternative Surround"),
+ _("A second number of adjacent points to consider "
+ "when filtering."),
1, 10, 1,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "filter-epsilon",
- "Filter epsilon",
- "Filter epsilon",
+ _("Filter E_psilon"),
+ _("If the angles between the vectors produced by "
+ "filter_surround and filter_alternative_surround "
+ "points differ by more than this, use the one from "
+ "filter_alternative_surround."),
5, 40, 10.0,
G_PARAM_READWRITE);
GIMP_PROC_ARG_INT (procedure, "filter-iteration-count",
- "Filter iteration count",
- "Filter iteration count",
+ _("Filter Iteration Co_unt"),
+ _("Number of times to smooth original data points. "
+ "Increasing this number dramatically --- to 50 or "
+ "so --- can produce vastly better results. But if "
+ "any points that 'should' be corners aren't found, "
+ "the curve goes to hell around that point."),
4, 70, 4,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "filter-percent",
- "Filter percent",
- "Filter percent",
+ _("Filt_er Percent"),
+ _("To produce the new point, use the old point plus "
+ "this times the neighbors."),
0, 1, 0.33,
G_PARAM_READWRITE);
GIMP_PROC_ARG_INT (procedure, "filter-secondary-surround",
- "Filter secondary surround",
- "Filter secondary surround",
+ _("Filter Secondar_y Surround"),
+ _("Number of adjacent points to consider if "
+ "'filter_surround' points defines a straight line."),
3, 10, 3,
G_PARAM_READWRITE);
GIMP_PROC_ARG_INT (procedure, "filter-surround",
- "Filter surround",
- "Filter surround",
+ _("Filter Surroun_d"),
+ _("Number of adjacent points to consider when filtering."),
2, 10, 2,
G_PARAM_READWRITE);
GIMP_PROC_ARG_BOOLEAN (procedure, "keep-knees",
- "Keep knees",
- "Keep knees",
+ _("_Keep Knees"),
+ _("Says whether or not to remove 'knee' "
+ "points after finding the outline."),
FALSE,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "line-reversion-threshold",
- "Line reversion threshold",
- "Line reversion threshold",
+ _("_Line Reversion Threshold"),
+ _("If a spline is closer to a straight line than this, "
+ "it remains a straight line, even if it would otherwise "
+ "be changed back to a curve. This is weighted by the "
+ "square of the curve length, to make shorter curves "
+ "more likely to be reverted."),
0.01, 0.2, 0.01,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "line-threshold",
- "Line threshold",
- "Line threshold",
+ _("L_ine Threshold"),
+ _("How many pixels (on the average) a spline can "
+ "diverge from the line determined by its endpoints "
+ "before it is changed to a straight line."),
0.2, 4, 0.5,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "reparametrize-improvement",
- "Reparametrize improvement",
- "Reparametrize improvement",
+ _("Reparametri_ze Improvement"),
+ _("If reparameterization doesn't improve the fit by this "
+ "much percent, stop doing it. ""Amount of error at which "
+ "it is pointless to reparameterize."),
0, 1, 0.01,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "reparametrize-threshold",
- "Reparametrize threshold",
- "Reparametrize threshold",
+ _("Repara_metrize Threshold"),
+ _("Amount of error at which it is pointless to reparameterize. "
+ "This happens, for example, when we are trying to fit the "
+ "outline of the outside of an 'O' with a single spline. "
+ "The initial fit is not good enough for the Newton-Raphson "
+ "iteration to improve it. It may be that it would be better "
+ "to detect the cases where we didn't find any corners."),
1, 50, 1.0,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "subdivide-search",
- "Subdivide search",
- "Subdivide search",
+ _("Subdi_vide Search"),
+ _("Percentage of the curve away from the worst point "
+ "to look for a better place to subdivide."),
0.05, 1, 0.1,
G_PARAM_READWRITE);
GIMP_PROC_ARG_INT (procedure, "subdivide-surround",
- "Subdivide surround",
- "Subdivide surround",
+ _("Su_bdivide Surround"),
+ _("Number of points to consider when deciding whether "
+ "a given point is a better place to subdivide."),
2, 10, 4,
G_PARAM_READWRITE);
GIMP_PROC_ARG_DOUBLE (procedure, "subdivide-threshold",
- "Subdivide threshold",
- "Subdivide threshold",
+ _("Subdivide_ Threshold"),
+ _("How many pixels a point can diverge from a straight "
+ "line and still be considered a better place to "
+ "subdivide."),
0.01, 1, 0.03,
G_PARAM_READWRITE);
GIMP_PROC_ARG_INT (procedure, "tangent-surround",
- "Tangent surround",
- "Tangent surround",
+ _("_Tangent Surround"),
+ _("Number of points to look at on either side of a "
+ "point when computing the approximation to the "
+ "tangent at that point."),
2, 10, 3,
G_PARAM_READWRITE);
}
@@ -283,7 +316,7 @@ sel2path_run (GimpProcedure *procedure,
GimpImage *image,
gint n_drawables,
GimpDrawable **drawables,
- const GimpValueArray *args,
+ GimpProcedureConfig *config,
gpointer run_data)
{
gegl_init (NULL, NULL);
@@ -297,171 +330,133 @@ sel2path_run (GimpProcedure *procedure,
NULL);
}
- fit_set_default_params (&selVals);
+ if (run_mode == GIMP_RUN_INTERACTIVE &&
+ ! sel2path_dialog (procedure, config))
+ return gimp_procedure_new_return_values (procedure,
+ GIMP_PDB_CANCEL,
+ NULL);
- switch (run_mode)
- {
- case GIMP_RUN_INTERACTIVE:
- if (gimp_get_data_size (PLUG_IN_PROC) > 0)
- gimp_get_data (PLUG_IN_PROC, &selVals);
-
- if (! sel2path_dialog (&selVals))
- return gimp_procedure_new_return_values (procedure,
- GIMP_PDB_CANCEL,
- NULL);
-
- /* Get the current settings */
- fit_set_params (&selVals);
- break;
-
- case GIMP_RUN_NONINTERACTIVE:
- selVals.align_threshold = GIMP_VALUES_GET_DOUBLE (args, 0);
- selVals.corner_always_threshold = GIMP_VALUES_GET_DOUBLE (args, 1);
- selVals.corner_surround = GIMP_VALUES_GET_INT (args, 2);
- selVals.corner_threshold = GIMP_VALUES_GET_DOUBLE (args, 3);
- selVals.error_threshold = GIMP_VALUES_GET_DOUBLE (args, 4);
- selVals.filter_alternative_surround = GIMP_VALUES_GET_INT (args, 5);
- selVals.filter_epsilon = GIMP_VALUES_GET_DOUBLE (args, 6);
- selVals.filter_iteration_count = GIMP_VALUES_GET_INT (args, 7);
- selVals.filter_percent = GIMP_VALUES_GET_DOUBLE (args, 8);
- selVals.filter_secondary_surround = GIMP_VALUES_GET_INT (args, 9);
- selVals.filter_surround = GIMP_VALUES_GET_INT (args, 10);
- selVals.keep_knees = GIMP_VALUES_GET_BOOLEAN (args, 11);
- selVals.line_reversion_threshold = GIMP_VALUES_GET_DOUBLE (args, 12);
- selVals.line_threshold = GIMP_VALUES_GET_DOUBLE (args, 13);
- selVals.reparameterize_improvement = GIMP_VALUES_GET_DOUBLE (args, 14);
- selVals.reparameterize_threshold = GIMP_VALUES_GET_DOUBLE (args, 15);
- selVals.subdivide_search = GIMP_VALUES_GET_DOUBLE (args, 16);
- selVals.subdivide_surround = GIMP_VALUES_GET_INT (args, 17);
- selVals.subdivide_threshold = GIMP_VALUES_GET_DOUBLE (args, 18);
- selVals.tangent_surround = GIMP_VALUES_GET_INT (args, 19);
-
- fit_set_params (&selVals);
- break;
-
- case GIMP_RUN_WITH_LAST_VALS:
- if (gimp_get_data_size (PLUG_IN_PROC) > 0)
- {
- gimp_get_data (PLUG_IN_PROC, &selVals);
-
- /* Set up the last values */
- fit_set_params (&selVals);
- }
- break;
-
- default:
- break;
- }
+ fit_set_params (config);
if (! sel2path (image))
return gimp_procedure_new_return_values (procedure,
GIMP_PDB_EXECUTION_ERROR,
NULL);
- dialog_print_selVals (&selVals);
-
- if (run_mode == GIMP_RUN_INTERACTIVE)
- gimp_set_data (PLUG_IN_PROC, &selVals, sizeof(SELVALS));
-
return gimp_procedure_new_return_values (procedure, GIMP_PDB_SUCCESS, NULL);
}
-static void
-dialog_print_selVals (SELVALS *sels)
-{
-#if 0
- printf ("selVals.align_threshold %g\n", selVals.align_threshold);
- printf ("selVals.corner_always_threshol %g\n", selVals.corner_always_threshold);
- printf ("selVals.corner_surround %g\n", selVals.corner_surround);
- printf ("selVals.corner_threshold %g\n", selVals.corner_threshold);
- printf ("selVals.error_threshold %g\n", selVals.error_threshold);
- printf ("selVals.filter_alternative_surround %g\n", selVals.filter_alternative_surround);
- printf ("selVals.filter_epsilon %g\n", selVals.filter_epsilon);
- printf ("selVals.filter_iteration_count %g\n", selVals.filter_iteration_count);
- printf ("selVals.filter_percent %g\n", selVals.filter_percent);
- printf ("selVals.filter_secondary_surround %g\n", selVals.filter_secondary_surround);
- printf ("selVals.filter_surround %g\n", selVals.filter_surround);
- printf ("selVals.keep_knees %d\n", selVals.keep_knees);
- printf ("selVals.line_reversion_threshold %g\n", selVals.line_reversion_threshold);
- printf ("selVals.line_threshold %g\n", selVals.line_threshold);
- printf ("selVals.reparameterize_improvement %g\n", selVals.reparameterize_improvement);
- printf ("selVals.reparameterize_threshold %g\n", selVals.reparameterize_threshold);
- printf ("selVals.subdivide_search %g\n" selVals.subdivide_search);
- printf ("selVals.subdivide_surround %g\n", selVals.subdivide_surround);
- printf ("selVals.subdivide_threshold %g\n", selVals.subdivide_threshold);
- printf ("selVals.tangent_surround %g\n", selVals.tangent_surround);
-#endif /* 0 */
-}
-
/* Build the dialog up. This was the hard part! */
static gint
-sel2path_dialog (SELVALS *sels)
+sel2path_dialog (GimpProcedure *procedure,
+ GimpProcedureConfig *config)
{
- GtkWidget *dlg;
- GtkWidget *table;
-
- retVal = FALSE;
+ GtkWidget *dialog;
+ GtkWidget *vbox;
+ GtkWidget *scrolled_win;
+ gboolean run;
gimp_ui_init (PLUG_IN_BINARY);
- dlg = gimp_dialog_new (_("Selection to Path Advanced Settings"),
- PLUG_IN_ROLE,
- NULL, 0,
- gimp_standard_help_func, PLUG_IN_PROC,
+ dialog = gimp_procedure_dialog_new (procedure,
+ GIMP_PROCEDURE_CONFIG (config),
+ _("Selection to Path Advanced Settings"));
- _("_Reset"), RESPONSE_RESET,
- _("_Cancel"), GTK_RESPONSE_CANCEL,
- _("_OK"), GTK_RESPONSE_OK,
-
- NULL);
-
- gimp_dialog_set_alternative_button_order (GTK_DIALOG (dlg),
+ gimp_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
RESPONSE_RESET,
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
- gimp_window_set_transient (GTK_WINDOW (dlg));
+ gimp_window_set_transient (GTK_WINDOW (dialog));
- g_signal_connect (dlg, "response",
- G_CALLBACK (sel2path_response),
- NULL);
- g_signal_connect (dlg, "destroy",
- G_CALLBACK (gtk_main_quit),
- NULL);
+ gimp_procedure_dialog_get_scale_entry (GIMP_PROCEDURE_DIALOG (dialog),
+ "align-threshold", 1.0);
+ gimp_procedure_dialog_get_scale_entry (GIMP_PROCEDURE_DIALOG (dialog),
+ "corner-always-threshold", 1.0);
+ gimp_procedure_dialog_get_scale_entry (GIMP_PROCEDURE_DIALOG (dialog),
+ "corner-surround", 1.0);
+ gimp_procedure_dialog_get_scale_entry (GIMP_PROCEDURE_DIALOG (dialog),
+ "corner-threshold", 1.0);
+ gimp_procedure_dialog_get_scale_entry (GIMP_PROCEDURE_DIALOG (dialog),
+ "error-threshold", 1.0);
+ gimp_procedure_dialog_get_scale_entry (GIMP_PROCEDURE_DIALOG (dialog),
+ "filter-alternative-surround", 1.0);
+ gimp_procedure_dialog_get_scale_entry (GIMP_PROCEDURE_DIALOG (dialog),
+ "filter-epsilon", 1.0);
+ gimp_procedure_dialog_get_scale_entry (GIMP_PROCEDURE_DIALOG (dialog),
+ "filter-iteration-count", 1.0);
+ gimp_procedure_dialog_get_scale_entry (GIMP_PROCEDURE_DIALOG (dialog),
+ "filter-percent", 1.0);
+ gimp_procedure_dialog_get_scale_entry (GIMP_PROCEDURE_DIALOG (dialog),
+ "filter-secondary-surround", 1.0);
+ gimp_procedure_dialog_get_scale_entry (GIMP_PROCEDURE_DIALOG (dialog),
+ "filter-surround", 1.0);
+ gimp_procedure_dialog_get_scale_entry (GIMP_PROCEDURE_DIALOG (dialog),
+ "line-reversion-threshold", 1.0);
+ gimp_procedure_dialog_get_scale_entry (GIMP_PROCEDURE_DIALOG (dialog),
+ "line-threshold", 1.0);
+ gimp_procedure_dialog_get_scale_entry (GIMP_PROCEDURE_DIALOG (dialog),
+ "reparametrize-improvement", 1.0);
+ gimp_procedure_dialog_get_scale_entry (GIMP_PROCEDURE_DIALOG (dialog),
+ "reparametrize-threshold", 1.0);
+ gimp_procedure_dialog_get_scale_entry (GIMP_PROCEDURE_DIALOG (dialog),
+ "subdivide-search", 1.0);
+ gimp_procedure_dialog_get_scale_entry (GIMP_PROCEDURE_DIALOG (dialog),
+ "subdivide-surround", 1.0);
+ gimp_procedure_dialog_get_scale_entry (GIMP_PROCEDURE_DIALOG (dialog),
+ "subdivide-threshold", 1.0);
+ gimp_procedure_dialog_get_scale_entry (GIMP_PROCEDURE_DIALOG (dialog),
+ "tangent-surround", 1.0);
- table = dialog_create_selection_area (sels);
- gtk_container_set_border_width (GTK_CONTAINER (table), 12);
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))),
- table, TRUE, TRUE, 0);
- gtk_widget_show (table);
+ vbox = gimp_procedure_dialog_fill_box (GIMP_PROCEDURE_DIALOG (dialog),
+ "selection-to-path-box",
+ "align-threshold",
+ "corner-always-threshold",
+ "corner-surround",
+ "corner-threshold",
+ "error-threshold",
+ "filter-alternative-surround",
+ "filter-epsilon",
+ "filter-iteration-count",
+ "filter-percent",
+ "filter-secondary-surround",
+ "filter-surround",
+ "keep-knees",
+ "line-reversion-threshold",
+ "line-threshold",
+ "reparametrize-improvement",
+ "reparametrize-threshold",
+ "subdivide-search",
+ "subdivide-surround",
+ "subdivide-threshold",
+ "tangent-surround",
+ NULL);
+ gtk_box_set_spacing (GTK_BOX (vbox), 12);
- gtk_widget_show (dlg);
+ scrolled_win = gimp_procedure_dialog_fill_scrolled_window (GIMP_PROCEDURE_DIALOG (dialog),
+ "scrollwin",
+ "selection-to-path-box");
+ gtk_widget_set_size_request (scrolled_win, 400, 400);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_win),
+ GTK_SHADOW_NONE);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
+ GTK_POLICY_NEVER,
+ GTK_POLICY_ALWAYS);
+ gtk_scrolled_window_set_overlay_scrolling (GTK_SCROLLED_WINDOW (scrolled_win),
+ FALSE);
- gtk_main ();
+ gimp_procedure_dialog_fill (GIMP_PROCEDURE_DIALOG (dialog),
+ "scrollwin",
+ NULL);
- return retVal;
-}
+ gtk_widget_show (dialog);
-static void
-sel2path_response (GtkWidget *widget,
- gint response_id,
- gpointer data)
-{
- switch (response_id)
- {
- case RESPONSE_RESET:
- reset_adv_dialog ();
- fit_set_params (&selVals);
- break;
+ run = gimp_procedure_dialog_run (GIMP_PROCEDURE_DIALOG (dialog));
- case GTK_RESPONSE_OK:
- retVal = TRUE;
+ gtk_widget_destroy (dialog);
- default:
- gtk_widget_destroy (widget);
- break;
- }
+ return run;
}
guchar