mirror of https://github.com/GNOME/gimp.git
fill the original cage position with a plain color + UI
This commit is contained in:
parent
e2a7ef2e32
commit
f44dcf26b3
|
@ -105,6 +105,13 @@ gimp_operation_cage_transform_class_init (GimpOperationCageTransformClass *klass
|
||||||
GIMP_TYPE_CAGE_CONFIG,
|
GIMP_TYPE_CAGE_CONFIG,
|
||||||
G_PARAM_READWRITE |
|
G_PARAM_READWRITE |
|
||||||
G_PARAM_CONSTRUCT));
|
G_PARAM_CONSTRUCT));
|
||||||
|
|
||||||
|
g_object_class_install_property (object_class, GIMP_OPERATION_CAGE_TRANSFORM_PROP_FILL,
|
||||||
|
g_param_spec_boolean ("fill_plain_color",
|
||||||
|
"Blocking render",
|
||||||
|
"Fill the original position of the cage with a plain color",
|
||||||
|
FALSE,
|
||||||
|
G_PARAM_READWRITE));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -141,6 +148,10 @@ gimp_operation_cage_transform_get_property (GObject *object,
|
||||||
g_value_set_object (value, self->config);
|
g_value_set_object (value, self->config);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case GIMP_OPERATION_CAGE_TRANSFORM_PROP_FILL:
|
||||||
|
g_value_set_boolean (value, self->fill_plain_color);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -163,6 +174,10 @@ gimp_operation_cage_transform_set_property (GObject *object,
|
||||||
self->config = g_value_dup_object (value);
|
self->config = g_value_dup_object (value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case GIMP_OPERATION_CAGE_TRANSFORM_PROP_FILL:
|
||||||
|
self->fill_plain_color = g_value_get_boolean (value);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -192,10 +207,11 @@ gimp_operation_cage_transform_process (GeglOperation *operation,
|
||||||
|
|
||||||
gint x, y;
|
gint x, y;
|
||||||
GeglRectangle cage_bb = gimp_cage_config_get_bounding_box (config);
|
GeglRectangle cage_bb = gimp_cage_config_get_bounding_box (config);
|
||||||
GeglRectangle buffer_bb = *gegl_operation_source_get_bounding_box (operation, "input");
|
|
||||||
gfloat *coords = g_slice_alloc ( 2 * sizeof (gfloat));
|
gfloat *coords = g_slice_alloc ( 2 * sizeof (gfloat));
|
||||||
GimpVector2 p1_d, p2_d, p3_d, p4_d;
|
GimpVector2 p1_d, p2_d, p3_d, p4_d;
|
||||||
GimpVector2 p1_s, p2_s, p3_s, p4_s;
|
GimpVector2 p1_s, p2_s, p3_s, p4_s;
|
||||||
|
GimpVector2 plain_color;
|
||||||
|
gboolean plain_color_set = FALSE;
|
||||||
|
|
||||||
/* pre-fill the out buffer with no-displacement coordinate */
|
/* pre-fill the out buffer with no-displacement coordinate */
|
||||||
GeglBufferIterator *it = gegl_buffer_iterator_new (out_buf, roi, NULL, GEGL_BUFFER_WRITE);
|
GeglBufferIterator *it = gegl_buffer_iterator_new (out_buf, roi, NULL, GEGL_BUFFER_WRITE);
|
||||||
|
@ -210,9 +226,23 @@ gimp_operation_cage_transform_process (GeglOperation *operation,
|
||||||
gfloat *output = it->data[0];
|
gfloat *output = it->data[0];
|
||||||
|
|
||||||
while(n_pixels--)
|
while(n_pixels--)
|
||||||
|
{
|
||||||
|
if (oct->fill_plain_color && gimp_cage_config_point_inside(config, x, y))
|
||||||
|
{
|
||||||
|
if (!plain_color_set)
|
||||||
|
{
|
||||||
|
plain_color.x = x;
|
||||||
|
plain_color.y = y;
|
||||||
|
plain_color_set = TRUE;
|
||||||
|
}
|
||||||
|
output[0] = plain_color.x;
|
||||||
|
output[1] = plain_color.y;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
output[0] = x;
|
output[0] = x;
|
||||||
output[1] = y;
|
output[1] = y;
|
||||||
|
}
|
||||||
|
|
||||||
output += 2;
|
output += 2;
|
||||||
|
|
||||||
|
@ -255,7 +285,7 @@ gimp_operation_cage_transform_process (GeglOperation *operation,
|
||||||
{
|
{
|
||||||
gimp_operation_cage_transform_interpolate_source_coords_recurs (oct,
|
gimp_operation_cage_transform_interpolate_source_coords_recurs (oct,
|
||||||
out_buf,
|
out_buf,
|
||||||
&buffer_bb,
|
roi,
|
||||||
p1_s, p1_d,
|
p1_s, p1_d,
|
||||||
p2_s, p2_d,
|
p2_s, p2_d,
|
||||||
p3_s, p3_d,
|
p3_s, p3_d,
|
||||||
|
@ -264,7 +294,7 @@ gimp_operation_cage_transform_process (GeglOperation *operation,
|
||||||
|
|
||||||
gimp_operation_cage_transform_interpolate_source_coords_recurs (oct,
|
gimp_operation_cage_transform_interpolate_source_coords_recurs (oct,
|
||||||
out_buf,
|
out_buf,
|
||||||
&buffer_bb,
|
roi,
|
||||||
p1_s, p1_d,
|
p1_s, p1_d,
|
||||||
p3_s, p3_d,
|
p3_s, p3_d,
|
||||||
p4_s, p4_d,
|
p4_s, p4_d,
|
||||||
|
@ -344,8 +374,8 @@ gimp_operation_cage_transform_interpolate_source_coords_recurs (GimpOperationCag
|
||||||
rect.x = xmax;
|
rect.x = xmax;
|
||||||
rect.y = ymax;
|
rect.y = ymax;
|
||||||
|
|
||||||
x = (gfloat) xmax;
|
x = (gdouble) xmax;
|
||||||
y = (gfloat) ymax;
|
y = (gdouble) ymax;
|
||||||
|
|
||||||
denom = (p2_d.x - p1_d.x) * p3_d.y + (p1_d.x - p3_d.x) * p2_d.y + (p3_d.x - p2_d.x) * p1_d.y;
|
denom = (p2_d.x - p1_d.x) * p3_d.y + (p1_d.x - p3_d.x) * p2_d.y + (p3_d.x - p2_d.x) * p1_d.y;
|
||||||
a = ((p2_d.x - x) * p3_d.y + (x - p3_d.x) * p2_d.y + (p3_d.x - p2_d.x) * y) / denom;
|
a = ((p2_d.x - x) * p3_d.y + (x - p3_d.x) * p2_d.y + (p3_d.x - p2_d.x) * y) / denom;
|
||||||
|
|
|
@ -26,7 +26,8 @@
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
GIMP_OPERATION_CAGE_TRANSFORM_PROP_0,
|
GIMP_OPERATION_CAGE_TRANSFORM_PROP_0,
|
||||||
GIMP_OPERATION_CAGE_TRANSFORM_PROP_CONFIG
|
GIMP_OPERATION_CAGE_TRANSFORM_PROP_CONFIG,
|
||||||
|
GIMP_OPERATION_CAGE_TRANSFORM_PROP_FILL
|
||||||
};
|
};
|
||||||
|
|
||||||
#define GIMP_TYPE_OPERATION_CAGE_TRANSFORM (gimp_operation_cage_transform_get_type ())
|
#define GIMP_TYPE_OPERATION_CAGE_TRANSFORM (gimp_operation_cage_transform_get_type ())
|
||||||
|
@ -44,6 +45,8 @@ struct _GimpOperationCageTransform
|
||||||
GeglOperationComposer parent_instance;
|
GeglOperationComposer parent_instance;
|
||||||
|
|
||||||
GimpCageConfig *config;
|
GimpCageConfig *config;
|
||||||
|
gboolean fill_plain_color;
|
||||||
|
|
||||||
Babl *format_coords;
|
Babl *format_coords;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,8 @@
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_CAGE_MODE
|
PROP_CAGE_MODE,
|
||||||
|
PROP_FILL_PLAIN_COLOR
|
||||||
};
|
};
|
||||||
|
|
||||||
static void gimp_cage_options_set_property (GObject *object,
|
static void gimp_cage_options_set_property (GObject *object,
|
||||||
|
@ -75,6 +76,11 @@ gimp_cage_options_class_init (GimpCageOptionsClass *klass)
|
||||||
GIMP_TYPE_CAGE_MODE,
|
GIMP_TYPE_CAGE_MODE,
|
||||||
GIMP_CAGE_MODE_CAGE_CHANGE,
|
GIMP_CAGE_MODE_CAGE_CHANGE,
|
||||||
GIMP_PARAM_STATIC_STRINGS);
|
GIMP_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
|
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_FILL_PLAIN_COLOR,
|
||||||
|
"fill-plain-color", NULL,
|
||||||
|
FALSE,
|
||||||
|
GIMP_PARAM_STATIC_STRINGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -97,6 +103,10 @@ gimp_cage_options_set_property (GObject *object,
|
||||||
options->cage_mode = g_value_get_enum (value);
|
options->cage_mode = g_value_get_enum (value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_FILL_PLAIN_COLOR:
|
||||||
|
options->fill_plain_color = g_value_get_boolean (value);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -117,6 +127,10 @@ gimp_cage_options_get_property (GObject *object,
|
||||||
g_value_set_enum (value, options->cage_mode);
|
g_value_set_enum (value, options->cage_mode);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_FILL_PLAIN_COLOR:
|
||||||
|
g_value_set_boolean (value, options->fill_plain_color);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -130,6 +144,7 @@ gimp_cage_options_gui (GimpToolOptions *tool_options)
|
||||||
GtkWidget *vbox = gimp_tool_options_gui (tool_options);
|
GtkWidget *vbox = gimp_tool_options_gui (tool_options);
|
||||||
GtkWidget *hbox;
|
GtkWidget *hbox;
|
||||||
GtkWidget *mode;
|
GtkWidget *mode;
|
||||||
|
GtkWidget *button;
|
||||||
|
|
||||||
hbox = gtk_hbox_new (FALSE, 2);
|
hbox = gtk_hbox_new (FALSE, 2);
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||||
|
@ -140,5 +155,11 @@ gimp_cage_options_gui (GimpToolOptions *tool_options)
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), mode, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox), mode, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (mode);
|
gtk_widget_show (mode);
|
||||||
|
|
||||||
|
|
||||||
|
button = gimp_prop_check_button_new (config, "fill-plain-color",
|
||||||
|
_("Fill the original cage position with a plain color"));
|
||||||
|
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
||||||
|
gtk_widget_show (button);
|
||||||
|
|
||||||
return vbox;
|
return vbox;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ struct _GimpCageOptions
|
||||||
GimpTransformOptions parent_instance;
|
GimpTransformOptions parent_instance;
|
||||||
|
|
||||||
GimpCageMode cage_mode;
|
GimpCageMode cage_mode;
|
||||||
|
gboolean fill_plain_color;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -673,7 +673,6 @@ gimp_cage_tool_compute_coef (GimpCageTool *ct,
|
||||||
GimpCageConfig *config = ct->config;
|
GimpCageConfig *config = ct->config;
|
||||||
|
|
||||||
Babl *format;
|
Babl *format;
|
||||||
GeglRectangle rect;
|
|
||||||
GeglNode *gegl, *input, *output;
|
GeglNode *gegl, *input, *output;
|
||||||
GeglProcessor *processor;
|
GeglProcessor *processor;
|
||||||
GimpProgress *progress;
|
GimpProgress *progress;
|
||||||
|
@ -687,7 +686,10 @@ gimp_cage_tool_compute_coef (GimpCageTool *ct,
|
||||||
}
|
}
|
||||||
|
|
||||||
format = babl_format_n(babl_type("float"), config->cage_vertice_number * 2);
|
format = babl_format_n(babl_type("float"), config->cage_vertice_number * 2);
|
||||||
rect = gimp_cage_config_get_bounding_box (config);
|
|
||||||
|
progress = gimp_progress_start (GIMP_PROGRESS (display),
|
||||||
|
_("Coefficient computation"),
|
||||||
|
FALSE);
|
||||||
|
|
||||||
gegl = gegl_node_new ();
|
gegl = gegl_node_new ();
|
||||||
|
|
||||||
|
@ -705,11 +707,6 @@ gimp_cage_tool_compute_coef (GimpCageTool *ct,
|
||||||
gegl_node_connect_to (input, "output",
|
gegl_node_connect_to (input, "output",
|
||||||
output, "input");
|
output, "input");
|
||||||
|
|
||||||
|
|
||||||
progress = gimp_progress_start (GIMP_PROGRESS (display),
|
|
||||||
_("Coefficient computation"),
|
|
||||||
FALSE);
|
|
||||||
|
|
||||||
processor = gegl_node_new_processor (output, NULL);
|
processor = gegl_node_new_processor (output, NULL);
|
||||||
|
|
||||||
while (gegl_processor_work (processor, &value))
|
while (gegl_processor_work (processor, &value))
|
||||||
|
@ -728,6 +725,7 @@ static void
|
||||||
gimp_cage_tool_process (GimpCageTool *ct,
|
gimp_cage_tool_process (GimpCageTool *ct,
|
||||||
GimpDisplay *display)
|
GimpDisplay *display)
|
||||||
{
|
{
|
||||||
|
GimpCageOptions *options = GIMP_CAGE_TOOL_GET_OPTIONS (ct);
|
||||||
TileManager *new_tiles;
|
TileManager *new_tiles;
|
||||||
GeglRectangle rect;
|
GeglRectangle rect;
|
||||||
|
|
||||||
|
@ -783,6 +781,7 @@ gimp_cage_tool_process (GimpCageTool *ct,
|
||||||
cage = gegl_node_new_child (gegl,
|
cage = gegl_node_new_child (gegl,
|
||||||
"operation", "gimp:cage_transform",
|
"operation", "gimp:cage_transform",
|
||||||
"config", ct->config,
|
"config", ct->config,
|
||||||
|
"fill_plain_color", options->fill_plain_color,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
coef = gegl_node_new_child (gegl,
|
coef = gegl_node_new_child (gegl,
|
||||||
|
|
Loading…
Reference in New Issue