Undo revision 23130 which was a merge with 2.5, a messy one because I did something...
[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_layers")
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                 layout.itemR(md, "split_edges")
191                 layout.itemR(md, "unborn")
192                 layout.itemR(md, "alive")
193                 layout.itemR(md, "dead")
194                 # Missing: "Refresh" and "Clear Vertex Group" Operator
195                 
196         def FLUID_SIMULATION(self, layout, ob, md):
197                 layout.itemL(text="See Fluid panel.")
198                 
199         def HOOK(self, layout, ob, md):
200                 layout.itemR(md, "falloff")
201                 layout.itemR(md, "force", slider=True)
202                 layout.itemR(md, "object")
203                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
204                 # Missing: "Reset" and "Recenter" Operator
205                 
206         def LATTICE(self, layout, ob, md):
207                 layout.itemR(md, "object")
208                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
209                 
210         def MASK(self, layout, ob, md):
211                 layout.itemR(md, "mode")
212                 if md.mode == 'ARMATURE':
213                         layout.itemR(md, "armature")
214                 elif md.mode == 'VERTEX_GROUP':
215                         layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
216                 layout.itemR(md, "inverse")
217                 
218         def MESH_DEFORM(self, layout, ob, md):
219                 layout.itemR(md, "object")
220                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
221                 layout.itemR(md, "invert")
222
223                 layout.itemS()
224                 
225                 layout.itemO("object.modifier_mdef_bind", text="Bind")
226                 row = layout.row()
227                 row.itemR(md, "precision")
228                 row.itemR(md, "dynamic")
229                 
230         def MIRROR(self, layout, ob, md):
231                 layout.itemR(md, "merge_limit")
232                 split = layout.split()
233                 
234                 col = split.column()
235                 col.itemR(md, "x")
236                 col.itemR(md, "y")
237                 col.itemR(md, "z")
238                 
239                 col = split.column()
240                 col.itemL(text="Textures:")
241                 col.itemR(md, "mirror_u")
242                 col.itemR(md, "mirror_v")
243                 
244                 col = split.column()
245                 col.itemR(md, "clip", text="Do Clipping")
246                 col.itemR(md, "mirror_vertex_groups", text="Vertex Group")
247                 
248                 layout.itemR(md, "mirror_object")
249                 
250         def MULTIRES(self, layout, ob, md):
251                 layout.itemR(md, "subdivision_type")
252                 layout.itemO("object.multires_subdivide", text="Subdivide")
253                 layout.itemR(md, "level")
254         
255         def PARTICLE_INSTANCE(self, layout, ob, md):
256                 layout.itemR(md, "object")
257                 layout.itemR(md, "particle_system_number")
258                 
259                 flow = layout.column_flow()
260                 flow.itemR(md, "normal")
261                 flow.itemR(md, "children")
262                 flow.itemR(md, "size")
263                 flow.itemR(md, "path")
264                 if md.path:
265                         flow.itemR(md, "keep_shape")
266                 flow.itemR(md, "unborn")
267                 flow.itemR(md, "alive")
268                 flow.itemR(md, "dead")
269                 flow.itemL(md, "")
270                 if md.path:
271                         flow.itemR(md, "axis", text="")
272                 
273                 if md.path:
274                         row = layout.row()
275                         row.itemR(md, "position", slider=True)
276                         row.itemR(md, "random_position", text = "Random", slider=True)
277                 
278         def PARTICLE_SYSTEM(self, layout, ob, md):
279                 layout.itemL(text="See Particle panel.")
280                 
281         def SHRINKWRAP(self, layout, ob, md):
282                 layout.itemR(md, "target")
283                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
284                 layout.itemR(md, "offset")
285                 layout.itemR(md, "subsurf_levels")
286                 layout.itemR(md, "mode")
287                 if md.mode == 'PROJECT':
288                         layout.itemR(md, "subsurf_levels")
289                         layout.itemR(md, "auxiliary_target")
290                 
291                         row = layout.row()
292                         row.itemR(md, "x")
293                         row.itemR(md, "y")
294                         row.itemR(md, "z")
295                 
296                         flow = layout.column_flow()
297                         flow.itemR(md, "negative")
298                         flow.itemR(md, "positive")
299                         flow.itemR(md, "cull_front_faces")
300                         flow.itemR(md, "cull_back_faces")
301                 elif md.mode == 'NEAREST_SURFACEPOINT':
302                         layout.itemR(md, "keep_above_surface")
303                 
304         def SIMPLE_DEFORM(self, layout, ob, md):
305                 layout.itemR(md, "mode")
306                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
307                 layout.itemR(md, "origin")
308                 layout.itemR(md, "relative")
309                 layout.itemR(md, "factor")
310                 layout.itemR(md, "limits")
311                 if md.mode in ('TAPER', 'STRETCH'):
312                         layout.itemR(md, "lock_x_axis")
313                         layout.itemR(md, "lock_y_axis")
314                         
315         def SMOKE(self, layout, ob, md):
316                 layout.itemL(text="See Smoke panel.")
317         
318         def SMOOTH(self, layout, ob, md):
319                 split = layout.split()
320                 
321                 col = split.column()
322                 col.itemR(md, "x")
323                 col.itemR(md, "y")
324                 col.itemR(md, "z")
325                 
326                 col = split.column()
327                 col.itemR(md, "factor")
328                 col.itemR(md, "repeat")
329                 
330                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
331                 
332         def SOFT_BODY(self, layout, ob, md):
333                 layout.itemL(text="See Soft Body panel.")
334         
335         def SUBSURF(self, layout, ob, md):
336                 layout.row().itemR(md, "subdivision_type", expand=True)
337                 
338                 flow = layout.column_flow()
339                 flow.itemR(md, "levels", text="Preview")
340                 flow.itemR(md, "render_levels", text="Render")
341                 flow.itemR(md, "optimal_draw", text="Optimal Display")
342                 flow.itemR(md, "subsurf_uv")
343
344         def SURFACE(self, layout, ob, md):
345                 layout.itemL(text="See Fields panel.")
346         
347         def UV_PROJECT(self, layout, ob, md):
348                 if ob.type == 'MESH':
349                         layout.item_pointerR(md, "uv_layer", ob.data, "uv_layers")
350                         #layout.itemR(md, "projectors")
351                         layout.itemR(md, "image")
352                         layout.itemR(md, "override_image")
353                         layout.itemL(text="Aspect Ratio:")
354                         col = layout.column(align=True)
355                         col.itemR(md, "horizontal_aspect_ratio", text="Horizontal")
356                         col.itemR(md, "vertical_aspect_ratio", text="Vertical")
357                         
358                         #"Projectors" don't work.
359                 
360         def WAVE(self, layout, ob, md):
361                 split = layout.split()
362                 
363                 col = split.column()
364                 col.itemL(text="Motion:")
365                 col.itemR(md, "x")
366                 col.itemR(md, "y")
367                 col.itemR(md, "cyclic")
368                 
369                 col = split.column()
370                 col.itemR(md, "normals")
371                 sub = col.row(align=True)
372                 sub.active = md.normals
373                 sub.itemR(md, "x_normal", text="X", toggle=True)
374                 sub.itemR(md, "y_normal", text="Y", toggle=True)
375                 sub.itemR(md, "z_normal", text="Z", toggle=True)
376                 
377                 flow = layout.column_flow()
378                 flow.itemR(md, "time_offset")
379                 flow.itemR(md, "lifetime")
380                 flow.itemR(md, "damping_time")
381                 flow.itemR(md, "falloff_radius")
382                 flow.itemR(md, "start_position_x")
383                 flow.itemR(md, "start_position_y")
384                 
385                 layout.itemR(md, "start_position_object")
386                 layout.item_pointerR(md, "vertex_group", ob, "vertex_groups")
387                 layout.itemR(md, "texture")
388                 layout.itemR(md, "texture_coordinates")
389                 if md.texture_coordinates == 'MAP_UV' and ob.type == 'MESH':
390                         layout.item_pointerR(md, "uv_layer", ob.data, "uv_layers")
391                 elif md.texture_coordinates == 'OBJECT':
392                         layout.itemR(md, "texture_coordinates_object")
393                 
394                 flow = layout.column_flow()
395                 flow.itemR(md, "speed", slider=True)
396                 flow.itemR(md, "height", slider=True)
397                 flow.itemR(md, "width", slider=True)
398                 flow.itemR(md, "narrowness", slider=True)
399
400 bpy.types.register(DATA_PT_modifiers)