- internal py/rna ifdef's USE_MATHUTILS was mixed up,

- updated tooltip for vertex group mirror.
This commit is contained in:
Campbell Barton 2010-12-09 06:08:19 +00:00
parent b25c32393d
commit de159a67aa
2 changed files with 58 additions and 51 deletions

@ -1836,7 +1836,7 @@ void OBJECT_OT_vertex_group_mirror(wmOperatorType *ot)
/* identifiers */
ot->name= "Mirror Vertex Group";
ot->idname= "OBJECT_OT_vertex_group_mirror";
ot->description= "Mirror weights, and flip vertex group names, copying when only one side is selected";
ot->description= "Mirror all vertex groups, flip weights and/or names, editing only selected vertices, flipping when both sides are selected otherwise copy from unselected";
/* api callbacks */
ot->poll= vertex_group_poll_edit;
@ -1847,7 +1847,7 @@ void OBJECT_OT_vertex_group_mirror(wmOperatorType *ot)
/* properties */
RNA_def_boolean(ot->srna, "mirror_weights", TRUE, "Mirror Weights", "Mirror weights.");
RNA_def_boolean(ot->srna, "flip_group_names", TRUE, "Flip Groups", "Flip vertex group names while mirroring.");
RNA_def_boolean(ot->srna, "flip_group_names", TRUE, "Flip Groups", "Flip vertex group names.");
}

@ -50,24 +50,13 @@
#include "DNA_anim_types.h"
#include "ED_keyframing.h"
#include "../generic/IDProp.h" /* for IDprop lookups */
#include "../generic/py_capi_utils.h"
#define USE_PEDANTIC_WRITE
#define USE_MATHUTILS
#define USE_STRING_COERCE
#ifdef USE_MATHUTILS
#include "../generic/mathutils.h" /* so we can have mathutils callbacks */
#include "../generic/IDProp.h" /* for IDprop lookups */
#include "../generic/py_capi_utils.h"
static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyObject *value, const char *error_prefix);
static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, PointerRNA *ptr, PropertyRNA *prop, int start, int stop, int length);
static Py_ssize_t pyrna_prop_array_length(BPy_PropertyArrayRNA *self);
static Py_ssize_t pyrna_prop_collection_length(BPy_PropertyRNA *self);
static short pyrna_rotation_euler_order_get(PointerRNA *ptr, PropertyRNA **prop_eul_order, short order_fallback);
static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item);
/* bpyrna vector/euler/quat callbacks */
static int mathutils_rna_array_cb_index= -1; /* index for our callbacks */
#ifdef USE_PEDANTIC_WRITE
static short rna_disallow_writes= FALSE;
@ -92,7 +81,21 @@ static int rna_id_write_error(PointerRNA *ptr, PyObject *key)
return FALSE;
}
#endif
#endif // USE_PEDANTIC_WRITE
static Py_ssize_t pyrna_prop_collection_length(BPy_PropertyRNA *self);
static Py_ssize_t pyrna_prop_array_length(BPy_PropertyArrayRNA *self);
static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyObject *value, const char *error_prefix);
static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item);
#ifdef USE_MATHUTILS
#include "../generic/mathutils.h" /* so we can have mathutils callbacks */
static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, PointerRNA *ptr, PropertyRNA *prop, int start, int stop, int length);
static short pyrna_rotation_euler_order_get(PointerRNA *ptr, PropertyRNA **prop_eul_order, short order_fallback);
/* bpyrna vector/euler/quat callbacks */
static int mathutils_rna_array_cb_index= -1; /* index for our callbacks */
/* subtype not used much yet */
#define MATHUTILS_CB_SUBTYPE_EUL 0
@ -135,7 +138,7 @@ static int mathutils_rna_vector_set(BaseMathObject *bmo, int subtype)
if(rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) {
return 0;
}
#endif
#endif // USE_PEDANTIC_WRITE
if (!RNA_property_editable_flag(&self->ptr, self->prop)) {
PyErr_Format(PyExc_AttributeError, "bpy_prop \"%.200s.%.200s\" is read-only", RNA_struct_identifier(self->ptr.type), RNA_property_identifier(self->prop));
@ -193,7 +196,7 @@ static int mathutils_rna_vector_set_index(BaseMathObject *bmo, int UNUSED(subtyp
if(rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) {
return 0;
}
#endif
#endif // USE_PEDANTIC_WRITE
if (!RNA_property_editable_flag(&self->ptr, self->prop)) {
PyErr_Format(PyExc_AttributeError, "bpy_prop \"%.200s.%.200s\" is read-only", RNA_struct_identifier(self->ptr.type), RNA_property_identifier(self->prop));
@ -244,7 +247,7 @@ static int mathutils_rna_matrix_set(BaseMathObject *bmo, int UNUSED(subtype))
if(rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) {
return 0;
}
#endif
#endif // USE_PEDANTIC_WRITE
if (!RNA_property_editable_flag(&self->ptr, self->prop)) {
PyErr_Format(PyExc_AttributeError, "bpy_prop \"%.200s.%.200s\" is read-only", RNA_struct_identifier(self->ptr.type), RNA_property_identifier(self->prop));
@ -268,19 +271,23 @@ Mathutils_Callback mathutils_rna_matrix_cb = {
NULL
};
/* same as RNA_enum_value_from_id but raises an exception */
int pyrna_enum_value_from_id(EnumPropertyItem *item, const char *identifier, int *value, const char *error_prefix)
static short pyrna_rotation_euler_order_get(PointerRNA *ptr, PropertyRNA **prop_eul_order, short order_fallback)
{
if(RNA_enum_value_from_id(item, identifier, value) == 0) {
char *enum_str= BPy_enum_as_string(item);
PyErr_Format(PyExc_TypeError, "%s: '%.200s' not found in (%s)", error_prefix, identifier, enum_str);
MEM_freeN(enum_str);
return -1;
/* attempt to get order */
if(*prop_eul_order==NULL)
*prop_eul_order= RNA_struct_find_property(ptr, "rotation_mode");
if(*prop_eul_order) {
short order= RNA_property_enum_get(ptr, *prop_eul_order);
if (order >= ROT_MODE_XYZ && order <= ROT_MODE_ZYX) /* could be quat or axisangle */
return order;
}
return 0;
return order_fallback;
}
#endif // USE_MATHUTILS
#define PROP_ALL_VECTOR_SUBTYPES PROP_TRANSLATION: case PROP_DIRECTION: case PROP_VELOCITY: case PROP_ACCELERATION: case PROP_XYZ: case PROP_XYZ_LENGTH
PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
@ -401,27 +408,25 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
ret = pyrna_prop_CreatePyObject(ptr, prop); /* owned by the Mathutils PyObject */
}
}
#endif
#else // USE_MATHUTILS
(void)ptr;
(void)prop;
#endif // USE_MATHUTILS
return ret;
}
#endif
static short pyrna_rotation_euler_order_get(PointerRNA *ptr, PropertyRNA **prop_eul_order, short order_fallback)
/* same as RNA_enum_value_from_id but raises an exception */
int pyrna_enum_value_from_id(EnumPropertyItem *item, const char *identifier, int *value, const char *error_prefix)
{
/* attempt to get order */
if(*prop_eul_order==NULL)
*prop_eul_order= RNA_struct_find_property(ptr, "rotation_mode");
if(*prop_eul_order) {
short order= RNA_property_enum_get(ptr, *prop_eul_order);
if (order >= ROT_MODE_XYZ && order <= ROT_MODE_ZYX) /* could be quat or axisangle */
return order;
if(RNA_enum_value_from_id(item, identifier, value) == 0) {
char *enum_str= BPy_enum_as_string(item);
PyErr_Format(PyExc_TypeError, "%s: '%.200s' not found in (%s)", error_prefix, identifier, enum_str);
MEM_freeN(enum_str);
return -1;
}
return order_fallback;
return 0;
}
static int pyrna_struct_compare( BPy_StructRNA * a, BPy_StructRNA * b )
@ -853,9 +858,9 @@ PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop)
else {
ret= PyUnicode_FromString(buf);
}
#else
#else // USE_STRING_COERCE
ret= PyUnicode_FromString(buf);
#endif
#endif // USE_STRING_COERCE
MEM_freeN(buf);
break;
}
@ -990,7 +995,7 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
if(!BaseMath_ReadCallback(mat))
return -1;
} else /* continue... */
#endif
#endif // USE_MATHUTILS
if (!PySequence_Check(value)) {
PyErr_Format(PyExc_TypeError, "%.200s RNA array assignment to %.200s.%.200s expected a sequence instead of %.200s instance", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
return -1;
@ -1072,9 +1077,9 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
else {
param= _PyUnicode_AsString(value);
}
#else
#else // USE_STRING_COERCE
param= _PyUnicode_AsString(value);
#endif
#endif // USE_STRING_COERCE
if (param==NULL) {
PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a string type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop));
@ -1086,7 +1091,7 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
}
#ifdef USE_STRING_COERCE
Py_XDECREF(value_coerce);
#endif
#endif // USE_STRING_COERCE
break;
}
case PROP_ENUM:
@ -1951,7 +1956,7 @@ static int pyrna_struct_ass_subscript( BPy_StructRNA *self, PyObject *key, PyObj
if(rna_disallow_writes && rna_id_write_error(&self->ptr, key)) {
return -1;
}
#endif
#endif // USE_STRING_COERCE
if(group==NULL) {
PyErr_SetString(PyExc_TypeError, "bpy_struct[key] = val: id properties not supported for this type");
@ -2781,7 +2786,7 @@ static int pyrna_struct_setattro( BPy_StructRNA *self, PyObject *pyname, PyObjec
if(rna_disallow_writes && rna_id_write_error(&self->ptr, pyname)) {
return -1;
}
#endif
#endif // USE_STRING_COERCE
if(name == NULL) {
PyErr_SetString(PyExc_AttributeError, "bpy_struct: __setattr__ must be a string");
@ -2900,7 +2905,7 @@ static int pyrna_prop_collection_setattro( BPy_PropertyRNA *self, PyObject *pyna
if(rna_disallow_writes && rna_id_write_error(&self->ptr, pyname)) {
return -1;
}
#endif
#endif // USE_STRING_COERCE
if(name == NULL) {
PyErr_SetString(PyExc_AttributeError, "bpy_prop: __setattr__ must be a string");
@ -3566,6 +3571,7 @@ PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *data)
break;
case PROP_FLOAT:
switch(RNA_property_subtype(prop)) {
#ifdef USE_MATHUTILS
case PROP_ALL_VECTOR_SUBTYPES:
ret= newVectorObject(data, len, Py_NEW, NULL);
break;
@ -3579,6 +3585,7 @@ PyObject *pyrna_param_to_py(PointerRNA *ptr, PropertyRNA *prop, void *data)
break;
}
/* pass through */
#endif
default:
ret = PyTuple_New(len);
for(a=0; a<len; a++)