change blender python interface for classes not to ise __idname__ rather bl_idname...
[blender-staging.git] / release / scripts / ui / buttons_data_modifier.py
1
2 import bpy
3
4 class DataButtonsPanel(bpy.types.Panel):
5         bl_space_type = 'PROPERTIES'
6         bl_region_type = 'WINDOW'
7         bl_context = "modifier"
8         
9 class DATA_PT_modifiers(DataButtonsPanel):
10         bl_label = "Modifiers"
11
12         def draw(self, context):
13                 layout = self.layout
14                 
15                 ob = context.object
16
17                 row = layout.row()
18                 row.item_menu_enumO("object.modifier_add", "type")
19                 row.itemL()
20
21                 for md in ob.modifiers:
22                         box = layout.template_modifier(md)
23                         if box:
24                                 # match enum type to our functions, avoids a lookup table.
25                                 getattr(self, md.type)(box, ob, md)
26         
27         # the mt.type enum is (ab)used for a lookup on function names
28         # ...to avoid lengthy if statements
29         # so each type must have a function here.
30
31         def ARMATURE(self, layout, ob, md):
32                 layout.itemR(md, "object")
33                 
34                 split = layout.split(percentage=0.5)
35                 split.itemL(text="Vertex Group:")
36                 sub = split.split(percentage=0.7)
37                 sub.item_pointerR(md, "vertex_group", ob, "vertex_groups", text="")
38                 subsub = sub.row()
39                 subsub.active = md.vertex_group
40                 subsub.itemR(md, "invert")
41                 
42                 layout.itemS()
43                 
44                 split = layout.split()
45
46                 col = split.column()
47                 col.itemL(text="Bind To:")
48                 col.itemR(md, "use_vertex_groups", text="Vertex Groups")
49                 col.itemR(md, "use_bone_envelopes", text="Bone Envelopes")
50                 
51                 col = split.column()
52                 col.itemL(text="Deformation:")
53                 col.itemR(md, "quaternion")
54                 col.itemR(md, "multi_modifier")
55                 
56         def ARRAY(self, layout, ob, md):
57                 layout.itemR(md, "fit_type")
58                 if md.fit_type == 'FIXED_COUNT':
59                         layout.itemR(md, "count")
60                 elif md.fit_type == 'FIT_LENGTH':
61                         layout.itemR(md, "length")
62                 elif md.fit_type == 'FIT_CURVE':
63                         layout.itemR(md, "curve")
64
65                 layout.itemS()
66                 
67                 split = layout.split()
68                 
69                 col = split.column()
70                 col.itemR(md, "constant_offset")
71                 sub = col.column()
72                 sub.active = md.constant_offset
73                 sub.itemR(md, "constant_offset_displacement", text="")
74
75                 col.itemS()
76
77                 col.itemR(md, "merge_adjacent_vertices", text="Merge")
78                 sub = col.column()
79                 sub.active = md.merge_adjacent_vertices
80                 sub.itemR(md, "merge_end_vertices", text="First Last")
81                 sub.itemR(md, "merge_distance", text="Distance")
82                 
83                 col = split.column()
84                 col.itemR(md, "relative_offset")
85                 sub = col.column()
86                 sub.active = md.relative_offset
87                 sub.itemR(md, "relative_offset_displacement", text="")
88
89                 col.itemS()
90
91                 col.itemR(md, "add_offset_object")
92                 sub = col.column()
93                 sub.active = md.add_offset_object
94                 sub.itemR(md, "offset_object", text="")
95
96                 layout.itemS()
97                 
98                 col = layout.column()
99                 col.itemR(md, "start_cap")
100                 col.itemR(md, "end_cap")
101         
102         def BEVEL(self, layout, ob, md):
103                 row = layout.row()
104                 row.itemR(md, "width")
105                 row.itemR(md, "only_vertices")
106                 
107                 layout.itemL(text="Limit Method:")
108                 layout.row().itemR(md, "limit_method", expand=True)
109                 if md.limit_method == 'ANGLE':
110                         layout.itemR(md, "angle")
111                 elif md.limit_method == 'WEIGHT':
112                         layout.row().itemR(md, "edge_weight_method", expand=True)
113                         
114         def BOOLEAN(self, layout, ob, md):
115                 layout.itemR(md, "operation")
116                 layout.itemR(md, "object")
117                 
118         def BUILD(self, layout, ob, md):
119                 split = layout.split()
120                 
121                 col = split.column()
122                 col.itemR(md, "start")
123                 col.itemR(md, "length")
124
125                 col = split.column()
126                 col.itemR(md, "randomize")
127                 sub = col.column()
128                 sub.active = md.randomize
129                 sub.itemR(md, "seed")
130
131         def CAST(self, layout, ob, md):
132                 layout.itemR(md, "cast_type")
133                 layout.itemR(md, "object")
134                 if md.object:
135                         layout.itemR(md, "use_transform")
136                 
137                 flow = layout.column_flow()
138                 flow.itemR(md, "x")
139                 flow.itemR(md, "y")
140                 flow.itemR(md, "z")
141                 flow.itemR(md, "factor")
142                 flow.itemR(md, "radius")
143                 flow.itemR(md, "size")
144
145                 layout.itemR(md, "from_radius")
146                 
147                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
148                 
149         def CLOTH(self, layout, ob, md):
150                 layout.itemL(text="See Cloth panel.")
151                 
152         def COLLISION(self, layout, ob, md):
153                 layout.itemL(text="See Collision panel.")
154                 
155         def CURVE(self, layout, ob, md):
156                 layout.itemR(md, "object")
157                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
158                 layout.itemR(md, "deform_axis")
159                 
160         def DECIMATE(self, layout, ob, md):
161                 layout.itemR(md, "ratio")
162                 layout.itemR(md, "face_count")
163                 
164         def DISPLACE(self, layout, ob, md):
165                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
166                 layout.itemR(md, "texture")
167                 layout.itemR(md, "midlevel")
168                 layout.itemR(md, "strength")
169                 layout.itemR(md, "direction")
170                 layout.itemR(md, "texture_coordinates")
171                 if md.texture_coordinates == 'OBJECT':
172                         layout.itemR(md, "texture_coordinate_object", text="Object")
173                 elif md.texture_coordinates == 'UV' and ob.type == 'MESH':
174                         layout.item_pointerR(md, "uv_layer", ob.data, "uv_textures")
175         
176         def EDGE_SPLIT(self, layout, ob, md):
177                 split = layout.split()
178                 
179                 col = split.column()
180                 col.itemR(md, "use_edge_angle", text="Edge Angle")
181                 sub = col.column()
182                 sub.active = md.use_edge_angle
183                 sub.itemR(md, "split_angle")
184                 
185                 col = split.column()
186                 col.itemR(md, "use_sharp", text="Sharp Edges")
187                 
188         def EXPLODE(self, layout, ob, md):
189                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
190                 layout.itemR(md, "protect")
191
192                 flow = layout.column_flow(2)
193                 flow.itemR(md, "split_edges")
194                 flow.itemR(md, "unborn")
195                 flow.itemR(md, "alive")
196                 flow.itemR(md, "dead")
197
198                 layout.itemO("object.explode_refresh", text="Refresh");
199                 
200         def FLUID_SIMULATION(self, layout, ob, md):
201                 layout.itemL(text="See Fluid panel.")
202                 
203         def HOOK(self, layout, ob, md):
204                 col = layout.column()
205                 col.itemR(md, "object")
206                 if md.object and md.object.type == 'ARMATURE':
207                         layout.item_pointerR(md, "subtarget", md.object.data, "bones", text="Bone")
208                 
209                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
210
211                 split = layout.split()
212                 split.itemR(md, "falloff")
213                 split.itemR(md, "force", slider=True)
214
215                 layout.itemS()
216
217                 row = layout.row()
218                 row.itemO("object.hook_reset", text="Reset")
219                 row.itemO("object.hook_recenter", text="Recenter")
220
221                 if ob.mode == 'EDIT':
222                         row = layout.row()
223                         row.itemO("object.hook_select", text="Select")
224                         row.itemO("object.hook_assign", text="Assign")
225                 
226         def LATTICE(self, layout, ob, md):
227                 layout.itemR(md, "object")
228                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
229                 
230         def MASK(self, layout, ob, md):
231                 layout.itemR(md, "mode")
232                 if md.mode == 'ARMATURE':
233                         layout.itemR(md, "armature")
234                 elif md.mode == 'VERTEX_GROUP':
235                         layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
236                 layout.itemR(md, "inverse")
237                 
238         def MESH_DEFORM(self, layout, ob, md):
239                 layout.itemR(md, "object")
240                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
241                 layout.itemR(md, "invert")
242
243                 layout.itemS()
244                 
245                 if md.is_bound:
246                         layout.itemO("object.meshdeform_bind", text="Unbind")
247                 else:
248                         layout.itemO("object.meshdeform_bind", text="Bind")
249                         row = layout.row()
250                         row.itemR(md, "precision")
251                         row.itemR(md, "dynamic")
252                 
253         def MIRROR(self, layout, ob, md):
254                 layout.itemR(md, "merge_limit")
255                 split = layout.split()
256                 
257                 col = split.column()
258                 col.itemR(md, "x")
259                 col.itemR(md, "y")
260                 col.itemR(md, "z")
261                 
262                 col = split.column()
263                 col.itemL(text="Textures:")
264                 col.itemR(md, "mirror_u")
265                 col.itemR(md, "mirror_v")
266                 
267                 col = split.column()
268                 col.itemR(md, "clip", text="Do Clipping")
269                 col.itemR(md, "mirror_vertex_groups", text="Vertex Group")
270                 
271                 layout.itemR(md, "mirror_object")
272                 
273         def MULTIRES(self, layout, ob, md):
274                 layout.itemR(md, "subdivision_type")
275                 
276                 row = layout.row()
277                 row.itemO("object.multires_subdivide", text="Subdivide")
278                 row.itemO("object.multires_higher_levels_delete", text="Delete Higher")
279
280                 layout.itemR(md, "level")
281         
282         def PARTICLE_INSTANCE(self, layout, ob, md):
283                 layout.itemR(md, "object")
284                 layout.itemR(md, "particle_system_number")
285                 
286                 flow = layout.column_flow()
287                 flow.itemR(md, "normal")
288                 flow.itemR(md, "children")
289                 flow.itemR(md, "size")
290                 flow.itemR(md, "path")
291                 if md.path:
292                         flow.itemR(md, "keep_shape")
293                 flow.itemR(md, "unborn")
294                 flow.itemR(md, "alive")
295                 flow.itemR(md, "dead")
296                 flow.itemL(md, "")
297                 if md.path:
298                         flow.itemR(md, "axis", text="")
299                 
300                 if md.path:
301                         row = layout.row()
302                         row.itemR(md, "position", slider=True)
303                         row.itemR(md, "random_position", text = "Random", slider=True)
304                 
305         def PARTICLE_SYSTEM(self, layout, ob, md):
306                 layout.itemL(text="See Particle panel.")
307                 
308         def SHRINKWRAP(self, layout, ob, md):
309                 layout.itemR(md, "target")
310                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
311                 layout.itemR(md, "offset")
312                 layout.itemR(md, "subsurf_levels")
313                 layout.itemR(md, "mode")
314                 if md.mode == 'PROJECT':
315                         layout.itemR(md, "subsurf_levels")
316                         layout.itemR(md, "auxiliary_target")
317                 
318                         row = layout.row()
319                         row.itemR(md, "x")
320                         row.itemR(md, "y")
321                         row.itemR(md, "z")
322                 
323                         flow = layout.column_flow()
324                         flow.itemR(md, "negative")
325                         flow.itemR(md, "positive")
326                         flow.itemR(md, "cull_front_faces")
327                         flow.itemR(md, "cull_back_faces")
328                 elif md.mode == 'NEAREST_SURFACEPOINT':
329                         layout.itemR(md, "keep_above_surface")
330                 
331         def SIMPLE_DEFORM(self, layout, ob, md):
332                 layout.itemR(md, "mode")
333                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
334                 layout.itemR(md, "origin")
335                 layout.itemR(md, "relative")
336                 layout.itemR(md, "factor")
337                 layout.itemR(md, "limits")
338                 if md.mode in ('TAPER', 'STRETCH'):
339                         layout.itemR(md, "lock_x_axis")
340                         layout.itemR(md, "lock_y_axis")
341                         
342         def SMOKE(self, layout, ob, md):
343                 layout.itemL(text="See Smoke panel.")
344         
345         def SMOOTH(self, layout, ob, md):
346                 split = layout.split()
347                 
348                 col = split.column()
349                 col.itemR(md, "x")
350                 col.itemR(md, "y")
351                 col.itemR(md, "z")
352                 
353                 col = split.column()
354                 col.itemR(md, "factor")
355                 col.itemR(md, "repeat")
356                 
357                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
358                 
359         def SOFT_BODY(self, layout, ob, md):
360                 layout.itemL(text="See Soft Body panel.")
361         
362         def SUBSURF(self, layout, ob, md):
363                 layout.row().itemR(md, "subdivision_type", expand=True)
364                 
365                 flow = layout.column_flow()
366                 flow.itemR(md, "levels", text="Preview")
367                 flow.itemR(md, "render_levels", text="Render")
368                 flow.itemR(md, "optimal_draw", text="Optimal Display")
369                 flow.itemR(md, "subsurf_uv")
370
371         def SURFACE(self, layout, ob, md):
372                 layout.itemL(text="See Fields panel.")
373         
374         def UV_PROJECT(self, layout, ob, md):
375                 if ob.type == 'MESH':
376                         layout.item_pointerR(md, "uv_layer", ob.data, "uv_textures")
377                         layout.itemR(md, "image")
378                         layout.itemR(md, "override_image")
379
380                         split = layout.split()
381
382                         col = split.column()
383                         col.itemL(text="Aspect Ratio:")
384
385                         sub = col.column(align=True)
386                         sub.itemR(md, "horizontal_aspect_ratio", text="Horizontal")
387                         sub.itemR(md, "vertical_aspect_ratio", text="Vertical")
388
389                         col = split.column()
390                         col.itemL(text="Projectors:")
391
392                         sub = col.column(align=True)
393                         sub.itemR(md, "num_projectors", text="Number")
394                         for proj in md.projectors:
395                                 sub.itemR(proj, "object", text="")
396                 
397         def WAVE(self, layout, ob, md):
398                 split = layout.split()
399                 
400                 col = split.column()
401                 col.itemL(text="Motion:")
402                 col.itemR(md, "x")
403                 col.itemR(md, "y")
404                 col.itemR(md, "cyclic")
405                 
406                 col = split.column()
407                 col.itemR(md, "normals")
408                 sub = col.column()
409                 sub.active = md.normals
410                 sub.itemR(md, "x_normal", text="X")
411                 sub.itemR(md, "y_normal", text="Y")
412                 sub.itemR(md, "z_normal", text="Z")
413                 
414                 split = layout.split()
415
416                 col = split.column()
417                 col.itemL(text="Time:")
418                 sub = col.column(align=True)
419                 sub.itemR(md, "time_offset", text="Offset")
420                 sub.itemR(md, "lifetime", text="Life")
421                 col.itemR(md, "damping_time", text="Damping")
422                 
423                 col = split.column()
424                 col.itemL(text="Position:")
425                 sub = col.column(align=True)
426                 sub.itemR(md, "start_position_x", text="X")
427                 sub.itemR(md, "start_position_y", text="Y")
428                 col.itemR(md, "falloff_radius", text="Falloff")
429                 
430                 layout.itemS()
431                 
432                 layout.itemR(md, "start_position_object")
433                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
434                 layout.itemR(md, "texture")
435                 layout.itemR(md, "texture_coordinates")
436                 if md.texture_coordinates == 'MAP_UV' and ob.type == 'MESH':
437                         layout.item_pointerR(md, "uv_layer", ob.data, "uv_textures")
438                 elif md.texture_coordinates == 'OBJECT':
439                         layout.itemR(md, "texture_coordinates_object")
440                 
441                 layout.itemS()
442                 
443                 flow = layout.column_flow()
444                 flow.itemR(md, "speed", slider=True)
445                 flow.itemR(md, "height", slider=True)
446                 flow.itemR(md, "width", slider=True)
447                 flow.itemR(md, "narrowness", slider=True)
448
449 bpy.types.register(DATA_PT_modifiers)