Commit de8e81f8 authored by Ell's avatar Ell

app: in GimpTransformGridTool, allow simultaneous forward and backward transforms

In GimpTransformGridTool, allow performing simultaneous forward
(normal) and backward (corrective) transforms, by having each
transform direction operate on an independent set of parameters.
In other words, whereas the transform-grid tools previously had a
single transform, which could be applied either normally or
correctively using the "direction" tool-option, they now have two
independent transforms, one applied normally and the other
applied correctively, which are toggled using the "direction"
option.  The overall transform is the combination of the backward
transform, followed by the forward transform.

Another way to think about it, is that the tool transforms a source
shape into a destination shape.  The source shape is defined by the
backward transform, and the destination shape is defined by the
forward transform.  Wherewas previously only one of these shapes
could be controlled (the other shape always being the item bounds),
it's now possible to control both shapes in a single transform.
The next commit will allow modifying both shapes simultaneously,
making this even more useful.

Note that since both transforms start off as the identity, using
only one of the transform directions has the same behavior as
before.
parent 9c3f150e
......@@ -42,11 +42,11 @@
/* local function prototypes */
static void gimp_generic_transform_tool_recalc_matrix (GimpTransformTool *tr_tool);
static void gimp_generic_transform_tool_dialog (GimpTransformGridTool *tg_tool);
static void gimp_generic_transform_tool_dialog_update (GimpTransformGridTool *tg_tool);
static void gimp_generic_transform_tool_prepare (GimpTransformGridTool *tg_tool);
static gboolean gimp_generic_transform_tool_info_to_matrix (GimpTransformGridTool *tg_tool,
GimpMatrix3 *transform);
static void gimp_generic_transform_tool_dialog (GimpTransformGridTool *tg_tool);
static void gimp_generic_transform_tool_dialog_update (GimpTransformGridTool *tg_tool);
static void gimp_generic_transform_tool_prepare (GimpTransformGridTool *tg_tool);
G_DEFINE_TYPE (GimpGenericTransformTool, gimp_generic_transform_tool,
......@@ -58,14 +58,12 @@ G_DEFINE_TYPE (GimpGenericTransformTool, gimp_generic_transform_tool,
static void
gimp_generic_transform_tool_class_init (GimpGenericTransformToolClass *klass)
{
GimpTransformToolClass *tr_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
GimpTransformGridToolClass *tg_class = GIMP_TRANSFORM_GRID_TOOL_CLASS (klass);
tr_class->recalc_matrix = gimp_generic_transform_tool_recalc_matrix;
tg_class->dialog = gimp_generic_transform_tool_dialog;
tg_class->dialog_update = gimp_generic_transform_tool_dialog_update;
tg_class->prepare = gimp_generic_transform_tool_prepare;
tg_class->info_to_matrix = gimp_generic_transform_tool_info_to_matrix;
tg_class->dialog = gimp_generic_transform_tool_dialog;
tg_class->dialog_update = gimp_generic_transform_tool_dialog_update;
tg_class->prepare = gimp_generic_transform_tool_prepare;
}
static void
......@@ -73,21 +71,20 @@ gimp_generic_transform_tool_init (GimpGenericTransformTool *unified_tool)
{
}
static void
gimp_generic_transform_tool_recalc_matrix (GimpTransformTool *tr_tool)
static gboolean
gimp_generic_transform_tool_info_to_matrix (GimpTransformGridTool *tg_tool,
GimpMatrix3 *transform)
{
GimpGenericTransformTool *generic = GIMP_GENERIC_TRANSFORM_TOOL (tr_tool);
GimpGenericTransformTool *generic = GIMP_GENERIC_TRANSFORM_TOOL (tg_tool);
if (GIMP_GENERIC_TRANSFORM_TOOL_GET_CLASS (generic)->recalc_points)
GIMP_GENERIC_TRANSFORM_TOOL_GET_CLASS (generic)->recalc_points (generic);
if (GIMP_GENERIC_TRANSFORM_TOOL_GET_CLASS (generic)->info_to_points)
GIMP_GENERIC_TRANSFORM_TOOL_GET_CLASS (generic)->info_to_points (generic);
gimp_matrix3_identity (&tr_tool->transform);
tr_tool->transform_valid =
gimp_transform_matrix_generic (&tr_tool->transform,
generic->input_points,
generic->output_points);
gimp_matrix3_identity (transform);
GIMP_TRANSFORM_TOOL_CLASS (parent_class)->recalc_matrix (tr_tool);
return gimp_transform_matrix_generic (transform,
generic->input_points,
generic->output_points);
}
static void
......@@ -144,10 +141,14 @@ gimp_generic_transform_tool_dialog (GimpTransformGridTool *tg_tool)
static void
gimp_generic_transform_tool_dialog_update (GimpTransformGridTool *tg_tool)
{
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
GimpGenericTransformTool *generic = GIMP_GENERIC_TRANSFORM_TOOL (tg_tool);
GimpMatrix3 transform;
gboolean transform_valid;
transform_valid = gimp_transform_grid_tool_info_to_matrix (tg_tool,
&transform);
if (tr_tool->transform_valid)
if (transform_valid)
{
gint x, y;
......@@ -160,8 +161,7 @@ gimp_generic_transform_tool_dialog_update (GimpTransformGridTool *tg_tool)
{
gchar buf[32];
g_snprintf (buf, sizeof (buf),
"%10.5f", tr_tool->transform.coeff[y][x]);
g_snprintf (buf, sizeof (buf), "%10.5f", transform.coeff[y][x]);
gtk_label_set_text (GTK_LABEL (generic->matrix_labels[y][x]), buf);
}
......
......@@ -49,7 +49,7 @@ struct _GimpGenericTransformToolClass
GimpTransformGridToolClass parent_class;
/* virtual functions */
void (* recalc_points) (GimpGenericTransformTool *generic);
void (* info_to_points) (GimpGenericTransformTool *generic);
};
......
......@@ -88,7 +88,7 @@ static GimpToolWidget * gimp_handle_transform_tool_get_widget (GimpTransform
static void gimp_handle_transform_tool_update_widget (GimpTransformGridTool *tg_tool);
static void gimp_handle_transform_tool_widget_changed (GimpTransformGridTool *tg_tool);
static void gimp_handle_transform_tool_recalc_points (GimpGenericTransformTool *generic);
static void gimp_handle_transform_tool_info_to_points (GimpGenericTransformTool *generic);
G_DEFINE_TYPE (GimpHandleTransformTool, gimp_handle_transform_tool,
......@@ -123,17 +123,17 @@ gimp_handle_transform_tool_class_init (GimpHandleTransformToolClass *klass)
GimpTransformGridToolClass *tg_class = GIMP_TRANSFORM_GRID_TOOL_CLASS (klass);
GimpGenericTransformToolClass *generic_class = GIMP_GENERIC_TRANSFORM_TOOL_CLASS (klass);
tool_class->modifier_key = gimp_handle_transform_tool_modifier_key;
tool_class->modifier_key = gimp_handle_transform_tool_modifier_key;
tg_class->prepare = gimp_handle_transform_tool_prepare;
tg_class->get_widget = gimp_handle_transform_tool_get_widget;
tg_class->update_widget = gimp_handle_transform_tool_update_widget;
tg_class->widget_changed = gimp_handle_transform_tool_widget_changed;
tg_class->prepare = gimp_handle_transform_tool_prepare;
tg_class->get_widget = gimp_handle_transform_tool_get_widget;
tg_class->update_widget = gimp_handle_transform_tool_update_widget;
tg_class->widget_changed = gimp_handle_transform_tool_widget_changed;
generic_class->recalc_points = gimp_handle_transform_tool_recalc_points;
generic_class->info_to_points = gimp_handle_transform_tool_info_to_points;
tr_class->undo_desc = C_("undo-type", "Handle transform");
tr_class->progress_text = _("Handle transformation");
tr_class->undo_desc = C_("undo-type", "Handle transform");
tr_class->progress_text = _("Handle transformation");
}
static void
......@@ -270,11 +270,16 @@ gimp_handle_transform_tool_get_widget (GimpTransformGridTool *tg_tool)
static void
gimp_handle_transform_tool_update_widget (GimpTransformGridTool *tg_tool)
{
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
GimpMatrix3 transform;
gboolean transform_valid;
GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->update_widget (tg_tool);
transform_valid = gimp_transform_grid_tool_info_to_matrix (tg_tool,
&transform);
g_object_set (tg_tool->widget,
"transform", &tr_tool->transform,
"show-guides", tr_tool->transform_valid,
"show-guides", transform_valid,
"n-handles", (gint) tg_tool->trans_info[N_HANDLES],
"orig-x1", tg_tool->trans_info[OX0],
"orig-y1", tg_tool->trans_info[OY0],
......@@ -326,7 +331,7 @@ gimp_handle_transform_tool_widget_changed (GimpTransformGridTool *tg_tool)
}
static void
gimp_handle_transform_tool_recalc_points (GimpGenericTransformTool *generic)
gimp_handle_transform_tool_info_to_points (GimpGenericTransformTool *generic)
{
GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (generic);
......
......@@ -59,7 +59,7 @@ static GimpToolWidget * gimp_perspective_tool_get_widget (GimpTransformGridT
static void gimp_perspective_tool_update_widget (GimpTransformGridTool *tg_tool);
static void gimp_perspective_tool_widget_changed (GimpTransformGridTool *tg_tool);
static void gimp_perspective_tool_recalc_points (GimpGenericTransformTool *generic);
static void gimp_perspective_tool_info_to_points (GimpGenericTransformTool *generic);
G_DEFINE_TYPE (GimpPerspectiveTool, gimp_perspective_tool,
......@@ -93,15 +93,15 @@ gimp_perspective_tool_class_init (GimpPerspectiveToolClass *klass)
GimpTransformGridToolClass *tg_class = GIMP_TRANSFORM_GRID_TOOL_CLASS (klass);
GimpGenericTransformToolClass *generic_class = GIMP_GENERIC_TRANSFORM_TOOL_CLASS (klass);
tg_class->prepare = gimp_perspective_tool_prepare;
tg_class->get_widget = gimp_perspective_tool_get_widget;
tg_class->update_widget = gimp_perspective_tool_update_widget;
tg_class->widget_changed = gimp_perspective_tool_widget_changed;
tg_class->prepare = gimp_perspective_tool_prepare;
tg_class->get_widget = gimp_perspective_tool_get_widget;
tg_class->update_widget = gimp_perspective_tool_update_widget;
tg_class->widget_changed = gimp_perspective_tool_widget_changed;
generic_class->recalc_points = gimp_perspective_tool_recalc_points;
generic_class->info_to_points = gimp_perspective_tool_info_to_points;
tr_class->undo_desc = C_("undo-type", "Perspective");
tr_class->progress_text = _("Perspective transformation");
tr_class->undo_desc = C_("undo-type", "Perspective");
tr_class->progress_text = _("Perspective transformation");
}
static void
......@@ -160,12 +160,13 @@ gimp_perspective_tool_update_widget (GimpTransformGridTool *tg_tool)
{
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->update_widget (tg_tool);
g_object_set (tg_tool->widget,
"transform", &tr_tool->transform,
"x1", (gdouble) tr_tool->x1,
"y1", (gdouble) tr_tool->y1,
"x2", (gdouble) tr_tool->x2,
"y2", (gdouble) tr_tool->y2,
"x1", (gdouble) tr_tool->x1,
"y1", (gdouble) tr_tool->y1,
"x2", (gdouble) tr_tool->x2,
"y2", (gdouble) tr_tool->y2,
NULL);
}
......@@ -202,7 +203,7 @@ gimp_perspective_tool_widget_changed (GimpTransformGridTool *tg_tool)
}
static void
gimp_perspective_tool_recalc_points (GimpGenericTransformTool *generic)
gimp_perspective_tool_info_to_points (GimpGenericTransformTool *generic)
{
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (generic);
GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (generic);
......
......@@ -61,9 +61,9 @@ static gboolean gimp_rotate_tool_key_press (GimpTool *
GdkEventKey *kevent,
GimpDisplay *display);
static void gimp_rotate_tool_recalc_matrix (GimpTransformTool *tr_tool);
static gchar * gimp_rotate_tool_get_undo_desc (GimpTransformTool *tr_tool);
static gboolean gimp_rotate_tool_info_to_matrix (GimpTransformGridTool *tg_tool,
GimpMatrix3 *transform);
static gchar * gimp_rotate_tool_get_undo_desc (GimpTransformGridTool *tg_tool);
static void gimp_rotate_tool_dialog (GimpTransformGridTool *tg_tool);
static void gimp_rotate_tool_dialog_update (GimpTransformGridTool *tg_tool);
static void gimp_rotate_tool_prepare (GimpTransformGridTool *tg_tool);
......@@ -108,9 +108,8 @@ gimp_rotate_tool_class_init (GimpRotateToolClass *klass)
tool_class->key_press = gimp_rotate_tool_key_press;
tr_class->recalc_matrix = gimp_rotate_tool_recalc_matrix;
tr_class->get_undo_desc = gimp_rotate_tool_get_undo_desc;
tg_class->info_to_matrix = gimp_rotate_tool_info_to_matrix;
tg_class->get_undo_desc = gimp_rotate_tool_get_undo_desc;
tg_class->dialog = gimp_rotate_tool_dialog;
tg_class->dialog_update = gimp_rotate_tool_dialog_update;
tg_class->prepare = gimp_rotate_tool_prepare;
......@@ -169,24 +168,23 @@ gimp_rotate_tool_key_press (GimpTool *tool,
return GIMP_TOOL_CLASS (parent_class)->key_press (tool, kevent, display);
}
static void
gimp_rotate_tool_recalc_matrix (GimpTransformTool *tr_tool)
static gboolean
gimp_rotate_tool_info_to_matrix (GimpTransformGridTool *tg_tool,
GimpMatrix3 *transform)
{
GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (tr_tool);
gimp_matrix3_identity (&tr_tool->transform);
gimp_transform_matrix_rotate_center (&tr_tool->transform,
gimp_matrix3_identity (transform);
gimp_transform_matrix_rotate_center (transform,
tg_tool->trans_info[PIVOT_X],
tg_tool->trans_info[PIVOT_Y],
tg_tool->trans_info[ANGLE]);
GIMP_TRANSFORM_TOOL_CLASS (parent_class)->recalc_matrix (tr_tool);
return TRUE;
}
static gchar *
gimp_rotate_tool_get_undo_desc (GimpTransformTool *tr_tool)
gimp_rotate_tool_get_undo_desc (GimpTransformGridTool *tg_tool)
{
GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (tr_tool);
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
if (tg_tool->trans_info[PIVOT_X] == (tr_tool->x1 + tr_tool->x2) / 2.0 &&
tg_tool->trans_info[PIVOT_Y] == (tr_tool->y1 + tr_tool->y2) / 2.0)
......@@ -362,13 +360,12 @@ gimp_rotate_tool_get_widget (GimpTransformGridTool *tg_tool)
static void
gimp_rotate_tool_update_widget (GimpTransformGridTool *tg_tool)
{
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->update_widget (tg_tool);
g_object_set (tg_tool->widget,
"transform", &tr_tool->transform,
"angle", tg_tool->trans_info[ANGLE],
"pivot-x", tg_tool->trans_info[PIVOT_X],
"pivot-y", tg_tool->trans_info[PIVOT_Y],
"angle", tg_tool->trans_info[ANGLE],
"pivot-x", tg_tool->trans_info[PIVOT_X],
"pivot-y", tg_tool->trans_info[PIVOT_Y],
NULL);
}
......
......@@ -60,9 +60,9 @@ enum
/* local function prototypes */
static void gimp_scale_tool_recalc_matrix (GimpTransformTool *tr_tool);
static gchar * gimp_scale_tool_get_undo_desc (GimpTransformTool *tr_tool);
static gboolean gimp_scale_tool_info_to_matrix (GimpTransformGridTool *tg_tool,
GimpMatrix3 *transform);
static gchar * gimp_scale_tool_get_undo_desc (GimpTransformGridTool *tg_tool);
static void gimp_scale_tool_dialog (GimpTransformGridTool *tg_tool);
static void gimp_scale_tool_dialog_update (GimpTransformGridTool *tg_tool);
static void gimp_scale_tool_prepare (GimpTransformGridTool *tg_tool);
......@@ -103,9 +103,8 @@ gimp_scale_tool_class_init (GimpScaleToolClass *klass)
GimpTransformToolClass *tr_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
GimpTransformGridToolClass *tg_class = GIMP_TRANSFORM_GRID_TOOL_CLASS (klass);
tr_class->recalc_matrix = gimp_scale_tool_recalc_matrix;
tr_class->get_undo_desc = gimp_scale_tool_get_undo_desc;
tg_class->info_to_matrix = gimp_scale_tool_info_to_matrix;
tg_class->get_undo_desc = gimp_scale_tool_get_undo_desc;
tg_class->dialog = gimp_scale_tool_dialog;
tg_class->dialog_update = gimp_scale_tool_dialog_update;
tg_class->prepare = gimp_scale_tool_prepare;
......@@ -126,13 +125,14 @@ gimp_scale_tool_init (GimpScaleTool *scale_tool)
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_RESIZE);
}
static void
gimp_scale_tool_recalc_matrix (GimpTransformTool *tr_tool)
static gboolean
gimp_scale_tool_info_to_matrix (GimpTransformGridTool *tg_tool,
GimpMatrix3 *transform)
{
GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (tr_tool);
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
gimp_matrix3_identity (&tr_tool->transform);
gimp_transform_matrix_scale (&tr_tool->transform,
gimp_matrix3_identity (transform);
gimp_transform_matrix_scale (transform,
tr_tool->x1,
tr_tool->y1,
tr_tool->x2 - tr_tool->x1,
......@@ -142,15 +142,14 @@ gimp_scale_tool_recalc_matrix (GimpTransformTool *tr_tool)
tg_tool->trans_info[X1] - tg_tool->trans_info[X0],
tg_tool->trans_info[Y1] - tg_tool->trans_info[Y0]);
GIMP_TRANSFORM_TOOL_CLASS (parent_class)->recalc_matrix (tr_tool);
return TRUE;
}
static gchar *
gimp_scale_tool_get_undo_desc (GimpTransformTool *tr_tool)
gimp_scale_tool_get_undo_desc (GimpTransformGridTool *tg_tool)
{
GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (tr_tool);
gint width;
gint height;
gint width;
gint height;
width = ROUND (tg_tool->trans_info[X1] - tg_tool->trans_info[X0]);
height = ROUND (tg_tool->trans_info[Y1] - tg_tool->trans_info[Y0]);
......@@ -262,15 +261,16 @@ gimp_scale_tool_update_widget (GimpTransformGridTool *tg_tool)
{
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->update_widget (tg_tool);
g_object_set (
tg_tool->widget,
"transform", &tr_tool->transform,
"x1", (gdouble) tr_tool->x1,
"y1", (gdouble) tr_tool->y1,
"x2", (gdouble) tr_tool->x2,
"y2", (gdouble) tr_tool->y2,
"pivot-x", (tg_tool->trans_info[X0] + tg_tool->trans_info[X1]) / 2.0,
"pivot-y", (tg_tool->trans_info[Y0] + tg_tool->trans_info[Y1]) / 2.0,
"x1", (gdouble) tr_tool->x1,
"y1", (gdouble) tr_tool->y1,
"x2", (gdouble) tr_tool->x2,
"y2", (gdouble) tr_tool->y2,
"pivot-x", (tg_tool->trans_info[X0] + tg_tool->trans_info[X1]) / 2.0,
"pivot-y", (tg_tool->trans_info[Y0] + tg_tool->trans_info[Y1]) / 2.0,
NULL);
}
......
......@@ -55,9 +55,9 @@ enum
/* local function prototypes */
static void gimp_shear_tool_recalc_matrix (GimpTransformTool *tr_tool);
static gchar * gimp_shear_tool_get_undo_desc (GimpTransformTool *tr_tool);
static gboolean gimp_shear_tool_info_to_matrix (GimpTransformGridTool *tg_tool,
GimpMatrix3 *transform);
static gchar * gimp_shear_tool_get_undo_desc (GimpTransformGridTool *tg_tool);
static void gimp_shear_tool_dialog (GimpTransformGridTool *tg_tool);
static void gimp_shear_tool_dialog_update (GimpTransformGridTool *tg_tool);
static void gimp_shear_tool_prepare (GimpTransformGridTool *tg_tool);
......@@ -99,9 +99,8 @@ gimp_shear_tool_class_init (GimpShearToolClass *klass)
GimpTransformToolClass *tr_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
GimpTransformGridToolClass *tg_class = GIMP_TRANSFORM_GRID_TOOL_CLASS (klass);
tr_class->recalc_matrix = gimp_shear_tool_recalc_matrix;
tr_class->get_undo_desc = gimp_shear_tool_get_undo_desc;
tg_class->info_to_matrix = gimp_shear_tool_info_to_matrix;
tg_class->get_undo_desc = gimp_shear_tool_get_undo_desc;
tg_class->dialog = gimp_shear_tool_dialog;
tg_class->dialog_update = gimp_shear_tool_dialog_update;
tg_class->prepare = gimp_shear_tool_prepare;
......@@ -122,11 +121,12 @@ gimp_shear_tool_init (GimpShearTool *shear_tool)
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_SHEAR);
}
static void
gimp_shear_tool_recalc_matrix (GimpTransformTool *tr_tool)
static gboolean
gimp_shear_tool_info_to_matrix (GimpTransformGridTool *tg_tool,
GimpMatrix3 *transform)
{
GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (tr_tool);
gdouble amount;
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
gdouble amount;
if (tg_tool->trans_info[SHEAR_X] == 0.0 &&
tg_tool->trans_info[SHEAR_Y] == 0.0)
......@@ -139,8 +139,8 @@ gimp_shear_tool_recalc_matrix (GimpTransformTool *tr_tool)
else
amount = tg_tool->trans_info[SHEAR_Y];
gimp_matrix3_identity (&tr_tool->transform);
gimp_transform_matrix_shear (&tr_tool->transform,
gimp_matrix3_identity (transform);
gimp_transform_matrix_shear (transform,
tr_tool->x1,
tr_tool->y1,
tr_tool->x2 - tr_tool->x1,
......@@ -148,15 +148,14 @@ gimp_shear_tool_recalc_matrix (GimpTransformTool *tr_tool)
tg_tool->trans_info[ORIENTATION],
amount);
GIMP_TRANSFORM_TOOL_CLASS (parent_class)->recalc_matrix (tr_tool);
return TRUE;
}
static gchar *
gimp_shear_tool_get_undo_desc (GimpTransformTool *tr_tool)
gimp_shear_tool_get_undo_desc (GimpTransformGridTool *tg_tool)
{
GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (tr_tool);
gdouble x = tg_tool->trans_info[SHEAR_X];
gdouble y = tg_tool->trans_info[SHEAR_Y];
gdouble x = tg_tool->trans_info[SHEAR_X];
gdouble y = tg_tool->trans_info[SHEAR_Y];
switch ((gint) tg_tool->trans_info[ORIENTATION])
{
......@@ -256,8 +255,9 @@ gimp_shear_tool_update_widget (GimpTransformGridTool *tg_tool)
{
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->update_widget (tg_tool);
g_object_set (tg_tool->widget,
"transform", &tr_tool->transform,
"x1", (gdouble) tr_tool->x1,
"y1", (gdouble) tr_tool->y1,
"x2", (gdouble) tr_tool->x2,
......
This diff is collapsed.
......@@ -47,17 +47,17 @@ struct _GimpTransformGridTool
{
GimpTransformTool parent_instance;
TransInfo trans_info; /* transformation info */
TransInfo *old_trans_info; /* for resetting everything */
TransInfo *prev_trans_info; /* the current finished state */
TransInfo init_trans_info; /* initial transformation info */
TransInfo trans_infos[2]; /* forward/backward transformation info */
gdouble *trans_info; /* current transformation info */
GList *undo_list; /* list of all states,
head is current == prev_trans_info,
tail is original == old_trans_info */
tail is original == old_trans_info */
GList *redo_list; /* list of all undone states,
NULL when nothing undone */
GimpItem *hidden_item; /* the item that was hidden during
the transform */
the transform */
GimpToolWidget *widget;
GimpToolWidget *grab_widget;
......@@ -74,6 +74,9 @@ struct _GimpTransformGridToolClass
GimpTransformToolClass parent_class;
/* virtual functions */
gboolean (* info_to_matrix) (GimpTransformGridTool *tg_tool,
GimpMatrix3 *transform);
gchar * (* get_undo_desc) (GimpTransformGridTool *tg_tool);
void (* dialog) (GimpTransformGridTool *tg_tool);
void (* dialog_update) (GimpTransformGridTool *tg_tool);
void (* prepare) (GimpTransformGridTool *tg_tool);
......@@ -93,9 +96,12 @@ struct _GimpTransformGridToolClass
};
GType gimp_transform_grid_tool_get_type (void) G_GNUC_CONST;
GType gimp_transform_grid_tool_get_type (void) G_GNUC_CONST;
void gimp_transform_grid_tool_push_internal_undo (GimpTransformGridTool *tg_tool);
gboolean gimp_transform_grid_tool_info_to_matrix (GimpTransformGridTool *tg_tool,
GimpMatrix3 *transform);
void gimp_transform_grid_tool_push_internal_undo (GimpTransformGridTool *tg_tool);
#endif /* __GIMP_TRANSFORM_GRID_TOOL_H__ */
......@@ -87,7 +87,6 @@ gimp_transform_grid_tool_undo_constructed (GObject *object)
{
GimpTransformGridToolUndo *tg_tool_undo = GIMP_TRANSFORM_GRID_TOOL_UNDO (object);
GimpTransformGridTool *tg_tool;
gint i;
G_OBJECT_CLASS (parent_class)->constructed (object);
......@@ -95,8 +94,10 @@ gimp_transform_grid_tool_undo_constructed (GObject *object)
tg_tool = tg_tool_undo->tg_tool;
for (i = 0; i < TRANS_INFO_SIZE; i++)
tg_tool_undo->trans_info[i] = (*tg_tool->old_trans_info)[i];
memcpy (tg_tool_undo->trans_infos[GIMP_TRANSFORM_FORWARD],
tg_tool->init_trans_info, sizeof (TransInfo));
memcpy (tg_tool_undo->trans_infos[GIMP_TRANSFORM_BACKWARD],
tg_tool->init_trans_info, sizeof (TransInfo));
#if 0
if (tg_tool->original)
......@@ -162,18 +163,17 @@ gimp_transform_grid_tool_undo_pop (GimpUndo *undo,
#if 0
TileManager *temp;
#endif
gdouble d;
gint i;
TransInfo temp_trans_infos[2];
tg_tool = tg_tool_undo->tg_tool;
/* swap the transformation information arrays */
for (i = 0; i < TRANS_INFO_SIZE; i++)
{
d = tg_tool_undo->trans_info[i];
tg_tool_undo->trans_info[i] = tg_tool->trans_info[i];
tg_tool->trans_info[i] = d;
}
/* swap the transformation information00 arrays */
memcpy (temp_trans_infos, tg_tool_undo->trans_infos,
sizeof (tg_tool->trans_infos));
memcpy (tg_tool_undo->trans_infos, tg_tool->trans_infos,
sizeof (tg_tool->trans_infos));
memcpy (tg_tool->trans_infos, temp_trans_infos,
sizeof (tg_tool->trans_infos));
#if 0
/* swap the original buffer--the source buffer for repeated transform_grids
......
......@@ -38,7 +38,7 @@ struct _GimpTransformGridToolUndo
GimpUndo parent_instance;
GimpTransformGridTool *tg_tool;
TransInfo trans_info;
TransInfo trans_infos[2];
#if 0
TileManager *original;
#endif
......
......@@ -61,15 +61,16 @@
/* local function prototypes */
static gchar * gimp_transform_tool_real_get_undo_desc (GimpTransformTool *tr_tool);
static GeglBuffer * gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
GimpItem *item,
GeglBuffer *orig_buffer,
gint orig_offset_x,
gint orig_offset_y,
GimpColorProfile **buffer_profile,
gint *new_offset_x,
gint *new_offset_y);
static gchar * gimp_transform_tool_real_get_undo_desc (GimpTransformTool *tr_tool);
static GimpTransformDirection gimp_transform_tool_real_get_direction (GimpTransformTool *tr_tool);
static GeglBuffer * gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
GimpItem *item,
GeglBuffer *orig_buffer,
gint orig_offset_x,
gint orig_offset_y,
GimpColorProfile **buffer_profile,
gint *new_offset_x,
gint *new_offset_y);
static gboolean gimp_transform_tool_confirm (GimpTransformTool *tr_tool,
GimpDisplay *display);
......@@ -88,6 +89,7 @@ gimp_transform_tool_class_init (GimpTransformToolClass *klass)
{
klass->recalc_matrix = NULL;
klass->get_undo_desc = gimp_transform_tool_real_get_undo_desc;
klass->get_direction = gimp_transform_tool_real_get_direction;
klass->transform = gimp_transform_tool_real_transform;
klass->undo_desc = _("Transform");
......@@ -107,6 +109,14 @@ gimp_transform_tool_real_get_undo_desc (GimpTransformTool *tr_tool)
return g_strdup (GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->undo_desc);
}
static GimpTransformDirection
gimp_transform_tool_real_get_direction (GimpTransformTool *tr_tool)
{
GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tr_tool);
return options->direction;
}
static GeglBuffer *
gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
GimpItem *active_item,
......@@ -123,8 +133,11 @@ gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
GimpContext *context = GIMP_CONTEXT (options);
GeglBuffer *ret = NULL;
GimpTransformResize clip = options->clip;
GimpTransformDirection direction;
GimpProgress *progress;
direction = GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->get_direction (tr_tool);
progress = gimp_progress_start (GIMP_PROGRESS (tool), FALSE,
"%s", klass->progress_text);
......@@ -150,7 +163,7 @@ gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
orig_offset_x,
orig_offset_y,
&tr_tool->transform,
options->direction,
direction,
options->interpolation,
clip,
buffer_profile,
......@@ -166,7 +179,7 @@ gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
{
gimp_item_linked_transform (active_item, context,
&tr_tool->transform,
options->direction,
direction,
options->interpolation,
clip,
progress);
......@@ -180,7 +193,7 @@ gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
gimp_item_transform (active_item, context,
&tr_tool->transform,
options->direction,
direction,
options->interpolation,
clip,
progress);
......@@ -207,15 +220,18 @@ gimp_transform_tool_confirm (GimpTransformTool *tr_tool,
if (GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->recalc_matrix)
{
GimpMatrix3 transform;
GeglRectangle selection_bounds;
gboolean selection_empty = TRUE;
GList *items;
GList *iter;
GimpMatrix3 transform;
GimpTransformDirection direction;
GeglRectangle selection_bounds;
gboolean selection_empty = TRUE;
GList *items;
GList *iter;
transform = tr_tool->transform;
direction = GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->get_direction (
tr_tool);
if (options->direction == GIMP_TRANSFORM_BACKWARD)
if (direction == GIMP_TRANSFORM_BACKWARD)
gimp_matrix3_invert (&transform);
if (options->type == GIMP_TRANSFORM_TYPE_LAYER &&
......
......@@ -61,16 +61,17 @@ struct _GimpTransformToolClass
GimpDrawToolClass parent_class;
/* virtual functions */
void (* recalc_matrix) (GimpTransformTool *tr_tool);
gchar * (* get_undo_desc) (GimpTransformTool *tr_tool);
GeglBuffer * (* transform) (GimpTransformTool *tr_tool,
GimpItem *item,
GeglBuffer *orig_buffer,
gint orig_offset_x,
gint orig_offset_y,
GimpColorProfile **buffer_profile,
gint *new_offset_x,
gint *new_offset_y);
void (* recalc_matrix) (GimpTransformTool *tr_tool);
gchar * (* get_undo_desc) (GimpTransformTool *tr_tool);
GimpTransformDirection (* get_direction) (GimpTransformTool *tr_tool);
GeglBuffer * (* transform) (GimpTransformTool *tr_tool,
GimpItem *item,
GeglBuffer *orig_buffer,