1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* 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 2 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, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
app/appenv.h New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc
1999-09-01 Tor Lillqvist <tml@iki.fi>
* app/appenv.h
* libgimp/gimpmath.h: New file. Includes <math.h>. Move G_PI,
RINT(), ROUND() etc from app/appenv.h here, so plug-ins can
use them, too. Remove some commented-out old stuff in appenv.h.
* libgimp/gimp.h: Include gimpmath.h.
* libgimp/gimp.c (gimp_main): Win32: Don't install signal
handlers, we can't do anything useful in the handler ourselves
anyway (it would be nice to print out a backtrace, but that seems
pretty hard to do, even if not impossible). Let Windows inform the
user about the crash. If the plug-in was compiled with MSVC, and
the user also has it, she is offered a chance to start the
debugger automatically anyway.
* app/*several*.c: Include gimpmath.h for G_PI etc. Don't include
<math.h>, as gimpmath.h includes it.
* plug-ins/*/*many*.c: Include config.h. Don't include <math.h>.
Remove all the duplicated definitions of G_PI and rint(). Use
RINT() instead of rint().
* app/app_procs.[ch]: app_exit() takes a gboolean.
* app/batch.c
* app/commands.c
* app/interface.c: Call app_exit() with FALSE or TRUE.
* app/main.c (on_error): Call gimp_fatal_error. (main): Don't
install any signal handler on Win32 here, either.
* app/errors.c (gimp_fatal_error, gimp_terminate): Win32: Format
the message and call MessageBox with it. g_on_error_query doesn't
do anything useful on Win32, and printf'ing a message to stdout or
stderr doesn't do anything, either, in a windowing application.
1999-09-02 04:30:56 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-01-24 07:56:18 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-24 07:56:18 +08:00
|
|
|
|
2002-05-03 20:45:22 +08:00
|
|
|
#include "tools-types.h"
|
|
|
|
|
2002-05-11 07:30:09 +08:00
|
|
|
#ifdef __GNUC__
|
2002-05-03 20:45:22 +08:00
|
|
|
#warning FIXME #include "gui/gui-types.h"
|
2002-05-11 07:30:09 +08:00
|
|
|
#endif
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "gui/gui-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpimage.h"
|
2001-11-20 02:23:43 +08:00
|
|
|
#include "core/gimpdrawable-transform.h"
|
|
|
|
#include "core/gimpdrawable-transform-utils.h"
|
|
|
|
#include "core/gimptoolinfo.h"
|
2001-04-25 02:43:31 +08:00
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
2002-06-27 06:16:59 +08:00
|
|
|
#include "display/gimpdisplayshell.h"
|
2001-01-23 21:01:48 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
#include "gui/info-dialog.h"
|
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
#include "gimprotatetool.h"
|
2001-04-29 04:14:32 +08:00
|
|
|
#include "transform_options.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* index into trans_info array */
|
1999-06-26 19:16:47 +08:00
|
|
|
#define ANGLE 0
|
|
|
|
#define REAL_ANGLE 1
|
|
|
|
#define CENTER_X 2
|
|
|
|
#define CENTER_Y 3
|
1998-08-14 04:19:09 +08:00
|
|
|
|
1999-06-26 19:16:47 +08:00
|
|
|
#define EPSILON 0.018 /* ~ 1 degree */
|
1999-08-05 07:22:29 +08:00
|
|
|
#define FIFTEEN_DEG (G_PI / 12.0)
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
/* local function prototypes */
|
2001-04-25 02:43:31 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
static void gimp_rotate_tool_class_init (GimpRotateToolClass *klass);
|
|
|
|
static void gimp_rotate_tool_init (GimpRotateTool *rotate_tool);
|
|
|
|
|
|
|
|
static TileManager * gimp_rotate_tool_transform (GimpTransformTool *tr_tool,
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpDisplay *gdisp,
|
2001-04-25 02:43:31 +08:00
|
|
|
TransformState state);
|
2000-12-31 12:07:42 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
static void rotate_tool_recalc (GimpTransformTool *tr_tool,
|
|
|
|
GimpDisplay *gdisp);
|
|
|
|
static void rotate_tool_motion (GimpTransformTool *tr_tool,
|
|
|
|
GimpDisplay *gdisp);
|
|
|
|
static void rotate_info_update (GimpTransformTool *tr_tool);
|
2000-12-31 12:07:42 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
static void rotate_angle_changed (GtkWidget *entry,
|
|
|
|
gpointer data);
|
|
|
|
static void rotate_center_changed (GtkWidget *entry,
|
|
|
|
gpointer data);
|
2000-12-31 12:07:42 +08:00
|
|
|
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* variables local to this file */
|
1999-06-26 19:16:47 +08:00
|
|
|
static gdouble angle_val;
|
|
|
|
static gdouble center_vals[2];
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-04-06 20:13:54 +08:00
|
|
|
/* needed for size update */
|
2000-12-31 12:07:42 +08:00
|
|
|
static GtkWidget *sizeentry = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
static GimpTransformToolClass *parent_class = NULL;
|
|
|
|
|
2001-07-07 20:17:23 +08:00
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
void
|
2002-03-29 11:50:29 +08:00
|
|
|
gimp_rotate_tool_register (GimpToolRegisterCallback callback,
|
2002-05-03 19:31:08 +08:00
|
|
|
gpointer data)
|
2001-04-25 02:43:31 +08:00
|
|
|
{
|
2002-03-29 11:50:29 +08:00
|
|
|
(* callback) (GIMP_TYPE_ROTATE_TOOL,
|
2001-11-21 07:00:47 +08:00
|
|
|
transform_options_new,
|
|
|
|
FALSE,
|
2002-03-21 20:17:17 +08:00
|
|
|
"gimp-rotate-tool",
|
2001-11-21 07:00:47 +08:00
|
|
|
_("Rotate Tool"),
|
|
|
|
_("Rotate the layer or selection"),
|
|
|
|
N_("/Tools/Transform Tools/Rotate"), "<shift>R",
|
|
|
|
NULL, "tools/rotate.html",
|
2002-03-29 11:50:29 +08:00
|
|
|
GIMP_STOCK_TOOL_ROTATE,
|
2002-05-03 19:31:08 +08:00
|
|
|
data);
|
2001-04-25 02:43:31 +08:00
|
|
|
}
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
GType
|
2001-04-25 02:43:31 +08:00
|
|
|
gimp_rotate_tool_get_type (void)
|
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
static GType tool_type = 0;
|
2001-04-25 02:43:31 +08:00
|
|
|
|
|
|
|
if (! tool_type)
|
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
static const GTypeInfo tool_info =
|
2001-04-25 02:43:31 +08:00
|
|
|
{
|
|
|
|
sizeof (GimpRotateToolClass),
|
2001-08-14 22:53:55 +08:00
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_rotate_tool_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpRotateTool),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_rotate_tool_init,
|
2001-04-25 02:43:31 +08:00
|
|
|
};
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
tool_type = g_type_register_static (GIMP_TYPE_TRANSFORM_TOOL,
|
|
|
|
"GimpRotateTool",
|
|
|
|
&tool_info, 0);
|
2001-04-25 02:43:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return tool_type;
|
|
|
|
}
|
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
static void
|
|
|
|
gimp_rotate_tool_class_init (GimpRotateToolClass *klass)
|
|
|
|
{
|
|
|
|
GimpTransformToolClass *trans_class;
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
trans_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
|
2001-04-25 02:43:31 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-04-25 02:43:31 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
trans_class->transform = gimp_rotate_tool_transform;
|
2001-04-25 02:43:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_rotate_tool_init (GimpRotateTool *rotate_tool)
|
|
|
|
{
|
2001-11-21 07:00:47 +08:00
|
|
|
GimpTool *tool;
|
2001-04-25 02:43:31 +08:00
|
|
|
|
2001-11-21 07:00:47 +08:00
|
|
|
tool = GIMP_TOOL (rotate_tool);
|
2001-04-29 04:14:32 +08:00
|
|
|
|
2002-05-03 05:03:27 +08:00
|
|
|
gimp_tool_control_set_tool_cursor (tool->control, GIMP_ROTATE_TOOL_CURSOR);
|
2001-04-25 02:43:31 +08:00
|
|
|
}
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
static TileManager *
|
2001-11-20 02:23:43 +08:00
|
|
|
gimp_rotate_tool_transform (GimpTransformTool *transform_tool,
|
|
|
|
GimpDisplay *gdisp,
|
|
|
|
TransformState state)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
switch (state)
|
|
|
|
{
|
2000-12-29 23:22:01 +08:00
|
|
|
case TRANSFORM_INIT:
|
2001-11-20 02:23:43 +08:00
|
|
|
angle_val = 0.0;
|
2001-04-25 02:43:31 +08:00
|
|
|
center_vals[0] = transform_tool->cx;
|
|
|
|
center_vals[1] = transform_tool->cy;
|
1999-06-01 05:46:43 +08:00
|
|
|
|
2001-11-22 21:01:26 +08:00
|
|
|
if (! transform_tool->info_dialog)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-20 02:23:43 +08:00
|
|
|
GtkWidget *widget;
|
|
|
|
GtkWidget *spinbutton2;
|
|
|
|
|
2001-11-22 21:01:26 +08:00
|
|
|
transform_tool->info_dialog =
|
|
|
|
info_dialog_new (_("Rotation Information"),
|
|
|
|
gimp_standard_help_func,
|
|
|
|
"tools/transform_rotate.html");
|
|
|
|
|
|
|
|
gimp_transform_tool_info_dialog_connect (transform_tool,
|
2001-11-22 22:28:39 +08:00
|
|
|
GIMP_STOCK_TOOL_ROTATE);
|
1999-04-03 03:46:59 +08:00
|
|
|
|
|
|
|
widget =
|
2001-11-22 21:01:26 +08:00
|
|
|
info_dialog_add_spinbutton (transform_tool->info_dialog, _("Angle:"),
|
1999-04-03 03:46:59 +08:00
|
|
|
&angle_val,
|
|
|
|
-180, 180, 1, 15, 1, 1, 2,
|
2001-08-01 10:57:58 +08:00
|
|
|
G_CALLBACK (rotate_angle_changed),
|
2001-11-20 02:23:43 +08:00
|
|
|
transform_tool);
|
1999-04-03 03:46:59 +08:00
|
|
|
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (widget), TRUE);
|
|
|
|
|
1999-07-09 22:51:01 +08:00
|
|
|
/* this looks strange (-180, 181), but it works */
|
2001-11-22 21:01:26 +08:00
|
|
|
widget = info_dialog_add_scale (transform_tool->info_dialog, "",
|
|
|
|
&angle_val,
|
1999-07-09 22:51:01 +08:00
|
|
|
-180, 181, 0.01, 0.1, 1, -1,
|
2001-08-01 10:57:58 +08:00
|
|
|
G_CALLBACK (rotate_angle_changed),
|
2001-11-20 02:23:43 +08:00
|
|
|
transform_tool);
|
2001-12-29 21:26:29 +08:00
|
|
|
gtk_widget_set_size_request (widget, 180, -1);
|
1999-04-03 03:46:59 +08:00
|
|
|
|
|
|
|
spinbutton2 =
|
2001-11-22 21:01:26 +08:00
|
|
|
info_dialog_add_spinbutton (transform_tool->info_dialog,
|
|
|
|
_("Center X:"),
|
|
|
|
NULL,
|
1999-04-03 03:46:59 +08:00
|
|
|
-1, 1, 1, 10, 1, 1, 2, NULL, NULL);
|
1999-04-06 20:13:54 +08:00
|
|
|
sizeentry =
|
2001-11-22 21:01:26 +08:00
|
|
|
info_dialog_add_sizeentry (transform_tool->info_dialog, _("Y:"),
|
1999-04-03 03:46:59 +08:00
|
|
|
center_vals, 1,
|
1999-05-23 01:56:35 +08:00
|
|
|
gdisp->gimage->unit, "%a",
|
1999-04-06 20:13:54 +08:00
|
|
|
TRUE, TRUE, FALSE,
|
1999-04-05 20:48:48 +08:00
|
|
|
GIMP_SIZE_ENTRY_UPDATE_SIZE,
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
G_CALLBACK (rotate_center_changed),
|
2001-11-20 02:23:43 +08:00
|
|
|
transform_tool);
|
1999-06-01 05:46:43 +08:00
|
|
|
|
1999-04-06 20:13:54 +08:00
|
|
|
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (sizeentry),
|
1999-04-05 20:48:48 +08:00
|
|
|
GTK_SPIN_BUTTON (spinbutton2), NULL);
|
1999-04-03 03:46:59 +08:00
|
|
|
|
2001-11-22 21:01:26 +08:00
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (transform_tool->info_dialog->info_table),
|
1999-04-03 03:46:59 +08:00
|
|
|
1, 6);
|
2001-11-22 21:01:26 +08:00
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (transform_tool->info_dialog->info_table),
|
1999-04-03 03:46:59 +08:00
|
|
|
2, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1999-06-01 05:46:43 +08:00
|
|
|
|
2001-08-01 10:57:58 +08:00
|
|
|
g_signal_handlers_block_by_func (G_OBJECT (sizeentry),
|
|
|
|
rotate_center_changed,
|
2001-11-20 02:23:43 +08:00
|
|
|
transform_tool);
|
1999-06-01 05:46:43 +08:00
|
|
|
|
|
|
|
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry),
|
|
|
|
gdisp->gimage->unit);
|
2002-06-27 06:16:59 +08:00
|
|
|
|
|
|
|
if (GIMP_DISPLAY_SHELL (gdisp->shell)->dot_for_dot)
|
2000-02-08 04:35:13 +08:00
|
|
|
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), GIMP_UNIT_PIXEL);
|
1999-06-01 05:46:43 +08:00
|
|
|
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0,
|
|
|
|
gdisp->gimage->xresolution, FALSE);
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 1,
|
|
|
|
gdisp->gimage->yresolution, FALSE);
|
|
|
|
|
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 0,
|
|
|
|
-65536,
|
|
|
|
65536 + gdisp->gimage->width);
|
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 1,
|
|
|
|
-65536,
|
|
|
|
65536 + gdisp->gimage->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-04-06 20:13:54 +08:00
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (sizeentry), 0,
|
2001-04-25 02:43:31 +08:00
|
|
|
transform_tool->x1, transform_tool->x2);
|
1999-04-06 20:13:54 +08:00
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (sizeentry), 1,
|
2001-04-25 02:43:31 +08:00
|
|
|
transform_tool->y1, transform_tool->y2);
|
1999-04-06 20:13:54 +08:00
|
|
|
|
1999-06-01 05:46:43 +08:00
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 0,
|
|
|
|
center_vals[0]);
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 1,
|
|
|
|
center_vals[1]);
|
|
|
|
|
2001-08-01 10:57:58 +08:00
|
|
|
g_signal_handlers_unblock_by_func (G_OBJECT (sizeentry),
|
|
|
|
rotate_center_changed,
|
2001-11-20 02:23:43 +08:00
|
|
|
transform_tool);
|
|
|
|
|
2001-11-22 21:01:26 +08:00
|
|
|
gtk_widget_set_sensitive (transform_tool->info_dialog->shell, TRUE);
|
1999-06-01 05:46:43 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
transform_tool->trans_info[ANGLE] = angle_val;
|
2001-04-25 02:43:31 +08:00
|
|
|
transform_tool->trans_info[REAL_ANGLE] = angle_val;
|
2001-11-09 03:14:51 +08:00
|
|
|
transform_tool->trans_info[CENTER_X] = center_vals[0];
|
|
|
|
transform_tool->trans_info[CENTER_Y] = center_vals[1];
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
case TRANSFORM_MOTION:
|
2001-11-20 02:23:43 +08:00
|
|
|
rotate_tool_motion (transform_tool, gdisp);
|
|
|
|
rotate_tool_recalc (transform_tool, gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
case TRANSFORM_RECALC:
|
2001-11-20 02:23:43 +08:00
|
|
|
rotate_tool_recalc (transform_tool, gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
case TRANSFORM_FINISH:
|
2001-11-20 02:23:43 +08:00
|
|
|
return gimp_transform_tool_transform_tiles (transform_tool,
|
|
|
|
_("Rotating..."));
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-20 02:23:43 +08:00
|
|
|
rotate_info_update (GimpTransformTool *transform_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-04-25 02:43:31 +08:00
|
|
|
angle_val = gimp_rad_to_deg (transform_tool->trans_info[ANGLE]);
|
2001-11-09 03:14:51 +08:00
|
|
|
center_vals[0] = transform_tool->trans_info[CENTER_X];
|
|
|
|
center_vals[1] = transform_tool->trans_info[CENTER_Y];
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-22 21:01:26 +08:00
|
|
|
info_dialog_update (transform_tool->info_dialog);
|
|
|
|
info_dialog_popup (transform_tool->info_dialog);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-08-15 21:34:54 +08:00
|
|
|
static void
|
2000-01-05 19:18:38 +08:00
|
|
|
rotate_angle_changed (GtkWidget *widget,
|
1999-04-03 03:46:59 +08:00
|
|
|
gpointer data)
|
1998-08-15 21:34:54 +08:00
|
|
|
{
|
2001-04-25 02:43:31 +08:00
|
|
|
GimpTool *tool;
|
|
|
|
GimpTransformTool *transform_tool;
|
|
|
|
gdouble value;
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
tool = GIMP_TOOL (data);
|
|
|
|
transform_tool = GIMP_TRANSFORM_TOOL (data);
|
|
|
|
|
|
|
|
value = gimp_deg_to_rad (GTK_ADJUSTMENT (widget)->value);
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
if (value != transform_tool->trans_info[ANGLE])
|
1998-08-15 21:34:54 +08:00
|
|
|
{
|
2001-11-20 02:23:43 +08:00
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
transform_tool->trans_info[ANGLE] = value;
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
rotate_tool_recalc (transform_tool, tool->gdisp);
|
|
|
|
|
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
1998-08-15 21:34:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-01-05 19:18:38 +08:00
|
|
|
rotate_center_changed (GtkWidget *widget,
|
1999-04-03 03:46:59 +08:00
|
|
|
gpointer data)
|
1998-08-15 21:34:54 +08:00
|
|
|
{
|
2001-04-25 02:43:31 +08:00
|
|
|
GimpTool *tool;
|
|
|
|
GimpTransformTool *transform_tool;
|
2002-02-20 00:35:13 +08:00
|
|
|
gdouble cx;
|
|
|
|
gdouble cy;
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
tool = GIMP_TOOL (data);
|
|
|
|
transform_tool = GIMP_TRANSFORM_TOOL (data);
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2002-02-20 00:35:13 +08:00
|
|
|
cx = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0);
|
|
|
|
cy = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1);
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
if ((cx != transform_tool->trans_info[CENTER_X]) ||
|
|
|
|
(cy != transform_tool->trans_info[CENTER_Y]))
|
|
|
|
{
|
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
transform_tool->trans_info[CENTER_X] = cx;
|
|
|
|
transform_tool->trans_info[CENTER_Y] = cy;
|
|
|
|
transform_tool->cx = cx;
|
|
|
|
transform_tool->cy = cy;
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
rotate_tool_recalc (transform_tool, tool->gdisp);
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
1998-08-15 21:34:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
2001-11-20 02:23:43 +08:00
|
|
|
rotate_tool_motion (GimpTransformTool *transform_tool,
|
|
|
|
GimpDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-30 00:44:51 +08:00
|
|
|
TransformOptions *options;
|
|
|
|
gdouble angle1, angle2, angle;
|
|
|
|
gdouble cx, cy;
|
|
|
|
gdouble x1, y1, x2, y2;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
if (transform_tool->function == TRANSFORM_HANDLE_CENTER)
|
1998-08-14 04:19:09 +08:00
|
|
|
{
|
2001-11-09 03:14:51 +08:00
|
|
|
transform_tool->trans_info[CENTER_X] = transform_tool->curx;
|
|
|
|
transform_tool->trans_info[CENTER_Y] = transform_tool->cury;
|
2001-11-20 02:23:43 +08:00
|
|
|
transform_tool->cx = transform_tool->curx;
|
|
|
|
transform_tool->cy = transform_tool->cury;
|
1998-08-14 04:19:09 +08:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-11-30 00:44:51 +08:00
|
|
|
options = (TransformOptions *) GIMP_TOOL (transform_tool)->tool_info->tool_options;
|
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
cx = transform_tool->trans_info[CENTER_X];
|
|
|
|
cy = transform_tool->trans_info[CENTER_Y];
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-20 00:35:13 +08:00
|
|
|
x1 = transform_tool->curx - cx;
|
2001-04-25 02:43:31 +08:00
|
|
|
x2 = transform_tool->lastx - cx;
|
|
|
|
y1 = cy - transform_tool->cury;
|
|
|
|
y2 = cy - transform_tool->lasty;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* find the first angle */
|
|
|
|
angle1 = atan2 (y1, x1);
|
|
|
|
|
|
|
|
/* find the angle */
|
|
|
|
angle2 = atan2 (y2, x2);
|
|
|
|
|
|
|
|
angle = angle2 - angle1;
|
|
|
|
|
1999-08-05 07:22:29 +08:00
|
|
|
if (angle > G_PI || angle < -G_PI)
|
2000-02-19 02:20:04 +08:00
|
|
|
angle = angle2 - ((angle1 < 0) ? 2.0 * G_PI + angle1 : angle1 - 2.0 * G_PI);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* increment the transform tool's angle */
|
2001-04-25 02:43:31 +08:00
|
|
|
transform_tool->trans_info[REAL_ANGLE] += angle;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* limit the angle to between 0 and 360 degrees */
|
2001-04-25 02:43:31 +08:00
|
|
|
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;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-05-31 22:11:10 +08:00
|
|
|
/* constrain the angle to 15-degree multiples if ctrl is held down */
|
2001-11-30 00:44:51 +08:00
|
|
|
if (options->constrain_1)
|
|
|
|
{
|
|
|
|
transform_tool->trans_info[ANGLE] =
|
|
|
|
FIFTEEN_DEG * (int) ((transform_tool->trans_info[REAL_ANGLE] +
|
|
|
|
FIFTEEN_DEG / 2.0) /
|
|
|
|
FIFTEEN_DEG);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2001-11-30 00:44:51 +08:00
|
|
|
{
|
|
|
|
transform_tool->trans_info[ANGLE] = transform_tool->trans_info[REAL_ANGLE];
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-01-05 19:18:38 +08:00
|
|
|
static void
|
2001-11-20 02:23:43 +08:00
|
|
|
rotate_tool_recalc (GimpTransformTool *transform_tool,
|
|
|
|
GimpDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-20 02:23:43 +08:00
|
|
|
gdouble cx, cy;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
cx = transform_tool->trans_info[CENTER_X];
|
|
|
|
cy = transform_tool->trans_info[CENTER_Y];
|
|
|
|
|
|
|
|
transform_tool->cx = cx;
|
|
|
|
transform_tool->cy = cy;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-20 00:35:13 +08:00
|
|
|
gimp_drawable_transform_matrix_rotate_center (transform_tool->cx,
|
|
|
|
transform_tool->cy,
|
|
|
|
transform_tool->trans_info[ANGLE],
|
|
|
|
transform_tool->transform);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* transform the bounding box */
|
2001-04-25 02:43:31 +08:00
|
|
|
gimp_transform_tool_transform_bounding_box (transform_tool);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* update the information dialog */
|
2001-11-20 02:23:43 +08:00
|
|
|
rotate_info_update (transform_tool);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|