svn merge -r 21508:22111 https://svn.blender.org/svnroot/bf-blender/branches/blender2...
[blender.git] / release / ui / buttons_scene.py
1
2 import bpy
3
4 # If python version is less than 2.4, try to get set stuff from module
5 try:
6         set
7 except:
8         from sets import Set as set
9
10 class RenderButtonsPanel(bpy.types.Panel):
11         __space_type__ = "BUTTONS_WINDOW"
12         __region_type__ = "WINDOW"
13         __context__ = "scene"
14         # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
15         
16         def poll(self, context):
17                 rd = context.scene.render_data
18                 return (rd.use_game_engine==False) and (rd.engine in self.COMPAT_ENGINES)
19
20 class SCENE_PT_render(RenderButtonsPanel):
21         __label__ = "Render"
22         COMPAT_ENGINES = set(['BLENDER_RENDER'])
23         
24         def draw(self, context):
25                 layout = self.layout
26                 
27                 rd = context.scene.render_data
28
29                 row = layout.row()
30                 row.itemO("screen.render", text="Image", icon='ICON_RENDER_RESULT')
31                 row.item_booleanO("screen.render", "animation", True, text="Animation", icon='ICON_RENDER_ANIMATION')
32
33                 layout.itemR(rd, "display_mode", text="Display")
34
35 class SCENE_PT_layers(RenderButtonsPanel):
36         __label__ = "Layers"
37         __default_closed__ = True
38         COMPAT_ENGINES = set(['BLENDER_RENDER'])
39         
40         def draw(self, context):
41                 layout = self.layout
42                 
43                 scene = context.scene
44                 rd = scene.render_data
45
46                 row = layout.row()
47                 row.template_list(rd, "layers", rd, "active_layer_index", rows=2)
48
49                 col = row.column(align=True)
50                 col.itemO("scene.render_layer_add", icon="ICON_ZOOMIN", text="")
51                 col.itemO("scene.render_layer_remove", icon="ICON_ZOOMOUT", text="")
52
53                 rl = rd.layers[rd.active_layer_index]
54
55                 split = layout.split()
56                 
57                 col = split.column()
58                 col.itemR(scene, "visible_layers", text="Scene")
59                 col = split.column()
60                 col.itemR(rl, "visible_layers", text="Layer")
61
62                 layout.itemR(rl, "light_override", text="Light")
63                 layout.itemR(rl, "material_override", text="Material")
64                 
65                 layout.itemS()
66                 layout.itemL(text="Include:")
67                 
68                 split = layout.split()
69
70                 col = split.column()
71                 col.itemR(rl, "zmask")
72                 row = col.row()
73                 row.itemR(rl, "zmask_negate", text="Negate")
74                 row.active = rl.zmask
75                 col.itemR(rl, "all_z")
76
77                 col = split.column()
78                 col.itemR(rl, "solid")
79                 col.itemR(rl, "halo")
80                 col.itemR(rl, "ztransp")
81
82                 col = split.column()
83                 col.itemR(rl, "sky")
84                 col.itemR(rl, "edge")
85                 col.itemR(rl, "strand")
86
87                 if rl.zmask:
88                         split = layout.split()
89                         split.itemL(text="Zmask Layers:")
90                         split.column().itemR(rl, "zmask_layers", text="")
91                 
92                 layout.itemS()
93                 
94                 split = layout.split()
95                 
96                 col = split.column()
97                 col.itemL(text="Passes:")
98                 col.itemR(rl, "pass_combined")
99                 col.itemR(rl, "pass_z")
100                 col.itemR(rl, "pass_vector")
101                 col.itemR(rl, "pass_normal")
102                 col.itemR(rl, "pass_uv")
103                 col.itemR(rl, "pass_mist")
104                 col.itemR(rl, "pass_object_index")
105
106                 col = split.column()
107                 col.itemL()
108                 col.itemR(rl, "pass_color")
109                 col.itemR(rl, "pass_diffuse")
110                 row = col.row()
111                 row.itemR(rl, "pass_specular")
112                 row.itemR(rl, "pass_specular_exclude", text="", icon="ICON_X")
113                 row = col.row()
114                 row.itemR(rl, "pass_shadow")
115                 row.itemR(rl, "pass_shadow_exclude", text="", icon="ICON_X")
116                 row = col.row()
117                 row.itemR(rl, "pass_ao")
118                 row.itemR(rl, "pass_ao_exclude", text="", icon="ICON_X")
119                 row = col.row()
120                 row.itemR(rl, "pass_reflection")
121                 row.itemR(rl, "pass_reflection_exclude", text="", icon="ICON_X")
122                 row = col.row()
123                 row.itemR(rl, "pass_refraction")
124                 row.itemR(rl, "pass_refraction_exclude", text="", icon="ICON_X")
125
126 class SCENE_PT_shading(RenderButtonsPanel):
127         __label__ = "Shading"
128         COMPAT_ENGINES = set(['BLENDER_RENDER'])
129
130         def draw(self, context):
131                 layout = self.layout
132                 
133                 rd = context.scene.render_data
134                 
135                 split = layout.split()
136                 
137                 col = split.column()
138                 col.itemR(rd, "render_textures", text="Textures")
139                 col.itemR(rd, "render_shadows", text="Shadows")
140                 col.itemR(rd, "render_sss", text="Subsurface Scattering")
141                 col.itemR(rd, "render_envmaps", text="Environment Map")
142                 
143                 col = split.column()
144                 col.itemR(rd, "render_raytracing", text="Ray Tracing")
145                 col.itemR(rd, "color_management")
146                 col.itemR(rd, "alpha_mode", text="Alpha")
147
148 class SCENE_PT_performance(RenderButtonsPanel):
149         __label__ = "Performance"
150         __default_closed__ = True
151         COMPAT_ENGINES = set(['BLENDER_RENDER'])
152
153         def draw(self, context):
154                 layout = self.layout
155                 
156                 rd = context.scene.render_data
157
158                 split = layout.split()
159                 
160                 col = split.column(align=True)
161                 col.itemL(text="Threads:")
162                 col.row().itemR(rd, "threads_mode", expand=True)
163                 sub = col.column()
164                 sub.enabled = rd.threads_mode == 'THREADS_FIXED'
165                 sub.itemR(rd, "threads")
166
167                 col = split.column(align=True)
168                 col.itemL(text="Tiles:")
169                 col.itemR(rd, "parts_x", text="X")
170                 col.itemR(rd, "parts_y", text="Y")
171
172                 split = layout.split()
173
174                 col = split.column()
175                 col.itemL(text="Memory:")
176                 row = col.row()
177                 row.itemR(rd, "save_buffers")
178                 row.enabled = not rd.full_sample
179
180                 col = split.column()
181                 col.active = rd.use_compositing
182                 col.itemL()
183                 col.itemR(rd, "free_image_textures")
184
185                 row = layout.row()
186                 row.active = rd.render_raytracing
187                 row.itemR(rd, "octree_resolution", text="Ray Tracing Octree")
188                 row.itemR(rd, "raytrace_structure", text="Structure")
189                 row.itemR(rd, "raytrace_tree_type", text="Tree Type")
190
191 class SCENE_PT_post_processing(RenderButtonsPanel):
192         __label__ = "Post Processing"
193         __default_closed__ = True
194         COMPAT_ENGINES = set(['BLENDER_RENDER'])
195
196         def draw(self, context):
197                 layout = self.layout
198                 
199                 rd = context.scene.render_data
200
201                 split = layout.split()
202
203                 col = split.column()
204                 col.itemR(rd, "use_compositing")
205                 col.itemR(rd, "use_sequencer")
206
207                 col = split.column()
208                 row = col.row()
209                 row.itemR(rd, "fields", text="Fields")
210                 sub = row.row()
211                 sub.active = rd.fields
212                 sub.itemR(rd, "fields_still", text="Still")
213                 sub = col.row()
214                 sub.active = rd.fields
215                 sub.itemR(rd, "field_order", expand=True)
216
217                 split = layout.split()
218                 split.itemL()
219                 split.itemR(rd, "dither_intensity", text="Dither", slider=True)
220                 
221 class SCENE_PT_output(RenderButtonsPanel):
222         __label__ = "Output"
223         COMPAT_ENGINES = set(['BLENDER_RENDER'])
224
225         def draw(self, context):
226                 layout = self.layout
227                 
228                 rd = context.scene.render_data
229                 
230                 layout.itemR(rd, "output_path", text="")
231
232                 split = layout.split()
233                 col = split.column()
234                 col.itemR(rd, "file_format", text="")
235                 col.row().itemR(rd, "color_mode", text="Color", expand=True)
236
237                 col = split.column()
238                 col.itemR(rd, "file_extensions")
239                 col.itemR(rd, "placeholders")
240                 col.itemR(rd, "no_overwrite")
241
242                 if rd.file_format in ('AVIJPEG', 'JPEG'):
243                         split = layout.split()
244                         split.itemR(rd, "quality", slider=True)
245                         
246                 elif rd.file_format == 'OPENEXR':
247                         split = layout.split()
248                         
249                         col = split.column()
250                         col.itemR(rd, "exr_codec")
251
252                         subsplit = split.split()
253                         col = subsplit.column()
254                         col.itemR(rd, "exr_half")
255                         col.itemR(rd, "exr_zbuf")
256                         col = subsplit.column()
257                         col.itemR(rd, "exr_preview")
258                 
259                 elif rd.file_format == 'JPEG2000':
260                         split = layout.split()
261                         col = split.column()
262                         col.itemL(text="Depth:")
263                         col.row().itemR(rd, "jpeg_depth", expand=True)
264
265                         col = split.column()
266                         col.itemR(rd, "jpeg_preset", text="")
267                         col.itemR(rd, "jpeg_ycc")
268                         col.itemR(rd, "exr_preview")
269                         
270                 elif rd.file_format in ('CINEON', 'DPX'):
271                         split = layout.split()
272                         col = split.column()
273                         col.itemR(rd, "cineon_log", text="Convert to Log")
274
275                         col = split.column(align=True)
276                         col.active = rd.cineon_log
277                         col.itemR(rd, "cineon_black", text="Black")
278                         col.itemR(rd, "cineon_white", text="White")
279                         col.itemR(rd, "cineon_gamma", text="Gamma")
280                         
281                 elif rd.file_format == 'TIFF':
282                         split = layout.split()
283                         split.itemR(rd, "tiff_bit")
284
285 class SCENE_PT_encoding(RenderButtonsPanel):
286         __label__ = "Encoding"
287         __default_closed__ = True
288         COMPAT_ENGINES = set(['BLENDER_RENDER'])
289         
290         def poll(self, context):
291                 rd = context.scene.render_data
292                 return rd.file_format in ('FFMPEG', 'XVID', 'H264', 'THEORA')
293
294         def draw(self, context):
295                 layout = self.layout
296                 
297                 rd = context.scene.render_data
298
299                 split = layout.split()
300                 
301                 split.itemR(rd, "ffmpeg_format")
302                 if rd.ffmpeg_format in ('AVI', 'QUICKTIME', 'MKV', 'OGG'):
303                         split.itemR(rd, "ffmpeg_codec")
304                 else:
305                         split.itemL()
306
307                 split = layout.split()
308         
309                 col = split.column()
310                 col.itemR(rd, "ffmpeg_video_bitrate")
311                 col.itemL(text="Rate:")
312                 col.itemR(rd, "ffmpeg_minrate", text="Minimum")
313                 col.itemR(rd, "ffmpeg_maxrate", text="Maximum")
314                 col.itemR(rd, "ffmpeg_buffersize", text="Buffer")
315                 
316                 col = split.column()
317                 col.itemR(rd, "ffmpeg_gopsize")
318                 col.itemR(rd, "ffmpeg_autosplit")
319                 col.itemL(text="Mux:")
320                 col.itemR(rd, "ffmpeg_muxrate", text="Rate")
321                 col.itemR(rd, "ffmpeg_packetsize", text="Packet Size")
322                 
323                 row = layout.row()
324                 row.itemL(text="Audio:")
325                 row = layout.row()
326                 row.itemR(rd, "ffmpeg_audio_codec")
327                 
328                 split = layout.split()
329
330                 col = split.column()
331                 col.itemR(rd, "ffmpeg_audio_bitrate")
332                 col = split.column()
333                 col.itemR(rd, "ffmpeg_multiplex_audio")
334
335 class SCENE_PT_antialiasing(RenderButtonsPanel):
336         __label__ = "Anti-Aliasing"
337         COMPAT_ENGINES = set(['BLENDER_RENDER'])
338
339         def draw_header(self, context):
340                 layout = self.layout
341                 
342                 rd = context.scene.render_data
343
344                 layout.itemR(rd, "antialiasing", text="")
345
346         def draw(self, context):
347                 layout = self.layout
348                 
349                 rd = context.scene.render_data
350
351                 layout.active = rd.antialiasing
352
353                 split = layout.split()
354                 
355                 col = split.column()
356                 col.row().itemR(rd, "antialiasing_samples", expand=True)
357                 col.itemR(rd, "full_sample")
358
359                 col = split.column()
360                 col.itemR(rd, "pixel_filter", text="")
361                 col.itemR(rd, "filter_size", text="Size", slider=True)
362         
363 class SCENE_PT_dimensions(RenderButtonsPanel):
364         __label__ = "Dimensions"
365         COMPAT_ENGINES = set(['BLENDER_RENDER'])
366
367         def draw(self, context):
368                 layout = self.layout
369                 
370                 scene = context.scene
371                 rd = scene.render_data
372                 
373                 split = layout.split()
374                 
375                 col = split.column()
376                 sub = col.column(align=True)
377                 sub.itemL(text="Resolution:")
378                 sub.itemR(rd, "resolution_x", text="X")
379                 sub.itemR(rd, "resolution_y", text="Y")
380                 sub.itemR(rd, "resolution_percentage", text="")
381                 
382                 sub.itemL(text="Aspect Ratio:")
383                 sub.itemR(rd, "pixel_aspect_x", text="X")
384                 sub.itemR(rd, "pixel_aspect_y", text="Y")
385
386                 row = col.row()
387                 row.itemR(rd, "border", text="Border")
388                 rowsub = row.row()
389                 rowsub.active = rd.border
390                 rowsub.itemR(rd, "crop_to_border", text="Crop")
391                 
392                 col = split.column(align=True)
393                 col.itemL(text="Frame Range:")
394                 col.itemR(scene, "start_frame", text="Start")
395                 col.itemR(scene, "end_frame", text="End")
396                 col.itemR(scene, "frame_step", text="Step")
397                 
398                 col.itemL(text="Frame Rate:")
399                 col.itemR(rd, "fps")
400                 col.itemR(rd, "fps_base",text="/")
401
402 class SCENE_PT_stamp(RenderButtonsPanel):
403         __label__ = "Stamp"
404         __default_closed__ = True
405         COMPAT_ENGINES = set(['BLENDER_RENDER'])
406
407         def draw_header(self, context):
408                 layout = self.layout
409                 
410                 rd = context.scene.render_data
411
412                 layout.itemR(rd, "render_stamp", text="")
413
414         def draw(self, context):
415                 layout = self.layout
416                 
417                 rd = context.scene.render_data
418
419                 layout.active = rd.render_stamp
420
421                 split = layout.split()
422                 
423                 col = split.column()
424                 col.itemR(rd, "stamp_time", text="Time")
425                 col.itemR(rd, "stamp_date", text="Date")
426                 col.itemR(rd, "stamp_frame", text="Frame")
427                 col.itemR(rd, "stamp_scene", text="Scene")
428                 col.itemR(rd, "stamp_camera", text="Camera")
429                 col.itemR(rd, "stamp_filename", text="Filename")
430                 col.itemR(rd, "stamp_marker", text="Marker")
431                 col.itemR(rd, "stamp_sequence_strip", text="Seq. Strip")
432
433                 col = split.column()
434                 col.active = rd.render_stamp
435                 col.itemR(rd, "stamp_foreground", slider=True)
436                 col.itemR(rd, "stamp_background", slider=True)
437                 col.itemR(rd, "stamp_font_size", text="Font Size")
438
439                 row = layout.split(percentage=0.2)
440                 row.itemR(rd, "stamp_note", text="Note")
441                 sub = row.row()
442                 sub.active = rd.stamp_note
443                 sub.itemR(rd, "stamp_note_text", text="")
444
445 bpy.types.register(SCENE_PT_render)
446 bpy.types.register(SCENE_PT_layers)
447 bpy.types.register(SCENE_PT_dimensions)
448 bpy.types.register(SCENE_PT_antialiasing)
449 bpy.types.register(SCENE_PT_shading)
450 bpy.types.register(SCENE_PT_output)
451 bpy.types.register(SCENE_PT_encoding)
452 bpy.types.register(SCENE_PT_performance)
453 bpy.types.register(SCENE_PT_post_processing)
454 bpy.types.register(SCENE_PT_stamp)