Commit 615035c1 authored by Ell's avatar Ell

app, cursors: add GimpToolTransform3DGrid tool widget

Add a new GimpToolTransform3DGrid tool widget, subclassed from
GimpToolTransformGrid, which can be used to perform 3D
transformations.

The widget can be in one of three modes:

  CAMERA - allows adjusting the primary vanishing point by moving a
  handle.

  MOVE   - allows moving the object through dragging.

  ROTATE - allows rotating the object through dragging.

By default, controlling the transformation through dragging applies
to the X and Y axes.  Holding Shift (or setting the "constrain-
axis" property) restricts the motion to only one of the axes.

For the MOVE and ROTATE mode, holding Ctrl (or setting the "z-axis"
property) allows controlling the Z axis instead.

For the same modes, holding Alt (or setting the "local-frame"
property), applies the adjustments in the object's local frame of
reference, instead of the display's global frame of reference.
parent 4ddf1afb
......@@ -194,6 +194,8 @@ libappdisplay_a_sources = \
gimptoolrotategrid.h \
gimptoolsheargrid.c \
gimptoolsheargrid.h \
gimptooltransform3dgrid.c \
gimptooltransform3dgrid.h \
gimptooltransformgrid.c \
gimptooltransformgrid.h \
gimptoolwidget.c \
......
......@@ -389,6 +389,37 @@ gimp_rectangle_precision_get_type (void)
return type;
}
GType
gimp_transform_3d_mode_get_type (void)
{
static const GEnumValue values[] =
{
{ GIMP_TRANSFORM_3D_MODE_CAMERA, "GIMP_TRANSFORM_3D_MODE_CAMERA", "camera" },
{ GIMP_TRANSFORM_3D_MODE_MOVE, "GIMP_TRANSFORM_3D_MODE_MOVE", "move" },
{ GIMP_TRANSFORM_3D_MODE_ROTATE, "GIMP_TRANSFORM_3D_MODE_ROTATE", "rotate" },
{ 0, NULL, NULL }
};
static const GimpEnumDesc descs[] =
{
{ GIMP_TRANSFORM_3D_MODE_CAMERA, "GIMP_TRANSFORM_3D_MODE_CAMERA", NULL },
{ GIMP_TRANSFORM_3D_MODE_MOVE, "GIMP_TRANSFORM_3D_MODE_MOVE", NULL },
{ GIMP_TRANSFORM_3D_MODE_ROTATE, "GIMP_TRANSFORM_3D_MODE_ROTATE", NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (G_UNLIKELY (! type))
{
type = g_enum_register_static ("GimpTransform3DMode", values);
gimp_type_set_translation_context (type, "transform3-dmode");
gimp_enum_set_value_descriptions (type, descs);
}
return type;
}
GType
gimp_transform_function_get_type (void)
{
......
......@@ -171,6 +171,18 @@ typedef enum
} GimpRectanglePrecision;
#define GIMP_TYPE_TRANSFORM_3D_MODE (gimp_transform_3d_mode_get_type ())
GType gimp_transform_3d_mode_get_type (void) G_GNUC_CONST;
typedef enum /*< lowercase_name=gimp_transform_3d_mode >*/
{
GIMP_TRANSFORM_3D_MODE_CAMERA,
GIMP_TRANSFORM_3D_MODE_MOVE,
GIMP_TRANSFORM_3D_MODE_ROTATE
} GimpTransform3DMode;
#define GIMP_TYPE_TRANSFORM_FUNCTION (gimp_transform_function_get_type ())
GType gimp_transform_function_get_type (void) G_GNUC_CONST;
......
This diff is collapsed.
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimptool3dtransformgrid.h
* Copyright (C) 2019 Ell
*
* 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 <https://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_TOOL_TRANSFORM_3D_GRID_H__
#define __GIMP_TOOL_TRANSFORM_3D_GRID_H__
#include "gimptooltransformgrid.h"
#define GIMP_TYPE_TOOL_TRANSFORM_3D_GRID (gimp_tool_transform_3d_grid_get_type ())
#define GIMP_TOOL_TRANSFORM_3D_GRID(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TOOL_TRANSFORM_3D_GRID, GimpToolTransform3DGrid))
#define GIMP_TOOL_TRANSFORM_3D_GRID_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TOOL_TRANSFORM_3D_GRID, GimpToolTransform3DGridClass))
#define GIMP_IS_TOOL_TRANSFORM_3D_GRID(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_TOOL_TRANSFORM_3D_GRID))
#define GIMP_IS_TOOL_TRANSFORM_3D_GRID_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_TOOL_TRANSFORM_3D_GRID))
#define GIMP_TOOL_TRANSFORM_3D_GRID_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_TOOL_TRANSFORM_3D_GRID, GimpToolTransform3DGridClass))
typedef struct _GimpToolTransform3DGrid GimpToolTransform3DGrid;
typedef struct _GimpToolTransform3DGridPrivate GimpToolTransform3DGridPrivate;
typedef struct _GimpToolTransform3DGridClass GimpToolTransform3DGridClass;
struct _GimpToolTransform3DGrid
{
GimpToolTransformGrid parent_instance;
GimpToolTransform3DGridPrivate *priv;
};
struct _GimpToolTransform3DGridClass
{
GimpToolTransformGridClass parent_class;
};
GType gimp_tool_transform_3d_grid_get_type (void) G_GNUC_CONST;
GimpToolWidget * gimp_tool_transform_3d_grid_new (GimpDisplayShell *shell,
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2,
gdouble camera_x,
gdouble camera_y,
gdouble camera_z);
#endif /* __GIMP_TOOL_TRANSFORM_3D_GRID_H__ */
......@@ -98,6 +98,7 @@ libappdisplay_sources = [
'gimptoolrectangle.c',
'gimptoolrotategrid.c',
'gimptoolsheargrid.c',
'gimptooltransform3dgrid.c',
'gimptooltransformgrid.c',
'gimptoolwidget.c',
'gimptoolwidgetgroup.c',
......
......@@ -174,6 +174,7 @@ static GimpCursor gimp_tool_cursors[] =
{ "tool-rotate" },
{ "tool-shear" },
{ "tool-perspective" },
{ "tool-transform-3d-camera" },
{ "tool-flip-horizontal" },
{ "tool-flip-vertical" },
{ "tool-text" },
......
......@@ -226,6 +226,7 @@ typedef enum /*< skip >*/
GIMP_TOOL_CURSOR_ROTATE,
GIMP_TOOL_CURSOR_SHEAR,
GIMP_TOOL_CURSOR_PERSPECTIVE,
GIMP_TOOL_CURSOR_TRANSFORM_3D_CAMERA,
GIMP_TOOL_CURSOR_FLIP_HORIZONTAL,
GIMP_TOOL_CURSOR_FLIP_VERTICAL,
GIMP_TOOL_CURSOR_TEXT,
......
......@@ -151,6 +151,8 @@ CURSOR_IMAGES = \
tool-smudge-x2.png \
tool-text.png \
tool-text-x2.png \
tool-transform-3d-camera.png \
tool-transform-3d-camera-x2.png \
tool-warp.png \
tool-warp-x2.png \
tool-zoom.png \
......
......@@ -149,6 +149,8 @@ tool_cursors = [
'tool-smudge-x2.png',
'tool-text.png',
'tool-text-x2.png',
'tool-transform-3d-camera.png',
'tool-transform-3d-camera-x2.png',
'tool-warp.png',
'tool-warp-x2.png',
'tool-zoom.png',
......
......@@ -270,6 +270,7 @@ app/display/gimptoolline.c
app/display/gimptoolpath.c
app/display/gimptoolpolygon.c
app/display/gimptoolrectangle.c
app/display/gimptooltransform3dgrid.c
app/display/gimptooltransformgrid.c
app/file/file-open.c
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment