Merge branch 'master' into soc-2018-npr
[blender.git] / release / scripts / startup / bl_ui / properties_scene.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
21 import bpy
22 from bpy.types import (
23     Panel,
24     UIList,
25 )
26
27 from rna_prop_ui import PropertyPanel
28
29 from .properties_physics_common import (
30     point_cache_ui,
31     effector_weights_ui,
32 )
33
34
35 class SCENE_UL_keying_set_paths(UIList):
36     def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
37         # assert(isinstance(item, bpy.types.KeyingSetPath)
38         kspath = item
39         icon = layout.enum_item_icon(kspath, "id_type", kspath.id_type)
40         if self.layout_type in {'DEFAULT', 'COMPACT'}:
41             # Do not make this one editable in uiList for now...
42             layout.label(text=kspath.data_path, translate=False, icon_value=icon)
43         elif self.layout_type == 'GRID':
44             layout.alignment = 'CENTER'
45             layout.label(text="", icon_value=icon)
46
47
48 class SceneButtonsPanel:
49     bl_space_type = 'PROPERTIES'
50     bl_region_type = 'WINDOW'
51     bl_context = "scene"
52
53
54 class SCENE_PT_scene(SceneButtonsPanel, Panel):
55     bl_label = "Scene"
56
57     def draw(self, context):
58         layout = self.layout
59         layout.use_property_split = True
60         layout.use_property_decorate = False
61
62         scene = context.scene
63
64         layout.prop(scene, "camera")
65         layout.prop(scene, "background_set")
66         layout.prop(scene, "active_clip")
67
68
69 class SCENE_PT_unit(SceneButtonsPanel, Panel):
70     bl_label = "Units"
71     bl_options = {'DEFAULT_CLOSED'}
72
73     def draw(self, context):
74         layout = self.layout
75
76         unit = context.scene.unit_settings
77
78         layout.use_property_split = True
79         layout.use_property_decorate = False
80
81         layout.prop(unit, "system")
82
83         col = layout.column()
84         col.enabled = unit.system != 'NONE'
85         col.prop(unit, "scale_length")
86         col.prop(unit, "use_separate")
87
88         col = layout.column()
89         col.prop(unit, "system_rotation", text="Rotation")
90         subcol = col.column()
91         subcol.enabled = unit.system != 'NONE'
92         subcol.prop(unit, "length_unit", text="Length")
93         subcol.prop(unit, "mass_unit", text="Mass")
94         subcol.prop(unit, "time_unit", text="Time")
95
96
97 class SceneKeyingSetsPanel:
98
99     @staticmethod
100     def draw_keyframing_settings(context, layout, ks, ksp):
101         SceneKeyingSetsPanel._draw_keyframing_setting(
102             context, layout, ks, ksp, "Needed",
103             "use_insertkey_override_needed", "use_insertkey_needed",
104             userpref_fallback="use_keyframe_insert_needed",
105         )
106         SceneKeyingSetsPanel._draw_keyframing_setting(
107             context, layout, ks, ksp, "Visual",
108             "use_insertkey_override_visual", "use_insertkey_visual",
109             userpref_fallback="use_visual_keying",
110         )
111         SceneKeyingSetsPanel._draw_keyframing_setting(
112             context, layout, ks, ksp, "XYZ to RGB",
113             "use_insertkey_override_xyz_to_rgb", "use_insertkey_xyz_to_rgb",
114         )
115
116     @staticmethod
117     def _draw_keyframing_setting(context, layout, ks, ksp, label, toggle_prop, prop, userpref_fallback=None):
118         if ksp:
119             item = ksp
120
121             if getattr(ks, toggle_prop):
122                 owner = ks
123                 propname = prop
124             else:
125                 owner = context.preferences.edit
126                 if userpref_fallback:
127                     propname = userpref_fallback
128                 else:
129                     propname = prop
130         else:
131             item = ks
132
133             owner = context.preferences.edit
134             if userpref_fallback:
135                 propname = userpref_fallback
136             else:
137                 propname = prop
138
139         row = layout.row(align=True)
140
141         subrow = row.row(align=True)
142         subrow.active = getattr(item, toggle_prop)
143
144         if subrow.active:
145             subrow.prop(item, prop, text=label)
146         else:
147             subrow.prop(owner, propname, text=label)
148
149         row.prop(item, toggle_prop, text="", icon='STYLUS_PRESSURE', toggle=True)  # XXX: needs dedicated icon
150
151
152 class SCENE_PT_keying_sets(SceneButtonsPanel, SceneKeyingSetsPanel, Panel):
153     bl_label = "Keying Sets"
154     bl_options = {'DEFAULT_CLOSED'}
155
156     def draw(self, context):
157         layout = self.layout
158
159         scene = context.scene
160
161         row = layout.row()
162
163         col = row.column()
164         col.template_list("UI_UL_list", "keying_sets", scene, "keying_sets", scene.keying_sets, "active_index", rows=1)
165
166         col = row.column(align=True)
167         col.operator("anim.keying_set_add", icon='ZOOMIN', text="")
168         col.operator("anim.keying_set_remove", icon='ZOOMOUT', text="")
169
170         layout.use_property_split = True
171         layout.use_property_decorate = False  # No animation.
172
173         flow = layout.grid_flow(row_major=False, columns=0, even_columns=False, even_rows=False, align=False)
174
175         ks = scene.keying_sets.active
176         if ks and ks.is_path_absolute:
177             col = flow.column()
178             col.prop(ks, "bl_description")
179
180             subcol = flow.column()
181             subcol.operator_context = 'INVOKE_DEFAULT'
182             subcol.operator("anim.keying_set_export", text="Export to File").filepath = "keyingset.py"
183
184
185 class SCENE_PT_keyframing_settings(SceneButtonsPanel, SceneKeyingSetsPanel, Panel):
186     bl_label = "Keyframing Settings"
187     bl_parent_id = "SCENE_PT_keying_sets"
188
189     @classmethod
190     def poll(cls, context):
191         ks = context.scene.keying_sets.active
192         return (ks and ks.is_path_absolute)
193
194     def draw(self, context):
195         layout = self.layout
196         layout.use_property_split = True
197         layout.use_property_decorate = False  # No animation.
198
199         scene = context.scene
200         ks = scene.keying_sets.active
201
202         flow = layout.grid_flow(row_major=True, columns=0, even_columns=False, even_rows=False, align=True)
203
204         col = flow.column(align=True)
205         col.alignment = 'RIGHT'
206         col.label(text="General Override")
207
208         self.draw_keyframing_settings(context, col, ks, None)
209
210         ksp = ks.paths.active
211         if ksp:
212             col.separator()
213
214             col = flow.column(align=True)
215             col.alignment = 'RIGHT'
216             col.label(text="Active Set Override")
217
218             self.draw_keyframing_settings(context, col, ks, ksp)
219
220
221 class SCENE_PT_keying_set_paths(SceneButtonsPanel, SceneKeyingSetsPanel, Panel):
222     bl_label = "Active Keying Set"
223     bl_parent_id = "SCENE_PT_keying_sets"
224
225     @classmethod
226     def poll(cls, context):
227         ks = context.scene.keying_sets.active
228         return (ks and ks.is_path_absolute)
229
230     def draw(self, context):
231         layout = self.layout
232
233         scene = context.scene
234         ks = scene.keying_sets.active
235
236         row = layout.row()
237         row.label(text="Paths:")
238
239         row = layout.row()
240
241         col = row.column()
242         col.template_list("SCENE_UL_keying_set_paths", "", ks, "paths", ks.paths, "active_index", rows=1)
243
244         col = row.column(align=True)
245         col.operator("anim.keying_set_path_add", icon='ZOOMIN', text="")
246         col.operator("anim.keying_set_path_remove", icon='ZOOMOUT', text="")
247
248         # TODO: 1) the template_any_ID needs to be fixed for the text alignment.
249         #       2) use_property_decorate has to properly skip the non animatable properties.
250         #          Properties affected with needless draw:
251         #          group_method, template_any_ID dropdown, use_entire_array
252
253         layout.use_property_split = True
254         layout.use_property_decorate = False  # No animation (remove this later on).
255
256         flow = layout.grid_flow(row_major=False, columns=0, even_columns=False, even_rows=False, align=True)
257
258         ksp = ks.paths.active
259         if ksp:
260             col = flow.column(align=True)
261             col.alignment = 'RIGHT'
262
263             col.template_any_ID(ksp, "id", "id_type", text="Target ID-Block")
264
265             col.separator()
266
267             col.template_path_builder(ksp, "data_path", ksp.id, text="Data Path")
268
269             col = flow.column()
270
271             col.prop(ksp, "use_entire_array", text="Array All Items")
272
273             if not ksp.use_entire_array:
274                 col.prop(ksp, "array_index", text="Index")
275
276             col.separator()
277
278             col.prop(ksp, "group_method", text="F-Curve Grouping")
279             if ksp.group_method == 'NAMED':
280                 col.prop(ksp, "group")
281
282
283 class SCENE_PT_color_management(SceneButtonsPanel, Panel):
284     bl_label = "Color Management"
285     bl_options = {'DEFAULT_CLOSED'}
286     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL', 'BLENDER_LANPR'}
287
288     def draw(self, context):
289         layout = self.layout
290         layout.use_property_split = True
291
292         scene = context.scene
293         view = scene.view_settings
294
295         flow = layout.grid_flow(row_major=True, columns=0, even_columns=False, even_rows=False, align=True)
296
297         col = flow.column()
298         col.prop(scene.display_settings, "display_device")
299
300         col.separator()
301
302         col.prop(view, "view_transform")
303         col.prop(view, "look")
304
305         col = flow.column()
306         col.prop(view, "exposure")
307         col.prop(view, "gamma")
308
309         col.separator()
310
311         col.prop(scene.sequencer_colorspace_settings, "name", text="Sequencer")
312
313
314 class SCENE_PT_color_management_curves(SceneButtonsPanel, Panel):
315     bl_label = "Use Curves"
316     bl_parent_id = "SCENE_PT_color_management"
317     bl_options = {'DEFAULT_CLOSED'}
318     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL', 'BLENDER_LANPR'}
319
320     def draw_header(self, context):
321
322         scene = context.scene
323         view = scene.view_settings
324
325         self.layout.prop(view, "use_curve_mapping", text="")
326
327     def draw(self, context):
328         layout = self.layout
329
330         scene = context.scene
331         view = scene.view_settings
332
333         layout.use_property_split = False
334         layout.enabled = view.use_curve_mapping
335
336         layout.template_curve_mapping(view, "curve_mapping", levels=True)
337
338
339 class SCENE_PT_audio(SceneButtonsPanel, Panel):
340     bl_label = "Audio"
341     bl_options = {'DEFAULT_CLOSED'}
342
343     def draw(self, context):
344         layout = self.layout
345         layout.use_property_split = True
346
347         scene = context.scene
348         rd = context.scene.render
349         ffmpeg = rd.ffmpeg
350
351         flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
352
353         col = flow.column()
354         col.prop(scene, "audio_volume")
355
356         col.separator()
357
358         col.prop(scene, "audio_distance_model")
359         col.prop(ffmpeg, "audio_channels")
360
361         col.separator()
362
363         col = flow.column()
364         col.prop(ffmpeg, "audio_mixrate", text="Sample Rate")
365
366         col.separator()
367
368         col = col.column(align=True)
369         col.prop(scene, "audio_doppler_speed", text="Doppler Speed")
370         col.prop(scene, "audio_doppler_factor", text="Doppler Factor")
371
372         col.separator()
373
374         layout.operator("sound.bake_animation")
375
376
377 class SCENE_PT_physics(SceneButtonsPanel, Panel):
378     bl_label = "Gravity"
379     bl_options = {'DEFAULT_CLOSED'}
380
381     def draw_header(self, context):
382         self.layout.prop(context.scene, "use_gravity", text="")
383
384     def draw(self, context):
385         layout = self.layout
386         layout.use_property_split = True
387
388         scene = context.scene
389
390         layout.active = scene.use_gravity
391
392         layout.prop(scene, "gravity")
393
394
395 class SCENE_PT_rigid_body_world(SceneButtonsPanel, Panel):
396     bl_label = "Rigid Body World"
397     bl_options = {'DEFAULT_CLOSED'}
398
399     def draw_header(self, context):
400         scene = context.scene
401         rbw = scene.rigidbody_world
402         if rbw is not None:
403             self.layout.prop(rbw, "enabled", text="")
404
405     def draw(self, context):
406         layout = self.layout
407         layout.use_property_split = True
408
409         scene = context.scene
410         rbw = scene.rigidbody_world
411
412         if rbw is None:
413             layout.operator("rigidbody.world_add")
414         else:
415             layout.operator("rigidbody.world_remove")
416
417
418 class RigidBodySubPanel(SceneButtonsPanel):
419     bl_parent_id = "SCENE_PT_rigid_body_world"
420
421     @classmethod
422     def poll(cls, context):
423         scene = context.scene
424         return scene and scene.rigidbody_world
425
426
427 class SCENE_PT_rigid_body_world_settings(RigidBodySubPanel, Panel):
428     bl_label = "Settings"
429
430     def draw(self, context):
431         layout = self.layout
432         layout.use_property_split = True
433
434         scene = context.scene
435         rbw = scene.rigidbody_world
436
437         if rbw:
438             flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
439
440             col = flow.column()
441             col.active = rbw.enabled
442
443             col = col.column()
444             col.prop(rbw, "collection")
445             col.prop(rbw, "constraints")
446
447             col = col.column()
448             col.prop(rbw, "time_scale", text="Speed")
449
450             col = flow.column()
451             col.active = rbw.enabled
452             col.prop(rbw, "use_split_impulse")
453
454             col = col.column()
455             col.prop(rbw, "steps_per_second", text="Steps Per Second")
456             col.prop(rbw, "solver_iterations", text="Solver Iterations")
457
458
459 class SCENE_PT_rigid_body_cache(RigidBodySubPanel, Panel):
460     bl_label = "Cache"
461     bl_options = {'DEFAULT_CLOSED'}
462
463     def draw(self, context):
464         scene = context.scene
465         rbw = scene.rigidbody_world
466
467         point_cache_ui(self, context, rbw.point_cache, rbw.point_cache.is_baked is False and rbw.enabled, 'RIGID_BODY')
468
469
470 class SCENE_PT_rigid_body_field_weights(RigidBodySubPanel, Panel):
471     bl_label = "Field Weights"
472     bl_parent_id = "SCENE_PT_rigid_body_world"
473     bl_options = {'DEFAULT_CLOSED'}
474
475     def draw(self, context):
476         scene = context.scene
477         rbw = scene.rigidbody_world
478
479         effector_weights_ui(self, context, rbw.effector_weights, 'RIGID_BODY')
480
481
482 class SCENE_PT_simplify(SceneButtonsPanel, Panel):
483     bl_label = "Simplify"
484     bl_options = {'DEFAULT_CLOSED'}
485     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL', 'BLENDER_LANPR'}
486
487     def draw_header(self, context):
488         rd = context.scene.render
489         self.layout.prop(rd, "use_simplify", text="")
490
491     def draw(self, context):
492         pass
493
494
495 class SCENE_PT_simplify_viewport(SceneButtonsPanel, Panel):
496     bl_label = "Viewport"
497     bl_parent_id = "SCENE_PT_simplify"
498     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL', 'BLENDER_LANPR'}
499
500     def draw(self, context):
501         layout = self.layout
502         layout.use_property_split = True
503
504         rd = context.scene.render
505
506         layout.active = rd.use_simplify
507
508         flow = layout.grid_flow(row_major=True, columns=0, even_columns=False, even_rows=False, align=True)
509
510         col = flow.column()
511         col.prop(rd, "simplify_subdivision", text="Max Subdivision")
512
513         col = flow.column()
514         col.prop(rd, "simplify_child_particles", text="Max Child Particles")
515
516
517 class SCENE_PT_simplify_render(SceneButtonsPanel, Panel):
518     bl_label = "Render"
519     bl_parent_id = "SCENE_PT_simplify"
520     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL', 'BLENDER_LANPR'}
521
522     def draw(self, context):
523         layout = self.layout
524         layout.use_property_split = True
525
526         rd = context.scene.render
527
528         layout.active = rd.use_simplify
529
530         flow = layout.grid_flow(row_major=True, columns=0, even_columns=False, even_rows=False, align=True)
531
532         col = flow.column()
533         col.prop(rd, "simplify_subdivision_render", text="Max Subdivision")
534
535         col = flow.column()
536         col.prop(rd, "simplify_child_particles_render", text="Max Child Particles")
537
538
539 class SCENE_PT_simplify_greasepencil(SceneButtonsPanel, Panel):
540     bl_label = "Grease Pencil"
541     bl_parent_id = "SCENE_PT_simplify"
542     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
543     bl_options = {'DEFAULT_CLOSED'}
544
545     def draw_header(self, context):
546         rd = context.scene.render
547         self.layout.prop(rd, "simplify_gpencil", text="")
548
549     def draw(self, context):
550         layout = self.layout
551         layout.use_property_split = True
552
553         rd = context.scene.render
554
555         layout.active = rd.simplify_gpencil
556
557         col = layout.column()
558         col.prop(rd, "simplify_gpencil_onplay", text="Playback Only")
559         col.prop(rd, "simplify_gpencil_view_modifier", text="Modifiers")
560         col.prop(rd, "simplify_gpencil_shader_fx", text="ShaderFX")
561
562         col = layout.column(align=True)
563         col.prop(rd, "simplify_gpencil_view_fill")
564         sub = col.column()
565         sub.active = rd.simplify_gpencil_view_fill
566         sub.prop(rd, "simplify_gpencil_remove_lines", text="Lines")
567
568 class SCENE_PT_viewport_display(SceneButtonsPanel, Panel):
569     bl_label = "Viewport Display"
570     bl_options = {'DEFAULT_CLOSED'}
571
572     @classmethod
573     def poll(cls, context):
574         return True
575
576     def draw(self, context):
577         layout = self.layout
578         layout.use_property_split = True
579         scene = context.scene
580         col = layout.column()
581         col.prop(scene.display, "light_direction")
582         col.prop(scene.display, "shadow_shift")
583
584 class LANPR_linesets(UIList):
585     def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
586         lineset = item
587         if self.layout_type in {'DEFAULT', 'COMPACT'}:
588             split = layout.split(factor=0.6)
589             split.label(text="Layer")
590             row = split.row(align=True)
591             row.prop(lineset, "color", text="", icon_value=icon)
592             row.prop(lineset, "thickness", text="", icon_value=icon)
593         elif self.layout_type == 'GRID':
594             layout.alignment = 'CENTER'
595             layout.label("", icon_value=icon)
596
597 def lanpr_get_composition_scene(scene):
598     n = scene.name+'_lanpr_comp'
599     for s in bpy.data.scenes:
600         if s.name == n: return s
601     return None
602
603 def lanpr_is_composition_scene(scene):
604     return scene.name.endswith('_lanpr_comp')
605
606 class SCENE_PT_lanpr(SceneButtonsPanel, Panel):
607     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_LANPR', 'BLENDER_OPENGL', 'BLENDER_EEVEE'}
608     bl_label = "LANPR"
609     bl_options = {'DEFAULT_CLOSED'}
610     
611     @classmethod
612     def poll(cls, context):
613         return True
614
615     def draw(self, context):
616         layout = self.layout
617         scene = context.scene
618         lanpr = scene.lanpr
619         active_layer = lanpr.layers.active_layer 
620         
621         sc = lanpr_get_composition_scene(scene)
622         
623         if sc is not None:
624             layout.label(text = 'You are adjusting values for LANPR compostion scene.')
625             row = layout.row()
626             row.scale_y=1.5
627             row.operator("lanpr.goto_composition_scene")
628             layout.operator("lanpr.remove_composition_scene")
629             scene = sc
630             lanpr = scene.lanpr
631             active_layer = lanpr.layers.active_layer
632             return
633         elif scene.render.engine!='BLENDER_LANPR':
634             layout.label(text = 'Select LANPR engine or use composition scene.')
635             layout.operator("lanpr.make_composition_scene")
636             return
637
638         if lanpr_is_composition_scene(scene):
639             row = layout.row()
640             row.scale_y=1.5
641             row.operator("lanpr.goto_original_scene") 
642             
643             layout.label(text='LANPR Composition')
644             row = layout.row()
645             row.scale_y=1.5
646             row.scale_x=4
647             row.operator("lanpr.render_composited", icon = 'RENDER_STILL')
648             row.scale_x=1
649             row.prop(lanpr,"composite_render_animation", toggle=True, icon = 'RENDER_ANIMATION')
650         
651         layout.label(text='Mode:')
652         
653         layout.prop(lanpr, "master_mode", expand=True) 
654
655         if lanpr.master_mode == "DPIX" or lanpr.master_mode == "SOFTWARE":
656             
657             layout.prop(lanpr, "background_color")
658
659             if lanpr.master_mode == "SOFTWARE":
660                 layout.label(text="Enable On Demand:")
661                 row = layout.row()
662                 row.prop(lanpr,"enable_intersections", text = "Intersection Lines")
663                 row.prop(lanpr,"enable_chaining", text = "Chaining (SLOW!)")
664                 layout.label(text="RUN:")
665                 layout.operator("scene.lanpr_calculate", icon='RENDER_STILL')
666
667                 split = layout.split(factor=0.7)
668                 col = split.column()
669                 col.label(text="Layer Composition:")
670                 col = split.column()
671                 col.operator("scene.lanpr_auto_create_line_layer", text = "Default")#, icon = "ZOOMIN")
672                 layout.template_list("LANPR_linesets", "", lanpr, "layers", lanpr.layers, "active_layer_index", rows=4)
673                 if active_layer:
674                     split = layout.split()
675                     col = split.column()
676                     col.operator("scene.lanpr_add_line_layer")#icon="ZOOMIN")
677                     col.operator("scene.lanpr_delete_line_layer")#, icon="ZOOMOUT")
678                     col = split.column()
679                     col.operator("scene.lanpr_move_line_layer").direction = "UP"
680                     col.operator("scene.lanpr_move_line_layer").direction = "DOWN"
681                     layout.operator("scene.lanpr_rebuild_all_commands")
682                 else:
683                     layout.operator("scene.lanpr_add_line_layer")
684             
685             if active_layer:
686                 layout.label(text= "Normal:")
687                 layout.prop(active_layer,"normal_mode", expand = True)
688                 if active_layer.normal_mode != "DISABLED":
689                     layout.prop(active_layer,"normal_control_object")
690                     layout.prop(active_layer,"normal_effect_inverse", toggle = True)
691                     layout.prop(active_layer,"normal_ramp_begin")
692                     layout.prop(active_layer,"normal_ramp_end")
693                     layout.prop(active_layer,"normal_thickness_begin", slider=True)
694                     layout.prop(active_layer,"normal_thickness_end", slider=True)
695             
696         else:
697             layout.label(text="Vectorization:")
698             layout.prop(lanpr, "enable_vector_trace", expand = True)
699
700
701 class SCENE_PT_lanpr_line_types(SceneButtonsPanel, Panel):
702     bl_label = "Types"
703     bl_parent_id = "SCENE_PT_lanpr"
704     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_LANPR', 'BLENDER_OPENGL'}
705
706     @classmethod
707     def poll(cls, context):
708         scene = context.scene
709         lanpr = scene.lanpr
710         active_layer = lanpr.layers.active_layer
711         return active_layer and lanpr.master_mode != "SNAKE"
712
713     def draw(self, context):
714         layout = self.layout
715         scene = context.scene
716         lanpr = scene.lanpr
717         active_layer = lanpr.layers.active_layer
718         if active_layer and lanpr.master_mode == "DPIX":
719             active_layer = lanpr.layers[0]
720
721         layout.operator("scene.lanpr_enable_all_line_types")
722
723         split = layout.split(factor=0.3)
724         col = split.column()
725         col.prop(active_layer, "enable_contour", text="Contour", toggle=True)
726         col.prop(active_layer, "enable_crease", text="Crease", toggle=True)
727         col.prop(active_layer, "enable_edge_mark", text="Mark", toggle=True)
728         col.prop(active_layer, "enable_material_seperate", text="Material", toggle=True)
729         col.prop(active_layer, "enable_intersection", text="Intersection", toggle=True)
730         col = split.column()
731         row = col.row(align = True)
732         #row.enabled = active_layer.enable_contour this is always enabled now
733         row.prop(active_layer, "color", text="")
734         row.prop(active_layer, "thickness", text="")
735         row = col.row(align = True)
736         row.enabled = active_layer.enable_crease
737         row.prop(active_layer, "crease_color", text="")
738         row.prop(active_layer, "thickness_crease", text="")
739         row = col.row(align = True)
740         row.enabled = active_layer.enable_edge_mark
741         row.prop(active_layer, "edge_mark_color", text="")
742         row.prop(active_layer, "thickness_edge_mark", text="")
743         row = col.row(align = True)
744         row.enabled = active_layer.enable_material_seperate
745         row.prop(active_layer, "material_color", text="")
746         row.prop(active_layer, "thickness_material", text="")
747         row = col.row(align = True)
748         if lanpr.enable_intersections:
749             row.enabled = active_layer.enable_intersection
750             row.prop(active_layer, "intersection_color", text="")
751             row.prop(active_layer, "thickness_intersection", text="")
752         else:
753             row.label(text= "Intersection Calculation Disabled")
754
755         if lanpr.master_mode == "DPIX" and active_layer.enable_intersection:
756             row = col.row(align = True)
757             row.prop(lanpr,"enable_intersections", toggle = True, text = "Enable")
758             if lanpr.enable_intersections:
759                 row.operator("scene.lanpr_calculate", text= "Recalculate")
760
761         if lanpr.master_mode == "SOFTWARE":
762             row = layout.row(align=True)
763             row.prop(active_layer, "qi_begin")
764             row.prop(active_layer, "qi_end")
765
766 class SCENE_PT_lanpr_line_components(SceneButtonsPanel, Panel):
767     bl_label = "Including"
768     bl_parent_id = "SCENE_PT_lanpr"
769     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_LANPR', 'BLENDER_OPENGL'}
770
771     @classmethod
772     def poll(cls, context):
773         scene = context.scene
774         lanpr = scene.lanpr
775         active_layer = lanpr.layers.active_layer
776         return active_layer and lanpr.master_mode == "SOFTWARE" and not lanpr.enable_chaining
777
778     def draw(self, context):
779         layout = self.layout
780         scene = context.scene
781         lanpr = scene.lanpr
782         active_layer = lanpr.layers.active_layer
783
784         layout.operator("scene.lanpr_add_line_component")#, icon = "ZOOMIN")
785         
786         i=0
787         for c in active_layer.components:
788             split = layout.split(factor=0.85)
789             col = split.column()
790             sp2 = col.split(factor=0.4)
791             cl = sp2.column()
792             cl.prop(c,"component_mode", text = "")
793             cl = sp2.column()
794             if c.component_mode == "OBJECT":
795                 cl.prop(c,"object_select", text = "")
796             elif c.component_mode == "MATERIAL":
797                 cl.prop(c,"material_select", text = "")
798             elif c.component_mode == "COLLECTION":
799                 cl.prop(c,"collection_select", text = "")
800             col = split.column()
801             col.operator("scene.lanpr_delete_line_component", text="").index=i
802             i=i+1
803
804
805 class SCENE_PT_lanpr_line_effects(SceneButtonsPanel, Panel):
806     bl_label = "Effects"
807     bl_parent_id = "SCENE_PT_lanpr"
808     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_LANPR', 'BLENDER_OPENGL'}
809
810     @classmethod
811     def poll(cls, context):
812         scene = context.scene
813         lanpr = scene.lanpr
814         return lanpr.master_mode == "DPIX"
815
816     def draw(self, context):
817         layout = self.layout
818         scene = context.scene
819         lanpr = scene.lanpr
820         active_layer = lanpr.layers.active_layer
821
822         row = layout.row(align = True)
823         row.prop(lanpr, "crease_threshold")
824         row.prop(lanpr, "crease_fade_threshold")
825         row = layout.row(align = True)
826         row.prop(lanpr, "depth_width_influence")
827         row.prop(lanpr, "depth_width_curve")
828         row = layout.row(align = True)
829         row.prop(lanpr, "depth_alpha_influence")
830         row.prop(lanpr, "depth_alpha_curve")
831
832 class SCENE_PT_lanpr_snake_sobel_parameters(SceneButtonsPanel, Panel):
833     bl_label = "Sobel Parameters"
834     bl_parent_id = "SCENE_PT_lanpr"
835     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_LANPR', 'BLENDER_OPENGL'}
836
837     @classmethod
838     def poll(cls, context):
839         scene = context.scene
840         lanpr = scene.lanpr
841         return lanpr.master_mode == "SNAKE"
842
843     def draw(self, context):
844         layout = self.layout
845         scene = context.scene
846         lanpr = scene.lanpr
847         layout.prop(lanpr, "depth_clamp")
848         layout.prop(lanpr, "depth_strength")
849         layout.prop(lanpr, "normal_clamp")
850         layout.prop(lanpr, "normal_strength")
851         if lanpr.enable_vector_trace == "DISABLED":
852             layout.prop(lanpr, "display_thinning_result")
853
854 class SCENE_PT_lanpr_snake_settings(SceneButtonsPanel, Panel):
855     bl_label = "Snake Settings"
856     bl_parent_id = "SCENE_PT_lanpr"
857     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_LANPR', 'BLENDER_OPENGL'}
858
859     @classmethod
860     def poll(cls, context):
861         scene = context.scene
862         lanpr = scene.lanpr
863         return lanpr.master_mode == "SNAKE" and lanpr.enable_vector_trace == "ENABLED"
864
865     def draw(self, context):
866         layout = self.layout
867         scene = context.scene
868         lanpr = scene.lanpr
869
870         split = layout.split()
871         col = split.column()
872         col.prop(lanpr, "background_color")
873         col = split.column()
874         col.prop(lanpr, "line_color")
875         
876         layout.prop(lanpr, "line_thickness")
877
878         split = layout.split()
879         col = split.column()
880         col.prop(lanpr, "depth_width_influence")
881         col.prop(lanpr, "depth_alpha_influence")
882         col = split.column()
883         col.prop(lanpr, "depth_width_curve")
884         col.prop(lanpr, "depth_alpha_curve")
885         
886         layout.label(text="Taper:")
887         layout.prop(lanpr, "use_same_taper", expand = True)
888         if lanpr.use_same_taper == "DISABLED":
889             split = layout.split()
890             col = split.column(align = True)
891             col.label(text="Left:")
892             col.prop(lanpr,"taper_left_distance")
893             col.prop(lanpr,"taper_left_strength")
894             col = split.column(align = True)
895             col.label(text="Right:")
896             col.prop(lanpr,"taper_right_distance")
897             col.prop(lanpr,"taper_right_strength")
898         else:
899             split = layout.split()
900             col = split.column(align = True)
901             col.prop(lanpr,"taper_left_distance")
902             col.prop(lanpr,"taper_left_strength") 
903
904         layout.label(text="Tip Extend:")
905         layout.prop(lanpr, "enable_tip_extend",  expand = True)
906         if lanpr.enable_tip_extend == "ENABLED":
907             layout.label(text="---INOP---")
908             layout.prop(lanpr,"extend_length")
909
910 class SCENE_PT_lanpr_software_chain_styles(SceneButtonsPanel, Panel):
911     bl_label = "Chain Styles"
912     bl_parent_id = "SCENE_PT_lanpr"
913     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_LANPR', 'BLENDER_OPENGL'}
914
915     @classmethod
916     def poll(cls, context):
917         scene = context.scene
918         lanpr = scene.lanpr
919         return lanpr.master_mode == "SOFTWARE" and lanpr.enable_chaining
920
921     def draw(self, context):
922         layout = self.layout
923         scene = context.scene
924         lanpr = scene.lanpr
925         layout.label(text="Taper:")
926         layout.prop(lanpr, "use_same_taper", expand = True)
927         if lanpr.use_same_taper == "DISABLED":
928             split = layout.split()
929             col = split.column(align = True)
930             col.label(text="Left:")
931             col.prop(lanpr,"taper_left_distance")
932             col.prop(lanpr,"taper_left_strength")
933             col = split.column(align = True)
934             col.label(text="Right:")
935             col.prop(lanpr,"taper_right_distance")
936             col.prop(lanpr,"taper_right_strength")
937         else:
938             split = layout.split()
939             col = split.column(align = True)
940             col.prop(lanpr,"taper_left_distance")
941             col.prop(lanpr,"taper_left_strength") 
942
943         layout.label(text="Tip Extend:")
944         layout.prop(lanpr, "enable_tip_extend",  expand = True)
945         if lanpr.enable_tip_extend == "ENABLED":
946             layout.label(text="---INOP---")
947             layout.prop(lanpr,"extend_length")
948
949
950 class SCENE_PT_viewport_display_ssao(SceneButtonsPanel, Panel):
951     bl_label = "Screen Space Ambient Occlusion"
952     bl_parent_id = "SCENE_PT_viewport_display"
953
954     @classmethod
955     def poll(cls, context):
956         return True
957
958     def draw(self, context):
959         layout = self.layout
960         layout.use_property_split = True
961         scene = context.scene
962         col = layout.column()
963         col.prop(scene.display, "matcap_ssao_samples")
964         col.prop(scene.display, "matcap_ssao_distance")
965         col.prop(scene.display, "matcap_ssao_attenuation")
966
967
968 class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, Panel):
969     _context_path = "scene"
970     _property_type = bpy.types.Scene
971
972
973 classes = (
974     SCENE_UL_keying_set_paths,
975     SCENE_PT_scene,
976     SCENE_PT_unit,
977     SCENE_PT_keying_sets,
978     SCENE_PT_keying_set_paths,
979     SCENE_PT_keyframing_settings,
980     SCENE_PT_color_management,
981     SCENE_PT_color_management_curves,
982     SCENE_PT_viewport_display,
983     SCENE_PT_viewport_display_ssao,
984     SCENE_PT_audio,
985     SCENE_PT_physics,
986     SCENE_PT_rigid_body_world,
987     SCENE_PT_rigid_body_world_settings,
988     SCENE_PT_rigid_body_cache,
989     SCENE_PT_rigid_body_field_weights,
990     SCENE_PT_simplify,
991     SCENE_PT_simplify_viewport,
992     SCENE_PT_simplify_render,
993     SCENE_PT_simplify_greasepencil,
994     SCENE_PT_custom_props,
995
996     SCENE_PT_lanpr,
997     SCENE_PT_lanpr_line_types,
998     SCENE_PT_lanpr_line_components,
999     SCENE_PT_lanpr_line_effects,
1000     SCENE_PT_lanpr_snake_sobel_parameters,
1001     SCENE_PT_lanpr_snake_settings,
1002     SCENE_PT_lanpr_software_chain_styles,
1003
1004     LANPR_linesets,
1005 )
1006
1007 if __name__ == "__main__":  # only for live edit.
1008     from bpy.utils import register_class
1009     for cls in classes:
1010         register_class(cls)