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