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