9d24cd2d5346a80b09e17575981f934e77505fd5
[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         __idname__ = "DATA_PT_modifiers"
11         __label__ = "Modifiers"
12
13         def draw(self, context):
14                 ob = context.object
15                 layout = self.layout
16
17                 row = layout.row()
18                 row.item_menu_enumO("OBJECT_OT_modifier_add", "type")
19                 row.itemL();
20
21                 for md in ob.modifiers:
22                         box = layout.template_modifier(context, md)
23
24                         if md.expanded:
25                                 if md.type == 'ARMATURE':
26                                         self.armature(box, ob, md)
27                                 if md.type == 'ARRAY':
28                                         self.array(box, ob, md)
29                                 if md.type == 'BEVEL':
30                                         self.bevel(box, ob, md)
31                                 if md.type == 'BOOLEAN':
32                                         self.boolean(box, ob, md)
33                                 if md.type == 'BUILD':
34                                         self.build(box, ob, md)
35                                 if md.type == 'CAST':
36                                         self.cast(box, ob, md)
37                                 if md.type == 'CLOTH':
38                                         self.cloth(box, ob, md)
39                                 if md.type == 'COLLISION':
40                                         self.collision(box, ob, md)
41                                 if md.type == 'CURVE':
42                                         self.curve(box, ob, md)
43                                 if md.type == 'DECIMATE':
44                                         self.decimate(box, ob, md)
45                                 if md.type == 'DISPLACE':
46                                         self.displace(box, ob, md)
47                                 if md.type == 'EDGE_SPLIT':
48                                         self.edgesplit(box, ob, md)
49                                 if md.type == 'EXPLODE':
50                                         self.explode(box, ob, md)
51                                 if md.type == 'FLUID_SIMULATION':
52                                         self.fluid(box, ob, md)
53                                 if md.type == 'HOOK':
54                                         self.hook(box, ob, md)
55                                 if md.type == 'LATTICE':
56                                         self.lattice(box, ob, md)
57                                 if md.type == 'MASK':
58                                         self.mask(box, ob, md)
59                                 if md.type == 'MESH_DEFORM':
60                                         self.mesh_deform(box, ob, md)
61                                 if md.type == 'MIRROR':
62                                         self.mirror(box, ob, md)
63                                 if md.type == 'MULTIRES':
64                                         self.multires(box, ob, md)
65                                 if md.type == 'PARTICLE_INSTANCE':
66                                         self.particleinstance(box, ob, md)
67                                 if md.type == 'PARTICLE_SYSTEM':
68                                         self.particlesystem(box, ob, md)
69                                 if md.type == 'SHRINKWRAP':
70                                         self.shrinkwrap(box, ob, md)
71                                 if md.type == 'SIMPLE_DEFORM':
72                                         self.simpledeform(box, ob, md)
73                                 if md.type == 'SMOOTH':
74                                         self.smooth(box, ob, md)
75                                 if md.type == 'SOFTBODY':
76                                         self.softbody(box, ob, md)
77                                 if md.type == 'SUBSURF':
78                                         self.subsurf(box, ob, md)
79                                 if md.type == 'UV_PROJECT':
80                                         self.uvproject(box, ob, md)
81                                 if md.type == 'WAVE':
82                                         self.wave(box, ob, md)
83                                                         
84         def armature(self, layout, ob, md):
85                 layout.itemR(md, "object")
86                 row = layout.row()
87                 row.item_pointerR(md, "vertex_group", ob, "vertex_groups")
88                 row.itemR(md, "invert")
89                 flow = layout.column_flow()
90                 flow.itemR(md, "use_vertex_groups", text="Vertex Groups")
91                 flow.itemR(md, "use_bone_envelopes", text="Bone Envelopes")
92                 flow.itemR(md, "quaternion")
93                 flow.itemR(md, "multi_modifier")
94                 
95         def array(self, layout, ob, md):
96                 layout.itemR(md, "fit_type")
97                 if md.fit_type == 'FIXED_COUNT':
98                         layout.itemR(md, "count")
99                 if md.fit_type == 'FIT_LENGTH':
100                         layout.itemR(md, "length")
101                 if md.fit_type == 'FIT_CURVE':
102                                 layout.itemR(md, "curve")
103
104                 layout.itemS()
105                 
106                 split = layout.split()
107                 
108                 col = split.column()
109                 col = col.column()
110                 col.itemR(md, "constant_offset")
111                 colsub = col.column()
112                 colsub.active = md.constant_offset
113                 colsub.itemR(md, "constant_offset_displacement", text="")
114
115                 col.itemS()
116
117                 sub = col.row().itemR(md, "merge_adjacent_vertices", text="Merge")
118                 colsub = col.column()
119                 colsub.active = md.merge_adjacent_vertices
120                 colsub.itemR(md, "merge_end_vertices", text="First Last")
121                 colsub.itemR(md, "merge_distance", text="Distance")
122                 
123                 col = split.column()
124                 col = col.column()
125                 col.itemR(md, "relative_offset")
126                 colsub = col.column()
127                 colsub.active = md.relative_offset
128                 colsub.itemR(md, "relative_offset_displacement", text="")
129
130                 col.itemS()
131
132                 col = col.column()
133                 col.itemR(md, "add_offset_object")
134                 colsub = col.column()
135                 colsub.active = md.add_offset_object
136                 colsub.itemR(md, "offset_object", text="")
137
138                 layout.itemS()
139                 
140                 col = layout.column()
141                 col.itemR(md, "start_cap")
142                 col.itemR(md, "end_cap")
143         
144         def bevel(self, layout, ob, md):
145                 row = layout.row()
146                 row.itemR(md, "width")
147                 row.itemR(md, "only_vertices")
148                 
149                 layout.itemL(text="Limit Method:")
150                 row = layout.row()
151                 row.itemR(md, "limit_method", expand=True)
152                 if md.limit_method == 'ANGLE':
153                         row = layout.row()
154                         row.itemR(md, "angle")
155                 if md.limit_method == 'WEIGHT':
156                         row = layout.row()
157                         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                 colsub = col.column()
173                 colsub.active = md.randomize
174                 colsub.itemR(md, "seed")
175                         
176                 
177                         
178         def cast(self, layout, ob, md):
179                 layout.itemR(md, "cast_type")
180                 col = layout.column_flow()
181                 col.itemR(md, "x")
182                 col.itemR(md, "y")
183                 col.itemR(md, "z")
184                 col.itemR(md, "factor")
185                 col.itemR(md, "radius")
186                 col.itemR(md, "size")
187                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
188                 #Missing: "OB" and "From Radius"
189                 
190         def cloth(self, layout, ob, md):
191                 layout.itemL(text="See Cloth panel.")
192                 
193         def collision(self, layout, ob, md):
194                 layout.itemL(text="See Collision panel.")
195                 
196         def curve(self, layout, ob, md):
197                 layout.itemR(md, "curve")
198                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
199                 layout.itemR(md, "deform_axis")
200                 
201         def decimate(self, layout, ob, md):
202                 layout.itemR(md, "ratio")
203                 layout.itemR(md, "face_count")
204                 
205         def displace(self, layout, ob, md):
206                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
207                 layout.itemR(md, "texture")
208                 layout.itemR(md, "midlevel")
209                 layout.itemR(md, "strength")
210                 layout.itemR(md, "direction")
211                 layout.itemR(md, "texture_coordinates")
212                 if md.texture_coordinates == 'OBJECT':
213                         layout.itemR(md, "texture_coordinate_object", text="Object")
214                 if md.texture_coordinates == 'UV' and ob.type == 'MESH':
215                         layout.item_pointerR(md, "uv_layer", ob.data, "uv_layers")
216         
217         def edgesplit(self, layout, ob, md):
218                 split = layout.split()
219                 
220                 col = split.column()
221                 col.itemR(md, "use_edge_angle", text="Edge Angle")
222                 colsub = col.column()
223                 colsub.active = md.use_edge_angle
224                 colsub.itemR(md, "split_angle")
225                 col = split.column()
226                 col.itemR(md, "use_sharp", text="Sharp Edges")
227                 
228         def explode(self, layout, ob, md):
229                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
230                 layout.itemR(md, "protect")
231                 layout.itemR(md, "split_edges")
232                 layout.itemR(md, "unborn")
233                 layout.itemR(md, "alive")
234                 layout.itemR(md, "dead")
235                 # Missing: "Refresh" and "Clear Vertex Group" ?
236                 
237         def fluid(self, layout, ob, md):
238                 layout.itemL(text="See Fluidsim panel.")
239                 
240         def hook(self, layout, ob, md):
241                 layout.itemR(md, "falloff")
242                 layout.itemR(md, "force", slider=True)
243                 layout.itemR(md, "object")
244                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
245                 # Missing: "Reset" and "Recenter"
246                 
247         def lattice(self, layout, ob, md):
248                 layout.itemR(md, "lattice")
249                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
250                 
251         def mask(self, layout, ob, md):
252                 layout.itemR(md, "mode")
253                 if md.mode == 'ARMATURE':
254                         layout.itemR(md, "armature")
255                 if md.mode == 'VERTEX_GROUP':
256                         layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
257                 layout.itemR(md, "inverse")
258                 
259         def mesh_deform(self, layout, ob, md):
260                 layout.itemR(md, "mesh")
261                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
262                 layout.itemR(md, "invert")
263
264                 layout.itemS()
265                 layout.itemO("OBJECT_OT_modifier_mdef_bind", text="Bind")
266                 row = layout.row()
267                 row.itemR(md, "precision")
268                 row.itemR(md, "dynamic")
269                 
270         def mirror(self, layout, ob, md):
271                 layout.itemR(md, "merge_limit")
272                 split = layout.split()
273                 
274                 sub = split.column()
275                 sub.itemR(md, "x")
276                 sub.itemR(md, "y")
277                 sub.itemR(md, "z")
278                 sub = split.column()
279                 sub.itemL(text="Textures:")
280                 sub.itemR(md, "mirror_u")
281                 sub.itemR(md, "mirror_v")
282                 sub = split.column()
283                 sub.itemR(md, "clip", text="Do Clipping")
284                 sub.itemR(md, "mirror_vertex_groups", text="Vertex Group")
285                 
286                 layout.itemR(md, "mirror_object")
287                 
288         def multires(self, layout, ob, md):
289                 layout.itemR(md, "subdivision_type")
290                 layout.itemO("OBJECT_OT_multires_subdivide", text="Subdivide")
291                 layout.itemR(md, "level")
292         
293         def particleinstance(self, layout, ob, md):
294                 layout.itemR(md, "object")
295                 layout.itemR(md, "particle_system_number")
296                 
297                 col = layout.column_flow()
298                 col.itemR(md, "normal")
299                 col.itemR(md, "children")
300                 col.itemR(md, "path")
301                 col.itemR(md, "unborn")
302                 col.itemR(md, "alive")
303                 col.itemR(md, "dead")
304                 
305         def particlesystem(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                         col = layout.column_flow()
324                         col.itemR(md, "negative")
325                         col.itemR(md, "positive")
326                         col.itemR(md, "cull_front_faces")
327                         col.itemR(md, "cull_back_faces")
328                 if md.mode == 'NEAREST_SURFACEPOINT':
329                         layout.itemR(md, "keep_above_surface")
330                 # To-Do: Validate if structs
331                 
332         def simpledeform(self, layout, ob, md):
333                 layout.itemR(md, "mode")
334                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
335                 layout.itemR(md, "origin")
336                 layout.itemR(md, "relative")
337                 layout.itemR(md, "factor")
338                 layout.itemR(md, "limits")
339                 if md.mode in ('TAPER', 'STRETCH'):
340                         layout.itemR(md, "lock_x_axis")
341                         layout.itemR(md, "lock_y_axis")
342         
343         def smooth(self, layout, ob, md):
344                 split = layout.split()
345                 sub = split.column()
346                 sub.itemR(md, "x")
347                 sub.itemR(md, "y")
348                 sub.itemR(md, "z")
349                 sub = split.column()
350                 sub.itemR(md, "factor")
351                 sub.itemR(md, "repeat")
352                 
353                 layout.template_pointer(md, "vertex_group", ob, "vertex_groups")
354                 
355         def softbody(self, layout, ob, md):
356                 layout.itemL(text="See Softbody panel.")
357         
358         def subsurf(self, layout, ob, md):
359                 layout.itemR(md, "subdivision_type")
360                 col = layout.column_flow()
361                 col.itemR(md, "levels", text="Preview")
362                 col.itemR(md, "render_levels", text="Render")
363                 col.itemR(md, "optimal_draw", text="Optimal Display")
364                 col.itemR(md, "subsurf_uv")
365         
366         def uvproject(self, layout, ob, md):
367                 if ob.type == 'MESH':
368                         layout.item_pointerR(md, "uv_layer", ob.data, "uv_layers")
369                         layout.itemR(md, "projectors")
370                         layout.itemR(md, "image")
371                         layout.itemR(md, "horizontal_aspect_ratio")
372                         layout.itemR(md, "vertical_aspect_ratio")
373                         layout.itemR(md, "override_image")
374                         #"Projectors" don't work.
375                 
376         def wave(self, layout, ob, md):
377                 split = layout.split()
378                 
379                 sub = split.column()
380                 sub.itemL(text="Motion:")
381                 sub.itemR(md, "x")
382                 sub.itemR(md, "y")
383                 sub.itemR(md, "cyclic")
384                 
385                 sub = split.column()
386                 sub.itemR(md, "normals")
387                 row = sub.row(align=True)
388                 row.active = md.normals
389                 row.itemR(md, "x_normal", text="X", toggle=True)
390                 row.itemR(md, "y_normal", text="Y", toggle=True)
391                 row.itemR(md, "z_normal", text="Z", toggle=True)
392                 
393                 col = layout.column_flow()
394                 col.itemR(md, "time_offset")
395                 col.itemR(md, "lifetime")
396                 col.itemR(md, "damping_time")
397                 col.itemR(md, "falloff_radius")
398                 col.itemR(md, "start_position_x")
399                 col.itemR(md, "start_position_y")
400                 
401                 layout.itemR(md, "start_position_object")
402                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
403                 layout.itemR(md, "texture")
404                 layout.itemR(md, "texture_coordinates")
405                 if md.texture_coordinates == 'MAP_UV' and ob.type == 'MESH':
406                         layout.item_pointerR(md, "uv_layer", ob.data, "uv_layers")
407                 if md.texture_coordinates == 'OBJECT':
408                         layout.itemR(md, "texture_coordinates_object")
409                 
410                 col = layout.column_flow()
411                 col.itemR(md, "speed", slider=True)
412                 col.itemR(md, "height", slider=True)
413                 col.itemR(md, "width", slider=True)
414                 col.itemR(md, "narrowness", slider=True)
415
416 bpy.types.register(DATA_PT_modifiers)