Revision: 22260
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22260
Author:   campbellbarton
Date:     2009-08-06 15:15:23 +0200 (Thu, 06 Aug 2009)

Log Message:
-----------
pedantic changes to python UI scripts
- SOFTBODY -> SOFT_BODY
- Use getattr() with enum value to get the modifier function rather then a lot 
of elif's

Modified Paths:
--------------
    branches/blender2.5/blender/release/ui/buttons_data_camera.py
    branches/blender2.5/blender/release/ui/buttons_data_metaball.py
    branches/blender2.5/blender/release/ui/buttons_data_modifier.py
    branches/blender2.5/blender/release/ui/buttons_game.py
    branches/blender2.5/blender/release/ui/buttons_material.py
    branches/blender2.5/blender/release/ui/buttons_physics_cloth.py
    branches/blender2.5/blender/release/ui/buttons_physics_fluid.py
    branches/blender2.5/blender/release/ui/buttons_physics_softbody.py
    branches/blender2.5/blender/release/ui/buttons_texture.py
    branches/blender2.5/blender/release/ui/space_image.py
    branches/blender2.5/blender/release/ui/space_info.py
    branches/blender2.5/blender/release/ui/space_text.py
    branches/blender2.5/blender/release/ui/space_view3d.py
    branches/blender2.5/blender/release/ui/space_view3d_toolbar.py
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_modifier.c

Modified: branches/blender2.5/blender/release/ui/buttons_data_camera.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_data_camera.py       
2009-08-06 13:01:24 UTC (rev 22259)
+++ branches/blender2.5/blender/release/ui/buttons_data_camera.py       
2009-08-06 13:15:23 UTC (rev 22260)
@@ -7,7 +7,7 @@
        __context__ = "data"
 
        def poll(self, context):
-               return (context.camera)
+               return (context.camera != None)
                
 class DATA_PT_context_camera(DataButtonsPanel):
        __show_header__ = False

Modified: branches/blender2.5/blender/release/ui/buttons_data_metaball.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_data_metaball.py     
2009-08-06 13:01:24 UTC (rev 22259)
+++ branches/blender2.5/blender/release/ui/buttons_data_metaball.py     
2009-08-06 13:15:23 UTC (rev 22260)
@@ -109,4 +109,4 @@
 
 bpy.types.register(DATA_PT_context_metaball)
 bpy.types.register(DATA_PT_metaball)
-bpy.types.register(DATA_PT_metaball_element)
\ No newline at end of file
+bpy.types.register(DATA_PT_metaball_element)

Modified: branches/blender2.5/blender/release/ui/buttons_data_modifier.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_data_modifier.py     
2009-08-06 13:01:24 UTC (rev 22259)
+++ branches/blender2.5/blender/release/ui/buttons_data_modifier.py     
2009-08-06 13:15:23 UTC (rev 22260)
@@ -16,76 +16,20 @@
 
                row = layout.row()
                row.item_menu_enumO("object.modifier_add", "type")
-               row.itemL();
+               row.itemL()
+               
+               class_dict = self.__class__.__dict__
 
                for md in ob.modifiers:
                        box = layout.template_modifier(md)
-
                        if box:
-                               if md.type == 'ARMATURE':
-                                       self.armature(box, ob, md)
-                               elif md.type == 'ARRAY':
-                                       self.array(box, ob, md)
-                               elif md.type == 'BEVEL':
-                                       self.bevel(box, ob, md)
-                               elif md.type == 'BOOLEAN':
-                                       self.boolean(box, ob, md)
-                               elif md.type == 'BUILD':
-                                       self.build(box, ob, md)
-                               elif md.type == 'CAST':
-                                       self.cast(box, ob, md)
-                               elif md.type == 'CLOTH':
-                                       self.cloth(box, ob, md)
-                               elif md.type == 'COLLISION':
-                                       self.collision(box, ob, md)
-                               elif md.type == 'CURVE':
-                                       self.curve(box, ob, md)
-                               elif md.type == 'DECIMATE':
-                                       self.decimate(box, ob, md)
-                               elif md.type == 'DISPLACE':
-                                       self.displace(box, ob, md)
-                               elif md.type == 'EDGE_SPLIT':
-                                       self.edgesplit(box, ob, md)
-                               elif md.type == 'EXPLODE':
-                                       self.explode(box, ob, md)
-                               elif md.type == 'FLUID_SIMULATION':
-                                       self.fluid(box, ob, md)
-                               elif md.type == 'HOOK':
-                                       self.hook(box, ob, md)
-                               elif md.type == 'LATTICE':
-                                       self.lattice(box, ob, md)
-                               elif md.type == 'MASK':
-                                       self.mask(box, ob, md)
-                               elif md.type == 'MESH_DEFORM':
-                                       self.mesh_deform(box, ob, md)
-                               elif md.type == 'MIRROR':
-                                       self.mirror(box, ob, md)
-                               elif md.type == 'MULTIRES':
-                                       self.multires(box, ob, md)
-                               elif md.type == 'PARTICLE_INSTANCE':
-                                       self.particleinstance(box, ob, md)
-                               elif md.type == 'PARTICLE_SYSTEM':
-                                       self.particlesystem(box, ob, md)
-                               elif md.type == 'SHRINKWRAP':
-                                       self.shrinkwrap(box, ob, md)
-                               elif md.type == 'SIMPLE_DEFORM':
-                                       self.simpledeform(box, ob, md)
-                               elif md.type == 'SMOKE':
-                                       self.smoke(box, ob, md)
-                               elif md.type == 'SMOOTH':
-                                       self.smooth(box, ob, md)
-                               elif md.type == 'SOFTBODY':
-                                       self.softbody(box, ob, md)
-                               elif md.type == 'SUBSURF':
-                                       self.subsurf(box, ob, md)
-                               elif md.type == 'SURFACE':
-                                       self.surface(box, ob, md)
-                               elif md.type == 'UV_PROJECT':
-                                       self.uvproject(box, ob, md)
-                               elif md.type == 'WAVE':
-                                       self.wave(box, ob, md)
-                                                       
-       def armature(self, layout, ob, md):
+                               # match enum type to our functions, avoids a 
lookup table.
+                               getattr(self, md.type)(box, ob, md)
+       
+       # the mt.type enum is (ab)used for a lookup on function names
+       # ...to avoid lengthy if statements
+       # so each type must have a function here.
+       def ARMATURE(self, layout, ob, md):
                layout.itemR(md, "object")
                
                row = layout.row()
@@ -98,7 +42,7 @@
                flow.itemR(md, "quaternion")
                flow.itemR(md, "multi_modifier")
                
-       def array(self, layout, ob, md):
+       def ARRAY(self, layout, ob, md):
                layout.itemR(md, "fit_type")
                if md.fit_type == 'FIXED_COUNT':
                        layout.itemR(md, "count")
@@ -144,7 +88,7 @@
                col.itemR(md, "start_cap")
                col.itemR(md, "end_cap")
        
-       def bevel(self, layout, ob, md):
+       def BEVEL(self, layout, ob, md):
                row = layout.row()
                row.itemR(md, "width")
                row.itemR(md, "only_vertices")
@@ -156,11 +100,11 @@
                elif md.limit_method == 'WEIGHT':
                        layout.row().itemR(md, "edge_weight_method", 
expand=True)
                        
-       def boolean(self, layout, ob, md):
+       def BOOLEAN(self, layout, ob, md):
                layout.itemR(md, "operation")
                layout.itemR(md, "object")
                
-       def build(self, layout, ob, md):
+       def BUILD(self, layout, ob, md):
                split = layout.split()
                
                col = split.column()
@@ -173,7 +117,7 @@
                sub.active = md.randomize
                sub.itemR(md, "seed")
 
-       def cast(self, layout, ob, md):
+       def CAST(self, layout, ob, md):
                layout.itemR(md, "cast_type")
                layout.itemR(md, "object")
                if md.object:
@@ -191,22 +135,22 @@
                
                layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
                
-       def cloth(self, layout, ob, md):
+       def CLOTH(self, layout, ob, md):
                layout.itemL(text="See Cloth panel.")
                
-       def collision(self, layout, ob, md):
+       def COLLISION(self, layout, ob, md):
                layout.itemL(text="See Collision panel.")
                
-       def curve(self, layout, ob, md):
+       def CURVE(self, layout, ob, md):
                layout.itemR(md, "object")
                layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
                layout.itemR(md, "deform_axis")
                
-       def decimate(self, layout, ob, md):
+       def DECIMATE(self, layout, ob, md):
                layout.itemR(md, "ratio")
                layout.itemR(md, "face_count")
                
-       def displace(self, layout, ob, md):
+       def DISPLACE(self, layout, ob, md):
                layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
                layout.itemR(md, "texture")
                layout.itemR(md, "midlevel")
@@ -218,7 +162,7 @@
                elif md.texture_coordinates == 'UV' and ob.type == 'MESH':
                        layout.item_pointerR(md, "uv_layer", ob.data, 
"uv_layers")
        
-       def edgesplit(self, layout, ob, md):
+       def EDGE_SPLIT(self, layout, ob, md):
                split = layout.split()
                
                col = split.column()
@@ -230,7 +174,7 @@
                col = split.column()
                col.itemR(md, "use_sharp", text="Sharp Edges")
                
-       def explode(self, layout, ob, md):
+       def EXPLODE(self, layout, ob, md):
                layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
                layout.itemR(md, "protect")
                layout.itemR(md, "split_edges")
@@ -239,21 +183,21 @@
                layout.itemR(md, "dead")
                # Missing: "Refresh" and "Clear Vertex Group" Operator
                
-       def fluid(self, layout, ob, md):
+       def FLUID_SIMULATION(self, layout, ob, md):
                layout.itemL(text="See Fluid panel.")
                
-       def hook(self, layout, ob, md):
+       def HOOK(self, layout, ob, md):
                layout.itemR(md, "falloff")
                layout.itemR(md, "force", slider=True)
                layout.itemR(md, "object")
                layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
                # Missing: "Reset" and "Recenter" Operator
                
-       def lattice(self, layout, ob, md):
+       def LATTICE(self, layout, ob, md):
                layout.itemR(md, "object")
                layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
                
-       def mask(self, layout, ob, md):
+       def MASK(self, layout, ob, md):
                layout.itemR(md, "mode")
                if md.mode == 'ARMATURE':
                        layout.itemR(md, "armature")
@@ -261,7 +205,7 @@
                        layout.item_pointerR(md, "vertex_group", ob, 
"vertex_groups")
                layout.itemR(md, "inverse")
                
-       def mesh_deform(self, layout, ob, md):
+       def MESH_DEFORM(self, layout, ob, md):
                layout.itemR(md, "object")
                layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
                layout.itemR(md, "invert")
@@ -273,7 +217,7 @@
                row.itemR(md, "precision")
                row.itemR(md, "dynamic")
                
-       def mirror(self, layout, ob, md):
+       def MIRROR(self, layout, ob, md):
                layout.itemR(md, "merge_limit")
                split = layout.split()
                
@@ -293,12 +237,12 @@
                
                layout.itemR(md, "mirror_object")
                
-       def multires(self, layout, ob, md):
+       def MULTIRES(self, layout, ob, md):
                layout.itemR(md, "subdivision_type")
                layout.itemO("object.multires_subdivide", text="Subdivide")
                layout.itemR(md, "level")
        
-       def particleinstance(self, layout, ob, md):
+       def PARTICLE_INSTANCE(self, layout, ob, md):
                layout.itemR(md, "object")
                layout.itemR(md, "particle_system_number")
                
@@ -321,10 +265,10 @@
                        row.itemR(md, "position", slider=True)
                        row.itemR(md, "random_position", text = "Random", 
slider=True)
                
-       def particlesystem(self, layout, ob, md):
+       def PARTICLE_SYSTEM(self, layout, ob, md):
                layout.itemL(text="See Particle panel.")
                
-       def shrinkwrap(self, layout, ob, md):
+       def SHRINKWRAP(self, layout, ob, md):
                layout.itemR(md, "target")
                layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
                layout.itemR(md, "offset")
@@ -347,7 +291,7 @@
                elif md.mode == 'NEAREST_SURFACEPOINT':
                        layout.itemR(md, "keep_above_surface")
                
-       def simpledeform(self, layout, ob, md):
+       def SIMPLE_DEFORM(self, layout, ob, md):
                layout.itemR(md, "mode")
                layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
                layout.itemR(md, "origin")
@@ -358,7 +302,7 @@
                        layout.itemR(md, "lock_x_axis")
                        layout.itemR(md, "lock_y_axis")
                        
-       def smoke(self, layout, ob, md):
+       def SMOKE(self, layout, ob, md):
                layout.itemR(md, "smoke_type")
                
                if md.smoke_type == 'TYPE_DOMAIN':
@@ -383,7 +327,7 @@
                elif md.smoke_type == 'TYPE_COLL':
                        layout.itemS()
        
-       def smooth(self, layout, ob, md):
+       def SMOOTH(self, layout, ob, md):
                split = layout.split()
                
                col = split.column()
@@ -397,10 +341,10 @@
                
                layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
                
-       def softbody(self, layout, ob, md):
+       def SOFT_BODY(self, layout, ob, md):
                layout.itemL(text="See Soft Body panel.")
        
-       def subsurf(self, layout, ob, md):
+       def SUBSURF(self, layout, ob, md):
                layout.itemR(md, "subdivision_type")
                
                flow = layout.column_flow()
@@ -409,10 +353,10 @@
                flow.itemR(md, "optimal_draw", text="Optimal Display")
                flow.itemR(md, "subsurf_uv")
 
-       def surface(self, layout, ob, md):
+       def SURFACE(self, layout, ob, md):
                layout.itemL(text="See Fields panel.")
        
-       def uvproject(self, layout, ob, md):
+       def UV_PROJECT(self, layout, ob, md):
                if ob.type == 'MESH':

@@ Diff output truncated at 10240 characters. @@

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

Reply via email to