poll() as a python '@staticmethod' was too limiting and didnt allow useful base class...
[blender.git] / release / scripts / ui / properties_physics_smoke.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21
22
23 from properties_physics_common import point_cache_ui
24 from properties_physics_common import effector_weights_ui
25
26
27 class PhysicButtonsPanel():
28     bl_space_type = 'PROPERTIES'
29     bl_region_type = 'WINDOW'
30     bl_context = "physics"
31
32     @classmethod
33     def poll(cls, context):
34         ob = context.object
35         rd = context.scene.render
36         return (ob and ob.type == 'MESH') and (not rd.use_game_engine)
37
38
39 class PHYSICS_PT_smoke(PhysicButtonsPanel, bpy.types.Panel):
40     bl_label = "Smoke"
41
42     def draw(self, context):
43         layout = self.layout
44
45         md = context.smoke
46         ob = context.object
47
48         split = layout.split()
49
50         if md:
51             # remove modifier + settings
52             split.set_context_pointer("modifier", md)
53             split.operator("object.modifier_remove", text="Remove")
54
55             row = split.row(align=True)
56             row.prop(md, "render", text="")
57             row.prop(md, "realtime", text="")
58
59         else:
60             # add modifier
61             split.operator("object.modifier_add", text="Add").type = 'SMOKE'
62             split.label()
63
64         if md:
65             layout.prop(md, "smoke_type", expand=True)
66
67             if md.smoke_type == 'DOMAIN':
68                 domain = md.domain_settings
69
70                 split = layout.split()
71
72                 col = split.column()
73                 col.label(text="Resolution:")
74                 col.prop(domain, "maxres", text="Divisions")
75                 col.label(text="Time:")
76                 col.prop(domain, "time_scale", text="Scale")
77                 col.label(text="Border Collisions:")
78                 col.prop(domain, "smoke_domain_colli", text="")
79
80                 col = split.column()
81                 col.label(text="Behavior:")
82                 col.prop(domain, "alpha")
83                 col.prop(domain, "beta")
84                 col.prop(domain, "vorticity")
85                 col.prop(domain, "dissolve_smoke", text="Dissolve")
86                 sub = col.column()
87                 sub.active = domain.dissolve_smoke
88                 sub.prop(domain, "dissolve_speed", text="Time")
89                 sub.prop(domain, "dissolve_smoke_log", text="Slow")
90
91             elif md.smoke_type == 'FLOW':
92     
93                 flow = md.flow_settings
94
95                 split = layout.split()
96
97                 col = split.column()
98                 col.prop(flow, "outflow")
99                 col.label(text="Particle System:")
100                 col.prop_object(flow, "psys", ob, "particle_systems", text="")
101
102                 sub = col.column()
103                 sub.active = not md.flow_settings.outflow
104
105                 sub.prop(flow, "initial_velocity", text="Initial Velocity")
106                 sub = sub.column()
107                 sub.active = flow.initial_velocity
108                 sub.prop(flow, "velocity_multiplier", text="Multiplier")
109
110
111                 sub = split.column()
112                 sub.active = not md.flow_settings.outflow
113                 sub.label(text="Behavior:")
114                 sub.prop(flow, "temperature")
115                 sub.prop(flow, "density")
116                 sub.prop(flow, "absolute")
117
118             #elif md.smoke_type == 'COLLISION':
119             #   layout.separator()
120
121
122 class PHYSICS_PT_smoke_groups(PhysicButtonsPanel, bpy.types.Panel):
123     bl_label = "Smoke Groups"
124     bl_default_closed = True
125
126     @classmethod
127     def poll(cls, context):
128         md = context.smoke
129         return md and (md.smoke_type == 'DOMAIN')
130
131     def draw(self, context):
132         layout = self.layout
133
134         group = context.smoke.domain_settings
135
136         split = layout.split()
137
138         col = split.column()
139         col.label(text="Flow Group:")
140         col.prop(group, "fluid_group", text="")
141
142         #col.label(text="Effector Group:")
143         #col.prop(group, "eff_group", text="")
144
145         col = split.column()
146         col.label(text="Collision Group:")
147         col.prop(group, "coll_group", text="")
148
149
150 class PHYSICS_PT_smoke_cache(PhysicButtonsPanel, bpy.types.Panel):
151     bl_label = "Smoke Cache"
152     bl_default_closed = True
153
154     @classmethod
155     def poll(cls, context):
156         md = context.smoke
157         return md and (md.smoke_type == 'DOMAIN')
158
159     def draw(self, context):
160         layout = self.layout
161
162         md = context.smoke.domain_settings
163         cache = md.point_cache_low
164
165         layout.label(text="Compression:")
166         layout.prop(md, "smoke_cache_comp", expand=True)
167
168         point_cache_ui(self, context, cache, (cache.baked is False), 'SMOKE')
169
170
171 class PHYSICS_PT_smoke_highres(PhysicButtonsPanel, bpy.types.Panel):
172     bl_label = "Smoke High Resolution"
173     bl_default_closed = True
174
175     @classmethod
176     def poll(cls, context):
177         md = context.smoke
178         return md and (md.smoke_type == 'DOMAIN')
179
180     def draw_header(self, context):
181         md = context.smoke.domain_settings
182
183         self.layout.prop(md, "highres", text="")
184
185     def draw(self, context):
186         layout = self.layout
187
188         md = context.smoke.domain_settings
189
190         layout.active = md.highres
191
192         split = layout.split()
193
194         col = split.column()
195         col.label(text="Resolution:")
196         col.prop(md, "amplify", text="Divisions")
197         col.prop(md, "smoothemitter")
198         col.prop(md, "viewhighres")
199
200         col = split.column()
201         col.label(text="Noise Method:")
202         col.row().prop(md, "noise_type", text="")
203         col.prop(md, "strength")
204
205
206 class PHYSICS_PT_smoke_cache_highres(PhysicButtonsPanel, bpy.types.Panel):
207     bl_label = "Smoke High Resolution Cache"
208     bl_default_closed = True
209
210     @classmethod
211     def poll(cls, context):
212         md = context.smoke
213         return md and (md.smoke_type == 'DOMAIN') and md.domain_settings.highres
214
215     def draw(self, context):
216         layout = self.layout
217
218         md = context.smoke.domain_settings
219         cache = md.point_cache_high
220
221         layout.label(text="Compression:")
222         layout.prop(md, "smoke_cache_high_comp", expand=True)
223
224         point_cache_ui(self, context, cache, (cache.baked is False), 'SMOKE')
225
226
227 class PHYSICS_PT_smoke_field_weights(PhysicButtonsPanel, bpy.types.Panel):
228     bl_label = "Smoke Field Weights"
229     bl_default_closed = True
230
231     @classmethod
232     def poll(cls, context):
233         smoke = context.smoke
234         return (smoke and smoke.smoke_type == 'DOMAIN')
235
236     def draw(self, context):
237         domain = context.smoke.domain_settings
238         effector_weights_ui(self, context, domain.effector_weights)
239
240
241 def register():
242     pass
243
244
245 def unregister():
246     pass
247
248 if __name__ == "__main__":
249     register()