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