| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2004-09-18 18:47:03 +00:00
										 |  |  |  * $Id$ | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |  * as published by the Free Software Foundation; either version 2 | 
					
						
							|  |  |  |  * of the License, or (at your option) any later version. The Blender | 
					
						
							|  |  |  |  * Foundation also sells licenses for use in proprietary software under | 
					
						
							|  |  |  |  * the Blender License.  See http://www.blender.org/BL/ for information
 | 
					
						
							|  |  |  |  * about this. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * 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 | 
					
						
							|  |  |  |  * along with this program; if not, write to the Free Software Foundation, | 
					
						
							|  |  |  |  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. | 
					
						
							|  |  |  |  * All rights reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This is a new part of Blender. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2005-05-20 12:16:54 +00:00
										 |  |  |  * Contributor(s): Jacques Guignot RIP 2005, Nathan Letwory,  | 
					
						
							|  |  |  |  *  Stephen Swaney, Ken Hughes | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * ***** END GPL/BL DUAL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-07-18 03:50:37 +00:00
										 |  |  | #include "Ipo.h" /*This must come first*/
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "BKE_main.h"
 | 
					
						
							|  |  |  | #include "BKE_global.h"
 | 
					
						
							|  |  |  | #include "BKE_library.h"
 | 
					
						
							| 
									
										
										
										
											2007-03-14 03:01:24 +00:00
										 |  |  | #include "BKE_object.h"
 | 
					
						
							| 
									
										
										
										
											2005-07-18 03:50:37 +00:00
										 |  |  | #include "BKE_ipo.h"
 | 
					
						
							|  |  |  | #include "BLI_blenlib.h"
 | 
					
						
							|  |  |  | #include "BIF_space.h"
 | 
					
						
							|  |  |  | #include "BSE_editipo.h"
 | 
					
						
							|  |  |  | #include "MEM_guardedalloc.h"
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | #include "DNA_key_types.h"
 | 
					
						
							| 
									
										
										
										
											2005-07-18 03:50:37 +00:00
										 |  |  | #include "mydevice.h"
 | 
					
						
							| 
									
										
										
										
											2004-10-07 19:25:40 +00:00
										 |  |  | #include "Ipocurve.h"
 | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | #include "gen_utils.h"
 | 
					
						
							| 
									
										
										
										
											2007-03-11 04:05:45 +00:00
										 |  |  | #include "gen_library.h"
 | 
					
						
							| 
									
										
										
										
											2004-10-07 19:25:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | extern int ob_ar[]; | 
					
						
							|  |  |  | extern int la_ar[]; | 
					
						
							|  |  |  | extern int ma_ar[]; | 
					
						
							|  |  |  | extern int ac_ar[]; | 
					
						
							|  |  |  | extern int cam_ar[]; | 
					
						
							|  |  |  | extern int co_ar[]; | 
					
						
							|  |  |  | extern int cu_ar[]; | 
					
						
							|  |  |  | extern int seq_ar[]; | 
					
						
							|  |  |  | extern int te_ar[]; | 
					
						
							|  |  |  | extern int wo_ar[]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyObject *submodule; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | /* Python API function prototypes for the Ipo module.                        */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *M_Ipo_New( PyObject * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *M_Ipo_Get( PyObject * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *M_Ipo_Recalc( PyObject * self, PyObject * args ); | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | /* The following string definitions are used for documentation strings.      */ | 
					
						
							|  |  |  | /* In Python these will be written to the console when doing a               */ | 
					
						
							|  |  |  | /* Blender.Ipo.__doc__                                                       */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | char M_Ipo_doc[] = ""; | 
					
						
							|  |  |  | char M_Ipo_New_doc[] = ""; | 
					
						
							|  |  |  | char M_Ipo_Get_doc[] = ""; | 
					
						
							| 
									
										
										
										
											2003-07-21 00:08:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Python method structure definition for Blender.Ipo module:             */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-07-21 00:08:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | struct PyMethodDef M_Ipo_methods[] = { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	{"New", ( PyCFunction ) M_Ipo_New, METH_VARARGS | METH_KEYWORDS, | 
					
						
							|  |  |  | 	 M_Ipo_New_doc}, | 
					
						
							|  |  |  | 	{"Get", M_Ipo_Get, METH_VARARGS, M_Ipo_Get_doc}, | 
					
						
							|  |  |  | 	{"get", M_Ipo_Get, METH_VARARGS, M_Ipo_Get_doc}, | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	{"Recalc", M_Ipo_Recalc, METH_O, M_Ipo_Get_doc}, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	{NULL, NULL, 0, NULL} | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Python BPy_Ipo methods declarations:                                     */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Ipo_getBlocktype( BPy_Ipo * self ); | 
					
						
							| 
									
										
										
										
											2006-04-24 05:24:58 +00:00
										 |  |  | static PyObject *Ipo_oldsetBlocktype( BPy_Ipo * self, PyObject * args ); | 
					
						
							|  |  |  | static int Ipo_setBlocktype( BPy_Ipo * self, PyObject * args ); | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Ipo_getRctf( BPy_Ipo * self ); | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | static PyObject *Ipo_oldsetRctf( BPy_Ipo * self, PyObject * args ); | 
					
						
							|  |  |  | static int Ipo_setRctf( BPy_Ipo * self, PyObject * args ); | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Ipo_getCurve( BPy_Ipo * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *Ipo_getCurves( BPy_Ipo * self ); | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | static PyObject *Ipo_getCurveNames( BPy_Ipo * self ); | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | static PyObject *Ipo_addCurve( BPy_Ipo * self, PyObject * value ); | 
					
						
							| 
									
										
										
										
											2005-04-24 19:03:39 +00:00
										 |  |  | static PyObject *Ipo_delCurve( BPy_Ipo * self, PyObject * args ); | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Ipo_getNcurves( BPy_Ipo * self ); | 
					
						
							|  |  |  | static PyObject *Ipo_getNBezPoints( BPy_Ipo * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *Ipo_DeleteBezPoints( BPy_Ipo * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *Ipo_getCurveBP( BPy_Ipo * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *Ipo_getCurvecurval( BPy_Ipo * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *Ipo_EvaluateCurveOn( BPy_Ipo * self, PyObject * args ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Ipo_setCurveBeztriple( BPy_Ipo * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *Ipo_getCurveBeztriple( BPy_Ipo * self, PyObject * args ); | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | static PyObject *Ipo_getChannel( BPy_Ipo * self ); | 
					
						
							| 
									
										
										
										
											2007-03-14 03:01:24 +00:00
										 |  |  | static PyObject *Ipo_copy( BPy_Ipo * self ); | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | static int Ipo_setChannel( BPy_Ipo * self, PyObject * args ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int Ipo_length( BPy_Ipo * inst ); | 
					
						
							|  |  |  | static PyObject *Ipo_getIpoCurveByName( BPy_Ipo * self, PyObject * key ); | 
					
						
							|  |  |  | static int Ipo_setIpoCurveByName( BPy_Ipo * self, PyObject * key,  | 
					
						
							|  |  |  | 		PyObject * value ); | 
					
						
							|  |  |  | static int Ipo_contains( BPy_Ipo * self, PyObject * key ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Python BPy_Ipo methods table:                                            */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | static PyMethodDef BPy_Ipo_methods[] = { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	/* name, method, flags, doc */ | 
					
						
							| 
									
										
										
										
											2007-02-25 07:36:50 +00:00
										 |  |  | 	{"getName", ( PyCFunction ) GenericLib_getName, METH_NOARGS, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	 "() - Return Ipo Data name"}, | 
					
						
							| 
									
										
										
										
											2007-02-25 07:36:50 +00:00
										 |  |  | 	{"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	 "(str) - Change Ipo Data name"}, | 
					
						
							|  |  |  | 	{"getBlocktype", ( PyCFunction ) Ipo_getBlocktype, METH_NOARGS, | 
					
						
							| 
									
										
										
										
											2005-12-05 05:23:35 +00:00
										 |  |  | 	 "() - Return Ipo blocktype"}, | 
					
						
							| 
									
										
										
										
											2006-04-24 05:24:58 +00:00
										 |  |  | 	{"setBlocktype", ( PyCFunction ) Ipo_oldsetBlocktype, METH_VARARGS, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	 "(str) - Change Ipo blocktype"}, | 
					
						
							|  |  |  | 	{"getRctf", ( PyCFunction ) Ipo_getRctf, METH_NOARGS, | 
					
						
							| 
									
										
										
										
											2005-12-05 05:23:35 +00:00
										 |  |  | 	 "() - Return Ipo rctf"}, | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	{"setRctf", ( PyCFunction ) Ipo_oldsetRctf, METH_VARARGS, | 
					
						
							| 
									
										
										
										
											2005-12-05 05:23:35 +00:00
										 |  |  | 	 "(flt,flt,flt,flt) - Change Ipo rctf"}, | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	{"addCurve", ( PyCFunction ) Ipo_addCurve, METH_O, | 
					
						
							| 
									
										
										
										
											2005-12-05 05:23:35 +00:00
										 |  |  | 	 "() - Add a curve to Ipo"}, | 
					
						
							| 
									
										
										
										
											2005-04-24 19:03:39 +00:00
										 |  |  | 	{"delCurve", ( PyCFunction ) Ipo_delCurve, METH_VARARGS, | 
					
						
							| 
									
										
										
										
											2005-12-05 05:23:35 +00:00
										 |  |  | 	 "(str) - Delete curve from Ipo"}, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	{"getNcurves", ( PyCFunction ) Ipo_getNcurves, METH_NOARGS, | 
					
						
							| 
									
										
										
										
											2005-12-05 05:23:35 +00:00
										 |  |  | 	 "() - Return number of Ipo curves"}, | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	{"getCurves", ( PyCFunction ) Ipo_getCurves, METH_NOARGS, | 
					
						
							|  |  |  | 	 "() - Return list of all defined Ipo curves"}, | 
					
						
							|  |  |  | 	{"getCurve", ( PyCFunction ) Ipo_getCurve, METH_VARARGS, | 
					
						
							|  |  |  | 	 "(str|int) - Returns specified Ipo curve"}, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	{"getNBezPoints", ( PyCFunction ) Ipo_getNBezPoints, METH_VARARGS, | 
					
						
							| 
									
										
										
										
											2005-12-05 05:23:35 +00:00
										 |  |  | 	 "(int) - Return number of Bez points on an Ipo curve"}, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	{"delBezPoint", ( PyCFunction ) Ipo_DeleteBezPoints, METH_VARARGS, | 
					
						
							| 
									
										
										
										
											2005-12-05 05:23:35 +00:00
										 |  |  | 	 "(int) - deprecated: use ipocurve.delBezier()"}, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	{"getCurveBP", ( PyCFunction ) Ipo_getCurveBP, METH_VARARGS, | 
					
						
							| 
									
										
										
										
											2005-12-05 05:23:35 +00:00
										 |  |  | 	 "() - unsupported"}, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	{"EvaluateCurveOn", ( PyCFunction ) Ipo_EvaluateCurveOn, METH_VARARGS, | 
					
						
							| 
									
										
										
										
											2005-12-05 05:23:35 +00:00
										 |  |  | 	 "(int,flt) - deprecated: see ipocurve.evaluate()"}, | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	{"getCurveCurval", ( PyCFunction ) Ipo_getCurvecurval, METH_VARARGS, | 
					
						
							| 
									
										
										
										
											2005-12-05 05:23:35 +00:00
										 |  |  | 	 "(int) - deprecated: see ipocurve.evaluate()"}, | 
					
						
							|  |  |  | 	{"getCurveBeztriple", ( PyCFunction ) Ipo_getCurveBeztriple, METH_VARARGS, | 
					
						
							|  |  |  | 	 "(int,int) - deprecated: see ipocurve.bezierPoints[]"}, | 
					
						
							|  |  |  | 	{"setCurveBeztriple", ( PyCFunction ) Ipo_setCurveBeztriple, METH_VARARGS, | 
					
						
							|  |  |  | 	 "(int,int,list) - set a BezTriple"}, | 
					
						
							| 
									
										
										
										
											2007-03-14 03:01:24 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	{"__copy__", ( PyCFunction ) Ipo_copy, METH_NOARGS, | 
					
						
							|  |  |  | 	 "() - copy the ipo"}, | 
					
						
							|  |  |  | 	{"copy", ( PyCFunction ) Ipo_copy, METH_NOARGS, | 
					
						
							|  |  |  | 	 "() - copy the ipo"}, | 
					
						
							|  |  |  | 	  | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	{NULL, NULL, 0, NULL} | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | /* Python BPy_Ipo attributes get/set structure:                              */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | static PyGetSetDef BPy_Ipo_getseters[] = { | 
					
						
							| 
									
										
										
										
											2007-02-25 07:36:50 +00:00
										 |  |  | 	GENERIC_LIB_GETSETATTR, | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	{"curves", | 
					
						
							|  |  |  | 	 (getter)Ipo_getCurves, (setter)NULL, | 
					
						
							|  |  |  | 	 "Ipo curves", | 
					
						
							|  |  |  | 	 NULL}, | 
					
						
							|  |  |  | 	{"curveConsts", | 
					
						
							|  |  |  | 	 (getter)Ipo_getCurveNames, (setter)NULL, | 
					
						
							|  |  |  | 	 "Ipo curve constants (values depend on Ipo type)", | 
					
						
							|  |  |  | 	 NULL}, | 
					
						
							|  |  |  | 	{"channel", | 
					
						
							|  |  |  | 	 (getter)Ipo_getChannel, (setter)Ipo_setChannel, | 
					
						
							|  |  |  | 	 "Ipo texture channel (world, lamp, material Ipos only)", | 
					
						
							|  |  |  | 	 NULL}, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	{"blocktype", | 
					
						
							|  |  |  | 	 (getter)Ipo_getBlocktype, (setter)NULL, | 
					
						
							|  |  |  | 	 "Ipo block type", | 
					
						
							|  |  |  | 	 NULL}, | 
					
						
							| 
									
										
										
										
											2007-05-25 16:43:25 +00:00
										 |  |  | 	{"rctf", | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	 (getter)Ipo_getRctf, (setter)Ipo_setRctf, | 
					
						
							|  |  |  | 	 "Ipo type", | 
					
						
							|  |  |  | 	 NULL}, | 
					
						
							|  |  |  | 	{NULL,NULL,NULL,NULL,NULL}  /* Sentinel */ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Python Ipo_Type Mapping Methods table:                                    */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | static PyMappingMethods Ipo_as_mapping = { | 
					
						
							|  |  |  | 	( inquiry ) Ipo_length,	/* mp_length        */ | 
					
						
							|  |  |  | 	( binaryfunc ) Ipo_getIpoCurveByName,	/* mp_subscript     */ | 
					
						
							|  |  |  | 	( objobjargproc ) Ipo_setIpoCurveByName,	/* mp_ass_subscript */ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PySequenceMethods Ipo_as_sequence = { | 
					
						
							|  |  |  | 	( inquiry ) 0,	/* sq_length */ | 
					
						
							|  |  |  | 	( binaryfunc ) 0,	/* sq_concat */ | 
					
						
							|  |  |  | 	( intargfunc ) 0,	/* sq_repeat */ | 
					
						
							|  |  |  | 	( intargfunc ) 0,	/* sq_item */ | 
					
						
							|  |  |  | 	( intintargfunc ) 0,	/* sq_slice */ | 
					
						
							|  |  |  | 	( intobjargproc ) 0,	/* sq_ass_item */ | 
					
						
							|  |  |  | 	( intintobjargproc ) 0,	/* sq_ass_slice */ | 
					
						
							|  |  |  | 	( objobjproc ) Ipo_contains,	/* sq_contains */ | 
					
						
							|  |  |  | 	( binaryfunc ) 0,		/* sq_inplace_concat */ | 
					
						
							|  |  |  | 	( intargfunc ) 0,		/* sq_inplace_repeat */ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Python Ipo_Type callback function prototypes:                             */ | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2007-02-23 14:51:20 +00:00
										 |  |  | /*static int IpoPrint (BPy_Ipo *self, FILE *fp, int flags);*/ | 
					
						
							| 
									
										
										
										
											2006-10-06 16:48:28 +00:00
										 |  |  | static int Ipo_compare( BPy_Ipo * a, BPy_Ipo * b ); | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | static PyObject *Ipo_repr( BPy_Ipo * self ); | 
					
						
							|  |  |  | static PyObject *Ipo_getIter( BPy_Ipo * self ); | 
					
						
							|  |  |  | static PyObject *Ipo_nextIter( BPy_Ipo * self ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* #define CURVEATTRS */ /* uncomment to enable curves as Ipo attributes */  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef CURVEATTRS
 | 
					
						
							|  |  |  | static PyGetSetDef BPy_Ipocurve_getseter = { | 
					
						
							|  |  |  | 	"noname", | 
					
						
							|  |  |  | 	 (getter)NULL, (setter)NULL, | 
					
						
							|  |  |  | 	 "Ipo curve name", | 
					
						
							|  |  |  | 	 NULL | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void generate_curveattrs( PyObject* dict, int blocktype ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	typedef char * (*namefunc)(int, ... ); | 
					
						
							|  |  |  | 	namefunc lookup_name; | 
					
						
							|  |  |  | 	int size; | 
					
						
							|  |  |  | 	int *vals = NULL; | 
					
						
							|  |  |  | 	char name[32]; | 
					
						
							|  |  |  | 	PyObject*desc; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	switch ( blocktype ) { | 
					
						
							|  |  |  | 	case ID_OB: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_ob_ei; | 
					
						
							|  |  |  | 		vals = ob_ar; | 
					
						
							|  |  |  | 		size = OB_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_MA: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_mat_ei; | 
					
						
							|  |  |  | 		vals = ma_ar; | 
					
						
							|  |  |  | 		size = MA_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_CA: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_cam_ei; | 
					
						
							|  |  |  | 		vals = cam_ar; | 
					
						
							|  |  |  | 		size = CAM_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_LA: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_la_ei; | 
					
						
							|  |  |  | 		vals = la_ar; | 
					
						
							|  |  |  | 		size = LA_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_TE: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_tex_ei; | 
					
						
							|  |  |  | 		vals = te_ar; | 
					
						
							|  |  |  | 		size = TE_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_WO: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_world_ei; | 
					
						
							|  |  |  | 		vals = wo_ar; | 
					
						
							|  |  |  | 		size = WO_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_PO: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_ac_ei; | 
					
						
							|  |  |  | 		vals = ac_ar; | 
					
						
							|  |  |  | 		size = AC_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_CO: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_co_ei; | 
					
						
							|  |  |  | 		vals = co_ar; | 
					
						
							|  |  |  | 		size = CO_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_CU: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_cu_ei; | 
					
						
							|  |  |  | 		vals = cu_ar; | 
					
						
							|  |  |  | 		size = CU_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_SEQ: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_seq_ei; | 
					
						
							|  |  |  | 		vals = seq_ar; | 
					
						
							|  |  |  | 		size = SEQ_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	desc = PyDescr_NewGetSet( &Ipo_Type, &BPy_Ipocurve_getseter ); | 
					
						
							|  |  |  | 	while( size-- ) { | 
					
						
							|  |  |  | 		strcpy( name, lookup_name( *vals ) );  | 
					
						
							|  |  |  | 		*name = tolower( *name ); | 
					
						
							|  |  |  | 		PyDict_SetItemString( dict, name, desc ); | 
					
						
							|  |  |  | 		++vals; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	Py_DECREF( desc ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static short lookup_curve_name( char *, int , int ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *getattro( PyObject *self, PyObject *value ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	char *name = PyString_AS_STRING( value ); | 
					
						
							|  |  |  | 	Ipo *ipo = ((BPy_Ipo *)self)->ipo; | 
					
						
							|  |  |  | 	int adrcode; | 
					
						
							|  |  |  | 	IpoCurve *icu; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( !strcmp(name, "__class__") ) | 
					
						
							|  |  |  | 		return PyObject_GenericGetAttr( self, value ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( !strcmp(name, "__dict__") ) /* no effect */ | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		PyObject *dict; | 
					
						
							|  |  |  | 		dict = PyDict_Copy( self->ob_type->tp_dict ); | 
					
						
							|  |  |  | 		generate_curveattrs( dict, ipo->blocktype ); | 
					
						
							|  |  |  | 		return dict; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	adrcode = lookup_curve_name( name, ipo->blocktype,  | 
					
						
							|  |  |  | 			((BPy_Ipo *)self)->mtex ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( adrcode != -1 ) { | 
					
						
							|  |  |  | 		for( icu = ipo->curve.first; icu; icu = icu->next ) | 
					
						
							|  |  |  | 			if( icu->adrcode == adrcode ) | 
					
						
							|  |  |  | 				return IpoCurve_CreatePyObject( icu ); | 
					
						
							|  |  |  | 		Py_RETURN_NONE; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return PyObject_GenericGetAttr( self, value ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | /* Python Ipo_Type structure definition:                                     */ | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | PyTypeObject Ipo_Type = { | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	PyObject_HEAD_INIT( NULL )  /* required py macro */ | 
					
						
							|  |  |  | 	0,                          /* ob_size */ | 
					
						
							|  |  |  | 	/*  For printing, in format "<module>.<name>" */ | 
					
						
							|  |  |  | 	"Blender Ipo",              /* char *tp_name; */ | 
					
						
							|  |  |  | 	sizeof( BPy_Ipo ),          /* int tp_basicsize; */ | 
					
						
							|  |  |  | 	0,                          /* tp_itemsize;  For allocation */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Methods to implement standard operations */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-15 01:47:53 +00:00
										 |  |  | 	NULL,						/* destructor tp_dealloc; */ | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	NULL,                       /* printfunc tp_print; */ | 
					
						
							|  |  |  | 	NULL,                       /* getattrfunc tp_getattr; */ | 
					
						
							|  |  |  | 	NULL,                       /* setattrfunc tp_setattr; */ | 
					
						
							| 
									
										
										
										
											2006-11-17 17:50:43 +00:00
										 |  |  | 	( cmpfunc ) Ipo_compare,   /* cmpfunc tp_compare; */ | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	( reprfunc ) Ipo_repr,     /* reprfunc tp_repr; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Method suites for standard classes */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	NULL,                       /* PyNumberMethods *tp_as_number; */ | 
					
						
							|  |  |  | 	&Ipo_as_sequence,           /* PySequenceMethods *tp_as_sequence; */ | 
					
						
							|  |  |  | 	&Ipo_as_mapping, 	        /* PyMappingMethods *tp_as_mapping; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* More standard operations (here for binary compatibility) */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-26 02:10:24 +00:00
										 |  |  | 	( hashfunc ) GenericLib_hash,	/* hashfunc tp_hash; */ | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	NULL,                       /* ternaryfunc tp_call; */ | 
					
						
							|  |  |  | 	NULL,                       /* reprfunc tp_str; */ | 
					
						
							|  |  |  | #ifdef CURVEATTRS
 | 
					
						
							|  |  |  | 	(getattrofunc)getattro, | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | 	NULL,                       /* getattrofunc tp_getattro; */ | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 	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 */ | 
					
						
							|  |  |  | 	( getiterfunc) Ipo_getIter, /* getiterfunc tp_iter; */ | 
					
						
							|  |  |  | 	( iternextfunc ) Ipo_nextIter, /* iternextfunc tp_iternext; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /*** Attribute descriptor and subclassing stuff ***/ | 
					
						
							|  |  |  | 	BPy_Ipo_methods,            /* struct PyMethodDef *tp_methods; */ | 
					
						
							|  |  |  | 	NULL,                       /* struct PyMemberDef *tp_members; */ | 
					
						
							|  |  |  | 	BPy_Ipo_getseters,          /* 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 | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* internal utility routines                                                 */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * Search through list of known Ipocurves for a particular name. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * str: name of curve we are searching for | 
					
						
							|  |  |  |  * blocktype: type of Ipo | 
					
						
							|  |  |  |  * channel: texture channel number, for World/Lamp/Material curves | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * returns the adrcode for the named curve if it exists, -1 otherwise | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* this is needed since getname_ob_ei() is different from the rest */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef char * (*namefunc)(int, ... ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static short lookup_curve_name( char *str, int blocktype, int channel ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	namefunc lookup_name; | 
					
						
							|  |  |  | 	int *adrcodes = NULL; | 
					
						
							|  |  |  | 	int size = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* make sure channel type is ignored when it should be */ | 
					
						
							|  |  |  | 	if( blocktype != ID_WO && blocktype != ID_LA && blocktype != ID_MA ) | 
					
						
							|  |  |  | 		channel = -1; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	switch ( blocktype ) { | 
					
						
							|  |  |  | 	case ID_OB: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_ob_ei; | 
					
						
							|  |  |  | 		adrcodes = ob_ar; | 
					
						
							|  |  |  | 		size = OB_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_MA: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_mat_ei; | 
					
						
							|  |  |  | 		adrcodes = ma_ar; | 
					
						
							|  |  |  | 		size = MA_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_CA: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_cam_ei; | 
					
						
							|  |  |  | 		adrcodes = cam_ar; | 
					
						
							|  |  |  | 		size = CAM_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_LA: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_la_ei; | 
					
						
							|  |  |  | 		adrcodes = la_ar; | 
					
						
							|  |  |  | 		size = LA_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_TE: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_tex_ei; | 
					
						
							|  |  |  | 		adrcodes = te_ar; | 
					
						
							|  |  |  | 		size = TE_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_WO: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_world_ei; | 
					
						
							|  |  |  | 		adrcodes = wo_ar; | 
					
						
							|  |  |  | 		size = WO_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_PO: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_ac_ei; | 
					
						
							|  |  |  | 		adrcodes = ac_ar; | 
					
						
							|  |  |  | 		size = AC_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_CO: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_co_ei; | 
					
						
							|  |  |  | 		adrcodes = co_ar; | 
					
						
							|  |  |  | 		size = CO_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_CU: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_cu_ei; | 
					
						
							|  |  |  | 		adrcodes = cu_ar; | 
					
						
							|  |  |  | 		size = CU_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_SEQ: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_seq_ei; | 
					
						
							|  |  |  | 		adrcodes = seq_ar; | 
					
						
							|  |  |  | 		size = SEQ_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_KE:	/* shouldn't happen */ | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 		return -1; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	while ( size-- ) { | 
					
						
							|  |  |  | 		char *name = lookup_name ( *adrcodes ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* if not a texture channel, just return the adrcode */ | 
					
						
							| 
									
										
										
										
											2006-07-02 21:37:06 +00:00
										 |  |  | 		if( !strcmp( str, name ) ) { | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 			if( channel == -1 || *adrcodes < MA_MAP1 ) | 
					
						
							|  |  |  | 				return (short)*adrcodes; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* otherwise adjust adrcode to include current channel */ | 
					
						
							|  |  |  | 			else { | 
					
						
							|  |  |  | 				int param = (short)*adrcodes & ~MA_MAP1; | 
					
						
							|  |  |  | 				param |= texchannel_to_adrcode( channel ); | 
					
						
							| 
									
										
										
										
											2006-04-24 15:09:07 +00:00
										 |  |  | 				return (short)param; | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		++adrcodes; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return -1; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static short lookup_curve_key( char *str, Ipo *ipo ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Key *keyiter; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* find the ipo in the keylist */ | 
					
						
							|  |  |  | 	for( keyiter = G.main->key.first; keyiter; keyiter = keyiter->id.next ) { | 
					
						
							|  |  |  | 		if( keyiter->ipo == ipo ) { | 
					
						
							|  |  |  | 			KeyBlock *block = keyiter->block.first; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			/* look for a matching string, get the adrcode */ | 
					
						
							|  |  |  | 			for( block = keyiter->block.first; block; block = block->next ) | 
					
						
							| 
									
										
										
										
											2006-07-02 21:37:06 +00:00
										 |  |  | 				if( !strcmp( str, block->name ) ) | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 					return block->adrcode; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			/* no match; no addr code */ | 
					
						
							|  |  |  | 			return -1; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* error if the ipo isn't in the list */ | 
					
						
							|  |  |  | 	return -2; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * Search through list of known Ipocurves for a particular adrcode. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * code: adrcode of curve we are searching for | 
					
						
							|  |  |  |  * blocktype: type of Ipo | 
					
						
							|  |  |  |  * channel: texture channel number, for World/Lamp/Material curves | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * returns the adrcode for the named curve if it exists, -1 otherwise | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static short lookup_curve_adrcode( int code, int blocktype, int channel ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int *adrcodes = NULL; | 
					
						
							|  |  |  | 	int size = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	switch ( blocktype ) { | 
					
						
							|  |  |  | 	case ID_OB: | 
					
						
							|  |  |  | 		adrcodes = ob_ar; | 
					
						
							|  |  |  | 		size = OB_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_MA: | 
					
						
							|  |  |  | 		adrcodes = ma_ar; | 
					
						
							|  |  |  | 		size = MA_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_CA: | 
					
						
							|  |  |  | 		adrcodes = cam_ar; | 
					
						
							|  |  |  | 		size = CAM_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_LA: | 
					
						
							|  |  |  | 		adrcodes = la_ar; | 
					
						
							|  |  |  | 		size = LA_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_TE: | 
					
						
							|  |  |  | 		adrcodes = te_ar; | 
					
						
							|  |  |  | 		size = TE_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_WO: | 
					
						
							|  |  |  | 		adrcodes = wo_ar; | 
					
						
							|  |  |  | 		size = WO_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_PO: | 
					
						
							|  |  |  | 		adrcodes = ac_ar; | 
					
						
							|  |  |  | 		size = AC_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_CO: | 
					
						
							|  |  |  | 		adrcodes = co_ar; | 
					
						
							|  |  |  | 		size = CO_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_CU: | 
					
						
							|  |  |  | 		adrcodes = cu_ar; | 
					
						
							|  |  |  | 		size = CU_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_SEQ: | 
					
						
							|  |  |  | 		adrcodes = seq_ar; | 
					
						
							|  |  |  | 		size = SEQ_TOTIPO; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_KE: | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 		return -1; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	while ( size-- ) { | 
					
						
							|  |  |  | 		if( *adrcodes == code ) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* if not a texture channel, just return the adrcode */ | 
					
						
							|  |  |  | 			if( channel == -1 || *adrcodes < MA_MAP1 ) | 
					
						
							| 
									
										
										
										
											2006-04-24 15:09:07 +00:00
										 |  |  | 				return (short)*adrcodes; | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		/* otherwise adjust adrcode to include current channel */ | 
					
						
							|  |  |  | 			else { | 
					
						
							|  |  |  | 				int param = *adrcodes & ~MA_MAP1; | 
					
						
							|  |  |  | 				param |= texchannel_to_adrcode( channel ); | 
					
						
							| 
									
										
										
										
											2006-04-24 15:09:07 +00:00
										 |  |  | 				return (short)param; | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		++adrcodes; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return -1; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * Delete an IpoCurve from an Ipo | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void del_ipocurve( Ipo * ipo, IpoCurve * icu ) { | 
					
						
							|  |  |  | 	BLI_remlink( &( ipo->curve ), icu ); | 
					
						
							|  |  |  | 	if( icu->bezt ) | 
					
						
							|  |  |  | 		MEM_freeN( icu->bezt ); | 
					
						
							|  |  |  | 	if( icu->driver ) | 
					
						
							|  |  |  | 		MEM_freeN( icu->driver ); | 
					
						
							|  |  |  | 	MEM_freeN( icu ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* have to do this to avoid crashes in the IPO window */ | 
					
						
							|  |  |  | 	allspace( REMAKEIPO, 0 ); | 
					
						
							|  |  |  | 	EXPP_allqueue( REDRAWIPO, 0 ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Python BPy_Ipo functions:                                                 */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Function:              M_Ipo_New                                          */ | 
					
						
							|  |  |  | /* Python equivalent:     Blender.Ipo.New                                    */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | static PyObject *M_Ipo_New( PyObject * self_unused, PyObject * args ) | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	char *name = NULL, *code = NULL; | 
					
						
							|  |  |  | 	int idcode = -1; | 
					
						
							|  |  |  | 	Ipo *blipo; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( !PyArg_ParseTuple( args, "ss", &code, &name ) ) | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 		return EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 				"expected two string arguments" ); | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if( !strcmp( code, "Object" ) ) | 
					
						
							|  |  |  | 		idcode = ID_OB; | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	else if( !strcmp( code, "Camera" ) ) | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 		idcode = ID_CA; | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	else if( !strcmp( code, "World" ) ) | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 		idcode = ID_WO; | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	else if( !strcmp( code, "Material" ) ) | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 		idcode = ID_MA; | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	else if( !strcmp( code, "Texture" ) ) | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 		idcode = ID_TE; | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	else if( !strcmp( code, "Lamp" ) ) | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 		idcode = ID_LA; | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	else if( !strcmp( code, "Action" ) ) | 
					
						
							| 
									
										
										
										
											2005-10-10 18:05:30 +00:00
										 |  |  | 		idcode = ID_PO; | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	else if( !strcmp( code, "Constraint" ) ) | 
					
						
							| 
									
										
										
										
											2005-10-10 18:05:30 +00:00
										 |  |  | 		idcode = ID_CO; | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	else if( !strcmp( code, "Sequence" ) ) | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 		idcode = ID_SEQ; | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	else if( !strcmp( code, "Curve" ) ) | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 		idcode = ID_CU; | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	else if( !strcmp( code, "Key" ) ) | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 		idcode = ID_KE; | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	else return EXPP_ReturnPyObjError( PyExc_ValueError, | 
					
						
							|  |  |  | 			"unknown Ipo code" ); | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	blipo = add_ipo( name, idcode ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( blipo ) { | 
					
						
							|  |  |  | 		/* return user count to zero because add_ipo() inc'd it */ | 
					
						
							|  |  |  | 		blipo->id.us = 0; | 
					
						
							|  |  |  | 		/* create python wrapper obj */ | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 		return Ipo_CreatePyObject( blipo ); | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	} else | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 		return EXPP_ReturnPyObjError( PyExc_RuntimeError, | 
					
						
							|  |  |  | 				"couldn't create Ipo Data in Blender" ); | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Function:              M_Ipo_Get                                       */ | 
					
						
							|  |  |  | /* Python equivalent:     Blender.Ipo.Get                                 */ | 
					
						
							|  |  |  | /* Description:           Receives a string and returns the ipo data obj  */ | 
					
						
							|  |  |  | /*                        whose name matches the string.  If no argument is  */ | 
					
						
							|  |  |  | /*                        passed in, a list of all ipo data names in the  */ | 
					
						
							|  |  |  | /*                        current scene is returned.                         */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | static PyObject *M_Ipo_Get( PyObject * self_unused, PyObject * args ) | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	char *name = NULL; | 
					
						
							|  |  |  | 	Ipo *ipo_iter; | 
					
						
							|  |  |  | 	PyObject *ipolist, *pyobj; | 
					
						
							|  |  |  | 	char error_msg[64]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( !PyArg_ParseTuple( args, "|s", &name ) ) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 						"expected string argument (or nothing)" ) ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ipo_iter = G.main->ipo.first; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( name ) {		/* (name) - Search ipo by name */ | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 		while( ipo_iter ) { | 
					
						
							|  |  |  | 			if( !strcmp( name, ipo_iter->id.name + 2 ) ) { | 
					
						
							|  |  |  | 				return Ipo_CreatePyObject( ipo_iter ); | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			ipo_iter = ipo_iter->id.next; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 		PyOS_snprintf( error_msg, sizeof( error_msg ), | 
					
						
							|  |  |  | 				   "Ipo \"%s\" not found", name ); | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_NameError, error_msg ); | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	else {			/* () - return a list with all ipos in the scene */ | 
					
						
							|  |  |  | 		int index = 0; | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 		ipolist = PyList_New( BLI_countlist( &( G.main->ipo ) ) ); | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 		if( !ipolist ) | 
					
						
							|  |  |  | 			return EXPP_ReturnPyObjError( PyExc_MemoryError, | 
					
						
							|  |  |  | 					"couldn't create PyList" ); | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 		while( ipo_iter ) { | 
					
						
							|  |  |  | 			pyobj = Ipo_CreatePyObject( ipo_iter ); | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 			if( !pyobj ) | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 				return NULL; | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 			PyList_SET_ITEM( ipolist, index, pyobj ); | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 			ipo_iter = ipo_iter->id.next; | 
					
						
							|  |  |  | 			index++; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 		return ipolist; | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * This should probably be deprecated too?  Or else documented in epydocs. | 
					
						
							|  |  |  |  * Seems very similar to Ipocurve.recalc(). | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2003-07-19 08:32:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Function:              M_Ipo_Recalc                                       */ | 
					
						
							|  |  |  | /* Python equivalent:     Blender.Ipo.Recalc                                 */ | 
					
						
							|  |  |  | /* Description:           Receives (presumably) an IpoCurve object and       */ | 
					
						
							|  |  |  | /*                        updates the curve after changes to control points. */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | static PyObject *M_Ipo_Recalc( PyObject * self_unused, PyObject * value ) | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	if( !BPy_IpoCurve_Check(value) ) | 
					
						
							| 
									
										
										
										
											2005-12-05 05:23:35 +00:00
										 |  |  | 		return EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 				"expected Ipo curve argument" ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	testhandles_ipocurve( IpoCurve_FromPyObject( value ) ); | 
					
						
							| 
									
										
										
										
											2003-07-19 08:32:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2003-07-19 08:32:01 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | /* Python BPy_Ipo methods:                                                   */ | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Ipo_getBlocktype( BPy_Ipo * self ) | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2007-06-29 08:59:26 +00:00
										 |  |  | 	return PyInt_FromLong( self->ipo->blocktype ); | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-24 05:24:58 +00:00
										 |  |  | static int Ipo_setBlocktype( BPy_Ipo * self, PyObject * args ) | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2007-07-01 05:41:23 +00:00
										 |  |  | 	if( !PyInt_Check( args ) ) | 
					
						
							| 
									
										
										
										
											2006-04-24 05:24:58 +00:00
										 |  |  | 		return EXPP_ReturnIntError( PyExc_TypeError, | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 				"expected int argument" ); | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-24 05:24:58 +00:00
										 |  |  | 	self->ipo->blocktype = (short)PyInt_AS_LONG( args ); | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-24 05:24:58 +00:00
										 |  |  | 	return 0; | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Ipo_getRctf( BPy_Ipo * self ) | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2007-05-25 16:43:25 +00:00
										 |  |  | 	PyObject *l = PyList_New( 4 ); | 
					
						
							|  |  |  | 	PyList_SET_ITEM( l, 0, PyFloat_FromDouble( self->ipo->cur.xmin ) ); | 
					
						
							|  |  |  | 	PyList_SET_ITEM( l, 1, PyFloat_FromDouble( self->ipo->cur.xmax ) ); | 
					
						
							|  |  |  | 	PyList_SET_ITEM( l, 2, PyFloat_FromDouble( self->ipo->cur.ymin ) ); | 
					
						
							|  |  |  | 	PyList_SET_ITEM( l, 3, PyFloat_FromDouble( self->ipo->cur.ymax ) ); | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	return l; | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | static int Ipo_setRctf( BPy_Ipo * self, PyObject * args ) | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	float v[4]; | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( !PyArg_ParseTuple( args, "ffff", v, v + 1, v + 2, v + 3 ) ) | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 		return EXPP_ReturnIntError( PyExc_TypeError, | 
					
						
							|  |  |  | 				"expected a tuple of 4 floats" ); | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	self->ipo->cur.xmin = v[0]; | 
					
						
							|  |  |  | 	self->ipo->cur.xmax = v[1]; | 
					
						
							|  |  |  | 	self->ipo->cur.ymin = v[2]; | 
					
						
							|  |  |  | 	self->ipo->cur.ymax = v[3]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	return 0; | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Get total number of Ipo curves for this Ipo.  NOTE:  this function | 
					
						
							|  |  |  |  * returns all curves for Ipos which have texture channels, unlike | 
					
						
							|  |  |  |  * Ipo_length(). | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Ipo_getNcurves( BPy_Ipo * self ) | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	IpoCurve *icu; | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	int i = 0; | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	for( icu = self->ipo->curve.first; icu; icu = icu->next ) { | 
					
						
							|  |  |  | 		i++; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	return PyInt_FromLong( (long)i ); | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-05-20 12:16:54 +00:00
										 |  |  | /* 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  |    Function:  Ipo_addCurve | 
					
						
							|  |  |  |    Bpy:       Blender.Ipo.addCurve( 'curname') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    add a new curve to an existing IPO. | 
					
						
							|  |  |  |    example: | 
					
						
							|  |  |  |    ipo = Blender.Ipo.New('Object','ObIpo') | 
					
						
							|  |  |  |    cu = ipo.addCurve('LocX') | 
					
						
							| 
									
										
										
										
											2005-05-20 12:16:54 +00:00
										 |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | static PyObject *Ipo_addCurve( BPy_Ipo * self, PyObject * value ) | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	short param;		/* numeric curve name constant */ | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	char *cur_name = PyString_AsString(value);	/* input arg: curve name */ | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	Ipo *ipo = 0; | 
					
						
							|  |  |  | 	IpoCurve *icu = 0; | 
					
						
							|  |  |  | 	Link *link; | 
					
						
							| 
									
										
										
										
											2005-05-20 12:16:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	if( !cur_name ) | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 		return ( EXPP_ReturnPyObjError | 
					
						
							|  |  |  | 			 ( PyExc_TypeError, "expected string argument" ) ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* chase down the ipo list looking for ours */ | 
					
						
							|  |  |  | 	link = G.main->ipo.first; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	while( link ) { | 
					
						
							|  |  |  | 		ipo = ( Ipo * ) link; | 
					
						
							|  |  |  | 		if( ipo == self->ipo ) | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		link = link->next; | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2005-05-20 12:16:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	if( !link ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError | 
					
						
							|  |  |  | 				( PyExc_RuntimeError, "Ipo not found" ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/*
 | 
					
						
							|  |  |  | 	 * Check if the input arg curve name is valid depending on the block | 
					
						
							|  |  |  | 	 * type, and set param to numeric value.  Invalid names will return | 
					
						
							|  |  |  | 	 * param = -1. | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-06-28 17:13:39 +00:00
										 |  |  | 	if( ipo->blocktype != ID_KE ) { | 
					
						
							|  |  |  | 		param = lookup_curve_name( cur_name, ipo->blocktype, self->mtex ); | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		param = lookup_curve_key( cur_name, ipo ); | 
					
						
							|  |  |  | 		if( param == -2 ) | 
					
						
							|  |  |  | 			return EXPP_ReturnPyObjError( PyExc_RuntimeError,  | 
					
						
							|  |  |  | 					"unable to find matching key data for Ipo" ); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if( param == -1 ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_NameError, | 
					
						
							|  |  |  | 				"curve name is not valid" ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* see if the curve already exists */ | 
					
						
							|  |  |  | 	for( icu = ipo->curve.first; icu; icu = icu->next ) | 
					
						
							|  |  |  | 		if( icu->adrcode == param ) | 
					
						
							|  |  |  | 			return EXPP_ReturnPyObjError( PyExc_ValueError, | 
					
						
							|  |  |  | 					"Ipo curve already exists" ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* create the new ipo curve */ | 
					
						
							|  |  |  | 	icu = MEM_callocN( sizeof(IpoCurve), "Python added ipocurve"); | 
					
						
							|  |  |  | 	icu->blocktype = ipo->blocktype; | 
					
						
							|  |  |  | 	icu->adrcode = param; | 
					
						
							|  |  |  | 	icu->flag |= IPO_VISIBLE|IPO_AUTO_HORIZ; | 
					
						
							|  |  |  | 	set_icu_vars( icu ); | 
					
						
							|  |  |  | 	BLI_addtail( &(ipo->curve), icu); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	allspace( REMAKEIPO, 0 ); | 
					
						
							|  |  |  | 	EXPP_allqueue( REDRAWIPO, 0 ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* create a bpy wrapper for the new ipo curve */ | 
					
						
							|  |  |  | 	return IpoCurve_CreatePyObject( icu ); | 
					
						
							| 
									
										
										
										
											2004-07-26 21:44:55 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | /* 
 | 
					
						
							|  |  |  |    Function:  Ipo_delCurve | 
					
						
							|  |  |  |    Bpy:       Blender.Ipo.delCurve(curtype) | 
					
						
							| 
									
										
										
										
											2005-05-20 12:16:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  |    delete an existing curve from IPO. | 
					
						
							|  |  |  |    example: | 
					
						
							|  |  |  |        ipo = Blender.Ipo.New('Object','ObIpo') | 
					
						
							|  |  |  |        cu = ipo.delCurve('LocX') | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2005-05-20 12:16:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | static PyObject *Ipo_delCurve( BPy_Ipo * self, PyObject * value ) | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	IpoCurve *icu; | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	char *strname = PyString_AsString(value); | 
					
						
							| 
									
										
										
										
											2005-05-20 12:16:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	if( !strname ) | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 		return EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 				"expected string argument" ); | 
					
						
							| 
									
										
										
										
											2005-05-20 12:16:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	for( icu = self->ipo->curve.first; icu; icu = icu->next ) { | 
					
						
							|  |  |  | 		if( !strcmp( strname, getIpoCurveName( icu ) ) ) { | 
					
						
							|  |  |  | 			del_ipocurve( self->ipo, icu ); | 
					
						
							|  |  |  |     		Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2005-05-20 12:16:54 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2005-05-20 12:16:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	return EXPP_ReturnPyObjError( PyExc_ValueError, "IpoCurve not found" ); | 
					
						
							| 
									
										
										
										
											2004-07-26 21:44:55 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | static PyObject *Ipo_getCurve( BPy_Ipo * self, PyObject * args ) | 
					
						
							| 
									
										
										
										
											2004-07-26 21:44:55 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  |     IpoCurve *icu = NULL; | 
					
						
							|  |  |  |     short adrcode; | 
					
						
							|  |  |  |     PyObject *value = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if( !PyArg_ParseTuple( args, "|O", &value ) ) | 
					
						
							|  |  |  | 		goto typeError; | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  |     /* if no name give, get all the Ipocurves */ | 
					
						
							|  |  |  | 	if( !value ) | 
					
						
							|  |  |  | 		return Ipo_getCurves( self ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* if arg is a string or int, look up the adrcode */ | 
					
						
							|  |  |  |     if( PyString_Check( value ) ) { | 
					
						
							|  |  |  | 		char *str = PyString_AsString( value ); | 
					
						
							|  |  |  |         for( icu = self->ipo->curve.first; icu; icu = icu->next ) { | 
					
						
							|  |  |  |             if( !strcmp( str, getIpoCurveName( icu ) ) ) | 
					
						
							|  |  |  |                 return IpoCurve_CreatePyObject( icu ); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     	Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  |     else if( PyInt_Check( value ) ) { | 
					
						
							|  |  |  |         adrcode = ( short )PyInt_AsLong( value ); | 
					
						
							|  |  |  |         for( icu = self->ipo->curve.first; icu; icu = icu->next ) { | 
					
						
							|  |  |  |             if( icu->adrcode == adrcode ) | 
					
						
							|  |  |  |                  return IpoCurve_CreatePyObject( icu ); | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  |     	Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | typeError: | 
					
						
							|  |  |  | 	return EXPP_ReturnPyObjError(PyExc_TypeError, | 
					
						
							|  |  |  | 			"expected string or int argument" ); | 
					
						
							|  |  |  | }  | 
					
						
							| 
									
										
										
										
											2004-07-26 21:44:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | static PyObject *Ipo_getCurves( BPy_Ipo * self ) | 
					
						
							| 
									
										
										
										
											2004-07-26 21:44:55 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2007-05-25 16:43:25 +00:00
										 |  |  | 	PyObject *attr = PyList_New( 0 ), *pyipo; | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	IpoCurve *icu; | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-05-25 16:43:25 +00:00
										 |  |  | 	for( icu = self->ipo->curve.first; icu; icu = icu->next ) { | 
					
						
							|  |  |  | 		pyipo = IpoCurve_CreatePyObject( icu ); | 
					
						
							|  |  |  | 		PyList_Append( attr, pyipo ); | 
					
						
							|  |  |  | 		Py_DECREF(pyipo); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	return attr; | 
					
						
							| 
									
										
										
										
											2004-07-26 21:44:55 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * return a list of valid curve name constants for the Ipo | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Ipo_getCurveNames( BPy_Ipo * self ) | 
					
						
							| 
									
										
										
										
											2004-07-26 21:44:55 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	namefunc lookup_name; | 
					
						
							|  |  |  | 	int size; | 
					
						
							|  |  |  | 	PyObject *dict; | 
					
						
							|  |  |  | 	int *vals = NULL; | 
					
						
							|  |  |  | 	char name[32]; | 
					
						
							| 
									
										
										
										
											2006-04-24 15:09:07 +00:00
										 |  |  | 	PyObject *attr = Py_None; | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	/* determine what type of Ipo we are */ | 
					
						
							| 
									
										
										
										
											2004-07-26 21:44:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	switch ( self->ipo->blocktype ) { | 
					
						
							|  |  |  | 	case ID_OB: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_ob_ei; | 
					
						
							|  |  |  | 		vals = ob_ar; | 
					
						
							|  |  |  | 		size = OB_TOTIPO; | 
					
						
							|  |  |  | 		strcpy( name, "OB_" ); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_MA: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_mat_ei; | 
					
						
							|  |  |  | 		vals = ma_ar; | 
					
						
							|  |  |  | 		size = MA_TOTIPO; | 
					
						
							|  |  |  | 		strcpy( name, "MA_" ); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_CA: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_cam_ei; | 
					
						
							|  |  |  | 		vals = cam_ar; | 
					
						
							|  |  |  | 		size = CAM_TOTIPO; | 
					
						
							|  |  |  | 		strcpy( name, "CA_" ); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_LA: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_la_ei; | 
					
						
							|  |  |  | 		vals = la_ar; | 
					
						
							|  |  |  | 		size = LA_TOTIPO; | 
					
						
							|  |  |  | 		strcpy( name, "LA_" ); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_TE: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_tex_ei; | 
					
						
							|  |  |  | 		vals = te_ar; | 
					
						
							|  |  |  | 		size = TE_TOTIPO; | 
					
						
							|  |  |  | 		strcpy( name, "TE_" ); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_WO: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_world_ei; | 
					
						
							|  |  |  | 		vals = wo_ar; | 
					
						
							|  |  |  | 		size = WO_TOTIPO; | 
					
						
							|  |  |  | 		strcpy( name, "WO_" ); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_PO: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_ac_ei; | 
					
						
							|  |  |  | 		vals = ac_ar; | 
					
						
							|  |  |  | 		size = AC_TOTIPO; | 
					
						
							|  |  |  | 		strcpy( name, "PO_" ); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_CO: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_co_ei; | 
					
						
							|  |  |  | 		vals = co_ar; | 
					
						
							|  |  |  | 		size = CO_TOTIPO; | 
					
						
							|  |  |  | 		strcpy( name, "CO_" ); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_CU: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_cu_ei; | 
					
						
							|  |  |  | 		vals = cu_ar; | 
					
						
							|  |  |  | 		size = CU_TOTIPO; | 
					
						
							|  |  |  | 		strcpy( name, "CU_" ); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_SEQ: | 
					
						
							|  |  |  | 		lookup_name = (namefunc)getname_seq_ei; | 
					
						
							|  |  |  | 		vals = seq_ar; | 
					
						
							|  |  |  | 		size = SEQ_TOTIPO; | 
					
						
							|  |  |  | 		strcpy( name, "SQ_" ); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case ID_KE: | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			Key *key; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			/* find the ipo in the keylist */ | 
					
						
							|  |  |  | 			for( key = G.main->key.first; key; key = key->id.next ) { | 
					
						
							|  |  |  | 				if( key->ipo == self->ipo ) { | 
					
						
							| 
									
										
										
										
											2007-05-25 16:43:25 +00:00
										 |  |  | 					PyObject *tmpstr; | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 					KeyBlock *block = key->block.first; | 
					
						
							|  |  |  | 					attr = PyList_New( 0 ); | 
					
						
							| 
									
										
										
										
											2007-05-25 16:43:25 +00:00
										 |  |  | 					 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 					/* add each name to the list */ | 
					
						
							| 
									
										
										
										
											2007-05-25 16:43:25 +00:00
										 |  |  | 					for( block = key->block.first; block; block = block->next ) { | 
					
						
							|  |  |  | 						tmpstr = PyString_FromString( block->name ); | 
					
						
							|  |  |  | 						PyList_Append( attr, tmpstr); | 
					
						
							|  |  |  | 						Py_DECREF(tmpstr); | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 					return attr; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			/* error if the ipo isn't in the list */ | 
					
						
							|  |  |  |         	return EXPP_ReturnPyObjError( PyExc_RuntimeError,  | 
					
						
							|  |  |  | 					"unable to find matching key data for Ipo" ); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 		Py_DECREF( attr ); | 
					
						
							|  |  |  |         return EXPP_ReturnPyObjError( PyExc_RuntimeError,  | 
					
						
							|  |  |  | 			   				"unknown Ipo type" ); | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	/*
 | 
					
						
							|  |  |  | 	 * go through the list of adrcodes to find names, then add to dictionary | 
					
						
							|  |  |  | 	 * with string as key and adrcode as value | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2004-07-26 21:44:55 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	dict = PyModule_GetDict( submodule ); | 
					
						
							|  |  |  | 	attr = PyConstant_New(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	while( size-- ) { | 
					
						
							|  |  |  | 		char *ptr = name+3; | 
					
						
							|  |  |  | 		strcpy( name+3, lookup_name( *vals ) );  | 
					
						
							|  |  |  | 		while( *ptr ) { | 
					
						
							| 
									
										
										
										
											2006-04-24 15:09:07 +00:00
										 |  |  | 			*ptr = (char)toupper( *ptr ); | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 			++ptr; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		PyConstant_Insert( (BPy_constant *)attr, name,  | 
					
						
							|  |  |  | 				PyInt_FromLong( *vals ) ); | 
					
						
							|  |  |  | 		++vals; | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	return attr; | 
					
						
							| 
									
										
										
										
											2004-07-26 21:44:55 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | void generate_curveconsts( PyObject* module ) | 
					
						
							| 
									
										
										
										
											2004-07-26 21:44:55 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2006-04-24 15:09:07 +00:00
										 |  |  | 	namefunc lookup_name = NULL; | 
					
						
							|  |  |  | 	int size = 0; | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	int *vals = NULL; | 
					
						
							|  |  |  | 	char name[32]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	unsigned int i = 0; | 
					
						
							|  |  |  | 	static short curvelist[] = { | 
					
						
							|  |  |  | 		ID_OB, ID_MA, ID_CA, ID_LA, ID_TE, ID_WO, ID_PO, ID_CO, ID_CU, ID_SEQ | 
					
						
							|  |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2005-05-20 12:16:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	for( i = 0; i < sizeof(curvelist)/sizeof(short); ++i ) { | 
					
						
							|  |  |  | 		switch ( curvelist[i] ) { | 
					
						
							|  |  |  | 		case ID_OB: | 
					
						
							|  |  |  | 			lookup_name = (namefunc)getname_ob_ei; | 
					
						
							|  |  |  | 			vals = ob_ar; | 
					
						
							|  |  |  | 			size = OB_TOTIPO; | 
					
						
							|  |  |  | 			strcpy( name, "OB_" ); | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case ID_MA: | 
					
						
							|  |  |  | 			lookup_name = (namefunc)getname_mat_ei; | 
					
						
							|  |  |  | 			vals = ma_ar; | 
					
						
							|  |  |  | 			size = MA_TOTIPO; | 
					
						
							|  |  |  | 			strcpy( name, "MA_" ); | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case ID_CA: | 
					
						
							|  |  |  | 			lookup_name = (namefunc)getname_cam_ei; | 
					
						
							|  |  |  | 			vals = cam_ar; | 
					
						
							|  |  |  | 			size = CAM_TOTIPO; | 
					
						
							|  |  |  | 			strcpy( name, "CA_" ); | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case ID_LA: | 
					
						
							|  |  |  | 			lookup_name = (namefunc)getname_la_ei; | 
					
						
							|  |  |  | 			vals = la_ar; | 
					
						
							|  |  |  | 			size = LA_TOTIPO; | 
					
						
							|  |  |  | 			strcpy( name, "LA_" ); | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case ID_TE: | 
					
						
							|  |  |  | 			lookup_name = (namefunc)getname_tex_ei; | 
					
						
							|  |  |  | 			vals = te_ar; | 
					
						
							|  |  |  | 			size = TE_TOTIPO; | 
					
						
							|  |  |  | 			strcpy( name, "TE_" ); | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case ID_WO: | 
					
						
							|  |  |  | 			lookup_name = (namefunc)getname_world_ei; | 
					
						
							|  |  |  | 			vals = wo_ar; | 
					
						
							|  |  |  | 			size = WO_TOTIPO; | 
					
						
							|  |  |  | 			strcpy( name, "WO_" ); | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case ID_PO: | 
					
						
							|  |  |  | 			lookup_name = (namefunc)getname_ac_ei; | 
					
						
							|  |  |  | 			vals = ac_ar; | 
					
						
							|  |  |  | 			size = AC_TOTIPO; | 
					
						
							|  |  |  | 			strcpy( name, "PO_" ); | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case ID_CO: | 
					
						
							|  |  |  | 			lookup_name = (namefunc)getname_co_ei; | 
					
						
							|  |  |  | 			vals = co_ar; | 
					
						
							|  |  |  | 			size = CO_TOTIPO; | 
					
						
							|  |  |  | 			strcpy( name, "CO_" ); | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case ID_CU: | 
					
						
							|  |  |  | 			lookup_name = (namefunc)getname_cu_ei; | 
					
						
							|  |  |  | 			vals = cu_ar; | 
					
						
							|  |  |  | 			size = CU_TOTIPO; | 
					
						
							|  |  |  | 			strcpy( name, "CU_" ); | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case ID_SEQ: | 
					
						
							|  |  |  | 			lookup_name = (namefunc)getname_seq_ei; | 
					
						
							|  |  |  | 			vals = seq_ar; | 
					
						
							|  |  |  | 			size = SEQ_TOTIPO; | 
					
						
							|  |  |  | 			strcpy( name, "SQ_" ); | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2005-05-20 12:16:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 		while( size-- ) { | 
					
						
							|  |  |  | 			char *ptr = name+3; | 
					
						
							|  |  |  | 			strcpy( name+3, lookup_name( *vals ) );  | 
					
						
							|  |  |  | 			while( *ptr ) { | 
					
						
							| 
									
										
										
										
											2006-04-24 15:09:07 +00:00
										 |  |  | 				*ptr = (char)toupper( *ptr ); | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 				++ptr; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			PyModule_AddIntConstant( module, name, *vals ); | 
					
						
							|  |  |  | 			++vals; | 
					
						
							| 
									
										
										
										
											2005-05-20 12:16:54 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2004-07-26 21:44:55 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-05-24 15:14:32 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  |  * get the current texture channel number, if defined | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2005-05-24 15:14:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | static PyObject *Ipo_getChannel( BPy_Ipo * self ) | 
					
						
							| 
									
										
										
										
											2004-07-26 21:44:55 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	if( self->mtex != -1 ) | 
					
						
							| 
									
										
										
										
											2007-05-26 04:39:31 +00:00
										 |  |  | 		return PyInt_FromLong( (long)self->mtex ); | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	Py_RETURN_NONE; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2005-05-24 15:14:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * set the current texture channel number, if defined | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | static int Ipo_setChannel( BPy_Ipo * self, PyObject * value ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if( self->mtex != -1 ) | 
					
						
							|  |  |  | 		return EXPP_setIValueRange( value, &self->mtex, 0, 9, 'h' ); | 
					
						
							|  |  |  | 	return 0; | 
					
						
							| 
									
										
										
										
											2004-07-26 21:44:55 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-10-06 16:48:28 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Function:    Ipo_compare			                                         */ | 
					
						
							|  |  |  | /* Description: This compares 2 ipo python types, == or != only.             */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | static int Ipo_compare( BPy_Ipo * a, BPy_Ipo * b ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return ( a->ipo == b->ipo ) ? 0 : -1; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Function:    Ipo_repr                                                     */ | 
					
						
							|  |  |  | /* Description: This is a callback function for the BPy_Ipo type. It         */ | 
					
						
							|  |  |  | /*              builds a meaningful string to represent ipo objects.         */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | static PyObject *Ipo_repr( BPy_Ipo * self ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	char *param; | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	switch ( self->ipo->blocktype ) { | 
					
						
							|  |  |  | 	case ID_OB: | 
					
						
							|  |  |  | 		param = "Object"; break; | 
					
						
							|  |  |  | 	case ID_CA: | 
					
						
							|  |  |  | 		param = "Camera"; break; | 
					
						
							|  |  |  | 	case ID_LA: | 
					
						
							|  |  |  | 		param = "Lamp"; break; | 
					
						
							|  |  |  | 	case ID_TE: | 
					
						
							|  |  |  | 		param = "Texture"; break; | 
					
						
							|  |  |  | 	case ID_WO: | 
					
						
							|  |  |  | 		param = "World"; break; | 
					
						
							|  |  |  | 	case ID_MA: | 
					
						
							|  |  |  | 		param = "Material"; break; | 
					
						
							|  |  |  | 	case ID_PO: | 
					
						
							|  |  |  | 		param = "Action"; break; | 
					
						
							|  |  |  | 	case ID_CO: | 
					
						
							|  |  |  | 		param = "Constriant"; break; | 
					
						
							|  |  |  | 	case ID_CU: | 
					
						
							|  |  |  | 		param = "Curve"; break; | 
					
						
							|  |  |  | 	case ID_SEQ: | 
					
						
							|  |  |  | 		param = "Sequence"; break; | 
					
						
							|  |  |  | 	case ID_KE: | 
					
						
							|  |  |  | 		param = "Key"; break; | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  |         return EXPP_ReturnPyObjError( PyExc_RuntimeError,  | 
					
						
							|  |  |  | 			   				"unknown Ipo type" ); | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	return PyString_FromFormat( "[Ipo \"%s\" (%s)]", self->ipo->id.name + 2, | 
					
						
							|  |  |  | 				    param ); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | /* Three Python Ipo_Type helper functions needed by the Object module: */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Function:    Ipo_CreatePyObject                                           */ | 
					
						
							|  |  |  | /* Description: This function will create a new BPy_Ipo from an existing     */ | 
					
						
							|  |  |  | /*              Blender ipo structure.                                       */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | PyObject *Ipo_CreatePyObject( Ipo * ipo ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	BPy_Ipo *pyipo; | 
					
						
							|  |  |  | 	pyipo = ( BPy_Ipo * ) PyObject_NEW( BPy_Ipo, &Ipo_Type ); | 
					
						
							|  |  |  | 	if( !pyipo ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_MemoryError, | 
					
						
							|  |  |  | 					      "couldn't create BPy_Ipo object" ); | 
					
						
							|  |  |  | 	pyipo->ipo = ipo; | 
					
						
							|  |  |  | 	pyipo->iter = 0; | 
					
						
							|  |  |  | 	if( pyipo->ipo->blocktype == ID_WO || pyipo->ipo->blocktype == ID_LA || | 
					
						
							|  |  |  | 			pyipo->ipo->blocktype == ID_MA ) | 
					
						
							|  |  |  | 		pyipo->mtex = 0; | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		pyipo->mtex = -1; | 
					
						
							|  |  |  | 	return ( PyObject * ) pyipo; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Function:    Ipo_FromPyObject                                             */ | 
					
						
							|  |  |  | /* Description: This function returns the Blender ipo from the given         */ | 
					
						
							|  |  |  | /*              PyObject.                                                    */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | Ipo *Ipo_FromPyObject( PyObject * pyobj ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return ( ( BPy_Ipo * ) pyobj )->ipo; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Function:    Ipo_length                                                   */ | 
					
						
							|  |  |  | /* Description: This function counts the number of curves accessible for the */ | 
					
						
							|  |  |  | /*              PyObject.                                                    */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | static int Ipo_length( BPy_Ipo * self ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	IpoCurve *icu; | 
					
						
							|  |  |  | 	int len = 0; | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	for( icu = self->ipo->curve.first; icu; icu = icu->next ) { | 
					
						
							|  |  |  | 		if( self->mtex == -1 || icu->adrcode < MA_MAP1 || | 
					
						
							|  |  |  | 				icu->adrcode & texchannel_to_adrcode( self->mtex ) ) | 
					
						
							|  |  |  | 			++len; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return len; | 
					
						
							| 
									
										
										
										
											2004-07-26 21:44:55 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-23 14:17:14 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * "mapping" operator getter: return an IpoCurve it we can find it | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | static PyObject *Ipo_getIpoCurveByName( BPy_Ipo * self, PyObject * key ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     IpoCurve *icu = NULL; | 
					
						
							|  |  |  |     int adrcode; | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2006-04-23 14:17:14 +00:00
										 |  |  | 	/* if Ipo is not ShapeKey and arg is an int, look up the adrcode */ | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	if( self->ipo->blocktype != ID_KE && PyNumber_Check( key ) ) | 
					
						
							|  |  |  | 		adrcode = lookup_curve_adrcode( PyInt_AsLong( key ), | 
					
						
							|  |  |  | 				self->ipo->blocktype, self->mtex ); | 
					
						
							| 
									
										
										
										
											2006-04-23 14:17:14 +00:00
										 |  |  | 	/* if Ipo is ShapeKey and arg is string, look up the adrcode */ | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	else if( self->ipo->blocktype == ID_KE && PyString_Check( key ) ) { | 
					
						
							|  |  |  | 		adrcode = lookup_curve_key( PyString_AS_STRING( key ), self->ipo ); | 
					
						
							|  |  |  | 		if( adrcode == -2 ) | 
					
						
							|  |  |  | 			return EXPP_ReturnPyObjError( PyExc_RuntimeError,  | 
					
						
							|  |  |  | 					"unable to find matching key data for Ipo" ); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 				"expected int or string key" ); | 
					
						
							| 
									
										
										
										
											2005-01-07 01:38:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	/* if no adrcode found, value error */ | 
					
						
							|  |  |  | 	if( adrcode == -1 ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_KeyError, "invalid curve key" ); | 
					
						
							| 
									
										
										
										
											2005-01-07 01:38:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	/* search for a matching adrcode */ | 
					
						
							|  |  |  | 	for( icu = self->ipo->curve.first; icu; icu = icu->next ) | 
					
						
							|  |  |  | 		if( icu->adrcode == adrcode ) | 
					
						
							|  |  |  | 			return IpoCurve_CreatePyObject( icu ); | 
					
						
							| 
									
										
										
										
											2005-01-07 01:38:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	/* no curve found */ | 
					
						
							|  |  |  |     Py_RETURN_NONE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-23 14:17:14 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * "mapping" operator setter: create or delete an IpoCurve it we can find it | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | static int Ipo_setIpoCurveByName( BPy_Ipo * self, PyObject * key,  | 
					
						
							|  |  |  | 		PyObject * arg ) | 
					
						
							| 
									
										
										
										
											2004-07-26 21:44:55 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	IpoCurve *icu; | 
					
						
							|  |  |  | 	Ipo *ipo = self->ipo; | 
					
						
							|  |  |  | 	short adrcode; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-23 14:17:14 +00:00
										 |  |  | 	/* "del ipo[const]" will send NULL here; give an error */ | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	if( !arg ) | 
					
						
							|  |  |  | 		return EXPP_ReturnIntError( PyExc_NotImplementedError, | 
					
						
							|  |  |  | 				"del operator not supported" ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-23 14:17:14 +00:00
										 |  |  | 	/* "del ipo[const]" will send NULL here; give an error */ | 
					
						
							|  |  |  | 	if( self->ipo->blocktype == ID_KE ) | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 		return EXPP_ReturnIntError( PyExc_TypeError, | 
					
						
							| 
									
										
										
										
											2006-04-23 14:17:14 +00:00
										 |  |  | 				"creation or deletion of Shape Keys not supported" ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* check for int argument */ | 
					
						
							|  |  |  | 	if( !PyNumber_Check( key ) ) | 
					
						
							|  |  |  | 		return EXPP_ReturnIntError( PyExc_TypeError, "expected int key" ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* look up the key, return error if not found */ | 
					
						
							|  |  |  | 	adrcode = lookup_curve_adrcode( PyInt_AsLong( key ), | 
					
						
							|  |  |  | 			self->ipo->blocktype, self->mtex ); | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if( adrcode == -1 ) | 
					
						
							|  |  |  | 		return EXPP_ReturnIntError( PyExc_KeyError, | 
					
						
							|  |  |  | 				"invalid curve specified" ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* if arg is None, delete the curve */ | 
					
						
							|  |  |  | 	if( arg == Py_None ) { | 
					
						
							|  |  |  | 		for( icu = self->ipo->curve.first; icu; icu = icu->next ) { | 
					
						
							|  |  |  | 			if( icu->adrcode == adrcode ) { | 
					
						
							|  |  |  | 				del_ipocurve( ipo, icu ); | 
					
						
							|  |  |  | 				return 0; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 		return EXPP_ReturnIntError( PyExc_ValueError, "IpoCurve not found" ); | 
					
						
							|  |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	/* create the new ipo curve */ | 
					
						
							|  |  |  | 		float time, curval; | 
					
						
							|  |  |  | 		PyObject *tmp, *flt=NULL, *val=NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* error if not a sequence or sequence with other than 2 values */ | 
					
						
							|  |  |  | 		if( PySequence_Size( arg ) != 2 ) | 
					
						
							|  |  |  | 			goto AttrError; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* get the time and curval */ | 
					
						
							|  |  |  | 		tmp = PySequence_ITEM( arg, 0 ); | 
					
						
							|  |  |  | 		flt = PyNumber_Float( tmp ); | 
					
						
							|  |  |  | 		Py_DECREF( tmp ); | 
					
						
							|  |  |  | 		tmp = PySequence_ITEM( arg, 1 ); | 
					
						
							|  |  |  | 		val = PyNumber_Float( tmp ); | 
					
						
							|  |  |  | 		Py_DECREF( tmp ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if( !flt || !val ) | 
					
						
							|  |  |  | 			goto AttrError; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-24 15:09:07 +00:00
										 |  |  | 		time = (float)PyFloat_AS_DOUBLE( flt ); | 
					
						
							|  |  |  | 		curval = (float)PyFloat_AS_DOUBLE( val ); | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 		Py_DECREF( flt ); | 
					
						
							|  |  |  | 		Py_DECREF( val ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* if curve already exist, delete the original */ | 
					
						
							|  |  |  | 		for( icu = ipo->curve.first; icu; icu = icu->next ) | 
					
						
							|  |  |  | 			if( icu->adrcode == adrcode ) { | 
					
						
							|  |  |  | 				del_ipocurve( ipo, icu ); | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 		/* create the new curve, then add the key */ | 
					
						
							|  |  |  | 		icu = MEM_callocN( sizeof(IpoCurve), "Python added ipocurve"); | 
					
						
							|  |  |  | 		icu->blocktype = ipo->blocktype; | 
					
						
							|  |  |  | 		icu->adrcode = adrcode; | 
					
						
							|  |  |  | 		icu->flag |= IPO_VISIBLE|IPO_AUTO_HORIZ; | 
					
						
							|  |  |  | 		set_icu_vars( icu ); | 
					
						
							|  |  |  | 		BLI_addtail( &(ipo->curve), icu); | 
					
						
							| 
									
										
										
										
											2007-09-18 06:41:29 +00:00
										 |  |  | 		insert_vert_icu( icu, time, curval, 0); | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 		allspace( REMAKEIPO, 0 ); | 
					
						
							|  |  |  | 		EXPP_allqueue( REDRAWIPO, 0 ); | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 		return 0;  | 
					
						
							| 
									
										
										
										
											2005-01-07 01:38:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | AttrError: | 
					
						
							|  |  |  | 		Py_XDECREF( val ); | 
					
						
							|  |  |  | 		Py_XDECREF( flt ); | 
					
						
							|  |  |  | 		return EXPP_ReturnIntError( PyExc_AttributeError, | 
					
						
							|  |  |  | 				"expected sequence of two floats" ); | 
					
						
							| 
									
										
										
										
											2005-01-07 01:38:14 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | }  | 
					
						
							| 
									
										
										
										
											2005-01-07 01:38:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * sequence __contains__ method (implements "x in ipo") | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2005-01-07 01:38:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | static int Ipo_contains( BPy_Ipo *self, PyObject *key ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     IpoCurve *icu = NULL; | 
					
						
							|  |  |  |     int adrcode; | 
					
						
							| 
									
										
										
										
											2005-10-25 04:46:49 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	/* take a Ipo curve name: key must be a int */  | 
					
						
							| 
									
										
										
										
											2004-01-18 23:43:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	if( self->ipo->blocktype != ID_KE && PyNumber_Check( key ) ) { | 
					
						
							|  |  |  | 		adrcode = lookup_curve_adrcode( PyInt_AsLong( key ), | 
					
						
							|  |  |  | 			self->ipo->blocktype, self->mtex ); | 
					
						
							| 
									
										
										
										
											2003-07-21 00:08:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 		/* if we found an adrcode for the key, search the ipo's curve */ | 
					
						
							|  |  |  | 		if( adrcode != -1 ) { | 
					
						
							|  |  |  | 			for( icu = self->ipo->curve.first; icu; icu = icu->next ) | 
					
						
							|  |  |  | 				if( icu->adrcode == adrcode ) | 
					
						
							|  |  |  | 					return 1; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} else if( self->ipo->blocktype == ID_KE && PyString_Check( key ) ) { | 
					
						
							|  |  |  | 		adrcode = lookup_curve_key( PyString_AS_STRING( key ), self->ipo ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* if we found an adrcode for the key, search the ipo's curve */ | 
					
						
							|  |  |  | 		if( adrcode >= 0 ) { | 
					
						
							|  |  |  | 			for( icu = self->ipo->curve.first; icu; icu = icu->next ) | 
					
						
							|  |  |  | 				if( icu->adrcode == adrcode ) | 
					
						
							|  |  |  | 					return 1; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}  | 
					
						
							| 
									
										
										
										
											2005-04-24 19:03:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	/* no curve found */ | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2005-04-24 19:03:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Initialize the interator index | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Ipo_getIter( BPy_Ipo * self ) | 
					
						
							| 
									
										
										
										
											2005-04-24 19:03:39 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2007-02-25 12:41:50 +00:00
										 |  |  | 	/* return a new IPO object if we are looping on the existing one
 | 
					
						
							|  |  |  | 	   This allows nested loops */ | 
					
						
							|  |  |  | 	if (self->iter==0) { | 
					
						
							|  |  |  | 		return EXPP_incr_ret ( (PyObject *) self ); | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		return Ipo_CreatePyObject(self->ipo); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2005-04-24 19:03:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Get the next Ipo curve | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2005-04-24 19:03:39 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | static PyObject *Ipo_nextIter( BPy_Ipo * self ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int i; | 
					
						
							|  |  |  | 	IpoCurve *icu = self->ipo->curve.first; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	++self->iter; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/*
 | 
					
						
							|  |  |  | 		 * count curves only if  | 
					
						
							|  |  |  | 		 * (a) Ipo has no texture channels | 
					
						
							|  |  |  | 		 * (b) Ipo has texture channels, but curve is not that type | 
					
						
							|  |  |  | 		 * (c) Ipo has texture channels, and curve is that type, and it is | 
					
						
							|  |  |  | 		 *    in the active texture channel | 
					
						
							|  |  |  | 		 */ | 
					
						
							|  |  |  | 	for( i = 0; icu; icu = icu->next ) { | 
					
						
							|  |  |  | 		if( self->mtex == -1 || icu->adrcode < MA_MAP1 || | 
					
						
							|  |  |  | 				icu->adrcode & texchannel_to_adrcode( self->mtex ) ) { | 
					
						
							|  |  |  | 			++i; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			/* if indices match, return the curve */ | 
					
						
							|  |  |  | 			if( i == self->iter ) | 
					
						
							|  |  |  | 				return IpoCurve_CreatePyObject( icu ); | 
					
						
							| 
									
										
										
										
											2005-04-24 19:03:39 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-02-25 12:41:50 +00:00
										 |  |  | 	self->iter = 0; /* allow iter use again */ | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	/* ran out of curves */ | 
					
						
							|  |  |  | 	return EXPP_ReturnPyObjError( PyExc_StopIteration, | 
					
						
							|  |  |  | 			"iterator at end" ); | 
					
						
							| 
									
										
										
										
											2005-04-24 19:03:39 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Function:              Ipo_Init                                           */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | PyObject *Ipo_Init( void ) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2007-02-23 14:51:20 +00:00
										 |  |  | 	/* PyObject *submodule; */ | 
					
						
							| 
									
										
										
										
											2004-01-18 23:43:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	if( PyType_Ready( &Ipo_Type ) < 0 ) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							| 
									
										
										
										
											2004-01-18 23:43:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	submodule = Py_InitModule3( "Blender.Ipo", M_Ipo_methods, M_Ipo_doc ); | 
					
						
							|  |  |  | 	generate_curveconsts( submodule ); | 
					
						
							| 
									
										
										
										
											2003-07-21 00:08:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	return submodule; | 
					
						
							| 
									
										
										
										
											2003-07-19 08:32:01 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * The following methods should be deprecated when there are equivalent | 
					
						
							|  |  |  |  * methods in Ipocurve (if there aren't already). | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2003-07-19 08:32:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Ipo_getNBezPoints( BPy_Ipo * self, PyObject * args ) | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	int num = 0; | 
					
						
							|  |  |  | 	IpoCurve *icu = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( !PyArg_ParseTuple( args, "i", &num ) ) | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 		return EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 				"expected int argument" ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	icu = self->ipo->curve.first; | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	while( icu && num > 0 ) { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 		icu = icu->next; | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 		--num; | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-23 18:16:20 +00:00
										 |  |  | 	if( num < 0 || !icu ) | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 		return EXPP_ReturnPyObjError( PyExc_IndexError, | 
					
						
							|  |  |  | 				"index out of range" ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return PyInt_FromLong( icu->totvert ); | 
					
						
							| 
									
										
										
										
											2003-07-19 08:32:01 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Ipo_DeleteBezPoints( BPy_Ipo * self, PyObject * args ) | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	int num = 0, i = 0; | 
					
						
							|  |  |  | 	IpoCurve *icu = 0; | 
					
						
							|  |  |  | 	if( !PyArg_ParseTuple( args, "i", &num ) ) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError | 
					
						
							|  |  |  | 			 ( PyExc_TypeError, "expected int argument" ) ); | 
					
						
							|  |  |  | 	icu = self->ipo->curve.first; | 
					
						
							|  |  |  | 	if( !icu ) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError | 
					
						
							|  |  |  | 			 ( PyExc_TypeError, "No IPO curve" ) ); | 
					
						
							|  |  |  | 	for( i = 0; i < num; i++ ) { | 
					
						
							|  |  |  | 		if( !icu ) | 
					
						
							|  |  |  | 			return ( EXPP_ReturnPyObjError | 
					
						
							|  |  |  | 				 ( PyExc_TypeError, "Bad curve number" ) ); | 
					
						
							|  |  |  | 		icu = icu->next; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	icu->totvert--; | 
					
						
							|  |  |  | 	return ( PyInt_FromLong( icu->totvert ) ); | 
					
						
							| 
									
										
										
										
											2003-07-19 08:32:01 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-12-17 17:34:51 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Ipo_getCurveBP() | 
					
						
							|  |  |  |  * this method is UNSUPPORTED. | 
					
						
							|  |  |  |  * Calling this method throws a TypeError Exception. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * it looks like the original intent was to return the first point | 
					
						
							|  |  |  |  * of a BPoint Ipo curve.  However, BPoint ipos are not currently | 
					
						
							|  |  |  |  * implemented. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | static PyObject *Ipo_getCurveBP( BPy_Ipo * self_unused, PyObject * args_unused ) | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-12-17 17:34:51 +00:00
										 |  |  | 	return EXPP_ReturnPyObjError( PyExc_NotImplementedError, | 
					
						
							| 
									
										
										
										
											2004-12-21 01:15:42 +00:00
										 |  |  | 				      "bpoint ipos are not supported" ); | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Ipo_getCurveBeztriple( BPy_Ipo * self, PyObject * args ) | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	struct BezTriple *ptrbt; | 
					
						
							|  |  |  | 	int num = 0, pos, i, j; | 
					
						
							|  |  |  | 	IpoCurve *icu; | 
					
						
							| 
									
										
										
										
											2007-05-27 21:33:48 +00:00
										 |  |  | 	PyObject *l, *pyfloat; | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if( !PyArg_ParseTuple( args, "ii", &num, &pos ) ) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError | 
					
						
							|  |  |  | 			 ( PyExc_TypeError, "expected int argument" ) ); | 
					
						
							|  |  |  | 	icu = self->ipo->curve.first; | 
					
						
							|  |  |  | 	if( !icu ) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError | 
					
						
							|  |  |  | 			 ( PyExc_TypeError, "No IPO curve" ) ); | 
					
						
							|  |  |  | 	for( i = 0; i < num; i++ ) { | 
					
						
							|  |  |  | 		if( !icu ) | 
					
						
							|  |  |  | 			return ( EXPP_ReturnPyObjError | 
					
						
							|  |  |  | 				 ( PyExc_TypeError, "Bad ipo number" ) ); | 
					
						
							|  |  |  | 		icu = icu->next; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if( pos >= icu->totvert ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 					      "Bad bezt number" ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ptrbt = icu->bezt + pos; | 
					
						
							|  |  |  | 	if( !ptrbt ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 					      "No bez triple" ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-05-27 21:33:48 +00:00
										 |  |  | 	l = PyList_New( 0 ); | 
					
						
							| 
									
										
										
										
											2007-05-25 16:43:25 +00:00
										 |  |  | 	for( i = 0; i < 3; i++ ) { | 
					
						
							|  |  |  | 		for( j = 0; j < 3; j++ ) { | 
					
						
							|  |  |  | 			pyfloat = PyFloat_FromDouble( ptrbt->vec[i][j] ); | 
					
						
							|  |  |  | 			PyList_Append( l, pyfloat ); | 
					
						
							|  |  |  | 			Py_DECREF(pyfloat); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	return l; | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Ipo_setCurveBeztriple( BPy_Ipo * self, PyObject * args ) | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	struct BezTriple *ptrbt; | 
					
						
							|  |  |  | 	int num = 0, pos, i; | 
					
						
							|  |  |  | 	IpoCurve *icu; | 
					
						
							|  |  |  | 	PyObject *listargs = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( !PyArg_ParseTuple( args, "iiO", &num, &pos, &listargs ) ) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError | 
					
						
							|  |  |  | 			 ( PyExc_TypeError, | 
					
						
							|  |  |  | 			   "expected int int object argument" ) ); | 
					
						
							|  |  |  | 	if( !PyTuple_Check( listargs ) ) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError | 
					
						
							|  |  |  | 			 ( PyExc_TypeError, "3rd arg should be a tuple" ) ); | 
					
						
							|  |  |  | 	icu = self->ipo->curve.first; | 
					
						
							|  |  |  | 	if( !icu ) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError | 
					
						
							|  |  |  | 			 ( PyExc_TypeError, "No IPO curve" ) ); | 
					
						
							|  |  |  | 	for( i = 0; i < num; i++ ) { | 
					
						
							|  |  |  | 		if( !icu ) | 
					
						
							|  |  |  | 			return ( EXPP_ReturnPyObjError | 
					
						
							|  |  |  | 				 ( PyExc_TypeError, "Bad ipo number" ) ); | 
					
						
							|  |  |  | 		icu = icu->next; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if( pos >= icu->totvert ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 					      "Bad bezt number" ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ptrbt = icu->bezt + pos; | 
					
						
							|  |  |  | 	if( !ptrbt ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 					      "No bez triple" ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for( i = 0; i < 9; i++ ) { | 
					
						
							|  |  |  | 		PyObject *xx = PyTuple_GetItem( listargs, i ); | 
					
						
							| 
									
										
										
										
											2005-07-18 03:50:37 +00:00
										 |  |  | 		ptrbt->vec[i / 3][i % 3] = (float)PyFloat_AsDouble( xx ); | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Py_INCREF( Py_None ); | 
					
						
							|  |  |  | 	return Py_None; | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-14 03:01:24 +00:00
										 |  |  | /* Ipo.__copy__ */ | 
					
						
							|  |  |  | static PyObject *Ipo_copy( BPy_Ipo * self ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Ipo *ipo = copy_ipo(self->ipo ); | 
					
						
							|  |  |  | 	ipo->id.us = 0; | 
					
						
							|  |  |  | 	return Ipo_CreatePyObject(ipo); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Ipo_EvaluateCurveOn( BPy_Ipo * self, PyObject * args ) | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	int num = 0, i; | 
					
						
							|  |  |  | 	IpoCurve *icu; | 
					
						
							|  |  |  | 	float time = 0; | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	if( !PyArg_ParseTuple( args, "if", &num, &time ) ) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError | 
					
						
							|  |  |  | 			 ( PyExc_TypeError, "expected int argument" ) ); | 
					
						
							| 
									
										
										
										
											2004-04-26 17:21:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	icu = self->ipo->curve.first; | 
					
						
							|  |  |  | 	if( !icu ) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError | 
					
						
							|  |  |  | 			 ( PyExc_TypeError, "No IPO curve" ) ); | 
					
						
							| 
									
										
										
										
											2004-04-26 17:21:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	for( i = 0; i < num; i++ ) { | 
					
						
							|  |  |  | 		if( !icu ) | 
					
						
							|  |  |  | 			return ( EXPP_ReturnPyObjError | 
					
						
							|  |  |  | 				 ( PyExc_TypeError, "Bad ipo number" ) ); | 
					
						
							|  |  |  | 		icu = icu->next; | 
					
						
							| 
									
										
										
										
											2003-08-01 19:47:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	return PyFloat_FromDouble( eval_icu( icu, time ) ); | 
					
						
							| 
									
										
										
										
											2003-08-01 19:47:01 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | static PyObject *Ipo_getCurvecurval( BPy_Ipo * self, PyObject * args ) | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 	int numcurve = 0, i; | 
					
						
							|  |  |  | 	IpoCurve *icu; | 
					
						
							|  |  |  | 	char *stringname = 0, *str1 = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	icu = self->ipo->curve.first; | 
					
						
							|  |  |  | 	if( !icu ) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError | 
					
						
							|  |  |  | 			 ( PyExc_TypeError, "No IPO curve" ) ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-02-23 14:51:20 +00:00
										 |  |  | 	if( PyNumber_Check( PyTuple_GetItem( args, 0 ) ) )	/* args is an integer */ | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 		if( !PyArg_ParseTuple( args, "i", &numcurve ) ) | 
					
						
							|  |  |  | 			return ( EXPP_ReturnPyObjError | 
					
						
							|  |  |  | 				 ( PyExc_TypeError, | 
					
						
							|  |  |  | 				   "expected int or string argument" ) ); | 
					
						
							|  |  |  | 		for( i = 0; i < numcurve; i++ ) { | 
					
						
							|  |  |  | 			if( !icu ) | 
					
						
							|  |  |  | 				return ( EXPP_ReturnPyObjError | 
					
						
							|  |  |  | 					 ( PyExc_TypeError, | 
					
						
							|  |  |  | 					   "Bad ipo number" ) ); | 
					
						
							|  |  |  | 			icu = icu->next; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-02-23 14:51:20 +00:00
										 |  |  | 	else			/* args is a string */ | 
					
						
							| 
									
										
										
										
											2004-03-29 08:16:18 +00:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 		if( !PyArg_ParseTuple( args, "s", &stringname ) ) | 
					
						
							|  |  |  | 			return ( EXPP_ReturnPyObjError | 
					
						
							|  |  |  | 				 ( PyExc_TypeError, | 
					
						
							|  |  |  | 				   "expected int or string argument" ) ); | 
					
						
							|  |  |  | 		while( icu ) { | 
					
						
							| 
									
										
										
										
											2005-04-24 19:03:39 +00:00
										 |  |  | 			str1 = getIpoCurveName( icu ); | 
					
						
							| 
									
										
										
										
											2004-09-25 20:30:40 +00:00
										 |  |  | 			if( !strcmp( str1, stringname ) ) | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			icu = icu->next; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( icu ) | 
					
						
							|  |  |  | 		return PyFloat_FromDouble( icu->curval ); | 
					
						
							| 
									
										
										
										
											2007-05-25 16:43:25 +00:00
										 |  |  | 	Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * The following methods should be deprecated when methods are pruned out. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2003-06-05 18:03:46 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | static PyObject *Ipo_oldsetRctf( BPy_Ipo * self, PyObject * args ) | 
					
						
							| 
									
										
										
										
											2003-06-12 04:51:50 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2006-04-21 20:27:52 +00:00
										 |  |  | 	return EXPP_setterWrapperTuple( (void *)self, args, | 
					
						
							|  |  |  | 			(setter)Ipo_setRctf ); | 
					
						
							| 
									
										
										
										
											2003-06-12 04:51:50 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2006-04-24 05:24:58 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Ipo_oldsetBlocktype( BPy_Ipo * self, PyObject * args ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return EXPP_setterWrapperTuple( (void *)self, args, | 
					
						
							|  |  |  | 			(setter)Ipo_setBlocktype ); | 
					
						
							|  |  |  | } |