~ubuntu-branches/ubuntu/vivid/gimp/vivid

« back to all changes in this revision

Viewing changes to app/pdb/item-transform-cmds.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach
  • Date: 2012-05-08 18:50:03 UTC
  • mto: (1.1.26) (0.5.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 71.
  • Revision ID: package-import@ubuntu.com-20120508185003-tltkvbaysf8d2426
ImportĀ upstreamĀ versionĀ 2.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* GIMP - The GNU Image Manipulation Program
 
2
 * Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
 
3
 *
 
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
 * (at your option) any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * 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
/* NOTE: This file is auto-generated by pdbgen.pl. */
 
19
 
 
20
#include "config.h"
 
21
 
 
22
#include <gegl.h>
 
23
 
 
24
#include "libgimpmath/gimpmath.h"
 
25
 
 
26
#include "pdb-types.h"
 
27
 
 
28
#include "core/gimp-transform-utils.h"
 
29
#include "core/gimpchannel.h"
 
30
#include "core/gimpdrawable-transform.h"
 
31
#include "core/gimpdrawable.h"
 
32
#include "core/gimpimage.h"
 
33
#include "core/gimpitem.h"
 
34
#include "core/gimpparamspecs.h"
 
35
#include "core/gimpprogress.h"
 
36
 
 
37
#include "gimppdb.h"
 
38
#include "gimppdb-utils.h"
 
39
#include "gimppdbcontext.h"
 
40
#include "gimpprocedure.h"
 
41
#include "internal-procs.h"
 
42
 
 
43
#include "gimp-intl.h"
 
44
 
 
45
 
 
46
static GValueArray *
 
47
item_transform_flip_simple_invoker (GimpProcedure      *procedure,
 
48
                                    Gimp               *gimp,
 
49
                                    GimpContext        *context,
 
50
                                    GimpProgress       *progress,
 
51
                                    const GValueArray  *args,
 
52
                                    GError            **error)
 
53
{
 
54
  gboolean success = TRUE;
 
55
  GValueArray *return_vals;
 
56
  GimpItem *item;
 
57
  gint32 flip_type;
 
58
  gboolean auto_center;
 
59
  gdouble axis;
 
60
 
 
61
  item = gimp_value_get_item (&args->values[0], gimp);
 
62
  flip_type = g_value_get_enum (&args->values[1]);
 
63
  auto_center = g_value_get_boolean (&args->values[2]);
 
64
  axis = g_value_get_double (&args->values[3]);
 
65
 
 
66
  if (success)
 
67
    {
 
68
      gint x, y, width, height;
 
69
 
 
70
      success = gimp_pdb_item_is_attached (item, NULL, TRUE, error);
 
71
 
 
72
      if (success &&
 
73
          gimp_item_mask_intersect (item, &x, &y, &width, &height))
 
74
        {
 
75
          GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context);
 
76
          gint            off_x, off_y;
 
77
 
 
78
          gimp_item_get_offset (item, &off_x, &off_y);
 
79
          x += off_x;
 
80
          y += off_y;
 
81
 
 
82
          gimp_transform_get_flip_axis (x, y, width, height,
 
83
                                        flip_type, auto_center, &axis);
 
84
 
 
85
          if (GIMP_IS_DRAWABLE (item) &&
 
86
              ! gimp_viewable_get_children (GIMP_VIEWABLE (item)) &&
 
87
              ! gimp_channel_is_empty (gimp_image_get_mask (gimp_item_get_image (item))))
 
88
            {
 
89
              GimpDrawable *drawable;
 
90
 
 
91
              drawable = gimp_drawable_transform_flip (GIMP_DRAWABLE (item), context,
 
92
                                                       flip_type, axis,
 
93
                                                       pdb_context->transform_resize);
 
94
 
 
95
              if (drawable)
 
96
                item = GIMP_ITEM (drawable);
 
97
              else
 
98
                success = FALSE;
 
99
            }
 
100
          else
 
101
            {
 
102
              gimp_item_flip (item, context,
 
103
                              flip_type, axis,
 
104
                              pdb_context->transform_resize);
 
105
            }
 
106
        }
 
107
    }
 
108
 
 
109
  return_vals = gimp_procedure_get_return_values (procedure, success,
 
110
                                                  error ? *error : NULL);
 
111
 
 
112
  if (success)
 
113
    gimp_value_set_item (&return_vals->values[1], item);
 
114
 
 
115
  return return_vals;
 
116
}
 
117
 
 
118
static GValueArray *
 
119
item_transform_flip_invoker (GimpProcedure      *procedure,
 
120
                             Gimp               *gimp,
 
121
                             GimpContext        *context,
 
122
                             GimpProgress       *progress,
 
123
                             const GValueArray  *args,
 
124
                             GError            **error)
 
125
{
 
126
  gboolean success = TRUE;
 
127
  GValueArray *return_vals;
 
128
  GimpItem *item;
 
129
  gdouble x0;
 
130
  gdouble y0;
 
131
  gdouble x1;
 
132
  gdouble y1;
 
133
 
 
134
  item = gimp_value_get_item (&args->values[0], gimp);
 
135
  x0 = g_value_get_double (&args->values[1]);
 
136
  y0 = g_value_get_double (&args->values[2]);
 
137
  x1 = g_value_get_double (&args->values[3]);
 
138
  y1 = g_value_get_double (&args->values[4]);
 
139
 
 
140
  if (success)
 
141
    {
 
142
      gint x, y, width, height;
 
143
 
 
144
      success = gimp_pdb_item_is_attached (item, NULL, TRUE, error);
 
145
 
 
146
      if (success &&
 
147
          gimp_item_mask_intersect (item, &x, &y, &width, &height))
 
148
        {
 
149
          GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context);
 
150
          GimpMatrix3     matrix;
 
151
          gint            off_x, off_y;
 
152
 
 
153
          gimp_item_get_offset (item, &off_x, &off_y);
 
154
          x += off_x;
 
155
          y += off_y;
 
156
 
 
157
          /* Assemble the transformation matrix */
 
158
          gimp_matrix3_identity (&matrix);
 
159
          gimp_transform_matrix_flip_free (&matrix, x0, y0, x1, y1);
 
160
 
 
161
          if (progress)
 
162
            gimp_progress_start (progress, _("Flipping"), FALSE);
 
163
 
 
164
          if (GIMP_IS_DRAWABLE (item) &&
 
165
              ! gimp_viewable_get_children (GIMP_VIEWABLE (item)) &&
 
166
              ! gimp_channel_is_empty (gimp_image_get_mask (gimp_item_get_image (item))))
 
167
            {
 
168
              GimpDrawable *drawable;
 
169
 
 
170
              drawable = gimp_drawable_transform_affine (GIMP_DRAWABLE (item),
 
171
                                                         context, &matrix,
 
172
                                                         pdb_context->transform_direction,
 
173
                                                         pdb_context->interpolation,
 
174
                                                         pdb_context->transform_recursion,
 
175
                                                         pdb_context->transform_resize,
 
176
                                                         progress);
 
177
 
 
178
              if (drawable)
 
179
                item = GIMP_ITEM (drawable);
 
180
              else
 
181
                success = FALSE;
 
182
            }
 
183
          else
 
184
            {
 
185
              gimp_item_transform (item, context, &matrix,
 
186
                                   pdb_context->transform_direction,
 
187
                                   pdb_context->interpolation,
 
188
                                   pdb_context->transform_recursion,
 
189
                                   pdb_context->transform_resize,
 
190
                                   progress);
 
191
            }
 
192
 
 
193
          if (progress)
 
194
            gimp_progress_end (progress);
 
195
        }
 
196
    }
 
197
 
 
198
  return_vals = gimp_procedure_get_return_values (procedure, success,
 
199
                                                  error ? *error : NULL);
 
200
 
 
201
  if (success)
 
202
    gimp_value_set_item (&return_vals->values[1], item);
 
203
 
 
204
  return return_vals;
 
205
}
 
206
 
 
207
static GValueArray *
 
208
item_transform_perspective_invoker (GimpProcedure      *procedure,
 
209
                                    Gimp               *gimp,
 
210
                                    GimpContext        *context,
 
211
                                    GimpProgress       *progress,
 
212
                                    const GValueArray  *args,
 
213
                                    GError            **error)
 
214
{
 
215
  gboolean success = TRUE;
 
216
  GValueArray *return_vals;
 
217
  GimpItem *item;
 
218
  gdouble x0;
 
219
  gdouble y0;
 
220
  gdouble x1;
 
221
  gdouble y1;
 
222
  gdouble x2;
 
223
  gdouble y2;
 
224
  gdouble x3;
 
225
  gdouble y3;
 
226
 
 
227
  item = gimp_value_get_item (&args->values[0], gimp);
 
228
  x0 = g_value_get_double (&args->values[1]);
 
229
  y0 = g_value_get_double (&args->values[2]);
 
230
  x1 = g_value_get_double (&args->values[3]);
 
231
  y1 = g_value_get_double (&args->values[4]);
 
232
  x2 = g_value_get_double (&args->values[5]);
 
233
  y2 = g_value_get_double (&args->values[6]);
 
234
  x3 = g_value_get_double (&args->values[7]);
 
235
  y3 = g_value_get_double (&args->values[8]);
 
236
 
 
237
  if (success)
 
238
    {
 
239
      gint x, y, width, height;
 
240
 
 
241
      success = gimp_pdb_item_is_attached (item, NULL, TRUE, error);
 
242
 
 
243
      if (success &&
 
244
          gimp_item_mask_intersect (item, &x, &y, &width, &height))
 
245
        {
 
246
          GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context);
 
247
          GimpMatrix3     matrix;
 
248
          gint            off_x, off_y;
 
249
 
 
250
          gimp_item_get_offset (item, &off_x, &off_y);
 
251
          x += off_x;
 
252
          y += off_y;
 
253
 
 
254
          /* Assemble the transformation matrix */
 
255
          gimp_matrix3_identity (&matrix);
 
256
          gimp_transform_matrix_perspective (&matrix,
 
257
                                             x, y, width, height,
 
258
                                             x0, y0, x1, y1,
 
259
                                             x2, y2, x3, y3);
 
260
 
 
261
          if (progress)
 
262
            gimp_progress_start (progress, _("Perspective"), FALSE);
 
263
 
 
264
          if (GIMP_IS_DRAWABLE (item) &&
 
265
              ! gimp_viewable_get_children (GIMP_VIEWABLE (item)) &&
 
266
              ! gimp_channel_is_empty (gimp_image_get_mask (gimp_item_get_image (item))))
 
267
            {
 
268
              GimpDrawable *drawable;
 
269
 
 
270
              drawable = gimp_drawable_transform_affine (GIMP_DRAWABLE (item),
 
271
                                                         context, &matrix,
 
272
                                                         pdb_context->transform_direction,
 
273
                                                         pdb_context->interpolation,
 
274
                                                         pdb_context->transform_recursion,
 
275
                                                         pdb_context->transform_resize,
 
276
                                                         progress);
 
277
 
 
278
              if (drawable)
 
279
                item = GIMP_ITEM (drawable);
 
280
              else
 
281
                success = FALSE;
 
282
            }
 
283
          else
 
284
            {
 
285
              gimp_item_transform (item, context, &matrix,
 
286
                                   pdb_context->transform_direction,
 
287
                                   pdb_context->interpolation,
 
288
                                   pdb_context->transform_recursion,
 
289
                                   pdb_context->transform_resize,
 
290
                                   progress);
 
291
            }
 
292
 
 
293
          if (progress)
 
294
            gimp_progress_end (progress);
 
295
        }
 
296
    }
 
297
 
 
298
  return_vals = gimp_procedure_get_return_values (procedure, success,
 
299
                                                  error ? *error : NULL);
 
300
 
 
301
  if (success)
 
302
    gimp_value_set_item (&return_vals->values[1], item);
 
303
 
 
304
  return return_vals;
 
305
}
 
306
 
 
307
static GValueArray *
 
308
item_transform_rotate_simple_invoker (GimpProcedure      *procedure,
 
309
                                      Gimp               *gimp,
 
310
                                      GimpContext        *context,
 
311
                                      GimpProgress       *progress,
 
312
                                      const GValueArray  *args,
 
313
                                      GError            **error)
 
314
{
 
315
  gboolean success = TRUE;
 
316
  GValueArray *return_vals;
 
317
  GimpItem *item;
 
318
  gint32 rotate_type;
 
319
  gboolean auto_center;
 
320
  gdouble center_x;
 
321
  gdouble center_y;
 
322
 
 
323
  item = gimp_value_get_item (&args->values[0], gimp);
 
324
  rotate_type = g_value_get_enum (&args->values[1]);
 
325
  auto_center = g_value_get_boolean (&args->values[2]);
 
326
  center_x = g_value_get_double (&args->values[3]);
 
327
  center_y = g_value_get_double (&args->values[4]);
 
328
 
 
329
  if (success)
 
330
    {
 
331
      gint x, y, width, height;
 
332
 
 
333
      success = gimp_pdb_item_is_attached (item, NULL, FALSE, error);
 
334
 
 
335
      if (success &&
 
336
          gimp_item_mask_intersect (item, &x, &y, &width, &height))
 
337
        {
 
338
          GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context);
 
339
          gint            off_x, off_y;
 
340
 
 
341
          gimp_item_get_offset (item, &off_x, &off_y);
 
342
          x += off_x;
 
343
          y += off_y;
 
344
 
 
345
          gimp_transform_get_rotate_center (x, y, width, height,
 
346
                                            auto_center, &center_x, &center_y);
 
347
 
 
348
          if (GIMP_IS_DRAWABLE (item) &&
 
349
              ! gimp_viewable_get_children (GIMP_VIEWABLE (item)) &&
 
350
              ! gimp_channel_is_empty (gimp_image_get_mask (gimp_item_get_image (item))))
 
351
            {
 
352
              GimpDrawable *drawable;
 
353
 
 
354
              drawable = gimp_drawable_transform_rotate (GIMP_DRAWABLE (item),
 
355
                                                         context,
 
356
                                                         rotate_type,
 
357
                                                         center_x, center_y,
 
358
                                                         pdb_context->transform_resize);
 
359
 
 
360
              if (drawable)
 
361
                item = GIMP_ITEM (drawable);
 
362
              else
 
363
                success = FALSE;
 
364
            }
 
365
          else
 
366
            {
 
367
              gimp_item_rotate (item, context,
 
368
                                rotate_type,
 
369
                                center_x, center_y,
 
370
                                pdb_context->transform_resize);
 
371
            }
 
372
        }
 
373
    }
 
374
 
 
375
  return_vals = gimp_procedure_get_return_values (procedure, success,
 
376
                                                  error ? *error : NULL);
 
377
 
 
378
  if (success)
 
379
    gimp_value_set_item (&return_vals->values[1], item);
 
380
 
 
381
  return return_vals;
 
382
}
 
383
 
 
384
static GValueArray *
 
385
item_transform_rotate_invoker (GimpProcedure      *procedure,
 
386
                               Gimp               *gimp,
 
387
                               GimpContext        *context,
 
388
                               GimpProgress       *progress,
 
389
                               const GValueArray  *args,
 
390
                               GError            **error)
 
391
{
 
392
  gboolean success = TRUE;
 
393
  GValueArray *return_vals;
 
394
  GimpItem *item;
 
395
  gdouble angle;
 
396
  gboolean auto_center;
 
397
  gdouble center_x;
 
398
  gdouble center_y;
 
399
 
 
400
  item = gimp_value_get_item (&args->values[0], gimp);
 
401
  angle = g_value_get_double (&args->values[1]);
 
402
  auto_center = g_value_get_boolean (&args->values[2]);
 
403
  center_x = g_value_get_double (&args->values[3]);
 
404
  center_y = g_value_get_double (&args->values[4]);
 
405
 
 
406
  if (success)
 
407
    {
 
408
      gint x, y, width, height;
 
409
 
 
410
      success = gimp_pdb_item_is_attached (item, NULL, TRUE, error);
 
411
 
 
412
      if (success &&
 
413
          gimp_item_mask_intersect (item, &x, &y, &width, &height))
 
414
        {
 
415
          GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context);
 
416
          GimpMatrix3     matrix;
 
417
          gint            off_x, off_y;
 
418
 
 
419
          gimp_item_get_offset (item, &off_x, &off_y);
 
420
          x += off_x;
 
421
          y += off_y;
 
422
 
 
423
          /* Assemble the transformation matrix */
 
424
          gimp_matrix3_identity (&matrix);
 
425
          if (auto_center)
 
426
            gimp_transform_matrix_rotate_rect (&matrix,
 
427
                                               x, y, width, height, angle);
 
428
          else
 
429
            gimp_transform_matrix_rotate_center (&matrix,
 
430
                                                 center_x, center_y, angle);
 
431
 
 
432
          if (progress)
 
433
            gimp_progress_start (progress, _("Rotating"), FALSE);
 
434
 
 
435
          if (GIMP_IS_DRAWABLE (item) &&
 
436
              ! gimp_viewable_get_children (GIMP_VIEWABLE (item)) &&
 
437
              ! gimp_channel_is_empty (gimp_image_get_mask (gimp_item_get_image (item))))
 
438
            {
 
439
              GimpDrawable *drawable;
 
440
 
 
441
              drawable = gimp_drawable_transform_affine (GIMP_DRAWABLE (item),
 
442
                                                         context, &matrix,
 
443
                                                         pdb_context->transform_direction,
 
444
                                                         pdb_context->interpolation,
 
445
                                                         pdb_context->transform_recursion,
 
446
                                                         pdb_context->transform_resize,
 
447
                                                         progress);
 
448
 
 
449
              if (drawable)
 
450
                item = GIMP_ITEM (drawable);
 
451
              else
 
452
                success = FALSE;
 
453
            }
 
454
          else
 
455
            {
 
456
              gimp_item_transform (item, context, &matrix,
 
457
                                   pdb_context->transform_direction,
 
458
                                   pdb_context->interpolation,
 
459
                                   pdb_context->transform_recursion,
 
460
                                   pdb_context->transform_resize,
 
461
                                   progress);
 
462
            }
 
463
 
 
464
          if (progress)
 
465
            gimp_progress_end (progress);
 
466
        }
 
467
    }
 
468
 
 
469
  return_vals = gimp_procedure_get_return_values (procedure, success,
 
470
                                                  error ? *error : NULL);
 
471
 
 
472
  if (success)
 
473
    gimp_value_set_item (&return_vals->values[1], item);
 
474
 
 
475
  return return_vals;
 
476
}
 
477
 
 
478
static GValueArray *
 
479
item_transform_scale_invoker (GimpProcedure      *procedure,
 
480
                              Gimp               *gimp,
 
481
                              GimpContext        *context,
 
482
                              GimpProgress       *progress,
 
483
                              const GValueArray  *args,
 
484
                              GError            **error)
 
485
{
 
486
  gboolean success = TRUE;
 
487
  GValueArray *return_vals;
 
488
  GimpItem *item;
 
489
  gdouble x0;
 
490
  gdouble y0;
 
491
  gdouble x1;
 
492
  gdouble y1;
 
493
 
 
494
  item = gimp_value_get_item (&args->values[0], gimp);
 
495
  x0 = g_value_get_double (&args->values[1]);
 
496
  y0 = g_value_get_double (&args->values[2]);
 
497
  x1 = g_value_get_double (&args->values[3]);
 
498
  y1 = g_value_get_double (&args->values[4]);
 
499
 
 
500
  if (success)
 
501
    {
 
502
      gint x, y, width, height;
 
503
 
 
504
      success = (gimp_pdb_item_is_attached (item, NULL, TRUE, error) && x0 < x1 && y0 < y1);
 
505
 
 
506
      if (success &&
 
507
          gimp_item_mask_intersect (item, &x, &y, &width, &height))
 
508
        {
 
509
          GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context);
 
510
          GimpMatrix3     matrix;
 
511
          gint            off_x, off_y;
 
512
 
 
513
          gimp_item_get_offset (item, &off_x, &off_y);
 
514
          x += off_x;
 
515
          y += off_y;
 
516
 
 
517
          /* Assemble the transformation matrix */
 
518
          gimp_matrix3_identity (&matrix);
 
519
          gimp_transform_matrix_scale (&matrix,
 
520
                                       x, y, width, height,
 
521
                                       x0, y0, x1 - x0, y1 - y0);
 
522
 
 
523
          if (progress)
 
524
            gimp_progress_start (progress, _("Scaling"), FALSE);
 
525
 
 
526
          if (GIMP_IS_DRAWABLE (item) &&
 
527
              ! gimp_viewable_get_children (GIMP_VIEWABLE (item)) &&
 
528
              ! gimp_channel_is_empty (gimp_image_get_mask (gimp_item_get_image (item))))
 
529
            {
 
530
              GimpDrawable *drawable;
 
531
 
 
532
              drawable = gimp_drawable_transform_affine (GIMP_DRAWABLE (item),
 
533
                                                         context, &matrix,
 
534
                                                         pdb_context->transform_direction,
 
535
                                                         pdb_context->interpolation,
 
536
                                                         pdb_context->transform_recursion,
 
537
                                                         pdb_context->transform_resize,
 
538
                                                         progress);
 
539
 
 
540
              if (drawable)
 
541
                item = GIMP_ITEM (drawable);
 
542
              else
 
543
                success = FALSE;
 
544
            }
 
545
          else
 
546
            {
 
547
              gimp_item_transform (item, context, &matrix,
 
548
                                   pdb_context->transform_direction,
 
549
                                   pdb_context->interpolation,
 
550
                                   pdb_context->transform_recursion,
 
551
                                   pdb_context->transform_resize,
 
552
                                   progress);
 
553
            }
 
554
 
 
555
          if (progress)
 
556
            gimp_progress_end (progress);
 
557
        }
 
558
    }
 
559
 
 
560
  return_vals = gimp_procedure_get_return_values (procedure, success,
 
561
                                                  error ? *error : NULL);
 
562
 
 
563
  if (success)
 
564
    gimp_value_set_item (&return_vals->values[1], item);
 
565
 
 
566
  return return_vals;
 
567
}
 
568
 
 
569
static GValueArray *
 
570
item_transform_shear_invoker (GimpProcedure      *procedure,
 
571
                              Gimp               *gimp,
 
572
                              GimpContext        *context,
 
573
                              GimpProgress       *progress,
 
574
                              const GValueArray  *args,
 
575
                              GError            **error)
 
576
{
 
577
  gboolean success = TRUE;
 
578
  GValueArray *return_vals;
 
579
  GimpItem *item;
 
580
  gint32 shear_type;
 
581
  gdouble magnitude;
 
582
 
 
583
  item = gimp_value_get_item (&args->values[0], gimp);
 
584
  shear_type = g_value_get_enum (&args->values[1]);
 
585
  magnitude = g_value_get_double (&args->values[2]);
 
586
 
 
587
  if (success)
 
588
    {
 
589
      gint x, y, width, height;
 
590
 
 
591
      success = gimp_pdb_item_is_attached (item, NULL, TRUE, error);
 
592
 
 
593
      if (success &&
 
594
          gimp_item_mask_intersect (item, &x, &y, &width, &height))
 
595
        {
 
596
          GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context);
 
597
          GimpMatrix3     matrix;
 
598
          gint            off_x, off_y;
 
599
 
 
600
          gimp_item_get_offset (item, &off_x, &off_y);
 
601
          x += off_x;
 
602
          y += off_y;
 
603
 
 
604
          /* Assemble the transformation matrix */
 
605
          gimp_matrix3_identity (&matrix);
 
606
          gimp_transform_matrix_shear (&matrix,
 
607
                                       x, y, width, height,
 
608
                                       shear_type, magnitude);
 
609
 
 
610
          if (progress)
 
611
            gimp_progress_start (progress, _("Shearing"), FALSE);
 
612
 
 
613
          if (GIMP_IS_DRAWABLE (item) &&
 
614
              ! gimp_viewable_get_children (GIMP_VIEWABLE (item)) &&
 
615
              ! gimp_channel_is_empty (gimp_image_get_mask (gimp_item_get_image (item))))
 
616
            {
 
617
              GimpDrawable *drawable;
 
618
 
 
619
              drawable = gimp_drawable_transform_affine (GIMP_DRAWABLE (item),
 
620
                                                         context, &matrix,
 
621
                                                         pdb_context->transform_direction,
 
622
                                                         pdb_context->interpolation,
 
623
                                                         pdb_context->transform_recursion,
 
624
                                                         pdb_context->transform_resize,
 
625
                                                         progress);
 
626
 
 
627
              if (drawable)
 
628
                item = GIMP_ITEM (drawable);
 
629
              else
 
630
                success = FALSE;
 
631
            }
 
632
          else
 
633
            {
 
634
              gimp_item_transform (item, context, &matrix,
 
635
                                   pdb_context->transform_direction,
 
636
                                   pdb_context->interpolation,
 
637
                                   pdb_context->transform_recursion,
 
638
                                   pdb_context->transform_resize,
 
639
                                   progress);
 
640
            }
 
641
 
 
642
          if (progress)
 
643
            gimp_progress_end (progress);
 
644
        }
 
645
    }
 
646
 
 
647
  return_vals = gimp_procedure_get_return_values (procedure, success,
 
648
                                                  error ? *error : NULL);
 
649
 
 
650
  if (success)
 
651
    gimp_value_set_item (&return_vals->values[1], item);
 
652
 
 
653
  return return_vals;
 
654
}
 
655
 
 
656
static GValueArray *
 
657
item_transform_2d_invoker (GimpProcedure      *procedure,
 
658
                           Gimp               *gimp,
 
659
                           GimpContext        *context,
 
660
                           GimpProgress       *progress,
 
661
                           const GValueArray  *args,
 
662
                           GError            **error)
 
663
{
 
664
  gboolean success = TRUE;
 
665
  GValueArray *return_vals;
 
666
  GimpItem *item;
 
667
  gdouble source_x;
 
668
  gdouble source_y;
 
669
  gdouble scale_x;
 
670
  gdouble scale_y;
 
671
  gdouble angle;
 
672
  gdouble dest_x;
 
673
  gdouble dest_y;
 
674
 
 
675
  item = gimp_value_get_item (&args->values[0], gimp);
 
676
  source_x = g_value_get_double (&args->values[1]);
 
677
  source_y = g_value_get_double (&args->values[2]);
 
678
  scale_x = g_value_get_double (&args->values[3]);
 
679
  scale_y = g_value_get_double (&args->values[4]);
 
680
  angle = g_value_get_double (&args->values[5]);
 
681
  dest_x = g_value_get_double (&args->values[6]);
 
682
  dest_y = g_value_get_double (&args->values[7]);
 
683
 
 
684
  if (success)
 
685
    {
 
686
      gint x, y, width, height;
 
687
 
 
688
      success = gimp_pdb_item_is_attached (item, NULL, TRUE, error);
 
689
 
 
690
      if (success &&
 
691
          gimp_item_mask_intersect (item, &x, &y, &width, &height))
 
692
        {
 
693
          GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context);
 
694
          GimpMatrix3     matrix;
 
695
          gint            off_x, off_y;
 
696
 
 
697
          gimp_item_get_offset (item, &off_x, &off_y);
 
698
          x += off_x;
 
699
          y += off_y;
 
700
 
 
701
          /* Assemble the transformation matrix */
 
702
          gimp_matrix3_identity  (&matrix);
 
703
          gimp_matrix3_translate (&matrix, -source_x, -source_y);
 
704
          gimp_matrix3_scale     (&matrix, scale_x, scale_y);
 
705
          gimp_matrix3_rotate    (&matrix, angle);
 
706
          gimp_matrix3_translate (&matrix, dest_x, dest_y);
 
707
 
 
708
          if (progress)
 
709
            gimp_progress_start (progress, _("2D Transform"), FALSE);
 
710
 
 
711
          if (GIMP_IS_DRAWABLE (item) &&
 
712
              ! gimp_viewable_get_children (GIMP_VIEWABLE (item)) &&
 
713
              ! gimp_channel_is_empty (gimp_image_get_mask (gimp_item_get_image (item))))
 
714
            {
 
715
              GimpDrawable *drawable;
 
716
 
 
717
              drawable = gimp_drawable_transform_affine (GIMP_DRAWABLE (item),
 
718
                                                         context, &matrix,
 
719
                                                         pdb_context->transform_direction,
 
720
                                                         pdb_context->interpolation,
 
721
                                                         pdb_context->transform_recursion,
 
722
                                                         pdb_context->transform_resize,
 
723
                                                         progress);
 
724
 
 
725
              if (drawable)
 
726
                item = GIMP_ITEM (drawable);
 
727
              else
 
728
                success = FALSE;
 
729
            }
 
730
          else
 
731
            {
 
732
              gimp_item_transform (item, context, &matrix,
 
733
                                   pdb_context->transform_direction,
 
734
                                   pdb_context->interpolation,
 
735
                                   pdb_context->transform_recursion,
 
736
                                   pdb_context->transform_resize,
 
737
                                   progress);
 
738
            }
 
739
 
 
740
          if (progress)
 
741
            gimp_progress_end (progress);
 
742
        }
 
743
    }
 
744
 
 
745
  return_vals = gimp_procedure_get_return_values (procedure, success,
 
746
                                                  error ? *error : NULL);
 
747
 
 
748
  if (success)
 
749
    gimp_value_set_item (&return_vals->values[1], item);
 
750
 
 
751
  return return_vals;
 
752
}
 
753
 
 
754
static GValueArray *
 
755
item_transform_matrix_invoker (GimpProcedure      *procedure,
 
756
                               Gimp               *gimp,
 
757
                               GimpContext        *context,
 
758
                               GimpProgress       *progress,
 
759
                               const GValueArray  *args,
 
760
                               GError            **error)
 
761
{
 
762
  gboolean success = TRUE;
 
763
  GValueArray *return_vals;
 
764
  GimpItem *item;
 
765
  gdouble coeff_0_0;
 
766
  gdouble coeff_0_1;
 
767
  gdouble coeff_0_2;
 
768
  gdouble coeff_1_0;
 
769
  gdouble coeff_1_1;
 
770
  gdouble coeff_1_2;
 
771
  gdouble coeff_2_0;
 
772
  gdouble coeff_2_1;
 
773
  gdouble coeff_2_2;
 
774
 
 
775
  item = gimp_value_get_item (&args->values[0], gimp);
 
776
  coeff_0_0 = g_value_get_double (&args->values[1]);
 
777
  coeff_0_1 = g_value_get_double (&args->values[2]);
 
778
  coeff_0_2 = g_value_get_double (&args->values[3]);
 
779
  coeff_1_0 = g_value_get_double (&args->values[4]);
 
780
  coeff_1_1 = g_value_get_double (&args->values[5]);
 
781
  coeff_1_2 = g_value_get_double (&args->values[6]);
 
782
  coeff_2_0 = g_value_get_double (&args->values[7]);
 
783
  coeff_2_1 = g_value_get_double (&args->values[8]);
 
784
  coeff_2_2 = g_value_get_double (&args->values[9]);
 
785
 
 
786
  if (success)
 
787
    {
 
788
      gint x, y, width, height;
 
789
 
 
790
      success = gimp_pdb_item_is_attached (item, NULL, TRUE, error);
 
791
 
 
792
      if (success &&
 
793
          gimp_item_mask_intersect (item, &x, &y, &width, &height))
 
794
        {
 
795
          GimpPDBContext *pdb_context = GIMP_PDB_CONTEXT (context);
 
796
          GimpMatrix3     matrix;
 
797
          gint            off_x, off_y;
 
798
 
 
799
          gimp_item_get_offset (item, &off_x, &off_y);
 
800
          x += off_x;
 
801
          y += off_y;
 
802
 
 
803
          /* Assemble the transformation matrix */
 
804
          matrix.coeff[0][0] = coeff_0_0;
 
805
          matrix.coeff[0][1] = coeff_0_1;
 
806
          matrix.coeff[0][2] = coeff_0_2;
 
807
          matrix.coeff[1][0] = coeff_1_0;
 
808
          matrix.coeff[1][1] = coeff_1_1;
 
809
          matrix.coeff[1][2] = coeff_1_2;
 
810
          matrix.coeff[2][0] = coeff_2_0;
 
811
          matrix.coeff[2][1] = coeff_2_1;
 
812
          matrix.coeff[2][2] = coeff_2_2;
 
813
 
 
814
          if (progress)
 
815
            gimp_progress_start (progress, _("2D Transforming"), FALSE);
 
816
 
 
817
          if (GIMP_IS_DRAWABLE (item) &&
 
818
              ! gimp_viewable_get_children (GIMP_VIEWABLE (item)) &&
 
819
              ! gimp_channel_is_empty (gimp_image_get_mask (gimp_item_get_image (item))))
 
820
            {
 
821
              GimpDrawable *drawable;
 
822
 
 
823
              drawable = gimp_drawable_transform_affine (GIMP_DRAWABLE (item),
 
824
                                                         context, &matrix,
 
825
                                                         pdb_context->transform_direction,
 
826
                                                         pdb_context->interpolation,
 
827
                                                         pdb_context->transform_recursion,
 
828
                                                         pdb_context->transform_resize,
 
829
                                                         progress);
 
830
 
 
831
              if (drawable)
 
832
                item = GIMP_ITEM (drawable);
 
833
              else
 
834
                success = FALSE;
 
835
            }
 
836
          else
 
837
            {
 
838
              gimp_item_transform (item, context, &matrix,
 
839
                                   pdb_context->transform_direction,
 
840
                                   pdb_context->interpolation,
 
841
                                   pdb_context->transform_recursion,
 
842
                                   pdb_context->transform_resize,
 
843
                                   progress);
 
844
            }
 
845
 
 
846
          if (progress)
 
847
            gimp_progress_end (progress);
 
848
        }
 
849
    }
 
850
 
 
851
  return_vals = gimp_procedure_get_return_values (procedure, success,
 
852
                                                  error ? *error : NULL);
 
853
 
 
854
  if (success)
 
855
    gimp_value_set_item (&return_vals->values[1], item);
 
856
 
 
857
  return return_vals;
 
858
}
 
859
 
 
860
void
 
861
register_item_transform_procs (GimpPDB *pdb)
 
862
{
 
863
  GimpProcedure *procedure;
 
864
 
 
865
  /*
 
866
   * gimp-item-transform-flip-simple
 
867
   */
 
868
  procedure = gimp_procedure_new (item_transform_flip_simple_invoker);
 
869
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
 
870
                               "gimp-item-transform-flip-simple");
 
871
  gimp_procedure_set_static_strings (procedure,
 
872
                                     "gimp-item-transform-flip-simple",
 
873
                                     "Flip the specified item either vertically or horizontally.",
 
874
                                     "This procedure flips the specified item. If a selection exists and the item is a drawable, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then flipped. If auto_center is set to TRUE, the flip is around the selection's center. Otherwise, the coordinate of the axis needs to be specified. The return value is the ID of the flipped item. If there was no selection or the item is not a drawable, this will be equal to the item ID supplied as input. Otherwise, this will be the newly created and flipped drawable. This procedure is affected by the following context setters: 'gimp-context-set-transform-resize'.",
 
875
                                     "Michael Natterer <mitch@gimp.org>",
 
876
                                     "Michael Natterer",
 
877
                                     "2004",
 
878
                                     NULL);
 
879
  gimp_procedure_add_argument (procedure,
 
880
                               gimp_param_spec_item_id ("item",
 
881
                                                        "item",
 
882
                                                        "The affected item",
 
883
                                                        pdb->gimp, FALSE,
 
884
                                                        GIMP_PARAM_READWRITE));
 
885
  gimp_procedure_add_argument (procedure,
 
886
                               gimp_param_spec_enum ("flip-type",
 
887
                                                     "flip type",
 
888
                                                     "Type of flip",
 
889
                                                     GIMP_TYPE_ORIENTATION_TYPE,
 
890
                                                     GIMP_ORIENTATION_HORIZONTAL,
 
891
                                                     GIMP_PARAM_READWRITE));
 
892
  gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM (procedure->args[1]),
 
893
                                      GIMP_ORIENTATION_UNKNOWN);
 
894
  gimp_procedure_add_argument (procedure,
 
895
                               g_param_spec_boolean ("auto-center",
 
896
                                                     "auto center",
 
897
                                                     "Whether to automatically position the axis in the selection center",
 
898
                                                     FALSE,
 
899
                                                     GIMP_PARAM_READWRITE));
 
900
  gimp_procedure_add_argument (procedure,
 
901
                               g_param_spec_double ("axis",
 
902
                                                    "axis",
 
903
                                                    "coord. of flip axis",
 
904
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
905
                                                    GIMP_PARAM_READWRITE));
 
906
  gimp_procedure_add_return_value (procedure,
 
907
                                   gimp_param_spec_item_id ("item",
 
908
                                                            "item",
 
909
                                                            "The flipped item",
 
910
                                                            pdb->gimp, FALSE,
 
911
                                                            GIMP_PARAM_READWRITE));
 
912
  gimp_pdb_register_procedure (pdb, procedure);
 
913
  g_object_unref (procedure);
 
914
 
 
915
  /*
 
916
   * gimp-item-transform-flip
 
917
   */
 
918
  procedure = gimp_procedure_new (item_transform_flip_invoker);
 
919
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
 
920
                               "gimp-item-transform-flip");
 
921
  gimp_procedure_set_static_strings (procedure,
 
922
                                     "gimp-item-transform-flip",
 
923
                                     "Flip the specified item around a given line.",
 
924
                                     "This procedure flips the specified item. If a selection exists and the item is a drawable , the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then flipped. The axis to flip around is specified by specifying two points from that line. The return value is the ID of the flipped item. If there was no selection or the item is not a drawable, this will be equal to the item ID supplied as input. Otherwise, this will be the newly created and flipped drawable. This procedure is affected by the following context setters: 'gimp-context-set-interpolation', 'gimp-context-set-transform-direction', 'gimp-context-set-transform-resize', 'gimp-context-set-transform-recursion'.",
 
925
                                     "Michael Natterer <mitch@gimp.org>",
 
926
                                     "Michael Natterer",
 
927
                                     "2010",
 
928
                                     NULL);
 
929
  gimp_procedure_add_argument (procedure,
 
930
                               gimp_param_spec_item_id ("item",
 
931
                                                        "item",
 
932
                                                        "The affected item",
 
933
                                                        pdb->gimp, FALSE,
 
934
                                                        GIMP_PARAM_READWRITE));
 
935
  gimp_procedure_add_argument (procedure,
 
936
                               g_param_spec_double ("x0",
 
937
                                                    "x0",
 
938
                                                    "horz. coord. of one end of axis",
 
939
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
940
                                                    GIMP_PARAM_READWRITE));
 
941
  gimp_procedure_add_argument (procedure,
 
942
                               g_param_spec_double ("y0",
 
943
                                                    "y0",
 
944
                                                    "vert. coord. of one end of axis",
 
945
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
946
                                                    GIMP_PARAM_READWRITE));
 
947
  gimp_procedure_add_argument (procedure,
 
948
                               g_param_spec_double ("x1",
 
949
                                                    "x1",
 
950
                                                    "horz. coord. of other end of axis",
 
951
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
952
                                                    GIMP_PARAM_READWRITE));
 
953
  gimp_procedure_add_argument (procedure,
 
954
                               g_param_spec_double ("y1",
 
955
                                                    "y1",
 
956
                                                    "vert. coord. of other end of axis",
 
957
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
958
                                                    GIMP_PARAM_READWRITE));
 
959
  gimp_procedure_add_return_value (procedure,
 
960
                                   gimp_param_spec_item_id ("item",
 
961
                                                            "item",
 
962
                                                            "The flipped item",
 
963
                                                            pdb->gimp, FALSE,
 
964
                                                            GIMP_PARAM_READWRITE));
 
965
  gimp_pdb_register_procedure (pdb, procedure);
 
966
  g_object_unref (procedure);
 
967
 
 
968
  /*
 
969
   * gimp-item-transform-perspective
 
970
   */
 
971
  procedure = gimp_procedure_new (item_transform_perspective_invoker);
 
972
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
 
973
                               "gimp-item-transform-perspective");
 
974
  gimp_procedure_set_static_strings (procedure,
 
975
                                     "gimp-item-transform-perspective",
 
976
                                     "Perform a possibly non-affine transformation on the specified item.",
 
977
                                     "This procedure performs a possibly non-affine transformation on the specified item by allowing the corners of the original bounding box to be arbitrarily remapped to any values. The specified item is remapped if no selection exists or it is not a drawable. However, if a selection exists and the item is a drawable, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then remapped as specified. The return value is the ID of the remapped item. If there was no selection or the item is not a drawable, this will be equal to the item ID supplied as input. Otherwise, this will be the newly created and remapped drawable. The 4 coordinates specify the new locations of each corner of the original bounding box. By specifying these values, any affine transformation (rotation, scaling, translation) can be affected. Additionally, these values can be specified such that the resulting transformed item will appear to have"
 
978
  "been projected via a perspective transform. This procedure is affected by the following context setters: 'gimp-context-set-interpolation', 'gimp-context-set-transform-direction', 'gimp-context-set-transform-resize', 'gimp-context-set-transform-recursion'.",
 
979
                                     "Michael Natterer <mitch@gimp.org>",
 
980
                                     "Michael Natterer",
 
981
                                     "2010",
 
982
                                     NULL);
 
983
  gimp_procedure_add_argument (procedure,
 
984
                               gimp_param_spec_item_id ("item",
 
985
                                                        "item",
 
986
                                                        "The affected item",
 
987
                                                        pdb->gimp, FALSE,
 
988
                                                        GIMP_PARAM_READWRITE));
 
989
  gimp_procedure_add_argument (procedure,
 
990
                               g_param_spec_double ("x0",
 
991
                                                    "x0",
 
992
                                                    "The new x coordinate of upper-left corner of original bounding box",
 
993
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
994
                                                    GIMP_PARAM_READWRITE));
 
995
  gimp_procedure_add_argument (procedure,
 
996
                               g_param_spec_double ("y0",
 
997
                                                    "y0",
 
998
                                                    "The new y coordinate of upper-left corner of original bounding box",
 
999
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1000
                                                    GIMP_PARAM_READWRITE));
 
1001
  gimp_procedure_add_argument (procedure,
 
1002
                               g_param_spec_double ("x1",
 
1003
                                                    "x1",
 
1004
                                                    "The new x coordinate of upper-right corner of original bounding box",
 
1005
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1006
                                                    GIMP_PARAM_READWRITE));
 
1007
  gimp_procedure_add_argument (procedure,
 
1008
                               g_param_spec_double ("y1",
 
1009
                                                    "y1",
 
1010
                                                    "The new y coordinate of upper-right corner of original bounding box",
 
1011
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1012
                                                    GIMP_PARAM_READWRITE));
 
1013
  gimp_procedure_add_argument (procedure,
 
1014
                               g_param_spec_double ("x2",
 
1015
                                                    "x2",
 
1016
                                                    "The new x coordinate of lower-left corner of original bounding box",
 
1017
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1018
                                                    GIMP_PARAM_READWRITE));
 
1019
  gimp_procedure_add_argument (procedure,
 
1020
                               g_param_spec_double ("y2",
 
1021
                                                    "y2",
 
1022
                                                    "The new y coordinate of lower-left corner of original bounding box",
 
1023
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1024
                                                    GIMP_PARAM_READWRITE));
 
1025
  gimp_procedure_add_argument (procedure,
 
1026
                               g_param_spec_double ("x3",
 
1027
                                                    "x3",
 
1028
                                                    "The new x coordinate of lower-right corner of original bounding box",
 
1029
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1030
                                                    GIMP_PARAM_READWRITE));
 
1031
  gimp_procedure_add_argument (procedure,
 
1032
                               g_param_spec_double ("y3",
 
1033
                                                    "y3",
 
1034
                                                    "The new y coordinate of lower-right corner of original bounding box",
 
1035
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1036
                                                    GIMP_PARAM_READWRITE));
 
1037
  gimp_procedure_add_return_value (procedure,
 
1038
                                   gimp_param_spec_item_id ("item",
 
1039
                                                            "item",
 
1040
                                                            "The newly mapped item",
 
1041
                                                            pdb->gimp, FALSE,
 
1042
                                                            GIMP_PARAM_READWRITE));
 
1043
  gimp_pdb_register_procedure (pdb, procedure);
 
1044
  g_object_unref (procedure);
 
1045
 
 
1046
  /*
 
1047
   * gimp-item-transform-rotate-simple
 
1048
   */
 
1049
  procedure = gimp_procedure_new (item_transform_rotate_simple_invoker);
 
1050
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
 
1051
                               "gimp-item-transform-rotate-simple");
 
1052
  gimp_procedure_set_static_strings (procedure,
 
1053
                                     "gimp-item-transform-rotate-simple",
 
1054
                                     "Rotate the specified item about given coordinates through the specified angle.",
 
1055
                                     "This function rotates the specified item. If a selection exists and the item is a drawable, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then rotated by the specified amount. The return value is the ID of the rotated item. If there was no selection or the item is not a drawable, this will be equal to the item ID supplied as input. Otherwise, this will be the newly created and rotated drawable. This procedure is affected by the following context setters: 'gimp-context-set-transform-resize'.",
 
1056
                                     "Michael Natterer <mitch@gimp.org>",
 
1057
                                     "Michael Natterer",
 
1058
                                     "2010",
 
1059
                                     NULL);
 
1060
  gimp_procedure_add_argument (procedure,
 
1061
                               gimp_param_spec_item_id ("item",
 
1062
                                                        "item",
 
1063
                                                        "The affected item",
 
1064
                                                        pdb->gimp, FALSE,
 
1065
                                                        GIMP_PARAM_READWRITE));
 
1066
  gimp_procedure_add_argument (procedure,
 
1067
                               g_param_spec_enum ("rotate-type",
 
1068
                                                  "rotate type",
 
1069
                                                  "Type of rotation",
 
1070
                                                  GIMP_TYPE_ROTATION_TYPE,
 
1071
                                                  GIMP_ROTATE_90,
 
1072
                                                  GIMP_PARAM_READWRITE));
 
1073
  gimp_procedure_add_argument (procedure,
 
1074
                               g_param_spec_boolean ("auto-center",
 
1075
                                                     "auto center",
 
1076
                                                     "Whether to automatically rotate around the selection center",
 
1077
                                                     FALSE,
 
1078
                                                     GIMP_PARAM_READWRITE));
 
1079
  gimp_procedure_add_argument (procedure,
 
1080
                               g_param_spec_double ("center-x",
 
1081
                                                    "center x",
 
1082
                                                    "The hor. coordinate of the center of rotation",
 
1083
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1084
                                                    GIMP_PARAM_READWRITE));
 
1085
  gimp_procedure_add_argument (procedure,
 
1086
                               g_param_spec_double ("center-y",
 
1087
                                                    "center y",
 
1088
                                                    "The vert. coordinate of the center of rotation",
 
1089
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1090
                                                    GIMP_PARAM_READWRITE));
 
1091
  gimp_procedure_add_return_value (procedure,
 
1092
                                   gimp_param_spec_item_id ("item",
 
1093
                                                            "item",
 
1094
                                                            "The rotated item",
 
1095
                                                            pdb->gimp, FALSE,
 
1096
                                                            GIMP_PARAM_READWRITE));
 
1097
  gimp_pdb_register_procedure (pdb, procedure);
 
1098
  g_object_unref (procedure);
 
1099
 
 
1100
  /*
 
1101
   * gimp-item-transform-rotate
 
1102
   */
 
1103
  procedure = gimp_procedure_new (item_transform_rotate_invoker);
 
1104
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
 
1105
                               "gimp-item-transform-rotate");
 
1106
  gimp_procedure_set_static_strings (procedure,
 
1107
                                     "gimp-item-transform-rotate",
 
1108
                                     "Rotate the specified item about given coordinates through the specified angle.",
 
1109
                                     "This function rotates the specified item. If a selection exists and the item is a drawable, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then rotated by the specified amount. The return value is the ID of the rotated item. If there was no selection or the item is not a drawable, this will be equal to the item ID supplied as input. Otherwise, this will be the newly created and rotated drawable. This procedure is affected by the following context setters: 'gimp-context-set-interpolation', 'gimp-context-set-transform-direction', 'gimp-context-set-transform-resize', 'gimp-context-set-transform-recursion'.",
 
1110
                                     "Michael Natterer <mitch@gimp.org>",
 
1111
                                     "Michael Natterer",
 
1112
                                     "2010",
 
1113
                                     NULL);
 
1114
  gimp_procedure_add_argument (procedure,
 
1115
                               gimp_param_spec_item_id ("item",
 
1116
                                                        "item",
 
1117
                                                        "The affected item",
 
1118
                                                        pdb->gimp, FALSE,
 
1119
                                                        GIMP_PARAM_READWRITE));
 
1120
  gimp_procedure_add_argument (procedure,
 
1121
                               g_param_spec_double ("angle",
 
1122
                                                    "angle",
 
1123
                                                    "The angle of rotation (radians)",
 
1124
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1125
                                                    GIMP_PARAM_READWRITE));
 
1126
  gimp_procedure_add_argument (procedure,
 
1127
                               g_param_spec_boolean ("auto-center",
 
1128
                                                     "auto center",
 
1129
                                                     "Whether to automatically rotate around the selection center",
 
1130
                                                     FALSE,
 
1131
                                                     GIMP_PARAM_READWRITE));
 
1132
  gimp_procedure_add_argument (procedure,
 
1133
                               g_param_spec_double ("center-x",
 
1134
                                                    "center x",
 
1135
                                                    "The hor. coordinate of the center of rotation",
 
1136
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1137
                                                    GIMP_PARAM_READWRITE));
 
1138
  gimp_procedure_add_argument (procedure,
 
1139
                               g_param_spec_double ("center-y",
 
1140
                                                    "center y",
 
1141
                                                    "The vert. coordinate of the center of rotation",
 
1142
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1143
                                                    GIMP_PARAM_READWRITE));
 
1144
  gimp_procedure_add_return_value (procedure,
 
1145
                                   gimp_param_spec_item_id ("item",
 
1146
                                                            "item",
 
1147
                                                            "The rotated item",
 
1148
                                                            pdb->gimp, FALSE,
 
1149
                                                            GIMP_PARAM_READWRITE));
 
1150
  gimp_pdb_register_procedure (pdb, procedure);
 
1151
  g_object_unref (procedure);
 
1152
 
 
1153
  /*
 
1154
   * gimp-item-transform-scale
 
1155
   */
 
1156
  procedure = gimp_procedure_new (item_transform_scale_invoker);
 
1157
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
 
1158
                               "gimp-item-transform-scale");
 
1159
  gimp_procedure_set_static_strings (procedure,
 
1160
                                     "gimp-item-transform-scale",
 
1161
                                     "Scale the specified item.",
 
1162
                                     "This procedure scales the specified item. If a selection exists and the item is a drawable, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then scaled by the specified amount. The return value is the ID of the scaled item. If there was no selection or the item is not a drawable, this will be equal to the item ID supplied as input. Otherwise, this will be the newly created and scaled drawable. This procedure is affected by the following context setters: 'gimp-context-set-interpolation', 'gimp-context-set-transform-direction', 'gimp-context-set-transform-resize', 'gimp-context-set-transform-recursion'.",
 
1163
                                     "Michael Natterer <mitch@gimp.org>",
 
1164
                                     "Michael Natterer",
 
1165
                                     "2010",
 
1166
                                     NULL);
 
1167
  gimp_procedure_add_argument (procedure,
 
1168
                               gimp_param_spec_item_id ("item",
 
1169
                                                        "item",
 
1170
                                                        "The affected item",
 
1171
                                                        pdb->gimp, FALSE,
 
1172
                                                        GIMP_PARAM_READWRITE));
 
1173
  gimp_procedure_add_argument (procedure,
 
1174
                               g_param_spec_double ("x0",
 
1175
                                                    "x0",
 
1176
                                                    "The new x coordinate of the upper-left corner of the scaled region",
 
1177
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1178
                                                    GIMP_PARAM_READWRITE));
 
1179
  gimp_procedure_add_argument (procedure,
 
1180
                               g_param_spec_double ("y0",
 
1181
                                                    "y0",
 
1182
                                                    "The new y coordinate of the upper-left corner of the scaled region",
 
1183
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1184
                                                    GIMP_PARAM_READWRITE));
 
1185
  gimp_procedure_add_argument (procedure,
 
1186
                               g_param_spec_double ("x1",
 
1187
                                                    "x1",
 
1188
                                                    "The new x coordinate of the lower-right corner of the scaled region",
 
1189
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1190
                                                    GIMP_PARAM_READWRITE));
 
1191
  gimp_procedure_add_argument (procedure,
 
1192
                               g_param_spec_double ("y1",
 
1193
                                                    "y1",
 
1194
                                                    "The new y coordinate of the lower-right corner of the scaled region",
 
1195
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1196
                                                    GIMP_PARAM_READWRITE));
 
1197
  gimp_procedure_add_return_value (procedure,
 
1198
                                   gimp_param_spec_item_id ("item",
 
1199
                                                            "item",
 
1200
                                                            "The scaled item",
 
1201
                                                            pdb->gimp, FALSE,
 
1202
                                                            GIMP_PARAM_READWRITE));
 
1203
  gimp_pdb_register_procedure (pdb, procedure);
 
1204
  g_object_unref (procedure);
 
1205
 
 
1206
  /*
 
1207
   * gimp-item-transform-shear
 
1208
   */
 
1209
  procedure = gimp_procedure_new (item_transform_shear_invoker);
 
1210
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
 
1211
                               "gimp-item-transform-shear");
 
1212
  gimp_procedure_set_static_strings (procedure,
 
1213
                                     "gimp-item-transform-shear",
 
1214
                                     "Shear the specified item about its center by the specified magnitude.",
 
1215
                                     "This procedure shears the specified item. If a selection exists and the item is a drawable, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then sheard by the specified amount. The return value is the ID of the sheard item. If there was no selection or the item is not a drawable, this will be equal to the item ID supplied as input. Otherwise, this will be the newly created and sheard drawable. The shear type parameter indicates whether the shear will be applied horizontally or vertically. The magnitude can be either positive or negative and indicates the extent (in pixels) to shear by. This procedure is affected by the following context setters: 'gimp-context-set-interpolation', 'gimp-context-set-transform-direction', 'gimp-context-set-transform-resize', 'gimp-context-set-transform-recursion'.",
 
1216
                                     "Michael Natterer <mitch@gimp.org>",
 
1217
                                     "Michael Natterer",
 
1218
                                     "2010",
 
1219
                                     NULL);
 
1220
  gimp_procedure_add_argument (procedure,
 
1221
                               gimp_param_spec_item_id ("item",
 
1222
                                                        "item",
 
1223
                                                        "The affected item",
 
1224
                                                        pdb->gimp, FALSE,
 
1225
                                                        GIMP_PARAM_READWRITE));
 
1226
  gimp_procedure_add_argument (procedure,
 
1227
                               gimp_param_spec_enum ("shear-type",
 
1228
                                                     "shear type",
 
1229
                                                     "Type of shear",
 
1230
                                                     GIMP_TYPE_ORIENTATION_TYPE,
 
1231
                                                     GIMP_ORIENTATION_HORIZONTAL,
 
1232
                                                     GIMP_PARAM_READWRITE));
 
1233
  gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM (procedure->args[1]),
 
1234
                                      GIMP_ORIENTATION_UNKNOWN);
 
1235
  gimp_procedure_add_argument (procedure,
 
1236
                               g_param_spec_double ("magnitude",
 
1237
                                                    "magnitude",
 
1238
                                                    "The magnitude of the shear",
 
1239
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1240
                                                    GIMP_PARAM_READWRITE));
 
1241
  gimp_procedure_add_return_value (procedure,
 
1242
                                   gimp_param_spec_item_id ("item",
 
1243
                                                            "item",
 
1244
                                                            "The sheared item",
 
1245
                                                            pdb->gimp, FALSE,
 
1246
                                                            GIMP_PARAM_READWRITE));
 
1247
  gimp_pdb_register_procedure (pdb, procedure);
 
1248
  g_object_unref (procedure);
 
1249
 
 
1250
  /*
 
1251
   * gimp-item-transform-2d
 
1252
   */
 
1253
  procedure = gimp_procedure_new (item_transform_2d_invoker);
 
1254
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
 
1255
                               "gimp-item-transform-2d");
 
1256
  gimp_procedure_set_static_strings (procedure,
 
1257
                                     "gimp-item-transform-2d",
 
1258
                                     "Transform the specified item in 2d.",
 
1259
                                     "This procedure transforms the specified item. If a selection exists and the item is a drawable, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then transformed. The transformation is done by scaling the image by the x and y scale factors about the point (source_x, source_y), then rotating around the same point, then translating that point to the new position (dest_x, dest_y). The return value is the ID of the rotated drawable. If there was no selection or the item is not a drawable, this will be equal to the item ID supplied as input. Otherwise, this will be the newly created and transformed drawable. This procedure is affected by the following context setters: 'gimp-context-set-interpolation', 'gimp-context-set-transform-direction', 'gimp-context-set-transform-resize', 'gimp-context-set-transform-recursion'.",
 
1260
                                     "Michael Natterer <mitch@gimp.org>",
 
1261
                                     "Michael Natterer",
 
1262
                                     "2010",
 
1263
                                     NULL);
 
1264
  gimp_procedure_add_argument (procedure,
 
1265
                               gimp_param_spec_item_id ("item",
 
1266
                                                        "item",
 
1267
                                                        "The affected item",
 
1268
                                                        pdb->gimp, FALSE,
 
1269
                                                        GIMP_PARAM_READWRITE));
 
1270
  gimp_procedure_add_argument (procedure,
 
1271
                               g_param_spec_double ("source-x",
 
1272
                                                    "source x",
 
1273
                                                    "X coordinate of the transformation center",
 
1274
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1275
                                                    GIMP_PARAM_READWRITE));
 
1276
  gimp_procedure_add_argument (procedure,
 
1277
                               g_param_spec_double ("source-y",
 
1278
                                                    "source y",
 
1279
                                                    "Y coordinate of the transformation center",
 
1280
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1281
                                                    GIMP_PARAM_READWRITE));
 
1282
  gimp_procedure_add_argument (procedure,
 
1283
                               g_param_spec_double ("scale-x",
 
1284
                                                    "scale x",
 
1285
                                                    "Amount to scale in x direction",
 
1286
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1287
                                                    GIMP_PARAM_READWRITE));
 
1288
  gimp_procedure_add_argument (procedure,
 
1289
                               g_param_spec_double ("scale-y",
 
1290
                                                    "scale y",
 
1291
                                                    "Amount to scale in y direction",
 
1292
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1293
                                                    GIMP_PARAM_READWRITE));
 
1294
  gimp_procedure_add_argument (procedure,
 
1295
                               g_param_spec_double ("angle",
 
1296
                                                    "angle",
 
1297
                                                    "The angle of rotation (radians)",
 
1298
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1299
                                                    GIMP_PARAM_READWRITE));
 
1300
  gimp_procedure_add_argument (procedure,
 
1301
                               g_param_spec_double ("dest-x",
 
1302
                                                    "dest x",
 
1303
                                                    "X coordinate of where the center goes",
 
1304
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1305
                                                    GIMP_PARAM_READWRITE));
 
1306
  gimp_procedure_add_argument (procedure,
 
1307
                               g_param_spec_double ("dest-y",
 
1308
                                                    "dest y",
 
1309
                                                    "Y coordinate of where the center goes",
 
1310
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1311
                                                    GIMP_PARAM_READWRITE));
 
1312
  gimp_procedure_add_return_value (procedure,
 
1313
                                   gimp_param_spec_item_id ("item",
 
1314
                                                            "item",
 
1315
                                                            "The transformed item",
 
1316
                                                            pdb->gimp, FALSE,
 
1317
                                                            GIMP_PARAM_READWRITE));
 
1318
  gimp_pdb_register_procedure (pdb, procedure);
 
1319
  g_object_unref (procedure);
 
1320
 
 
1321
  /*
 
1322
   * gimp-item-transform-matrix
 
1323
   */
 
1324
  procedure = gimp_procedure_new (item_transform_matrix_invoker);
 
1325
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
 
1326
                               "gimp-item-transform-matrix");
 
1327
  gimp_procedure_set_static_strings (procedure,
 
1328
                                     "gimp-item-transform-matrix",
 
1329
                                     "Transform the specified item in 2d.",
 
1330
                                     "This procedure transforms the specified item. If a selection exists and the item is a drawable, the portion of the drawable which lies under the selection is cut from the drawable and made into a floating selection which is then transformed. The transformation is done by assembling a 3x3 matrix from the coefficients passed. The return value is the ID of the transformed item. If there was no selection or the item is not a drawable, this will be equal to the item ID supplied as input. Otherwise, this will be the newly created and transformed drawable. This procedure is affected by the following context setters: 'gimp-context-set-interpolation', 'gimp-context-set-transform-direction', 'gimp-context-set-transform-resize', 'gimp-context-set-transform-recursion'.",
 
1331
                                     "Michael Natterer <mitch@gimp.org>",
 
1332
                                     "Michael Natterer",
 
1333
                                     "2010",
 
1334
                                     NULL);
 
1335
  gimp_procedure_add_argument (procedure,
 
1336
                               gimp_param_spec_item_id ("item",
 
1337
                                                        "item",
 
1338
                                                        "The affected item",
 
1339
                                                        pdb->gimp, FALSE,
 
1340
                                                        GIMP_PARAM_READWRITE));
 
1341
  gimp_procedure_add_argument (procedure,
 
1342
                               g_param_spec_double ("coeff-0-0",
 
1343
                                                    "coeff 0 0",
 
1344
                                                    "coefficient (0,0) of the transformation matrix",
 
1345
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1346
                                                    GIMP_PARAM_READWRITE));
 
1347
  gimp_procedure_add_argument (procedure,
 
1348
                               g_param_spec_double ("coeff-0-1",
 
1349
                                                    "coeff 0 1",
 
1350
                                                    "coefficient (0,1) of the transformation matrix",
 
1351
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1352
                                                    GIMP_PARAM_READWRITE));
 
1353
  gimp_procedure_add_argument (procedure,
 
1354
                               g_param_spec_double ("coeff-0-2",
 
1355
                                                    "coeff 0 2",
 
1356
                                                    "coefficient (0,2) of the transformation matrix",
 
1357
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1358
                                                    GIMP_PARAM_READWRITE));
 
1359
  gimp_procedure_add_argument (procedure,
 
1360
                               g_param_spec_double ("coeff-1-0",
 
1361
                                                    "coeff 1 0",
 
1362
                                                    "coefficient (1,0) of the transformation matrix",
 
1363
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1364
                                                    GIMP_PARAM_READWRITE));
 
1365
  gimp_procedure_add_argument (procedure,
 
1366
                               g_param_spec_double ("coeff-1-1",
 
1367
                                                    "coeff 1 1",
 
1368
                                                    "coefficient (1,1) of the transformation matrix",
 
1369
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1370
                                                    GIMP_PARAM_READWRITE));
 
1371
  gimp_procedure_add_argument (procedure,
 
1372
                               g_param_spec_double ("coeff-1-2",
 
1373
                                                    "coeff 1 2",
 
1374
                                                    "coefficient (1,2) of the transformation matrix",
 
1375
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1376
                                                    GIMP_PARAM_READWRITE));
 
1377
  gimp_procedure_add_argument (procedure,
 
1378
                               g_param_spec_double ("coeff-2-0",
 
1379
                                                    "coeff 2 0",
 
1380
                                                    "coefficient (2,0) of the transformation matrix",
 
1381
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1382
                                                    GIMP_PARAM_READWRITE));
 
1383
  gimp_procedure_add_argument (procedure,
 
1384
                               g_param_spec_double ("coeff-2-1",
 
1385
                                                    "coeff 2 1",
 
1386
                                                    "coefficient (2,1) of the transformation matrix",
 
1387
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1388
                                                    GIMP_PARAM_READWRITE));
 
1389
  gimp_procedure_add_argument (procedure,
 
1390
                               g_param_spec_double ("coeff-2-2",
 
1391
                                                    "coeff 2 2",
 
1392
                                                    "coefficient (2,2) of the transformation matrix",
 
1393
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
 
1394
                                                    GIMP_PARAM_READWRITE));
 
1395
  gimp_procedure_add_return_value (procedure,
 
1396
                                   gimp_param_spec_item_id ("item",
 
1397
                                                            "item",
 
1398
                                                            "The transformed item",
 
1399
                                                            pdb->gimp, FALSE,
 
1400
                                                            GIMP_PARAM_READWRITE));
 
1401
  gimp_pdb_register_procedure (pdb, procedure);
 
1402
  g_object_unref (procedure);
 
1403
}