remove use of gettext: _("...") style translation now its handled by rna.
[blender.git] / release / scripts / startup / bl_ui / properties_physics_fluid.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 from bpy.types import Panel
22
23
24 class PhysicButtonsPanel():
25     bl_space_type = 'PROPERTIES'
26     bl_region_type = 'WINDOW'
27     bl_context = "physics"
28
29     @classmethod
30     def poll(cls, context):
31         ob = context.object
32         rd = context.scene.render
33         return (ob and ob.type == 'MESH') and (not rd.use_game_engine) and (context.fluid)
34
35
36 class PHYSICS_PT_fluid(PhysicButtonsPanel, Panel):
37     bl_label = "Fluid"
38
39     def draw(self, context):
40         layout = self.layout
41
42         md = context.fluid
43
44         if md:
45             fluid = md.settings
46
47             row = layout.row()
48             if fluid is None:
49                 row.label("Built without fluids")
50                 return
51
52             row.prop(fluid, "type")
53             if fluid.type not in {'NONE', 'DOMAIN', 'PARTICLE', 'FLUID'}:
54                 row.prop(fluid, "use", text="")
55
56             layout = layout.column()
57             if fluid.type not in {'NONE', 'DOMAIN', 'PARTICLE', 'FLUID'}:
58                 layout.active = fluid.use
59
60             if fluid.type == 'DOMAIN':
61                 layout.operator("fluid.bake", text="Bake (Req. Memory:" + " %s)" % fluid.memory_estimate, icon='MOD_FLUIDSIM')
62                 split = layout.split()
63
64                 col = split.column()
65                 col.label(text="Resolution:")
66                 col.prop(fluid, "resolution", text="Final")
67                 col.label(text="Render Display:")
68                 col.prop(fluid, "render_display_mode", text="")
69
70                 col = split.column()
71                 col.label()
72                 col.prop(fluid, "preview_resolution", text="Preview")
73                 col.label(text="Viewport Display:")
74                 col.prop(fluid, "viewport_display_mode", text="")
75
76                 split = layout.split()
77
78                 col = split.column()
79                 col.label(text="Time:")
80                 sub = col.column(align=True)
81                 sub.prop(fluid, "start_time", text="Start")
82                 sub.prop(fluid, "end_time", text="End")
83
84                 col = split.column()
85                 col.label()
86                 col.prop(fluid, "use_speed_vectors")
87                 col.prop(fluid, "use_reverse_frames")
88
89                 layout.prop(fluid, "filepath", text="")
90
91             elif fluid.type == 'FLUID':
92                 split = layout.split()
93
94                 col = split.column()
95                 col.label(text="Volume Initialization:")
96                 col.prop(fluid, "volume_initialization", text="")
97                 col.prop(fluid, "use_animated_mesh")
98
99                 col = split.column()
100                 col.label(text="Initial Velocity:")
101                 col.prop(fluid, "initial_velocity", text="")
102
103             elif fluid.type == 'OBSTACLE':
104                 split = layout.split()
105
106                 col = split.column()
107                 col.label(text="Volume Initialization:")
108                 col.prop(fluid, "volume_initialization", text="")
109                 col.prop(fluid, "use_animated_mesh")
110
111                 col = split.column()
112                 col.label(text="Slip Type:")
113                 col.prop(fluid, "slip_type", text="")
114                 if fluid.slip_type == 'PARTIALSLIP':
115                     col.prop(fluid, "partial_slip_factor", slider=True, text="Amount")
116
117                 col.label(text="Impact:")
118                 col.prop(fluid, "impact_factor", text="Factor")
119
120             elif fluid.type == 'INFLOW':
121                 split = layout.split()
122
123                 col = split.column()
124                 col.label(text="Volume Initialization:")
125                 col.prop(fluid, "volume_initialization", text="")
126                 col.prop(fluid, "use_animated_mesh")
127                 row = col.row()
128                 row.active = not fluid.use_animated_mesh
129                 row.prop(fluid, "use_local_coords")
130
131                 col = split.column()
132                 col.label(text="Inflow Velocity:")
133                 col.prop(fluid, "inflow_velocity", text="")
134
135             elif fluid.type == 'OUTFLOW':
136                 split = layout.split()
137
138                 col = split.column()
139                 col.label(text="Volume Initialization:")
140                 col.prop(fluid, "volume_initialization", text="")
141                 col.prop(fluid, "use_animated_mesh")
142
143                 split.column()
144
145             elif fluid.type == 'PARTICLE':
146                 split = layout.split()
147
148                 col = split.column()
149                 col.label(text="Influence:")
150                 col.prop(fluid, "particle_influence", text="Size")
151                 col.prop(fluid, "alpha_influence", text="Alpha")
152
153                 col = split.column()
154                 col.label(text="Type:")
155                 col.prop(fluid, "use_drops")
156                 col.prop(fluid, "use_floats")
157                 col.prop(fluid, "show_tracer")
158
159                 layout.prop(fluid, "filepath", text="")
160
161             elif fluid.type == 'CONTROL':
162                 split = layout.split()
163
164                 col = split.column()
165                 col.label(text="")
166                 col.prop(fluid, "quality", slider=True)
167                 col.prop(fluid, "use_reverse_frames")
168
169                 col = split.column()
170                 col.label(text="Time:")
171                 sub = col.column(align=True)
172                 sub.prop(fluid, "start_time", text="Start")
173                 sub.prop(fluid, "end_time", text="End")
174
175                 split = layout.split()
176
177                 col = split.column()
178                 col.label(text="Attraction Force:")
179                 sub = col.column(align=True)
180                 sub.prop(fluid, "attraction_strength", text="Strength")
181                 sub.prop(fluid, "attraction_radius", text="Radius")
182
183                 col = split.column()
184                 col.label(text="Velocity Force:")
185                 sub = col.column(align=True)
186                 sub.prop(fluid, "velocity_strength", text="Strength")
187                 sub.prop(fluid, "velocity_radius", text="Radius")
188
189
190 class PHYSICS_PT_domain_gravity(PhysicButtonsPanel, Panel):
191     bl_label = "Domain World"
192     bl_options = {'DEFAULT_CLOSED'}
193
194     @classmethod
195     def poll(cls, context):
196         md = context.fluid
197         return md and md.settings and (md.settings.type == 'DOMAIN')
198
199     def draw(self, context):
200         layout = self.layout
201
202         fluid = context.fluid.settings
203         scene = context.scene
204
205         split = layout.split()
206
207         col = split.column()
208         if scene.use_gravity:
209             col.label(text="Using Scene Gravity", icon="SCENE_DATA")
210             sub = col.column()
211             sub.enabled = False
212             sub.prop(fluid, "gravity", text="")
213         else:
214             col.label(text="Gravity:")
215             col.prop(fluid, "gravity", text="")
216
217         if scene.unit_settings.system != 'NONE':
218             col.label(text="Using Scene Size Units", icon="SCENE_DATA")
219             sub = col.column()
220             sub.enabled = False
221             sub.prop(fluid, "simulation_scale", text="Metres")
222         else:
223             col.label(text="Real World Size:")
224             col.prop(fluid, "simulation_scale", text="Metres")
225
226         col = split.column()
227         col.label(text="Viscosity Presets:")
228         sub = col.column(align=True)
229         sub.prop(fluid, "viscosity_preset", text="")
230
231         if fluid.viscosity_preset == 'MANUAL':
232             sub.prop(fluid, "viscosity_base", text="Base")
233             sub.prop(fluid, "viscosity_exponent", text="Exponent", slider=True)
234
235         col.label(text="Optimization:")
236         col.prop(fluid, "grid_levels", slider=True)
237         col.prop(fluid, "compressibility", slider=True)
238
239
240 class PHYSICS_PT_domain_boundary(PhysicButtonsPanel, Panel):
241     bl_label = "Domain Boundary"
242     bl_options = {'DEFAULT_CLOSED'}
243
244     @classmethod
245     def poll(cls, context):
246         md = context.fluid
247         return md and md.settings and (md.settings.type == 'DOMAIN')
248
249     def draw(self, context):
250         layout = self.layout
251
252         fluid = context.fluid.settings
253
254         split = layout.split()
255
256         col = split.column()
257         col.label(text="Slip Type:")
258         col.prop(fluid, "slip_type", text="")
259         if fluid.slip_type == 'PARTIALSLIP':
260             col.prop(fluid, "partial_slip_factor", slider=True, text="Amount")
261         col.prop(fluid, "surface_noobs")
262
263         col = split.column()
264         col.label(text="Surface:")
265         col.prop(fluid, "surface_smooth", text="Smoothing")
266         col.prop(fluid, "surface_subdivisions", text="Subdivisions")
267
268
269 class PHYSICS_PT_domain_particles(PhysicButtonsPanel, Panel):
270     bl_label = "Domain Particles"
271     bl_options = {'DEFAULT_CLOSED'}
272
273     @classmethod
274     def poll(cls, context):
275         md = context.fluid
276         return md and md.settings and (md.settings.type == 'DOMAIN')
277
278     def draw(self, context):
279         layout = self.layout
280
281         fluid = context.fluid.settings
282
283         col = layout.column(align=True)
284         col.prop(fluid, "tracer_particles")
285         col.prop(fluid, "generate_particles")
286
287 if __name__ == "__main__":  # only for live edit.
288     bpy.utils.register_module(__name__)