~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to source/blender/python/intern/bpy_rna_anim.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
#include "BKE_fcurve.h"
45
45
 
46
46
#include "RNA_access.h"
 
47
#include "RNA_enum_types.h"
47
48
 
48
49
#include "WM_api.h"
49
50
#include "WM_types.h"
52
53
#include "bpy_util.h"
53
54
#include "bpy_rna_anim.h"
54
55
 
55
 
#define TRUE 1
56
 
#define FALSE 0
57
 
 
58
56
/* for keyframes and drivers */
59
57
static int pyrna_struct_anim_args_parse(
60
58
        PointerRNA *ptr, const char *error_prefix, const char *path,
150
148
/* internal use for insert and delete */
151
149
static int pyrna_struct_keyframe_parse(
152
150
        PointerRNA *ptr, PyObject *args, PyObject *kw, const char *parse_str, const char *error_prefix,
153
 
        const char **path_full, int *index, float *cfra, const char **group_name)     /* return values */
 
151
        const char **path_full, int *index, float *cfra, const char **group_name, int *options)     /* return values */
154
152
{
155
 
        static const char *kwlist[] = {"data_path", "index", "frame", "group", NULL};
 
153
        static const char *kwlist[] = {"data_path", "index", "frame", "group", "options", NULL};
 
154
        PyObject *pyoptions = NULL;
156
155
        const char *path;
157
156
 
158
 
        /* note, parse_str MUST start with 's|ifs' */
159
 
        if (!PyArg_ParseTupleAndKeywords(args, kw, parse_str, (char **)kwlist, &path, index, cfra, group_name))
 
157
        /* note, parse_str MUST start with 's|ifsO!' */
 
158
        if (!PyArg_ParseTupleAndKeywords(args, kw, parse_str, (char **)kwlist, &path, index, cfra, group_name,
 
159
                                         &PySet_Type, &pyoptions)) {
160
160
                return -1;
 
161
        }
161
162
 
162
 
        if (pyrna_struct_anim_args_parse(ptr, error_prefix, path, path_full, index) < 0)
 
163
        if (pyrna_struct_anim_args_parse(ptr, error_prefix, path, path_full, index) == -1)
163
164
                return -1;
164
165
 
165
166
        if (*cfra == FLT_MAX)
166
167
                *cfra = CTX_data_scene(BPy_GetContext())->r.cfra;
167
168
 
 
169
        /* flag may be null (no option currently for remove keyframes e.g.). */
 
170
        if (pyoptions && options && (pyrna_set_to_enum_bitfield(keying_flag_items, pyoptions, options, error_prefix) == -1))
 
171
                return -1;
 
172
 
168
173
        return 0; /* success */
169
174
}
170
175
 
175
180
"\n"
176
181
"   :arg data_path: path to the property to key, analogous to the fcurve's data path.\n"
177
182
"   :type data_path: string\n"
178
 
"   :arg index: array index of the property to key. Defaults to -1 which will key all indices or a single channel if the property is not an array.\n"
 
183
"   :arg index: array index of the property to key. Defaults to -1 which will key all indices or a single channel "
 
184
               "if the property is not an array.\n"
179
185
"   :type index: int\n"
180
186
"   :arg frame: The frame on which the keyframe is inserted, defaulting to the current frame.\n"
181
187
"   :type frame: float\n"
182
188
"   :arg group: The name of the group the F-Curve should be added to if it doesn't exist yet.\n"
183
189
"   :type group: str\n"
 
190
"   :arg options: Some optional flags:\n"
 
191
"                     'NEEDED': Only insert keyframes where they're needed in the relevant F-Curves.\n"
 
192
"                     'VISUAL': Insert keyframes based on 'visual transforms'.\n"
 
193
"                     'XYZ_TO_RGB': Color for newly added transformation F-Curves (Location, Rotation, Scale) "
 
194
                                   "and also Color is based on the transform axis.\n"
 
195
"   :type flag: set\n"
184
196
"   :return: Success of keyframe insertion.\n"
185
197
"   :rtype: boolean\n"
186
198
;
191
203
        int index = -1;
192
204
        float cfra = FLT_MAX;
193
205
        const char *group_name = NULL;
 
206
        int options = 0;
194
207
 
195
208
        PYRNA_STRUCT_CHECK_OBJ(self);
196
209
 
197
210
        if (pyrna_struct_keyframe_parse(&self->ptr, args, kw,
198
 
                                        "s|ifs:bpy_struct.keyframe_insert()", "bpy_struct.keyframe_insert()",
199
 
                                        &path_full, &index, &cfra, &group_name) == -1)
 
211
                                        "s|ifsO!:bpy_struct.keyframe_insert()", "bpy_struct.keyframe_insert()",
 
212
                                        &path_full, &index, &cfra, &group_name, &options) == -1)
200
213
        {
201
214
                return NULL;
202
215
        }
206
219
 
207
220
                BKE_reports_init(&reports, RPT_STORE);
208
221
 
209
 
                result = insert_keyframe(&reports, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, 0);
 
222
                result = insert_keyframe(&reports, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, options);
210
223
                MEM_freeN((void *)path_full);
211
224
 
212
 
                if (BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1)
 
225
                if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
213
226
                        return NULL;
214
227
 
215
228
                return PyBool_FromLong(result);
243
256
        PYRNA_STRUCT_CHECK_OBJ(self);
244
257
 
245
258
        if (pyrna_struct_keyframe_parse(&self->ptr, args, kw,
246
 
                                        "s|ifs:bpy_struct.keyframe_delete()",
 
259
                                        "s|ifsO!:bpy_struct.keyframe_delete()",
247
260
                                        "bpy_struct.keyframe_insert()",
248
 
                                        &path_full, &index, &cfra, &group_name) == -1)
 
261
                                        &path_full, &index, &cfra, &group_name, NULL) == -1)
249
262
        {
250
263
                return NULL;
251
264
        }
258
271
                result = delete_keyframe(&reports, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, 0);
259
272
                MEM_freeN((void *)path_full);
260
273
 
261
 
                if (BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1)
 
274
                if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
262
275
                        return NULL;
263
276
 
264
277
                return PyBool_FromLong(result);
288
301
        if (!PyArg_ParseTuple(args, "s|i:driver_add", &path, &index))
289
302
                return NULL;
290
303
 
291
 
        if (pyrna_struct_anim_args_parse(&self->ptr, "bpy_struct.driver_add():", path, &path_full, &index) < 0) {
 
304
        if (pyrna_struct_anim_args_parse(&self->ptr, "bpy_struct.driver_add():", path, &path_full, &index) == -1) {
292
305
                return NULL;
293
306
        }
294
307
        else {
300
313
 
301
314
                result = ANIM_add_driver(&reports, (ID *)self->ptr.id.data, path_full, index, 0, DRIVER_TYPE_PYTHON);
302
315
 
303
 
                if (BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1)
 
316
                if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
304
317
                        return NULL;
305
318
 
306
319
                if (result) {
364
377
        if (!PyArg_ParseTuple(args, "s|i:driver_remove", &path, &index))
365
378
                return NULL;
366
379
 
367
 
        if (pyrna_struct_anim_args_parse(&self->ptr, "bpy_struct.driver_remove():", path, &path_full, &index) < 0) {
 
380
        if (pyrna_struct_anim_args_parse(&self->ptr, "bpy_struct.driver_remove():", path, &path_full, &index) == -1) {
368
381
                return NULL;
369
382
        }
370
383
        else {
377
390
 
378
391
                MEM_freeN((void *)path_full);
379
392
 
380
 
                if (BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1)
 
393
                if (BPy_reports_to_error(&reports, PyExc_RuntimeError, true) == -1)
381
394
                        return NULL;
382
395
                
383
396
                WM_event_add_notifier(BPy_GetContext(), NC_ANIMATION | ND_FCURVES_ORDER, NULL);