Merging r45744 through r45747 from trunk into soc-2011-tomato
[blender.git] / intern / cycles / blender / addon / ui.py
1 #
2 # Copyright 2011, Blender Foundation.
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software Foundation,
16 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 #
18
19 # <pep8 compliant>
20
21 import bpy
22
23 from bpy.types import Panel, Menu
24
25 from . import enums, engine
26
27
28 class CYCLES_MT_integrator_presets(Menu):
29     bl_label = "Integrator Presets"
30     preset_subdir = "cycles/integrator"
31     preset_operator = "script.execute_preset"
32     COMPAT_ENGINES = {'CYCLES'}
33     draw = Menu.draw_preset
34
35
36 class CyclesButtonsPanel():
37     bl_space_type = "PROPERTIES"
38     bl_region_type = "WINDOW"
39     bl_context = "render"
40
41     @classmethod
42     def poll(cls, context):
43         rd = context.scene.render
44         return rd.engine == 'CYCLES'
45
46
47 class CyclesRender_PT_integrator(CyclesButtonsPanel, Panel):
48     bl_label = "Integrator"
49     bl_options = {'DEFAULT_CLOSED'}
50
51     def draw(self, context):
52         layout = self.layout
53
54         scene = context.scene
55         cscene = scene.cycles
56
57         row = layout.row(align=True)
58         row.menu("CYCLES_MT_integrator_presets", text=bpy.types.CYCLES_MT_integrator_presets.bl_label)
59         row.operator("render.cycles_integrator_preset_add", text="", icon="ZOOMIN")
60         row.operator("render.cycles_integrator_preset_add", text="", icon="ZOOMOUT").remove_active = True
61
62         split = layout.split()
63
64         col = split.column()
65         sub = col.column(align=True)
66         sub.label(text="Samples:")
67         sub.prop(cscene, "samples", text="Render")
68         sub.prop(cscene, "preview_samples", text="Preview")
69         sub.prop(cscene, "seed")
70         sub.prop(cscene, "sample_clamp")
71
72         sub = col.column(align=True)
73         sub.label("Transparency:")
74         sub.prop(cscene, "transparent_max_bounces", text="Max")
75         sub.prop(cscene, "transparent_min_bounces", text="Min")
76         sub.prop(cscene, "use_transparent_shadows", text="Shadows")
77
78         col = split.column()
79
80         sub = col.column(align=True)
81         sub.label(text="Bounces:")
82         sub.prop(cscene, "max_bounces", text="Max")
83         sub.prop(cscene, "min_bounces", text="Min")
84
85         sub = col.column(align=True)
86         sub.label(text="Light Paths:")
87         sub.prop(cscene, "diffuse_bounces", text="Diffuse")
88         sub.prop(cscene, "glossy_bounces", text="Glossy")
89         sub.prop(cscene, "transmission_bounces", text="Transmission")
90
91         col.separator()
92
93         col.prop(cscene, "no_caustics")
94         col.prop(cscene, "blur_glossy")
95
96
97 class CyclesRender_PT_film(CyclesButtonsPanel, Panel):
98     bl_label = "Film"
99
100     def draw(self, context):
101         layout = self.layout
102
103         scene = context.scene
104         cscene = scene.cycles
105
106         split = layout.split()
107
108         col = split.column()
109         col.prop(cscene, "film_exposure")
110         col.prop(cscene, "film_transparent")
111
112         col = split.column()
113         sub = col.column(align=True)
114         sub.prop(cscene, "filter_type", text="")
115         if cscene.filter_type != 'BOX':
116             sub.prop(cscene, "filter_width", text="Width")
117
118
119 class CyclesRender_PT_performance(CyclesButtonsPanel, Panel):
120     bl_label = "Performance"
121     bl_options = {'DEFAULT_CLOSED'}
122
123     def draw(self, context):
124         layout = self.layout
125
126         scene = context.scene
127         rd = scene.render
128         cscene = scene.cycles
129
130         split = layout.split()
131
132         col = split.column(align=True)
133
134         col.label(text="Threads:")
135         col.row().prop(rd, "threads_mode", expand=True)
136         sub = col.column()
137         sub.enabled = rd.threads_mode == 'FIXED'
138         sub.prop(rd, "threads")
139
140         sub = col.column(align=True)
141         sub.label(text="Tiles:")
142         sub.prop(cscene, "debug_tile_size")
143         sub.prop(cscene, "debug_min_size")
144
145         col = split.column()
146
147         sub = col.column(align=True)
148         sub.label(text="Acceleration structure:")
149         sub.prop(cscene, "debug_bvh_type", text="")
150         sub.prop(cscene, "debug_use_spatial_splits")
151         sub.prop(cscene, "use_cache")
152
153
154 class CyclesRender_PT_layers(CyclesButtonsPanel, Panel):
155     bl_label = "Layers"
156     bl_options = {'DEFAULT_CLOSED'}
157     COMPAT_ENGINES = {'BLENDER_RENDER'}
158
159     def draw(self, context):
160         layout = self.layout
161
162         scene = context.scene
163         rd = scene.render
164
165         row = layout.row()
166         row.template_list(rd, "layers", rd.layers, "active_index", rows=2)
167
168         col = row.column(align=True)
169         col.operator("scene.render_layer_add", icon='ZOOMIN', text="")
170         col.operator("scene.render_layer_remove", icon='ZOOMOUT', text="")
171
172         row = layout.row()
173         rl = rd.layers.active
174         row.prop(rl, "name")
175         row.prop(rd, "use_single_layer", text="", icon_only=True)
176
177         split = layout.split()
178
179         col = split.column()
180         col.prop(scene, "layers", text="Scene")
181         col.prop(rl, "layers_exclude", text="Exclude")
182
183         col = split.column()
184         col.prop(rl, "layers", text="Layer")
185         col.label(text="Mask Layers:")
186         col.prop(rl, "layers_zmask", text="")
187
188         split = layout.split()
189
190         col = split.column()
191         col.label(text="Material:")
192         col.prop(rl, "material_override", text="")
193
194         col = split.column()
195         col.prop(rl, "use_sky", "Use Environment")
196
197         split = layout.split()
198
199         col = split.column()
200         col.label(text="Passes:")
201         col.prop(rl, "use_pass_combined")
202         col.prop(rl, "use_pass_z")
203         col.prop(rl, "use_pass_normal")
204         col.prop(rl, "use_pass_object_index")
205         col.prop(rl, "use_pass_material_index")
206         col.prop(rl, "use_pass_emit")
207         col.prop(rl, "use_pass_environment")
208         col.prop(rl, "use_pass_ambient_occlusion")
209         col.prop(rl, "use_pass_shadow")
210
211         col = split.column()
212         col.label()
213         col.label(text="Diffuse:")
214         row = col.row(align=True)
215         row.prop(rl, "use_pass_diffuse_direct", text="Direct", toggle=True)
216         row.prop(rl, "use_pass_diffuse_indirect", text="Indirect", toggle=True)
217         row.prop(rl, "use_pass_diffuse_color", text="Color", toggle=True)
218         col.label(text="Glossy:")
219         row = col.row(align=True)
220         row.prop(rl, "use_pass_glossy_direct", text="Direct", toggle=True)
221         row.prop(rl, "use_pass_glossy_indirect", text="Indirect", toggle=True)
222         row.prop(rl, "use_pass_glossy_color", text="Color", toggle=True)
223         col.label(text="Transmission:")
224         row = col.row(align=True)
225         row.prop(rl, "use_pass_transmission_direct", text="Direct", toggle=True)
226         row.prop(rl, "use_pass_transmission_indirect", text="Indirect", toggle=True)
227         row.prop(rl, "use_pass_transmission_color", text="Color", toggle=True)
228
229
230 class Cycles_PT_post_processing(CyclesButtonsPanel, Panel):
231     bl_label = "Post Processing"
232     bl_options = {'DEFAULT_CLOSED'}
233
234     def draw(self, context):
235         layout = self.layout
236
237         rd = context.scene.render
238
239         split = layout.split()
240
241         col = split.column()
242         col.prop(rd, "use_compositing")
243         col.prop(rd, "use_sequencer")
244
245         col = split.column()
246         col.prop(rd, "dither_intensity", text="Dither", slider=True)
247
248
249 class CyclesCamera_PT_dof(CyclesButtonsPanel, Panel):
250     bl_label = "Depth of Field"
251     bl_context = "data"
252
253     @classmethod
254     def poll(cls, context):
255         return context.camera and CyclesButtonsPanel.poll(context)
256
257     def draw(self, context):
258         layout = self.layout
259
260         cam = context.camera
261         ccam = cam.cycles
262
263         split = layout.split()
264
265         col = split.column()
266         col.label("Focus:")
267         col.prop(cam, "dof_object", text="")
268
269         sub = col.row()
270         sub.active = cam.dof_object is None
271         sub.prop(cam, "dof_distance", text="Distance")
272
273         col = split.column()
274
275         col.label("Aperture:")
276         sub = col.column(align=True)
277         sub.prop(ccam, "aperture_type", text="")
278         if ccam.aperture_type == 'RADIUS':
279             sub.prop(ccam, "aperture_size", text="Size")
280         elif ccam.aperture_type == 'FSTOP':
281             sub.prop(ccam, "aperture_fstop", text="Number")
282
283         sub = col.column(align=True)
284         sub.prop(ccam, "aperture_blades", text="Blades")
285         sub.prop(ccam, "aperture_rotation", text="Rotation")
286
287
288 class Cycles_PT_context_material(CyclesButtonsPanel, Panel):
289     bl_label = ""
290     bl_context = "material"
291     bl_options = {'HIDE_HEADER'}
292
293     @classmethod
294     def poll(cls, context):
295         return (context.material or context.object) and CyclesButtonsPanel.poll(context)
296
297     def draw(self, context):
298         layout = self.layout
299
300         mat = context.material
301         ob = context.object
302         slot = context.material_slot
303         space = context.space_data
304
305         if ob:
306             row = layout.row()
307
308             row.template_list(ob, "material_slots", ob, "active_material_index", rows=2)
309
310             col = row.column(align=True)
311             col.operator("object.material_slot_add", icon='ZOOMIN', text="")
312             col.operator("object.material_slot_remove", icon='ZOOMOUT', text="")
313
314             col.menu("MATERIAL_MT_specials", icon='DOWNARROW_HLT', text="")
315
316             if ob.mode == 'EDIT':
317                 row = layout.row(align=True)
318                 row.operator("object.material_slot_assign", text="Assign")
319                 row.operator("object.material_slot_select", text="Select")
320                 row.operator("object.material_slot_deselect", text="Deselect")
321
322         split = layout.split(percentage=0.65)
323
324         if ob:
325             split.template_ID(ob, "active_material", new="material.new")
326             row = split.row()
327
328             if slot:
329                 row.prop(slot, "link", text="")
330             else:
331                 row.label()
332         elif mat:
333             split.template_ID(space, "pin_id")
334             split.separator()
335
336
337 class Cycles_PT_mesh_displacement(CyclesButtonsPanel, Panel):
338     bl_label = "Displacement"
339     bl_context = "data"
340
341     @classmethod
342     def poll(cls, context):
343         if CyclesButtonsPanel.poll(context):
344             if context.mesh or context.curve or context.meta_ball:
345                 if context.scene.cycles.feature_set == 'EXPERIMENTAL':
346                     return True
347
348         return False
349
350     def draw(self, context):
351         layout = self.layout
352
353         mesh = context.mesh
354         curve = context.curve
355         mball = context.meta_ball
356
357         if mesh:
358             cdata = mesh.cycles
359         elif curve:
360             cdata = curve.cycles
361         elif mball:
362             cdata = mball.cycles
363
364         layout.prop(cdata, "displacement_method", text="Method")
365         layout.prop(cdata, "use_subdivision")
366         layout.prop(cdata, "dicing_rate")
367
368
369 class CyclesObject_PT_ray_visibility(CyclesButtonsPanel, Panel):
370     bl_label = "Ray Visibility"
371     bl_context = "object"
372     bl_options = {'DEFAULT_CLOSED'}
373
374     @classmethod
375     def poll(cls, context):
376         ob = context.object
377         return CyclesButtonsPanel.poll(context) and ob and ob.type in {'MESH', 'CURVE', 'CURVE', 'SURFACE', 'FONT', 'META'}  # todo: 'LAMP'
378
379     def draw(self, context):
380         layout = self.layout
381
382         ob = context.object
383         visibility = ob.cycles_visibility
384
385         flow = layout.column_flow()
386
387         flow.prop(visibility, "camera")
388         flow.prop(visibility, "diffuse")
389         flow.prop(visibility, "glossy")
390         flow.prop(visibility, "transmission")
391         flow.prop(visibility, "shadow")
392
393
394 def find_node(material, nodetype):
395     if material and material.node_tree:
396         ntree = material.node_tree
397
398         for node in ntree.nodes:
399             if getattr(node, "type", None) == nodetype:
400                 return node
401
402     return None
403
404
405 def find_node_input(node, name):
406     for input in node.inputs:
407         if input.name == name:
408             return input
409
410     return None
411
412
413 def panel_node_draw(layout, id_data, output_type, input_name):
414     if not id_data.use_nodes:
415         layout.prop(id_data, "use_nodes", icon='NODETREE')
416         return False
417
418     ntree = id_data.node_tree
419
420     node = find_node(id_data, output_type)
421     if not node:
422         layout.label(text="No output node.")
423     else:
424         input = find_node_input(node, input_name)
425         layout.template_node_view(ntree, node, input)
426
427     return True
428
429
430 class CyclesLamp_PT_lamp(CyclesButtonsPanel, Panel):
431     bl_label = "Lamp"
432     bl_context = "data"
433
434     @classmethod
435     def poll(cls, context):
436         return context.lamp and CyclesButtonsPanel.poll(context)
437
438     def draw(self, context):
439         layout = self.layout
440
441         lamp = context.lamp
442         clamp = lamp.cycles
443
444         layout.prop(lamp, "type", expand=True)
445
446         split = layout.split()
447         col = split.column(align=True)
448
449         if lamp.type in {'POINT', 'SUN', 'SPOT'}:
450             col.prop(lamp, "shadow_soft_size", text="Size")
451         elif lamp.type == 'AREA':
452             col.prop(lamp, "shape", text="")
453             sub = col.column(align=True)
454
455             if lamp.shape == 'SQUARE':
456                 sub.prop(lamp, "size")
457             elif lamp.shape == 'RECTANGLE':
458                 sub.prop(lamp, "size", text="Size X")
459                 sub.prop(lamp, "size_y", text="Size Y")
460
461         col = split.column()
462         col.prop(clamp, "cast_shadow")
463
464         if lamp.type == 'SPOT':
465             layout.label(text="Not supported, interpreted as point lamp.")
466         elif lamp.type == 'HEMI':
467             layout.label(text="Not supported, interpreted as sun lamp.")
468
469
470 class CyclesLamp_PT_nodes(CyclesButtonsPanel, Panel):
471     bl_label = "Nodes"
472     bl_context = "data"
473
474     @classmethod
475     def poll(cls, context):
476         return context.lamp and CyclesButtonsPanel.poll(context)
477
478     def draw(self, context):
479         layout = self.layout
480
481         lamp = context.lamp
482         if not panel_node_draw(layout, lamp, 'OUTPUT_LAMP', 'Surface'):
483             layout.prop(lamp, "color")
484
485
486 class CyclesWorld_PT_surface(CyclesButtonsPanel, Panel):
487     bl_label = "Surface"
488     bl_context = "world"
489
490     @classmethod
491     def poll(cls, context):
492         return context.world and CyclesButtonsPanel.poll(context)
493
494     def draw(self, context):
495         layout = self.layout
496
497         world = context.world
498
499         if not panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Surface'):
500             layout.prop(world, "horizon_color", text="Color")
501
502
503 class CyclesWorld_PT_volume(CyclesButtonsPanel, Panel):
504     bl_label = "Volume"
505     bl_context = "world"
506     bl_options = {'DEFAULT_CLOSED'}
507
508     @classmethod
509     def poll(cls, context):
510         # world = context.world
511         # world and world.node_tree and CyclesButtonsPanel.poll(context)
512         return False
513
514     def draw(self, context):
515         layout = self.layout
516         layout.active = False
517
518         world = context.world
519         panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Volume')
520
521
522 class CyclesWorld_PT_ambient_occlusion(CyclesButtonsPanel, Panel):
523     bl_label = "Ambient Occlusion"
524     bl_context = "world"
525
526     @classmethod
527     def poll(cls, context):
528         return context.world and CyclesButtonsPanel.poll(context)
529
530     def draw_header(self, context):
531         light = context.world.light_settings
532         self.layout.prop(light, "use_ambient_occlusion", text="")
533
534     def draw(self, context):
535         layout = self.layout
536         light = context.world.light_settings
537
538         layout.active = light.use_ambient_occlusion
539
540         row = layout.row()
541         row.prop(light, "ao_factor", text="Factor")
542         row.prop(light, "distance", text="Distance")
543
544
545 class CyclesWorld_PT_settings(CyclesButtonsPanel, Panel):
546     bl_label = "Settings"
547     bl_context = "world"
548     bl_options = {'DEFAULT_CLOSED'}
549
550     @classmethod
551     def poll(cls, context):
552         return context.world and CyclesButtonsPanel.poll(context)
553
554     def draw(self, context):
555         layout = self.layout
556
557         world = context.world
558         cworld = world.cycles
559
560         col = layout.column()
561
562         col.prop(cworld, "sample_as_light")
563         row = col.row()
564         row.active = cworld.sample_as_light
565         row.prop(cworld, "sample_map_resolution")
566
567
568 class CyclesMaterial_PT_surface(CyclesButtonsPanel, Panel):
569     bl_label = "Surface"
570     bl_context = "material"
571
572     @classmethod
573     def poll(cls, context):
574         return context.material and CyclesButtonsPanel.poll(context)
575
576     def draw(self, context):
577         layout = self.layout
578
579         mat = context.material
580         if not panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Surface'):
581             layout.prop(mat, "diffuse_color")
582
583
584 class CyclesMaterial_PT_volume(CyclesButtonsPanel, Panel):
585     bl_label = "Volume"
586     bl_context = "material"
587     bl_options = {'DEFAULT_CLOSED'}
588
589     @classmethod
590     def poll(cls, context):
591         # mat = context.material
592         # mat and mat.node_tree and CyclesButtonsPanel.poll(context)
593         return False
594
595     def draw(self, context):
596         layout = self.layout
597         layout.active = False
598
599         mat = context.material
600         cmat = mat.cycles
601
602         panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Volume')
603
604         layout.prop(cmat, "homogeneous_volume")
605
606
607 class CyclesMaterial_PT_displacement(CyclesButtonsPanel, Panel):
608     bl_label = "Displacement"
609     bl_context = "material"
610
611     @classmethod
612     def poll(cls, context):
613         mat = context.material
614         return mat and mat.node_tree and CyclesButtonsPanel.poll(context)
615
616     def draw(self, context):
617         layout = self.layout
618
619         mat = context.material
620         panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Displacement')
621
622
623 class CyclesMaterial_PT_settings(CyclesButtonsPanel, Panel):
624     bl_label = "Settings"
625     bl_context = "material"
626     bl_options = {'DEFAULT_CLOSED'}
627
628     @classmethod
629     def poll(cls, context):
630         return context.material and CyclesButtonsPanel.poll(context)
631
632     def draw(self, context):
633         layout = self.layout
634
635         mat = context.material
636         cmat = mat.cycles
637
638         split = layout.split()
639
640         col = split.column()
641         col.prop(mat, "diffuse_color", text="Viewport Color")
642
643         col = split.column()
644         col.prop(cmat, "sample_as_light")
645         col.prop(mat, "pass_index")
646
647
648 class CyclesTexture_PT_context(CyclesButtonsPanel, Panel):
649     bl_label = ""
650     bl_context = "texture"
651     bl_options = {'HIDE_HEADER'}
652     COMPAT_ENGINES = {'CYCLES'}
653
654     def draw(self, context):
655         layout = self.layout
656
657         tex = context.texture
658         space = context.space_data
659         pin_id = space.pin_id
660         use_pin_id = space.use_pin_id
661         user = context.texture_user
662
663         if not use_pin_id or not isinstance(pin_id, bpy.types.Texture):
664             pin_id = None
665
666         if not pin_id:
667             layout.template_texture_user()
668
669         if user:
670             layout.separator()
671
672             split = layout.split(percentage=0.65)
673             col = split.column()
674
675             if pin_id:
676                 col.template_ID(space, "pin_id")
677             elif user:
678                 col.template_ID(user, "texture", new="texture.new")
679
680             if tex:
681                 split = layout.split(percentage=0.2)
682                 split.label(text="Type:")
683                 split.prop(tex, "type", text="")
684
685
686 class CyclesTexture_PT_nodes(CyclesButtonsPanel, Panel):
687     bl_label = "Nodes"
688     bl_context = "texture"
689
690     @classmethod
691     def poll(cls, context):
692         tex = context.texture
693         return (tex and tex.use_nodes) and CyclesButtonsPanel.poll(context)
694
695     def draw(self, context):
696         layout = self.layout
697
698         tex = context.texture
699         panel_node_draw(layout, tex, 'OUTPUT_TEXTURE', 'Color')
700
701
702 class CyclesTexture_PT_node(CyclesButtonsPanel, Panel):
703     bl_label = "Node"
704     bl_context = "texture"
705
706     @classmethod
707     def poll(cls, context):
708         node = context.texture_node
709         return node and CyclesButtonsPanel.poll(context)
710
711     def draw(self, context):
712         layout = self.layout
713
714         node = context.texture_node
715         ntree = node.id_data
716         layout.template_node_view(ntree, node, None)
717
718
719 class CyclesTexture_PT_mapping(CyclesButtonsPanel, Panel):
720     bl_label = "Mapping"
721     bl_context = "texture"
722
723     @classmethod
724     def poll(cls, context):
725         tex = context.texture
726         node = context.texture_node
727         return (node or (tex and tex.use_nodes)) and CyclesButtonsPanel.poll(context)
728
729     def draw(self, context):
730         layout = self.layout
731
732         # tex = context.texture
733         node = context.texture_node
734
735         mapping = node.texture_mapping
736
737         row = layout.row()
738
739         row.column().prop(mapping, "translation")
740         row.column().prop(mapping, "rotation")
741         row.column().prop(mapping, "scale")
742
743         layout.label(text="Projection:")
744
745         row = layout.row()
746         row.prop(mapping, "mapping_x", text="")
747         row.prop(mapping, "mapping_y", text="")
748         row.prop(mapping, "mapping_z", text="")
749
750
751 class CyclesTexture_PT_colors(CyclesButtonsPanel, Panel):
752     bl_label = "Color"
753     bl_context = "texture"
754     bl_options = {'DEFAULT_CLOSED'}
755
756     @classmethod
757     def poll(cls, context):
758         # tex = context.texture
759         # node = context.texture_node
760         return False
761         #return (node or (tex and tex.use_nodes)) and CyclesButtonsPanel.poll(context)
762
763     def draw(self, context):
764         layout = self.layout
765
766         # tex = context.texture
767         node = context.texture_node
768
769         mapping = node.color_mapping
770
771         split = layout.split()
772
773         col = split.column()
774         col.label(text="Blend:")
775         col.prop(mapping, "blend_type", text="")
776         col.prop(mapping, "blend_factor", text="Factor")
777         col.prop(mapping, "blend_color", text="")
778
779         col = split.column()
780         col.label(text="Adjust:")
781         col.prop(mapping, "brightness")
782         col.prop(mapping, "contrast")
783         col.prop(mapping, "saturation")
784
785         layout.separator()
786
787         layout.prop(mapping, "use_color_ramp", text="Ramp")
788         if mapping.use_color_ramp:
789             layout.template_color_ramp(mapping, "color_ramp", expand=True)
790
791
792 def draw_device(self, context):
793     scene = context.scene
794     layout = self.layout
795
796     if scene.render.engine == 'CYCLES':
797         cscene = scene.cycles
798
799         layout.prop(cscene, "feature_set")
800
801         device_type = context.user_preferences.system.compute_device_type
802         if device_type == 'CUDA':
803             layout.prop(cscene, "device")
804         elif device_type == 'OPENCL' and cscene.feature_set == 'EXPERIMENTAL':
805             layout.prop(cscene, "device")
806
807
808 def draw_pause(self, context):
809     layout = self.layout
810     scene = context.scene
811
812     if scene.render.engine == "CYCLES":
813         view = context.space_data
814
815         if view.viewport_shade == 'RENDERED':
816             cscene = scene.cycles
817             layername = scene.render.layers.active.name
818             layout.prop(cscene, "preview_pause", icon="PAUSE", text="")
819             layout.prop(cscene, "preview_active_layer", icon="RENDERLAYERS", text=layername)
820
821
822 def get_panels():
823     return (
824         bpy.types.RENDER_PT_render,
825         bpy.types.RENDER_PT_output,
826         bpy.types.RENDER_PT_encoding,
827         bpy.types.RENDER_PT_dimensions,
828         bpy.types.RENDER_PT_stamp,
829         bpy.types.SCENE_PT_scene,
830         bpy.types.SCENE_PT_audio,
831         bpy.types.SCENE_PT_unit,
832         bpy.types.SCENE_PT_keying_sets,
833         bpy.types.SCENE_PT_keying_set_paths,
834         bpy.types.SCENE_PT_physics,
835         bpy.types.WORLD_PT_context_world,
836         bpy.types.DATA_PT_context_mesh,
837         bpy.types.DATA_PT_context_camera,
838         bpy.types.DATA_PT_context_lamp,
839         bpy.types.DATA_PT_texture_space,
840         bpy.types.DATA_PT_curve_texture_space,
841         bpy.types.DATA_PT_mball_texture_space,
842         bpy.types.DATA_PT_vertex_groups,
843         bpy.types.DATA_PT_shape_keys,
844         bpy.types.DATA_PT_uv_texture,
845         bpy.types.DATA_PT_vertex_colors,
846         bpy.types.DATA_PT_camera,
847         bpy.types.DATA_PT_camera_display,
848         bpy.types.DATA_PT_lens,
849         bpy.types.DATA_PT_custom_props_mesh,
850         bpy.types.DATA_PT_custom_props_camera,
851         bpy.types.DATA_PT_custom_props_lamp,
852         bpy.types.TEXTURE_PT_clouds,
853         bpy.types.TEXTURE_PT_wood,
854         bpy.types.TEXTURE_PT_marble,
855         bpy.types.TEXTURE_PT_magic,
856         bpy.types.TEXTURE_PT_blend,
857         bpy.types.TEXTURE_PT_stucci,
858         bpy.types.TEXTURE_PT_image,
859         bpy.types.TEXTURE_PT_image_sampling,
860         bpy.types.TEXTURE_PT_image_mapping,
861         bpy.types.TEXTURE_PT_musgrave,
862         bpy.types.TEXTURE_PT_voronoi,
863         bpy.types.TEXTURE_PT_distortednoise,
864         bpy.types.TEXTURE_PT_voxeldata,
865         bpy.types.TEXTURE_PT_pointdensity,
866         bpy.types.TEXTURE_PT_pointdensity_turbulence,
867         bpy.types.PARTICLE_PT_context_particles,
868         bpy.types.PARTICLE_PT_emission,
869         bpy.types.PARTICLE_PT_hair_dynamics,
870         bpy.types.PARTICLE_PT_cache,
871         bpy.types.PARTICLE_PT_velocity,
872         bpy.types.PARTICLE_PT_rotation,
873         bpy.types.PARTICLE_PT_physics,
874         bpy.types.PARTICLE_PT_boidbrain,
875         bpy.types.PARTICLE_PT_render,
876         bpy.types.PARTICLE_PT_draw,
877         bpy.types.PARTICLE_PT_children,
878         bpy.types.PARTICLE_PT_field_weights,
879         bpy.types.PARTICLE_PT_force_fields,
880         bpy.types.PARTICLE_PT_vertexgroups,
881         bpy.types.PARTICLE_PT_custom_props,
882         )
883
884
885 def register():
886     bpy.types.RENDER_PT_render.append(draw_device)
887     bpy.types.VIEW3D_HT_header.append(draw_pause)
888
889     for panel in get_panels():
890         panel.COMPAT_ENGINES.add('CYCLES')
891
892
893 def unregister():
894     bpy.types.RENDER_PT_render.remove(draw_device)
895     bpy.types.VIEW3D_HT_header.remove(draw_pause)
896
897     for panel in get_panels():
898         panel.COMPAT_ENGINES.remove('CYCLES')