rotate: use the new more generic sub-classing infrastructure

parent 91d0febb
......@@ -39,7 +39,7 @@ gegl_module_query (GTypeModule *module)
return &modinfo;
}
GType rotate_get_type (void);
GType gegl_op_rotate_register_type (GTypeModule *module);
GType rotate_on_center_get_type (void);
GType scale_ratio_get_type (void);
GType scale_size_get_type (void);
......@@ -49,6 +49,8 @@ GType translate_get_type (void);
GType reflect_get_type (void);
GType transform_get_type (void);
#include <stdio.h>
G_MODULE_EXPORT gboolean
gegl_module_register (GTypeModule *module)
{
......@@ -56,7 +58,6 @@ gegl_module_register (GTypeModule *module)
transform_module = module;
dummy = op_transform_get_type ();
dummy = rotate_get_type ();
dummy = rotate_on_center_get_type ();
dummy = scale_ratio_get_type ();
dummy = scale_size_get_type ();
......@@ -65,6 +66,7 @@ gegl_module_register (GTypeModule *module)
dummy = translate_get_type ();
dummy = reflect_get_type ();
dummy = transform_get_type ();
dummy = gegl_op_rotate_register_type (module);
dummy ++; /* silence gcc, having it is required to avoid optimizing
away the _get_type calls themselves */
......
......@@ -14,23 +14,31 @@
* License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2006 Philip Lafleur
* 2017 Øyvind Kolås
*/
#include "config.h"
#include <glib/gi18n-lib.h>
#ifdef GEGL_PROPERTIES
#ifdef GEGL_CHANT_PROPERTIES
gegl_chant_double (degrees, -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
_("Angle to rotate (counter-clockwise)"))
property_double (degrees, _("Degrees"), 0.0)
description(_("Angle to rotate (counter-clockwise)"))
value_range (-720.0, 720.0)
ui_range (-180.0, 180.0)
#else
#define GEGL_CHANT_NAME rotate
#define GEGL_CHANT_DESCRIPTION _("Rotate the buffer around the specified origin.")
#define GEGL_CHANT_SELF "rotate.c"
#include "chant.h"
#include "gegl-operation-filter.h"
#include "transform-core.h"
#define GEGL_OP_NO_SOURCE
#define GEGL_OP_Parent OpTransform
#define GEGL_OP_PARENT TYPE_OP_TRANSFORM
#define GEGL_OP_NAME rotate
#define GEGL_OP_BUNDLE
#define GEGL_OP_C_FILE "rotate.c"
#include "gegl-op.h"
#include <math.h>
......@@ -38,12 +46,32 @@ static void
create_matrix (OpTransform *op,
GeglMatrix3 *matrix)
{
GeglChantOperation *chant = GEGL_CHANT_OPERATION (op);
double radians = chant->degrees * (2 * G_PI / 360.0);
GeglProperties *o = GEGL_PROPERTIES (op);
double radians = o->degrees * (2 * G_PI / 360.0);
matrix->coeff [0][0] = matrix->coeff [1][1] = cos (radians);
matrix->coeff [0][1] = sin (radians);
matrix->coeff [1][0] = - matrix->coeff [0][1];
}
#include <stdio.h>
static void
gegl_op_class_init (GeglOpClass *klass)
{
GeglOperationClass *operation_class;
OpTransformClass *transform_class;
operation_class = GEGL_OPERATION_CLASS (klass);
transform_class = OP_TRANSFORM_CLASS (klass);
transform_class->create_matrix = create_matrix;
gegl_operation_class_set_keys (operation_class,
"name", "gegl:rotate",
"title", _("Rotate"),
"categories", "transform",
"description", _("Rotate the buffer around the specified origin."),
NULL);
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment