mirror of https://github.com/GNOME/gimp.git
Enabled the rest of the transform tools and changed some of the options
Enabled the rest of the transform tools and changed some of the options stuff in transform_options_new(). There are one or two outstanding (non-critical) runtime problems in that function.
This commit is contained in:
parent
6c0ad19af9
commit
24c39e398a
|
@ -79,10 +79,6 @@ struct _TransformOptions
|
|||
{
|
||||
ToolOptions tool_options;
|
||||
|
||||
GtkType type;
|
||||
GtkType type_d;
|
||||
GtkWidget *type_w[4]; /* 4 radio buttons */
|
||||
|
||||
gboolean smoothing;
|
||||
gboolean smoothing_d;
|
||||
GtkWidget *smoothing_w;
|
||||
|
@ -167,8 +163,6 @@ static void gimp_transform_tool_control (GimpTool *tool,
|
|||
|
||||
static void gimp_transform_tool_draw (GimpDrawTool *draw_tool);
|
||||
|
||||
static void gimp_transform_tool_change_type (GtkType new_type);
|
||||
|
||||
static TransformOptions * transform_options_new (void);
|
||||
static void transform_options_reset (ToolOptions *tool_options);
|
||||
|
||||
|
@ -1791,16 +1785,6 @@ gimp_transform_tool_show_path_update (GtkWidget *widget,
|
|||
gimp_transform_tool_showpath_changed (0); /* resume */
|
||||
}
|
||||
|
||||
/* FIXME Do we still want to do this this way? Perhaps we should make
|
||||
separate icons for each tool. */
|
||||
|
||||
static void
|
||||
gimp_transform_tool_type_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
gimp_transform_tool_change_type ((GtkType) data);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_tool_direction_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
|
@ -1830,15 +1814,6 @@ transform_options_reset (ToolOptions *tool_options)
|
|||
|
||||
options = (TransformOptions *) tool_options;
|
||||
|
||||
/* FIXME this is gross. */
|
||||
gtk_toggle_button_set_active (((options->type_d == GIMP_TYPE_ROTATE_TOOL) ?
|
||||
GTK_TOGGLE_BUTTON (options->type_w[0]) :
|
||||
((options->type_d == GIMP_TYPE_SCALE_TOOL) ?
|
||||
GTK_TOGGLE_BUTTON (options->type_w[1]) :
|
||||
((options->type_d == GIMP_TYPE_SHEAR_TOOL) ?
|
||||
GTK_TOGGLE_BUTTON (options->type_w[2]) :
|
||||
GTK_TOGGLE_BUTTON (options->type_w[3])))),
|
||||
TRUE);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->smoothing_w),
|
||||
options->smoothing_d);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->showpath_w),
|
||||
|
@ -1861,8 +1836,8 @@ transform_options_new (void)
|
|||
TransformOptions *options;
|
||||
|
||||
GtkWidget *table;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *hbox2;
|
||||
GtkWidget *label;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *fbox;
|
||||
|
@ -1872,7 +1847,6 @@ transform_options_new (void)
|
|||
tool_options_init ((ToolOptions *) options,
|
||||
transform_options_reset);
|
||||
|
||||
options->type = options->type_d = GIMP_TYPE_SCALE_TOOL; /* FIXME: GIMP_TYPE_ROTATE_TOOL; */
|
||||
options->smoothing = options->smoothing_d = TRUE;
|
||||
options->showpath = options->showpath_d = TRUE;
|
||||
options->clip = options->clip_d = FALSE;
|
||||
|
@ -1880,43 +1854,12 @@ transform_options_new (void)
|
|||
options->grid_size = options->grid_size_d = 32;
|
||||
options->show_grid = options->show_grid_d = TRUE;
|
||||
|
||||
/* the main table */
|
||||
table = gtk_table_new (2, 2, FALSE);
|
||||
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2);
|
||||
gtk_box_pack_start (GTK_BOX (options->tool_options.main_vbox), table,
|
||||
|
||||
/* the top hbox (containing two frames) */
|
||||
hbox2 = gtk_hbox_new (FALSE, 2);
|
||||
gtk_box_pack_start (GTK_BOX (options->tool_options.main_vbox), hbox2,
|
||||
FALSE, FALSE, 0);
|
||||
|
||||
/* the left vbox */
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), vbox, 0, 1, 0, 1);
|
||||
|
||||
/* the transform type radio buttons */
|
||||
frame =
|
||||
gimp_radio_group_new (TRUE, _("Transform"),
|
||||
|
||||
_("Rotation"), gimp_transform_tool_type_callback,
|
||||
GIMP_TYPE_ROTATE_TOOL, NULL, &options->type_w[0], TRUE,
|
||||
|
||||
_("Scaling"), gimp_transform_tool_type_callback,
|
||||
GIMP_TYPE_SCALE_TOOL, NULL, &options->type_w[1], FALSE,
|
||||
|
||||
_("Shearing"), gimp_transform_tool_type_callback,
|
||||
GIMP_TYPE_SHEAR_TOOL, NULL, &options->type_w[2], FALSE,
|
||||
|
||||
_("Perspective"), gimp_transform_tool_type_callback,
|
||||
GIMP_TYPE_PERSPECTIVE_TOOL, NULL, &options->type_w[3], FALSE,
|
||||
|
||||
NULL);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
/* the right vbox */
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), vbox, 1, 2, 0, 1);
|
||||
|
||||
/* the second radio frame and box, for transform direction */
|
||||
frame = gimp_radio_group_new (TRUE, _("Tool Paradigm"),
|
||||
|
||||
|
@ -1930,12 +1873,12 @@ transform_options_new (void)
|
|||
|
||||
NULL);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox2), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
/* the grid frame */
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox2), frame, FALSE, FALSE, 0);
|
||||
|
||||
fbox = gtk_vbox_new (FALSE, 1);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (fbox), 2);
|
||||
|
@ -1977,7 +1920,13 @@ transform_options_new (void)
|
|||
gtk_widget_show (fbox);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
gtk_widget_show (vbox);
|
||||
gtk_widget_show (hbox2);
|
||||
|
||||
/* the main table */
|
||||
table = gtk_table_new (1, 2, FALSE);
|
||||
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2);
|
||||
gtk_box_pack_start (GTK_BOX (options->tool_options.main_vbox), table,
|
||||
FALSE, FALSE, 0);
|
||||
|
||||
/* the smoothing toggle button */
|
||||
options->smoothing_w = gtk_check_button_new_with_label (_("Smoothing"));
|
||||
|
@ -1985,7 +1934,7 @@ transform_options_new (void)
|
|||
GTK_SIGNAL_FUNC (gimp_toggle_button_update),
|
||||
&options->smoothing);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table),
|
||||
options->smoothing_w, 0, 1, 1, 2);
|
||||
options->smoothing_w, 0, 1, 0, 1);
|
||||
gtk_widget_show (options->smoothing_w);
|
||||
|
||||
/* the showpath toggle button */
|
||||
|
@ -1994,7 +1943,7 @@ transform_options_new (void)
|
|||
GTK_SIGNAL_FUNC (gimp_transform_tool_show_path_update),
|
||||
&options->showpath);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table),
|
||||
options->showpath_w, 1, 2, 1, 2);
|
||||
options->showpath_w, 1, 2, 0, 1);
|
||||
gtk_widget_show (options->showpath_w);
|
||||
|
||||
gtk_widget_show (table);
|
||||
|
@ -2011,25 +1960,6 @@ transform_options_new (void)
|
|||
return options;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_tool_change_type (GtkType new_type)
|
||||
{
|
||||
if (transform_options->type != new_type)
|
||||
{
|
||||
GimpToolInfo *tool_info;
|
||||
|
||||
/* change the type, free the old tool, create the new tool */
|
||||
transform_options->type = new_type;
|
||||
|
||||
tool_info = tool_manager_get_info_by_type (new_type);
|
||||
|
||||
if (gimp_context_get_tool (gimp_context_get_user ()) != tool_info)
|
||||
gimp_context_set_tool (gimp_context_get_user (), tool_info);
|
||||
else
|
||||
gimp_context_tool_changed (gimp_context_get_user ());
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_transform_tool_smoothing (void)
|
||||
{
|
||||
|
|
|
@ -79,10 +79,6 @@ struct _TransformOptions
|
|||
{
|
||||
ToolOptions tool_options;
|
||||
|
||||
GtkType type;
|
||||
GtkType type_d;
|
||||
GtkWidget *type_w[4]; /* 4 radio buttons */
|
||||
|
||||
gboolean smoothing;
|
||||
gboolean smoothing_d;
|
||||
GtkWidget *smoothing_w;
|
||||
|
@ -167,8 +163,6 @@ static void gimp_transform_tool_control (GimpTool *tool,
|
|||
|
||||
static void gimp_transform_tool_draw (GimpDrawTool *draw_tool);
|
||||
|
||||
static void gimp_transform_tool_change_type (GtkType new_type);
|
||||
|
||||
static TransformOptions * transform_options_new (void);
|
||||
static void transform_options_reset (ToolOptions *tool_options);
|
||||
|
||||
|
@ -1791,16 +1785,6 @@ gimp_transform_tool_show_path_update (GtkWidget *widget,
|
|||
gimp_transform_tool_showpath_changed (0); /* resume */
|
||||
}
|
||||
|
||||
/* FIXME Do we still want to do this this way? Perhaps we should make
|
||||
separate icons for each tool. */
|
||||
|
||||
static void
|
||||
gimp_transform_tool_type_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
gimp_transform_tool_change_type ((GtkType) data);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_tool_direction_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
|
@ -1830,15 +1814,6 @@ transform_options_reset (ToolOptions *tool_options)
|
|||
|
||||
options = (TransformOptions *) tool_options;
|
||||
|
||||
/* FIXME this is gross. */
|
||||
gtk_toggle_button_set_active (((options->type_d == GIMP_TYPE_ROTATE_TOOL) ?
|
||||
GTK_TOGGLE_BUTTON (options->type_w[0]) :
|
||||
((options->type_d == GIMP_TYPE_SCALE_TOOL) ?
|
||||
GTK_TOGGLE_BUTTON (options->type_w[1]) :
|
||||
((options->type_d == GIMP_TYPE_SHEAR_TOOL) ?
|
||||
GTK_TOGGLE_BUTTON (options->type_w[2]) :
|
||||
GTK_TOGGLE_BUTTON (options->type_w[3])))),
|
||||
TRUE);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->smoothing_w),
|
||||
options->smoothing_d);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->showpath_w),
|
||||
|
@ -1861,8 +1836,8 @@ transform_options_new (void)
|
|||
TransformOptions *options;
|
||||
|
||||
GtkWidget *table;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *hbox2;
|
||||
GtkWidget *label;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *fbox;
|
||||
|
@ -1872,7 +1847,6 @@ transform_options_new (void)
|
|||
tool_options_init ((ToolOptions *) options,
|
||||
transform_options_reset);
|
||||
|
||||
options->type = options->type_d = GIMP_TYPE_SCALE_TOOL; /* FIXME: GIMP_TYPE_ROTATE_TOOL; */
|
||||
options->smoothing = options->smoothing_d = TRUE;
|
||||
options->showpath = options->showpath_d = TRUE;
|
||||
options->clip = options->clip_d = FALSE;
|
||||
|
@ -1880,43 +1854,12 @@ transform_options_new (void)
|
|||
options->grid_size = options->grid_size_d = 32;
|
||||
options->show_grid = options->show_grid_d = TRUE;
|
||||
|
||||
/* the main table */
|
||||
table = gtk_table_new (2, 2, FALSE);
|
||||
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2);
|
||||
gtk_box_pack_start (GTK_BOX (options->tool_options.main_vbox), table,
|
||||
|
||||
/* the top hbox (containing two frames) */
|
||||
hbox2 = gtk_hbox_new (FALSE, 2);
|
||||
gtk_box_pack_start (GTK_BOX (options->tool_options.main_vbox), hbox2,
|
||||
FALSE, FALSE, 0);
|
||||
|
||||
/* the left vbox */
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), vbox, 0, 1, 0, 1);
|
||||
|
||||
/* the transform type radio buttons */
|
||||
frame =
|
||||
gimp_radio_group_new (TRUE, _("Transform"),
|
||||
|
||||
_("Rotation"), gimp_transform_tool_type_callback,
|
||||
GIMP_TYPE_ROTATE_TOOL, NULL, &options->type_w[0], TRUE,
|
||||
|
||||
_("Scaling"), gimp_transform_tool_type_callback,
|
||||
GIMP_TYPE_SCALE_TOOL, NULL, &options->type_w[1], FALSE,
|
||||
|
||||
_("Shearing"), gimp_transform_tool_type_callback,
|
||||
GIMP_TYPE_SHEAR_TOOL, NULL, &options->type_w[2], FALSE,
|
||||
|
||||
_("Perspective"), gimp_transform_tool_type_callback,
|
||||
GIMP_TYPE_PERSPECTIVE_TOOL, NULL, &options->type_w[3], FALSE,
|
||||
|
||||
NULL);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
/* the right vbox */
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), vbox, 1, 2, 0, 1);
|
||||
|
||||
/* the second radio frame and box, for transform direction */
|
||||
frame = gimp_radio_group_new (TRUE, _("Tool Paradigm"),
|
||||
|
||||
|
@ -1930,12 +1873,12 @@ transform_options_new (void)
|
|||
|
||||
NULL);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox2), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
/* the grid frame */
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox2), frame, FALSE, FALSE, 0);
|
||||
|
||||
fbox = gtk_vbox_new (FALSE, 1);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (fbox), 2);
|
||||
|
@ -1977,7 +1920,13 @@ transform_options_new (void)
|
|||
gtk_widget_show (fbox);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
gtk_widget_show (vbox);
|
||||
gtk_widget_show (hbox2);
|
||||
|
||||
/* the main table */
|
||||
table = gtk_table_new (1, 2, FALSE);
|
||||
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2);
|
||||
gtk_box_pack_start (GTK_BOX (options->tool_options.main_vbox), table,
|
||||
FALSE, FALSE, 0);
|
||||
|
||||
/* the smoothing toggle button */
|
||||
options->smoothing_w = gtk_check_button_new_with_label (_("Smoothing"));
|
||||
|
@ -1985,7 +1934,7 @@ transform_options_new (void)
|
|||
GTK_SIGNAL_FUNC (gimp_toggle_button_update),
|
||||
&options->smoothing);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table),
|
||||
options->smoothing_w, 0, 1, 1, 2);
|
||||
options->smoothing_w, 0, 1, 0, 1);
|
||||
gtk_widget_show (options->smoothing_w);
|
||||
|
||||
/* the showpath toggle button */
|
||||
|
@ -1994,7 +1943,7 @@ transform_options_new (void)
|
|||
GTK_SIGNAL_FUNC (gimp_transform_tool_show_path_update),
|
||||
&options->showpath);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table),
|
||||
options->showpath_w, 1, 2, 1, 2);
|
||||
options->showpath_w, 1, 2, 0, 1);
|
||||
gtk_widget_show (options->showpath_w);
|
||||
|
||||
gtk_widget_show (table);
|
||||
|
@ -2011,25 +1960,6 @@ transform_options_new (void)
|
|||
return options;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_tool_change_type (GtkType new_type)
|
||||
{
|
||||
if (transform_options->type != new_type)
|
||||
{
|
||||
GimpToolInfo *tool_info;
|
||||
|
||||
/* change the type, free the old tool, create the new tool */
|
||||
transform_options->type = new_type;
|
||||
|
||||
tool_info = tool_manager_get_info_by_type (new_type);
|
||||
|
||||
if (gimp_context_get_tool (gimp_context_get_user ()) != tool_info)
|
||||
gimp_context_set_tool (gimp_context_get_user (), tool_info);
|
||||
else
|
||||
gimp_context_tool_changed (gimp_context_get_user ());
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_transform_tool_smoothing (void)
|
||||
{
|
||||
|
|
|
@ -2157,7 +2157,7 @@ perspective_invoker (Argument *args)
|
|||
/* Determine the perspective transform that maps from
|
||||
* the unit cube to the trans_info coordinates
|
||||
*/
|
||||
perspective_find_transform (trans_info, m);
|
||||
gimp_perspective_tool_find_transform (trans_info, m);
|
||||
|
||||
tile_manager_get_offsets (float_tiles, &offset_x, &offset_y);
|
||||
cx = (gdouble) offset_x;
|
||||
|
@ -2176,7 +2176,7 @@ perspective_invoker (Argument *args)
|
|||
gimp_matrix3_mult (m, matrix);
|
||||
|
||||
/* Perspective the buffer */
|
||||
new_tiles = perspective_tool_perspective (gimage, drawable, NULL,
|
||||
new_tiles = gimp_perspective_tool_perspective (gimage, drawable, NULL,
|
||||
float_tiles, interpolation,
|
||||
matrix);
|
||||
|
||||
|
@ -2428,7 +2428,7 @@ rotate_invoker (Argument *args)
|
|||
gimp_matrix3_translate (matrix, +cx, +cy);
|
||||
|
||||
/* Rotate the buffer */
|
||||
new_tiles = rotate_tool_rotate (gimage, drawable, NULL, angle,
|
||||
new_tiles = gimp_rotate_tool_rotate (gimage, drawable, NULL, angle,
|
||||
float_tiles, interpolation, matrix);
|
||||
|
||||
/* Free the cut/copied buffer */
|
||||
|
@ -2696,7 +2696,7 @@ shear_invoker (Argument *args)
|
|||
gimp_matrix3_translate (matrix, +cx, +cy);
|
||||
|
||||
/* Shear the buffer */
|
||||
new_tiles = shear_tool_shear (gimage, drawable, NULL, float_tiles,
|
||||
new_tiles = gimp_shear_tool_shear (gimage, drawable, NULL, float_tiles,
|
||||
interpolation, matrix);
|
||||
|
||||
/* Free the cut/copied buffer */
|
||||
|
|
|
@ -626,7 +626,6 @@ static char *pencil_bits [] =
|
|||
/* Image name: perspective */
|
||||
|
||||
|
||||
/*
|
||||
#define perspective_width 22
|
||||
#define perspective_height 22
|
||||
static char *perspective_bits [] =
|
||||
|
@ -654,7 +653,6 @@ static char *perspective_bits [] =
|
|||
"......................",
|
||||
"......................"
|
||||
};
|
||||
*/
|
||||
/* GIMP icon image format -- S. Kimball, P. Mattis */
|
||||
/* Image name: rect */
|
||||
|
||||
|
@ -690,7 +688,6 @@ static char *rect_bits [] =
|
|||
/* Image name: rotate */
|
||||
|
||||
|
||||
/*
|
||||
#define rotate_width 22
|
||||
#define rotate_height 22
|
||||
static char *rotate_bits [] =
|
||||
|
@ -718,7 +715,6 @@ static char *rotate_bits [] =
|
|||
"....aaa....eaee.......",
|
||||
"............ee........"
|
||||
};
|
||||
*/
|
||||
/* GIMP icon image format -- S. Kimball, P. Mattis */
|
||||
/* Image name: scale */
|
||||
|
||||
|
@ -787,10 +783,9 @@ static char *sharpen_bits [] =
|
|||
/* Image name: skew */
|
||||
|
||||
|
||||
/*
|
||||
#define skew_width 22
|
||||
#define skew_height 22
|
||||
static char *skew_bits [] =
|
||||
#define shear_width 22
|
||||
#define shear_height 22
|
||||
static char *shear_bits [] =
|
||||
{
|
||||
"......................",
|
||||
"......................",
|
||||
|
@ -815,7 +810,7 @@ static char *skew_bits [] =
|
|||
"......................",
|
||||
"......................"
|
||||
};
|
||||
*/
|
||||
|
||||
/* GIMP icon image format -- S. Kimball, P. Mattis */
|
||||
/* Image name: text */
|
||||
|
||||
|
|
|
@ -58,18 +58,18 @@ libapptools_la_SOURCES = \
|
|||
gimppathtool.h \
|
||||
gimppenciltool.c \
|
||||
gimppenciltool.h \
|
||||
## gimpperspectivetool.c \
|
||||
## gimpperspectivetool.h \
|
||||
gimpperspectivetool.c \
|
||||
gimpperspectivetool.h \
|
||||
gimprectselecttool.c \
|
||||
gimprectselecttool.h \
|
||||
## gimprotatetool.c \
|
||||
## gimprotatetool.h \
|
||||
gimprotatetool.c \
|
||||
gimprotatetool.h \
|
||||
gimpscaletool.c \
|
||||
gimpscaletool.h \
|
||||
gimpselectiontool.c \
|
||||
gimpselectiontool.h \
|
||||
## gimpsheartool.c \
|
||||
## gimpsheartool.h \
|
||||
gimpsheartool.c \
|
||||
gimpsheartool.h \
|
||||
gimpsmudgetool.c \
|
||||
gimpsmudgetool.h \
|
||||
gimptexttool.c \
|
||||
|
|
|
@ -30,234 +30,109 @@
|
|||
#include "gimage_mask.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimpprogress.h"
|
||||
#include "info_dialog.h"
|
||||
#include "gui/info-dialog.h"
|
||||
#include "selection.h"
|
||||
#include "tile_manager.h"
|
||||
#include "undo.h"
|
||||
|
||||
#include "perspective_tool.h"
|
||||
#include "tools.h"
|
||||
#include "transform_core.h"
|
||||
#include "transform_tool.h"
|
||||
#include "gimpperspectivetool.h"
|
||||
#include "tool_manager.h"
|
||||
#include "tool_options.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#include "pixmaps2.h"
|
||||
|
||||
/* forward function declarations */
|
||||
static TileManager * perspective_tool_transform (Tool *tool,
|
||||
GDisplay *gdisp,
|
||||
TransformState state);
|
||||
static void perspective_tool_recalc (Tool *tool,
|
||||
GDisplay *gdisp);
|
||||
static void perspective_tool_motion (Tool *tool,
|
||||
GDisplay *gdisp);
|
||||
static void perspective_info_update (Tool *tool);
|
||||
static void gimp_perspective_tool_class_init (GimpPerspectiveToolClass *klass);
|
||||
static void gimp_perspective_tool_init (GimpPerspectiveTool *perspective_tool);
|
||||
|
||||
static void gimp_perspective_tool_destroy (GtkObject *object);
|
||||
|
||||
static TileManager * gimp_perspective_tool_transform (GimpTransformTool *transform_tool,
|
||||
GDisplay *gdisp,
|
||||
TransformState state);
|
||||
static void perspective_tool_recalc (GimpTool *tool,
|
||||
GDisplay *gdisp);
|
||||
static void perspective_tool_motion (GimpTool *tool,
|
||||
GDisplay *gdisp);
|
||||
static void perspective_info_update (GimpTool *tool);
|
||||
|
||||
|
||||
/* storage for information dialog fields */
|
||||
static gchar matrix_row_buf [3][MAX_INFO_BUF];
|
||||
|
||||
static GimpTransformToolClass *parent_class = NULL;
|
||||
|
||||
static TileManager *
|
||||
perspective_tool_transform (Tool *tool,
|
||||
GDisplay *gdisp,
|
||||
TransformState state)
|
||||
|
||||
/* public functions */
|
||||
|
||||
void
|
||||
gimp_perspective_tool_register (void)
|
||||
{
|
||||
TransformCore *transform_core;
|
||||
|
||||
transform_core = (TransformCore *) tool->private;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case TRANSFORM_INIT:
|
||||
if (!transform_info)
|
||||
{
|
||||
transform_info =
|
||||
info_dialog_new (_("Perspective Transform Information"),
|
||||
gimp_standard_help_func,
|
||||
"tools/transform_perspective.html");
|
||||
info_dialog_add_label (transform_info, _("Matrix:"),
|
||||
matrix_row_buf[0]);
|
||||
info_dialog_add_label (transform_info, "", matrix_row_buf[1]);
|
||||
info_dialog_add_label (transform_info, "", matrix_row_buf[2]);
|
||||
}
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), TRUE);
|
||||
|
||||
transform_core->trans_info [X0] = (double) transform_core->x1;
|
||||
transform_core->trans_info [Y0] = (double) transform_core->y1;
|
||||
transform_core->trans_info [X1] = (double) transform_core->x2;
|
||||
transform_core->trans_info [Y1] = (double) transform_core->y1;
|
||||
transform_core->trans_info [X2] = (double) transform_core->x1;
|
||||
transform_core->trans_info [Y2] = (double) transform_core->y2;
|
||||
transform_core->trans_info [X3] = (double) transform_core->x2;
|
||||
transform_core->trans_info [Y3] = (double) transform_core->y2;
|
||||
|
||||
return NULL;
|
||||
break;
|
||||
|
||||
case TRANSFORM_MOTION:
|
||||
perspective_tool_motion (tool, gdisp);
|
||||
perspective_tool_recalc (tool, gdisp);
|
||||
break;
|
||||
|
||||
case TRANSFORM_RECALC:
|
||||
perspective_tool_recalc (tool, gdisp);
|
||||
break;
|
||||
|
||||
case TRANSFORM_FINISH:
|
||||
/* Let the transform core handle the inverse mapping */
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), FALSE);
|
||||
return
|
||||
perspective_tool_perspective (gdisp->gimage,
|
||||
gimp_image_active_drawable (gdisp->gimage),
|
||||
gdisp,
|
||||
transform_core->original,
|
||||
transform_tool_smoothing (),
|
||||
transform_core->transform);
|
||||
break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
tool_manager_register_tool (GIMP_TYPE_PERSPECTIVE_TOOL,
|
||||
FALSE,
|
||||
"gimp:perspective_tool",
|
||||
_("Perspective Tool"),
|
||||
_("Change perspective of the layer or selection"),
|
||||
N_("/Tools/Transform Tools/Perspective"), "<shift>P",
|
||||
NULL, "tools/perspective.html",
|
||||
(const gchar **) perspective_bits);
|
||||
}
|
||||
|
||||
Tool *
|
||||
tools_new_perspective_tool (void)
|
||||
GtkType
|
||||
gimp_perspective_tool_get_type (void)
|
||||
{
|
||||
Tool *tool;
|
||||
TransformCore *private;
|
||||
static GtkType tool_type = 0;
|
||||
|
||||
tool = transform_core_new (PERSPECTIVE, TRUE);
|
||||
if (! tool_type)
|
||||
{
|
||||
GtkTypeInfo tool_info =
|
||||
{
|
||||
"GimpPerspectiveTool",
|
||||
sizeof (GimpPerspectiveTool),
|
||||
sizeof (GimpPerspectiveToolClass),
|
||||
(GtkClassInitFunc) gimp_perspective_tool_class_init,
|
||||
(GtkObjectInitFunc) gimp_perspective_tool_init,
|
||||
/* reserved_1 */ NULL,
|
||||
/* reserved_2 */ NULL,
|
||||
(GtkClassInitFunc) NULL,
|
||||
};
|
||||
|
||||
tool->tool_cursor = GIMP_PERSPECTIVE_TOOL_CURSOR;
|
||||
tool_type = gtk_type_unique (GIMP_TYPE_TRANSFORM_TOOL, &tool_info);
|
||||
}
|
||||
|
||||
private = tool->private;
|
||||
return tool_type;
|
||||
}
|
||||
|
||||
/* set the rotation specific transformation attributes */
|
||||
private->trans_func = perspective_tool_transform;
|
||||
private->trans_info[X0] = 0;
|
||||
private->trans_info[Y0] = 0;
|
||||
private->trans_info[X1] = 0;
|
||||
private->trans_info[Y1] = 0;
|
||||
private->trans_info[X2] = 0;
|
||||
private->trans_info[Y2] = 0;
|
||||
private->trans_info[X3] = 0;
|
||||
private->trans_info[Y3] = 0;
|
||||
TileManager *
|
||||
gimp_perspective_tool_perspective (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
GDisplay *gdisp,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix3 matrix)
|
||||
{
|
||||
GimpProgress *progress;
|
||||
TileManager *ret;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix3_identity (private->transform);
|
||||
progress = progress_start (gdisp, _("Perspective..."), FALSE, NULL, NULL);
|
||||
|
||||
return tool;
|
||||
ret = gimp_transform_tool_do (gimage, drawable, float_tiles,
|
||||
interpolation, matrix,
|
||||
progress ? progress_update_and_flush :
|
||||
(GimpProgressFunc) NULL,
|
||||
progress);
|
||||
|
||||
if (progress)
|
||||
progress_end (progress);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
tools_free_perspective_tool (Tool *tool)
|
||||
{
|
||||
transform_core_free (tool);
|
||||
}
|
||||
|
||||
static void
|
||||
perspective_info_update (Tool *tool)
|
||||
{
|
||||
TransformCore *transform_core;
|
||||
gint i;
|
||||
|
||||
transform_core = (TransformCore *) tool->private;
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
gchar *p = matrix_row_buf[i];
|
||||
gint j;
|
||||
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
p += g_snprintf (p, MAX_INFO_BUF - (p - matrix_row_buf[i]),
|
||||
"%10.3g", transform_core->transform[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
info_dialog_update (transform_info);
|
||||
info_dialog_popup (transform_info);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
perspective_tool_motion (Tool *tool,
|
||||
GDisplay *gdisp)
|
||||
{
|
||||
TransformCore *transform_core;
|
||||
gint diff_x, diff_y;
|
||||
|
||||
transform_core = (TransformCore *) tool->private;
|
||||
|
||||
diff_x = transform_core->curx - transform_core->lastx;
|
||||
diff_y = transform_core->cury - transform_core->lasty;
|
||||
|
||||
switch (transform_core->function)
|
||||
{
|
||||
case TRANSFORM_HANDLE_1:
|
||||
transform_core->trans_info [X0] += diff_x;
|
||||
transform_core->trans_info [Y0] += diff_y;
|
||||
break;
|
||||
case TRANSFORM_HANDLE_2:
|
||||
transform_core->trans_info [X1] += diff_x;
|
||||
transform_core->trans_info [Y1] += diff_y;
|
||||
break;
|
||||
case TRANSFORM_HANDLE_3:
|
||||
transform_core->trans_info [X2] += diff_x;
|
||||
transform_core->trans_info [Y2] += diff_y;
|
||||
break;
|
||||
case TRANSFORM_HANDLE_4:
|
||||
transform_core->trans_info [X3] += diff_x;
|
||||
transform_core->trans_info [Y3] += diff_y;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
perspective_tool_recalc (Tool *tool,
|
||||
GDisplay *gdisp)
|
||||
{
|
||||
TransformCore *transform_core;
|
||||
GimpMatrix3 m;
|
||||
gdouble cx, cy;
|
||||
gdouble scalex, scaley;
|
||||
|
||||
transform_core = (TransformCore *) tool->private;
|
||||
|
||||
/* determine the perspective transform that maps from
|
||||
* the unit cube to the trans_info coordinates
|
||||
*/
|
||||
perspective_find_transform (transform_core->trans_info, m);
|
||||
|
||||
cx = transform_core->x1;
|
||||
cy = transform_core->y1;
|
||||
scalex = 1.0;
|
||||
scaley = 1.0;
|
||||
|
||||
if (transform_core->x2 - transform_core->x1)
|
||||
scalex = 1.0 / (transform_core->x2 - transform_core->x1);
|
||||
if (transform_core->y2 - transform_core->y1)
|
||||
scaley = 1.0 / (transform_core->y2 - transform_core->y1);
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix3_identity (transform_core->transform);
|
||||
gimp_matrix3_translate (transform_core->transform, -cx, -cy);
|
||||
gimp_matrix3_scale (transform_core->transform, scalex, scaley);
|
||||
gimp_matrix3_mult (m, transform_core->transform);
|
||||
|
||||
/* transform the bounding box */
|
||||
transform_core_transform_bounding_box (tool);
|
||||
|
||||
/* update the information dialog */
|
||||
perspective_info_update (tool);
|
||||
}
|
||||
|
||||
void
|
||||
perspective_find_transform (gdouble *coords,
|
||||
GimpMatrix3 matrix)
|
||||
gimp_perspective_tool_find_transform (gdouble *coords,
|
||||
GimpMatrix3 matrix)
|
||||
{
|
||||
gdouble dx1, dx2, dx3, dy1, dy2, dy3;
|
||||
gdouble det1, det2;
|
||||
|
@ -303,27 +178,215 @@ perspective_find_transform (gdouble *coords,
|
|||
matrix[2][2] = 1.0;
|
||||
}
|
||||
|
||||
TileManager *
|
||||
perspective_tool_perspective (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
GDisplay *gdisp,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix3 matrix)
|
||||
/* private function definitions */
|
||||
|
||||
static void
|
||||
gimp_perspective_tool_class_init (GimpPerspectiveToolClass *klass)
|
||||
{
|
||||
GimpProgress *progress;
|
||||
TileManager *ret;
|
||||
GtkObjectClass *object_class;
|
||||
GimpTransformToolClass *trans_class;
|
||||
|
||||
progress = progress_start (gdisp, _("Perspective..."), FALSE, NULL, NULL);
|
||||
object_class = (GtkObjectClass *) klass;
|
||||
trans_class = (GimpTransformToolClass *) klass;
|
||||
|
||||
ret = transform_core_do (gimage, drawable, float_tiles,
|
||||
interpolation, matrix,
|
||||
progress ? progress_update_and_flush :
|
||||
(GimpProgressFunc) NULL,
|
||||
progress);
|
||||
parent_class = gtk_type_class (GIMP_TYPE_TRANSFORM_TOOL);
|
||||
|
||||
if (progress)
|
||||
progress_end (progress);
|
||||
object_class->destroy = gimp_perspective_tool_destroy;
|
||||
|
||||
return ret;
|
||||
trans_class->transform = gimp_perspective_tool_transform;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_perspective_tool_init (GimpPerspectiveTool *perspective_tool)
|
||||
{
|
||||
GimpTool *tool;
|
||||
GimpTransformTool *tr_tool;
|
||||
|
||||
tool = GIMP_TOOL (perspective_tool);
|
||||
tr_tool = GIMP_TRANSFORM_TOOL (perspective_tool);
|
||||
|
||||
tool->tool_cursor = GIMP_PERSPECTIVE_TOOL_CURSOR;
|
||||
|
||||
tr_tool->trans_info[X0] = 0;
|
||||
tr_tool->trans_info[Y0] = 0;
|
||||
tr_tool->trans_info[X1] = 0;
|
||||
tr_tool->trans_info[Y1] = 0;
|
||||
tr_tool->trans_info[X2] = 0;
|
||||
tr_tool->trans_info[Y2] = 0;
|
||||
tr_tool->trans_info[X3] = 0;
|
||||
tr_tool->trans_info[Y3] = 0;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix3_identity (tr_tool->transform);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_perspective_tool_destroy (GtkObject *object)
|
||||
{
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
static TileManager *
|
||||
gimp_perspective_tool_transform (GimpTransformTool *transform_tool,
|
||||
GDisplay *gdisp,
|
||||
TransformState state)
|
||||
{
|
||||
GimpTool *tool;
|
||||
|
||||
tool = GIMP_TOOL (transform_tool);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case TRANSFORM_INIT:
|
||||
if (!transform_info)
|
||||
{
|
||||
transform_info =
|
||||
info_dialog_new (_("Perspective Transform Information"),
|
||||
gimp_standard_help_func,
|
||||
"tools/transform_perspective.html");
|
||||
info_dialog_add_label (transform_info, _("Matrix:"),
|
||||
matrix_row_buf[0]);
|
||||
info_dialog_add_label (transform_info, "", matrix_row_buf[1]);
|
||||
info_dialog_add_label (transform_info, "", matrix_row_buf[2]);
|
||||
}
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), TRUE);
|
||||
|
||||
transform_tool->trans_info [X0] = (double) transform_tool->x1;
|
||||
transform_tool->trans_info [Y0] = (double) transform_tool->y1;
|
||||
transform_tool->trans_info [X1] = (double) transform_tool->x2;
|
||||
transform_tool->trans_info [Y1] = (double) transform_tool->y1;
|
||||
transform_tool->trans_info [X2] = (double) transform_tool->x1;
|
||||
transform_tool->trans_info [Y2] = (double) transform_tool->y2;
|
||||
transform_tool->trans_info [X3] = (double) transform_tool->x2;
|
||||
transform_tool->trans_info [Y3] = (double) transform_tool->y2;
|
||||
|
||||
return NULL;
|
||||
break;
|
||||
|
||||
case TRANSFORM_MOTION:
|
||||
perspective_tool_motion (tool, gdisp);
|
||||
perspective_tool_recalc (tool, gdisp);
|
||||
break;
|
||||
|
||||
case TRANSFORM_RECALC:
|
||||
perspective_tool_recalc (tool, gdisp);
|
||||
break;
|
||||
|
||||
case TRANSFORM_FINISH:
|
||||
/* Let the transform tool handle the inverse mapping */
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), FALSE);
|
||||
return
|
||||
gimp_perspective_tool_perspective (gdisp->gimage,
|
||||
gimp_image_active_drawable (gdisp->gimage),
|
||||
gdisp,
|
||||
transform_tool->original,
|
||||
gimp_transform_tool_smoothing (),
|
||||
transform_tool->transform);
|
||||
break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
perspective_info_update (GimpTool *tool)
|
||||
{
|
||||
GimpTransformTool *transform_tool;
|
||||
gint i;
|
||||
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
gchar *p = matrix_row_buf[i];
|
||||
gint j;
|
||||
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
p += g_snprintf (p, MAX_INFO_BUF - (p - matrix_row_buf[i]),
|
||||
"%10.3g", transform_tool->transform[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
info_dialog_update (transform_info);
|
||||
info_dialog_popup (transform_info);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
perspective_tool_motion (GimpTool *tool,
|
||||
GDisplay *gdisp)
|
||||
{
|
||||
GimpTransformTool *transform_tool;
|
||||
gint diff_x, diff_y;
|
||||
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
||||
|
||||
diff_x = transform_tool->curx - transform_tool->lastx;
|
||||
diff_y = transform_tool->cury - transform_tool->lasty;
|
||||
|
||||
switch (transform_tool->function)
|
||||
{
|
||||
case TRANSFORM_HANDLE_1:
|
||||
transform_tool->trans_info [X0] += diff_x;
|
||||
transform_tool->trans_info [Y0] += diff_y;
|
||||
break;
|
||||
case TRANSFORM_HANDLE_2:
|
||||
transform_tool->trans_info [X1] += diff_x;
|
||||
transform_tool->trans_info [Y1] += diff_y;
|
||||
break;
|
||||
case TRANSFORM_HANDLE_3:
|
||||
transform_tool->trans_info [X2] += diff_x;
|
||||
transform_tool->trans_info [Y2] += diff_y;
|
||||
break;
|
||||
case TRANSFORM_HANDLE_4:
|
||||
transform_tool->trans_info [X3] += diff_x;
|
||||
transform_tool->trans_info [Y3] += diff_y;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
perspective_tool_recalc (GimpTool *tool,
|
||||
GDisplay *gdisp)
|
||||
{
|
||||
GimpTransformTool *transform_tool;
|
||||
GimpMatrix3 m;
|
||||
gdouble cx, cy;
|
||||
gdouble scalex, scaley;
|
||||
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
||||
|
||||
/* determine the perspective transform that maps from
|
||||
* the unit cube to the trans_info coordinates
|
||||
*/
|
||||
gimp_perspective_tool_find_transform (transform_tool->trans_info, m);
|
||||
|
||||
cx = transform_tool->x1;
|
||||
cy = transform_tool->y1;
|
||||
scalex = 1.0;
|
||||
scaley = 1.0;
|
||||
|
||||
if (transform_tool->x2 - transform_tool->x1)
|
||||
scalex = 1.0 / (transform_tool->x2 - transform_tool->x1);
|
||||
if (transform_tool->y2 - transform_tool->y1)
|
||||
scaley = 1.0 / (transform_tool->y2 - transform_tool->y1);
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix3_identity (transform_tool->transform);
|
||||
gimp_matrix3_translate (transform_tool->transform, -cx, -cy);
|
||||
gimp_matrix3_scale (transform_tool->transform, scalex, scaley);
|
||||
gimp_matrix3_mult (m, transform_tool->transform);
|
||||
|
||||
/* transform the bounding box */
|
||||
gimp_transform_tool_transform_bounding_box (transform_tool);
|
||||
|
||||
/* update the information dialog */
|
||||
perspective_info_update (tool);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,21 +16,46 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __PERSPECTIVE_TOOL_H__
|
||||
#define __PERSPECTIVE_TOOL_H__
|
||||
#ifndef __GIMP_PERSPECTIVE_TOOL_H__
|
||||
#define __GIMP_PERSPECTIVE_TOOL_H__
|
||||
|
||||
|
||||
TileManager * perspective_tool_perspective (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
GDisplay *gdisp,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix3 matrix);
|
||||
void perspective_find_transform (gdouble *coords,
|
||||
GimpMatrix3 matrix);
|
||||
|
||||
Tool * tools_new_perspective_tool (void);
|
||||
void tools_free_perspective_tool (Tool *tool);
|
||||
#include "gimptransformtool.h"
|
||||
|
||||
|
||||
#endif /* __PERSPECTIVE_TOOL_H__ */
|
||||
#define GIMP_TYPE_PERSPECTIVE_TOOL (gimp_perspective_tool_get_type ())
|
||||
#define GIMP_PERSPECTIVE_TOOL(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_PERSPECTIVE_TOOL, GimpPerspectiveTool))
|
||||
#define GIMP_IS_PERSPECTIVE_TOOL(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_PERSPECTIVE_TOOL))
|
||||
#define GIMP_PERSPECTIVE_TOOL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_PERSPECTIVE_TOOL, GimpPerspectiveToolClass))
|
||||
#define GIMP_IS_PERSPECTIVE_TOOL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_PERSPECTIVE_TOOL))
|
||||
|
||||
|
||||
typedef struct _GimpPerspectiveTool GimpPerspectiveTool;
|
||||
typedef struct _GimpPerspectiveToolClass GimpPerspectiveToolClass;
|
||||
|
||||
struct _GimpPerspectiveTool
|
||||
{
|
||||
GimpTransformTool parent_instance;
|
||||
};
|
||||
|
||||
struct _GimpPerspectiveToolClass
|
||||
{
|
||||
GimpTransformToolClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GtkType gimp_perspective_tool_get_type (void);
|
||||
|
||||
void gimp_perspective_tool_register (void);
|
||||
|
||||
|
||||
TileManager * gimp_perspective_tool_perspective (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
GDisplay *gdisp,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix3 matrix);
|
||||
void gimp_perspective_tool_find_transform (gdouble *coords,
|
||||
GimpMatrix3 matrix);
|
||||
|
||||
#endif /* __GIMP_PERSPECTIVE_TOOL_H__ */
|
||||
|
|
|
@ -25,25 +25,31 @@
|
|||
|
||||
#include "apptypes.h"
|
||||
|
||||
#include "draw_core.h"
|
||||
#include "drawable.h"
|
||||
#include "paint-funcs/paint-funcs.h"
|
||||
#include "gui/info-dialog.h"
|
||||
|
||||
#include "cursorutil.h"
|
||||
#include "floating_sel.h"
|
||||
#include "gdisplay.h"
|
||||
#include "gdisplay_ops.h"
|
||||
#include "gimage_mask.h"
|
||||
#include "gimplayer.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimpprogress.h"
|
||||
#include "info_dialog.h"
|
||||
#include "selection.h"
|
||||
#include "tile_manager.h"
|
||||
#include "undo.h"
|
||||
#include "path_transform.h"
|
||||
#include "pixel_region.h"
|
||||
#include "tile_manager.h"
|
||||
|
||||
#include "rotate_tool.h"
|
||||
#include "gimprotatetool.h"
|
||||
#include "tool_manager.h"
|
||||
#include "tool_options.h"
|
||||
#include "tools.h"
|
||||
#include "transform_core.h"
|
||||
#include "transform_tool.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#include "pixmaps2.h"
|
||||
|
||||
|
||||
/* index into trans_info array */
|
||||
#define ANGLE 0
|
||||
|
@ -55,21 +61,26 @@
|
|||
#define FIFTEEN_DEG (G_PI / 12.0)
|
||||
|
||||
|
||||
/* forward function declarations */
|
||||
static TileManager * rotate_tool_transform (Tool *tool,
|
||||
GDisplay *gdisp,
|
||||
TransformState state);
|
||||
/* local function declarations */
|
||||
static void gimp_rotate_tool_class_init (GimpRotateToolClass *klass);
|
||||
static void gimp_rotate_tool_init (GimpRotateTool *rotate_tool);
|
||||
|
||||
static void rotate_tool_recalc (Tool *tool,
|
||||
GDisplay *gdisp);
|
||||
static void rotate_tool_motion (Tool *tool,
|
||||
GDisplay *gdisp);
|
||||
static void rotate_info_update (Tool *tool);
|
||||
static void gimp_rotate_tool_destroy (GtkObject *object);
|
||||
|
||||
static void rotate_angle_changed (GtkWidget *entry,
|
||||
gpointer data);
|
||||
static void rotate_center_changed (GtkWidget *entry,
|
||||
gpointer data);
|
||||
static TileManager * gimp_rotate_tool_transform (GimpTransformTool *transform_tool,
|
||||
GDisplay *gdisp,
|
||||
TransformState state);
|
||||
|
||||
static void rotate_tool_recalc (GimpTool *tool,
|
||||
GDisplay *gdisp);
|
||||
static void rotate_tool_motion (GimpTool *tool,
|
||||
GDisplay *gdisp);
|
||||
static void rotate_info_update (GimpTool *tool);
|
||||
|
||||
static void rotate_angle_changed (GtkWidget *entry,
|
||||
gpointer data);
|
||||
static void rotate_center_changed (GtkWidget *entry,
|
||||
gpointer data);
|
||||
|
||||
|
||||
/* variables local to this file */
|
||||
|
@ -79,24 +90,138 @@ static gdouble center_vals[2];
|
|||
/* needed for size update */
|
||||
static GtkWidget *sizeentry = NULL;
|
||||
|
||||
static GimpTransformToolClass *parent_class = NULL;
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
void
|
||||
gimp_rotate_tool_register (void)
|
||||
{
|
||||
tool_manager_register_tool (GIMP_TYPE_ROTATE_TOOL,
|
||||
FALSE,
|
||||
"gimp:rotate_tool",
|
||||
_("Rotate Tool"),
|
||||
_("Rotate the layer or selection"),
|
||||
N_("/Tools/Transform Tools/Rotate"), "<shift>R",
|
||||
NULL, "tools/rotate.html",
|
||||
(const gchar **) rotate_bits);
|
||||
}
|
||||
|
||||
GtkType
|
||||
gimp_rotate_tool_get_type (void)
|
||||
{
|
||||
static GtkType tool_type = 0;
|
||||
|
||||
if (! tool_type)
|
||||
{
|
||||
GtkTypeInfo tool_info =
|
||||
{
|
||||
"GimpRotateTool",
|
||||
sizeof (GimpRotateTool),
|
||||
sizeof (GimpRotateToolClass),
|
||||
(GtkClassInitFunc) gimp_rotate_tool_class_init,
|
||||
(GtkObjectInitFunc) gimp_rotate_tool_init,
|
||||
/* reserved_1 */ NULL,
|
||||
/* reserved_2 */ NULL,
|
||||
(GtkClassInitFunc) NULL,
|
||||
};
|
||||
|
||||
tool_type = gtk_type_unique (GIMP_TYPE_TRANSFORM_TOOL, &tool_info);
|
||||
}
|
||||
|
||||
return tool_type;
|
||||
}
|
||||
|
||||
TileManager *
|
||||
gimp_rotate_tool_rotate (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
GDisplay *gdisp,
|
||||
gdouble angle,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix3 matrix)
|
||||
{
|
||||
GimpProgress *progress;
|
||||
TileManager *ret;
|
||||
|
||||
progress = progress_start (gdisp, _("Rotating..."), FALSE, NULL, NULL);
|
||||
|
||||
ret = gimp_transform_tool_do (gimage, drawable, float_tiles,
|
||||
interpolation, matrix,
|
||||
progress ? progress_update_and_flush :
|
||||
(GimpProgressFunc) NULL,
|
||||
progress);
|
||||
|
||||
if (progress)
|
||||
progress_end (progress);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* private function definitions */
|
||||
|
||||
static void
|
||||
gimp_rotate_tool_class_init (GimpRotateToolClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
GimpTransformToolClass *trans_class;
|
||||
|
||||
object_class = (GtkObjectClass *) klass;
|
||||
trans_class = (GimpTransformToolClass *) klass;
|
||||
|
||||
parent_class = gtk_type_class (GIMP_TYPE_TRANSFORM_TOOL);
|
||||
|
||||
object_class->destroy = gimp_rotate_tool_destroy;
|
||||
|
||||
trans_class->transform = gimp_rotate_tool_transform;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_rotate_tool_init (GimpRotateTool *rotate_tool)
|
||||
{
|
||||
GimpTool *tool;
|
||||
GimpTransformTool *tr_tool;
|
||||
|
||||
tool = GIMP_TOOL (rotate_tool);
|
||||
tr_tool = GIMP_TRANSFORM_TOOL (rotate_tool);
|
||||
|
||||
tool->tool_cursor = GIMP_ROTATE_TOOL_CURSOR;
|
||||
|
||||
tr_tool->trans_info[ANGLE] = 0.0;
|
||||
tr_tool->trans_info[REAL_ANGLE] = 0.0;
|
||||
tr_tool->trans_info[CENTER_X] = 0.0;
|
||||
tr_tool->trans_info[CENTER_Y] = 0.0;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix3_identity (tr_tool->transform);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_rotate_tool_destroy (GtkObject *object)
|
||||
{
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
static TileManager *
|
||||
rotate_tool_transform (Tool *tool,
|
||||
GDisplay *gdisp,
|
||||
TransformState state)
|
||||
gimp_rotate_tool_transform (GimpTransformTool *transform_tool,
|
||||
GDisplay *gdisp,
|
||||
TransformState state)
|
||||
{
|
||||
TransformCore *transform_core;
|
||||
GimpTool *tool;
|
||||
GtkWidget *widget;
|
||||
GtkWidget *spinbutton2;
|
||||
|
||||
transform_core = (TransformCore *) tool->private;
|
||||
tool = GIMP_TOOL (transform_tool);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case TRANSFORM_INIT:
|
||||
angle_val = 0.0;
|
||||
center_vals[0] = transform_core->cx;
|
||||
center_vals[1] = transform_core->cy;
|
||||
center_vals[0] = transform_tool->cx;
|
||||
center_vals[1] = transform_tool->cy;
|
||||
|
||||
if (!transform_info)
|
||||
{
|
||||
|
@ -159,9 +284,9 @@ rotate_tool_transform (Tool *tool,
|
|||
65536 + gdisp->gimage->height);
|
||||
|
||||
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (sizeentry), 0,
|
||||
transform_core->x1, transform_core->x2);
|
||||
transform_tool->x1, transform_tool->x2);
|
||||
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (sizeentry), 1,
|
||||
transform_core->y1, transform_core->y2);
|
||||
transform_tool->y1, transform_tool->y2);
|
||||
|
||||
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 0,
|
||||
center_vals[0]);
|
||||
|
@ -172,10 +297,10 @@ rotate_tool_transform (Tool *tool,
|
|||
|
||||
gtk_signal_handler_unblock_by_data (GTK_OBJECT (sizeentry), tool);
|
||||
|
||||
transform_core->trans_info[ANGLE] = angle_val;
|
||||
transform_core->trans_info[REAL_ANGLE] = angle_val;
|
||||
transform_core->trans_info[CENTER_X] = center_vals[0];
|
||||
transform_core->trans_info[CENTER_Y] = center_vals[1];
|
||||
transform_tool->trans_info[ANGLE] = angle_val;
|
||||
transform_tool->trans_info[REAL_ANGLE] = angle_val;
|
||||
transform_tool->trans_info[CENTER_X] = center_vals[0];
|
||||
transform_tool->trans_info[CENTER_Y] = center_vals[1];
|
||||
|
||||
return NULL;
|
||||
break;
|
||||
|
@ -191,60 +316,29 @@ rotate_tool_transform (Tool *tool,
|
|||
|
||||
case TRANSFORM_FINISH:
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), FALSE);
|
||||
return rotate_tool_rotate (gdisp->gimage,
|
||||
gimp_image_active_drawable (gdisp->gimage),
|
||||
gdisp,
|
||||
transform_core->trans_info[ANGLE],
|
||||
transform_core->original,
|
||||
transform_tool_smoothing (),
|
||||
transform_core->transform);
|
||||
return gimp_rotate_tool_rotate (gdisp->gimage,
|
||||
gimp_image_active_drawable (gdisp->gimage),
|
||||
gdisp,
|
||||
transform_tool->trans_info[ANGLE],
|
||||
transform_tool->original,
|
||||
gimp_transform_tool_smoothing (),
|
||||
transform_tool->transform);
|
||||
break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Tool *
|
||||
tools_new_rotate_tool (void)
|
||||
{
|
||||
Tool *tool;
|
||||
TransformCore *private;
|
||||
|
||||
tool = transform_core_new (ROTATE, TRUE);
|
||||
|
||||
tool->tool_cursor = GIMP_ROTATE_TOOL_CURSOR;
|
||||
|
||||
private = tool->private;
|
||||
|
||||
/* set the rotation specific transformation attributes */
|
||||
private->trans_func = rotate_tool_transform;
|
||||
private->trans_info[ANGLE] = 0.0;
|
||||
private->trans_info[REAL_ANGLE] = 0.0;
|
||||
private->trans_info[CENTER_X] = 0.0;
|
||||
private->trans_info[CENTER_Y] = 0.0;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix3_identity (private->transform);
|
||||
|
||||
return tool;
|
||||
}
|
||||
|
||||
void
|
||||
tools_free_rotate_tool (Tool *tool)
|
||||
{
|
||||
transform_core_free (tool);
|
||||
}
|
||||
|
||||
static void
|
||||
rotate_info_update (Tool *tool)
|
||||
rotate_info_update (GimpTool *tool)
|
||||
{
|
||||
TransformCore *transform_core;
|
||||
GimpTransformTool *transform_tool;
|
||||
|
||||
transform_core = (TransformCore *) tool->private;
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
||||
|
||||
angle_val = gimp_rad_to_deg (transform_core->trans_info[ANGLE]);
|
||||
center_vals[0] = transform_core->cx;
|
||||
center_vals[1] = transform_core->cy;
|
||||
angle_val = gimp_rad_to_deg (transform_tool->trans_info[ANGLE]);
|
||||
center_vals[0] = transform_tool->cx;
|
||||
center_vals[1] = transform_tool->cy;
|
||||
|
||||
info_dialog_update (transform_info);
|
||||
info_dialog_popup (transform_info);
|
||||
|
@ -254,24 +348,26 @@ static void
|
|||
rotate_angle_changed (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
Tool *tool;
|
||||
TransformCore *transform_core;
|
||||
gdouble value;
|
||||
GimpTool *tool;
|
||||
GimpDrawTool *draw_tool;
|
||||
GimpTransformTool *transform_tool;
|
||||
gdouble value;
|
||||
|
||||
tool = (Tool *) data;
|
||||
tool = (GimpTool *) data;
|
||||
|
||||
if (tool)
|
||||
{
|
||||
transform_core = (TransformCore *) tool->private;
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
||||
draw_tool = GIMP_DRAW_TOOL (tool);
|
||||
|
||||
value = gimp_deg_to_rad (GTK_ADJUSTMENT (widget)->value);
|
||||
|
||||
if (value != transform_core->trans_info[ANGLE])
|
||||
if (value != transform_tool->trans_info[ANGLE])
|
||||
{
|
||||
draw_core_pause (transform_core->core, tool);
|
||||
transform_core->trans_info[ANGLE] = value;
|
||||
gimp_draw_tool_pause (draw_tool);
|
||||
transform_tool->trans_info[ANGLE] = value;
|
||||
rotate_tool_recalc (tool, tool->gdisp);
|
||||
draw_core_resume (transform_core->core, tool);
|
||||
gimp_draw_tool_resume (draw_tool);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -280,58 +376,60 @@ static void
|
|||
rotate_center_changed (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
Tool *tool;
|
||||
TransformCore *transform_core;
|
||||
gint cx;
|
||||
gint cy;
|
||||
GimpTool *tool;
|
||||
GimpDrawTool *draw_tool;
|
||||
GimpTransformTool *transform_tool;
|
||||
gint cx;
|
||||
gint cy;
|
||||
|
||||
tool = (Tool *) data;
|
||||
tool = (GimpTool *) data;
|
||||
|
||||
if (tool)
|
||||
{
|
||||
transform_core = (TransformCore *) tool->private;
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
||||
draw_tool = GIMP_DRAW_TOOL (tool);
|
||||
|
||||
cx = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0));
|
||||
cy = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1));
|
||||
|
||||
if ((cx != transform_core->cx) ||
|
||||
(cy != transform_core->cy))
|
||||
if ((cx != transform_tool->cx) ||
|
||||
(cy != transform_tool->cy))
|
||||
{
|
||||
draw_core_pause (transform_core->core, tool);
|
||||
transform_core->cx = cx;
|
||||
transform_core->cy = cy;
|
||||
gimp_draw_tool_pause (draw_tool);
|
||||
transform_tool->cx = cx;
|
||||
transform_tool->cy = cy;
|
||||
rotate_tool_recalc (tool, tool->gdisp);
|
||||
draw_core_resume (transform_core->core, tool);
|
||||
gimp_draw_tool_resume (draw_tool);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
rotate_tool_motion (Tool *tool,
|
||||
rotate_tool_motion (GimpTool *tool,
|
||||
GDisplay *gdisp)
|
||||
{
|
||||
TransformCore *transform_core;
|
||||
gdouble angle1, angle2, angle;
|
||||
gdouble cx, cy;
|
||||
gdouble x1, y1, x2, y2;
|
||||
GimpTransformTool *transform_tool;
|
||||
gdouble angle1, angle2, angle;
|
||||
gdouble cx, cy;
|
||||
gdouble x1, y1, x2, y2;
|
||||
|
||||
transform_core = (TransformCore *) tool->private;
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
||||
|
||||
if (transform_core->function == TRANSFORM_HANDLE_CENTER)
|
||||
if (transform_tool->function == TRANSFORM_HANDLE_CENTER)
|
||||
{
|
||||
transform_core->cx = transform_core->curx;
|
||||
transform_core->cy = transform_core->cury;
|
||||
transform_tool->cx = transform_tool->curx;
|
||||
transform_tool->cy = transform_tool->cury;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
cx = transform_core->cx;
|
||||
cy = transform_core->cy;
|
||||
cx = transform_tool->cx;
|
||||
cy = transform_tool->cy;
|
||||
|
||||
x1 = transform_core->curx - cx;
|
||||
x2 = transform_core->lastx - cx;
|
||||
y1 = cy - transform_core->cury;
|
||||
y2 = cy - transform_core->lasty;
|
||||
x1 = transform_tool->curx - cx;
|
||||
x2 = transform_tool->lastx - cx;
|
||||
y1 = cy - transform_tool->cury;
|
||||
y2 = cy - transform_tool->lasty;
|
||||
|
||||
/* find the first angle */
|
||||
angle1 = atan2 (y1, x1);
|
||||
|
@ -345,74 +443,48 @@ rotate_tool_motion (Tool *tool,
|
|||
angle = angle2 - ((angle1 < 0) ? 2.0 * G_PI + angle1 : angle1 - 2.0 * G_PI);
|
||||
|
||||
/* increment the transform tool's angle */
|
||||
transform_core->trans_info[REAL_ANGLE] += angle;
|
||||
transform_tool->trans_info[REAL_ANGLE] += angle;
|
||||
|
||||
/* limit the angle to between 0 and 360 degrees */
|
||||
if (transform_core->trans_info[REAL_ANGLE] < - G_PI)
|
||||
transform_core->trans_info[REAL_ANGLE] =
|
||||
2.0 * G_PI - transform_core->trans_info[REAL_ANGLE];
|
||||
else if (transform_core->trans_info[REAL_ANGLE] > G_PI)
|
||||
transform_core->trans_info[REAL_ANGLE] =
|
||||
transform_core->trans_info[REAL_ANGLE] - 2.0 * G_PI;
|
||||
if (transform_tool->trans_info[REAL_ANGLE] < - G_PI)
|
||||
transform_tool->trans_info[REAL_ANGLE] =
|
||||
2.0 * G_PI - transform_tool->trans_info[REAL_ANGLE];
|
||||
else if (transform_tool->trans_info[REAL_ANGLE] > G_PI)
|
||||
transform_tool->trans_info[REAL_ANGLE] =
|
||||
transform_tool->trans_info[REAL_ANGLE] - 2.0 * G_PI;
|
||||
|
||||
/* constrain the angle to 15-degree multiples if ctrl is held down */
|
||||
if (transform_core->state & GDK_CONTROL_MASK)
|
||||
transform_core->trans_info[ANGLE] =
|
||||
FIFTEEN_DEG * (int) ((transform_core->trans_info[REAL_ANGLE] +
|
||||
if (transform_tool->state & GDK_CONTROL_MASK)
|
||||
transform_tool->trans_info[ANGLE] =
|
||||
FIFTEEN_DEG * (int) ((transform_tool->trans_info[REAL_ANGLE] +
|
||||
FIFTEEN_DEG / 2.0) /
|
||||
FIFTEEN_DEG);
|
||||
else
|
||||
transform_core->trans_info[ANGLE] = transform_core->trans_info[REAL_ANGLE];
|
||||
transform_tool->trans_info[ANGLE] = transform_tool->trans_info[REAL_ANGLE];
|
||||
}
|
||||
|
||||
static void
|
||||
rotate_tool_recalc (Tool *tool,
|
||||
rotate_tool_recalc (GimpTool *tool,
|
||||
GDisplay *gdisp)
|
||||
{
|
||||
TransformCore *transform_core;
|
||||
gdouble cx, cy;
|
||||
GimpTransformTool *transform_tool;
|
||||
gdouble cx, cy;
|
||||
|
||||
transform_core = (TransformCore *) tool->private;
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
||||
|
||||
cx = transform_core->cx;
|
||||
cy = transform_core->cy;
|
||||
cx = transform_tool->cx;
|
||||
cy = transform_tool->cy;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix3_identity (transform_core->transform);
|
||||
gimp_matrix3_translate (transform_core->transform, -cx, -cy);
|
||||
gimp_matrix3_rotate (transform_core->transform,
|
||||
transform_core->trans_info[ANGLE]);
|
||||
gimp_matrix3_translate (transform_core->transform, +cx, +cy);
|
||||
gimp_matrix3_identity (transform_tool->transform);
|
||||
gimp_matrix3_translate (transform_tool->transform, -cx, -cy);
|
||||
gimp_matrix3_rotate (transform_tool->transform,
|
||||
transform_tool->trans_info[ANGLE]);
|
||||
gimp_matrix3_translate (transform_tool->transform, +cx, +cy);
|
||||
|
||||
/* transform the bounding box */
|
||||
transform_core_transform_bounding_box (tool);
|
||||
gimp_transform_tool_transform_bounding_box (transform_tool);
|
||||
|
||||
/* update the information dialog */
|
||||
rotate_info_update (tool);
|
||||
}
|
||||
|
||||
TileManager *
|
||||
rotate_tool_rotate (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
GDisplay *gdisp,
|
||||
gdouble angle,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix3 matrix)
|
||||
{
|
||||
GimpProgress *progress;
|
||||
TileManager *ret;
|
||||
|
||||
progress = progress_start (gdisp, _("Rotating..."), FALSE, NULL, NULL);
|
||||
|
||||
ret = transform_core_do (gimage, drawable, float_tiles,
|
||||
interpolation, matrix,
|
||||
progress ? progress_update_and_flush :
|
||||
(GimpProgressFunc) NULL,
|
||||
progress);
|
||||
|
||||
if (progress)
|
||||
progress_end (progress);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -16,20 +16,45 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __ROTATE_TOOL_H__
|
||||
#define __ROTATE_TOOL_H__
|
||||
#ifndef __GIMP_ROTATE_TOOL_H__
|
||||
#define __GIMP_ROTATE_TOOL_H__
|
||||
|
||||
|
||||
TileManager * rotate_tool_rotate (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
GDisplay *gdisp,
|
||||
gdouble angle,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix3 matrix);
|
||||
|
||||
Tool * tools_new_rotate_tool (void);
|
||||
void tools_free_rotate_tool (Tool *tool);
|
||||
#include "gimptransformtool.h"
|
||||
|
||||
|
||||
#endif /* __ROTATE_TOOL_H__ */
|
||||
#define GIMP_TYPE_ROTATE_TOOL (gimp_rotate_tool_get_type ())
|
||||
#define GIMP_ROTATE_TOOL(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_ROTATE_TOOL, GimpRotateTool))
|
||||
#define GIMP_IS_ROTATE_TOOL(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_ROTATE_TOOL))
|
||||
#define GIMP_ROTATE_TOOL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_ROTATE_TOOL, GimpRotateToolClass))
|
||||
#define GIMP_IS_ROTATE_TOOL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_ROTATE_TOOL))
|
||||
|
||||
|
||||
typedef struct _GimpRotateTool GimpRotateTool;
|
||||
typedef struct _GimpRotateToolClass GimpRotateToolClass;
|
||||
|
||||
struct _GimpRotateTool
|
||||
{
|
||||
GimpTransformTool parent_instance;
|
||||
};
|
||||
|
||||
struct _GimpRotateToolClass
|
||||
{
|
||||
GimpTransformToolClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GtkType gimp_rotate_tool_get_type (void);
|
||||
|
||||
void gimp_rotate_tool_register (void);
|
||||
|
||||
|
||||
TileManager * gimp_rotate_tool_rotate (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
GDisplay *gdisp,
|
||||
gdouble angle,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix3 matrix);
|
||||
|
||||
#endif /* __GIMP_ROTATE_TOOL_H__ */
|
||||
|
|
|
@ -27,25 +27,27 @@
|
|||
|
||||
#include "apptypes.h"
|
||||
|
||||
#include "draw_core.h"
|
||||
#include "drawable.h"
|
||||
#include "gui/info-dialog.h"
|
||||
|
||||
#include "floating_sel.h"
|
||||
#include "gdisplay.h"
|
||||
#include "gdisplay_ops.h"
|
||||
#include "gimage_mask.h"
|
||||
#include "gimplayer.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimpprogress.h"
|
||||
#include "info_dialog.h"
|
||||
#include "shear_tool.h"
|
||||
#include "selection.h"
|
||||
#include "tile_manager.h"
|
||||
#include "undo.h"
|
||||
#include "pixel_region.h"
|
||||
#include "tile_manager.h"
|
||||
|
||||
#include "tools.h"
|
||||
#include "gimpsheartool.h"
|
||||
#include "tool_manager.h"
|
||||
#include "tool_options.h"
|
||||
#include "transform_core.h"
|
||||
#include "transform_tool.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#include "pixmaps2.h"
|
||||
|
||||
/* index into trans_info array */
|
||||
#define HORZ_OR_VERT 0
|
||||
|
@ -57,35 +59,148 @@
|
|||
|
||||
|
||||
/* forward function declarations */
|
||||
static TileManager * shear_tool_transform (Tool *tool,
|
||||
GDisplay *gdisp,
|
||||
TransformState state);
|
||||
|
||||
static void shear_tool_recalc (Tool *tool,
|
||||
GDisplay *gdisp);
|
||||
static void shear_tool_motion (Tool *tool,
|
||||
GDisplay *gdisp);
|
||||
static void shear_info_update (Tool *tool);
|
||||
static void gimp_shear_tool_class_init (GimpShearToolClass *klass);
|
||||
static void gimp_shear_tool_init (GimpShearTool *shear_tool);
|
||||
|
||||
static void shear_x_mag_changed (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void shear_y_mag_changed (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void gimp_shear_tool_destroy (GtkObject *object);
|
||||
|
||||
static TileManager * gimp_shear_tool_transform (GimpTransformTool *transform_tool,
|
||||
GDisplay *gdisp,
|
||||
TransformState state);
|
||||
|
||||
static void shear_tool_recalc (GimpTool *tool,
|
||||
GDisplay *gdisp);
|
||||
static void shear_tool_motion (GimpTool *tool,
|
||||
GDisplay *gdisp);
|
||||
static void shear_info_update (GimpTool *tool);
|
||||
|
||||
static void shear_x_mag_changed (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void shear_y_mag_changed (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
|
||||
/* variables local to this file */
|
||||
static gdouble xshear_val;
|
||||
static gdouble yshear_val;
|
||||
|
||||
static GimpTransformToolClass *parent_class = NULL;
|
||||
|
||||
|
||||
/* Public functions */
|
||||
|
||||
void
|
||||
gimp_shear_tool_register (void)
|
||||
{
|
||||
tool_manager_register_tool (GIMP_TYPE_SHEAR_TOOL,
|
||||
FALSE,
|
||||
"gimp:shear_tool",
|
||||
_("Shear Tool"),
|
||||
_("Shear the layer or selection"),
|
||||
N_("/Tools/Transform Tools/Shear"), "<shift>F",
|
||||
NULL, "tools/shear.html",
|
||||
(const gchar **) shear_bits);
|
||||
}
|
||||
|
||||
GtkType
|
||||
gimp_shear_tool_get_type (void)
|
||||
{
|
||||
static GtkType tool_type = 0;
|
||||
|
||||
if (! tool_type)
|
||||
{
|
||||
GtkTypeInfo tool_info =
|
||||
{
|
||||
"GimpShearTool",
|
||||
sizeof (GimpShearTool),
|
||||
sizeof (GimpShearToolClass),
|
||||
(GtkClassInitFunc) gimp_shear_tool_class_init,
|
||||
(GtkObjectInitFunc) gimp_shear_tool_init,
|
||||
/* reserved_1 */ NULL,
|
||||
/* reserved_2 */ NULL,
|
||||
(GtkClassInitFunc) NULL,
|
||||
};
|
||||
|
||||
tool_type = gtk_type_unique (GIMP_TYPE_TRANSFORM_TOOL, &tool_info);
|
||||
}
|
||||
|
||||
return tool_type;
|
||||
}
|
||||
|
||||
TileManager *
|
||||
gimp_shear_tool_shear (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
GDisplay *gdisp,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix3 matrix)
|
||||
{
|
||||
GimpProgress *progress;
|
||||
TileManager *ret;
|
||||
|
||||
progress = progress_start (gdisp, _("Shearing..."), FALSE, NULL, NULL);
|
||||
|
||||
ret = gimp_transform_tool_do (gimage, drawable, float_tiles,
|
||||
interpolation, matrix,
|
||||
progress ? progress_update_and_flush :
|
||||
(GimpProgressFunc) NULL,
|
||||
progress);
|
||||
|
||||
if (progress)
|
||||
progress_end (progress);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
gimp_shear_tool_class_init (GimpShearToolClass *klass)
|
||||
{
|
||||
GtkObjectClass *object_class;
|
||||
GimpTransformToolClass *trans_class;
|
||||
|
||||
object_class = (GtkObjectClass *) klass;
|
||||
trans_class = (GimpTransformToolClass *) klass;
|
||||
|
||||
parent_class = gtk_type_class (GIMP_TYPE_TRANSFORM_TOOL);
|
||||
|
||||
object_class->destroy = gimp_shear_tool_destroy;
|
||||
|
||||
trans_class->transform = gimp_shear_tool_transform;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_shear_tool_init (GimpShearTool *shear_tool)
|
||||
{
|
||||
GimpTool *tool;
|
||||
GimpTransformTool *tr_tool;
|
||||
|
||||
tool = GIMP_TOOL (shear_tool);
|
||||
tr_tool = GIMP_TRANSFORM_TOOL (shear_tool);
|
||||
|
||||
tool->tool_cursor = GIMP_SHEAR_TOOL_CURSOR;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix3_identity (tr_tool->transform);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_shear_tool_destroy (GtkObject *object)
|
||||
{
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
||||
}
|
||||
|
||||
static TileManager *
|
||||
shear_tool_transform (Tool *tool,
|
||||
GDisplay *gdisp,
|
||||
TransformState state)
|
||||
gimp_shear_tool_transform (GimpTransformTool *transform_tool,
|
||||
GDisplay *gdisp,
|
||||
TransformState state)
|
||||
{
|
||||
TransformCore *transform_core;
|
||||
|
||||
transform_core = (TransformCore *) tool->private;
|
||||
GimpTool *tool;
|
||||
tool = GIMP_TOOL (transform_tool);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
|
@ -109,9 +224,9 @@ shear_tool_transform (Tool *tool,
|
|||
shear_y_mag_changed, tool);
|
||||
}
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), TRUE);
|
||||
transform_core->trans_info[HORZ_OR_VERT] = ORIENTATION_UNKNOWN;
|
||||
transform_core->trans_info[XSHEAR] = 0.0;
|
||||
transform_core->trans_info[YSHEAR] = 0.0;
|
||||
transform_tool->trans_info[HORZ_OR_VERT] = ORIENTATION_UNKNOWN;
|
||||
transform_tool->trans_info[XSHEAR] = 0.0;
|
||||
transform_tool->trans_info[YSHEAR] = 0.0;
|
||||
|
||||
return NULL;
|
||||
break;
|
||||
|
@ -127,54 +242,27 @@ shear_tool_transform (Tool *tool,
|
|||
|
||||
case TRANSFORM_FINISH:
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), FALSE);
|
||||
return shear_tool_shear (gdisp->gimage,
|
||||
gimp_image_active_drawable (gdisp->gimage),
|
||||
gdisp,
|
||||
transform_core->original,
|
||||
transform_tool_smoothing (),
|
||||
transform_core->transform);
|
||||
return gimp_shear_tool_shear (gdisp->gimage,
|
||||
gimp_image_active_drawable (gdisp->gimage),
|
||||
gdisp,
|
||||
transform_tool->original,
|
||||
gimp_transform_tool_smoothing (),
|
||||
transform_tool->transform);
|
||||
break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Tool *
|
||||
tools_new_shear_tool (void)
|
||||
{
|
||||
Tool *tool;
|
||||
TransformCore *private;
|
||||
|
||||
tool = transform_core_new (SHEAR, TRUE);
|
||||
|
||||
tool->tool_cursor = GIMP_SHEAR_TOOL_CURSOR;
|
||||
|
||||
private = tool->private;
|
||||
|
||||
/* set the rotation specific transformation attributes */
|
||||
private->trans_func = shear_tool_transform;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix3_identity (private->transform);
|
||||
|
||||
return tool;
|
||||
}
|
||||
|
||||
void
|
||||
tools_free_shear_tool (Tool *tool)
|
||||
{
|
||||
transform_core_free (tool);
|
||||
}
|
||||
|
||||
static void
|
||||
shear_info_update (Tool *tool)
|
||||
shear_info_update (GimpTool *tool)
|
||||
{
|
||||
TransformCore *transform_core;
|
||||
GimpTransformTool *transform_tool;
|
||||
|
||||
transform_core = (TransformCore *) tool->private;
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
||||
|
||||
xshear_val = transform_core->trans_info[XSHEAR];
|
||||
yshear_val = transform_core->trans_info[YSHEAR];
|
||||
xshear_val = transform_tool->trans_info[XSHEAR];
|
||||
yshear_val = transform_tool->trans_info[YSHEAR];
|
||||
|
||||
info_dialog_update (transform_info);
|
||||
info_dialog_popup (transform_info);
|
||||
|
@ -184,24 +272,26 @@ static void
|
|||
shear_x_mag_changed (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
Tool *tool;
|
||||
TransformCore *transform_core;
|
||||
gint value;
|
||||
GimpTool *tool;
|
||||
GimpDrawTool *draw_tool;
|
||||
GimpTransformTool *transform_tool;
|
||||
gint value;
|
||||
|
||||
tool = (Tool *) data;
|
||||
tool = (GimpTool *) data;
|
||||
|
||||
if (tool)
|
||||
{
|
||||
transform_core = (TransformCore *) tool->private;
|
||||
draw_tool = GIMP_DRAW_TOOL (tool);
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
||||
|
||||
value = GTK_ADJUSTMENT (widget)->value;
|
||||
|
||||
if (value != transform_core->trans_info[XSHEAR])
|
||||
if (value != transform_tool->trans_info[XSHEAR])
|
||||
{
|
||||
draw_core_pause (transform_core->core, tool);
|
||||
transform_core->trans_info[XSHEAR] = value;
|
||||
gimp_draw_tool_pause (draw_tool);
|
||||
transform_tool->trans_info[XSHEAR] = value;
|
||||
shear_tool_recalc (tool, tool->gdisp);
|
||||
draw_core_resume (transform_core->core, tool);
|
||||
gimp_draw_tool_resume (draw_tool);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -210,97 +300,99 @@ static void
|
|||
shear_y_mag_changed (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
Tool *tool;
|
||||
TransformCore *transform_core;
|
||||
gint value;
|
||||
GimpTool *tool;
|
||||
GimpDrawTool *draw_tool;
|
||||
GimpTransformTool *transform_tool;
|
||||
gint value;
|
||||
|
||||
tool = (Tool *) data;
|
||||
tool = (GimpTool *) data;
|
||||
|
||||
if (tool)
|
||||
{
|
||||
transform_core = (TransformCore *) tool->private;
|
||||
draw_tool = GIMP_DRAW_TOOL (tool);
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
||||
|
||||
value = GTK_ADJUSTMENT (widget)->value;
|
||||
|
||||
if (value != transform_core->trans_info[YSHEAR])
|
||||
if (value != transform_tool->trans_info[YSHEAR])
|
||||
{
|
||||
draw_core_pause (transform_core->core, tool);
|
||||
transform_core->trans_info[YSHEAR] = value;
|
||||
gimp_draw_tool_pause (draw_tool);
|
||||
transform_tool->trans_info[YSHEAR] = value;
|
||||
shear_tool_recalc (tool, tool->gdisp);
|
||||
draw_core_resume (transform_core->core, tool);
|
||||
gimp_draw_tool_resume (draw_tool);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
shear_tool_motion (Tool *tool,
|
||||
shear_tool_motion (GimpTool *tool,
|
||||
GDisplay *gdisp)
|
||||
{
|
||||
TransformCore *transform_core;
|
||||
gint diffx, diffy;
|
||||
gint dir;
|
||||
GimpTransformTool *transform_tool;
|
||||
gint diffx, diffy;
|
||||
gint dir;
|
||||
|
||||
transform_core = (TransformCore *) tool->private;
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
||||
|
||||
diffx = transform_core->curx - transform_core->lastx;
|
||||
diffy = transform_core->cury - transform_core->lasty;
|
||||
diffx = transform_tool->curx - transform_tool->lastx;
|
||||
diffy = transform_tool->cury - transform_tool->lasty;
|
||||
|
||||
/* If we haven't yet decided on which way to control shearing
|
||||
* decide using the maximum differential
|
||||
*/
|
||||
|
||||
if (transform_core->trans_info[HORZ_OR_VERT] == ORIENTATION_UNKNOWN)
|
||||
if (transform_tool->trans_info[HORZ_OR_VERT] == ORIENTATION_UNKNOWN)
|
||||
{
|
||||
if (abs (diffx) > MIN_MOVE || abs (diffy) > MIN_MOVE)
|
||||
{
|
||||
if (abs (diffx) > abs (diffy))
|
||||
{
|
||||
transform_core->trans_info[HORZ_OR_VERT] = ORIENTATION_HORIZONTAL;
|
||||
transform_core->trans_info[ORIENTATION_VERTICAL] = 0.0;
|
||||
transform_tool->trans_info[HORZ_OR_VERT] = ORIENTATION_HORIZONTAL;
|
||||
transform_tool->trans_info[ORIENTATION_VERTICAL] = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
transform_core->trans_info[HORZ_OR_VERT] = ORIENTATION_VERTICAL;
|
||||
transform_core->trans_info[ORIENTATION_HORIZONTAL] = 0.0;
|
||||
transform_tool->trans_info[HORZ_OR_VERT] = ORIENTATION_VERTICAL;
|
||||
transform_tool->trans_info[ORIENTATION_HORIZONTAL] = 0.0;
|
||||
}
|
||||
}
|
||||
/* set the current coords to the last ones */
|
||||
else
|
||||
{
|
||||
transform_core->curx = transform_core->lastx;
|
||||
transform_core->cury = transform_core->lasty;
|
||||
transform_tool->curx = transform_tool->lastx;
|
||||
transform_tool->cury = transform_tool->lasty;
|
||||
}
|
||||
}
|
||||
|
||||
/* if the direction is known, keep track of the magnitude */
|
||||
if (transform_core->trans_info[HORZ_OR_VERT] != ORIENTATION_UNKNOWN)
|
||||
if (transform_tool->trans_info[HORZ_OR_VERT] != ORIENTATION_UNKNOWN)
|
||||
{
|
||||
dir = transform_core->trans_info[HORZ_OR_VERT];
|
||||
switch (transform_core->function)
|
||||
dir = transform_tool->trans_info[HORZ_OR_VERT];
|
||||
switch (transform_tool->function)
|
||||
{
|
||||
case TRANSFORM_HANDLE_1:
|
||||
if (dir == ORIENTATION_HORIZONTAL)
|
||||
transform_core->trans_info[XSHEAR] -= diffx;
|
||||
transform_tool->trans_info[XSHEAR] -= diffx;
|
||||
else
|
||||
transform_core->trans_info[YSHEAR] -= diffy;
|
||||
transform_tool->trans_info[YSHEAR] -= diffy;
|
||||
break;
|
||||
case TRANSFORM_HANDLE_2:
|
||||
if (dir == ORIENTATION_HORIZONTAL)
|
||||
transform_core->trans_info[XSHEAR] -= diffx;
|
||||
transform_tool->trans_info[XSHEAR] -= diffx;
|
||||
else
|
||||
transform_core->trans_info[YSHEAR] += diffy;
|
||||
transform_tool->trans_info[YSHEAR] += diffy;
|
||||
break;
|
||||
case TRANSFORM_HANDLE_3:
|
||||
if (dir == ORIENTATION_HORIZONTAL)
|
||||
transform_core->trans_info[XSHEAR] += diffx;
|
||||
transform_tool->trans_info[XSHEAR] += diffx;
|
||||
else
|
||||
transform_core->trans_info[YSHEAR] -= diffy;
|
||||
transform_tool->trans_info[YSHEAR] -= diffy;
|
||||
break;
|
||||
case TRANSFORM_HANDLE_4:
|
||||
if (dir == ORIENTATION_HORIZONTAL)
|
||||
transform_core->trans_info[XSHEAR] += diffx;
|
||||
transform_tool->trans_info[XSHEAR] += diffx;
|
||||
else
|
||||
transform_core->trans_info[YSHEAR] += diffy;
|
||||
transform_tool->trans_info[YSHEAR] += diffy;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -309,20 +401,20 @@ shear_tool_motion (Tool *tool,
|
|||
}
|
||||
|
||||
static void
|
||||
shear_tool_recalc (Tool *tool,
|
||||
shear_tool_recalc (GimpTool *tool,
|
||||
GDisplay *gdisp)
|
||||
{
|
||||
TransformCore *transform_core;
|
||||
gfloat width, height;
|
||||
gfloat cx, cy;
|
||||
GimpTransformTool *transform_tool;
|
||||
gfloat width, height;
|
||||
gfloat cx, cy;
|
||||
|
||||
transform_core = (TransformCore *) tool->private;
|
||||
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
||||
|
||||
cx = (transform_core->x1 + transform_core->x2) / 2.0;
|
||||
cy = (transform_core->y1 + transform_core->y2) / 2.0;
|
||||
cx = (transform_tool->x1 + transform_tool->x2) / 2.0;
|
||||
cy = (transform_tool->y1 + transform_tool->y2) / 2.0;
|
||||
|
||||
width = transform_core->x2 - transform_core->x1;
|
||||
height = transform_core->y2 - transform_core->y1;
|
||||
width = transform_tool->x2 - transform_tool->x1;
|
||||
height = transform_tool->y2 - transform_tool->y1;
|
||||
|
||||
if (width == 0)
|
||||
width = 1;
|
||||
|
@ -330,47 +422,22 @@ shear_tool_recalc (Tool *tool,
|
|||
height = 1;
|
||||
|
||||
/* assemble the transformation matrix */
|
||||
gimp_matrix3_identity (transform_core->transform);
|
||||
gimp_matrix3_translate (transform_core->transform, -cx, -cy);
|
||||
gimp_matrix3_identity (transform_tool->transform);
|
||||
gimp_matrix3_translate (transform_tool->transform, -cx, -cy);
|
||||
|
||||
/* shear matrix */
|
||||
if (transform_core->trans_info[HORZ_OR_VERT] == ORIENTATION_HORIZONTAL)
|
||||
gimp_matrix3_xshear (transform_core->transform,
|
||||
(float) transform_core->trans_info [XSHEAR] / height);
|
||||
if (transform_tool->trans_info[HORZ_OR_VERT] == ORIENTATION_HORIZONTAL)
|
||||
gimp_matrix3_xshear (transform_tool->transform,
|
||||
(float) transform_tool->trans_info [XSHEAR] / height);
|
||||
else
|
||||
gimp_matrix3_yshear (transform_core->transform,
|
||||
(float) transform_core->trans_info [YSHEAR] / width);
|
||||
gimp_matrix3_yshear (transform_tool->transform,
|
||||
(float) transform_tool->trans_info [YSHEAR] / width);
|
||||
|
||||
gimp_matrix3_translate (transform_core->transform, +cx, +cy);
|
||||
gimp_matrix3_translate (transform_tool->transform, +cx, +cy);
|
||||
|
||||
/* transform the bounding box */
|
||||
transform_core_transform_bounding_box (tool);
|
||||
gimp_transform_tool_transform_bounding_box (transform_tool);
|
||||
|
||||
/* update the information dialog */
|
||||
shear_info_update (tool);
|
||||
}
|
||||
|
||||
TileManager *
|
||||
shear_tool_shear (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
GDisplay *gdisp,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix3 matrix)
|
||||
{
|
||||
GimpProgress *progress;
|
||||
TileManager *ret;
|
||||
|
||||
progress = progress_start (gdisp, _("Shearing..."), FALSE, NULL, NULL);
|
||||
|
||||
ret = transform_core_do (gimage, drawable, float_tiles,
|
||||
interpolation, matrix,
|
||||
progress ? progress_update_and_flush :
|
||||
(GimpProgressFunc) NULL,
|
||||
progress);
|
||||
|
||||
if (progress)
|
||||
progress_end (progress);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -16,19 +16,45 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __SHEAR_TOOL_H__
|
||||
#define __SHEAR_TOOL_H__
|
||||
#ifndef __GIMP_SHEAR_TOOL_H__
|
||||
#define __GIMP_SHEAR_TOOL_H__
|
||||
|
||||
|
||||
TileManager * shear_tool_shear (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
GDisplay *gdisp,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix3 matrix);
|
||||
|
||||
Tool * tools_new_shear_tool (void);
|
||||
void tools_free_shear_tool (Tool *matrix);
|
||||
#include "gimptransformtool.h"
|
||||
|
||||
|
||||
#endif /* __SHEAR_TOOL_H__ */
|
||||
#define GIMP_TYPE_SHEAR_TOOL (gimp_shear_tool_get_type ())
|
||||
#define GIMP_SHEAR_TOOL(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_SHEAR_TOOL, GimpShearTool))
|
||||
#define GIMP_IS_SHEAR_TOOL(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_SHEAR_TOOL))
|
||||
#define GIMP_SHEAR_TOOL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_SHEAR_TOOL, GimpShearToolClass))
|
||||
#define GIMP_IS_SHEAR_TOOL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_SHEAR_TOOL))
|
||||
|
||||
|
||||
typedef struct _GimpShearTool GimpShearTool;
|
||||
typedef struct _GimpShearToolClass GimpShearToolClass;
|
||||
|
||||
struct _GimpShearTool
|
||||
{
|
||||
GimpTransformTool parent_instance;
|
||||
};
|
||||
|
||||
struct _GimpShearToolClass
|
||||
{
|
||||
GimpTransformToolClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GtkType gimp_shear_tool_get_type (void);
|
||||
|
||||
void gimp_shear_tool_register (void);
|
||||
|
||||
|
||||
TileManager * gimp_shear_tool_shear (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
GDisplay *gdisp,
|
||||
TileManager *float_tiles,
|
||||
gboolean interpolation,
|
||||
GimpMatrix3 matrix);
|
||||
|
||||
|
||||
#endif /* __GIMP_SHEAR_TOOL_H__ */
|
||||
|
|
|
@ -482,10 +482,6 @@ gimp_tool_help_func (const gchar *help_data)
|
|||
|
||||
STUB(by_color_select_initialize_by_image)
|
||||
STUB(by_color_select)
|
||||
STUB(perspective_find_transform)
|
||||
STUB(perspective_tool_perspective)
|
||||
STUB(rotate_tool_rotate)
|
||||
STUB(shear_tool_shear)
|
||||
STUB(clone_non_gui)
|
||||
STUB(clone_non_gui_default)
|
||||
STUB(convolve_non_gui)
|
||||
|
|
|
@ -24,9 +24,6 @@
|
|||
|
||||
|
||||
#define GIMP_TYPE_BY_COLOR_SELECT_TOOL GTK_TYPE_NONE
|
||||
#define GIMP_TYPE_ROTATE_TOOL GTK_TYPE_NONE
|
||||
#define GIMP_TYPE_SHEAR_TOOL GTK_TYPE_NONE
|
||||
#define GIMP_TYPE_PERSPECTIVE_TOOL GTK_TYPE_NONE
|
||||
|
||||
/* The possibilities for where the cursor lies */
|
||||
#define ACTIVE_LAYER (1 << 0)
|
||||
|
|
|
@ -79,10 +79,6 @@ struct _TransformOptions
|
|||
{
|
||||
ToolOptions tool_options;
|
||||
|
||||
GtkType type;
|
||||
GtkType type_d;
|
||||
GtkWidget *type_w[4]; /* 4 radio buttons */
|
||||
|
||||
gboolean smoothing;
|
||||
gboolean smoothing_d;
|
||||
GtkWidget *smoothing_w;
|
||||
|
@ -167,8 +163,6 @@ static void gimp_transform_tool_control (GimpTool *tool,
|
|||
|
||||
static void gimp_transform_tool_draw (GimpDrawTool *draw_tool);
|
||||
|
||||
static void gimp_transform_tool_change_type (GtkType new_type);
|
||||
|
||||
static TransformOptions * transform_options_new (void);
|
||||
static void transform_options_reset (ToolOptions *tool_options);
|
||||
|
||||
|
@ -1791,16 +1785,6 @@ gimp_transform_tool_show_path_update (GtkWidget *widget,
|
|||
gimp_transform_tool_showpath_changed (0); /* resume */
|
||||
}
|
||||
|
||||
/* FIXME Do we still want to do this this way? Perhaps we should make
|
||||
separate icons for each tool. */
|
||||
|
||||
static void
|
||||
gimp_transform_tool_type_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
gimp_transform_tool_change_type ((GtkType) data);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_tool_direction_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
|
@ -1830,15 +1814,6 @@ transform_options_reset (ToolOptions *tool_options)
|
|||
|
||||
options = (TransformOptions *) tool_options;
|
||||
|
||||
/* FIXME this is gross. */
|
||||
gtk_toggle_button_set_active (((options->type_d == GIMP_TYPE_ROTATE_TOOL) ?
|
||||
GTK_TOGGLE_BUTTON (options->type_w[0]) :
|
||||
((options->type_d == GIMP_TYPE_SCALE_TOOL) ?
|
||||
GTK_TOGGLE_BUTTON (options->type_w[1]) :
|
||||
((options->type_d == GIMP_TYPE_SHEAR_TOOL) ?
|
||||
GTK_TOGGLE_BUTTON (options->type_w[2]) :
|
||||
GTK_TOGGLE_BUTTON (options->type_w[3])))),
|
||||
TRUE);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->smoothing_w),
|
||||
options->smoothing_d);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->showpath_w),
|
||||
|
@ -1861,8 +1836,8 @@ transform_options_new (void)
|
|||
TransformOptions *options;
|
||||
|
||||
GtkWidget *table;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *hbox2;
|
||||
GtkWidget *label;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *fbox;
|
||||
|
@ -1872,7 +1847,6 @@ transform_options_new (void)
|
|||
tool_options_init ((ToolOptions *) options,
|
||||
transform_options_reset);
|
||||
|
||||
options->type = options->type_d = GIMP_TYPE_SCALE_TOOL; /* FIXME: GIMP_TYPE_ROTATE_TOOL; */
|
||||
options->smoothing = options->smoothing_d = TRUE;
|
||||
options->showpath = options->showpath_d = TRUE;
|
||||
options->clip = options->clip_d = FALSE;
|
||||
|
@ -1880,43 +1854,12 @@ transform_options_new (void)
|
|||
options->grid_size = options->grid_size_d = 32;
|
||||
options->show_grid = options->show_grid_d = TRUE;
|
||||
|
||||
/* the main table */
|
||||
table = gtk_table_new (2, 2, FALSE);
|
||||
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2);
|
||||
gtk_box_pack_start (GTK_BOX (options->tool_options.main_vbox), table,
|
||||
|
||||
/* the top hbox (containing two frames) */
|
||||
hbox2 = gtk_hbox_new (FALSE, 2);
|
||||
gtk_box_pack_start (GTK_BOX (options->tool_options.main_vbox), hbox2,
|
||||
FALSE, FALSE, 0);
|
||||
|
||||
/* the left vbox */
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), vbox, 0, 1, 0, 1);
|
||||
|
||||
/* the transform type radio buttons */
|
||||
frame =
|
||||
gimp_radio_group_new (TRUE, _("Transform"),
|
||||
|
||||
_("Rotation"), gimp_transform_tool_type_callback,
|
||||
GIMP_TYPE_ROTATE_TOOL, NULL, &options->type_w[0], TRUE,
|
||||
|
||||
_("Scaling"), gimp_transform_tool_type_callback,
|
||||
GIMP_TYPE_SCALE_TOOL, NULL, &options->type_w[1], FALSE,
|
||||
|
||||
_("Shearing"), gimp_transform_tool_type_callback,
|
||||
GIMP_TYPE_SHEAR_TOOL, NULL, &options->type_w[2], FALSE,
|
||||
|
||||
_("Perspective"), gimp_transform_tool_type_callback,
|
||||
GIMP_TYPE_PERSPECTIVE_TOOL, NULL, &options->type_w[3], FALSE,
|
||||
|
||||
NULL);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
/* the right vbox */
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), vbox, 1, 2, 0, 1);
|
||||
|
||||
/* the second radio frame and box, for transform direction */
|
||||
frame = gimp_radio_group_new (TRUE, _("Tool Paradigm"),
|
||||
|
||||
|
@ -1930,12 +1873,12 @@ transform_options_new (void)
|
|||
|
||||
NULL);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox2), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
/* the grid frame */
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (hbox2), frame, FALSE, FALSE, 0);
|
||||
|
||||
fbox = gtk_vbox_new (FALSE, 1);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (fbox), 2);
|
||||
|
@ -1977,7 +1920,13 @@ transform_options_new (void)
|
|||
gtk_widget_show (fbox);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
gtk_widget_show (vbox);
|
||||
gtk_widget_show (hbox2);
|
||||
|
||||
/* the main table */
|
||||
table = gtk_table_new (1, 2, FALSE);
|
||||
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2);
|
||||
gtk_box_pack_start (GTK_BOX (options->tool_options.main_vbox), table,
|
||||
FALSE, FALSE, 0);
|
||||
|
||||
/* the smoothing toggle button */
|
||||
options->smoothing_w = gtk_check_button_new_with_label (_("Smoothing"));
|
||||
|
@ -1985,7 +1934,7 @@ transform_options_new (void)
|
|||
GTK_SIGNAL_FUNC (gimp_toggle_button_update),
|
||||
&options->smoothing);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table),
|
||||
options->smoothing_w, 0, 1, 1, 2);
|
||||
options->smoothing_w, 0, 1, 0, 1);
|
||||
gtk_widget_show (options->smoothing_w);
|
||||
|
||||
/* the showpath toggle button */
|
||||
|
@ -1994,7 +1943,7 @@ transform_options_new (void)
|
|||
GTK_SIGNAL_FUNC (gimp_transform_tool_show_path_update),
|
||||
&options->showpath);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table),
|
||||
options->showpath_w, 1, 2, 1, 2);
|
||||
options->showpath_w, 1, 2, 0, 1);
|
||||
gtk_widget_show (options->showpath_w);
|
||||
|
||||
gtk_widget_show (table);
|
||||
|
@ -2011,25 +1960,6 @@ transform_options_new (void)
|
|||
return options;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_transform_tool_change_type (GtkType new_type)
|
||||
{
|
||||
if (transform_options->type != new_type)
|
||||
{
|
||||
GimpToolInfo *tool_info;
|
||||
|
||||
/* change the type, free the old tool, create the new tool */
|
||||
transform_options->type = new_type;
|
||||
|
||||
tool_info = tool_manager_get_info_by_type (new_type);
|
||||
|
||||
if (gimp_context_get_tool (gimp_context_get_user ()) != tool_info)
|
||||
gimp_context_set_tool (gimp_context_get_user (), tool_info);
|
||||
else
|
||||
gimp_context_tool_changed (gimp_context_get_user ());
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_transform_tool_smoothing (void)
|
||||
{
|
||||
|
|
|
@ -81,10 +81,10 @@ register_tools (void)
|
|||
/* transform tools */
|
||||
|
||||
gimp_flip_tool_register ();
|
||||
/* gimp_perspective_tool_register (); */
|
||||
/* gimp_shear_tool_register (); */
|
||||
gimp_perspective_tool_register ();
|
||||
gimp_shear_tool_register ();
|
||||
gimp_scale_tool_register ();
|
||||
/* gimp_rotate_tool_register (); */
|
||||
gimp_rotate_tool_register ();
|
||||
gimp_crop_tool_register ();
|
||||
gimp_move_tool_register ();
|
||||
|
||||
|
|
|
@ -997,7 +997,7 @@ HELP
|
|||
/* Determine the perspective transform that maps from
|
||||
* the unit cube to the trans_info coordinates
|
||||
*/
|
||||
perspective_find_transform (trans_info, m);
|
||||
gimp_perspective_tool_find_transform (trans_info, m);
|
||||
|
||||
tile_manager_get_offsets (float_tiles, &offset_x, &offset_y);
|
||||
cx = (gdouble) offset_x;
|
||||
|
@ -1016,7 +1016,7 @@ HELP
|
|||
gimp_matrix3_mult (m, matrix);
|
||||
|
||||
/* Perspective the buffer */
|
||||
new_tiles = perspective_tool_perspective (gimage, drawable, NULL,
|
||||
new_tiles = gimp_perspective_tool_perspective (gimage, drawable, NULL,
|
||||
float_tiles, interpolation,
|
||||
matrix);
|
||||
|
||||
|
@ -1125,7 +1125,7 @@ HELP
|
|||
gimp_matrix3_translate (matrix, +cx, +cy);
|
||||
|
||||
/* Rotate the buffer */
|
||||
new_tiles = rotate_tool_rotate (gimage, drawable, NULL, angle,
|
||||
new_tiles = gimp_rotate_tool_rotate (gimage, drawable, NULL, angle,
|
||||
float_tiles, interpolation, matrix);
|
||||
|
||||
/* Free the cut/copied buffer */
|
||||
|
@ -1303,7 +1303,7 @@ HELP
|
|||
gimp_matrix3_translate (matrix, +cx, +cy);
|
||||
|
||||
/* Shear the buffer */
|
||||
new_tiles = shear_tool_shear (gimage, drawable, NULL, float_tiles,
|
||||
new_tiles = gimp_shear_tool_shear (gimage, drawable, NULL, float_tiles,
|
||||
interpolation, matrix);
|
||||
|
||||
/* Free the cut/copied buffer */
|
||||
|
|
|
@ -997,7 +997,7 @@ HELP
|
|||
/* Determine the perspective transform that maps from
|
||||
* the unit cube to the trans_info coordinates
|
||||
*/
|
||||
perspective_find_transform (trans_info, m);
|
||||
gimp_perspective_tool_find_transform (trans_info, m);
|
||||
|
||||
tile_manager_get_offsets (float_tiles, &offset_x, &offset_y);
|
||||
cx = (gdouble) offset_x;
|
||||
|
@ -1016,7 +1016,7 @@ HELP
|
|||
gimp_matrix3_mult (m, matrix);
|
||||
|
||||
/* Perspective the buffer */
|
||||
new_tiles = perspective_tool_perspective (gimage, drawable, NULL,
|
||||
new_tiles = gimp_perspective_tool_perspective (gimage, drawable, NULL,
|
||||
float_tiles, interpolation,
|
||||
matrix);
|
||||
|
||||
|
@ -1125,7 +1125,7 @@ HELP
|
|||
gimp_matrix3_translate (matrix, +cx, +cy);
|
||||
|
||||
/* Rotate the buffer */
|
||||
new_tiles = rotate_tool_rotate (gimage, drawable, NULL, angle,
|
||||
new_tiles = gimp_rotate_tool_rotate (gimage, drawable, NULL, angle,
|
||||
float_tiles, interpolation, matrix);
|
||||
|
||||
/* Free the cut/copied buffer */
|
||||
|
@ -1303,7 +1303,7 @@ HELP
|
|||
gimp_matrix3_translate (matrix, +cx, +cy);
|
||||
|
||||
/* Shear the buffer */
|
||||
new_tiles = shear_tool_shear (gimage, drawable, NULL, float_tiles,
|
||||
new_tiles = gimp_shear_tool_shear (gimage, drawable, NULL, float_tiles,
|
||||
interpolation, matrix);
|
||||
|
||||
/* Free the cut/copied buffer */
|
||||
|
|
|
@ -997,7 +997,7 @@ HELP
|
|||
/* Determine the perspective transform that maps from
|
||||
* the unit cube to the trans_info coordinates
|
||||
*/
|
||||
perspective_find_transform (trans_info, m);
|
||||
gimp_perspective_tool_find_transform (trans_info, m);
|
||||
|
||||
tile_manager_get_offsets (float_tiles, &offset_x, &offset_y);
|
||||
cx = (gdouble) offset_x;
|
||||
|
@ -1016,7 +1016,7 @@ HELP
|
|||
gimp_matrix3_mult (m, matrix);
|
||||
|
||||
/* Perspective the buffer */
|
||||
new_tiles = perspective_tool_perspective (gimage, drawable, NULL,
|
||||
new_tiles = gimp_perspective_tool_perspective (gimage, drawable, NULL,
|
||||
float_tiles, interpolation,
|
||||
matrix);
|
||||
|
||||
|
@ -1125,7 +1125,7 @@ HELP
|
|||
gimp_matrix3_translate (matrix, +cx, +cy);
|
||||
|
||||
/* Rotate the buffer */
|
||||
new_tiles = rotate_tool_rotate (gimage, drawable, NULL, angle,
|
||||
new_tiles = gimp_rotate_tool_rotate (gimage, drawable, NULL, angle,
|
||||
float_tiles, interpolation, matrix);
|
||||
|
||||
/* Free the cut/copied buffer */
|
||||
|
@ -1303,7 +1303,7 @@ HELP
|
|||
gimp_matrix3_translate (matrix, +cx, +cy);
|
||||
|
||||
/* Shear the buffer */
|
||||
new_tiles = shear_tool_shear (gimage, drawable, NULL, float_tiles,
|
||||
new_tiles = gimp_shear_tool_shear (gimage, drawable, NULL, float_tiles,
|
||||
interpolation, matrix);
|
||||
|
||||
/* Free the cut/copied buffer */
|
||||
|
|
|
@ -997,7 +997,7 @@ HELP
|
|||
/* Determine the perspective transform that maps from
|
||||
* the unit cube to the trans_info coordinates
|
||||
*/
|
||||
perspective_find_transform (trans_info, m);
|
||||
gimp_perspective_tool_find_transform (trans_info, m);
|
||||
|
||||
tile_manager_get_offsets (float_tiles, &offset_x, &offset_y);
|
||||
cx = (gdouble) offset_x;
|
||||
|
@ -1016,7 +1016,7 @@ HELP
|
|||
gimp_matrix3_mult (m, matrix);
|
||||
|
||||
/* Perspective the buffer */
|
||||
new_tiles = perspective_tool_perspective (gimage, drawable, NULL,
|
||||
new_tiles = gimp_perspective_tool_perspective (gimage, drawable, NULL,
|
||||
float_tiles, interpolation,
|
||||
matrix);
|
||||
|
||||
|
@ -1125,7 +1125,7 @@ HELP
|
|||
gimp_matrix3_translate (matrix, +cx, +cy);
|
||||
|
||||
/* Rotate the buffer */
|
||||
new_tiles = rotate_tool_rotate (gimage, drawable, NULL, angle,
|
||||
new_tiles = gimp_rotate_tool_rotate (gimage, drawable, NULL, angle,
|
||||
float_tiles, interpolation, matrix);
|
||||
|
||||
/* Free the cut/copied buffer */
|
||||
|
@ -1303,7 +1303,7 @@ HELP
|
|||
gimp_matrix3_translate (matrix, +cx, +cy);
|
||||
|
||||
/* Shear the buffer */
|
||||
new_tiles = shear_tool_shear (gimage, drawable, NULL, float_tiles,
|
||||
new_tiles = gimp_shear_tool_shear (gimage, drawable, NULL, float_tiles,
|
||||
interpolation, matrix);
|
||||
|
||||
/* Free the cut/copied buffer */
|
||||
|
|
Loading…
Reference in New Issue