app: npd-tool: add provisional tool's options
This commit is contained in:
committed by
Michael Natterer
parent
b4ae7c7f61
commit
b1059d9461
@ -27,11 +27,24 @@
|
||||
|
||||
#include "tools-types.h"
|
||||
|
||||
#include "widgets/gimppropwidgets.h"
|
||||
#include "widgets/gimpspinscale.h"
|
||||
|
||||
#include "gimpnpointdeformationoptions.h"
|
||||
#include "gimptooloptions-gui.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_SQUARE_SIZE,
|
||||
PROP_RIGIDITY,
|
||||
PROP_ASAP_DEFORMATION,
|
||||
PROP_MLS_WEIGHTS,
|
||||
PROP_MLS_WEIGHTS_ALPHA
|
||||
};
|
||||
|
||||
|
||||
static void gimp_n_point_deformation_options_set_property (GObject *object,
|
||||
guint property_id,
|
||||
@ -57,6 +70,30 @@ gimp_n_point_deformation_options_class_init (GimpNPointDeformationOptionsClass *
|
||||
object_class->set_property = gimp_n_point_deformation_options_set_property;
|
||||
object_class->get_property = gimp_n_point_deformation_options_get_property;
|
||||
|
||||
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_SQUARE_SIZE,
|
||||
"square-size", _("Square Size"),
|
||||
5.0, 1000.0, 20.0,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_RIGIDITY,
|
||||
"rigidity", _("Rigidity"),
|
||||
1.0, 10000.0, 100.0,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_ASAP_DEFORMATION,
|
||||
"ASAP-deformation", _("Deformation Type"),
|
||||
FALSE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_MLS_WEIGHTS,
|
||||
"MLS-weights", _("MLS Weights"),
|
||||
FALSE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_MLS_WEIGHTS_ALPHA,
|
||||
"MLS-weights-alpha", _("MLS Weights Alpha"),
|
||||
0.1, 2.0, 1.0,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -70,8 +107,29 @@ gimp_n_point_deformation_options_set_property (GObject *object,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
// GimpNPointDeformationOptions *options = GIMP_N_POINT_DEFORMATION_OPTIONS (object);
|
||||
GimpNPointDeformationOptions *options = GIMP_N_POINT_DEFORMATION_OPTIONS (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_SQUARE_SIZE:
|
||||
options->square_size = g_value_get_double (value);
|
||||
break;
|
||||
case PROP_RIGIDITY:
|
||||
options->rigidity = g_value_get_double (value);
|
||||
break;
|
||||
case PROP_ASAP_DEFORMATION:
|
||||
options->ASAP_deformation = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_MLS_WEIGHTS:
|
||||
options->MLS_weights = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_MLS_WEIGHTS_ALPHA:
|
||||
options->square_size = g_value_get_double (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -80,15 +138,61 @@ gimp_n_point_deformation_options_get_property (GObject *object,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
// GimpNPointDeformationOptions *options = GIMP_N_POINT_DEFORMATION_OPTIONS (object);
|
||||
GimpNPointDeformationOptions *options = GIMP_N_POINT_DEFORMATION_OPTIONS (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_SQUARE_SIZE:
|
||||
g_value_set_double (value, options->square_size);
|
||||
break;
|
||||
case PROP_RIGIDITY:
|
||||
g_value_set_double (value, options->rigidity);
|
||||
break;
|
||||
case PROP_ASAP_DEFORMATION:
|
||||
g_value_set_boolean (value, options->ASAP_deformation);
|
||||
break;
|
||||
case PROP_MLS_WEIGHTS:
|
||||
g_value_set_boolean (value, options->MLS_weights);
|
||||
break;
|
||||
case PROP_MLS_WEIGHTS_ALPHA:
|
||||
g_value_set_double (value, options->square_size);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gimp_n_point_deformation_options_gui (GimpToolOptions *tool_options)
|
||||
{
|
||||
// GObject *config = G_OBJECT (tool_options);
|
||||
GObject *config = G_OBJECT (tool_options);
|
||||
GtkWidget *vbox = gimp_tool_options_gui (tool_options);
|
||||
GtkWidget *combo;
|
||||
GtkWidget *scale;
|
||||
|
||||
scale = gimp_prop_spin_scale_new (config, "square-size", _("Square Size"), 1.0, 10.0, 0);
|
||||
gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale), 5.0, 1000.0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
|
||||
gtk_widget_show (scale);
|
||||
|
||||
scale = gimp_prop_spin_scale_new (config, "rigidity", _("Rigidity"), 1.0, 10.0, 0);
|
||||
gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale), 1.0, 10000.0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
|
||||
gtk_widget_show (scale);
|
||||
|
||||
combo = gimp_prop_boolean_combo_box_new (config, "ASAP-deformation", _("ASAP"), _("ARAP"));
|
||||
gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, FALSE, 0);
|
||||
gtk_widget_show (combo);
|
||||
|
||||
combo = gimp_prop_boolean_combo_box_new (config, "MLS-weights", _("Enabled"), _("Disabled"));
|
||||
gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, FALSE, 0);
|
||||
gtk_widget_show (combo);
|
||||
|
||||
scale = gimp_prop_spin_scale_new (config, "MLS-weights-alpha", _("MLS Weights Alpha"), 0.1, 0.1, 1);
|
||||
gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale), 0.1, 2.0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
|
||||
gtk_widget_show (scale);
|
||||
|
||||
return vbox;
|
||||
}
|
||||
|
||||
|
||||
@ -38,6 +38,12 @@ typedef struct _GimpNPointDeformationOptionsClass GimpNPointDeformationOptionsCl
|
||||
struct _GimpNPointDeformationOptions
|
||||
{
|
||||
GimpToolOptions parent_instance;
|
||||
|
||||
gdouble square_size;
|
||||
gdouble rigidity;
|
||||
gboolean ASAP_deformation;
|
||||
gboolean MLS_weights;
|
||||
gdouble MLS_weights_alpha;
|
||||
};
|
||||
|
||||
struct _GimpNPointDeformationOptionsClass
|
||||
|
||||
@ -57,6 +57,8 @@
|
||||
void gimp_n_point_deformation_tool_start (GimpNPointDeformationTool *npd_tool,
|
||||
GimpDisplay *display);
|
||||
void gimp_n_point_deformation_tool_halt (GimpNPointDeformationTool *npd_tool);
|
||||
static void gimp_n_point_deformation_tool_set_options (GeglNode *npd_node,
|
||||
GimpNPointDeformationOptions *npd_options);
|
||||
static void gimp_n_point_deformation_tool_options_notify (GimpTool *tool,
|
||||
GimpToolOptions *options,
|
||||
const GParamSpec *pspec);
|
||||
@ -234,9 +236,12 @@ gimp_n_point_deformation_tool_start (GimpNPointDeformationTool *npd_tool,
|
||||
sink = gegl_node_new_child (graph, "operation", "gegl:write-buffer",
|
||||
"buffer", shadow,
|
||||
NULL);
|
||||
|
||||
gegl_node_link_many (source, node, sink, NULL);
|
||||
|
||||
gegl_node_link_many (source, node, sink, NULL);
|
||||
|
||||
gimp_n_point_deformation_tool_set_options (node,
|
||||
GIMP_N_POINT_DEFORMATION_TOOL_GET_OPTIONS (npd_tool));
|
||||
|
||||
gegl_node_process (sink);
|
||||
|
||||
gegl_node_get (node, "model", &model, NULL);
|
||||
@ -267,11 +272,38 @@ gimp_n_point_deformation_tool_halt (GimpNPointDeformationTool *npd_tool)
|
||||
tool->display = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_n_point_deformation_tool_set_options (GeglNode *npd_node,
|
||||
GimpNPointDeformationOptions *npd_options)
|
||||
{
|
||||
gegl_node_set (npd_node,
|
||||
"square size", (int) npd_options->square_size,
|
||||
"rigidity", (int) npd_options->rigidity,
|
||||
"ASAP deformation", npd_options->ASAP_deformation,
|
||||
"MLS weights", npd_options->MLS_weights,
|
||||
"MLS weights alpha", npd_options->MLS_weights_alpha,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_n_point_deformation_tool_options_notify (GimpTool *tool,
|
||||
GimpToolOptions *options,
|
||||
const GParamSpec *pspec)
|
||||
{
|
||||
GimpNPointDeformationTool *npd_tool = GIMP_N_POINT_DEFORMATION_TOOL (tool);
|
||||
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
|
||||
GimpNPointDeformationOptions *npd_options = GIMP_N_POINT_DEFORMATION_OPTIONS (options);
|
||||
|
||||
GIMP_TOOL_CLASS (parent_class)->options_notify (tool, options, pspec);
|
||||
|
||||
if (!npd_tool->active) return;
|
||||
|
||||
gimp_draw_tool_pause (draw_tool);
|
||||
|
||||
gimp_npd_debug (("npd options notify\n"));
|
||||
gimp_n_point_deformation_tool_set_options (npd_tool->node, npd_options);
|
||||
|
||||
gimp_draw_tool_resume (draw_tool);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
||||
Reference in New Issue
Block a user