20
20
"name" : "Depth of Field Utilities" ,
21
21
"author" : "Christian Brinkmann (p2or)" ,
22
22
"description" : "Displays depth of field in 3D view port." ,
23
- "version" : (0 , 0 , 9 ),
23
+ "version" : (0 , 1 , 0 ),
24
24
"blender" : (2 , 80 , 0 ),
25
25
"location" : "3d View > Properties Panel (N) > Depth of Field Utilities" ,
26
26
"wiki_url" : "https://github.com/p2or/blender-dof-utils" ,
42
42
# Preferences & Scene Properties
43
43
# ------------------------------------------------------------------------
44
44
45
- class DofUtilsPreferences (bpy .types .AddonPreferences ):
45
+ class DOFU_AP_preferences (bpy .types .AddonPreferences ):
46
46
47
47
bl_idname = __name__
48
48
@@ -63,7 +63,7 @@ def draw(self, context):
63
63
layout .row ().operator ("dof_utils.reset_preferences" , icon = 'FILE_REFRESH' )
64
64
65
65
66
- class DofUtilsSettings (bpy .types .PropertyGroup ):
66
+ class DOFU_PG_settings (bpy .types .PropertyGroup ):
67
67
68
68
_visualize_handle = None
69
69
_instructions_handle = None
@@ -398,7 +398,7 @@ def draw_circle(matrix, radius=.1, num_segments=16, offset=0, offset_axis="Z", c
398
398
# Operators
399
399
# ------------------------------------------------------------------------
400
400
401
- class DofUtilsFocusPicking (bpy .types .Operator ):
401
+ class DOFU_OT_focusPicking (bpy .types .Operator ):
402
402
"""Sets the focus distance by using the 3d cursor"""
403
403
bl_idname = "dof_utils.focus_picking"
404
404
bl_label = "Set Focus using 3d Cursor"
@@ -428,8 +428,8 @@ def modal(self, context, event):
428
428
# Set cursor tool
429
429
bpy .ops .wm .tool_set_by_id (name = "builtin.cursor" )
430
430
except :
431
- bpy .types .SpaceView3D .draw_handler_remove (DofUtilsSettings ._instructions_handle , 'WINDOW' )
432
- DofUtilsSettings ._instructions_handle = None
431
+ bpy .types .SpaceView3D .draw_handler_remove (DOFU_PG_settings ._instructions_handle , 'WINDOW' )
432
+ DOFU_PG_settings ._instructions_handle = None
433
433
context .scene .dof_utils .use_cursor = False
434
434
return {'CANCELLED' }
435
435
@@ -442,8 +442,8 @@ def modal(self, context, event):
442
442
elif event .type in {'RIGHTMOUSE' , 'ESC' } or not dofu .use_cursor :
443
443
dofu .use_cursor = False
444
444
try :
445
- bpy .types .SpaceView3D .draw_handler_remove (DofUtilsSettings ._instructions_handle , 'WINDOW' )
446
- DofUtilsSettings ._instructions_handle = None
445
+ bpy .types .SpaceView3D .draw_handler_remove (DOFU_PG_settings ._instructions_handle , 'WINDOW' )
446
+ DOFU_PG_settings ._instructions_handle = None
447
447
except :
448
448
pass
449
449
# Reset to selected tool before running the operator
@@ -464,9 +464,9 @@ def invoke(self, context, event):
464
464
from bl_ui .space_toolsystem_common import ToolSelectPanelHelper
465
465
self ._tool = ToolSelectPanelHelper .tool_active_from_context (context ).idname
466
466
467
- if prefs .display_info and not DofUtilsSettings ._instructions_handle :
467
+ if prefs .display_info and not DOFU_PG_settings ._instructions_handle :
468
468
args = (self , context )
469
- DofUtilsSettings ._instructions_handle = bpy .types .SpaceView3D .draw_handler_add (draw_callback_2d , args , 'WINDOW' , 'POST_PIXEL' )
469
+ DOFU_PG_settings ._instructions_handle = bpy .types .SpaceView3D .draw_handler_add (draw_callback_2d , args , 'WINDOW' , 'POST_PIXEL' )
470
470
471
471
context .window_manager .modal_handler_add (self )
472
472
dofu .use_cursor = True
@@ -479,7 +479,7 @@ def invoke(self, context, event):
479
479
return {'CANCELLED' }
480
480
481
481
482
- class DofUtilsVisualizeLimits (bpy .types .Operator ):
482
+ class DOFU_OT_visualizeLimits (bpy .types .Operator ):
483
483
""" Draws depth of field in the viewport via OpenGL """
484
484
bl_idname = "dof_utils.visualize_dof"
485
485
bl_label = "Visualize Depth of Field"
@@ -508,10 +508,10 @@ def modal(self, context, event):
508
508
if event .type in {'RIGHTMOUSE' , 'ESC' } or not dofu .draw_dof :
509
509
dofu .draw_dof = False
510
510
try : # TODO, viewport class
511
- bpy .types .SpaceView3D .draw_handler_remove (DofUtilsSettings ._visualize_handle , 'WINDOW' )
512
- bpy .types .SpaceView3D .draw_handler_remove (DofUtilsSettings ._instructions_handle , 'WINDOW' )
513
- DofUtilsSettings ._instructions_handle = None
514
- DofUtilsSettings ._visualize_handle = None
511
+ bpy .types .SpaceView3D .draw_handler_remove (DOFU_PG_settings ._visualize_handle , 'WINDOW' )
512
+ bpy .types .SpaceView3D .draw_handler_remove (DOFU_PG_settings ._instructions_handle , 'WINDOW' )
513
+ DOFU_PG_settings ._instructions_handle = None
514
+ DOFU_PG_settings ._visualize_handle = None
515
515
except :
516
516
pass
517
517
if context .area is not None :
@@ -529,10 +529,10 @@ def invoke(self, context, event):
529
529
if context .area .type == 'VIEW_3D' :
530
530
args = (self , context )
531
531
# Add the region OpenGL drawing callback, draw in view space with 'POST_VIEW' and 'PRE_VIEW'
532
- DofUtilsSettings ._visualize_handle = bpy .types .SpaceView3D .draw_handler_add (draw_callback_3d , args , 'WINDOW' , 'POST_VIEW' )
532
+ DOFU_PG_settings ._visualize_handle = bpy .types .SpaceView3D .draw_handler_add (draw_callback_3d , args , 'WINDOW' , 'POST_VIEW' )
533
533
534
- if prefs .display_info and not DofUtilsSettings ._instructions_handle :
535
- DofUtilsSettings ._instructions_handle = bpy .types .SpaceView3D .draw_handler_add (draw_callback_2d , args , 'WINDOW' , 'POST_PIXEL' )
534
+ if prefs .display_info and not DOFU_PG_settings ._instructions_handle :
535
+ DOFU_PG_settings ._instructions_handle = bpy .types .SpaceView3D .draw_handler_add (draw_callback_2d , args , 'WINDOW' , 'POST_PIXEL' )
536
536
537
537
context .window_manager .modal_handler_add (self )
538
538
dofu .draw_dof = True
@@ -547,7 +547,7 @@ def invoke(self, context, event):
547
547
return {'CANCELLED' }
548
548
549
549
550
- class DofUtilsKillVisualization (bpy .types .Operator ):
550
+ class DOFU_OT_killVisualisation (bpy .types .Operator ):
551
551
""" Kill Visualization """
552
552
bl_idname = "dof_utils.kill_visualization"
553
553
bl_label = "Kill Visualization"
@@ -558,7 +558,7 @@ def execute(self, context):
558
558
return {'FINISHED' }
559
559
560
560
561
- class DofUtilsKillFocusPicking (bpy .types .Operator ):
561
+ class DOFU_OT_killFocusPicking (bpy .types .Operator ):
562
562
""" Kill Focus Picking """
563
563
bl_idname = "dof_utils.kill_focus_picking"
564
564
bl_label = "Kill Visualization"
@@ -569,7 +569,7 @@ def execute(self, context):
569
569
return {'FINISHED' }
570
570
571
571
572
- class DofUtilsResetViewport (bpy .types .Operator ):
572
+ class DOFU_OT_viewportReset (bpy .types .Operator ):
573
573
""" Reset Viewport """
574
574
bl_idname = "dof_utils.reset_viewport"
575
575
bl_label = "Reset Viewport"
@@ -578,17 +578,17 @@ class DofUtilsResetViewport(bpy.types.Operator):
578
578
# TODO, viewport class
579
579
def execute (self , context ):
580
580
try :
581
- DofUtilsSettings ._instructions_handle = None
582
- DofUtilsSettings ._visualize_handle = None
583
- bpy .types .SpaceView3D .draw_handler_remove (DofUtilsSettings ._instructions_handle , 'WINDOW' )
584
- bpy .types .SpaceView3D .draw_handler_remove (DofUtilsSettings ._visualize_handle , 'WINDOW' )
581
+ DOFU_PG_settings ._instructions_handle = None
582
+ DOFU_PG_settings ._visualize_handle = None
583
+ bpy .types .SpaceView3D .draw_handler_remove (DOFU_PG_settings ._instructions_handle , 'WINDOW' )
584
+ bpy .types .SpaceView3D .draw_handler_remove (DOFU_PG_settings ._visualize_handle , 'WINDOW' )
585
585
586
586
except :
587
587
pass
588
588
return {'FINISHED' }
589
589
590
590
591
- class DofUtilsResetPreferences (bpy .types .Operator ):
591
+ class DOFU_OT_preferencesReset (bpy .types .Operator ):
592
592
""" Reset Add-on Preferences """
593
593
bl_idname = "dof_utils.reset_preferences"
594
594
bl_label = "Reset Properties and Settings"
@@ -613,101 +613,112 @@ def execute(self, context):
613
613
# UI
614
614
# ------------------------------------------------------------------------
615
615
616
- class DOFU_PT_main_panel (bpy .types .Panel ):
617
- bl_label = "Depth of Field Utilities"
616
+ class DOFU_panel :
618
617
bl_space_type = "VIEW_3D"
619
618
bl_region_type = "UI"
620
619
bl_category = "DoF Utils"
621
620
622
621
@classmethod
623
622
def poll (cls , context ):
624
- #rd = context.scene.render
625
- return is_camera (context .object )# and rd.engine == "CYCLES"
623
+ return is_camera (context .object )
624
+
625
+
626
+ class DOFU_PT_main_panel (DOFU_panel , bpy .types .Panel ):
627
+ bl_label = "Depth of Field"
628
+ bl_category = "DoF Utils"
626
629
630
+ def draw_header (self , context ):
631
+ self .layout .prop (context .active_object .data .dof , "use_dof" , text = "" )
632
+
627
633
def draw (self , context ):
628
- scene = context .scene
629
- dofu = scene .dof_utils #cam_ob = scene.camera.data
634
+ dofu = context .scene .dof_utils #cam_ob = scene.camera.data
630
635
cam_ob = context .active_object .data
631
- #ccam = cam_ob.cycles
632
636
633
- row = self .layout .row ()
634
- row .prop (cam_ob .dof , "use_dof" , text = "Enable Depth of Field" , toggle = True )
635
- self .layout .separator ()
637
+ layout = self .layout
638
+ layout .use_property_split = True
636
639
637
- col = self .layout .column (align = True )
638
- row = col .row (align = True )
639
- viz = row .row (align = True )
640
+ layout .active = cam_ob .dof .use_dof
641
+ active_flag = not dofu .use_cursor and cam_ob .dof .focus_object is None
642
+
643
+ # Visualize
644
+ row = layout .row (align = True )
645
+ viz = row .column (align = True )
640
646
viz .enabled = not dofu .draw_dof # enabled
641
647
viz .operator ("dof_utils.visualize_dof" , icon = "SNAP_NORMAL" if not dofu .draw_dof else "REC" )
642
- row = row .row (align = True )
648
+ row = row .column (align = True )
643
649
row .operator ("dof_utils.kill_visualization" , icon = "X" , text = "" )
644
650
645
- row = col .row (align = True )
646
- #split = row.split(.07, align=True)
647
- row .prop (dofu , "color_limits" , text = "" )
648
- #row = split.row(align=True)
649
-
650
- row = col .row (align = True )
651
- row .prop (dofu , "size_limits" )
652
- row .prop (dofu , "opacity_limits" )
653
- row .prop (dofu , "segments_limits" )
654
- #row.prop(dofu, "fill_limits", text="", icon="META_EMPTY")
655
-
656
- row = col .row (align = True )
657
- row .prop (dofu , "overlay" , text = "Overlay Limits" , toggle = True , icon = "GHOST_ENABLED" )
658
- row .prop (dofu , "draw_focus" , toggle = True , icon = "FORCE_FORCE" )
659
- #row.prop(dofu, "fill_limits", text="", icon="PROP_ON")
660
- #row = col.row(align=True)
661
- #row.prop(dofu, "fill_limits", text="Reset", icon="FILE_REFRESH")
662
-
663
- col = self .layout .column (align = True )
664
- col .label (text = "Aperture:" )
665
- row = col .row (align = True )
666
- #row.prop(ccam, "aperture_type", expand=True)
667
- # Following lines rem as radius option not exist
668
- #if ccam.aperture_type == 'RADIUS':
669
- # col.prop(ccam, "aperture_size", text="Size")
670
- #elif ccam.aperture_type == 'FSTOP':
671
- col .prop (cam_ob .dof , "aperture_fstop" , text = "Number" )
672
-
673
- col = self .layout .column (align = True )
674
- col .label (text = "Focus:" )
675
- row = col .row (align = True )
676
- pic = row .row (align = True )
677
- active_flag = not dofu .use_cursor and cam_ob .dof .focus_object is None
651
+ # Focus Picking
652
+ row = layout .row (align = True )
653
+ pic = row .column (align = True )
678
654
pic .enabled = active_flag # enabled
679
655
pic .operator ("dof_utils.focus_picking" , icon = "RESTRICT_SELECT_OFF" if active_flag or cam_ob .dof .focus_object else "REC" )
680
- row = row .row (align = True ) #layout.prop_search(dofu, "camera", bpy.data, "cameras")
656
+ row = row .column (align = True ) #layout.prop_search(dofu, "camera", bpy.data, "cameras")
681
657
row .enabled = cam_ob .dof .focus_object is None
682
658
row .operator ("dof_utils.kill_focus_picking" , icon = "X" , text = "" )
683
- row = col .row (align = True )
684
- dis = row .row (align = True )
659
+
660
+
661
+ class DOFU_PT_camera (DOFU_panel , bpy .types .Panel ):
662
+ bl_label = "Camera Settings"
663
+ bl_parent_id = "DOFU_PT_main_panel"
664
+
665
+ def draw (self , context ):
666
+ dofu = context .scene .dof_utils #cam_ob = scene.camera.data
667
+ cam_ob = context .active_object .data
668
+ active_flag = not dofu .use_cursor and cam_ob .dof .focus_object is None
669
+
670
+ layout = self .layout
671
+ layout .use_property_split = True
672
+ layout .active = cam_ob .dof .use_dof
673
+
674
+ col = layout .column ()
675
+ col .prop (cam_ob .dof , "aperture_fstop" , text = "F-Stop" )
676
+ dis = col .column ()
685
677
dis .enabled = active_flag # active
686
- dis .prop (cam_ob .dof , "focus_distance" , text = "Distance" )
687
- col .prop (cam_ob .dof , "focus_object" , text = "" )
678
+ dis .prop (cam_ob .dof , "focus_distance" , text = "Focus Distance" )
679
+ col .prop (cam_ob , "lens" )
680
+ col .prop (cam_ob .dof , "focus_object" , text = "Focus Object" )
681
+ layout .separator ()
682
+
683
+
684
+ class DOFU_PT_visualize (DOFU_panel , bpy .types .Panel ):
685
+ bl_label = "Visualisation Options"
686
+ bl_parent_id = "DOFU_PT_main_panel"
687
+
688
+ def draw (self , context ):
689
+ dofu = context .scene .dof_utils #cam_ob = scene.camera.data
690
+
691
+ layout = self .layout
692
+ layout .use_property_split = True
693
+ layout .active = context .active_object .data .dof .use_dof
688
694
689
- col = self .layout .column (align = True )
690
- cam_info = ["Cam: {}" .format (cam_ob .name )]
691
- if cam_ob .type == "PERSP" :
692
- cam_info .append (" Lens: {:.2f}mm" .format (cam_ob .lens ))
693
- col .label (text = "," .join (cam_info ))
694
- self .layout .separator ()
695
+ col = layout .column ()
696
+ col .prop (dofu , "color_limits" , text = "Color" )
697
+ col .prop (dofu , "size_limits" )
698
+ col .prop (dofu , "opacity_limits" )
699
+ col .prop (dofu , "segments_limits" )
700
+ col = layout .column ()
701
+ col .prop (dofu , "overlay" , text = "Overlay Limits" )#, toggle=True, icon="GHOST_ENABLED")
702
+ col .prop (dofu , "draw_focus" ) #, toggle=True, icon="FORCE_FORCE")
703
+ layout .separator ()
695
704
696
705
697
706
# ------------------------------------------------------------------------
698
707
# Registration
699
708
# ------------------------------------------------------------------------
700
709
701
710
classes = (
702
- DofUtilsPreferences ,
703
- DofUtilsFocusPicking ,
704
- DofUtilsVisualizeLimits ,
705
- DofUtilsKillVisualization ,
706
- DofUtilsKillFocusPicking ,
707
- DofUtilsResetViewport ,
708
- DofUtilsResetPreferences ,
711
+ DOFU_AP_preferences ,
712
+ DOFU_PG_settings ,
713
+ DOFU_OT_focusPicking ,
714
+ DOFU_OT_visualizeLimits ,
715
+ DOFU_OT_killVisualisation ,
716
+ DOFU_OT_killFocusPicking ,
717
+ DOFU_OT_viewportReset ,
718
+ DOFU_OT_preferencesReset ,
709
719
DOFU_PT_main_panel ,
710
- DofUtilsSettings
720
+ DOFU_PT_camera ,
721
+ DOFU_PT_visualize
711
722
)
712
723
713
724
@@ -716,7 +727,7 @@ def register():
716
727
for cls in classes :
717
728
register_class (cls )
718
729
719
- bpy .types .Scene .dof_utils = bpy .props .PointerProperty (type = DofUtilsSettings )
730
+ bpy .types .Scene .dof_utils = bpy .props .PointerProperty (type = DOFU_PG_settings )
720
731
721
732
def unregister ():
722
733
bpy .ops .dof_utils .reset_preferences ()
0 commit comments