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