Merge with -r 22620:23107.
[blender.git] / release / ui / buttons_data_modifier.py
1
2 import bpy
3
4 class DataButtonsPanel(bpy.types.Panel):
5         __space_type__ = 'PROPERTIES'
6         __region_type__ = 'WINDOW'
7         __context__ = "modifier"
8         
9 class DATA_PT_modifiers(DataButtonsPanel):
10         __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                 layout.itemO("object.meshdeform_bind", text="Bind")
246                 row = layout.row()
247                 row.itemR(md, "precision")
248                 row.itemR(md, "dynamic")
249                 
250         def MIRROR(self, layout, ob, md):
251                 layout.itemR(md, "merge_limit")
252                 split = layout.split()
253                 
254                 col = split.column()
255                 col.itemR(md, "x")
256                 col.itemR(md, "y")
257                 col.itemR(md, "z")
258                 
259                 col = split.column()
260                 col.itemL(text="Textures:")
261                 col.itemR(md, "mirror_u")
262                 col.itemR(md, "mirror_v")
263                 
264                 col = split.column()
265                 col.itemR(md, "clip", text="Do Clipping")
266                 col.itemR(md, "mirror_vertex_groups", text="Vertex Group")
267                 
268                 layout.itemR(md, "mirror_object")
269                 
270         def MULTIRES(self, layout, ob, md):
271                 layout.itemR(md, "subdivision_type")
272                 
273                 row = layout.row()
274                 row.itemO("object.multires_subdivide", text="Subdivide")
275                 row.itemO("object.multires_higher_levels_delete", text="Delete Higher")
276
277                 layout.itemR(md, "level")
278         
279         def PARTICLE_INSTANCE(self, layout, ob, md):
280                 layout.itemR(md, "object")
281                 layout.itemR(md, "particle_system_number")
282                 
283                 flow = layout.column_flow()
284                 flow.itemR(md, "normal")
285                 flow.itemR(md, "children")
286                 flow.itemR(md, "size")
287                 flow.itemR(md, "path")
288                 if md.path:
289                         flow.itemR(md, "keep_shape")
290                 flow.itemR(md, "unborn")
291                 flow.itemR(md, "alive")
292                 flow.itemR(md, "dead")
293                 flow.itemL(md, "")
294                 if md.path:
295                         flow.itemR(md, "axis", text="")
296                 
297                 if md.path:
298                         row = layout.row()
299                         row.itemR(md, "position", slider=True)
300                         row.itemR(md, "random_position", text = "Random", slider=True)
301                 
302         def PARTICLE_SYSTEM(self, layout, ob, md):
303                 layout.itemL(text="See Particle panel.")
304                 
305         def SHRINKWRAP(self, layout, ob, md):
306                 layout.itemR(md, "target")
307                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
308                 layout.itemR(md, "offset")
309                 layout.itemR(md, "subsurf_levels")
310                 layout.itemR(md, "mode")
311                 if md.mode == 'PROJECT':
312                         layout.itemR(md, "subsurf_levels")
313                         layout.itemR(md, "auxiliary_target")
314                 
315                         row = layout.row()
316                         row.itemR(md, "x")
317                         row.itemR(md, "y")
318                         row.itemR(md, "z")
319                 
320                         flow = layout.column_flow()
321                         flow.itemR(md, "negative")
322                         flow.itemR(md, "positive")
323                         flow.itemR(md, "cull_front_faces")
324                         flow.itemR(md, "cull_back_faces")
325                 elif md.mode == 'NEAREST_SURFACEPOINT':
326                         layout.itemR(md, "keep_above_surface")
327                 
328         def SIMPLE_DEFORM(self, layout, ob, md):
329                 layout.itemR(md, "mode")
330                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
331                 layout.itemR(md, "origin")
332                 layout.itemR(md, "relative")
333                 layout.itemR(md, "factor")
334                 layout.itemR(md, "limits")
335                 if md.mode in ('TAPER', 'STRETCH'):
336                         layout.itemR(md, "lock_x_axis")
337                         layout.itemR(md, "lock_y_axis")
338                         
339         def SMOKE(self, layout, ob, md):
340                 layout.itemL(text="See Smoke panel.")
341         
342         def SMOOTH(self, layout, ob, md):
343                 split = layout.split()
344                 
345                 col = split.column()
346                 col.itemR(md, "x")
347                 col.itemR(md, "y")
348                 col.itemR(md, "z")
349                 
350                 col = split.column()
351                 col.itemR(md, "factor")
352                 col.itemR(md, "repeat")
353                 
354                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
355                 
356         def SOFT_BODY(self, layout, ob, md):
357                 layout.itemL(text="See Soft Body panel.")
358         
359         def SUBSURF(self, layout, ob, md):
360                 layout.row().itemR(md, "subdivision_type", expand=True)
361                 
362                 flow = layout.column_flow()
363                 flow.itemR(md, "levels", text="Preview")
364                 flow.itemR(md, "render_levels", text="Render")
365                 flow.itemR(md, "optimal_draw", text="Optimal Display")
366                 flow.itemR(md, "subsurf_uv")
367
368         def SURFACE(self, layout, ob, md):
369                 layout.itemL(text="See Fields panel.")
370         
371         def UV_PROJECT(self, layout, ob, md):
372                 if ob.type == 'MESH':
373                         layout.item_pointerR(md, "uv_layer", ob.data, "uv_textures")
374                         layout.itemR(md, "image")
375                         layout.itemR(md, "override_image")
376
377                         split = layout.split()
378
379                         col = split.column()
380                         col.itemL(text="Aspect Ratio:")
381
382                         sub = col.column(align=True)
383                         sub.itemR(md, "horizontal_aspect_ratio", text="Horizontal")
384                         sub.itemR(md, "vertical_aspect_ratio", text="Vertical")
385
386                         col = split.column()
387                         col.itemL(text="Projectors:")
388
389                         sub = col.column(align=True)
390                         sub.itemR(md, "num_projectors", text="Number")
391                         for proj in md.projectors:
392                                 sub.itemR(proj, "object", text="")
393                 
394         def WAVE(self, layout, ob, md):
395                 split = layout.split()
396                 
397                 col = split.column()
398                 col.itemL(text="Motion:")
399                 col.itemR(md, "x")
400                 col.itemR(md, "y")
401                 col.itemR(md, "cyclic")
402                 
403                 col = split.column()
404                 col.itemR(md, "normals")
405                 sub = col.column()
406                 sub.active = md.normals
407                 sub.itemR(md, "x_normal", text="X")
408                 sub.itemR(md, "y_normal", text="Y")
409                 sub.itemR(md, "z_normal", text="Z")
410                 
411                 split = layout.split()
412
413                 col = split.column()
414                 col.itemL(text="Time:")
415                 sub = col.column(align=True)
416                 sub.itemR(md, "time_offset", text="Offset")
417                 sub.itemR(md, "lifetime", text="Life")
418                 col.itemR(md, "damping_time", text="Damping")
419                 
420                 col = split.column()
421                 col.itemL(text="Position:")
422                 sub = col.column(align=True)
423                 sub.itemR(md, "start_position_x", text="X")
424                 sub.itemR(md, "start_position_y", text="Y")
425                 col.itemR(md, "falloff_radius", text="Falloff")
426                 
427                 layout.itemS()
428                 
429                 layout.itemR(md, "start_position_object")
430                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
431                 layout.itemR(md, "texture")
432                 layout.itemR(md, "texture_coordinates")
433                 if md.texture_coordinates == 'MAP_UV' and ob.type == 'MESH':
434                         layout.item_pointerR(md, "uv_layer", ob.data, "uv_textures")
435                 elif md.texture_coordinates == 'OBJECT':
436                         layout.itemR(md, "texture_coordinates_object")
437                 
438                 layout.itemS()
439                 
440                 flow = layout.column_flow()
441                 flow.itemR(md, "speed", slider=True)
442                 flow.itemR(md, "height", slider=True)
443                 flow.itemR(md, "width", slider=True)
444                 flow.itemR(md, "narrowness", slider=True)
445
446 bpy.types.register(DATA_PT_modifiers)