1
/* GIMP - The GNU Image Manipulation Program
2
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
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 2 of the License, or
7
* (at your option) any later version.
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.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
#include <glib-object.h>
25
#include "paint-types.h"
28
#include "gimpink-blob.h"
29
#include "gimpinkundo.h"
32
static GObject * gimp_ink_undo_constructor (GType type,
34
GObjectConstructParam *params);
36
static void gimp_ink_undo_pop (GimpUndo *undo,
37
GimpUndoMode undo_mode,
38
GimpUndoAccumulator *accum);
39
static void gimp_ink_undo_free (GimpUndo *undo,
40
GimpUndoMode undo_mode);
43
G_DEFINE_TYPE (GimpInkUndo, gimp_ink_undo, GIMP_TYPE_PAINT_CORE_UNDO)
45
#define parent_class gimp_ink_undo_parent_class
49
gimp_ink_undo_class_init (GimpInkUndoClass *klass)
51
GObjectClass *object_class = G_OBJECT_CLASS (klass);
52
GimpUndoClass *undo_class = GIMP_UNDO_CLASS (klass);
54
object_class->constructor = gimp_ink_undo_constructor;
56
undo_class->pop = gimp_ink_undo_pop;
57
undo_class->free = gimp_ink_undo_free;
61
gimp_ink_undo_init (GimpInkUndo *undo)
66
gimp_ink_undo_constructor (GType type,
68
GObjectConstructParam *params)
71
GimpInkUndo *ink_undo;
74
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
76
ink_undo = GIMP_INK_UNDO (object);
78
g_assert (GIMP_IS_INK (GIMP_PAINT_CORE_UNDO (ink_undo)->paint_core));
80
ink = GIMP_INK (GIMP_PAINT_CORE_UNDO (ink_undo)->paint_core);
83
ink_undo->last_blob = blob_duplicate (ink->start_blob);
85
memcpy (ink_undo->dt_buffer, ink->dt_buffer,
86
sizeof (ink_undo->dt_buffer));
88
ink_undo->dt_index = ink->dt_index;
90
memcpy (ink_undo->ts_buffer, ink->ts_buffer,
91
sizeof (ink_undo->ts_buffer));
93
ink_undo->ts_index = ink->ts_index;
95
ink_undo->last_time = ink->last_time;
97
ink_undo->init_velocity = ink->init_velocity;
103
gimp_ink_undo_pop (GimpUndo *undo,
104
GimpUndoMode undo_mode,
105
GimpUndoAccumulator *accum)
107
GimpInkUndo *ink_undo = GIMP_INK_UNDO (undo);
109
GIMP_UNDO_CLASS (parent_class)->pop (undo, undo_mode, accum);
111
if (GIMP_PAINT_CORE_UNDO (ink_undo)->paint_core)
113
GimpInk *ink = GIMP_INK (GIMP_PAINT_CORE_UNDO (ink_undo)->paint_core);
117
guint32 tmp_int_buf[DIST_SMOOTHER_BUFFER];
118
gdouble tmp_double_buf[DIST_SMOOTHER_BUFFER];
120
tmp_blob = ink->last_blob;
121
ink->last_blob = ink_undo->last_blob;
122
ink_undo->last_blob = tmp_blob;
124
memcpy (tmp_double_buf, ink->dt_buffer,
125
sizeof (tmp_double_buf));
126
memcpy (ink->dt_buffer, ink_undo->dt_buffer,
127
sizeof (tmp_double_buf));
128
memcpy (ink_undo->dt_buffer, tmp_double_buf,
129
sizeof (tmp_double_buf));
131
tmp_int = ink->dt_index;
132
ink->dt_index = ink_undo->dt_index;
133
ink_undo->dt_index = tmp_int;
135
memcpy (tmp_int_buf, ink->ts_buffer,
136
sizeof (tmp_int_buf));
137
memcpy (ink->ts_buffer, ink_undo->ts_buffer,
138
sizeof (tmp_int_buf));
139
memcpy (ink_undo->ts_buffer, tmp_int_buf,
140
sizeof (tmp_int_buf));
142
tmp_int = ink->ts_index;
143
ink->ts_index = ink_undo->ts_index;
144
ink_undo->ts_index = tmp_int;
146
tmp_double = ink->last_time;
147
ink->last_time = ink_undo->last_time;
148
ink_undo->last_time = tmp_double;
150
tmp_int = ink->init_velocity;
151
ink->init_velocity = ink_undo->init_velocity;
152
ink_undo->init_velocity = tmp_int;
157
gimp_ink_undo_free (GimpUndo *undo,
158
GimpUndoMode undo_mode)
160
GimpInkUndo *ink_undo = GIMP_INK_UNDO (undo);
162
if (ink_undo->last_blob)
164
g_free (ink_undo->last_blob);
165
ink_undo->last_blob = NULL;
168
GIMP_UNDO_CLASS (parent_class)->free (undo, undo_mode);