2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-25 06:05:25 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1997-11-25 06:05:25 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1997-11-25 06:05:25 +08:00
|
|
|
* (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
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2000-12-29 23:22:01 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2011-04-28 20:23:33 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-24 07:56:18 +08:00
|
|
|
|
2002-05-03 20:45:22 +08:00
|
|
|
#include "tools-types.h"
|
|
|
|
|
2003-08-22 09:42:57 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
2019-03-08 05:18:03 +08:00
|
|
|
#include "display/gimpdisplayshell.h"
|
|
|
|
#include "display/gimpdisplayshell-transform.h"
|
2013-06-07 17:52:48 +08:00
|
|
|
#include "display/gimptoolgui.h"
|
2017-06-17 09:02:01 +08:00
|
|
|
#include "display/gimptooltransformgrid.h"
|
2001-01-23 21:01:48 +08:00
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
#include "gimpperspectivetool.h"
|
2003-04-16 00:05:52 +08:00
|
|
|
#include "gimptoolcontrol.h"
|
2018-06-10 04:25:03 +08:00
|
|
|
#include "gimptransformgridoptions.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
1998-12-16 08:37:09 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2011-03-28 06:50:46 +08:00
|
|
|
/* index into trans_info array */
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
X0,
|
|
|
|
Y0,
|
|
|
|
X1,
|
|
|
|
Y1,
|
|
|
|
X2,
|
|
|
|
Y2,
|
|
|
|
X3,
|
|
|
|
Y3
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
app: in GimpTransformGridTool, allow linking forward/backward transforms
Add a GimpTransformGridTool::matrix_to_info() virtual function,
which should extract the tool-specific transformation parameters
given a transformation matrix, and the old parameter set (which is
needed in some tools, to derive the parameters that aren't encoded
in the matrix, such as the pivot point). The transformation matrix
can be any combination of matrices calculated by the tool, and
their inverses. Subclasses should only implement this function if
every such matrix can be mapped back to transformation parameters.
This is currently the case for all the transform-grid tools, except
for the shear tool (since it only supports shearing along one of
the horizontal or the vertical directions, however, the combined
matrix may require shearing in both directions).
When a transform-grid tool implements this function, show a chain-
button between the two transform-direction radio-buttons in the
tool options. When the chain-button is linked, whenever the
transform corresponding to the active direction is modified, adjust
the transform corresponding to the non-active direction such that
the overall transform remains the same.
One notable workflow that this enables is transforming a layer
while adjusting a different area than its boundary, by first
defining the area while the transform-directions are linked, and
then transforming the area while the transform-directions are
unlinked.
2019-02-05 04:33:44 +08:00
|
|
|
static void gimp_perspective_tool_matrix_to_info (GimpTransformGridTool *tg_tool,
|
|
|
|
const GimpMatrix3 *transform);
|
2018-06-10 04:25:03 +08:00
|
|
|
static void gimp_perspective_tool_prepare (GimpTransformGridTool *tg_tool);
|
2019-03-08 05:18:03 +08:00
|
|
|
static void gimp_perspective_tool_readjust (GimpTransformGridTool *tg_tool);
|
2018-06-10 04:25:03 +08:00
|
|
|
static GimpToolWidget * gimp_perspective_tool_get_widget (GimpTransformGridTool *tg_tool);
|
2018-06-16 03:42:19 +08:00
|
|
|
static void gimp_perspective_tool_update_widget (GimpTransformGridTool *tg_tool);
|
|
|
|
static void gimp_perspective_tool_widget_changed (GimpTransformGridTool *tg_tool);
|
2018-06-10 04:25:03 +08:00
|
|
|
|
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.
2019-02-04 23:30:18 +08:00
|
|
|
static void gimp_perspective_tool_info_to_points (GimpGenericTransformTool *generic);
|
2001-11-20 02:23:43 +08:00
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
|
2005-12-13 17:13:50 +08:00
|
|
|
G_DEFINE_TYPE (GimpPerspectiveTool, gimp_perspective_tool,
|
2018-01-27 20:21:39 +08:00
|
|
|
GIMP_TYPE_GENERIC_TRANSFORM_TOOL)
|
|
|
|
|
|
|
|
#define parent_class gimp_perspective_tool_parent_class
|
2001-04-25 02:43:31 +08:00
|
|
|
|
2001-07-07 20:17:23 +08:00
|
|
|
|
2003-08-22 09:42:57 +08:00
|
|
|
void
|
2002-03-29 11:50:29 +08:00
|
|
|
gimp_perspective_tool_register (GimpToolRegisterCallback callback,
|
2002-05-03 19:31:08 +08:00
|
|
|
gpointer data)
|
2001-04-25 02:43:31 +08:00
|
|
|
{
|
2002-03-29 11:50:29 +08:00
|
|
|
(* callback) (GIMP_TYPE_PERSPECTIVE_TOOL,
|
2018-06-10 04:25:03 +08:00
|
|
|
GIMP_TYPE_TRANSFORM_GRID_OPTIONS,
|
|
|
|
gimp_transform_grid_options_gui,
|
2015-09-09 03:18:49 +08:00
|
|
|
GIMP_CONTEXT_PROP_MASK_BACKGROUND,
|
2002-03-21 20:17:17 +08:00
|
|
|
"gimp-perspective-tool",
|
2002-11-01 07:06:09 +08:00
|
|
|
_("Perspective"),
|
2006-10-17 17:38:51 +08:00
|
|
|
_("Perspective Tool: "
|
|
|
|
"Change perspective of the layer, selection or path"),
|
2004-04-29 21:19:28 +08:00
|
|
|
N_("_Perspective"), "<shift>P",
|
2003-08-22 09:42:57 +08:00
|
|
|
NULL, GIMP_HELP_TOOL_PERSPECTIVE,
|
2017-03-05 23:01:59 +08:00
|
|
|
GIMP_ICON_TOOL_PERSPECTIVE,
|
2002-05-03 19:31:08 +08:00
|
|
|
data);
|
2001-04-25 02:43:31 +08:00
|
|
|
}
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
static void
|
|
|
|
gimp_perspective_tool_class_init (GimpPerspectiveToolClass *klass)
|
|
|
|
{
|
2018-06-10 04:25:03 +08:00
|
|
|
GimpTransformToolClass *tr_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
|
|
|
|
GimpTransformGridToolClass *tg_class = GIMP_TRANSFORM_GRID_TOOL_CLASS (klass);
|
2018-01-27 20:21:39 +08:00
|
|
|
GimpGenericTransformToolClass *generic_class = GIMP_GENERIC_TRANSFORM_TOOL_CLASS (klass);
|
|
|
|
|
app: in GimpTransformGridTool, allow linking forward/backward transforms
Add a GimpTransformGridTool::matrix_to_info() virtual function,
which should extract the tool-specific transformation parameters
given a transformation matrix, and the old parameter set (which is
needed in some tools, to derive the parameters that aren't encoded
in the matrix, such as the pivot point). The transformation matrix
can be any combination of matrices calculated by the tool, and
their inverses. Subclasses should only implement this function if
every such matrix can be mapped back to transformation parameters.
This is currently the case for all the transform-grid tools, except
for the shear tool (since it only supports shearing along one of
the horizontal or the vertical directions, however, the combined
matrix may require shearing in both directions).
When a transform-grid tool implements this function, show a chain-
button between the two transform-direction radio-buttons in the
tool options. When the chain-button is linked, whenever the
transform corresponding to the active direction is modified, adjust
the transform corresponding to the non-active direction such that
the overall transform remains the same.
One notable workflow that this enables is transforming a layer
while adjusting a different area than its boundary, by first
defining the area while the transform-directions are linked, and
then transforming the area while the transform-directions are
unlinked.
2019-02-05 04:33:44 +08:00
|
|
|
tg_class->matrix_to_info = gimp_perspective_tool_matrix_to_info;
|
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.
2019-02-04 23:30:18 +08:00
|
|
|
tg_class->prepare = gimp_perspective_tool_prepare;
|
2019-03-08 05:18:03 +08:00
|
|
|
tg_class->readjust = gimp_perspective_tool_readjust;
|
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.
2019-02-04 23:30:18 +08:00
|
|
|
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;
|
2018-01-27 20:21:39 +08:00
|
|
|
|
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.
2019-02-04 23:30:18 +08:00
|
|
|
generic_class->info_to_points = gimp_perspective_tool_info_to_points;
|
2018-06-10 04:25:03 +08:00
|
|
|
|
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.
2019-02-04 23:30:18 +08:00
|
|
|
tr_class->undo_desc = C_("undo-type", "Perspective");
|
|
|
|
tr_class->progress_text = _("Perspective transformation");
|
2001-08-14 22:53:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_perspective_tool_init (GimpPerspectiveTool *perspective_tool)
|
|
|
|
{
|
2018-06-10 04:25:03 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (perspective_tool);
|
2001-08-14 22:53:55 +08:00
|
|
|
|
2002-06-17 01:13:39 +08:00
|
|
|
gimp_tool_control_set_tool_cursor (tool->control,
|
2004-06-05 07:08:29 +08:00
|
|
|
GIMP_TOOL_CURSOR_PERSPECTIVE);
|
2018-06-10 04:25:03 +08:00
|
|
|
}
|
2002-11-14 19:54:57 +08:00
|
|
|
|
app: in GimpTransformGridTool, allow linking forward/backward transforms
Add a GimpTransformGridTool::matrix_to_info() virtual function,
which should extract the tool-specific transformation parameters
given a transformation matrix, and the old parameter set (which is
needed in some tools, to derive the parameters that aren't encoded
in the matrix, such as the pivot point). The transformation matrix
can be any combination of matrices calculated by the tool, and
their inverses. Subclasses should only implement this function if
every such matrix can be mapped back to transformation parameters.
This is currently the case for all the transform-grid tools, except
for the shear tool (since it only supports shearing along one of
the horizontal or the vertical directions, however, the combined
matrix may require shearing in both directions).
When a transform-grid tool implements this function, show a chain-
button between the two transform-direction radio-buttons in the
tool options. When the chain-button is linked, whenever the
transform corresponding to the active direction is modified, adjust
the transform corresponding to the non-active direction such that
the overall transform remains the same.
One notable workflow that this enables is transforming a layer
while adjusting a different area than its boundary, by first
defining the area while the transform-directions are linked, and
then transforming the area while the transform-directions are
unlinked.
2019-02-05 04:33:44 +08:00
|
|
|
static void
|
|
|
|
gimp_perspective_tool_matrix_to_info (GimpTransformGridTool *tg_tool,
|
|
|
|
const GimpMatrix3 *transform)
|
|
|
|
{
|
|
|
|
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
|
|
|
|
|
|
|
gimp_matrix3_transform_point (transform,
|
|
|
|
tr_tool->x1,
|
|
|
|
tr_tool->y1,
|
|
|
|
&tg_tool->trans_info[X0],
|
|
|
|
&tg_tool->trans_info[Y0]);
|
|
|
|
gimp_matrix3_transform_point (transform,
|
|
|
|
tr_tool->x2,
|
|
|
|
tr_tool->y1,
|
|
|
|
&tg_tool->trans_info[X1],
|
|
|
|
&tg_tool->trans_info[Y1]);
|
|
|
|
gimp_matrix3_transform_point (transform,
|
|
|
|
tr_tool->x1,
|
|
|
|
tr_tool->y2,
|
|
|
|
&tg_tool->trans_info[X2],
|
|
|
|
&tg_tool->trans_info[Y2]);
|
|
|
|
gimp_matrix3_transform_point (transform,
|
|
|
|
tr_tool->x2,
|
|
|
|
tr_tool->y2,
|
|
|
|
&tg_tool->trans_info[X3],
|
|
|
|
&tg_tool->trans_info[Y3]);
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
2018-06-10 04:25:03 +08:00
|
|
|
gimp_perspective_tool_prepare (GimpTransformGridTool *tg_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2018-06-10 04:25:03 +08:00
|
|
|
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
|
|
|
|
|
|
|
GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->prepare (tg_tool);
|
|
|
|
|
|
|
|
tg_tool->trans_info[X0] = (gdouble) tr_tool->x1;
|
|
|
|
tg_tool->trans_info[Y0] = (gdouble) tr_tool->y1;
|
|
|
|
tg_tool->trans_info[X1] = (gdouble) tr_tool->x2;
|
|
|
|
tg_tool->trans_info[Y1] = (gdouble) tr_tool->y1;
|
|
|
|
tg_tool->trans_info[X2] = (gdouble) tr_tool->x1;
|
|
|
|
tg_tool->trans_info[Y2] = (gdouble) tr_tool->y2;
|
|
|
|
tg_tool->trans_info[X3] = (gdouble) tr_tool->x2;
|
|
|
|
tg_tool->trans_info[Y3] = (gdouble) tr_tool->y2;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2019-03-08 05:18:03 +08:00
|
|
|
static void
|
|
|
|
gimp_perspective_tool_readjust (GimpTransformGridTool *tg_tool)
|
|
|
|
{
|
|
|
|
GimpTool *tool = GIMP_TOOL (tg_tool);
|
|
|
|
GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
|
|
|
|
gdouble x;
|
|
|
|
gdouble y;
|
|
|
|
gdouble r;
|
|
|
|
|
|
|
|
x = shell->disp_width / 2.0;
|
|
|
|
y = shell->disp_height / 2.0;
|
|
|
|
r = MIN (x, y) / G_SQRT2;
|
|
|
|
|
|
|
|
gimp_display_shell_untransform_xy_f (shell,
|
|
|
|
x - r, y - r,
|
|
|
|
&tg_tool->trans_info[X0],
|
|
|
|
&tg_tool->trans_info[Y0]);
|
|
|
|
gimp_display_shell_untransform_xy_f (shell,
|
|
|
|
x + r, y - r,
|
|
|
|
&tg_tool->trans_info[X1],
|
|
|
|
&tg_tool->trans_info[Y1]);
|
|
|
|
gimp_display_shell_untransform_xy_f (shell,
|
|
|
|
x - r, y + r,
|
|
|
|
&tg_tool->trans_info[X2],
|
|
|
|
&tg_tool->trans_info[Y2]);
|
|
|
|
gimp_display_shell_untransform_xy_f (shell,
|
|
|
|
x + r, y + r,
|
|
|
|
&tg_tool->trans_info[X3],
|
|
|
|
&tg_tool->trans_info[Y3]);
|
|
|
|
}
|
|
|
|
|
2017-06-17 09:02:01 +08:00
|
|
|
static GimpToolWidget *
|
2018-06-10 04:25:03 +08:00
|
|
|
gimp_perspective_tool_get_widget (GimpTransformGridTool *tg_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2018-06-10 04:25:03 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (tg_tool);
|
|
|
|
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
|
|
|
GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
|
|
|
|
GimpToolWidget *widget;
|
2017-06-17 09:02:01 +08:00
|
|
|
|
|
|
|
widget = gimp_tool_transform_grid_new (shell,
|
|
|
|
&tr_tool->transform,
|
|
|
|
tr_tool->x1,
|
|
|
|
tr_tool->y1,
|
|
|
|
tr_tool->x2,
|
2017-06-20 05:06:39 +08:00
|
|
|
tr_tool->y2);
|
2017-06-17 09:02:01 +08:00
|
|
|
|
|
|
|
g_object_set (widget,
|
|
|
|
"inside-function", GIMP_TRANSFORM_FUNCTION_PERSPECTIVE,
|
|
|
|
"outside-function", GIMP_TRANSFORM_FUNCTION_PERSPECTIVE,
|
|
|
|
"use-perspective-handles", TRUE,
|
|
|
|
"use-center-handle", TRUE,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
return widget;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-01-05 19:18:38 +08:00
|
|
|
static void
|
2018-06-16 03:42:19 +08:00
|
|
|
gimp_perspective_tool_update_widget (GimpTransformGridTool *tg_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2018-06-10 04:25:03 +08:00
|
|
|
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
|
|
|
|
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.
2019-02-04 23:30:18 +08:00
|
|
|
GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->update_widget (tg_tool);
|
|
|
|
|
2018-06-16 03:42:19 +08:00
|
|
|
g_object_set (tg_tool->widget,
|
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.
2019-02-04 23:30:18 +08:00
|
|
|
"x1", (gdouble) tr_tool->x1,
|
|
|
|
"y1", (gdouble) tr_tool->y1,
|
|
|
|
"x2", (gdouble) tr_tool->x2,
|
|
|
|
"y2", (gdouble) tr_tool->y2,
|
2018-06-16 03:42:19 +08:00
|
|
|
NULL);
|
2018-01-27 20:21:39 +08:00
|
|
|
}
|
|
|
|
|
2017-06-17 09:02:01 +08:00
|
|
|
static void
|
2018-06-16 03:42:19 +08:00
|
|
|
gimp_perspective_tool_widget_changed (GimpTransformGridTool *tg_tool)
|
2017-06-17 09:02:01 +08:00
|
|
|
{
|
2018-06-10 04:25:03 +08:00
|
|
|
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
|
|
|
GimpMatrix3 *transform;
|
2017-06-17 09:02:01 +08:00
|
|
|
|
2018-06-16 03:42:19 +08:00
|
|
|
g_object_get (tg_tool->widget,
|
2017-06-17 09:02:01 +08:00
|
|
|
"transform", &transform,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
gimp_matrix3_transform_point (transform,
|
|
|
|
tr_tool->x1, tr_tool->y1,
|
2018-06-10 04:25:03 +08:00
|
|
|
&tg_tool->trans_info[X0],
|
|
|
|
&tg_tool->trans_info[Y0]);
|
2017-06-17 09:02:01 +08:00
|
|
|
gimp_matrix3_transform_point (transform,
|
|
|
|
tr_tool->x2, tr_tool->y1,
|
2018-06-10 04:25:03 +08:00
|
|
|
&tg_tool->trans_info[X1],
|
|
|
|
&tg_tool->trans_info[Y1]);
|
2017-06-17 09:02:01 +08:00
|
|
|
gimp_matrix3_transform_point (transform,
|
|
|
|
tr_tool->x1, tr_tool->y2,
|
2018-06-10 04:25:03 +08:00
|
|
|
&tg_tool->trans_info[X2],
|
|
|
|
&tg_tool->trans_info[Y2]);
|
2017-06-17 09:02:01 +08:00
|
|
|
gimp_matrix3_transform_point (transform,
|
|
|
|
tr_tool->x2, tr_tool->y2,
|
2018-06-10 04:25:03 +08:00
|
|
|
&tg_tool->trans_info[X3],
|
|
|
|
&tg_tool->trans_info[Y3]);
|
2017-06-17 09:02:01 +08:00
|
|
|
|
|
|
|
g_free (transform);
|
|
|
|
|
2018-06-16 03:42:19 +08:00
|
|
|
GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->widget_changed (tg_tool);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
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.
2019-02-04 23:30:18 +08:00
|
|
|
gimp_perspective_tool_info_to_points (GimpGenericTransformTool *generic)
|
2018-06-16 03:42:19 +08:00
|
|
|
{
|
|
|
|
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (generic);
|
|
|
|
GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (generic);
|
|
|
|
|
|
|
|
generic->input_points[0] = (GimpVector2) {tr_tool->x1, tr_tool->y1};
|
|
|
|
generic->input_points[1] = (GimpVector2) {tr_tool->x2, tr_tool->y1};
|
|
|
|
generic->input_points[2] = (GimpVector2) {tr_tool->x1, tr_tool->y2};
|
|
|
|
generic->input_points[3] = (GimpVector2) {tr_tool->x2, tr_tool->y2};
|
|
|
|
|
|
|
|
generic->output_points[0] = (GimpVector2) {tg_tool->trans_info[X0],
|
|
|
|
tg_tool->trans_info[Y0]};
|
|
|
|
generic->output_points[1] = (GimpVector2) {tg_tool->trans_info[X1],
|
|
|
|
tg_tool->trans_info[Y1]};
|
|
|
|
generic->output_points[2] = (GimpVector2) {tg_tool->trans_info[X2],
|
|
|
|
tg_tool->trans_info[Y2]};
|
|
|
|
generic->output_points[3] = (GimpVector2) {tg_tool->trans_info[X3],
|
|
|
|
tg_tool->trans_info[Y3]};
|
2017-06-17 09:02:01 +08:00
|
|
|
}
|