Page MenuHome

key.patch

key.patch

Index: source/blender/python/api2_2x/Key.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Key.c,v
retrieving revision 1.3
diff -u -r1.3 Key.c
--- source/blender/python/api2_2x/Key.c 3 Oct 2005 14:28:08 -0000 1.3
+++ source/blender/python/api2_2x/Key.c 25 Oct 2005 18:20:41 -0000
@@ -30,15 +30,23 @@
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
+#include "DNA_scene_types.h"
+
#include <BLI_blenlib.h>
#include <BKE_global.h>
#include <BKE_main.h>
+#include "IpoCurve.h"
#include "Key.h"
#include "NMesh.h" /* we create NMesh.NMVert objects */
#include "Ipo.h"
#include "BezTriple.h"
+#include "types.h"
+#include "BSE_editipo.h"
+#include "mydevice.h"
+#include "BKE_depsgraph.h"
+#include "blendef.h"
#include "constant.h"
#include "gen_utils.h"
@@ -55,63 +63,227 @@
static PyObject *KeyBlock_getattr( PyObject * self, char *name );
static PyObject *Key_repr( BPy_Key * self );
-PyTypeObject Key_Type = {
- PyObject_HEAD_INIT( NULL ) 0, /*ob_size */
- "Blender Key", /*tp_name */
- sizeof( BPy_Key ), /*tp_basicsize */
- 0, /*tp_itemsize */
- /* methods */
- ( destructor ) Key_dealloc, /*tp_dealloc */
- ( printfunc ) 0, /*tp_print */
- ( getattrfunc ) Key_getattr, /*tp_getattr */
- ( setattrfunc ) 0, /*tp_setattr */
- 0, /*tp_compare*/
- ( reprfunc ) Key_repr, /* tp_repr */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-};
-
-PyTypeObject KeyBlock_Type = {
- PyObject_HEAD_INIT( NULL ) 0, /*ob_size */
- "Blender KeyBlock", /*tp_name */
- sizeof( BPy_KeyBlock ), /*tp_basicsize */
- 0, /*tp_itemsize */
- /* methods */
- ( destructor ) KeyBlock_dealloc, /*tp_dealloc */
- ( printfunc ) 0, /*tp_print */
- ( getattrfunc ) KeyBlock_getattr, /*tp_getattr */
- ( setattrfunc ) 0, /*tp_setattr */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-};
-
static PyObject *Key_getBlocks( PyObject * self );
+static PyObject *Key_getChannelIpo(PyObject *self, PyObject *args);
static PyObject *Key_getType( PyObject * self );
static PyObject *Key_getIpo( PyObject * self );
static PyObject *Key_getValue( PyObject * self );
+static int Key_setValue( BPy_Key *, PyObject * args );
+static int Key_setType( BPy_Key *, PyObject * args );
static struct PyMethodDef Key_methods[] = {
- { "getType", (PyCFunction) Key_getType, METH_NOARGS, "Get key type" },
- { "getValue", (PyCFunction) Key_getValue, METH_NOARGS, "Get key value" },
{ "getBlocks", (PyCFunction) Key_getBlocks, METH_NOARGS, "Get key blocks" },
+ { "getChannelIpo", (PyCFunction) Key_getChannelIpo, METH_VARARGS, "Get a Particular shape channel's IpoCurve key blocks" },
{ "getIpo", (PyCFunction) Key_getIpo, METH_NOARGS, "Get key Ipo" },
{ 0, 0, 0, 0 }
};
+static PyGetSetDef BPy_Key_getsetters[] = {
+ {"type",(getter)Key_getType, (setter)NULL,
+ "Key Type",NULL},
+ {"value",(getter)Key_getValue, (setter)NULL,
+ "Key value",NULL},
+ {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
+ };
+
+
+
static PyObject *KeyBlock_getData( PyObject * self );
-static PyObject *KeyBlock_getPos( PyObject * self );
-static PyObject *KeyBlock_getName( PyObject * self );
+
+static PyObject *KeyBlock_getName( BPy_KeyBlock * self );
+static PyObject *KeyBlock_getPos( BPy_KeyBlock * self );
+static PyObject *KeyBlock_getSlidermin( BPy_KeyBlock * self );
+static PyObject *KeyBlock_getSlidermax( BPy_KeyBlock * self );
+static PyObject *KeyBlock_getVgroup( BPy_KeyBlock * self );
+
+static int KeyBlock_setName( BPy_KeyBlock *, PyObject * args );
+static int KeyBlock_setPos( BPy_KeyBlock *, PyObject * args );
+static int KeyBlock_setVgroup( BPy_KeyBlock *, PyObject * args );
+static int KeyBlock_setSlidermin( BPy_KeyBlock *, PyObject * args );
+static int KeyBlock_setSlidermax( BPy_KeyBlock *, PyObject * args );
+
+
static struct PyMethodDef KeyBlock_methods[] = {
- { "getPos", (PyCFunction) KeyBlock_getPos, METH_NOARGS,
- "Get keyblock position"},
{ "getData", (PyCFunction) KeyBlock_getData, METH_NOARGS,
"Get keyblock data" },
- { "getName", (PyCFunction) KeyBlock_getName, METH_NOARGS,
- "Get keyblock name"},
+
{ 0, 0, 0, 0 }
};
+static PyGetSetDef BPy_KeyBlock_getsetters[] = {
+ {"name",(getter)KeyBlock_getName, (setter)KeyBlock_setName,
+ "Keyblock Name",NULL},
+ {"pos",(getter)KeyBlock_getPos, (setter)NULL,
+ "Keyblock Pos",NULL},
+ {"slidermin",(getter)KeyBlock_getSlidermin, (setter)KeyBlock_setSlidermin,
+ "Keyblock Slider Minimum",NULL},
+ {"slidermax",(getter)KeyBlock_getSlidermax, (setter)KeyBlock_setSlidermax,
+ "Keyblock Slider Maximum",NULL},
+ {"vgroup",(getter)KeyBlock_getVgroup, (setter)KeyBlock_setVgroup,
+ "Keyblock VGroup",NULL},
+ {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
+ };
+
+PyTypeObject Key_Type = {
+ PyObject_HEAD_INIT( NULL ) 0, /*ob_size */
+ "Blender Key", /*tp_name */
+ sizeof( BPy_Key ), /*tp_basicsize */
+ 0, /*tp_itemsize */
+ /* methods */
+ ( destructor ) Key_dealloc, /*tp_dealloc */
+ ( printfunc ) 0, /*tp_print */
+ ( getattrfunc ) 0, /*tp_getattr */
+ ( setattrfunc ) 0, /*tp_setattr */
+ 0, /*tp_compare*/
+ ( reprfunc ) Key_repr, /* tp_repr */
+ /* Method suites for standard classes */
+
+ NULL, /* PyNumberMethods *tp_as_number; */
+ NULL, /* PySequenceMethods *tp_as_sequence; */
+ NULL, /* PyMappingMethods *tp_as_mapping; */
+
+ /* More standard operations (here for binary compatibility) */
+
+ NULL, /* hashfunc tp_hash; */
+ NULL, /* ternaryfunc tp_call; */
+ NULL, /* reprfunc tp_str; */
+ NULL, /* getattrofunc tp_getattro; */
+ NULL, /* setattrofunc tp_setattro; */
+
+ /* Functions to access object as input/output buffer */
+ NULL, /* PyBufferProcs *tp_as_buffer; */
+
+ /*** Flags to define presence of optional/expanded features ***/
+ Py_TPFLAGS_DEFAULT, /* long tp_flags; */
+
+ NULL, /* char *tp_doc; Documentation string */
+ /*** Assigned meaning in release 2.0 ***/
+ /* call function for all accessible objects */
+ NULL, /* traverseproc tp_traverse; */
+
+ /* delete references to contained objects */
+ NULL, /* inquiry tp_clear; */
+
+ /*** Assigned meaning in release 2.1 ***/
+ /*** rich comparisons ***/
+ NULL, /* richcmpfunc tp_richcompare; */
+
+ /*** weak reference enabler ***/
+ 0, /* long tp_weaklistoffset; */
+
+ /*** Added in release 2.2 ***/
+ /* Iterators */
+ NULL, /* getiterfunc tp_iter; */
+ NULL, /* iternextfunc tp_iternext; */
+
+ /*** Attribute descriptor and subclassing stuff ***/
+ Key_methods, /* struct PyMethodDef *tp_methods; */
+ NULL, /* struct PyMemberDef *tp_members; */
+ BPy_Key_getsetters, /* struct PyGetSetDef *tp_getset; */
+ NULL, /* struct _typeobject *tp_base; */
+ NULL, /* PyObject *tp_dict; */
+ NULL, /* descrgetfunc tp_descr_get; */
+ NULL, /* descrsetfunc tp_descr_set; */
+ 0, /* long tp_dictoffset; */
+ NULL, /* initproc tp_init; */
+ NULL, /* allocfunc tp_alloc; */
+ NULL, /* newfunc tp_new; */
+ /* Low-level free-memory routine */
+ NULL, /* freefunc tp_free; */
+ /* For PyObject_IS_GC */
+ NULL, /* inquiry tp_is_gc; */
+ NULL, /* PyObject *tp_bases; */
+ /* method resolution order */
+ NULL, /* PyObject *tp_mro; */
+ NULL, /* PyObject *tp_cache; */
+ NULL, /* PyObject *tp_subclasses; */
+ NULL, /* PyObject *tp_weaklist; */
+ NULL
+};
+
+
+
+
+PyTypeObject KeyBlock_Type = {
+ PyObject_HEAD_INIT( NULL ) 0, /*ob_size */
+ "Blender KeyBlock", /*tp_name */
+ sizeof( BPy_KeyBlock ), /*tp_basicsize */
+ 0, /*tp_itemsize */
+ /* methods */
+ ( destructor ) KeyBlock_dealloc, /*tp_dealloc */
+ NULL, /*tp_print */
+ NULL, /*tp_getattr */
+ NULL, /*tp_setattr */
+ NULL, /*tp_compare*/
+ NULL, /* tp_repr */
+ /* Method suites for standard classes */
+
+ NULL, /* PyNumberMethods *tp_as_number; */
+ NULL, /* PySequenceMethods *tp_as_sequence; */
+ NULL, /* PyMappingMethods *tp_as_mapping; */
+
+ /* More standard operations (here for binary compatibility) */
+
+ NULL, /* hashfunc tp_hash; */
+ NULL, /* ternaryfunc tp_call; */
+ NULL, /* reprfunc tp_str; */
+ NULL, /* getattrofunc tp_getattro; */
+ NULL, /* setattrofunc tp_setattro; */
+
+ /* Functions to access object as input/output buffer */
+ NULL, /* PyBufferProcs *tp_as_buffer; */
+
+ /*** Flags to define presence of optional/expanded features ***/
+ Py_TPFLAGS_DEFAULT, /* long tp_flags; */
+
+ NULL, /* char *tp_doc; Documentation string */
+ /*** Assigned meaning in release 2.0 ***/
+ /* call function for all accessible objects */
+ NULL, /* traverseproc tp_traverse; */
+
+ /* delete references to contained objects */
+ NULL, /* inquiry tp_clear; */
+
+ /*** Assigned meaning in release 2.1 ***/
+ /*** rich comparisons ***/
+ NULL, /* richcmpfunc tp_richcompare; */
+
+ /*** weak reference enabler ***/
+ 0, /* long tp_weaklistoffset; */
+
+ /*** Added in release 2.2 ***/
+ /* Iterators */
+ NULL, /* getiterfunc tp_iter; */
+ NULL, /* iternextfunc tp_iternext; */
+
+ /*** Attribute descriptor and subclassing stuff ***/
+ KeyBlock_methods, /* struct PyMethodDef *tp_methods; */
+ NULL, /* struct PyMemberDef *tp_members; */
+ BPy_KeyBlock_getsetters, /* struct PyGetSetDef *tp_getset; */
+ NULL, /* struct _typeobject *tp_base; */
+ NULL, /* PyObject *tp_dict; */
+ NULL, /* descrgetfunc tp_descr_get; */
+ NULL, /* descrsetfunc tp_descr_set; */
+ 0, /* long tp_dictoffset; */
+ NULL, /* initproc tp_init; */
+ NULL, /* allocfunc tp_alloc; */
+ NULL, /* newfunc tp_new; */
+ /* Low-level free-memory routine */
+ NULL, /* freefunc tp_free; */
+ /* For PyObject_IS_GC */
+ NULL, /* inquiry tp_is_gc; */
+ NULL, /* PyObject *tp_bases; */
+ /* method resolution order */
+ NULL, /* PyObject *tp_mro; */
+ NULL, /* PyObject *tp_cache; */
+ NULL, /* PyObject *tp_subclasses; */
+ NULL, /* PyObject *tp_weaklist; */
+ NULL
+};
+
+
+
static void Key_dealloc( PyObject * self )
{
PyObject_DEL( self );
@@ -159,13 +331,6 @@
return PyString_FromFormat( "[Key \"%s\"]", self->key->id.name + 2 );
}
-static PyObject *Key_getValue( PyObject * self )
-{
- BPy_Key *k = ( BPy_Key * ) self;
-
- return PyFloat_FromDouble( k->key->curval );
-}
-
static PyObject *Key_getIpo( PyObject * self )
{
BPy_Key *k = ( BPy_Key * ) self;
@@ -220,6 +385,19 @@
return l;
}
+
+static PyObject *Key_getValue( PyObject * self )
+{
+ BPy_Key *k = ( BPy_Key * ) self;
+
+ return PyFloat_FromDouble( k->key->curval );
+}
+
+
+
+
+// ------------ Key Block Functions --------------//
+
static void KeyBlock_dealloc( PyObject * self )
{
PyObject_DEL( self );
@@ -258,19 +436,76 @@
return Py_FindMethod( KeyBlock_methods, ( PyObject * ) self, name );
}
-static PyObject *KeyBlock_getName( PyObject * self ) {
+
+
+static PyObject *KeyBlock_getName( BPy_KeyBlock * self ) {
BPy_KeyBlock *kb = ( BPy_KeyBlock * ) self;
PyObject *name = Py_BuildValue( "s", kb->keyblock->name);
return name;
}
+static PyObject *KeyBlock_getPos( BPy_KeyBlock * self ){
+ BPy_KeyBlock *kb = ( BPy_KeyBlock * ) self;
+ return PyFloat_FromDouble( kb->keyblock->pos );
+}
+static PyObject *KeyBlock_getSlidermin( BPy_KeyBlock * self ){
+ BPy_KeyBlock *kb = ( BPy_KeyBlock * ) self;
+ return PyFloat_FromDouble( kb->keyblock->slidermin );
+}
+static PyObject *KeyBlock_getSlidermax( BPy_KeyBlock * self ){
+ BPy_KeyBlock *kb = ( BPy_KeyBlock * ) self;
+ return PyFloat_FromDouble( kb->keyblock->slidermax );
+}
+static PyObject *KeyBlock_getVgroup( BPy_KeyBlock * self ){
+ BPy_KeyBlock *kb = ( BPy_KeyBlock * ) self;
+ PyObject *name = Py_BuildValue( "s", kb->keyblock->vgroup);
+ return name;
+}
-static PyObject *KeyBlock_getPos( PyObject * self )
-{
- BPy_KeyBlock *kb = ( BPy_KeyBlock * ) self;
- return PyFloat_FromDouble( kb->keyblock->pos );
+
+
+static int KeyBlock_setName( BPy_KeyBlock * self, PyObject * args ){
+ char* text = NULL;
+ BPy_KeyBlock *kb = ( BPy_KeyBlock * ) self;
+
+ text = PyString_AsString ( args );
+ if( !text )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected string argument" );
+ strncpy( kb->keyblock->name, text , 32);
+
+ return 0;
+}
+
+static int KeyBlock_setVgroup( BPy_KeyBlock * self, PyObject * args ){
+ char* text = NULL;
+ BPy_KeyBlock *kb = ( BPy_KeyBlock * ) self;
+
+ text = PyString_AsString ( args );
+ if( !text )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected string argument" );
+ strncpy( kb->keyblock->vgroup, text , 32);
+
+ return 0;
+}
+static int KeyBlock_setSlidermin( BPy_KeyBlock * self, PyObject * args ){
+ return EXPP_setFloatClamped ( args, &self->keyblock->slidermin,
+ -10.0f,
+ 10.0f );
+}
+static int KeyBlock_setSlidermax( BPy_KeyBlock * self, PyObject * args ){
+ return EXPP_setFloatClamped ( args, &self->keyblock->slidermax,
+ -10.0f,
+ 10.0f );
}
+
+
+
+
+
+
static PyObject *KeyBlock_getData( PyObject * self )
{
/* If this is a mesh key, data is an array of MVert.
@@ -405,8 +640,13 @@
{
PyObject *submodule, *KeyTypes;
+ if( PyType_Ready( &Key_Type ) < 0)
+ return NULL;
+
Key_Type.ob_type = &PyType_Type;
- KeyBlock_Type.ob_type = &PyType_Type;
+ //KeyBlock_Type.ob_type = &PyType_Type;
+ PyType_Ready( &KeyBlock_Type );
+
submodule =
Py_InitModule3( "Blender.Key", M_Key_methods, "Key module" );
@@ -425,4 +665,22 @@
PyModule_AddIntConstant( submodule, "TYPE_LATTICE", KEY_TYPE_LATTICE );
*/
return submodule;
+}
+
+static PyObject *Key_getChannelIpo(PyObject *self, PyObject *args){
+ short index;
+ IpoCurve *curve;
+ BPy_KeyBlock *kb = ( BPy_KeyBlock * ) self;
+ Key *key = kb->key;
+ C_IpoCurve *output;
+
+ if( !PyArg_ParseTuple( args, "i", &index ) ) {
+ return ( EXPP_ReturnIntError( PyExc_TypeError,
+ "expected one integer as an arguments" ) );
+ }
+
+ curve = verify_ipocurve(&key->id,ID_KE,NULL,NULL,index);
+ output = ( C_IpoCurve * ) PyObject_NEW( C_IpoCurve, &IpoCurve_Type );
+ output->ipocurve = curve;
+ return ( ( PyObject * ) output );
}
Index: source/blender/python/api2_2x/doc/Key.py
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/doc/Key.py,v
retrieving revision 1.2
diff -u -r1.2 Key.py
--- source/blender/python/api2_2x/doc/Key.py 3 Oct 2005 14:29:03 -0000 1.2
+++ source/blender/python/api2_2x/doc/Key.py 23 Oct 2005 00:49:19 -0000
@@ -35,17 +35,17 @@
An object with keyframes (L{Lattice.Lattice}, L{NMesh.NMesh} or
L{Curve.Curve}) will contain a Key object representing the
keyframe data.
+
+ @ivar value: The Value of the Key - Read Only
+ @type value: float
+ @ivar type: An integer from the L{Types} dictionary
+ representing the Key type.
+ @type type: int
+
@cvar blocks: A list of KeyBlocks.
@cvar ipo: The L{Ipo.Ipo} object associated with this key.
- @cvar type: An integer from the L{Types} dictionary
- representing the Key type.
"""
- def getType():
- """
- Get the type of this Key object. It will be one of the
- integers defined in the L{Types} dictionary.
- """
def getIpo():
"""
Get the L{Ipo.Ipo} object associated with this key.
@@ -55,44 +55,51 @@
Get a list of L{KeyBlock}s, containing the keyframes defined for
this Key.
"""
-
+ def setDriverChannel(index):
+ """
+ Get the IpoCurve object associated with the shape key referenced
+ by the index of that key in getBlocks
+ @type index: int
+ @param index: the keyblock index to retrieve an IPO for.
+ @rtype: Blender IpoCurve
+ @return: Ipo Data Object:
+ """
+
class KeyBlock:
+ """
+ The KeyBlock object
+ ===================
+ Each Key object has a list of KeyBlocks attached, each KeyBlock
+ representing a keyframe.
+
+ @ivar name: The Name of the Keyblock
+ Truncated to 32 Characters
+ @type name: string
+ @ivar pos: The position of the keyframe
+ @type pos: float
+ @ivar slidermin: The minimum value for the action slider
+ @type slidermin: float
+ @ivar slidermax: The maximum value for the action slider
+ @type slidermax: float
+ @ivar vgroup: The assigned VGroup for the Key Block
+ @type vgroup: string
+
+ @cvar data: The data of the KeyBlock (see L{getData}). This
+ attribute is read-only.
+ """
+ def getData():
"""
- The KeyBlock object
- ===================
- Each Key object has a list of KeyBlocks attached, each KeyBlock
- representing a keyframe.
-
- @cvar data: The data of the KeyBlock (see L{getData}). This
- attribute is read-only.
- @cvar pos: The position of the keyframe (see L{getPos}). This
- attribute is read-only.
- @cvar name: The name of the KeyBlock. This attribute is read-only.
- """
- def getData():
- """
- Get the data of a KeyBlock, as a list of data items. Each item
- will have a different data type depending on the type of this
- Key.
-
- Mesh keys have a list of L{NMesh.NMVert} objects in the data
- block.
-
- Lattice keys have a list of BPoints in the data block. These
- don't have corresponding Python objects yet, so each BPoint is
- represented using a list of four floating-point numbers.
-
- Curve keys have a list of L{Ipo.BezTriple} objects in the data
- block.
- """
+ Get the data of a KeyBlock, as a list of data items. Each item
+ will have a different data type depending on the type of this
+ Key.
+ Mesh keys have a list of L{NMesh.NMVert} objects in the data
+ block.
+
+ Lattice keys have a list of BPoints in the data block. These
+ don't have corresponding Python objects yet, so each BPoint is
+ represented using a list of four floating-point numbers.
- def getPos():
- """
- Get the position of the keyframe represented by this KeyBlock,
- normally between 0.0 and 1.0. The time point when the Speed
- Ipo intersects the KeyBlock position is the actual time of the
- keyframe.
- """
+ Curve keys have a list of L{Ipo.BezTriple} objects in the data
+ block.
+ """
- def getName():
- """Get the name of the keyframe represented by this KeyBlock."""

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
92/f3/b429ea4efa577ec7f06f30aa8fb1

Event Timeline