fix for keying set rna path attribute and object select menu incorrect args to UI...
[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 narrowui = 180
23
24
25 from properties_physics_common import point_cache_ui
26 from properties_physics_common import effector_weights_ui
27
28
29 class PhysicButtonsPanel(bpy.types.Panel):
30     bl_space_type = 'PROPERTIES'
31     bl_region_type = 'WINDOW'
32     bl_context = "physics"
33
34     def poll(self, context):
35         ob = context.object
36         rd = context.scene.render
37         return (ob and ob.type == 'MESH') and (not rd.use_game_engine)
38
39
40 class PHYSICS_PT_smoke(PhysicButtonsPanel):
41     bl_label = "Smoke"
42
43     def draw(self, context):
44         layout = self.layout
45
46         md = context.smoke
47         ob = context.object
48         wide_ui = context.region.width > narrowui
49
50         split = layout.split()
51         split.operator_context = 'EXEC_DEFAULT'
52
53         if md:
54             # remove modifier + settings
55             split.set_context_pointer("modifier", md)
56             split.operator("object.modifier_remove", text="Remove")
57
58             row = split.row(align=True)
59             row.prop(md, "render", text="")
60             row.prop(md, "realtime", text="")
61
62         else:
63             # add modifier
64             split.operator("object.modifier_add", text="Add").type = 'SMOKE'
65             if wide_ui:
66                 split.label()
67
68         if md:
69             if wide_ui:
70                 layout.prop(md, "smoke_type", expand=True)
71             else:
72                 layout.prop(md, "smoke_type", text="")
73
74             if md.smoke_type == 'TYPE_DOMAIN':
75
76                 domain = md.domain_settings
77
78                 split = layout.split()
79
80                 col = split.column()
81                 col.label(text="Resolution:")
82                 col.prop(domain, "maxres", text="Divisions")
83                 col.label(text="Particle:")
84                 col.prop(domain, "initial_velocity", text="Initial Velocity")
85
86                 if wide_ui:
87                     col = split.column()
88                 col.label(text="Behavior:")
89                 col.prop(domain, "alpha")
90                 col.prop(domain, "beta")
91                 col.prop(domain, "dissolve_smoke", text="Dissolve")
92                 sub = col.column()
93                 sub.active = domain.dissolve_smoke
94                 sub.prop(domain, "dissolve_speed", text="Time")
95                 sub.prop(domain, "dissolve_smoke_log", text="Slow")
96
97             elif md.smoke_type == 'TYPE_FLOW':
98
99                 flow = md.flow_settings
100
101                 split = layout.split()
102
103                 col = split.column()
104                 col.prop(flow, "outflow")
105                 col.label(text="Particle System:")
106                 col.prop_object(flow, "psys", ob, "particle_systems", text="")
107
108                 if md.flow_settings.outflow:
109                     if wide_ui:
110                         col = split.column()
111                 else:
112                     if wide_ui:
113                         col = split.column()
114                     col.label(text="Behavior:")
115                     col.prop(flow, "temperature")
116                     col.prop(flow, "density")
117
118             #elif md.smoke_type == 'TYPE_COLL':
119             #   layout.separator()
120
121
122 class PHYSICS_PT_smoke_groups(PhysicButtonsPanel):
123     bl_label = "Smoke Groups"
124     bl_default_closed = True
125
126     def poll(self, context):
127         md = context.smoke
128         return md and (md.smoke_type == 'TYPE_DOMAIN')
129
130     def draw(self, context):
131         layout = self.layout
132
133         group = context.smoke.domain_settings
134         wide_ui = context.region.width > narrowui
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         if wide_ui:
146             col = split.column()
147         col.label(text="Collision Group:")
148         col.prop(group, "coll_group", text="")
149
150
151 class PHYSICS_PT_smoke_cache(PhysicButtonsPanel):
152     bl_label = "Smoke Cache"
153     bl_default_closed = True
154
155     def poll(self, context):
156         md = context.smoke
157         return md and (md.smoke_type == 'TYPE_DOMAIN')
158
159     def draw(self, context):
160         layout = self.layout
161
162         domain = context.smoke.domain_settings
163
164         layout.label(text="Compression:")
165         layout.prop(domain, "smoke_cache_comp", expand=True)
166
167         md = context.smoke.domain_settings
168         cache = md.point_cache_low
169
170         point_cache_ui(self, context, cache, (cache.baked is False), 0, 1)
171
172
173 class PHYSICS_PT_smoke_highres(PhysicButtonsPanel):
174     bl_label = "Smoke High Resolution"
175     bl_default_closed = True
176
177     def poll(self, context):
178         md = context.smoke
179         return md and (md.smoke_type == 'TYPE_DOMAIN')
180
181     def draw_header(self, context):
182         high = context.smoke.domain_settings
183
184         self.layout.prop(high, "highres", text="")
185
186     def draw(self, context):
187         layout = self.layout
188
189         md = context.smoke.domain_settings
190         wide_ui = context.region.width > narrowui
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, "viewhighres")
198
199         if wide_ui:
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):
207     bl_label = "Smoke High Resolution Cache"
208     bl_default_closed = True
209
210     def poll(self, context):
211         md = context.smoke
212         return md and (md.smoke_type == 'TYPE_DOMAIN') and md.domain_settings.highres
213
214     def draw(self, context):
215         layout = self.layout
216
217         domain = context.smoke.domain_settings
218
219         layout.label(text="Compression:")
220         layout.prop(domain, "smoke_cache_high_comp", expand=True)
221
222
223         md = context.smoke.domain_settings
224         cache = md.point_cache_high
225
226         point_cache_ui(self, context, cache, (cache.baked is False), 0, 1)
227
228
229 class PHYSICS_PT_smoke_field_weights(PhysicButtonsPanel):
230     bl_label = "Smoke Field Weights"
231     bl_default_closed = True
232
233     def poll(self, context):
234         smoke = context.smoke
235         return (smoke and smoke.smoke_type == 'TYPE_DOMAIN')
236
237     def draw(self, context):
238         domain = context.smoke.domain_settings
239         effector_weights_ui(self, context, domain.effector_weights)
240
241
242 classes = [
243     PHYSICS_PT_smoke,
244     PHYSICS_PT_smoke_field_weights,
245     PHYSICS_PT_smoke_cache,
246     PHYSICS_PT_smoke_highres,
247     PHYSICS_PT_smoke_groups,
248     PHYSICS_PT_smoke_cache_highres]
249
250
251 def register():
252     register = bpy.types.register
253     for cls in classes:
254         register(cls)
255
256
257 def unregister():
258     unregister = bpy.types.unregister
259     for cls in classes:
260         unregister(cls)
261
262 if __name__ == "__main__":
263     register()