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