9bd0019bd6c5c7510e252e136a291b242eca2a82
[blender.git] / release / scripts / ui / buttons_scene.py
1
2 import bpy
3
4 class SceneButtonsPanel(bpy.types.Panel):
5         __space_type__ = 'PROPERTIES'
6         __region_type__ = 'WINDOW'
7         __context__ = "scene"
8         
9         def poll(self, context):
10                 return (context.scene != None)
11
12 class RenderButtonsPanel(bpy.types.Panel):
13         __space_type__ = 'PROPERTIES'
14         __region_type__ = 'WINDOW'
15         __context__ = "scene"
16         # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
17         
18         def poll(self, context):
19                 rd = context.scene.render_data
20                 return (rd.use_game_engine==False) and (rd.engine in self.COMPAT_ENGINES)
21
22 class SCENE_PT_render(RenderButtonsPanel):
23         __label__ = "Render"
24         COMPAT_ENGINES = set(['BLENDER_RENDER'])
25         
26         def draw(self, context):
27                 layout = self.layout
28                 
29                 rd = context.scene.render_data
30
31                 row = layout.row()
32                 row.itemO("screen.render", text="Image", icon='ICON_RENDER_RESULT')
33                 row.item_booleanO("screen.render", "animation", True, text="Animation", icon='ICON_RENDER_ANIMATION')
34
35                 layout.itemR(rd, "display_mode", text="Display")
36
37 class SCENE_PT_layers(RenderButtonsPanel):
38         __label__ = "Layers"
39         __default_closed__ = True
40         COMPAT_ENGINES = set(['BLENDER_RENDER'])
41         
42         def draw(self, context):
43                 layout = self.layout
44                 
45                 scene = context.scene
46                 rd = scene.render_data
47
48                 row = layout.row()
49                 row.template_list(rd, "layers", rd, "active_layer_index", rows=2)
50
51                 col = row.column(align=True)
52                 col.itemO("scene.render_layer_add", icon='ICON_ZOOMIN', text="")
53                 col.itemO("scene.render_layer_remove", icon='ICON_ZOOMOUT', text="")
54
55                 rl = rd.layers[rd.active_layer_index]
56
57                 split = layout.split()
58                 
59                 col = split.column()
60                 col.itemR(scene, "visible_layers", text="Scene")
61                 col = split.column()
62                 col.itemR(rl, "visible_layers", text="Layer")
63
64                 layout.itemR(rl, "light_override", text="Light")
65                 layout.itemR(rl, "material_override", text="Material")
66                 
67                 layout.itemS()
68                 layout.itemL(text="Include:")
69                 
70                 split = layout.split()
71
72                 col = split.column()
73                 col.itemR(rl, "zmask")
74                 row = col.row()
75                 row.itemR(rl, "zmask_negate", text="Negate")
76                 row.active = rl.zmask
77                 col.itemR(rl, "all_z")
78
79                 col = split.column()
80                 col.itemR(rl, "solid")
81                 col.itemR(rl, "halo")
82                 col.itemR(rl, "ztransp")
83
84                 col = split.column()
85                 col.itemR(rl, "sky")
86                 col.itemR(rl, "edge")
87                 col.itemR(rl, "strand")
88
89                 if rl.zmask:
90                         split = layout.split()
91                         split.itemL(text="Zmask Layers:")
92                         split.column().itemR(rl, "zmask_layers", text="")
93                 
94                 layout.itemS()
95                 
96                 split = layout.split()
97                 
98                 col = split.column()
99                 col.itemL(text="Passes:")
100                 col.itemR(rl, "pass_combined")
101                 col.itemR(rl, "pass_z")
102                 col.itemR(rl, "pass_vector")
103                 col.itemR(rl, "pass_normal")
104                 col.itemR(rl, "pass_uv")
105                 col.itemR(rl, "pass_mist")
106                 col.itemR(rl, "pass_object_index")
107
108                 col = split.column()
109                 col.itemL()
110                 col.itemR(rl, "pass_color")
111                 col.itemR(rl, "pass_diffuse")
112                 row = col.row()
113                 row.itemR(rl, "pass_specular")
114                 row.itemR(rl, "pass_specular_exclude", text="", icon='ICON_X')
115                 row = col.row()
116                 row.itemR(rl, "pass_shadow")
117                 row.itemR(rl, "pass_shadow_exclude", text="", icon='ICON_X')
118                 row = col.row()
119                 row.itemR(rl, "pass_ao")
120                 row.itemR(rl, "pass_ao_exclude", text="", icon='ICON_X')
121                 row = col.row()
122                 row.itemR(rl, "pass_reflection")
123                 row.itemR(rl, "pass_reflection_exclude", text="", icon='ICON_X')
124                 row = col.row()
125                 row.itemR(rl, "pass_refraction")
126                 row.itemR(rl, "pass_refraction_exclude", text="", icon='ICON_X')
127
128 class SCENE_PT_shading(RenderButtonsPanel):
129         __label__ = "Shading"
130         COMPAT_ENGINES = set(['BLENDER_RENDER'])
131
132         def draw(self, context):
133                 layout = self.layout
134                 
135                 rd = context.scene.render_data
136                 
137                 split = layout.split()
138                 
139                 col = split.column()
140                 col.itemR(rd, "render_textures", text="Textures")
141                 col.itemR(rd, "render_shadows", text="Shadows")
142                 col.itemR(rd, "render_sss", text="Subsurface Scattering")
143                 col.itemR(rd, "render_envmaps", text="Environment Map")
144                 
145                 col = split.column()
146                 col.itemR(rd, "render_raytracing", text="Ray Tracing")
147                 col.itemR(rd, "color_management")
148                 col.itemR(rd, "alpha_mode", text="Alpha")
149
150 class SCENE_PT_performance(RenderButtonsPanel):
151         __label__ = "Performance"
152         __default_closed__ = True
153         COMPAT_ENGINES = set(['BLENDER_RENDER'])
154
155         def draw(self, context):
156                 layout = self.layout
157                 
158                 rd = context.scene.render_data
159
160                 split = layout.split()
161                 
162                 col = split.column(align=True)
163                 col.itemL(text="Threads:")
164                 col.row().itemR(rd, "threads_mode", expand=True)
165                 sub = col.column()
166                 sub.enabled = rd.threads_mode == 'THREADS_FIXED'
167                 sub.itemR(rd, "threads")
168                 col.itemL(text="Tiles:")
169                 col.itemR(rd, "parts_x", text="X")
170                 col.itemR(rd, "parts_y", text="Y")
171
172                 col = split.column()
173                 col.itemL(text="Memory:")
174                 sub = col.column()
175                 sub.itemR(rd, "save_buffers")
176                 sub.enabled = not rd.full_sample
177                 sub = col.column()
178                 sub.active = rd.use_compositing
179                 sub.itemR(rd, "free_image_textures")
180                 sub = col.column()
181                 sub.active = rd.render_raytracing
182                 sub.itemL(text="Acceleration structure:")
183                 sub.itemR(rd, "raytrace_structure", text="")
184                 if rd.raytrace_structure == "OCTREE":
185                         sub.itemR(rd, "octree_resolution", text="Resolution")
186                 else:
187                         sub.itemR(rd, "use_instances", text="Instances")
188                 sub.itemR(rd, "use_local_coords", text="Local Coordinates")
189
190 class SCENE_PT_post_processing(RenderButtonsPanel):
191         __label__ = "Post Processing"
192         __default_closed__ = True
193         COMPAT_ENGINES = set(['BLENDER_RENDER'])
194
195         def draw(self, context):
196                 layout = self.layout
197                 
198                 rd = context.scene.render_data
199
200                 split = layout.split()
201
202                 col = split.column()
203                 col.itemR(rd, "use_compositing")
204                 col.itemR(rd, "use_sequencer")
205                 
206                 col = split.column()
207                 col.itemR(rd, "dither_intensity", text="Dither", slider=True)
208                 
209                 layout.itemS()
210                                 
211                 split = layout.split()
212                 
213                 col = split.column()
214                 col.itemR(rd, "fields", text="Fields")
215                 sub = col.column()
216                 sub.active = rd.fields
217                 sub.row().itemR(rd, "field_order", expand=True)
218                 sub.itemR(rd, "fields_still", text="Still")
219                 
220                 col = split.column()
221                 col.itemR(rd, "edge")
222                 sub = col.column()
223                 sub.active = rd.edge
224                 sub.itemR(rd, "edge_threshold", text="Threshold", slider=True)
225                 sub.itemR(rd, "edge_color", text="")
226                 
227 class SCENE_PT_output(RenderButtonsPanel):
228         __label__ = "Output"
229         COMPAT_ENGINES = set(['BLENDER_RENDER'])
230
231         def draw(self, context):
232                 layout = self.layout
233                 
234                 rd = context.scene.render_data
235                 
236                 layout.itemR(rd, "output_path", text="")
237
238                 split = layout.split()
239                 col = split.column()
240                 col.itemR(rd, "file_format", text="")
241                 col.row().itemR(rd, "color_mode", text="Color", expand=True)
242
243                 col = split.column()
244                 col.itemR(rd, "file_extensions")
245                 col.itemR(rd, "use_overwrite")
246                 col.itemR(rd, "use_placeholder")
247
248                 if rd.file_format in ('AVIJPEG', 'JPEG'):
249                         split = layout.split()
250                         split.itemR(rd, "quality", slider=True)
251                         
252                 elif rd.file_format == 'OPENEXR':
253                         split = layout.split()
254                         
255                         col = split.column()
256                         col.itemL(text="Codec:")
257                         col.itemR(rd, "exr_codec", text="")
258
259                         subsplit = split.split()
260                         col = subsplit.column()
261                         col.itemR(rd, "exr_half")
262                         col.itemR(rd, "exr_zbuf")
263                         col = subsplit.column()
264                         col.itemR(rd, "exr_preview")
265                 
266                 elif rd.file_format == 'JPEG2000':
267                         split = layout.split()
268                         col = split.column()
269                         col.itemL(text="Depth:")
270                         col.row().itemR(rd, "jpeg2k_depth", expand=True)
271
272                         col = split.column()
273                         col.itemR(rd, "jpeg2k_preset", text="")
274                         col.itemR(rd, "jpeg2k_ycc")
275                         
276                 elif rd.file_format in ('CINEON', 'DPX'):
277                         split = layout.split()
278                         col = split.column()
279                         col.itemR(rd, "cineon_log", text="Convert to Log")
280
281                         col = split.column(align=True)
282                         col.active = rd.cineon_log
283                         col.itemR(rd, "cineon_black", text="Black")
284                         col.itemR(rd, "cineon_white", text="White")
285                         col.itemR(rd, "cineon_gamma", text="Gamma")
286                         
287                 elif rd.file_format == 'TIFF':
288                         split = layout.split()
289                         split.itemR(rd, "tiff_bit")
290
291 class SCENE_PT_encoding(RenderButtonsPanel):
292         __label__ = "Encoding"
293         __default_closed__ = True
294         COMPAT_ENGINES = set(['BLENDER_RENDER'])
295         
296         def poll(self, context):
297                 rd = context.scene.render_data
298                 return rd.file_format in ('FFMPEG', 'XVID', 'H264', 'THEORA')
299
300         def draw(self, context):
301                 layout = self.layout
302                 
303                 rd = context.scene.render_data
304
305                 split = layout.split()
306                 
307                 split.itemR(rd, "ffmpeg_format")
308                 if rd.ffmpeg_format in ('AVI', 'QUICKTIME', 'MKV', 'OGG'):
309                         split.itemR(rd, "ffmpeg_codec")
310                 else:
311                         split.itemL()
312
313                 split = layout.split()
314         
315                 col = split.column()
316                 col.itemR(rd, "ffmpeg_video_bitrate")
317                 col.itemL(text="Rate:")
318                 col.itemR(rd, "ffmpeg_minrate", text="Minimum")
319                 col.itemR(rd, "ffmpeg_maxrate", text="Maximum")
320                 col.itemR(rd, "ffmpeg_buffersize", text="Buffer")
321                 
322                 col = split.column()
323                 col.itemR(rd, "ffmpeg_gopsize")
324                 col.itemR(rd, "ffmpeg_autosplit")
325                 col.itemL(text="Mux:")
326                 col.itemR(rd, "ffmpeg_muxrate", text="Rate")
327                 col.itemR(rd, "ffmpeg_packetsize", text="Packet Size")
328                 
329                 row = layout.row()
330                 row.itemL(text="Audio:")
331                 row = layout.row()
332                 row.itemR(rd, "ffmpeg_audio_codec")
333                 
334                 split = layout.split()
335
336                 col = split.column()
337                 col.itemR(rd, "ffmpeg_audio_bitrate")
338                 col.itemR(rd, "ffmpeg_audio_mixrate")
339                 col = split.column()
340                 col.itemR(rd, "ffmpeg_multiplex_audio")
341                 col.itemR(rd, "ffmpeg_audio_volume")
342
343 class SCENE_PT_antialiasing(RenderButtonsPanel):
344         __label__ = "Anti-Aliasing"
345         COMPAT_ENGINES = set(['BLENDER_RENDER'])
346
347         def draw_header(self, context):
348                 rd = context.scene.render_data
349
350                 self.layout.itemR(rd, "antialiasing", text="")
351
352         def draw(self, context):
353                 layout = self.layout
354                 
355                 rd = context.scene.render_data
356
357                 layout.active = rd.antialiasing
358
359                 split = layout.split()
360                 
361                 col = split.column()
362                 col.row().itemR(rd, "antialiasing_samples", expand=True)
363                 col.itemR(rd, "full_sample")
364
365                 col = split.column()
366                 col.itemR(rd, "pixel_filter", text="")
367                 col.itemR(rd, "filter_size", text="Size", slider=True)
368         
369 class SCENE_PT_dimensions(RenderButtonsPanel):
370         __label__ = "Dimensions"
371         COMPAT_ENGINES = set(['BLENDER_RENDER'])
372
373         def draw(self, context):
374                 layout = self.layout
375                 
376                 scene = context.scene
377                 rd = scene.render_data
378                 
379                 split = layout.split()
380                 
381                 col = split.column()
382                 sub = col.column(align=True)
383                 sub.itemL(text="Resolution:")
384                 sub.itemR(rd, "resolution_x", text="X")
385                 sub.itemR(rd, "resolution_y", text="Y")
386                 sub.itemR(rd, "resolution_percentage", text="")
387                 
388                 sub.itemL(text="Aspect Ratio:")
389                 sub.itemR(rd, "pixel_aspect_x", text="X")
390                 sub.itemR(rd, "pixel_aspect_y", text="Y")
391
392                 row = col.row()
393                 row.itemR(rd, "use_border", text="Border")
394                 rowsub = row.row()
395                 rowsub.active = rd.use_border
396                 rowsub.itemR(rd, "crop_to_border", text="Crop")
397                 
398                 col = split.column(align=True)
399                 col.itemL(text="Frame Range:")
400                 col.itemR(scene, "start_frame", text="Start")
401                 col.itemR(scene, "end_frame", text="End")
402                 col.itemR(scene, "frame_step", text="Step")
403                 
404                 col.itemL(text="Frame Rate:")
405                 col.itemR(rd, "fps")
406                 col.itemR(rd, "fps_base",text="/")
407
408 class SCENE_PT_stamp(RenderButtonsPanel):
409         __label__ = "Stamp"
410         __default_closed__ = True
411         COMPAT_ENGINES = set(['BLENDER_RENDER'])
412
413         def draw_header(self, context):
414                 rd = context.scene.render_data
415
416                 self.layout.itemR(rd, "render_stamp", text="")
417
418         def draw(self, context):
419                 layout = self.layout
420                 
421                 rd = context.scene.render_data
422
423                 layout.active = rd.render_stamp
424
425                 split = layout.split()
426                 
427                 col = split.column()
428                 col.itemR(rd, "stamp_time", text="Time")
429                 col.itemR(rd, "stamp_date", text="Date")
430                 col.itemR(rd, "stamp_frame", text="Frame")
431                 col.itemR(rd, "stamp_scene", text="Scene")
432                 col.itemR(rd, "stamp_camera", text="Camera")
433                 col.itemR(rd, "stamp_filename", text="Filename")
434                 col.itemR(rd, "stamp_marker", text="Marker")
435                 col.itemR(rd, "stamp_sequence_strip", text="Seq. Strip")
436
437                 col = split.column()
438                 col.active = rd.render_stamp
439                 col.itemR(rd, "stamp_foreground", slider=True)
440                 col.itemR(rd, "stamp_background", slider=True)
441                 col.itemR(rd, "stamp_font_size", text="Font Size")
442
443                 row = layout.split(percentage=0.2)
444                 row.itemR(rd, "stamp_note", text="Note")
445                 sub = row.row()
446                 sub.active = rd.stamp_note
447                 sub.itemR(rd, "stamp_note_text", text="")
448
449 class SCENE_PT_unit(RenderButtonsPanel):
450         __label__ = "Units"
451         __default_closed__ = True
452         COMPAT_ENGINES = set(['BLENDER_RENDER'])
453
454         def draw(self, context):
455                 layout = self.layout
456                 
457                 unit = context.scene.unit_settings
458                 
459                 col = layout.column()
460                 col.row().itemR(unit, "system", expand=True)
461                 
462                 row = layout.row()
463                 row.active = (unit.system != 'NONE')
464                 row.itemR(unit, "scale_length", text="Scale")
465                 row.itemR(unit, "use_separate")
466                 
467 class SCENE_PT_keying_sets(SceneButtonsPanel):
468         __label__ = "Keying Sets"
469         __default_closed__ = True
470         
471         def draw(self, context):
472                 layout = self.layout
473                 
474                 scene = context.scene
475                 
476                 row = layout.row()
477                 row.itemL(text="Keying Sets")
478                 
479                 row = layout.row()
480                 
481                 col = row.column()
482                 col.template_list(scene, "keying_sets", scene, "active_keying_set_index", rows=2)
483                 
484                 col = row.column(align=True)
485                 col.itemO("anim.keying_set_add", icon='ICON_ZOOMIN', text="")
486                 col.itemO("anim.keying_set_remove", icon='ICON_ZOOMOUT', text="")
487                 
488                 ks = scene.active_keying_set
489                 if ks:
490                         row = layout.row()
491                         
492                         col = row.column()
493                         col.itemR(ks, "name")
494                         col.itemR(ks, "absolute")
495                         
496                         col = row.column()
497                         col.itemL(text="Keyframing Settings:")
498                         col.itemR(ks, "insertkey_needed", text="Needed")
499                         col.itemR(ks, "insertkey_visual", text="Visual")
500                         
501 class SCENE_PT_keying_set_paths(SceneButtonsPanel):
502         __label__ = "Active Keying Set"
503         __default_closed__ = True
504         
505         def poll(self, context):
506                 return (context.scene != None) and (context.scene.active_keying_set != None)
507         
508         def draw(self, context):
509                 layout = self.layout
510                 
511                 scene = context.scene
512                 ks = scene.active_keying_set
513                 
514                 row = layout.row()
515                 row.itemL(text="Paths")
516                 
517                 row = layout.row()
518                 
519                 col = row.column()
520                 col.template_list(ks, "paths", ks, "active_path_index", rows=2)
521                 
522                 col = row.column(align=True)
523                 col.itemO("anim.keying_set_path_add", icon='ICON_ZOOMIN', text="")
524                 col.itemO("anim.keying_set_path_remove", icon='ICON_ZOOMOUT', text="")
525                 
526                 ksp = ks.active_path
527                 if ksp:
528                         col = layout.column()
529                         col.itemL(text="Target:")
530                         col.itemR(ksp, "id")
531                         col.itemR(ksp, "rna_path")
532                         
533                         
534                         row = layout.row()
535                         
536                         col = row.column()
537                         col.itemL(text="Array Target:")
538                         col.itemR(ksp, "entire_array")
539                         if ksp.entire_array == False:
540                                 col.itemR(ksp, "array_index")
541                                 
542                         col = row.column()
543                         col.itemL(text="F-Curve Grouping:")
544                         col.itemR(ksp, "grouping")
545                         if ksp.grouping == 'NAMED':
546                                 col.itemR(ksp, "group")
547                                 
548                         
549                         
550
551 class SCENE_PT_physics(RenderButtonsPanel):
552         __label__ = "Gravity"
553         COMPAT_ENGINES = set(['BLENDER_RENDER'])
554
555         def draw_header(self, context):
556                 self.layout.itemR(context.scene, "use_gravity", text="")
557
558         def draw(self, context):
559                 layout = self.layout
560                 
561                 scene = context.scene
562
563                 layout.active = scene.use_gravity
564
565                 layout.itemR(scene, "gravity", text="")
566
567                 
568 bpy.types.register(SCENE_PT_render)
569 bpy.types.register(SCENE_PT_layers)
570 bpy.types.register(SCENE_PT_dimensions)
571 bpy.types.register(SCENE_PT_antialiasing)
572 bpy.types.register(SCENE_PT_shading)
573 bpy.types.register(SCENE_PT_output)
574 bpy.types.register(SCENE_PT_encoding)
575 bpy.types.register(SCENE_PT_performance)
576 bpy.types.register(SCENE_PT_post_processing)
577 bpy.types.register(SCENE_PT_stamp)
578 bpy.types.register(SCENE_PT_unit)
579 bpy.types.register(SCENE_PT_keying_sets)
580 bpy.types.register(SCENE_PT_keying_set_paths)
581 bpy.types.register(SCENE_PT_physics)