[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [10922] branches/pyapi_devel/source/ blender/python/api2_2x: Camera, Scene, Object - removed get/set' s from the API (getName, setName) - just use .name

Campbell Barton cbarton at metavr.com
Thu Jun 14 01:17:28 CEST 2007


Revision: 10922
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=10922
Author:   campbellbarton
Date:     2007-06-14 01:17:28 +0200 (Thu, 14 Jun 2007)

Log Message:
-----------
Camera, Scene, Object - removed get/set's from the API (getName, setName) - just use .name
Added a new (and only partly working) type for scriptlinks.

Camera and Scene are almost finished.

ob.scriptlinks = []
rather then
 ob.clearScriptLinks(..)

 ob.scriptlinks.append((text, event))
rather then
ob.addScriptLink(..)

 ob.data = data
rather then...
 removed ob.link(data)

 ob.dataname
rather then
 ob.getData(name_only=1)

removed Layers, rather then having Layers (flag) and layers (list) 
just use layers (bitmask) - should be discussed.

Modified Paths:
--------------
    branches/pyapi_devel/source/blender/python/api2_2x/Blender.c
    branches/pyapi_devel/source/blender/python/api2_2x/Camera.c
    branches/pyapi_devel/source/blender/python/api2_2x/Object.c
    branches/pyapi_devel/source/blender/python/api2_2x/Scene.c
    branches/pyapi_devel/source/blender/python/api2_2x/gen_library.c
    branches/pyapi_devel/source/blender/python/api2_2x/gen_library.h

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

Modified: branches/pyapi_devel/source/blender/python/api2_2x/Blender.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Blender.c	2007-06-13 19:25:15 UTC (rev 10921)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Blender.c	2007-06-13 23:17:28 UTC (rev 10922)
@@ -946,7 +946,7 @@
 	PyDict_SetItemString(dict, "CurNurb", CurNurb_Init());
 	PyDict_SetItemString(dict, "Constraint", Constraint_Init());
 	PyDict_SetItemString(dict, "Curve", Curve_Init());
-	PyDict_SetItemString(dict, "Camera", Camera_Init());
+	Camera_Init(); /*PyDict_SetItemString(dict, "Camera", Camera_Init());*/
 	PyDict_SetItemString(dict, "Draw", Draw_Init());
 	PyDict_SetItemString(dict, "Effect", Effect_Init());
 	PyDict_SetItemString(dict, "Ipo", Ipo_Init());

Modified: branches/pyapi_devel/source/blender/python/api2_2x/Camera.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Camera.c	2007-06-13 19:25:15 UTC (rev 10921)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Camera.c	2007-06-13 23:17:28 UTC (rev 10922)
@@ -64,168 +64,51 @@
 	EXPP_CAM_ATTR_ALPHA,
 };
 
-/*****************************************************************************/
-/* Python API function prototypes for the Camera module.                     */
-/*****************************************************************************/
-static PyObject *M_Camera_New( PyObject * self, PyObject * args,
-			       PyObject * keywords );
-static PyObject *M_Camera_Get( PyObject * self, PyObject * args );
 
 /*****************************************************************************/
-/* The following string definitions are used for documentation strings.      */
-/* In Python these will be written to the console when doing a               */
-/* Blender.Camera.__doc__                                                    */
+/* Python BPy_Camera methods:                                               */
 /*****************************************************************************/
-static char M_Camera_doc[] = "The Blender Camera module\n\
-\n\
-This module provides access to **Camera Data** objects in Blender\n\
-\n\
-Example::\n\
-\n\
-  from Blender import Camera, Object, Scene\n\
-  c = Camera.New('ortho')      # create new ortho camera data\n\
-  c.scale = 6.0                # set scale value\n\
-  scn = Scene.GetCurrent()     # get current Scene\n\
-  ob = scn.objects.new(c)      # Make an object from this data in the scene\n\
-  cur.setCurrentCamera(ob)     # make this camera the active";
 
-static char M_Camera_New_doc[] =
-	"Camera.New (type = 'persp', name = 'CamData'):\n\
-        Return a new Camera Data object with the given type and name.";
+/*
+ * Camera_insertIpoKey()
+ *  inserts Camera IPO key for LENS and CLIPPING
+ * - TODO- Replce constants.
+ */
 
-static char M_Camera_Get_doc[] = "Camera.Get (name = None):\n\
-        Return the camera data with the given 'name', None if not found, or\n\
-        Return a list with all Camera Data objects in the current scene,\n\
-        if no argument was given.";
+static PyObject *Camera_insertIpoKey( BPy_Camera * self, PyObject * args )
+{
+	int key = 0;
 
-/*****************************************************************************/
-/* Python method structure definition for Blender.Camera module:             */
-/*****************************************************************************/
-struct PyMethodDef M_Camera_methods[] = {
-	{"New", ( PyCFunction ) M_Camera_New, METH_VARARGS | METH_KEYWORDS,
-	 M_Camera_New_doc},
-	{"Get", M_Camera_Get, METH_VARARGS, M_Camera_Get_doc},
-	{"get", M_Camera_Get, METH_VARARGS, M_Camera_Get_doc},
-	{NULL, NULL, 0, NULL}
-};
+	if( !PyArg_ParseTuple( args, "i", &( key ) ) )
+		return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+										"expected int argument" ) );
 
-/*****************************************************************************/
-/* Python BPy_Camera methods declarations:                                   */
-/*****************************************************************************/
-static PyObject *Camera_oldgetType( BPy_Camera * self );
-static PyObject *Camera_oldgetMode( BPy_Camera * self );
-static PyObject *Camera_oldgetLens( BPy_Camera * self );
-static PyObject *Camera_oldgetClipStart( BPy_Camera * self );
-static PyObject *Camera_oldgetClipEnd( BPy_Camera * self );
-static PyObject *Camera_oldgetDrawSize( BPy_Camera * self );
-static PyObject *Camera_oldgetScale( BPy_Camera * self );
-static PyObject *Camera_getIpo( BPy_Camera * self );
-static int Camera_setIpo( BPy_Camera * self, PyObject * value );
-static PyObject *Camera_oldsetIpo( BPy_Camera * self, PyObject * args );
-static PyObject *Camera_oldsetType( BPy_Camera * self, PyObject * args );
-static PyObject *Camera_oldsetMode( BPy_Camera * self, PyObject * args );
-static PyObject *Camera_oldsetLens( BPy_Camera * self, PyObject * args );
-static PyObject *Camera_oldsetClipStart( BPy_Camera * self, PyObject * args );
-static PyObject *Camera_oldsetClipEnd( BPy_Camera * self, PyObject * args );
-static PyObject *Camera_oldsetDrawSize( BPy_Camera * self, PyObject * args );
-static PyObject *Camera_oldsetScale( BPy_Camera * self, PyObject * args );
-static PyObject *Camera_oldgetScriptLinks( BPy_Camera * self, PyObject * args );
-static PyObject *Camera_addScriptLink( BPy_Camera * self, PyObject * args );
-static PyObject *Camera_oldclearIpo( BPy_Camera * self );
-static PyObject *Camera_clearScriptLinks( BPy_Camera * self, PyObject * args );
-static PyObject *Camera_insertIpoKey( BPy_Camera * self, PyObject * args );
-static PyObject *Camera_copy( BPy_Camera * self );
+	if (key == IPOKEY_LENS){
+		insertkey((ID *)self->camera, ID_CA, NULL, NULL, CAM_LENS);     
+	}
+	else if (key == IPOKEY_CLIPPING){
+		insertkey((ID *)self->camera, ID_CA, NULL, NULL, CAM_STA);
+		insertkey((ID *)self->camera, ID_CA, NULL, NULL, CAM_END);   
+	}
 
+	allspace(REMAKEIPO, 0);
+	EXPP_allqueue(REDRAWIPO, 0);
+	EXPP_allqueue(REDRAWVIEW3D, 0);
+	EXPP_allqueue(REDRAWACTION, 0);
+	EXPP_allqueue(REDRAWNLA, 0);
 
-/*****************************************************************************/
-/* Python BPy_Camera methods table:                                          */
-/*****************************************************************************/
-static PyMethodDef BPy_Camera_methods[] = {
-	/* name, method, flags, doc */
-	{"getIpo", ( PyCFunction ) Camera_getIpo, METH_NOARGS,
-	 "() - Return Camera Data Ipo"},
-	{"getName", ( PyCFunction ) GenericLib_getName, METH_NOARGS,
-	 "() - Return Camera Data name"},
-	{"getType", ( PyCFunction ) Camera_oldgetType, METH_NOARGS,
-	 "() - Return Camera type - 'persp':0, 'ortho':1"},
-	{"getMode", ( PyCFunction ) Camera_oldgetMode, METH_NOARGS,
-	 "() - Return Camera mode flags (or'ed value) -\n"
-	 "     'showLimits':1, 'showMist':2"},
-	{"getLens", ( PyCFunction ) Camera_oldgetLens, METH_NOARGS,
-	 "() - Return *perspective* Camera lens value"},
-	{"getScale", ( PyCFunction ) Camera_oldgetScale, METH_NOARGS,
-	 "() - Return *ortho* Camera scale value"},
-	{"getClipStart", ( PyCFunction ) Camera_oldgetClipStart, METH_NOARGS,
-	 "() - Return Camera clip start value"},
-	{"getClipEnd", ( PyCFunction ) Camera_oldgetClipEnd, METH_NOARGS,
-	 "() - Return Camera clip end value"},
-	{"getDrawSize", ( PyCFunction ) Camera_oldgetDrawSize, METH_NOARGS,
-	 "() - Return Camera draw size value"},
-	{"setIpo", ( PyCFunction ) Camera_oldsetIpo, METH_VARARGS,
-	 "(Blender Ipo) - Set Camera Ipo"},
-	{"clearIpo", ( PyCFunction ) Camera_oldclearIpo, METH_NOARGS,
-	 "() - Unlink Ipo from this Camera."},
-	 {"insertIpoKey", ( PyCFunction ) Camera_insertIpoKey, METH_VARARGS,
-	 "( Camera IPO type ) - Inserts a key into IPO"},
-	{"setName", ( PyCFunction ) GenericLib_setName_with_method, METH_VARARGS,
-	 "(s) - Set Camera Data name"},
-	{"setType", ( PyCFunction ) Camera_oldsetType, METH_VARARGS,
-	 "(s) - Set Camera type, which can be 'persp' or 'ortho'"},
-	{"setMode", ( PyCFunction ) Camera_oldsetMode, METH_VARARGS,
-	 "(<s<,s>>) - Set Camera mode flag(s): 'showLimits' and 'showMist'"},
-	{"setLens", ( PyCFunction ) Camera_oldsetLens, METH_VARARGS,
-	 "(f) - Set *perpective* Camera lens value"},
-	{"setScale", ( PyCFunction ) Camera_oldsetScale, METH_VARARGS,
-	 "(f) - Set *ortho* Camera scale value"},
-	{"setClipStart", ( PyCFunction ) Camera_oldsetClipStart, METH_VARARGS,
-	 "(f) - Set Camera clip start value"},
-	{"setClipEnd", ( PyCFunction ) Camera_oldsetClipEnd, METH_VARARGS,
-	 "(f) - Set Camera clip end value"},
-	{"setDrawSize", ( PyCFunction ) Camera_oldsetDrawSize, METH_VARARGS,
-	 "(f) - Set Camera draw size value"},
-	{"getScriptLinks", ( PyCFunction ) Camera_oldgetScriptLinks, METH_VARARGS,
-	 "(eventname) - Get a list of this camera's scriptlinks (Text names) "
-	 "of the given type\n"
-	 "(eventname) - string: FrameChanged, Redraw or Render."},
-	{"addScriptLink", ( PyCFunction ) Camera_addScriptLink, METH_VARARGS,
-	 "(text, evt) - Add a new camera scriptlink.\n"
-	 "(text) - string: an existing Blender Text name;\n"
-	 "(evt) string: FrameChanged, Redraw or Render."},
-	{"clearScriptLinks", ( PyCFunction ) Camera_clearScriptLinks,
-	 METH_NOARGS,
-	 "() - Delete all scriptlinks from this camera.\n"
-	 "([s1<,s2,s3...>]) - Delete specified scriptlinks from this camera."},
-	{"__copy__", ( PyCFunction ) Camera_copy, METH_NOARGS,
-	 "() - Return a copy of the camera."},
-	{"copy", ( PyCFunction ) Camera_copy, METH_NOARGS,
-	 "() - Return a copy of the camera."},
-	{NULL, NULL, 0, NULL}
-};
+	Py_RETURN_NONE;
+}
 
-/*****************************************************************************/
-/* Python Camera_Type callback function prototypes:                          */
-/*****************************************************************************/
-static int Camera_compare( BPy_Camera * a, BPy_Camera * b );
-static PyObject *Camera_repr( BPy_Camera * self );
 
-static PyObject *M_Camera_New( PyObject * self, PyObject * args,
-			       PyObject * kwords )
+/* cam.__copy__ */
+static PyObject *Camera_copy( BPy_Camera * self )
 {
-	char *type_str = "persp";	/* "persp" is type 0, "ortho" is type 1 */
-	char *name_str = "Camera";
-	static char *kwlist[] = { "type_str", "name_str", NULL };

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list