| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * $Id$ | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ***** 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): Joilnen Leite | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  |  *                 Johnny Matthews | 
					
						
							| 
									
										
										
										
											2007-03-03 14:05:36 +00:00
										 |  |  |  *                 Campbell BArton | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * ***** END GPL/BL DUAL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2007-03-26 02:10:24 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-07-18 03:50:37 +00:00
										 |  |  | #include "Text3d.h" /*This must come first*/
 | 
					
						
							|  |  |  |   | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | #include "DNA_object_types.h"
 | 
					
						
							| 
									
										
										
										
											2005-03-09 19:45:59 +00:00
										 |  |  | #include "MEM_guardedalloc.h"
 | 
					
						
							| 
									
										
										
										
											2005-07-18 03:50:37 +00:00
										 |  |  | #include "BKE_curve.h"
 | 
					
						
							|  |  |  | #include "BKE_library.h"
 | 
					
						
							|  |  |  | #include "BKE_global.h"
 | 
					
						
							|  |  |  | #include "BKE_main.h"
 | 
					
						
							| 
									
										
										
										
											2005-12-07 05:44:29 +00:00
										 |  |  | #include "BIF_editfont.h"	/* do_textedit() */
 | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | #include "Curve.h"
 | 
					
						
							|  |  |  | #include "constant.h"
 | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | #include "Font.h"
 | 
					
						
							| 
									
										
										
										
											2005-07-18 03:50:37 +00:00
										 |  |  | #include "gen_utils.h"
 | 
					
						
							| 
									
										
										
										
											2007-03-11 04:05:45 +00:00
										 |  |  | #include "gen_library.h"
 | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-03 14:05:36 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | enum t3d_consts { | 
					
						
							|  |  |  | 	EXPP_T3D_ATTR_FRAME_WIDTH = 0, | 
					
						
							|  |  |  | 	EXPP_T3D_ATTR_FRAME_HEIGHT, | 
					
						
							|  |  |  | 	EXPP_T3D_ATTR_FRAME_X, | 
					
						
							|  |  |  | 	EXPP_T3D_ATTR_FRAME_Y | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*no prototypes declared in header files - external linkage outside of python*/ | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | extern VFont *get_builtin_font(void);   | 
					
						
							|  |  |  | extern void freedisplist(struct ListBase *lb); | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | extern VFont *give_vfontpointer(int); | 
					
						
							|  |  |  | extern VFont *exist_vfont(char *str); | 
					
						
							|  |  |  | extern VFont *load_vfont(char *name); | 
					
						
							|  |  |  | extern int BLI_exist(char *name); | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | /* Python API function prototypes for the Text3D module.                     */ | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | static PyObject *M_Text3d_New( PyObject * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *M_Text3d_Get( PyObject * self, PyObject * args ); | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | PyObject *M_Text3d_LoadFont (PyObject * self, PyObject * args ); | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-26 18:14:29 +00:00
										 |  |  | /*****************************************************************************
 | 
					
						
							|  |  |  |  * Python callback function prototypes for the Text3D module.   | 
					
						
							|  |  |  |  *****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | static PyObject *return_ModuleConstant( char *constant_name); | 
					
						
							|  |  |  | static PyObject *generate_ModuleIntConstant(char *name, int value); | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | /* Python method structure definition for Blender.Text3d module:             */ | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | struct PyMethodDef M_Text3d_methods[] = { | 
					
						
							|  |  |  | 	{"New", ( PyCFunction ) M_Text3d_New, METH_VARARGS, NULL}, | 
					
						
							|  |  |  | 	{"Get", ( PyCFunction ) M_Text3d_Get, METH_VARARGS, NULL}, | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	{"LoadFont", ( PyCFunction ) M_Text3d_LoadFont, METH_O, NULL}, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	{NULL, NULL, 0, NULL} | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Python Text3d_Type callback function prototypes:                          */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | /* int Text3dPrint (BPy_Text3d *msh, FILE *fp, int flags); */ | 
					
						
							| 
									
										
										
										
											2007-02-25 17:38:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Text3d_repr( BPy_Text3d * self ); | 
					
						
							|  |  |  | static int Text3d_compare( BPy_Text3d * a, BPy_Text3d * b ); | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Python BPy_Text3d methods declarations:                                   */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /*PyObject *Text3d_getType(BPy_Text3d *self);*/ | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | static PyObject *Text3d_getName( BPy_Text3d * self ); | 
					
						
							|  |  |  | static PyObject *Text3d_setName( BPy_Text3d * self, PyObject * args ); | 
					
						
							| 
									
										
										
										
											2007-06-16 13:17:41 +00:00
										 |  |  | static PyObject *Text3d_setText( BPy_Text3d * self, PyObject * value ); | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | static PyObject *Text3d_getText( BPy_Text3d * self ); | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | static PyObject *Text3d_getDrawMode( BPy_Text3d * self ); | 
					
						
							|  |  |  | static PyObject *Text3d_setDrawMode( BPy_Text3d * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *Text3d_getUVorco( BPy_Text3d * self ); | 
					
						
							|  |  |  | static PyObject *Text3d_setUVorco( BPy_Text3d * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *Text3d_getBevelAmount( BPy_Text3d * self ); | 
					
						
							|  |  |  | static PyObject *Text3d_setBevelAmount( BPy_Text3d * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *Text3d_getDefaultResolution( BPy_Text3d * self ); | 
					
						
							|  |  |  | static PyObject *Text3d_setDefaultResolution( BPy_Text3d * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *Text3d_getWidth( BPy_Text3d * self ); | 
					
						
							|  |  |  | static PyObject *Text3d_setWidth( BPy_Text3d * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *Text3d_getExtrudeDepth( BPy_Text3d * self ); | 
					
						
							|  |  |  | static PyObject *Text3d_setExtrudeDepth( BPy_Text3d * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *Text3d_getExtrudeBevelDepth( BPy_Text3d * self ); | 
					
						
							|  |  |  | static PyObject *Text3d_setExtrudeBevelDepth( BPy_Text3d * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *Text3d_getShear( BPy_Text3d * self ); | 
					
						
							|  |  |  | static PyObject *Text3d_setShear( BPy_Text3d * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *Text3d_getSize( BPy_Text3d * self ); | 
					
						
							|  |  |  | static PyObject *Text3d_setSize( BPy_Text3d * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *Text3d_getLineSeparation( BPy_Text3d * self ); | 
					
						
							|  |  |  | static PyObject *Text3d_setLineSeparation( BPy_Text3d * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *Text3d_getSpacing( BPy_Text3d * self ); | 
					
						
							|  |  |  | static PyObject *Text3d_setSpacing( BPy_Text3d * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *Text3d_getXoffset( BPy_Text3d * self ); | 
					
						
							|  |  |  | static PyObject *Text3d_setXoffset( BPy_Text3d * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *Text3d_getYoffset( BPy_Text3d * self ); | 
					
						
							|  |  |  | static PyObject *Text3d_setYoffset( BPy_Text3d * self, PyObject * args ); | 
					
						
							|  |  |  | static PyObject *Text3d_getAlignment( BPy_Text3d * self ); | 
					
						
							|  |  |  | static PyObject *Text3d_setAlignment( BPy_Text3d * self, PyObject * args ); | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | static PyObject *Text3d_getFont( BPy_Text3d * self ); | 
					
						
							|  |  |  | static PyObject *Text3d_setFont( BPy_Text3d * self, PyObject * args ); | 
					
						
							| 
									
										
										
										
											2007-03-03 14:05:36 +00:00
										 |  |  | static PyObject *Text3d_addFrame( BPy_Text3d * self ); | 
					
						
							|  |  |  | static PyObject *Text3d_removeFrame( BPy_Text3d * self, PyObject * args ); | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Python BPy_Text3d methods table:                                            */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | char M_Text3D_doc[] = "The Blender Text3D module\n\n\
 | 
					
						
							|  |  |  | 	This module provides control over Text Curve objects in Blender.\n"; | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyMethodDef BPy_Text3d_methods[] = { | 
					
						
							|  |  |  | 	{"getName", ( PyCFunction ) Text3d_getName, | 
					
						
							|  |  |  | 	 METH_NOARGS, "() - Return Text3d Data name"}, | 
					
						
							|  |  |  | 	{"setName", ( PyCFunction ) Text3d_setName, | 
					
						
							|  |  |  | 	 METH_VARARGS, "() - Sets Text3d Data name"}, | 
					
						
							|  |  |  | 	{"setText", ( PyCFunction ) Text3d_setText, | 
					
						
							| 
									
										
										
										
											2007-06-28 13:46:42 +00:00
										 |  |  | 	 METH_O, "() - Sets Text3d Data"}, | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | 	{"getText", ( PyCFunction ) Text3d_getText, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	 METH_NOARGS, "() - Gets Text3d Data"},		  | 
					
						
							|  |  |  | 	{"getDrawMode", ( PyCFunction ) Text3d_getDrawMode, | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	METH_NOARGS, "() - Return the font drawing mode"}, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	{"setDrawMode", ( PyCFunction ) Text3d_setDrawMode, | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	METH_VARARGS, "(int) - Set the font drawing mode"}, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  |  	{"getUVorco", ( PyCFunction ) Text3d_getUVorco, | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	METH_NOARGS, "() - Return wether UV coords are used for Texture mapping"}, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	{"setUVorco", ( PyCFunction ) Text3d_setUVorco, | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	METH_VARARGS, "() - Set the font to use UV coords for Texture mapping"}, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	{"getBevelAmount", ( PyCFunction ) Text3d_getBevelAmount, | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	METH_NOARGS, "() - Return bevel resolution"}, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	{"setBevelAmount", ( PyCFunction ) Text3d_setBevelAmount, | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	METH_VARARGS, "() - Sets bevel resolution"}, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	{"getDefaultResolution", ( PyCFunction ) Text3d_getDefaultResolution, | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	METH_NOARGS, "() - Return Default text resolution"}, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	{"setDefaultResolution", ( PyCFunction ) Text3d_setDefaultResolution, | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	METH_VARARGS, "() - Sets Default text Resolution"}, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	{"getWidth", ( PyCFunction ) Text3d_getWidth, | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	METH_NOARGS, "() - Return curve width"}, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	{"setWidth", ( PyCFunction ) Text3d_setWidth, | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	METH_VARARGS, "(int) - Sets curve width"}, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	{"getExtrudeDepth", ( PyCFunction ) Text3d_getExtrudeDepth, | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	METH_NOARGS, "() - Gets Text3d ExtrudeDepth"}, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	{"setExtrudeDepth", ( PyCFunction ) Text3d_setExtrudeDepth, | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	METH_VARARGS, "() - Sets Text3d ExtrudeDepth"}, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	{"getExtrudeBevelDepth", ( PyCFunction ) Text3d_getExtrudeBevelDepth, | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	METH_NOARGS, "() - Gets Text3d ExtrudeBevelDepth"}, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	{"setExtrudeBevelDepth", ( PyCFunction ) Text3d_setExtrudeBevelDepth, | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	METH_VARARGS, "() - Sets Text3d ExtrudeBevelDepth"}, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	{"getShear", ( PyCFunction ) Text3d_getShear, | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	METH_NOARGS, "() - Gets Text3d Shear Data"}, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	{"setShear", ( PyCFunction ) Text3d_setShear, | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	METH_VARARGS, "() - Sets Text3d Shear Data"}, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  |  	{"getSize", ( PyCFunction ) Text3d_getSize, | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	METH_NOARGS, "() - Gets Text3d Size Data"}, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	{"setSize", ( PyCFunction ) Text3d_setSize, | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	METH_VARARGS, "() - Sets Text3d Size Data"}, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  |  	{"getLineSeparation", ( PyCFunction ) Text3d_getLineSeparation, | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	METH_NOARGS, "() - Gets Text3d LineSeparation Data"}, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	{"setLineSeparation", ( PyCFunction ) Text3d_setLineSeparation, | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	METH_VARARGS, "() - Sets Text3d LineSeparation Data"}, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  |  	{"getSpacing", ( PyCFunction ) Text3d_getSpacing, | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	METH_NOARGS, "() - Gets Text3d letter spacing"}, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	{"setSpacing", ( PyCFunction ) Text3d_setSpacing, | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	METH_VARARGS, "() - Sets Text3d letter spacing"}, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  |  	{"getXoffset", ( PyCFunction ) Text3d_getXoffset, | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	METH_NOARGS, "() - Gets Text3d Xoffset Data"}, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	{"setXoffset", ( PyCFunction ) Text3d_setXoffset, | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	METH_VARARGS, "() - Sets Text3d Xoffset Data"}, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  |  	{"getYoffset", ( PyCFunction ) Text3d_getYoffset, | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	METH_NOARGS, "() - Gets Text3d Yoffset Data"}, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	{"setYoffset", ( PyCFunction ) Text3d_setYoffset, | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	METH_VARARGS, "() - Sets Text3d Yoffset Data"}, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  |  	{"getAlignment", ( PyCFunction ) Text3d_getAlignment, | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	METH_NOARGS, "() - Gets Text3d Alignment Data"}, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	{"setAlignment", ( PyCFunction ) Text3d_setAlignment, | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	METH_VARARGS, "() - Sets Text3d Alignment Data"}, | 
					
						
							|  |  |  |  	{"getFont", ( PyCFunction ) Text3d_getFont, | 
					
						
							|  |  |  | 	METH_NOARGS, "() - Gets font list for Text3d"}, | 
					
						
							|  |  |  |  	{"setFont", ( PyCFunction ) Text3d_setFont, | 
					
						
							|  |  |  |  	METH_VARARGS, "() - Sets font for Text3d"}, | 
					
						
							| 
									
										
										
										
											2007-03-03 14:05:36 +00:00
										 |  |  |  	{"addFrame", ( PyCFunction ) Text3d_addFrame, | 
					
						
							|  |  |  |  	METH_NOARGS, "() - adds a new text frame"}, | 
					
						
							|  |  |  |  	{"removeFrame", ( PyCFunction ) Text3d_removeFrame, | 
					
						
							|  |  |  |  	METH_VARARGS, "(index) - remove this frame"}, | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	{NULL, NULL, 0, NULL} | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-03 14:05:36 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Text3d_getTotalFrames( BPy_Text3d * self ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return PyInt_FromLong( (long)(self->curve->totbox ) ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Text3d_getActiveFrame( BPy_Text3d * self ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return PyInt_FromLong( (long)(self->curve->actbox-1) ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int Text3d_setActiveFrame( BPy_Text3d * self, PyObject * value ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct Curve *curve= self->curve;	 | 
					
						
							|  |  |  | 	PyObject* frame_int = PyNumber_Int( value ); | 
					
						
							|  |  |  | 	int index; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( !frame_int ) | 
					
						
							|  |  |  | 		return EXPP_ReturnIntError( PyExc_TypeError, | 
					
						
							|  |  |  | 				"expected integer argument" ); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	index = ( int )PyInt_AS_LONG( frame_int ); | 
					
						
							|  |  |  | 	index ++; | 
					
						
							|  |  |  | 	if (index < 1 || index > curve->totbox) | 
					
						
							|  |  |  | 		return EXPP_ReturnIntError( PyExc_IndexError, | 
					
						
							|  |  |  | 				"index out of range" ); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	curve->actbox = index; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *getFloatAttr( BPy_Text3d *self, void *type ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	float param; | 
					
						
							|  |  |  | 	struct Curve *curve= self->curve; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	switch( (int)type ) { | 
					
						
							|  |  |  | 	case EXPP_T3D_ATTR_FRAME_WIDTH:  | 
					
						
							|  |  |  | 		param = curve->tb[curve->actbox-1].w; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case EXPP_T3D_ATTR_FRAME_HEIGHT:  | 
					
						
							|  |  |  | 		param = curve->tb[curve->actbox-1].h; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case EXPP_T3D_ATTR_FRAME_X:  | 
					
						
							|  |  |  | 		param = curve->tb[curve->actbox-1].x; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case EXPP_T3D_ATTR_FRAME_Y:  | 
					
						
							|  |  |  | 		param = curve->tb[curve->actbox-1].y; | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_RuntimeError,  | 
					
						
							|  |  |  | 				"undefined type in getFloatAttr" ); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return PyFloat_FromDouble( param ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int setFloatAttrClamp( BPy_Text3d *self, PyObject *value, void *type ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	float *param; | 
					
						
							|  |  |  | 	struct Curve *curve= self->curve; | 
					
						
							|  |  |  | 	float min, max; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	switch( (int)type ) { | 
					
						
							|  |  |  | 	case EXPP_T3D_ATTR_FRAME_WIDTH: | 
					
						
							|  |  |  | 		min = 0.0; | 
					
						
							|  |  |  | 		max = 50.0; | 
					
						
							|  |  |  | 		param = &(curve->tb[curve->actbox-1].w); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case EXPP_T3D_ATTR_FRAME_HEIGHT: | 
					
						
							|  |  |  | 		min = 0.0; | 
					
						
							|  |  |  | 		max = 50.0; | 
					
						
							|  |  |  | 		param = &(curve->tb[curve->actbox-1].h); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case EXPP_T3D_ATTR_FRAME_X: | 
					
						
							|  |  |  | 		min = 0.0; | 
					
						
							|  |  |  | 		max = 50.0; | 
					
						
							|  |  |  | 		param = &(curve->tb[curve->actbox-1].x); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	case EXPP_T3D_ATTR_FRAME_Y: | 
					
						
							|  |  |  | 		min = 0.0; | 
					
						
							|  |  |  | 		max = 50.0; | 
					
						
							|  |  |  | 		param = &(curve->tb[curve->actbox-1].y); | 
					
						
							|  |  |  | 		break; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	default: | 
					
						
							|  |  |  | 		return EXPP_ReturnIntError( PyExc_RuntimeError, | 
					
						
							|  |  |  | 				"undefined type in setFloatAttrClamp" ); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return EXPP_setFloatClamped( value, param, min, max ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-02-25 17:38:22 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Python attributes get/set structure:                                      */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | static PyGetSetDef BPy_Text3d_getseters[] = { | 
					
						
							|  |  |  | 	GENERIC_LIB_GETSETATTR, /* didnt have any attributes, at least lets have the standard ID attrs */ | 
					
						
							| 
									
										
										
										
											2007-03-03 14:05:36 +00:00
										 |  |  | 	{"activeFrame", | 
					
						
							|  |  |  | 	 (getter)Text3d_getActiveFrame, (setter)Text3d_setActiveFrame, | 
					
						
							|  |  |  | 	 "the index of the active text frame", | 
					
						
							|  |  |  | 	 NULL}, | 
					
						
							|  |  |  | 	{"totalFrames", | 
					
						
							|  |  |  | 	 (getter)Text3d_getTotalFrames, (setter)NULL, | 
					
						
							|  |  |  | 	 "the total number of text frames", | 
					
						
							|  |  |  | 	 NULL}, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	{"frameWidth", | 
					
						
							|  |  |  | 	 (getter)getFloatAttr, (setter)setFloatAttrClamp, | 
					
						
							|  |  |  | 	 "the width of the active text frame", | 
					
						
							|  |  |  | 	 (void *)EXPP_T3D_ATTR_FRAME_WIDTH}, | 
					
						
							|  |  |  | 	{"frameHeight", | 
					
						
							|  |  |  | 	 (getter)getFloatAttr, (setter)setFloatAttrClamp, | 
					
						
							|  |  |  | 	 "the height of the active text frame", | 
					
						
							|  |  |  | 	 (void *)EXPP_T3D_ATTR_FRAME_HEIGHT}, | 
					
						
							|  |  |  | 	{"frameX", | 
					
						
							|  |  |  | 	 (getter)getFloatAttr, (setter)setFloatAttrClamp, | 
					
						
							|  |  |  | 	 "the X position of the active text frame", | 
					
						
							|  |  |  | 	 (void *)EXPP_T3D_ATTR_FRAME_X}, | 
					
						
							|  |  |  | 	{"frameY", | 
					
						
							|  |  |  | 	 (getter)getFloatAttr, (setter)setFloatAttrClamp, | 
					
						
							|  |  |  | 	 "the Y position of the active text frame", | 
					
						
							|  |  |  | 	 (void *)EXPP_T3D_ATTR_FRAME_Y}, | 
					
						
							| 
									
										
										
										
											2007-02-25 17:38:22 +00:00
										 |  |  | 	{NULL,NULL,NULL,NULL,NULL}  /* Sentinel */ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Python Text3d_Type structure definition:                                  */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | PyTypeObject Text3d_Type = { | 
					
						
							|  |  |  | 	PyObject_HEAD_INIT( NULL ) | 
					
						
							|  |  |  | 	0,		/* ob_size */ | 
					
						
							|  |  |  | 	"Text3d",		/* tp_name */ | 
					
						
							|  |  |  | 	sizeof( BPy_Text3d ),	/* tp_basicsize */ | 
					
						
							|  |  |  | 	0,			/* tp_itemsize */ | 
					
						
							|  |  |  | 	/* methods */ | 
					
						
							| 
									
										
										
										
											2007-03-15 01:47:53 +00:00
										 |  |  | 	NULL,			/* tp_dealloc */ | 
					
						
							| 
									
										
										
										
											2007-02-25 17:38:22 +00:00
										 |  |  | 	NULL,			/* tp_print */ | 
					
						
							| 
									
										
										
										
											2007-03-15 01:47:53 +00:00
										 |  |  | 	NULL,			/* tp_getattr */ | 
					
						
							|  |  |  | 	NULL,			/* tp_setattr */ | 
					
						
							| 
									
										
										
										
											2007-02-25 17:38:22 +00:00
										 |  |  | 	( cmpfunc ) Text3d_compare,			/* tp_compare */ | 
					
						
							|  |  |  | 	( reprfunc ) Text3d_repr,	/* tp_repr */ | 
					
						
							|  |  |  | 	/* Method suites for standard classes */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	NULL,                       /* PyNumberMethods *tp_as_number; */ | 
					
						
							|  |  |  | 	NULL,                       /* PySequenceMethods *tp_as_sequence; */ | 
					
						
							|  |  |  | 	NULL,                       /* PyMappingMethods *tp_as_mapping; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* More standard operations (here for binary compatibility) */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-26 02:10:24 +00:00
										 |  |  | 	( hashfunc ) GenericLib_hash,	/* hashfunc tp_hash; */ | 
					
						
							| 
									
										
										
										
											2007-02-25 17:38:22 +00:00
										 |  |  | 	NULL,                       /* ternaryfunc tp_call; */ | 
					
						
							|  |  |  | 	NULL,                       /* reprfunc tp_str; */ | 
					
						
							|  |  |  | 	NULL,                       /* getattrofunc tp_getattro; */ | 
					
						
							|  |  |  | 	NULL,                       /* setattrofunc tp_setattro; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Functions to access object as input/output buffer */ | 
					
						
							|  |  |  | 	NULL,                       /* PyBufferProcs *tp_as_buffer; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /*** Flags to define presence of optional/expanded features ***/ | 
					
						
							|  |  |  | 	Py_TPFLAGS_DEFAULT,         /* long tp_flags; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	NULL,                       /*  char *tp_doc;  Documentation string */ | 
					
						
							|  |  |  |   /*** Assigned meaning in release 2.0 ***/ | 
					
						
							|  |  |  | 	/* call function for all accessible objects */ | 
					
						
							|  |  |  | 	NULL,                       /* traverseproc tp_traverse; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* delete references to contained objects */ | 
					
						
							|  |  |  | 	NULL,                       /* inquiry tp_clear; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /***  Assigned meaning in release 2.1 ***/ | 
					
						
							|  |  |  |   /*** rich comparisons ***/ | 
					
						
							|  |  |  | 	NULL,                       /* richcmpfunc tp_richcompare; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /***  weak reference enabler ***/ | 
					
						
							|  |  |  | 	0,                          /* long tp_weaklistoffset; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /*** Added in release 2.2 ***/ | 
					
						
							|  |  |  | 	/*   Iterators */ | 
					
						
							|  |  |  | 	NULL,                       /* getiterfunc tp_iter; */ | 
					
						
							|  |  |  | 	NULL,                       /* iternextfunc tp_iternext; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /*** Attribute descriptor and subclassing stuff ***/ | 
					
						
							|  |  |  | 	BPy_Text3d_methods,           /* struct PyMethodDef *tp_methods; */ | 
					
						
							|  |  |  | 	NULL,                       /* struct PyMemberDef *tp_members; */ | 
					
						
							|  |  |  | 	BPy_Text3d_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 | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-02-25 17:38:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | /* 
 | 
					
						
							|  |  |  |  *   Text3d_update( ) | 
					
						
							|  |  |  |  *   method to update display list for a Curve. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | static PyObject *Text3d_update( BPy_Text3d * self ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	freedisplist( &self->curve->disp ); | 
					
						
							| 
									
										
										
										
											2006-12-27 05:04:20 +00:00
										 |  |  | 	Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | /* Function:              M_Text3d_New                                       */ | 
					
						
							|  |  |  | /* Python equivalent:     Blender.Text3d.New                                 */ | 
					
						
							|  |  |  | /*****************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyObject *M_Text3d_New( PyObject * self, PyObject * args ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	char *name = NULL; | 
					
						
							|  |  |  | 	BPy_Text3d *pytext3d;	/* for Curve Data object wrapper in Python */ | 
					
						
							|  |  |  | 	Text3d *bltext3d = 0;	/* for actual Curve Data we create in Blender */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( !PyArg_ParseTuple( args, "|s", &name ) ) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError | 
					
						
							|  |  |  | 			 ( PyExc_AttributeError, | 
					
						
							|  |  |  | 			   "expected string argument or no argument" ) ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-11 16:25:17 +00:00
										 |  |  | 	bltext3d = add_curve( "Text", OB_FONT );	/* first create the Curve Data in Blender */ | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | 	bltext3d->vfont= get_builtin_font(); | 
					
						
							|  |  |  | 	bltext3d->vfont->id.us++; | 
					
						
							|  |  |  | 	bltext3d->str= MEM_mallocN(12, "str"); | 
					
						
							|  |  |  | 	strcpy(bltext3d->str, "Text"); | 
					
						
							|  |  |  | 	bltext3d->pos= 4; | 
					
						
							| 
									
										
										
										
											2005-09-29 15:46:06 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	bltext3d->strinfo= MEM_callocN(12*sizeof(CharInfo), "strinfo"); | 
					
						
							|  |  |  | 	bltext3d->totbox= bltext3d->actbox= 1; | 
					
						
							|  |  |  | 	bltext3d->tb= MEM_callocN(MAXTEXTBOX*sizeof(TextBox), "textbox"); | 
					
						
							|  |  |  | 	bltext3d->tb[0].w = bltext3d->tb[0].h = 0.0; | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	if( bltext3d == NULL )	/* bail out if add_curve() failed */ | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError | 
					
						
							|  |  |  | 			 ( PyExc_RuntimeError, | 
					
						
							|  |  |  | 			   "couldn't create Curve Data in Blender" ) ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* return user count to zero because add_curve() inc'd it */ | 
					
						
							|  |  |  | 	bltext3d->id.us = 0; | 
					
						
							|  |  |  | 	/* create python wrapper obj */ | 
					
						
							|  |  |  | 	pytext3d = ( BPy_Text3d * ) PyObject_NEW( BPy_Text3d, &Text3d_Type ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( pytext3d == NULL ) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError | 
					
						
							|  |  |  | 			 ( PyExc_MemoryError, | 
					
						
							|  |  |  | 			   "couldn't create Curve Data object" ) ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	pytext3d->curve = bltext3d;	/* link Python curve wrapper to Blender Curve */ | 
					
						
							| 
									
										
										
										
											2006-12-27 05:04:20 +00:00
										 |  |  | 	if( name ) | 
					
						
							|  |  |  | 		rename_id( &bltext3d->id, name ); | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | 	Text3d_update ( pytext3d ); | 
					
						
							|  |  |  | 	return ( PyObject * ) pytext3d; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyObject *M_Text3d_Get( PyObject * self, PyObject * args ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	char *name = NULL; | 
					
						
							|  |  |  | 	Text3d *curv_iter; | 
					
						
							|  |  |  | 	BPy_Text3d *wanted_curv; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( !PyArg_ParseTuple( args, "|s", &name ) )	/* expects nothing or a string */ | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 						"expected string argument" ) ); | 
					
						
							|  |  |  | 	if( name ) {		/*a name has been given */ | 
					
						
							|  |  |  | 		/* 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 ) { | 
					
						
							|  |  |  | 				wanted_curv = ( BPy_Text3d * ) | 
					
						
							|  |  |  | 					PyObject_NEW( BPy_Text3d, &Text3d_Type ); | 
					
						
							|  |  |  | 				if( wanted_curv ) | 
					
						
							|  |  |  | 					wanted_curv->curve = curv_iter; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			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; | 
					
						
							|  |  |  | 	} /* end  of if(name) */ | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		/* no name has been given; return a list of all curves by name.  */ | 
					
						
							|  |  |  | 		PyObject *curvlist; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		curv_iter = G.main->curve.first; | 
					
						
							|  |  |  | 		curvlist = PyList_New( 0 ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if( curvlist == NULL ) | 
					
						
							|  |  |  | 			return ( EXPP_ReturnPyObjError( PyExc_MemoryError, | 
					
						
							|  |  |  | 							"couldn't create PyList" ) ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		while( curv_iter && curv_iter->vfont ) { | 
					
						
							|  |  |  | 			BPy_Text3d *found_text3d = | 
					
						
							|  |  |  | 				( BPy_Text3d * ) PyObject_NEW( BPy_Text3d, | 
					
						
							|  |  |  | 							      &Text3d_Type ); | 
					
						
							|  |  |  | 			found_text3d->curve = curv_iter; | 
					
						
							|  |  |  | 			PyList_Append( curvlist, ( PyObject * ) found_text3d ); | 
					
						
							| 
									
										
										
										
											2007-05-25 16:43:25 +00:00
										 |  |  | 			Py_DECREF(found_text3d); | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | 			curv_iter = curv_iter->id.next; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		return ( curvlist ); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | static PyObject *generate_ModuleIntConstant(char *name, int value) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2005-08-17 14:26:00 +00:00
										 |  |  | 	PyObject *constant = PyConstant_New(); | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-08-17 14:26:00 +00:00
										 |  |  | 	PyConstant_Insert((BPy_constant*)constant,  | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 		"value", PyInt_FromLong(value)); | 
					
						
							| 
									
										
										
										
											2005-08-17 14:26:00 +00:00
										 |  |  | 	PyConstant_Insert((BPy_constant*)constant,  | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 		"name", PyString_FromString(name)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Py_INCREF(constant); | 
					
						
							|  |  |  | 	return constant; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | PyObject *Text3d_Init( void ) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	//module
 | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	PyObject *submodule, *dict; | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	//add module...
 | 
					
						
							| 
									
										
										
										
											2007-02-25 17:38:22 +00:00
										 |  |  | 	if( PyType_Ready( &Text3d_Type ) < 0 ) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	submodule = Py_InitModule3( "Blender.Text3d", M_Text3d_methods,  | 
					
						
							|  |  |  | 		M_Text3D_doc); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	//add constants to module...
 | 
					
						
							|  |  |  | 	PyModule_AddObject( submodule, "LEFT",  | 
					
						
							|  |  |  | 		generate_ModuleIntConstant("Text3d.LEFT", CU_LEFT)); | 
					
						
							|  |  |  | 	PyModule_AddObject( submodule, "MIDDLE",  | 
					
						
							|  |  |  | 		generate_ModuleIntConstant("Text3d.MIDDLE", CU_MIDDLE)); | 
					
						
							|  |  |  | 	PyModule_AddObject( submodule, "RIGHT", | 
					
						
							|  |  |  | 		generate_ModuleIntConstant("Text3d.RIGHT", CU_RIGHT)); | 
					
						
							|  |  |  | 	PyModule_AddObject( submodule, "FLUSH", | 
					
						
							|  |  |  | 		generate_ModuleIntConstant("Text3d.FLUSH", CU_FLUSH)); | 
					
						
							| 
									
										
										
										
											2007-05-28 17:06:03 +00:00
										 |  |  | 	PyModule_AddObject( submodule, "JUSTIFY", | 
					
						
							|  |  |  | 		generate_ModuleIntConstant("Text3d.JUSTIFY", CU_JUSTIFY)); | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	PyModule_AddObject( submodule, "DRAW3D", | 
					
						
							|  |  |  | 		generate_ModuleIntConstant("Text3d.DRAW3D", CU_3D)); | 
					
						
							|  |  |  | 	PyModule_AddObject( submodule, "DRAWFRONT", | 
					
						
							|  |  |  | 		generate_ModuleIntConstant("Text3d.DRAWFRONT", CU_FRONT)); | 
					
						
							|  |  |  | 	PyModule_AddObject( submodule, "DRAWBACK", | 
					
						
							|  |  |  | 		generate_ModuleIntConstant("Text3d.DRAWBACK", CU_BACK)); | 
					
						
							|  |  |  | 	PyModule_AddObject( submodule, "UVORCO", | 
					
						
							|  |  |  | 		generate_ModuleIntConstant("Text3d.UVORCO", CU_UV_ORCO)); | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	dict = PyModule_GetDict( submodule ); | 
					
						
							|  |  |  | 	PyDict_SetItemString( dict, "Font", Font_Init(  ) ); | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | 	return ( submodule ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-07-01 16:59:10 +00:00
										 |  |  | /****************************************************************************
 | 
					
						
							| 
									
										
										
										
											2007-02-25 17:38:22 +00:00
										 |  |  |  * Function:    Text3d_repr                                                    | 
					
						
							| 
									
										
										
										
											2006-07-01 16:59:10 +00:00
										 |  |  |  * Description: Callback function for the BPy_Text3d type to It       | 
					
						
							|  |  |  |  *               build a meaninful string to represent Text3d objects.       | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  ***************************************************************************/ | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-02-25 17:38:22 +00:00
										 |  |  | static PyObject *Text3d_repr( BPy_Text3d * self ) | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2006-07-01 16:59:10 +00:00
										 |  |  | 	/* skip over CU in idname.  CUTEXT */ | 
					
						
							|  |  |  | 	return PyString_FromFormat( "[Text3d \"%s\"]", | 
					
						
							|  |  |  | 								self->curve->id.name + 2 );  | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-02-25 17:38:22 +00:00
										 |  |  | /****************************************************************************
 | 
					
						
							|  |  |  |  * Function:    Text3d_compare                                                    | 
					
						
							|  |  |  |  * Description: Callback function for the BPy_Text3d type to Compare 2 types | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  ***************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* mat_a==mat_b or mat_a!=mat_b*/ | 
					
						
							|  |  |  | static int Text3d_compare( BPy_Text3d * a, BPy_Text3d * b ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return ( a->curve == b->curve) ? 0 : -1; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | struct Text3d *Text3d_FromPyObject( PyObject * py_obj ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	BPy_Text3d *blen_obj; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	blen_obj = ( BPy_Text3d * ) py_obj; | 
					
						
							| 
									
										
										
										
											2005-03-09 19:45:59 +00:00
										 |  |  | 	return ((struct Text3d*) blen_obj->curve ); | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | static PyObject *return_ModuleConstant( char *constant_name){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	PyObject *module = NULL, *dict = NULL, *constant = NULL;; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	module = PyImport_AddModule("Blender.Text3d"); | 
					
						
							|  |  |  | 	if(!module){	//null = error returning module
 | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, | 
					
						
							|  |  |  | 			"error encountered with returning module constant..." ) ); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	dict = PyModule_GetDict(module); //never fails
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	constant = PyDict_GetItemString(dict, constant_name); | 
					
						
							|  |  |  | 	if(!constant){	//null = key not found
 | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, | 
					
						
							|  |  |  | 			"error encountered with returning module constant..." ) ); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	return EXPP_incr_ret( constant ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | static PyObject *Text3d_getName( BPy_Text3d * self ) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	return Curve_getName( (BPy_Curve*)self ); | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Text3d_setName( BPy_Text3d * self, PyObject * args ) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	return Curve_setName( (BPy_Curve*)self,args ); | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-16 13:17:41 +00:00
										 |  |  | static PyObject *Text3d_setText( BPy_Text3d * self, PyObject * value ) | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2007-06-16 13:17:41 +00:00
										 |  |  | 	char *text = PyString_AsString(value); | 
					
						
							| 
									
										
										
										
											2005-12-07 05:44:29 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-16 13:17:41 +00:00
										 |  |  | 	if( !text ) | 
					
						
							| 
									
										
										
										
											2005-12-07 05:44:29 +00:00
										 |  |  | 		return EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 				"expected string argument" ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/*
 | 
					
						
							|  |  |  | 	 * If the text is currently being edited, then we have to put the | 
					
						
							|  |  |  | 	 * text into the edit buffer. | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( G.obedit && G.obedit->data == self->curve ) { | 
					
						
							|  |  |  | 		short qual = G.qual; | 
					
						
							|  |  |  | 		G.qual = 0;		/* save key qualifier, then clear it */ | 
					
						
							|  |  |  | 		self->curve->pos = self->curve->len = 0; | 
					
						
							|  |  |  | 		while ( *text ) | 
					
						
							|  |  |  | 			do_textedit( 0, 0, *text++ ); | 
					
						
							|  |  |  | 		G.qual = qual; | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		short len = (short)strlen(text); | 
					
						
							| 
									
										
										
										
											2005-06-12 05:54:15 +00:00
										 |  |  | 		MEM_freeN( self->curve->str ); | 
					
						
							| 
									
										
										
										
											2005-12-07 05:44:29 +00:00
										 |  |  | 		self->curve->str = MEM_callocN( len+sizeof(wchar_t), "str" ); | 
					
						
							| 
									
										
										
										
											2005-06-12 05:54:15 +00:00
										 |  |  | 		strcpy( self->curve->str, text ); | 
					
						
							| 
									
										
										
										
											2005-12-07 05:44:29 +00:00
										 |  |  | 		self->curve->pos = len; | 
					
						
							|  |  |  | 		self->curve->len = len; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if( self->curve->strinfo ) | 
					
						
							|  |  |  | 			MEM_freeN( self->curve->strinfo ); | 
					
						
							|  |  |  | 		/* don't know why this is +4, just duplicating load_editText() */ | 
					
						
							|  |  |  | 		self->curve->strinfo = MEM_callocN( (len+4) *sizeof(CharInfo), | 
					
						
							|  |  |  | 				"strinfo"); | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2005-12-07 05:44:29 +00:00
										 |  |  | 	Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Text3d_getText( BPy_Text3d * self ) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2005-12-07 05:44:29 +00:00
										 |  |  | 	if( self->curve->str ) | 
					
						
							|  |  |  | 		return PyString_FromString( self->curve->str ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2005-03-06 14:55:00 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | static PyObject* Text3d_getDrawMode(BPy_Text3d* self) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *tuple = NULL; | 
					
						
							|  |  |  | 	int size = 0, pos = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	//get the tuple size
 | 
					
						
							|  |  |  | 	if(self->curve->flag & CU_3D) | 
					
						
							|  |  |  | 		size++; | 
					
						
							|  |  |  | 	if (self->curve->flag & CU_FRONT) | 
					
						
							|  |  |  | 		size++; | 
					
						
							|  |  |  | 	if (self->curve->flag & CU_BACK) | 
					
						
							|  |  |  | 		size++; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	//generate tuple
 | 
					
						
							|  |  |  | 	tuple = PyTuple_New(size); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	//load tuple
 | 
					
						
							|  |  |  | 	if(self->curve->flag & CU_3D){ | 
					
						
							|  |  |  | 		PyTuple_SET_ITEM( tuple, pos, return_ModuleConstant("DRAW3D")); | 
					
						
							|  |  |  | 		pos++; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (self->curve->flag & CU_FRONT){ | 
					
						
							|  |  |  | 		PyTuple_SET_ITEM( tuple, pos, return_ModuleConstant("DRAWFRONT")); | 
					
						
							|  |  |  | 		pos++; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (self->curve->flag & CU_BACK){ | 
					
						
							|  |  |  | 		PyTuple_SET_ITEM( tuple, pos, return_ModuleConstant("DRAWBACK")); | 
					
						
							|  |  |  | 		pos++; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return tuple; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject* Text3d_setDrawMode(BPy_Text3d* self,PyObject* args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *listObject = NULL; | 
					
						
							|  |  |  | 	int size, i; | 
					
						
							|  |  |  | 	short temp; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	size = PySequence_Length(args); | 
					
						
							|  |  |  | 	if ( size == 1 ) { | 
					
						
							|  |  |  | 		listObject = PySequence_GetItem(args, 0); | 
					
						
							|  |  |  | 		if ( PySequence_Check(listObject) ) { | 
					
						
							|  |  |  | 			size = PySequence_Length(listObject); | 
					
						
							|  |  |  | 		}else{ //not a sequence but maybe a single constant
 | 
					
						
							|  |  |  | 			Py_INCREF(args); | 
					
						
							|  |  |  | 			listObject = args; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} else { //a list of objects (non-sequence)
 | 
					
						
							|  |  |  | 		Py_INCREF(args); | 
					
						
							|  |  |  | 		listObject = args; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if ( size > 3 || size < 1 ) { | 
					
						
							|  |  |  | 		//bad number of arguments
 | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 			"too many parameters - expects 1 - 3 constants" ) ); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	//clear bits
 | 
					
						
							|  |  |  | 	temp = self->curve->flag; //in case of failure
 | 
					
						
							|  |  |  | 	if(self->curve->flag & CU_3D) | 
					
						
							|  |  |  | 		self->curve->flag &= ~CU_3D; | 
					
						
							|  |  |  | 	if(self->curve->flag & CU_FRONT) | 
					
						
							|  |  |  | 		self->curve->flag &= ~CU_FRONT; | 
					
						
							|  |  |  | 	if(self->curve->flag & CU_BACK) | 
					
						
							|  |  |  | 		self->curve->flag &= ~CU_BACK; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	//parse and set bits
 | 
					
						
							|  |  |  | 	for (i = 0; i < size; i++) { | 
					
						
							|  |  |  | 		PyObject *v; | 
					
						
							|  |  |  | 		int value; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		v = PySequence_GetItem(listObject, i); | 
					
						
							|  |  |  | 		if (v == NULL) { //unable to return item - null = failure
 | 
					
						
							|  |  |  | 			Py_DECREF(listObject); | 
					
						
							|  |  |  | 			self->curve->flag = temp; | 
					
						
							|  |  |  | 			return ( EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 				"unable to parse list" ) );	 | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		if( !BPy_Constant_Check(v)){ | 
					
						
							|  |  |  | 			Py_DECREF(listObject); | 
					
						
							|  |  |  | 			Py_DECREF(v); | 
					
						
							|  |  |  | 			self->curve->flag = temp; | 
					
						
							|  |  |  | 			return ( EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 				"bad argument types - expects module constants" ) ); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		value = PyInt_AS_LONG(PyDict_GetItemString( | 
					
						
							|  |  |  | 			((BPy_constant*)v)->dict, "value")); | 
					
						
							|  |  |  | 		self->curve->flag |= (short)value; | 
					
						
							|  |  |  | 		Py_DECREF(v); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	Py_DECREF(listObject); | 
					
						
							| 
									
										
										
										
											2006-12-27 05:04:20 +00:00
										 |  |  | 	Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject* Text3d_getUVorco(BPy_Text3d* self) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if(self->curve->flag & CU_UV_ORCO) | 
					
						
							|  |  |  | 		return EXPP_incr_ret_True(); | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		return EXPP_incr_ret_False(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject* Text3d_setUVorco(BPy_Text3d* self,PyObject* args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int flag; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( !PyArg_ParseTuple( args, "i", &flag ) ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 			   "expected TRUE or FALSE (1 or 0)" ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( flag < 0 || flag > 1 ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 			   "expected TRUE or FALSE (1 or 0)" ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( flag ) | 
					
						
							|  |  |  | 		self->curve->flag |= CU_UV_ORCO; | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		self->curve->flag &= ~CU_UV_ORCO; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-27 05:04:20 +00:00
										 |  |  | 	Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject* Text3d_getBevelAmount(BPy_Text3d* self) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return Curve_getBevresol((BPy_Curve*)self); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject* Text3d_setBevelAmount(BPy_Text3d* self,PyObject* args) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return Curve_setBevresol((BPy_Curve*)self,args); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Text3d_getDefaultResolution( BPy_Text3d * self ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return Curve_getResolu( (BPy_Curve*)self ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Text3d_setDefaultResolution( BPy_Text3d * self, PyObject * args ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return Curve_setResolu( (BPy_Curve*)self,args ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Text3d_getWidth( BPy_Text3d * self ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return Curve_getWidth( (BPy_Curve*)self ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Text3d_setWidth( BPy_Text3d * self, PyObject * args ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return Curve_setWidth( (BPy_Curve*)self,args ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Text3d_getExtrudeDepth( BPy_Text3d * self ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return Curve_getExt1( (BPy_Curve*)self ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Text3d_setExtrudeDepth( BPy_Text3d * self, PyObject * args ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return Curve_setExt1( (BPy_Curve*)self,args ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Text3d_getExtrudeBevelDepth( BPy_Text3d * self ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return Curve_getExt2( (BPy_Curve*)self ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Text3d_setExtrudeBevelDepth( BPy_Text3d * self, PyObject * args ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return Curve_setExt2( (BPy_Curve*)self,args ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Text3d_getShear( BPy_Text3d * self ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *attr = PyFloat_FromDouble( (double) self->curve->shear ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( attr ) | 
					
						
							|  |  |  | 		return attr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, | 
					
						
							|  |  |  | 		"couldn't get Curve.shear attribute" ) ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Text3d_setShear( BPy_Text3d * self, PyObject * args ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	float value; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( !PyArg_ParseTuple( args, "f", &value ) ) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 			"expected float argument" ) ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if(value > 1.0f || value < -1.0f) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 			"acceptable values are between 1.0 and -1.0" ) ); | 
					
						
							|  |  |  | 	self->curve->shear = value; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-27 05:04:20 +00:00
										 |  |  | 	Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Text3d_getSize( BPy_Text3d * self ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *attr = PyFloat_FromDouble( (double) self->curve->fsize ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( attr ) | 
					
						
							|  |  |  | 		return attr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, | 
					
						
							|  |  |  | 		"couldn't get Curve.fsize attribute" ) ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Text3d_setSize( BPy_Text3d * self, PyObject * args ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	float value; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( !PyArg_ParseTuple( args, "f", &value ) ) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 			"expected float argument" ) ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if(value > 10.0f || value < 0.1f) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 			"acceptable values are between 10.0 and 0.1" ) ); | 
					
						
							|  |  |  | 	self->curve->fsize = value; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-27 05:04:20 +00:00
										 |  |  | 	Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Text3d_getLineSeparation( BPy_Text3d * self ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *attr = PyFloat_FromDouble( (double) self->curve->linedist ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( attr ) | 
					
						
							|  |  |  | 		return attr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, | 
					
						
							|  |  |  | 		"couldn't get Curve.linedist attribute" ) ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Text3d_setLineSeparation( BPy_Text3d * self, PyObject * args ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	float value; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( !PyArg_ParseTuple( args, "f", &value ) ) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 			"expected float argument" ) ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if(value > 10.0f || value < 0.0f) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 			"acceptable values are between 10.0 and 0.0" ) ); | 
					
						
							|  |  |  | 	self->curve->linedist = value; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-27 05:04:20 +00:00
										 |  |  | 	Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Text3d_getSpacing( BPy_Text3d * self ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *attr = PyFloat_FromDouble( (double) self->curve->spacing ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( attr ) | 
					
						
							|  |  |  | 		return attr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, | 
					
						
							|  |  |  | 		"couldn't get Curve.spacing attribute" ) ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Text3d_setSpacing( BPy_Text3d * self, PyObject * args ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	float value; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( !PyArg_ParseTuple( args, "f", &value ) ) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 			"expected float argument" ) ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if(value > 10.0f || value < 0.0f) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 			"acceptable values are between 10.0 and 0.0" ) ); | 
					
						
							|  |  |  | 	self->curve->spacing = value; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-27 05:04:20 +00:00
										 |  |  | 	Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | } | 
					
						
							|  |  |  | static PyObject *Text3d_getXoffset( BPy_Text3d * self ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *attr = PyFloat_FromDouble( (double) self->curve->xof ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( attr ) | 
					
						
							|  |  |  | 		return attr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, | 
					
						
							|  |  |  | 		"couldn't get Curve.xof attribute" ) ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Text3d_setXoffset( BPy_Text3d * self, PyObject * args ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	float value; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( !PyArg_ParseTuple( args, "f", &value ) ) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 		"expected float argument" ) ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if(value > 50.0f || value < -50.0f) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 			"acceptable values are between 50.0 and -50.0" ) ); | 
					
						
							|  |  |  | 	self->curve->xof = value; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-27 05:04:20 +00:00
										 |  |  | 	Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Text3d_getYoffset( BPy_Text3d * self ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyObject *attr = PyFloat_FromDouble( (double) self->curve->yof ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( attr ) | 
					
						
							|  |  |  | 		return attr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, | 
					
						
							|  |  |  | 		"couldn't get Curve.yof attribute" ) ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Text3d_setYoffset( BPy_Text3d * self, PyObject * args ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	float value; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( !PyArg_ParseTuple( args, "f", &value ) ) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 		"expected float argument" ) ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if(value > 50.0f || value < -50.0f) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 			"acceptable values are between 50.0 and -50.0" ) ); | 
					
						
							|  |  |  | 	self->curve->yof = value; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-27 05:04:20 +00:00
										 |  |  | 	Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Text3d_getAlignment( BPy_Text3d * self ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if(self->curve->spacemode == CU_LEFT){ | 
					
						
							|  |  |  | 		return return_ModuleConstant("LEFT"); | 
					
						
							|  |  |  | 	}else if (self->curve->spacemode == CU_MIDDLE){ | 
					
						
							|  |  |  | 		return return_ModuleConstant("MIDDLE"); | 
					
						
							|  |  |  | 	}else if (self->curve->spacemode == CU_RIGHT){ | 
					
						
							|  |  |  | 		return return_ModuleConstant("RIGHT"); | 
					
						
							|  |  |  | 	}else if (self->curve->spacemode == CU_FLUSH){ | 
					
						
							|  |  |  | 		return return_ModuleConstant("FLUSH"); | 
					
						
							| 
									
										
										
										
											2007-05-28 17:06:03 +00:00
										 |  |  | 	}else if (self->curve->spacemode == CU_JUSTIFY){  | 
					
						
							|  |  |  | 		return return_ModuleConstant("JUSTIFY"); | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2007-05-28 17:06:03 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | 	return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, | 
					
						
							|  |  |  | 		"couldn't get Curve.spacemode attribute" ) ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Text3d_setAlignment( BPy_Text3d * self, PyObject * args ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	BPy_constant *constant; | 
					
						
							|  |  |  | 	int value; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( !PyArg_ParseTuple( args, "O!", &constant_Type, &constant ) ) | 
					
						
							|  |  |  | 		return ( EXPP_ReturnPyObjError( PyExc_AttributeError, | 
					
						
							|  |  |  | 			"expected module constant" ) ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	value = PyInt_AS_LONG(PyDict_GetItemString(constant->dict, "value")); | 
					
						
							|  |  |  | 	self->curve->spacemode = (short)value; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-12-27 05:04:20 +00:00
										 |  |  | 	Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2005-03-19 03:24:00 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2005-03-26 18:14:29 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************
 | 
					
						
							|  |  |  |  * Function:    Text3d_CreatePyObject                                        | 
					
						
							|  |  |  |  * Description: This function will create a new BPy_Text3d from an existing    | 
					
						
							|  |  |  |  *               Blender structure.                                      | 
					
						
							|  |  |  |  *****************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyObject *Text3d_CreatePyObject( Text3d * text3d ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	BPy_Text3d *pytext3d; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	pytext3d = ( BPy_Text3d * ) PyObject_NEW( BPy_Text3d, &Text3d_Type ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( !pytext3d ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_MemoryError, | 
					
						
							|  |  |  | 					      "couldn't create BPy_Text3d object" ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	pytext3d->curve = text3d; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return ( PyObject * ) pytext3d; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Text3d_getFont( BPy_Text3d * self ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (self->curve)  | 
					
						
							|  |  |  | 		return Font_CreatePyObject (self->curve->vfont); | 
					
						
							|  |  |  | 	else | 
					
						
							| 
									
										
										
										
											2006-12-27 05:04:20 +00:00
										 |  |  | 		Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Text3d_setFont( BPy_Text3d * self, PyObject * args ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	BPy_Font  *pyobj= NULL; | 
					
						
							| 
									
										
										
										
											2005-06-04 16:22:50 +00:00
										 |  |  | 	VFont *vf; //, *vfont;
 | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	if( !PyArg_ParseTuple( args, "|O!",&Font_Type, &pyobj) ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 					      "expected a string" ); | 
					
						
							|  |  |  | 	if( !pyobj ) { | 
					
						
							|  |  |  | 	//	pyobj= M_Text3d_LoadFont (self, Py_BuildValue("(s)", "<builtin>"));
 | 
					
						
							|  |  |  | 		self->curve->vfont= get_builtin_font (); | 
					
						
							| 
									
										
										
										
											2006-12-27 05:04:20 +00:00
										 |  |  | 		Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	vf= exist_vfont(pyobj->font->name); | 
					
						
							|  |  |  | 	if (vf) { | 
					
						
							|  |  |  | 		id_us_plus((ID *)vf); | 
					
						
							|  |  |  | 		self->curve->vfont->id.us--; | 
					
						
							|  |  |  | 		self->curve->vfont= vf; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2007-03-10 09:43:43 +00:00
										 |  |  | 		vf= load_vfont (pyobj->font->name); | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 		if (vf) { | 
					
						
							|  |  |  | 			id_us_plus((ID *)vf); | 
					
						
							|  |  |  | 			self->curve->vfont->id.us--; | 
					
						
							|  |  |  | 			self->curve->vfont= vf; | 
					
						
							|  |  |  | 		}	 | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2006-12-27 05:04:20 +00:00
										 |  |  | 	Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-03 14:05:36 +00:00
										 |  |  | static PyObject *Text3d_addFrame( BPy_Text3d * self ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Curve *cu = self->curve; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (cu->totbox >= 256)	 | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_RuntimeError, | 
					
						
							|  |  |  | 			"limited to 256 frames" ); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	cu->totbox++;	 | 
					
						
							|  |  |  | 	cu->tb[cu->totbox-1]= cu->tb[cu->totbox-2]; | 
					
						
							|  |  |  | 	Py_RETURN_NONE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Text3d_removeFrame( BPy_Text3d * self, PyObject * args ) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Curve *cu = self->curve; | 
					
						
							|  |  |  | 	int index, i; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (cu->totbox == 1) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_RuntimeError, | 
					
						
							|  |  |  | 			"cannot remove the last frame" ); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	index = cu->totbox-1; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if( !PyArg_ParseTuple( args, "|i", &index ) ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_RuntimeError, | 
					
						
							|  |  |  | 			"expected an int" ); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (index < 0 || index >= cu->totbox ) | 
					
						
							|  |  |  | 		return EXPP_ReturnPyObjError( PyExc_IndexError, | 
					
						
							|  |  |  | 			"index out of range" ); | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	for (i = index; i < cu->totbox; i++) cu->tb[i]= cu->tb[i+1]; | 
					
						
							|  |  |  | 	cu->totbox--; | 
					
						
							|  |  |  | 	cu->actbox--; | 
					
						
							|  |  |  | 	Py_RETURN_NONE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | PyObject *M_Text3d_LoadFont( PyObject * self, PyObject * value ) | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	char *fontfile= PyString_AsString(value); | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	FILE *file= NULL; | 
					
						
							|  |  |  | 	VFont *vf= NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-06-16 12:24:41 +00:00
										 |  |  | 	if( !fontfile ) | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 		return EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 					      "expected a string" ); | 
					
						
							| 
									
										
										
										
											2005-06-04 16:22:50 +00:00
										 |  |  | 	vf= exist_vfont(fontfile); | 
					
						
							|  |  |  | 	if( vf ) | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 		return Font_CreatePyObject( vf ); | 
					
						
							| 
									
										
										
										
											2005-06-04 16:22:50 +00:00
										 |  |  | 	/* No use for that -- lukep
 | 
					
						
							|  |  |  | 	 else | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 		vf= NULL; | 
					
						
							| 
									
										
										
										
											2005-06-04 16:22:50 +00:00
										 |  |  | 	 */ | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	file= fopen( fontfile, "r"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if( file || !strcmp (fontfile, "<builtin>") ) { | 
					
						
							|  |  |  | 		load_vfont( fontfile ); | 
					
						
							| 
									
										
										
										
											2005-07-09 17:54:03 +00:00
										 |  |  | 		if(file) fclose( file ); | 
					
						
							| 
									
										
										
										
											2006-04-24 15:09:07 +00:00
										 |  |  | 		vf = exist_vfont( fontfile ); | 
					
						
							|  |  |  | 		if(vf) | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 			return Font_CreatePyObject( vf ); | 
					
						
							| 
									
										
										
										
											2006-12-27 05:04:20 +00:00
										 |  |  | 		Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2005-05-04 21:31:51 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return EXPP_ReturnPyObjError( PyExc_TypeError, | 
					
						
							|  |  |  | 				      "string isn't filename or fontpath" ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 |