[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11488] branches/pyapi_devel/source/ blender/python/api2_2x: adding missing files

Campbell Barton cbarton at metavr.com
Sun Aug 5 19:09:36 CEST 2007


Revision: 11488
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11488
Author:   campbellbarton
Date:     2007-08-05 19:09:35 +0200 (Sun, 05 Aug 2007)

Log Message:
-----------
adding missing files

Added Paths:
-----------
    branches/pyapi_devel/source/blender/python/api2_2x/CurveBase.c
    branches/pyapi_devel/source/blender/python/api2_2x/CurveBase.h

Added: branches/pyapi_devel/source/blender/python/api2_2x/CurveBase.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/CurveBase.c	                        (rev 0)
+++ branches/pyapi_devel/source/blender/python/api2_2x/CurveBase.c	2007-08-05 17:09:35 UTC (rev 11488)
@@ -0,0 +1,699 @@
+/* 
+ * $Id: Curve.c 11367 2007-07-25 13:01:44Z campbellbarton $
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License.  See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * This is a new part of Blender.
+ *
+ * Contributor(s): Jacques Guignot, Stephen Swaney
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
+
+#include "Curve.h" /*This must come first*/
+#include "CurveBase.h" /*This must come first*/
+
+#include "BLI_blenlib.h"
+#include "BKE_main.h"
+#include "BKE_displist.h"
+#include "BKE_global.h"
+#include "BKE_library.h"
+#include "BKE_curve.h"
+#include "BKE_material.h"
+#include "MEM_guardedalloc.h"	/* because we wil be mallocing memory */
+#include "CurNurb.h"
+#include "SurfNurb.h"
+#include "Material.h"
+#include "Object.h"
+#include "Key.h"
+#include "gen_utils.h"
+#include "gen_library.h"
+#include "mydevice.h"
+#include "bpy_list.h"
+
+
+/*****************************************************************************/
+/* The following string definitions are used for documentation strings.      */
+/* In Python these will be written to the console when doing a               */
+/*  Blender.Curve.__doc__                                                    */
+/*****************************************************************************/
+
+char M_Curve_doc[] = "";
+
+/*****************************************************************************/
+/*  Python API function prototypes for the Curve module.                     */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/*  Python BPyCurveBaseObject instance methods declarations:                          */
+/*****************************************************************************/
+
+static PyObject *Curve_getPathLen( BPyCurveBaseObject * self );
+static int Curve_setPathLen( BPyCurveBaseObject * self, PyObject * args );
+static PyObject *Curve_getLoc( BPyCurveBaseObject * self );
+static int Curve_setLoc( BPyCurveBaseObject * self, PyObject * args );
+static PyObject *Curve_getRot( BPyCurveBaseObject * self );
+static int Curve_setRot( BPyCurveBaseObject * self, PyObject * args );
+static PyObject *Curve_getSize( BPyCurveBaseObject * self );
+static int Curve_setSize( BPyCurveBaseObject * self, PyObject * args );
+static PyObject *Curve_getKey( BPyCurveBaseObject * self );
+
+static PyObject *Curve_getBevOb( BPyCurveBaseObject * self );
+static int Curve_setBevOb( BPyCurveBaseObject * self, PyObject * args );
+
+static PyObject *Curve_getTaperOb( BPyCurveBaseObject * self );
+static int Curve_setTaperOb( BPyCurveBaseObject * self, PyObject * args );
+static PyObject *Curve_copy( BPyCurveBaseObject * self );
+
+
+struct chartrans *text_to_curve( Object * ob, int mode );
+/*****************************************************************************/
+/* Python BPyCurveBaseObject methods:                                        */
+/* gives access to                                                           */
+/* name, pathlen totcol flag bevresol                                        */
+/* resolu resolv width ext1 ext2                                             */
+/* controlpoint loc rot size                                                 */
+/* numpts                                                                    */
+/*****************************************************************************/
+
+static PyObject *Curve_getPathLen( BPyCurveBaseObject * self )
+{
+	return PyInt_FromLong( ( long ) self->curve->pathlen );
+}
+
+
+static int Curve_setPathLen( BPyCurveBaseObject * self, PyObject * value )
+{
+	PyObject *num;
+
+	if( !PyNumber_Check( value ) )
+		return EXPP_ReturnIntError( PyExc_TypeError,
+				"expected int argument" );
+
+	num = PyNumber_Int( value );
+	self->curve->pathlen = (short)PyInt_AS_LONG( num );
+	Py_DECREF( num );
+
+	return 0;
+}
+
+PyObject *Curve_getMode( BPyCurveBaseObject * self )
+{
+	return PyInt_FromLong( ( long ) self->curve->flag );
+}
+
+
+int Curve_setMode( BPyCurveBaseObject * self, PyObject * args )
+{
+	PyObject *num;
+
+	if( !PyNumber_Check( args ) )
+		return EXPP_ReturnIntError( PyExc_TypeError,
+				"expected int argument" );
+
+	num = PyNumber_Int( args );
+	self->curve->flag = (short)PyInt_AS_LONG( num );
+	Py_DECREF( num );
+
+	return 0;
+}
+
+PyObject *Curve_getBevresol( BPyCurveBaseObject * self )
+{
+	return PyInt_FromLong( ( long ) self->curve->bevresol );
+}
+
+int Curve_setBevresol( BPyCurveBaseObject * self, PyObject * args )
+{
+	short value;
+	PyObject *num;
+
+	if( !PyNumber_Check( args ) )
+		return EXPP_ReturnIntError( PyExc_TypeError,
+				"expected int argument" );
+
+	num = PyNumber_Int( args );
+	value = (short)PyInt_AS_LONG( num );
+	Py_DECREF( num );
+
+	if( value > 10 || value < 0 )
+		return EXPP_ReturnIntError( PyExc_ValueError,
+				"acceptable values are between 0 and 10" );
+
+	self->curve->bevresol = value;
+	return 0;
+}
+
+
+PyObject *Curve_getResolu( BPyCurveBaseObject * self )
+{
+	return PyInt_FromLong( ( long ) self->curve->resolu );
+}
+
+
+int Curve_setResolu( BPyCurveBaseObject * self, PyObject * args )
+{
+	short value;
+	Nurb *nu;
+	PyObject *num;
+
+	if( !PyNumber_Check( args ) )
+		return EXPP_ReturnIntError( PyExc_TypeError,
+				"expected int argument" );
+
+	num = PyNumber_Int( args );
+	value = (short)PyInt_AS_LONG( num );
+	Py_DECREF( num );
+
+	if( value > 128 || value < 1 )
+		return EXPP_ReturnIntError( PyExc_ValueError,
+				"acceptable values are between 1 and 128" );
+
+	self->curve->resolu = value;
+	/* propagate the change through all the curves */
+	for( nu = self->curve->nurb.first; nu; nu = nu->next )
+		nu->resolu = value;
+
+	return 0;
+}
+
+PyObject *Curve_getResolv( BPyCurveBaseObject * self )
+{
+	return PyInt_FromLong( ( long ) self->curve->resolv );
+}
+
+int Curve_setResolv( BPyCurveBaseObject * self, PyObject * args )
+{
+	short value;
+	PyObject *num;
+
+	if( !PyNumber_Check( args ) )
+		return EXPP_ReturnIntError( PyExc_TypeError,
+				"expected int argument" );
+
+	num = PyNumber_Int( args );
+	value = (short)PyInt_AS_LONG( num );
+	Py_DECREF( num );
+
+	if(value > 128 || value < 1)
+		return EXPP_ReturnIntError( PyExc_ValueError,
+			"acceptable values are between 1 and 128" );
+	self->curve->resolv = value;
+
+	return 0;
+}
+
+PyObject *Curve_getWidth( BPyCurveBaseObject * self )
+{
+	return PyFloat_FromDouble( ( double ) self->curve->width );
+}
+
+
+int Curve_setWidth( BPyCurveBaseObject * self, PyObject * args )
+{
+	float value;
+	PyObject *num;
+
+	if( !PyNumber_Check( args ) )
+		return EXPP_ReturnIntError( PyExc_TypeError,
+				"expected float argument" );
+
+	num = PyNumber_Float( args );
+	value = (float)PyFloat_AS_DOUBLE( num );
+	Py_DECREF( num );
+
+	if(value > 2.0f || value < 0.0f)
+		return EXPP_ReturnIntError( PyExc_ValueError,
+				"acceptable values are between 2.0 and 0.0" );
+	self->curve->width = value;
+
+	return 0;
+}
+
+
+PyObject *Curve_getExt1( BPyCurveBaseObject * self )
+{
+	return PyFloat_FromDouble( ( double ) self->curve->ext1 );
+}
+
+
+int Curve_setExt1( BPyCurveBaseObject * self, PyObject * args )
+{
+	float value;
+	PyObject *num;
+
+	if( !PyNumber_Check( args ) )
+		return EXPP_ReturnIntError( PyExc_TypeError,
+				"expected float argument" );
+
+	num = PyNumber_Float( args );
+	value = (float)PyFloat_AS_DOUBLE( num );
+	Py_DECREF( num );
+
+	if(value > 5.0f || value < 0.0f)
+		return EXPP_ReturnIntError( PyExc_ValueError,
+				"acceptable values are between 0.0 and 5.0" );
+	self->curve->ext1 = value;
+
+	return 0;
+}
+
+PyObject *Curve_getExt2( BPyCurveBaseObject * self )
+{
+	return PyFloat_FromDouble( ( double ) self->curve->ext2 );
+}
+
+
+int Curve_setExt2( BPyCurveBaseObject * self, PyObject * args )
+{
+	float value;
+	PyObject *num;
+
+	if( !PyNumber_Check( args ) )
+		return EXPP_ReturnIntError( PyExc_TypeError,
+				"expected float argument" );
+
+	num = PyNumber_Float( args );
+	value = (float)PyFloat_AS_DOUBLE( num );
+	Py_DECREF( num );
+
+	if(value > 2.0f || value < 0.0f)
+		return EXPP_ReturnIntError( PyExc_ValueError,
+				"acceptable values are between 0.0 and 2.0" );
+	self->curve->ext2 = value;
+
+	return 0;
+}
+
+static PyObject *Curve_getLoc( BPyCurveBaseObject * self )
+{
+	return Py_BuildValue( "[f,f,f]", self->curve->loc[0],
+				self->curve->loc[1], self->curve->loc[2] );
+}
+
+static int Curve_setLoc( BPyCurveBaseObject * self, PyObject * args )
+{
+	float loc[3];
+	int i;
+
+	if( ( !PyList_Check( args ) && !PyTuple_Check( args ) ) ||
+			PySequence_Size( args ) != 3 ) {
+TypeError:
+		return EXPP_ReturnIntError( PyExc_TypeError,
+				"expected a sequence of three floats" );
+	}
+
+	for( i = 0; i < 3; i++ ) {
+		PyObject *item = PySequence_GetItem( args, i );
+		PyObject *num = PyNumber_Float( item );
+		Py_DECREF( item );
+		if( !num )
+			goto TypeError;
+		loc[i] = PyFloat_AS_DOUBLE( num );
+		Py_DECREF( num );
+	}
+	memcpy( self->curve->loc, loc, sizeof( loc ) );
+
+	return 0;
+}
+
+static PyObject *Curve_getRot( BPyCurveBaseObject * self )
+{
+	return Py_BuildValue( "[f,f,f]", self->curve->rot[0],
+				self->curve->rot[1], self->curve->rot[2] );
+}
+
+static int Curve_setRot( BPyCurveBaseObject * self, PyObject * args )
+{

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list