transform-tools-cmds.c 36.6 KB
Newer Older
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 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
/* NOTE: This file is auto-generated by pdbgen.pl. */
19 20 21

#include "config.h"

22
#include <gegl.h>
23

24 25
#include "libgimpmath/gimpmath.h"

26 27
#include "pdb-types.h"

28
#include "config/gimpcoreconfig.h"
Sven Neumann's avatar
Sven Neumann committed
29
#include "core/gimp-transform-utils.h"
30
#include "core/gimp.h"
31 32
#include "core/gimpdrawable-transform.h"
#include "core/gimpdrawable.h"
33
#include "core/gimpimage.h"
34
#include "core/gimpparamspecs.h"
35
#include "core/gimpprogress.h"
36

37 38 39
#include "gimppdb.h"
#include "gimppdb-utils.h"
#include "gimpprocedure.h"
40
#include "internal-procs.h"
41

42 43
#include "gimp-intl.h"

44

45
static GValueArray *
46 47 48 49 50 51
flip_invoker (GimpProcedure      *procedure,
              Gimp               *gimp,
              GimpContext        *context,
              GimpProgress       *progress,
              const GValueArray  *args,
              GError            **error)
52 53
{
  gboolean success = TRUE;
54
  GValueArray *return_vals;
55 56 57
  GimpDrawable *drawable;
  gint32 flip_type;

58 59
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
  flip_type = g_value_get_enum (&args->values[1]);
60 61 62

  if (success)
    {
63 64
      gint x, y, width, height;

65
      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
66

67
      if (success &&
68
          gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
69
        {
70 71 72 73 74
          gdouble axis;

          gimp_transform_get_flip_axis (x, y, width, height,
                                        flip_type, TRUE, &axis);

75 76 77 78 79
          if (! gimp_drawable_transform_flip (drawable, context,
                                              flip_type, axis, FALSE))
            {
              success = FALSE;
            }
80
        }
81 82
    }

83 84
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
85 86

  if (success)
87
    gimp_value_set_drawable (&return_vals->values[1], drawable);
88

89
  return return_vals;
90 91
}

92
static GValueArray *
93 94 95 96 97 98
perspective_invoker (GimpProcedure      *procedure,
                     Gimp               *gimp,
                     GimpContext        *context,
                     GimpProgress       *progress,
                     const GValueArray  *args,
                     GError            **error)
99 100
{
  gboolean success = TRUE;
101
  GValueArray *return_vals;
102 103
  GimpDrawable *drawable;
  gboolean interpolation;
104 105 106 107 108 109 110 111
  gdouble x0;
  gdouble y0;
  gdouble x1;
  gdouble y1;
  gdouble x2;
  gdouble y2;
  gdouble x3;
  gdouble y3;
112

113 114 115 116 117 118 119 120 121 122
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
  interpolation = g_value_get_boolean (&args->values[1]);
  x0 = g_value_get_double (&args->values[2]);
  y0 = g_value_get_double (&args->values[3]);
  x1 = g_value_get_double (&args->values[4]);
  y1 = g_value_get_double (&args->values[5]);
  x2 = g_value_get_double (&args->values[6]);
  y2 = g_value_get_double (&args->values[7]);
  x3 = g_value_get_double (&args->values[8]);
  y3 = g_value_get_double (&args->values[9]);
123 124 125

  if (success)
    {
126 127
      gint x, y, width, height;

128
      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
129

130
      if (success &&
131
          gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
132
        {
133 134
          GimpMatrix3           matrix;
          GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
135 136
          gint                  off_x, off_y;

137
          gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
138 139 140

          x += off_x;
          y += off_y;
141 142

          /* Assemble the transformation matrix */
143 144 145
          gimp_matrix3_identity (&matrix);
          gimp_transform_matrix_perspective (&matrix,
                                             x, y, width, height,
146 147
                                             x0, y0, x1, y1,
                                             x2, y2, x3, y3);
148 149 150 151 152

          if (interpolation)
            interpolation_type = gimp->config->interpolation_type;

          if (progress)
153
            gimp_progress_start (progress, _("Perspective"), FALSE);
154

155 156 157 158 159 160 161 162
          if (! gimp_drawable_transform_affine (drawable, context,
                                                &matrix,
                                                GIMP_TRANSFORM_FORWARD,
                                                interpolation_type, 3,
                                                FALSE, progress))
            {
              success = FALSE;
            }
163 164 165

          if (progress)
            gimp_progress_end (progress);
166
        }
167 168
    }

169 170
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
171 172

  if (success)
173
    gimp_value_set_drawable (&return_vals->values[1], drawable);
174

175
  return return_vals;
176 177
}

178
static GValueArray *
179 180 181 182 183 184
rotate_invoker (GimpProcedure      *procedure,
                Gimp               *gimp,
                GimpContext        *context,
                GimpProgress       *progress,
                const GValueArray  *args,
                GError            **error)
185 186
{
  gboolean success = TRUE;
187
  GValueArray *return_vals;
188 189 190 191
  GimpDrawable *drawable;
  gboolean interpolation;
  gdouble angle;

192 193 194
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
  interpolation = g_value_get_boolean (&args->values[1]);
  angle = g_value_get_double (&args->values[2]);
195 196 197

  if (success)
    {
198 199
      gint x, y, width, height;

200
      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
201

202
      if (success &&
203
          gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
204
        {
205 206
          GimpMatrix3           matrix;
          GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
207 208
          gint                  off_x, off_y;

209
          gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
210 211 212

          x += off_x;
          y += off_y;
213 214

          /* Assemble the transformation matrix */
215 216
          gimp_matrix3_identity (&matrix);
          gimp_transform_matrix_rotate_rect (&matrix,
217 218
                                             x, y, width, height,
                                             angle);
219 220 221 222 223

          if (interpolation)
            interpolation_type = gimp->config->interpolation_type;

          if (progress)
224
            gimp_progress_start (progress, _("Rotating"), FALSE);
225

226 227 228 229 230 231 232 233
          if (! gimp_drawable_transform_affine (drawable, context,
                                                &matrix,
                                                GIMP_TRANSFORM_FORWARD,
                                                interpolation_type, 3,
                                                FALSE, progress))
            {
              success = FALSE;
            }
234 235 236

          if (progress)
            gimp_progress_end (progress);
237
        }
238 239
    }

240 241
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
242 243

  if (success)
244
    gimp_value_set_drawable (&return_vals->values[1], drawable);
245

246
  return return_vals;
247 248
}

249
static GValueArray *
250 251 252 253 254 255
scale_invoker (GimpProcedure      *procedure,
               Gimp               *gimp,
               GimpContext        *context,
               GimpProgress       *progress,
               const GValueArray  *args,
               GError            **error)
256 257
{
  gboolean success = TRUE;
258
  GValueArray *return_vals;
259 260
  GimpDrawable *drawable;
  gboolean interpolation;
261 262 263 264
  gdouble x0;
  gdouble y0;
  gdouble x1;
  gdouble y1;
265

266 267 268 269 270 271
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
  interpolation = g_value_get_boolean (&args->values[1]);
  x0 = g_value_get_double (&args->values[2]);
  y0 = g_value_get_double (&args->values[3]);
  x1 = g_value_get_double (&args->values[4]);
  y1 = g_value_get_double (&args->values[5]);
272 273 274

  if (success)
    {
275 276
      gint x, y, width, height;

277
      success = (gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error) &&
278
                 x0 < x1 && y0 < y1);
279

280
      if (success &&
281
          gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
282
        {
283 284
          GimpMatrix3           matrix;
          GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
285 286
          gint                  off_x, off_y;

287
          gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
288 289 290

          x += off_x;
          y += off_y;
291 292

          /* Assemble the transformation matrix */
293 294 295
          gimp_matrix3_identity (&matrix);
          gimp_transform_matrix_scale (&matrix,
                                       x, y, width, height,
296
                                       x0, y0, x1 - x0, y1 - y0);
297 298 299 300 301

          if (interpolation)
            interpolation_type = gimp->config->interpolation_type;

          if (progress)
302
            gimp_progress_start (progress, _("Scaling"), FALSE);
303

304 305 306 307 308 309 310 311
          if (! gimp_drawable_transform_affine (drawable, context,
                                                &matrix,
                                                GIMP_TRANSFORM_FORWARD,
                                                interpolation_type, 3,
                                                FALSE, progress))
            {
              success = FALSE;
            }
312 313 314

          if (progress)
            gimp_progress_end (progress);
315
        }
316 317
    }

318 319
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
320 321

  if (success)
322
    gimp_value_set_drawable (&return_vals->values[1], drawable);
323

324
  return return_vals;
325 326
}

327
static GValueArray *
328 329 330 331 332 333
shear_invoker (GimpProcedure      *procedure,
               Gimp               *gimp,
               GimpContext        *context,
               GimpProgress       *progress,
               const GValueArray  *args,
               GError            **error)
334 335
{
  gboolean success = TRUE;
336
  GValueArray *return_vals;
337 338 339 340 341
  GimpDrawable *drawable;
  gboolean interpolation;
  gint32 shear_type;
  gdouble magnitude;

342 343 344 345
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
  interpolation = g_value_get_boolean (&args->values[1]);
  shear_type = g_value_get_enum (&args->values[2]);
  magnitude = g_value_get_double (&args->values[3]);
346 347 348

  if (success)
    {
349 350
      gint x, y, width, height;

351
      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
352

353
      if (success &&
354
          gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
355
        {
356 357
          GimpMatrix3           matrix;
          GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;
358 359
          gint                  off_x, off_y;

360
          gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
361 362 363

          x += off_x;
          y += off_y;
364 365

          /* Assemble the transformation matrix */
366 367 368 369
          gimp_matrix3_identity (&matrix);
          gimp_transform_matrix_shear (&matrix,
                                       x, y, width, height,
                                       shear_type, magnitude);
370 371 372 373 374

          if (interpolation)
            interpolation_type = gimp->config->interpolation_type;

          if (progress)
375
            gimp_progress_start (progress, _("Shearing"), FALSE);
376

377 378 379 380 381 382 383 384
          if (! gimp_drawable_transform_affine (drawable, context,
                                                &matrix,
                                                GIMP_TRANSFORM_FORWARD,
                                                interpolation_type, 3,
                                                FALSE, progress))
            {
              success = FALSE;
            }
385 386 387

          if (progress)
            gimp_progress_end (progress);
388
        }
389 390
    }

391 392
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
393 394

  if (success)
395
    gimp_value_set_drawable (&return_vals->values[1], drawable);
396

397
  return return_vals;
398 399
}

400
static GValueArray *
401 402 403 404 405 406
transform_2d_invoker (GimpProcedure      *procedure,
                      Gimp               *gimp,
                      GimpContext        *context,
                      GimpProgress       *progress,
                      const GValueArray  *args,
                      GError            **error)
407 408
{
  gboolean success = TRUE;
409
  GValueArray *return_vals;
410 411 412 413 414 415 416 417 418 419
  GimpDrawable *drawable;
  gboolean interpolation;
  gdouble source_x;
  gdouble source_y;
  gdouble scale_x;
  gdouble scale_y;
  gdouble angle;
  gdouble dest_x;
  gdouble dest_y;

420 421 422 423 424 425 426 427 428
  drawable = gimp_value_get_drawable (&args->values[0], gimp);
  interpolation = g_value_get_boolean (&args->values[1]);
  source_x = g_value_get_double (&args->values[2]);
  source_y = g_value_get_double (&args->values[3]);
  scale_x = g_value_get_double (&args->values[4]);
  scale_y = g_value_get_double (&args->values[5]);
  angle = g_value_get_double (&args->values[6]);
  dest_x = g_value_get_double (&args->values[7]);
  dest_y = g_value_get_double (&args->values[8]);
429 430 431

  if (success)
    {
432 433
      gint x, y, width, height;

434
      success = gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL, TRUE, error);
435

436
      if (success &&
437
          gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
        {
          GimpMatrix3           matrix;
          GimpInterpolationType interpolation_type = GIMP_INTERPOLATION_NONE;

          /* Assemble the transformation matrix */
          gimp_matrix3_identity  (&matrix);
          gimp_matrix3_translate (&matrix, -source_x, -source_y);
          gimp_matrix3_scale     (&matrix, scale_x, scale_y);
          gimp_matrix3_rotate    (&matrix, angle);
          gimp_matrix3_translate (&matrix, dest_x, dest_y);

          if (interpolation)
            interpolation_type = gimp->config->interpolation_type;

          if (progress)
            gimp_progress_start (progress, _("2D Transform"), FALSE);

455 456 457 458 459 460 461
          if (! gimp_drawable_transform_affine (drawable, context,
                                                &matrix, GIMP_TRANSFORM_FORWARD,
                                                interpolation_type, 3,
                                                FALSE, progress))
            {
              success = FALSE;
            }
462 463 464 465 466 467

          if (progress)
            gimp_progress_end (progress);
        }
    }

468 469
  return_vals = gimp_procedure_get_return_values (procedure, success,
                                                  error ? *error : NULL);
470 471 472 473 474 475 476 477

  if (success)
    gimp_value_set_drawable (&return_vals->values[1], drawable);

  return return_vals;
}

void
478
register_transform_tools_procs (GimpPDB *pdb)
479 480 481 482 483 484
{
  GimpProcedure *procedure;

  /*
   * gimp-flip
   */
485
  procedure = gimp_procedure_new (flip_invoker);
486 487
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-flip");
488 489
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-flip",
490 491
                                     "Deprecated: Use 'gimp-item-transform-flip-simple' instead.",
                                     "Deprecated: Use 'gimp-item-transform-flip-simple' instead.",
492 493 494
                                     "",
                                     "",
                                     "",
495
                                     "gimp-item-transform-flip-simple");
496 497 498 499
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_drawable_id ("drawable",
                                                            "drawable",
                                                            "The affected drawable",
500
                                                            pdb->gimp, FALSE,
501 502 503 504
                                                            GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_enum ("flip-type",
                                                     "flip type",
505
                                                     "Type of flip",
506 507 508 509 510 511 512 513 514
                                                     GIMP_TYPE_ORIENTATION_TYPE,
                                                     GIMP_ORIENTATION_HORIZONTAL,
                                                     GIMP_PARAM_READWRITE));
  gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM (procedure->args[1]),
                                      GIMP_ORIENTATION_UNKNOWN);
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_drawable_id ("drawable",
                                                                "drawable",
                                                                "The flipped drawable",
515
                                                                pdb->gimp, FALSE,
516
                                                                GIMP_PARAM_READWRITE));
517
  gimp_pdb_register_procedure (pdb, procedure);
518
  g_object_unref (procedure);
519 520 521 522

  /*
   * gimp-perspective
   */
523
  procedure = gimp_procedure_new (perspective_invoker);
524 525
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-perspective");
526 527
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-perspective",
528 529
                                     "Deprecated: Use 'gimp-item-transform-perspective' instead.",
                                     "Deprecated: Use 'gimp-item-transform-perspective' instead.",
530 531 532
                                     "",
                                     "",
                                     "",
533
                                     "gimp-item-transform-perspective");
534 535 536 537
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_drawable_id ("drawable",
                                                            "drawable",
                                                            "The affected drawable",
538
                                                            pdb->gimp, FALSE,
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597
                                                            GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_boolean ("interpolation",
                                                     "interpolation",
                                                     "Whether to use interpolation",
                                                     FALSE,
                                                     GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_double ("x0",
                                                    "x0",
                                                    "The new x coordinate of upper-left corner of original bounding box",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_double ("y0",
                                                    "y0",
                                                    "The new y coordinate of upper-left corner of original bounding box",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_double ("x1",
                                                    "x1",
                                                    "The new x coordinate of upper-right corner of original bounding box",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_double ("y1",
                                                    "y1",
                                                    "The new y coordinate of upper-right corner of original bounding box",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_double ("x2",
                                                    "x2",
                                                    "The new x coordinate of lower-left corner of original bounding box",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_double ("y2",
                                                    "y2",
                                                    "The new y coordinate of lower-left corner of original bounding box",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_double ("x3",
                                                    "x3",
                                                    "The new x coordinate of lower-right corner of original bounding box",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_double ("y3",
                                                    "y3",
                                                    "The new y coordinate of lower-right corner of original bounding box",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_drawable_id ("drawable",
                                                                "drawable",
                                                                "The newly mapped drawable",
598
                                                                pdb->gimp, FALSE,
599
                                                                GIMP_PARAM_READWRITE));
600
  gimp_pdb_register_procedure (pdb, procedure);
601
  g_object_unref (procedure);
602 603 604 605

  /*
   * gimp-rotate
   */
606
  procedure = gimp_procedure_new (rotate_invoker);
607 608
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-rotate");
609 610
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-rotate",
611 612
                                     "Deprecated: Use 'gimp-item-transform-rotate' instead.",
                                     "Deprecated: Use 'gimp-item-transform-rotate' instead.",
613 614 615
                                     "",
                                     "",
                                     "",
616
                                     "gimp-item-transform-rotate");
617 618 619 620
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_drawable_id ("drawable",
                                                            "drawable",
                                                            "The affected drawable",
621
                                                            pdb->gimp, FALSE,
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638
                                                            GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_boolean ("interpolation",
                                                     "interpolation",
                                                     "Whether to use interpolation",
                                                     FALSE,
                                                     GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_double ("angle",
                                                    "angle",
                                                    "The angle of rotation (radians)",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_drawable_id ("drawable",
                                                                "drawable",
                                                                "The rotated drawable",
639
                                                                pdb->gimp, FALSE,
640
                                                                GIMP_PARAM_READWRITE));
641
  gimp_pdb_register_procedure (pdb, procedure);
642
  g_object_unref (procedure);
643

644 645 646
  /*
   * gimp-scale
   */
647
  procedure = gimp_procedure_new (scale_invoker);
648 649
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-scale");
650 651
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-scale",
652 653
                                     "Deprecated: Use 'gimp-item-transform-scale' instead.",
                                     "Deprecated: Use 'gimp-item-transform-scale' instead.",
654 655 656
                                     "",
                                     "",
                                     "",
657
                                     "gimp-item-transform-scale");
658 659 660 661
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_drawable_id ("drawable",
                                                            "drawable",
                                                            "The affected drawable",
662
                                                            pdb->gimp, FALSE,
663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697
                                                            GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_boolean ("interpolation",
                                                     "interpolation",
                                                     "Whether to use interpolation",
                                                     FALSE,
                                                     GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_double ("x0",
                                                    "x0",
                                                    "The new x coordinate of the upper-left corner of the scaled region",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_double ("y0",
                                                    "y0",
                                                    "The new y coordinate of the upper-left corner of the scaled region",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_double ("x1",
                                                    "x1",
                                                    "The new x coordinate of the lower-right corner of the scaled region",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_double ("y1",
                                                    "y1",
                                                    "The new y coordinate of the lower-right corner of the scaled region",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_drawable_id ("drawable",
                                                                "drawable",
                                                                "The scaled drawable",
698
                                                                pdb->gimp, FALSE,
699
                                                                GIMP_PARAM_READWRITE));
700
  gimp_pdb_register_procedure (pdb, procedure);
701
  g_object_unref (procedure);
702

703 704 705
  /*
   * gimp-shear
   */
706
  procedure = gimp_procedure_new (shear_invoker);
707 708
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-shear");
709 710
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-shear",
711 712
                                     "Deprecated: Use 'gimp-item-transform-shear' instead.",
                                     "Deprecated: Use 'gimp-item-transform-shear' instead.",
713 714 715
                                     "",
                                     "",
                                     "",
716
                                     "gimp-item-transform-shear");
717 718 719 720
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_drawable_id ("drawable",
                                                            "drawable",
                                                            "The affected drawable",
721
                                                            pdb->gimp, FALSE,
722 723 724 725 726 727 728 729 730 731
                                                            GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_boolean ("interpolation",
                                                     "interpolation",
                                                     "Whether to use interpolation",
                                                     FALSE,
                                                     GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_enum ("shear-type",
                                                     "shear type",
732
                                                     "Type of shear",
733 734 735 736 737 738 739 740 741 742 743 744 745 746 747
                                                     GIMP_TYPE_ORIENTATION_TYPE,
                                                     GIMP_ORIENTATION_HORIZONTAL,
                                                     GIMP_PARAM_READWRITE));
  gimp_param_spec_enum_exclude_value (GIMP_PARAM_SPEC_ENUM (procedure->args[2]),
                                      GIMP_ORIENTATION_UNKNOWN);
  gimp_procedure_add_argument (procedure,
                               g_param_spec_double ("magnitude",
                                                    "magnitude",
                                                    "The magnitude of the shear",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_drawable_id ("drawable",
                                                                "drawable",
                                                                "The sheared drawable",
748
                                                                pdb->gimp, FALSE,
749
                                                                GIMP_PARAM_READWRITE));
750
  gimp_pdb_register_procedure (pdb, procedure);
751
  g_object_unref (procedure);
752

753 754 755
  /*
   * gimp-transform-2d
   */
756
  procedure = gimp_procedure_new (transform_2d_invoker);
757 758
  gimp_object_set_static_name (GIMP_OBJECT (procedure),
                               "gimp-transform-2d");
759 760
  gimp_procedure_set_static_strings (procedure,
                                     "gimp-transform-2d",
761 762
                                     "Deprecated: Use 'gimp-item-transform-2d' instead.",
                                     "Deprecated: Use 'gimp-item-transform-2d' instead.",
763 764 765
                                     "",
                                     "",
                                     "",
766
                                     "gimp-item-transform-2d");
767 768 769 770
  gimp_procedure_add_argument (procedure,
                               gimp_param_spec_drawable_id ("drawable",
                                                            "drawable",
                                                            "The affected drawable",
771
                                                            pdb->gimp, FALSE,
772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824
                                                            GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_boolean ("interpolation",
                                                     "interpolation",
                                                     "Whether to use interpolation",
                                                     FALSE,
                                                     GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_double ("source-x",
                                                    "source x",
                                                    "X coordinate of the transformation center",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_double ("source-y",
                                                    "source y",
                                                    "Y coordinate of the transformation center",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_double ("scale-x",
                                                    "scale x",
                                                    "Amount to scale in x direction",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_double ("scale-y",
                                                    "scale y",
                                                    "Amount to scale in y direction",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_double ("angle",
                                                    "angle",
                                                    "The angle of rotation (radians)",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_double ("dest-x",
                                                    "dest x",
                                                    "X coordinate of where the centre goes",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    GIMP_PARAM_READWRITE));
  gimp_procedure_add_argument (procedure,
                               g_param_spec_double ("dest-y",
                                                    "dest y",
                                                    "Y coordinate of where the centre goes",
                                                    -G_MAXDOUBLE, G_MAXDOUBLE, 0,
                                                    GIMP_PARAM_READWRITE));
  gimp_procedure_add_return_value (procedure,
                                   gimp_param_spec_drawable_id ("drawable",
                                                                "drawable",
                                                                "The transformed drawable",
825
                                                                pdb->gimp, FALSE,
826
                                                                GIMP_PARAM_READWRITE));
827
  gimp_pdb_register_procedure (pdb, procedure);
828
  g_object_unref (procedure);
829
}