Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2006-09-17 06:31:16 +0400
committerCampbell Barton <ideasman42@gmail.com>2006-09-17 06:31:16 +0400
commite472a3d8521f5c9b90498dcff8784ddeb678bae0 (patch)
treeb96eb16b5e67d3a94860c94e5dd60ffd244fa08f /source
parenteaad4e4129ed3f2b8d1c518da20a0996c1e60fbb (diff)
renamed Blender.Image.SetCurrent(img) to img.makeCurrent() to be consistant with scene.
applied patch #4998 (array count), as well as adding other array settings, updated documentation as well. added EXPP_setVec3Clamped() as a way to set a vector from getset attrs (used with array offset and scale)
Diffstat (limited to 'source')
-rw-r--r--source/blender/python/api2_2x/Image.c41
-rw-r--r--source/blender/python/api2_2x/Modifier.c101
-rw-r--r--source/blender/python/api2_2x/doc/Image.py19
-rw-r--r--source/blender/python/api2_2x/doc/Modifier.py72
-rw-r--r--source/blender/python/api2_2x/gen_utils.c22
-rw-r--r--source/blender/python/api2_2x/gen_utils.h2
6 files changed, 180 insertions, 77 deletions
diff --git a/source/blender/python/api2_2x/Image.c b/source/blender/python/api2_2x/Image.c
index 0d443031d3d..875aacbab1c 100644
--- a/source/blender/python/api2_2x/Image.c
+++ b/source/blender/python/api2_2x/Image.c
@@ -106,6 +106,7 @@ static PyObject *Image_getMinXY( BPy_Image * self );
static PyObject *Image_save( BPy_Image * self );
static PyObject *Image_unpack( BPy_Image * self, PyObject * args );
static PyObject *Image_pack( BPy_Image * self );
+static PyObject *Image_makeCurrent( BPy_Image * self );
/*****************************************************************************/
@@ -172,7 +173,9 @@ static PyMethodDef BPy_Image_methods[] = {
{"unpack", ( PyCFunction ) Image_unpack, METH_VARARGS,
"(int) - Unpack image. Uses the values defined in Blender.UnpackModes."},
{"pack", ( PyCFunction ) Image_pack, METH_NOARGS,
- "() Pack the image"},
+ "() - Pack the image"},
+ {"makeCurrent", ( PyCFunction ) Image_makeCurrent, METH_NOARGS,
+ "() - Make this the currently displayed image"},
{NULL, NULL, 0, NULL}
};
@@ -196,10 +199,6 @@ static char M_Image_GetCurrent_doc[] =
"() - return the current image, from last active the uv/image view, \
returns None no image is in the view.\n";
-static char M_Image_SetCurrent_doc[] =
- "(image) - set the image to be the current, from last active the uv/image view, \
-returns False if no image could be set.";
-
static char M_Image_Load_doc[] =
"(filename) - return image from file filename as Image Object, \
returns None if not found.\n";
@@ -211,7 +210,6 @@ struct PyMethodDef M_Image_methods[] = {
{"New", M_Image_New, METH_VARARGS, M_Image_New_doc},
{"Get", M_Image_Get, METH_VARARGS, M_Image_Get_doc},
{"GetCurrent", ( PyCFunction ) M_Image_GetCurrent, METH_NOARGS, M_Image_GetCurrent_doc},
- {"SetCurrent", ( PyCFunction ) M_Image_SetCurrent, METH_VARARGS, M_Image_SetCurrent_doc},
{"get", M_Image_Get, METH_VARARGS, M_Image_Get_doc},
{"Load", M_Image_Load, METH_VARARGS, M_Image_Load_doc},
{NULL, NULL, 0, NULL}
@@ -332,27 +330,6 @@ static PyObject *M_Image_GetCurrent( PyObject * self )
return Image_CreatePyObject( G.sima->image );
}
-/*****************************************************************************/
-/* Function: M_Image_SetCurrent*/
-/* Python equivalent: Blender.Image.SetCurrent */
-/* Description: Sets the active current (G.sima) */
-/* This will be the image last under the mouse cursor */
-/* None if there is no Image. */
-/*****************************************************************************/
-static PyObject *M_Image_SetCurrent( PyObject * self, PyObject * args )
-{
- BPy_Image *image;
-
- if (!G.sima)
- Py_RETURN_FALSE;
-
- if( !PyArg_ParseTuple( args, "O!", &Image_Type, &image) )
- return ( EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected an image argument" ) );
-
- G.sima->image= image->image;
- Py_RETURN_TRUE;
-}
/*****************************************************************************/
/* Function: M_Image_Load */
@@ -721,6 +698,16 @@ static PyObject *Image_pack( BPy_Image * self )
}
+static PyObject *Image_makeCurrent( BPy_Image * self )
+{
+ if (!G.sima)
+ Py_RETURN_FALSE;
+
+ G.sima->image= self->image;
+ Py_RETURN_TRUE;
+}
+
+
/* save image to file */
static PyObject *Image_save( BPy_Image * self )
diff --git a/source/blender/python/api2_2x/Modifier.c b/source/blender/python/api2_2x/Modifier.c
index 973d00c5794..8c1cf9e7334 100644
--- a/source/blender/python/api2_2x/Modifier.c
+++ b/source/blender/python/api2_2x/Modifier.c
@@ -45,6 +45,7 @@
#include "mydevice.h"
#include "Object.h"
+#include "Mathutils.h"
#include "gen_utils.h"
enum mod_constants {
@@ -60,6 +61,7 @@ enum mod_constants {
EXPP_MOD_LIMIT, /*ARRAY, MIRROR*/
EXPP_MOD_FLAG, /*MIRROR, WAVE*/
EXPP_MOD_COUNT, /*DECIMATOR, ARRAY*/
+ EXPP_MOD_LENGTH, /*BUILD, ARRAY*/
/*SUBSURF SPESIFIC*/
EXPP_MOD_TYPES,
@@ -71,9 +73,15 @@ enum mod_constants {
/*ARMATURE SPESIFIC*/
EXPP_MOD_ENVELOPES,
+ /*ARRAY SPESIFIC*/
+ EXPP_MOD_OBJECT_OFFSET,
+ EXPP_MOD_OBJECT_CURVE,
+ EXPP_MOD_OFFSET_VEC,
+ EXPP_MOD_SCALE_VEC,
+ EXPP_MOD_MERGE_DIST,
+
/*BUILD SPESIFIC*/
EXPP_MOD_START,
- EXPP_MOD_LENGTH,
EXPP_MOD_SEED,
EXPP_MOD_RANDOMIZE,
@@ -99,7 +107,7 @@ enum mod_constants {
/* yet to be implemented */
/* EXPP_MOD_HOOK_,*/
- /* EXPP_MOD_ARRAY_, */
+ /* , */
};
/*****************************************************************************/
@@ -610,6 +618,71 @@ static int wave_setter( BPy_Modifier *self, int type, PyObject *value )
}
}
+static PyObject *array_getter( BPy_Modifier * self, int type )
+{
+ ArrayModifierData *md = (ArrayModifierData *)(self->md);
+
+ if( type == EXPP_MOD_OBJECT_OFFSET )
+ return Object_CreatePyObject( md->offset_ob );
+ else if( type == EXPP_MOD_OBJECT_CURVE )
+ return Object_CreatePyObject( md->curve_ob );
+ else if( type == EXPP_MOD_COUNT )
+ return PyInt_FromLong( (long)md->count );
+ else if( type == EXPP_MOD_LENGTH )
+ return PyFloat_FromDouble( md->length );
+ else if( type == EXPP_MOD_MERGE_DIST )
+ return PyFloat_FromDouble( md->merge_dist );
+ else if( type == EXPP_MOD_MERGE_DIST )
+ return PyFloat_FromDouble( md->merge_dist );
+ else if( type == EXPP_MOD_OFFSET_VEC)
+ return newVectorObject( md->offset, 3, Py_NEW );
+ else if( type == EXPP_MOD_SCALE_VEC)
+ return newVectorObject( md->scale, 3, Py_NEW );
+
+ return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
+}
+
+static int array_setter( BPy_Modifier *self, int type, PyObject *value )
+{
+ ArrayModifierData *md = (ArrayModifierData *)(self->md);
+ switch( type ) {
+ case EXPP_MOD_OBJECT_OFFSET: {
+ Object *obj = (( BPy_Object * )value)->object;
+ if( !BPy_Object_Check( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected BPy object argument" );
+ if(obj == self->obj )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "Cannot lattice deform an object with its self" );
+ md->offset_ob = obj;
+ return 0;
+ }
+ case EXPP_MOD_OBJECT_CURVE: {
+ Object *obj = (( BPy_Object * )value)->object;
+ if( !BPy_Object_Check( value ) || obj->type != OB_CURVE )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected BPy object argument" );
+ if(obj == self->obj )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "Cannot lattice deform an object with its self" );
+ md->curve_ob = obj;
+ return 0;
+ }
+ case EXPP_MOD_COUNT:
+ return EXPP_setIValueClamped( value, &md->count, 1, 1000, 'i' );
+ case EXPP_MOD_LENGTH:
+ return EXPP_setFloatClamped( value, &md->length, 0.0, 1000.0 );
+ case EXPP_MOD_MERGE_DIST:
+ return EXPP_setFloatClamped( value, &md->merge_dist, 0.0, 1000.0 );
+ case EXPP_MOD_OFFSET_VEC:
+ return EXPP_setVec3Clamped( value, &md->offset, -10000.0, 10000.0 );
+ case EXPP_MOD_SCALE_VEC:
+ return EXPP_setVec3Clamped( value, &md->scale, -10000.0, 10000.0 );
+ default:
+ return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
+ }
+}
+
static PyObject *boolean_getter( BPy_Modifier * self, int type )
{
BooleanModifierData *md = (BooleanModifierData *)(self->md);
@@ -693,6 +766,7 @@ static PyObject *Modifier_getData( BPy_Modifier * self, PyObject * key )
case eModifierType_Hook:
case eModifierType_Softbody:
case eModifierType_Array:
+ return array_getter( self, setting );
case eModifierType_None:
Py_RETURN_NONE;
}
@@ -745,6 +819,8 @@ static int Modifier_setData( BPy_Modifier * self, PyObject * key,
return build_setter( self, key_int, arg );
case eModifierType_Mirror:
return mirror_setter( self, key_int, arg );
+ case eModifierType_Array:
+ return array_setter( self, key_int, arg );
case eModifierType_Decimate:
return decimate_setter( self, key_int, arg );
case eModifierType_Wave:
@@ -753,7 +829,6 @@ static int Modifier_setData( BPy_Modifier * self, PyObject * key,
return boolean_setter( self, key_int, arg );
case eModifierType_Hook:
case eModifierType_Softbody:
- case eModifierType_Array:
case eModifierType_None:
return 0;
}
@@ -1156,6 +1231,8 @@ static PyObject *M_Modifier_TypeDict( void )
PyInt_FromLong( eModifierType_Wave ) );
PyConstant_Insert( d, "BOOLEAN",
PyInt_FromLong( eModifierType_Boolean ) );
+ PyConstant_Insert( d, "ARRAY",
+ PyInt_FromLong( eModifierType_Array ) );
}
return S;
}
@@ -1175,7 +1252,7 @@ st='''
EXPP_MOD_RENDER = 0,
EXPP_MOD_REALTIME,
EXPP_MOD_EDITMODE,
- ........ and so on, copy from above
+ etc.. copy from above
'''
base= '''
@@ -1189,7 +1266,7 @@ for var in st.replace(',','').split('\n'):
var= var[0]
if (not var) or var.startswith('/'): continue
- var=var.split('_')[-1]
+ var='_'.join(var.split('_')[2:])
print base % (var, var),
# END PYSCRIPT
*/
@@ -1213,6 +1290,8 @@ for var in st.replace(',','').split('\n'):
PyInt_FromLong( EXPP_MOD_FLAG ) );
PyConstant_Insert( d, "COUNT",
PyInt_FromLong( EXPP_MOD_COUNT ) );
+ PyConstant_Insert( d, "LENGTH",
+ PyInt_FromLong( EXPP_MOD_LENGTH ) );
PyConstant_Insert( d, "TYPES",
PyInt_FromLong( EXPP_MOD_TYPES ) );
PyConstant_Insert( d, "LEVELS",
@@ -1225,10 +1304,18 @@ for var in st.replace(',','').split('\n'):
PyInt_FromLong( EXPP_MOD_UV ) );
PyConstant_Insert( d, "ENVELOPES",
PyInt_FromLong( EXPP_MOD_ENVELOPES ) );
+ PyConstant_Insert( d, "OBJECT_OFFSET",
+ PyInt_FromLong( EXPP_MOD_OBJECT_OFFSET ) );
+ PyConstant_Insert( d, "OBJECT_CURVE",
+ PyInt_FromLong( EXPP_MOD_OBJECT_CURVE ) );
+ PyConstant_Insert( d, "OFFSET_VEC",
+ PyInt_FromLong( EXPP_MOD_OFFSET_VEC ) );
+ PyConstant_Insert( d, "SCALE_VEC",
+ PyInt_FromLong( EXPP_MOD_SCALE_VEC ) );
+ PyConstant_Insert( d, "MERGE_DIST",
+ PyInt_FromLong( EXPP_MOD_MERGE_DIST ) );
PyConstant_Insert( d, "START",
PyInt_FromLong( EXPP_MOD_START ) );
- PyConstant_Insert( d, "LENGTH",
- PyInt_FromLong( EXPP_MOD_LENGTH ) );
PyConstant_Insert( d, "SEED",
PyInt_FromLong( EXPP_MOD_SEED ) );
PyConstant_Insert( d, "RANDOMIZE",
diff --git a/source/blender/python/api2_2x/doc/Image.py b/source/blender/python/api2_2x/doc/Image.py
index 9385d7bcc2f..96bf31e293f 100644
--- a/source/blender/python/api2_2x/doc/Image.py
+++ b/source/blender/python/api2_2x/doc/Image.py
@@ -65,16 +65,6 @@ def GetCurrent ():
@return: The Current Blender Image, If there is no current image it returns None.
"""
-def SetCurrent (image):
- """
- Set the currently displayed Image from Blenders UV/Image window.
- When multiple images are displayed, the last active UV/Image windows image is used.
- @type image: Blender Image
- @param image: The image to display in the image view.
- @rtype: bool
- @return: True if the current image could be set, if no window was available, it will be set to False.
- """
-
class Image:
"""
The Image object
@@ -337,3 +327,12 @@ class Image:
@rtype: none
@type mode: int
"""
+ def SetCurrent (image):
+ """
+ Set the currently displayed Image from Blenders UV/Image window.
+ When multiple images are displayed, the last active UV/Image windows image is used.
+ @type image: Blender Image
+ @param image: The image to display in the image view.
+ @rtype: bool
+ @return: True if the current image could be set, if no window was available, return False.
+ """
diff --git a/source/blender/python/api2_2x/doc/Modifier.py b/source/blender/python/api2_2x/doc/Modifier.py
index c721b3ea021..5c24fd45d0a 100644
--- a/source/blender/python/api2_2x/doc/Modifier.py
+++ b/source/blender/python/api2_2x/doc/Modifier.py
@@ -59,45 +59,51 @@ Example::
@type Settings: readonly dictionary
@var Settings: Constant Modifier dict used for changing modifier settings.
- - RENDER - Used for all modifiers
- - REALTIME - Used for all modifiers
- - EDITMODE - Used for all modifiers
- - ONCAGE - Used for all modifiers
-
- - OBJECT - Used for Armature, Lattice, Curve, Boolean and Array
- - VERTGROUP - Used for Armature, Lattice and Curve
- - LIMIT - Array and Mirror
- - FLAG - Mirror and Wave
- - COUNT - Decimator and Array
+ - RENDER - Used for all modifiers (bool)
+ - REALTIME - Used for all modifiers (bool)
+ - EDITMODE - Used for all modifiers (bool)
+ - ONCAGE - Used for all modifiers (bool)
+
+ - OBJECT - Used for Armature, Lattice, Curve, Boolean and Array (Object)
+ - VERTGROUP - Used for Armature, Lattice and Curve (String)
+ - LIMIT - Array and Mirror (float [0.0 - 1.0])
+ - FLAG - Mirror and Wave (int)
+ - COUNT - Decimator Polycount (readonly) and Array (int)
+ - LENGTH - Build [1.0-300000.0] and Array [0.0 - 10000.0] (float)
- TYPES - Used for Subsurf only
- - LEVELS - Used for Subsurf only
- - RENDLEVELS - Used for Subsurf only
- - OPTIMAL - Used for Subsurf only
- - UV - Used for Subsurf only
-
-
- - ENVELOPES - Used for Armature only
+ - LEVELS - Used for Subsurf only (int [0 - 6])
+ - RENDLEVELS - Used for Subsurf only (int [0 - 6])
+ - OPTIMAL - Used for Subsurf only (bool)
+ - UV - Used for Subsurf only (bool)
+
+ - OBJECT_OFFSET - Used for Array only (Object)
+ - OBJECT_CURVE - Used for Array only (Curve Object)
+ - OFFSET_VEC - Used for Array only (3d Vector)
+ - SCALE_VEC - Used for Array only (3d Vector)
+ - MERGE_DIST - Used for Array only (float)
+
+ - ENVELOPES - Used for Armature only (bool)
- - START - Used for Build only
- - LENGTH - Used for Build only
- - SEED - Used for Build only
- - RANDOMIZE - Used for Build only
+ - START - Used for Build only (int)
+ - SEED - Used for Build only (int)
+ - RANDOMIZE - Used for Build only (bool)
- - AXIS - Used for Mirror only
+ - AXIS - Used for Mirror only (int [0 - 2])
- - RATIO - Used for Decimate only
+ - RATIO - Used for Decimate only (float [0.0 - 1.0])
+
+ - STARTX - Used for Wave only (float [-100.0 - 100.0])
+ - STARTY - Used for Wave only (float [-100.0 - 100.0])
+ - HEIGHT - Used for Wave only (float [-2.0 - 2.0])
+ - WIDTH - Used for Wave only (float [0.0 - 5.0])
+ - NARROW - Used for Wave only (float [0.0 - 10.0])
+ - SPEED - Used for Wave only (float [-2.0 - 2.0])
+ - DAMP - Used for Wave only (float [-1000.0 - 1000.0])
+ - LIFETIME - Used for Wave only (float [-1000.0 - 1000.0])
+ - TIMEOFFS - Used for Wave only (float [-1000.0 - 1000.0])
- - STARTX - Used for Wave only
- - STARTY - Used for Wave only
- - HEIGHT - Used for Wave only
- - WIDTH - Used for Wave only
- - NARROW - Used for Wave only
- - SPEED - Used for Wave only
- - DAMP - Used for Wave only
- - LIFETIME - Used for Wave only
- - TIMEOFFS - Used for Wave only
- - OPERATION - Used for Wave only
+ - OPERATION - Used for boolean only (int 0,1,2 : Intersect, Union, Difference)
"""
class Modifiers:
diff --git a/source/blender/python/api2_2x/gen_utils.c b/source/blender/python/api2_2x/gen_utils.c
index 7748dc91618..afd3f001917 100644
--- a/source/blender/python/api2_2x/gen_utils.c
+++ b/source/blender/python/api2_2x/gen_utils.c
@@ -39,6 +39,8 @@
#include "BKE_global.h"
#include "BKE_main.h"
+#include "Mathutils.h"
+
#include "constant.h"
//---------------------- EXPP_FloatsAreEqual -------------------------
@@ -683,6 +685,26 @@ int EXPP_setIValueClamped( PyObject *value, void *param,
}
}
+int EXPP_setVec3Clamped( PyObject *value, float *param[3],
+ float min, float max )
+{
+ if( VectorObject_Check( value ) ) {
+ VectorObject *vect = (VectorObject *)value;
+ if( vect->size == 3 ) {
+ *param[0] = EXPP_ClampFloat( vect->vec[0], min, max );
+ *param[1] = EXPP_ClampFloat( vect->vec[1], min, max );
+ *param[2] = EXPP_ClampFloat( vect->vec[2], min, max );
+ return 0;
+ }
+ }
+
+ if (1) {
+ char errstr[128];
+ sprintf ( errstr, "expected vector argument in [%f,%f]", min, max );
+ return EXPP_ReturnIntError( PyExc_TypeError, errstr );
+ }
+}
+
/*
* Utility routines to range-check and store various datatypes. The object
diff --git a/source/blender/python/api2_2x/gen_utils.h b/source/blender/python/api2_2x/gen_utils.h
index f9336282eef..2c75c074c06 100644
--- a/source/blender/python/api2_2x/gen_utils.h
+++ b/source/blender/python/api2_2x/gen_utils.h
@@ -114,6 +114,8 @@ int EXPP_setIValueClamped( PyObject *value, void *param,
int min, int max, char type );
int EXPP_setFloatClamped ( PyObject *value, float *param,
float min, float max);
+int EXPP_setVec3Clamped ( PyObject *value, float *param[3],
+ float min, float max);
int EXPP_setIValueRange( PyObject *value, void *param,
int min, int max, char type );
int EXPP_setFloatRange ( PyObject *value, float *param,