| 
									
										
										
										
											2003-05-17 07:08:08 +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. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Contributor(s): Jacques Guignot | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ***** END GPL/BL DUAL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "Curve.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Function:              M_Curve_New                                       */ | 
					
						
							|  |  |  | /* Python equivalent:     Blender.Curve.New                                 */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | static PyObject *M_Curve_New(PyObject *self, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2003-05-29 04:00:35 +00:00
										 |  |  |   char buf[24]; | 
					
						
							|  |  |  |   char*name=NULL ; | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  |   BPy_Curve    *pycurve; /* for Curve Data object wrapper in Python */ | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  |   Curve      *blcurve = 0; /* for actual Curve Data we create in Blender */ | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   if (!PyArg_ParseTuple(args, "|s", &name)) | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 					return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							|  |  |  | 														"expected string argument or no argument")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   blcurve = add_curve(OB_CURVE); /* first create the Curve Data in Blender */ | 
					
						
							| 
									
										
										
										
											2003-05-29 04:00:35 +00:00
										 |  |  |   if (blcurve == NULL) | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 					return (EXPP_ReturnPyObjError (PyExc_RuntimeError, | 
					
						
							|  |  |  | 														"couldn't create Curve Data in Blender")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  |   pycurve = (BPy_Curve *)PyObject_NEW(BPy_Curve, &Curve_Type); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |       | 
					
						
							| 
									
										
										
										
											2003-05-29 04:00:35 +00:00
										 |  |  |   if (pycurve == NULL) | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 					return (EXPP_ReturnPyObjError (PyExc_MemoryError, | 
					
						
							|  |  |  | 															"couldn't create Curve Data object")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   pycurve->curve = blcurve; /* link Python curve wrapper to Blender Curve */ | 
					
						
							|  |  |  |   if (name) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       PyOS_snprintf(buf, sizeof(buf), "%s", name); | 
					
						
							|  |  |  |       rename_id(&blcurve->id, buf); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return (PyObject *)pycurve; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-05-29 04:00:35 +00:00
										 |  |  | /* Function:              M_Curve_Get                                       */ | 
					
						
							|  |  |  | /* Python equivalent:     Blender.Curve.Get                                 */ | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | static PyObject *M_Curve_Get(PyObject *self, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2003-05-29 04:00:35 +00:00
										 |  |  |   char     *name = NULL; | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  |   Curve   *curv_iter; | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  |   BPy_Curve *wanted_curv; | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-05-29 04:00:35 +00:00
										 |  |  |   if (!PyArg_ParseTuple(args, "|s", &name))//expects nothing or a string
 | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  |     return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 														"expected string argument")); | 
					
						
							| 
									
										
										
										
											2003-05-29 04:00:35 +00:00
										 |  |  |   if(name){//a name has been given
 | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  |     /* Use the name to search for the curve requested */ | 
					
						
							|  |  |  |     wanted_curv = NULL; | 
					
						
							|  |  |  |     curv_iter = G.main->curve.first; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     while ((curv_iter) && (wanted_curv == NULL)) { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       if (strcmp (name, curv_iter->id.name+2) == 0) { | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | 	wanted_curv = (BPy_Curve *)PyObject_NEW(BPy_Curve, &Curve_Type); | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 	if (wanted_curv) wanted_curv->curve = curv_iter; | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       curv_iter = curv_iter->id.next; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (wanted_curv == NULL) { /* Requested curve doesn't exist */ | 
					
						
							|  |  |  |       char error_msg[64]; | 
					
						
							|  |  |  |       PyOS_snprintf(error_msg, sizeof(error_msg), | 
					
						
							|  |  |  |                     "Curve \"%s\" not found", name); | 
					
						
							|  |  |  |       return (EXPP_ReturnPyObjError (PyExc_NameError, error_msg)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return (PyObject*)wanted_curv; | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  |   }//if(name)
 | 
					
						
							|  |  |  |   else{//no name has been given; return a list of all curves by name. 
 | 
					
						
							|  |  |  |     PyObject *curvlist; | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     curv_iter = G.main->curve.first; | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  |     curvlist = PyList_New (0); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (curvlist == NULL) | 
					
						
							|  |  |  |       return (PythonReturnErrorObject (PyExc_MemoryError, | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 				       "couldn't create PyList")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     while (curv_iter) { | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | BPy_Curve *found_cur=(BPy_Curve*)PyObject_NEW(BPy_Curve,&Curve_Type); | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 			found_cur->curve = curv_iter; | 
					
						
							|  |  |  |       PyList_Append (curvlist,  (PyObject *)found_cur); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |       curv_iter = curv_iter->id.next; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return (curvlist); | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  |   }//else
 | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | /* Function:              Curve_Init                                         */ | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-06-28 07:38:21 +00:00
										 |  |  | PyObject *Curve_Init (void) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  |   PyObject  *submodule; | 
					
						
							| 
									
										
										
										
											2003-06-02 20:15:50 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   Curve_Type.ob_type = &PyType_Type; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  |   submodule = Py_InitModule3("Blender.Curve",M_Curve_methods, M_Curve_doc); | 
					
						
							|  |  |  |   return (submodule); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | /* Python BPy_Curve methods:                                                   */ | 
					
						
							| 
									
										
										
										
											2003-05-29 04:00:35 +00:00
										 |  |  | /* gives access to                                                           */ | 
					
						
							|  |  |  | /* name, pathlen totcol flag bevresol                                        */ | 
					
						
							|  |  |  | /* resolu resolv width ext1 ext2                                             */  | 
					
						
							|  |  |  | /* controlpoint loc rot size                                                 */ | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-05-29 04:00:35 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *Curve_getName(BPy_Curve *self) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  |   PyObject *attr = PyString_FromString(self->curve->id.name+2); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (attr) return attr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return (EXPP_ReturnPyObjError (PyExc_RuntimeError, | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 													"couldn't get Curve.name attribute")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *Curve_setName(BPy_Curve *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  |   char*name; | 
					
						
							| 
									
										
										
										
											2003-05-29 04:00:35 +00:00
										 |  |  |   char buf[50]; | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  |    | 
					
						
							|  |  |  |   if (!PyArg_ParseTuple(args, "s", &(name)))   | 
					
						
							|  |  |  |     return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 														"expected string argument")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  |   PyOS_snprintf(buf, sizeof(buf), "%s", name); | 
					
						
							|  |  |  |   rename_id(&self->curve->id, buf); /* proper way in Blender */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							|  |  |  |   return Py_None; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *Curve_getPathLen(BPy_Curve *self) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  |   PyObject *attr = PyInt_FromLong((long)self->curve->pathlen); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (attr) return attr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return (EXPP_ReturnPyObjError (PyExc_RuntimeError, | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 													"couldn't get Curve.pathlen attribute")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *Curve_setPathLen(BPy_Curve *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (!PyArg_ParseTuple(args, "i", &(self->curve->pathlen))) | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 					return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							|  |  |  | 																	"expected int argument")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  |   | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							|  |  |  |   return Py_None; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *Curve_getTotcol(BPy_Curve *self) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  |   PyObject *attr = PyInt_FromLong((long)self->curve->totcol); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (attr) return attr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return (EXPP_ReturnPyObjError (PyExc_RuntimeError, | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 													"couldn't get Curve.totcol attribute")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *Curve_setTotcol(BPy_Curve *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (!PyArg_ParseTuple(args, "i", &(self->curve->totcol))) | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 					return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							|  |  |  | 																	"expected int argument")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  |   | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							|  |  |  |   return Py_None; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *Curve_getMode(BPy_Curve *self) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  |   PyObject *attr = PyInt_FromLong((long)self->curve->flag); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (attr) return attr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return (EXPP_ReturnPyObjError (PyExc_RuntimeError, | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 													"couldn't get Curve.flag attribute")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *Curve_setMode(BPy_Curve *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (!PyArg_ParseTuple(args, "i", &(self->curve->flag))) | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 					return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							|  |  |  | 																	"expected int argument")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  |   | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							|  |  |  |   return Py_None; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *Curve_getBevresol(BPy_Curve *self) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  |   PyObject *attr = PyInt_FromLong((long)self->curve->bevresol); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (attr) return attr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return (EXPP_ReturnPyObjError (PyExc_RuntimeError, | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 													"couldn't get Curve.bevresol attribute")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *Curve_setBevresol(BPy_Curve *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (!PyArg_ParseTuple(args, "i", &(self->curve->bevresol))) | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 					return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							|  |  |  | 																	"expected int argument")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  |   | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							|  |  |  |   return Py_None; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *Curve_getResolu(BPy_Curve *self) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  |   PyObject *attr = PyInt_FromLong((long)self->curve->resolu); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (attr) return attr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return (EXPP_ReturnPyObjError (PyExc_RuntimeError, | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 													"couldn't get Curve.resolu attribute")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *Curve_setResolu(BPy_Curve *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (!PyArg_ParseTuple(args, "i", &(self->curve->resolu))) | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 					return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							|  |  |  | 																	"expected int argument")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  |   | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							|  |  |  |   return Py_None; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *Curve_getResolv(BPy_Curve *self) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  |   PyObject *attr = PyInt_FromLong((long)self->curve->resolv); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (attr) return attr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return (EXPP_ReturnPyObjError (PyExc_RuntimeError, | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 													"couldn't get Curve.resolv attribute")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *Curve_setResolv(BPy_Curve *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (!PyArg_ParseTuple(args, "i", &(self->curve->resolv))) | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 					return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							|  |  |  | 																	"expected int argument")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  |   | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							|  |  |  |   return Py_None; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *Curve_getWidth(BPy_Curve *self) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  |   PyObject *attr = PyFloat_FromDouble((double)self->curve->width); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (attr) return attr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return (EXPP_ReturnPyObjError (PyExc_RuntimeError, | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 													"couldn't get Curve.width attribute")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *Curve_setWidth(BPy_Curve *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (!PyArg_ParseTuple(args, "f", &(self->curve->width))) | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 					return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							|  |  |  | 																	"expected float argument")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  |   | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							|  |  |  |   return Py_None; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *Curve_getExt1(BPy_Curve *self) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  |   PyObject *attr = PyFloat_FromDouble((double)self->curve->ext1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (attr) return attr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return (EXPP_ReturnPyObjError (PyExc_RuntimeError, | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 													"couldn't get Curve.ext1 attribute")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *Curve_setExt1(BPy_Curve *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (!PyArg_ParseTuple(args, "f", &(self->curve->ext1))) | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 					return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							|  |  |  | 																	"expected float argument")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  |   | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							|  |  |  |   return Py_None; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *Curve_getExt2(BPy_Curve *self) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  |   PyObject *attr = PyFloat_FromDouble((double)self->curve->ext2); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (attr) return attr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return (EXPP_ReturnPyObjError (PyExc_RuntimeError, | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 													"couldn't get Curve.ext2 attribute")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *Curve_setExt2(BPy_Curve *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (!PyArg_ParseTuple(args, "f", &(self->curve->ext2))) | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 					return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							|  |  |  | 																	"expected float argument")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  |   | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							|  |  |  |   return Py_None; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *Curve_setControlPoint(BPy_Curve *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  |   Nurb*ptrnurb = self->curve->nurb.first; | 
					
						
							|  |  |  |   int numcourbe,numpoint,i,j; | 
					
						
							|  |  |  |   float x,y,z,w; | 
					
						
							|  |  |  |   float bez[9]; | 
					
						
							| 
									
										
										
										
											2003-05-29 04:00:35 +00:00
										 |  |  |   if (!ptrnurb){ Py_INCREF(Py_None);return Py_None;} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  |   if (ptrnurb->bp) | 
					
						
							|  |  |  |     if (!PyArg_ParseTuple(args, "iiffff", &numcourbe,&numpoint,&x,&y,&z,&w))   | 
					
						
							|  |  |  |       return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 								"expected int int float float float float arguments")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  |   if (ptrnurb->bezt) | 
					
						
							|  |  |  |     if (!PyArg_ParseTuple(args, "iifffffffff", &numcourbe,&numpoint, | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 						bez,bez+1,bez+2,bez+3,bez+4,bez+5,bez+6,bez+7,bez+8))   | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  |       return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 					"expected int int float float float float float float " | 
					
						
							|  |  |  | 					"float float float arguments")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   for(i = 0;i< numcourbe;i++) | 
					
						
							|  |  |  |     ptrnurb=ptrnurb->next; | 
					
						
							|  |  |  |   if (ptrnurb->bp) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       ptrnurb->bp[numpoint].vec[0] = x; | 
					
						
							|  |  |  |       ptrnurb->bp[numpoint].vec[1] = y; | 
					
						
							|  |  |  |       ptrnurb->bp[numpoint].vec[2] = z; | 
					
						
							|  |  |  |       ptrnurb->bp[numpoint].vec[3] = w; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   if (ptrnurb->bezt) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       for(i = 0;i<3;i++) | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 	for(j = 0;j<3;j++) | 
					
						
							|  |  |  | 	  ptrnurb->bezt[numpoint].vec[i][j] = bez[i*3+j]; | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  |   Py_INCREF(Py_None); | 
					
						
							|  |  |  |   return Py_None; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *Curve_getControlPoint(BPy_Curve *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2003-05-29 04:00:35 +00:00
										 |  |  |   PyObject* liste = PyList_New(0);  | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   Nurb*ptrnurb; | 
					
						
							|  |  |  |   int numcourbe,numpoint,i,j; | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |   if (!PyArg_ParseTuple(args, "ii", &numcourbe,&numpoint))   | 
					
						
							|  |  |  |     return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 														"expected int int arguments")); | 
					
						
							| 
									
										
										
										
											2003-05-29 04:00:35 +00:00
										 |  |  |   //check args ???
 | 
					
						
							|  |  |  |   if (!self->curve->nurb.first)return liste; | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  |   ptrnurb = self->curve->nurb.first; | 
					
						
							| 
									
										
										
										
											2003-05-29 04:00:35 +00:00
										 |  |  |   for(i = 0;i< numcourbe;i++)//selection of the first point of the curve
 | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  |     ptrnurb=ptrnurb->next; | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |   if (ptrnurb->bp) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       for(i = 0;i< 4;i++) | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 	PyList_Append(liste,  PyFloat_FromDouble( ptrnurb->bp[numpoint].vec[i])); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  |     } | 
					
						
							|  |  |  |       | 
					
						
							|  |  |  |   if (ptrnurb->bezt) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |       liste = PyList_New(9); | 
					
						
							|  |  |  |       for(i = 0;i< 3;i++) | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 	for(j = 0;j< 3;j++) | 
					
						
							|  |  |  | 	  PyList_Append(liste, | 
					
						
							|  |  |  | 							PyFloat_FromDouble( ptrnurb->bezt[numpoint].vec[i][j])); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return liste; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *Curve_getLoc(BPy_Curve *self) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  |   int i; | 
					
						
							|  |  |  |   PyObject* liste = PyList_New(3); | 
					
						
							|  |  |  |   for(i = 0;i< 3;i++) | 
					
						
							|  |  |  |     PyList_SetItem(liste, i, PyFloat_FromDouble( self->curve->loc[i])); | 
					
						
							|  |  |  |   return liste; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *Curve_setLoc(BPy_Curve *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  |   float x,y,z; | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   if (!PyArg_ParseTuple(args, "fff",&x,&y,&z))   | 
					
						
							|  |  |  |     return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 														"expected  float float float arguments")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   self->curve->loc[0] = x; | 
					
						
							|  |  |  |   self->curve->loc[1] = y; | 
					
						
							|  |  |  |   self->curve->loc[2] = z; | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							|  |  |  |   return Py_None; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *Curve_getRot(BPy_Curve *self) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   int i; | 
					
						
							|  |  |  |   PyObject* liste = PyList_New(3); | 
					
						
							|  |  |  |   for(i = 0;i< 3;i++) | 
					
						
							|  |  |  |     PyList_SetItem(liste, i, PyFloat_FromDouble( self->curve->rot[i])); | 
					
						
							|  |  |  |   return liste; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *Curve_setRot(BPy_Curve *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  |   float x,y,z; | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   if (!PyArg_ParseTuple(args, "fff",&x,&y,&z))   | 
					
						
							|  |  |  |     return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 														"expected  float float float arguments")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   self->curve->rot[0] = x; | 
					
						
							|  |  |  |   self->curve->rot[1] = y; | 
					
						
							|  |  |  |   self->curve->rot[2] = z; | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							|  |  |  |   return Py_None; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *Curve_getSize(BPy_Curve *self) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  |   int i; | 
					
						
							|  |  |  |   PyObject* liste = PyList_New(3); | 
					
						
							|  |  |  |   for(i = 0;i< 3;i++) | 
					
						
							|  |  |  |     PyList_SetItem(liste, i, PyFloat_FromDouble( self->curve->size[i])); | 
					
						
							|  |  |  |   return liste; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *Curve_setSize(BPy_Curve *self, PyObject *args) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  |   float x,y,z; | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   if (!PyArg_ParseTuple(args, "fff",&x,&y,&z))   | 
					
						
							|  |  |  |     return (EXPP_ReturnPyObjError (PyExc_AttributeError, | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 														"expected  float float float arguments")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   self->curve->size[0] = x; | 
					
						
							|  |  |  |   self->curve->size[1] = y; | 
					
						
							|  |  |  |   self->curve->size[2] = z; | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							|  |  |  |   return Py_None; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Function:    CurveDeAlloc                                                 */ | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | /* Description: This is a callback function for the BPy_Curve type. It is      */ | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | /*              the destructor function.                                     */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static void CurveDeAlloc (BPy_Curve *self) | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  |   PyObject_DEL (self); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Function:    CurveGetAttr                                                 */ | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | /* Description: This is a callback function for the BPy_Curve type. It is      */ | 
					
						
							|  |  |  | /*              the function that accesses BPy_Curve "member variables" and    */ | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | /*              methods.                                                     */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *CurveGetAttr (BPy_Curve *self, char *name)//getattr
 | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  |   PyObject *attr = Py_None; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (strcmp(name, "name") == 0) | 
					
						
							|  |  |  |     attr = PyString_FromString(self->curve->id.name+2); | 
					
						
							| 
									
										
										
										
											2003-05-29 04:00:35 +00:00
										 |  |  |   if (strcmp(name, "pathlen") == 0) | 
					
						
							|  |  |  |     attr = PyInt_FromLong(self->curve->pathlen); | 
					
						
							|  |  |  |   if (strcmp(name, "totcol") == 0) | 
					
						
							|  |  |  |     attr = PyInt_FromLong(self->curve->totcol); | 
					
						
							|  |  |  |   if (strcmp(name, "flag") == 0) | 
					
						
							|  |  |  |     attr = PyInt_FromLong(self->curve->flag); | 
					
						
							|  |  |  |   if (strcmp(name, "bevresol") == 0) | 
					
						
							|  |  |  |     attr = PyInt_FromLong(self->curve->bevresol); | 
					
						
							|  |  |  |   if (strcmp(name, "resolu") == 0) | 
					
						
							|  |  |  |     attr = PyInt_FromLong(self->curve->resolu); | 
					
						
							|  |  |  |   if (strcmp(name, "resolv") == 0) | 
					
						
							|  |  |  |     attr = PyInt_FromLong(self->curve->resolv); | 
					
						
							|  |  |  |   if (strcmp(name, "width") == 0) | 
					
						
							|  |  |  |     attr = PyFloat_FromDouble(self->curve->width); | 
					
						
							|  |  |  |   if (strcmp(name, "ext1") == 0) | 
					
						
							|  |  |  |     attr = PyFloat_FromDouble(self->curve->ext1); | 
					
						
							|  |  |  |   if (strcmp(name, "ext2") == 0) | 
					
						
							|  |  |  |     attr = PyFloat_FromDouble(self->curve->ext2); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   if (!attr) | 
					
						
							|  |  |  |     return (EXPP_ReturnPyObjError (PyExc_MemoryError, | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  | 														"couldn't create PyObject")); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   if (attr != Py_None) return attr; /* member attribute found, return it */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /* not an attribute, search the methods table */ | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  |   return Py_FindMethod(BPy_Curve_methods, (PyObject *)self, name); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Function:    CurveSetAttr                                                 */ | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | /* Description: This is a callback function for the BPy_Curve type. It is the  */ | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | /*              function that sets Curve Data attributes (member variables). */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static int CurveSetAttr (BPy_Curve *self, char *name, PyObject *value) | 
					
						
							| 
									
										
										
										
											2003-05-29 04:00:35 +00:00
										 |  |  | { PyObject *valtuple;  | 
					
						
							|  |  |  |   PyObject *error = NULL; | 
					
						
							| 
									
										
										
										
											2003-06-09 04:01:48 +00:00
										 |  |  |   valtuple = Py_BuildValue("(O)", value); | 
					
						
							| 
									
										
										
										
											2003-05-29 04:00:35 +00:00
										 |  |  |   //resolu resolv width ext1 ext2  
 | 
					
						
							|  |  |  |   if (!valtuple)  | 
					
						
							|  |  |  |     return EXPP_ReturnIntError(PyExc_MemoryError, | 
					
						
							|  |  |  |                          "CurveSetAttr: couldn't create PyTuple"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (strcmp (name, "name") == 0) | 
					
						
							|  |  |  |     error = Curve_setName (self, valtuple); | 
					
						
							|  |  |  |   else if (strcmp (name, "pathlen") == 0) | 
					
						
							|  |  |  |     error = Curve_setPathLen(self, valtuple); | 
					
						
							|  |  |  |   else if (strcmp (name, "resolu") == 0) | 
					
						
							|  |  |  |     error = Curve_setResolu (self, valtuple); | 
					
						
							|  |  |  |   else if (strcmp (name, "resolv") == 0) | 
					
						
							|  |  |  |     error = Curve_setResolv (self, valtuple); | 
					
						
							|  |  |  |   else if (strcmp (name, "width") == 0) | 
					
						
							|  |  |  |     error = Curve_setWidth (self, valtuple); | 
					
						
							|  |  |  |   else if (strcmp (name, "ext1") == 0) | 
					
						
							|  |  |  |     error = Curve_setExt1 (self, valtuple); | 
					
						
							|  |  |  |   else if (strcmp (name, "ext2") == 0) | 
					
						
							|  |  |  |     error = Curve_setExt2 (self, valtuple); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   else { /* Error */ | 
					
						
							|  |  |  |     Py_DECREF(valtuple); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if ((strcmp (name, "Types") == 0) ||  | 
					
						
							|  |  |  |         (strcmp (name, "Modes") == 0))    | 
					
						
							|  |  |  |       return (EXPP_ReturnIntError (PyExc_AttributeError, | 
					
						
							|  |  |  |                    "constant dictionary -- cannot be changed")); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     else  | 
					
						
							|  |  |  |       return (EXPP_ReturnIntError (PyExc_KeyError, | 
					
						
							|  |  |  |                    "attribute not found")); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Py_DECREF(valtuple); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (error != Py_None) return -1; | 
					
						
							|  |  |  |   Py_DECREF(Py_None); | 
					
						
							|  |  |  |   return 0;  | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Function:    CurvePrint                                                   */ | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | /* Description: This is a callback function for the BPy_Curve type. It         */ | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | /*              builds a meaninful string to 'print' curve objects.          */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-07-04 16:09:34 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static int CurvePrint(BPy_Curve *self, FILE *fp, int flags) //print
 | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | {  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   fprintf(fp, "[Curve \"%s\"]\n", self->curve->id.name+2); | 
					
						
							| 
									
										
										
										
											2003-06-21 20:44:44 +00:00
										 |  |  |   	 | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  |   return 0; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2003-07-04 16:09:34 +00:00
										 |  |  | */ | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Function:    CurveRepr                                                    */ | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | /* Description: This is a callback function for the BPy_Curve type. It         */ | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | /*              builds a meaninful string to represent curve objects.        */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  | static PyObject *CurveRepr (BPy_Curve *self) //used by 'repr'
 | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | { | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2003-07-04 16:09:34 +00:00
										 |  |  |   return PyString_FromFormat("[Curve \"%s\"]", self->curve->id.name+2); | 
					
						
							| 
									
										
										
										
											2003-05-17 07:08:08 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2003-05-20 03:53:30 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | PyObject* CurveCreatePyObject (struct Curve *curve) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  |  BPy_Curve    * blen_object; | 
					
						
							| 
									
										
										
										
											2003-05-20 03:53:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  |     blen_object = (BPy_Curve*)PyObject_NEW (BPy_Curve, &Curve_Type); | 
					
						
							| 
									
										
										
										
											2003-05-20 03:53:30 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (blen_object == NULL) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return (NULL); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     blen_object->curve = curve; | 
					
						
							|  |  |  |     return ((PyObject*)blen_object); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int CurveCheckPyObject (PyObject *py_obj) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2003-05-29 04:00:35 +00:00
										 |  |  | return (py_obj->ob_type == &Curve_Type); | 
					
						
							| 
									
										
										
										
											2003-05-20 03:53:30 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-05-29 04:00:35 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-05-20 03:53:30 +00:00
										 |  |  | struct Curve* CurveFromPyObject (PyObject *py_obj) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  |  BPy_Curve    * blen_obj; | 
					
						
							| 
									
										
										
										
											2003-05-20 03:53:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2003-06-27 07:35:55 +00:00
										 |  |  |     blen_obj = (BPy_Curve*)py_obj; | 
					
						
							| 
									
										
										
										
											2003-05-20 03:53:30 +00:00
										 |  |  |     return (blen_obj->curve); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2003-05-29 04:00:35 +00:00
										 |  |  | 
 |