diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-03-23 17:58:36 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-03-23 17:58:36 +0300 |
commit | 33e0ea0e5940dba240dc68fe44b5295c31dcb974 (patch) | |
tree | 621647cf7ddf2222d70baed9140768068e9ba113 /source/blender/makesrna | |
parent | 5fad6edcb010f75c3918d0a21bf95f94a687522b (diff) |
py/rna functions for adding and removing curve data.
(commit 27666 by Campbell from render25 branch)
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/RNA_enum_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/RNA_types.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_main_api.c | 39 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 17 |
4 files changed, 55 insertions, 4 deletions
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index 9ccab8394e9..6adad6aa92c 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -73,6 +73,8 @@ extern EnumPropertyItem unpack_method_items[]; extern EnumPropertyItem object_type_items[]; +extern EnumPropertyItem object_type_curve_items[]; + extern EnumPropertyItem space_type_items[]; extern EnumPropertyItem keymap_propvalue_items[]; diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index 77eff6ad4c5..e09bd19774c 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -340,6 +340,7 @@ typedef struct ExtensionRNA { #define MainActions Main #define MainGroups Main #define MainTextures Main +#define MainCurves Main #ifdef __cplusplus } diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 9433294fdd3..690b671c318 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -54,6 +54,7 @@ #include "DNA_armature_types.h" #include "DNA_camera_types.h" +#include "DNA_curve_types.h" #include "DNA_lamp_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" @@ -243,6 +244,20 @@ void rna_Main_images_remove(Main *bmain, ReportList *reports, Image *image) /* XXX python now has invalid pointer? */ } +Curve *rna_Main_curves_new(Main *bmain, char* name, int type) +{ + Curve *cu= add_curve(name, type); + cu->id.us--; + return cu; +} +void rna_Main_curves_remove(Main *bmain, ReportList *reports, struct Curve *cu) +{ + if(ID_REAL_USERS(cu) <= 0) + free_libblock(&bmain->curve, cu); + else + BKE_reportf(reports, RPT_ERROR, "Curve \"%s\" must have zero users to be removed, found %d.", cu->id.name+2, ID_REAL_USERS(cu)); +} + Tex *rna_Main_textures_new(Main *bmain, char* name) { Tex *tex= add_texture(name); @@ -508,7 +523,7 @@ void RNA_def_main_screens(BlenderRNA *brna, PropertyRNA *cprop) } void RNA_def_main_window_managers(BlenderRNA *brna, PropertyRNA *cprop) { - + } void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop) { @@ -552,7 +567,29 @@ void RNA_def_main_lattices(BlenderRNA *brna, PropertyRNA *cprop) } void RNA_def_main_curves(BlenderRNA *brna, PropertyRNA *cprop) { + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "MainCurves"); + srna= RNA_def_struct(brna, "MainCurves", NULL); + RNA_def_struct_ui_text(srna, "Main Curves", "Collection of curves"); + func= RNA_def_function(srna, "new", "rna_Main_curves_new"); + RNA_def_function_ui_description(func, "Add a new curve to the main database"); + parm= RNA_def_string(func, "name", "Curve", 0, "", "New name for the datablock."); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_enum(func, "type", object_type_curve_items, 0, "Type", "The type of curve object to add"); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* return type */ + parm= RNA_def_pointer(func, "curve", "Curve", "", "New curve datablock."); + RNA_def_function_return(func, parm); + + func= RNA_def_function(srna, "remove", "rna_Main_curves_remove"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Remove a curve from the current blendfile."); + parm= RNA_def_pointer(func, "curve", "Curve", "", "Curve to remove."); + RNA_def_property_flag(parm, PROP_REQUIRED); } void RNA_def_main_metaballs(BlenderRNA *brna, PropertyRNA *cprop) { diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 8fd2528e2be..b0fd3eb58e2 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -76,12 +76,17 @@ static EnumPropertyItem collision_bounds_items[] = { //{OB_DYN_MESH, "DYNAMIC_MESH", 0, "Dynamic Mesh", ""}, {0, NULL, 0, NULL, NULL}}; +/* used for 2 enums */ +#define OBTYPE_CU_CURVE {OB_CURVE, "CURVE", 0, "Curve", ""} +#define OBTYPE_CU_SURF {OB_SURF, "SURFACE", 0, "Surface", ""} +#define OBTYPE_CU_TEXT {OB_FONT, "TEXT", 0, "Text", ""} + EnumPropertyItem object_type_items[] = { {OB_MESH, "MESH", 0, "Mesh", ""}, - {OB_CURVE, "CURVE", 0, "Curve", ""}, - {OB_SURF, "SURFACE", 0, "Surface", ""}, + OBTYPE_CU_CURVE, + OBTYPE_CU_SURF, {OB_MBALL, "META", 0, "Meta", ""}, - {OB_FONT, "TEXT", 0, "Text", ""}, + OBTYPE_CU_TEXT, {0, "", 0, NULL, NULL}, {OB_ARMATURE, "ARMATURE", 0, "Armature", ""}, {OB_LATTICE, "LATTICE", 0, "Lattice", ""}, @@ -91,6 +96,12 @@ EnumPropertyItem object_type_items[] = { {OB_LAMP, "LAMP", 0, "Lamp", ""}, {0, NULL, 0, NULL, NULL}}; +EnumPropertyItem object_type_curve_items[] = { + OBTYPE_CU_CURVE, + OBTYPE_CU_SURF, + OBTYPE_CU_TEXT, + {0, NULL, 0, NULL, NULL}}; + #ifdef RNA_RUNTIME #include "BLI_math.h" |