diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-11-23 20:12:11 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-11-23 20:12:11 +0400 |
commit | 85497e35d0a012e8584022cfa021dd1b8435d17b (patch) | |
tree | 4262bec6539efdddc3e71d0fffe0e69f235db28d /source/blender/makesrna | |
parent | f48cc83b3e7327565c17fc18f42881099941b4bf (diff) |
Added method clear to most of collections which supports new/remove.
This method not added to animation-specific structures yet/
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_curve.c | 16 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_meta.c | 18 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_nodetree.c | 48 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 37 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 18 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 9 |
6 files changed, 144 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index 95f44d86058..3125c2eec08 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -588,6 +588,19 @@ static void rna_Curve_spline_remove(Curve *cu, ReportList *reports, Nurb *nu) freeNurb(nu); /* invalidate pointer!, no can do */ + + DAG_id_tag_update(&cu->id, OB_RECALC_DATA); + WM_main_add_notifier(NC_GEOM|ND_DATA, NULL); +} + +static void rna_Curve_spline_clear(Curve *cu) +{ + ListBase *nurbs= BKE_curve_nurbs(cu); + + freeNurblist(nurbs); + + DAG_id_tag_update(&cu->id, OB_RECALC_DATA); + WM_main_add_notifier(NC_GEOM|ND_DATA, NULL); } static PointerRNA rna_Curve_active_spline_get(PointerRNA *ptr) @@ -1200,6 +1213,9 @@ static void rna_def_curve_splines(BlenderRNA *brna, PropertyRNA *cprop) parm= RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove"); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + func= RNA_def_function(srna, "clear", "rna_Curve_spline_clear"); + RNA_def_function_ui_description(func, "Remove all spline from a curve"); + prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "Object"); RNA_def_property_pointer_funcs(prop, "rna_Curve_active_spline_get", "rna_Curve_active_spline_set", NULL, NULL); diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c index 323fb6780fb..5f948a3a243 100644 --- a/source/blender/makesrna/intern/rna_meta.c +++ b/source/blender/makesrna/intern/rna_meta.c @@ -147,6 +147,17 @@ static void rna_MetaBall_elements_remove(MetaBall *mb, ReportList *reports, Meta } } +static void rna_MetaBall_elements_clear(MetaBall *mb) +{ + BLI_freelistN(&mb->elems); + + /* cheating way for importers to avoid slow updates */ + if(mb->id.us > 0) { + DAG_id_tag_update(&mb->id, 0); + WM_main_add_notifier(NC_GEOM|ND_DATA, &mb->id); + } +} + #else static void rna_def_metaelement(BlenderRNA *brna) @@ -234,17 +245,20 @@ static void rna_def_metaball_elements(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_struct_ui_text(srna, "Meta Elements", "Collection of metaball elements"); func= RNA_def_function(srna, "new", "rna_MetaBall_elements_new"); - RNA_def_function_ui_description(func, "Add a new spline to the curve"); + RNA_def_function_ui_description(func, "Add a new element to the metaball"); RNA_def_enum(func, "type", metaelem_type_items, MB_BALL, "", "type for the new meta-element"); parm= RNA_def_pointer(func, "element", "MetaElement", "", "The newly created meta-element"); RNA_def_function_return(func, parm); func= RNA_def_function(srna, "remove", "rna_MetaBall_elements_remove"); - RNA_def_function_ui_description(func, "Remove a spline from a curve"); + RNA_def_function_ui_description(func, "Remove an element from the metaball"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "element", "MetaElement", "", "The element to remove"); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + func= RNA_def_function(srna, "clear", "rna_MetaBall_elements_clear"); + RNA_def_function_ui_description(func, "Remove all elements from the metaball"); + prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "lastelem"); RNA_def_property_ui_text(prop, "Active Element", "Last selected element"); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index cd1b74f2b38..062fbad421a 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -645,6 +645,26 @@ static void rna_NodeTree_node_remove(bNodeTree *ntree, ReportList *reports, bNod } } +static void rna_NodeTree_node_clear(bNodeTree *ntree) +{ + bNode *node= ntree->nodes.first; + + while(node) { + bNode *next_node= node->next; + + if (node->id) + id_us_min(node->id); + + nodeFreeNode(ntree, node); + + node= next_node; + } + + ntreeUpdateTree(ntree); /* update group node socket links*/ + + WM_main_add_notifier(NC_NODE|NA_EDITED, ntree); +} + static bNodeLink *rna_NodeTree_link_new(bNodeTree *ntree, ReportList *reports, bNodeSocket *in, bNodeSocket *out) { bNodeLink *ret; @@ -687,6 +707,22 @@ static void rna_NodeTree_link_remove(bNodeTree *ntree, ReportList *reports, bNod } } +static void rna_NodeTree_link_clear(bNodeTree *ntree) +{ + bNodeLink *link= ntree->links.first; + + while(link) { + bNodeLink *next_link= link->next; + + nodeRemLink(ntree, link); + + link= next_link; + } + ntreeUpdateTree(ntree); + + WM_main_add_notifier(NC_NODE|NA_EDITED, ntree); +} + static bNodeSocket *rna_NodeTree_input_new(bNodeTree *ntree, ReportList *UNUSED(reports), const char *name, int type) { /* XXX should check if tree is a group here! no good way to do this currently. */ @@ -2828,6 +2864,9 @@ static void rna_def_nodetree_link_api(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "link", "NodeLink", "", "The node link to remove"); RNA_def_property_flag(parm, PROP_REQUIRED); + + func= RNA_def_function(srna, "clear", "rna_NodeTree_link_clear"); + RNA_def_function_ui_description(func, "remove all node links from the node tree"); } static void rna_def_composite_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop) @@ -2856,6 +2895,9 @@ static void rna_def_composite_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "node", "Node", "", "The node to remove"); RNA_def_property_flag(parm, PROP_REQUIRED); + + func= RNA_def_function(srna, "clear", "rna_NodeTree_node_clear"); + RNA_def_function_ui_description(func, "Remove all nodes from this node tree"); } static void rna_def_shader_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop) @@ -2884,6 +2926,9 @@ static void rna_def_shader_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "node", "Node", "", "The node to remove"); RNA_def_property_flag(parm, PROP_REQUIRED); + + func= RNA_def_function(srna, "clear", "rna_NodeTree_node_clear"); + RNA_def_function_ui_description(func, "Remove all nodes from this node tree"); } static void rna_def_texture_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop) @@ -2912,6 +2957,9 @@ static void rna_def_texture_nodetree_api(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "node", "Node", "", "The node to remove"); RNA_def_property_flag(parm, PROP_REQUIRED); + + func= RNA_def_function(srna, "clear", "rna_NodeTree_node_clear"); + RNA_def_function_ui_description(func, "Remove all nodes from this node tree"); } static void rna_def_node_socket(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 6e797146f12..9dd6d2e8175 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -1156,6 +1156,16 @@ static void rna_Object_constraints_remove(Object *object, ReportList *reports, b WM_main_add_notifier(NC_OBJECT|ND_CONSTRAINT|NA_REMOVED, object); } +static void rna_Object_constraints_clear(Object *object) +{ + free_constraints(&object->constraints); + + ED_object_constraint_update(object); + ED_object_constraint_set_active(object, NULL); + + WM_main_add_notifier(NC_OBJECT|ND_CONSTRAINT|NA_REMOVED, object); +} + static ModifierData *rna_Object_modifier_new(Object *object, bContext *C, ReportList *reports, const char *name, int type) { return ED_object_modifier_add(reports, CTX_data_main(C), CTX_data_scene(C), object, name, type); @@ -1164,6 +1174,15 @@ static ModifierData *rna_Object_modifier_new(Object *object, bContext *C, Report static void rna_Object_modifier_remove(Object *object, bContext *C, ReportList *reports, ModifierData *md) { ED_object_modifier_remove(reports, CTX_data_main(C), CTX_data_scene(C), object, md); + + WM_main_add_notifier(NC_OBJECT|ND_MODIFIER|NA_REMOVED, object); +} + +static void rna_Object_modifier_clear(Object *object, bContext *C) +{ + ED_object_modifier_clear(CTX_data_main(C), CTX_data_scene(C), object); + + WM_main_add_notifier(NC_OBJECT|ND_MODIFIER|NA_REMOVED, object); } static void rna_Object_boundbox_get(PointerRNA *ptr, float *values) @@ -1195,6 +1214,13 @@ static void rna_Object_vgroup_remove(Object *ob, bDeformGroup *defgroup) WM_main_add_notifier(NC_OBJECT|ND_DRAW, ob); } +static void rna_Object_vgroup_clear(Object *ob) +{ + ED_vgroup_clear(ob); + + WM_main_add_notifier(NC_OBJECT|ND_DRAW, ob); +} + static void rna_VertexGroup_vertex_add(ID *id, bDeformGroup *def, ReportList *reports, int index_len, int *index, float weight, int assignmode) { @@ -1636,6 +1662,9 @@ static void rna_def_object_constraints(BlenderRNA *brna, PropertyRNA *cprop) /* constraint to remove */ parm= RNA_def_pointer(func, "constraint", "Constraint", "", "Removed constraint"); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "clear", "rna_Object_constraints_clear"); + RNA_def_function_ui_description(func, "Remove all constraint from this object"); } /* object.modifiers */ @@ -1684,6 +1713,11 @@ static void rna_def_object_modifiers(BlenderRNA *brna, PropertyRNA *cprop) /* target to remove*/ parm= RNA_def_pointer(func, "modifier", "Modifier", "", "Modifier to remove"); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + /* clear all modifiers */ + func= RNA_def_function(srna, "clear", "rna_Object_modifier_clear"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Remove all modifiers from the object"); } /* object.particle_systems */ @@ -1758,6 +1792,9 @@ static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Delete vertex group from object"); parm= RNA_def_pointer(func, "group", "VertexGroup", "", "Vertex group to remove"); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "clear", "rna_Object_vgroup_clear"); + RNA_def_function_ui_description(func, "Delete all vertex groups from object"); } diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index f1dfa819140..8e162f27e52 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1194,6 +1194,10 @@ static TimeMarker *rna_TimeLine_add(Scene *scene, const char name[]) marker->frame= 1; BLI_strncpy_utf8(marker->name, name, sizeof(marker->name)); BLI_addtail(&scene->markers, marker); + + WM_main_add_notifier(NC_SCENE|ND_MARKERS, NULL); + WM_main_add_notifier(NC_ANIMATION|ND_MARKERS, NULL); + return marker; } @@ -1206,6 +1210,17 @@ static void rna_TimeLine_remove(Scene *scene, ReportList *reports, TimeMarker *m /* XXX, invalidates PyObject */ MEM_freeN(marker); + + WM_main_add_notifier(NC_SCENE|ND_MARKERS, NULL); + WM_main_add_notifier(NC_ANIMATION|ND_MARKERS, NULL); +} + +static void rna_TimeLine_clear(Scene *scene) +{ + BLI_freelistN(&scene->markers); + + WM_main_add_notifier(NC_SCENE|ND_MARKERS, NULL); + WM_main_add_notifier(NC_ANIMATION|ND_MARKERS, NULL); } static KeyingSet *rna_Scene_keying_set_new(Scene *sce, ReportList *reports, const char name[]) @@ -3605,6 +3620,9 @@ static void rna_def_timeline_markers(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "marker", "TimelineMarker", "", "Timeline marker to remove"); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "clear", "rna_TimeLine_clear"); + RNA_def_function_ui_description(func, "Remove all timeline markers"); } /* scene.keying_sets */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 9f6f0bb7802..495a83f4bbe 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -911,6 +911,12 @@ static void rna_BackgroundImage_remove(View3D *v3d, ReportList *reports, BGpic * } } +static void rna_BackgroundImage_clear(View3D *v3d) +{ + ED_view3D_background_image_clear(v3d); + WM_main_add_notifier(NC_SPACE|ND_SPACE_VIEW3D, v3d); +} + /* Space Node Editor */ static int rna_SpaceNodeEditor_node_tree_poll(PointerRNA *ptr, PointerRNA value) @@ -1328,6 +1334,9 @@ static void rna_def_backgroundImages(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_flag(func, FUNC_USE_REPORTS); parm= RNA_def_pointer(func, "image", "BackgroundImage", "", "Image displayed as viewport background"); RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + + func= RNA_def_function(srna, "clear", "rna_BackgroundImage_clear"); + RNA_def_function_ui_description(func, "Remove all background images"); } static void rna_def_space_view3d(BlenderRNA *brna) |