Revision: 27666
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27666
Author:   campbellbarton
Date:     2010-03-22 18:25:29 +0100 (Mon, 22 Mar 2010)

Log Message:
-----------
py/rna functions for adding and removing curve data.

Modified Paths:
--------------
    branches/render25/source/blender/makesrna/RNA_enum_types.h
    branches/render25/source/blender/makesrna/RNA_types.h
    branches/render25/source/blender/makesrna/intern/rna_main_api.c
    branches/render25/source/blender/makesrna/intern/rna_object.c

Modified: branches/render25/source/blender/makesrna/RNA_enum_types.h
===================================================================
--- branches/render25/source/blender/makesrna/RNA_enum_types.h  2010-03-22 
17:24:17 UTC (rev 27665)
+++ branches/render25/source/blender/makesrna/RNA_enum_types.h  2010-03-22 
17:25:29 UTC (rev 27666)
@@ -73,6 +73,8 @@
 
 extern EnumPropertyItem object_type_items[];
 
+extern EnumPropertyItem object_type_curve_items[];
+
 extern EnumPropertyItem space_type_items[];
 
 extern EnumPropertyItem keymap_propvalue_items[];

Modified: branches/render25/source/blender/makesrna/RNA_types.h
===================================================================
--- branches/render25/source/blender/makesrna/RNA_types.h       2010-03-22 
17:24:17 UTC (rev 27665)
+++ branches/render25/source/blender/makesrna/RNA_types.h       2010-03-22 
17:25:29 UTC (rev 27666)
@@ -340,6 +340,7 @@
 #define MainActions Main
 #define MainGroups Main
 #define MainTextures Main
+#define MainCurves Main
 
 #ifdef __cplusplus
 }

Modified: branches/render25/source/blender/makesrna/intern/rna_main_api.c
===================================================================
--- branches/render25/source/blender/makesrna/intern/rna_main_api.c     
2010-03-22 17:24:17 UTC (rev 27665)
+++ branches/render25/source/blender/makesrna/intern/rna_main_api.c     
2010-03-22 17:25:29 UTC (rev 27666)
@@ -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 @@
        /* 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_window_managers(BlenderRNA *brna, PropertyRNA *cprop)
 {
-
+    
 }
 void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop)
 {
@@ -552,7 +567,29 @@
 }
 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)
 {

Modified: branches/render25/source/blender/makesrna/intern/rna_object.c
===================================================================
--- branches/render25/source/blender/makesrna/intern/rna_object.c       
2010-03-22 17:24:17 UTC (rev 27665)
+++ branches/render25/source/blender/makesrna/intern/rna_object.c       
2010-03-22 17:25:29 UTC (rev 27666)
@@ -76,12 +76,17 @@
        //{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,11 @@
        {OB_LAMP, "LAMP", 0, "Lamp", ""},
        {0, NULL, 0, NULL, NULL}};
 
+EnumPropertyItem object_type_curve_items[] = {
+       OBTYPE_CU_CURVE,
+       OBTYPE_CU_SURF,
+       OBTYPE_CU_TEXT};
+    
 #ifdef RNA_RUNTIME
 
 #include "BLI_math.h"


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to