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