gimptransformtool.h 5.72 KB
Newer Older
1
/* GIMP - The GNU Image Manipulation Program
2 3
 * Copyright (C) 1995-2001 Spencer Kimball, Peter Mattis, and others
 *
4
 * This program is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 3 of the License, or
7 8 9 10 11 12 13 14
 * (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
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 17 18 19 20 21
 */

#ifndef __GIMP_TRANSFORM_TOOL_H__
#define __GIMP_TRANSFORM_TOOL_H__


22
#include "libgimpmath/gimpmatrix.h"
23
#include "gimpdrawtool.h"
24

25

26
#define TRANS_INFO_SIZE  8
27 28


29
typedef gdouble TransInfo[TRANS_INFO_SIZE];
30

31 32

#define GIMP_TYPE_TRANSFORM_TOOL            (gimp_transform_tool_get_type ())
33 34
#define GIMP_TRANSFORM_TOOL(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TRANSFORM_TOOL, GimpTransformTool))
#define GIMP_TRANSFORM_TOOL_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TRANSFORM_TOOL, GimpTransformToolClass))
35
#define GIMP_IS_TRANSFORM_TOOL(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_TRANSFORM_TOOL))
36
#define GIMP_IS_TRANSFORM_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_TRANSFORM_TOOL))
37
#define GIMP_TRANSFORM_TOOL_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_TRANSFORM_TOOL, GimpTransformToolClass))
38

39 40
#define GIMP_TRANSFORM_TOOL_GET_OPTIONS(t)  (GIMP_TRANSFORM_OPTIONS (gimp_tool_get_options (GIMP_TOOL (t))))

41 42 43

typedef struct _GimpTransformToolClass GimpTransformToolClass;

44 45 46 47
struct _GimpTransformTool
{
  GimpDrawTool    parent_instance;

48 49
  gdouble         startx;          /*  starting x coord                  */
  gdouble         starty;          /*  starting y coord                  */
50

51 52
  gdouble         curx;            /*  current x coord                   */
  gdouble         cury;            /*  current y coord                   */
53

54 55
  gdouble         lastx;           /*  last x coord                      */
  gdouble         lasty;           /*  last y coord                      */
56

57
  GdkModifierType state;           /*  state of buttons and keys         */
58

59 60 61
  gint            x1, y1;          /*  upper left hand coordinate        */
  gint            x2, y2;          /*  lower right hand coords           */
  gdouble         cx, cy;          /*  center point (for rotation)       */
62
  gdouble         aspect;          /*  original aspect ratio             */
63

64
  gdouble         tx1, ty1;        /*  transformed handle coords         */
65 66 67
  gdouble         tx2, ty2;
  gdouble         tx3, ty3;
  gdouble         tx4, ty4;
68
  gdouble         tcx, tcy;
69

70 71
  GimpMatrix3     transform;       /*  transformation matrix             */
  TransInfo       trans_info;      /*  transformation info               */
72 73
  TransInfo       old_trans_info;  /*  for resetting everything          */
  TransInfo       prev_trans_info; /*  for cancelling a drag operation   */
74

75
  TransformAction function;        /*  current tool activity             */
76

77 78 79 80
  gboolean        use_grid;        /*  does the tool use the grid        */
  gboolean        use_handles;     /*  uses the corner handles           */
  gboolean        use_center;      /*  uses the center handle            */
  gboolean        use_mid_handles; /*  use handles at midpoints of edges */
81

82 83 84
  gint            handle_w;        /*  handle width                      */
  gint            handle_h;        /*  handle height                     */

85 86 87 88 89 90 91 92
  gint            ngx, ngy;        /*  number of grid lines in original
                                    *  x and y directions
                                    */
  gdouble        *grid_coords;     /*  x and y coordinates of the grid
                                    *  endpoints (a total of (ngx+ngy)*2
                                    *  coordinate pairs)
                                    */
  gdouble        *tgrid_coords;    /*  transformed grid_coords           */
93

94 95
  GimpTransformType       type;
  GimpTransformDirection  direction;
96

97
  const gchar    *undo_desc;
98
  const gchar    *progress_text;
99

100
  GtkWidget      *dialog;
101 102
};

103 104
struct _GimpTransformToolClass
{
105 106
  GimpDrawToolClass parent_class;

107
  /*  virtual functions  */
108 109 110
  void          (* dialog)        (GimpTransformTool *tool);
  void          (* dialog_update) (GimpTransformTool *tool);
  void          (* prepare)       (GimpTransformTool *tool,
111
                                   GimpDisplay       *display);
112
  void          (* motion)        (GimpTransformTool *tool,
113
                                   GimpDisplay       *display);
114
  void          (* recalc)        (GimpTransformTool *tool,
115
                                   GimpDisplay       *display);
116 117
  TileManager * (* transform)     (GimpTransformTool *tool,
                                   GimpItem          *item,
118
                                   GimpDisplay       *display,
119 120 121
                                   TileManager       *orig_tiles,
                                   gint               orig_offset_x,
                                   gint               orig_offset_y,
122 123
                                   gint              *new_offset_x,
                                   gint              *new_offset_y);
Nate Summers's avatar
Nate Summers committed
124
};
125 126


127
GType   gimp_transform_tool_get_type       (void) G_GNUC_CONST;
128

129
void    gimp_transform_tool_recalc         (GimpTransformTool *tr_tool,
130
                                            GimpDisplay       *display);
131
void    gimp_transform_tool_expose_preview (GimpTransformTool *tr_tool);
132

133

134
#endif  /*  __GIMP_TRANSFORM_TOOL_H__  */