[Bf-extensions-cvs] [5a22dc9a] master: Display Tools: Code update and clean up

lijenstina noreply at git.blender.org
Wed Mar 8 00:38:13 CET 2017


Commit: 5a22dc9a896e814b9b57d6a178ee2b28a4376af5
Author: lijenstina
Date:   Wed Mar 8 00:37:21 2017 +0100
Branches: master
https://developer.blender.org/rBAC5a22dc9a896e814b9b57d6a178ee2b28a4376af5

Display Tools: Code update and clean up

Bumped version to 1.6.1
Remove unused imports, props, variables and operators
Deduplicate code - merge operators into one when possible
Fix UI crash with an empty scene
Remove boxes in the UI layout
Reorganize some UI elements
Use BoolVectorProperty for the dropdowns

Notes:
The possible rewrite of Scene Restrictor still has
to be done
Tooltips and operator behavior maybe need some refinement
Maybe some of the removed operators can be restored later
Some operators are possibly still unused
More testing is always welcomed

===================================================================

M	space_view3d_display_tools/__init__.py
M	space_view3d_display_tools/display.py
M	space_view3d_display_tools/fast_navigate.py
M	space_view3d_display_tools/modifier_tools.py
M	space_view3d_display_tools/scene_vis.py
M	space_view3d_display_tools/select_tools.py
M	space_view3d_display_tools/selection_restrictor.py
M	space_view3d_display_tools/shading_menu.py
M	space_view3d_display_tools/useless_tools.py

===================================================================

diff --git a/space_view3d_display_tools/__init__.py b/space_view3d_display_tools/__init__.py
index 1e043b10..950f9f09 100644
--- a/space_view3d_display_tools/__init__.py
+++ b/space_view3d_display_tools/__init__.py
@@ -1,10 +1,8 @@
 # space_view_3d_display_tools.py Copyright (C) 2014, Jordi Vall-llovera
-#
 # Multiple display tools for fast navigate/interact with the viewport
-#
+
 # ***** BEGIN GPL LICENSE BLOCK *****
 #
-#
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
 # as published by the Free Software Foundation; either version 2
@@ -20,17 +18,17 @@
 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 #
 # ***** END GPL LICENCE BLOCK *****
-## Contributed to by Jasperge, Pixaal, Meta-androcto
+# Contributed to by Jasperge, Pixaal, Meta-androcto, Lapineige, lijenstina
 
 bl_info = {
     "name": "Display Tools",
     "author": "Jordi Vall-llovera Medina, Jhon Wallace",
-    "version": (1, 6, 0),
+    "version": (1, 6, 1),
     "blender": (2, 7, 0),
     "location": "Toolshelf",
-    "description": "Display tools for fast navigate/interact with the viewport",
+    "description": "Display tools for fast navigation/interaction with the viewport",
     "warning": "",
-    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/"
+    "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/"
                 "3D_interaction/Display_Tools",
     "tracker_url": "",
     "category": "3D View"}
@@ -59,172 +57,162 @@ else:
 
 import bpy
 from bpy.types import (
-        Operator,
         Panel,
         PropertyGroup,
         AddonPreferences,
-        PointerProperty,
         )
 from bpy.props import (
         IntProperty,
         BoolProperty,
+        BoolVectorProperty,
         EnumProperty,
         StringProperty,
+        PointerProperty,
         )
 
-from bpy_extras import view3d_utils
 
-# define base dummy class for inheritance
-class BasePollCheck:
-    @classmethod
-    def poll(cls, context):
-        return True
-
-
-class DisplayToolsPanel(bpy.types.Panel):
-    bl_label = 'Display Tools'
-    bl_space_type = 'VIEW_3D'
-    bl_region_type = 'TOOLS'
-    bl_category = 'Display'
+class DisplayToolsPanel(Panel):
+    bl_label = "Display Tools"
+    bl_space_type = "VIEW_3D"
+    bl_region_type = "TOOLS"
+    bl_category = "Display"
     bl_options = {'DEFAULT_CLOSED'}
 
-    draw_type_icons = {'BOUNDS':'BBOX',
-                       'WIRE':'WIRE',
-                       'SOLID':'SOLID', 
-                       'TEXTURED':'POTATO'}
-    
-    bounds_icons = {'BOX':'MESH_CUBE',
-                    'SPHERE':'MATSPHERE',
-                    'CYLINDER':'MESH_CYLINDER',
-                    'CONE':'MESH_CONE'}
+    draw_type_icons = {'BOUNDS': 'BBOX',
+                       'WIRE': 'WIRE',
+                       'SOLID': 'SOLID',
+                       'TEXTURED': 'POTATO'
+                        }
+    bounds_icons = {'BOX': 'MESH_CUBE',
+                    'SPHERE': 'MATSPHERE',
+                    'CYLINDER': 'MESH_CYLINDER',
+                    'CONE': 'MESH_CONE'
+                    }
 
     def draw(self, context):
         scene = context.scene
-        DISPLAYDROP = scene.UTDisplayDrop
-        SHADINGDROP = scene.UTShadingDrop
-        SCENEDROP = scene.UTSceneDrop
-        MODIFIERDROP = scene.UTModifierDrop
-        SELECT2DROP = scene.UTSelect2Drop
-        SUBSURF1DROP = scene.UTSubSurf1Drop
-        WIREDROP = scene.UTWireDrop
-        VIEWPORTDROP = scene.UTViewPortDrop
-        MISCDROP = scene.UTMiscDrop
-        FASTNAVDROP = scene.UTFastnavDrop
+        display_tools = scene.display_tools
+        render = scene.render
         view = context.space_data
-        toolsettings = context.tool_settings
+        gs = scene.game_settings
+        obj = context.object
+        obj_type = obj.type if obj else None
+        fx_settings = view.fx_settings
+
+        DISPLAYDROP = display_tools.UiTabDrop[0]
+        SHADINGDROP = display_tools.UiTabDrop[1]
+        SCENEDROP = display_tools.UiTabDrop[2]
+        MODIFIERDROP = display_tools.UiTabDrop[3]
+        SELECT2DROP = display_tools.UiTabDrop[4]
+        FASTNAVDROP = display_tools.UiTabDrop[5]
+        icon_active_0 = "TRIA_RIGHT" if not DISPLAYDROP else "TRIA_DOWN"
+        icon_active_1 = "TRIA_RIGHT" if not SHADINGDROP else "TRIA_DOWN"
+        icon_active_2 = "TRIA_RIGHT" if not SCENEDROP else "TRIA_DOWN"
+        icon_active_3 = "TRIA_RIGHT" if not MODIFIERDROP else "TRIA_DOWN"
+        icon_active_4 = "TRIA_RIGHT" if not SELECT2DROP else "TRIA_DOWN"
+        icon_active_5 = "TRIA_RIGHT" if not FASTNAVDROP else "TRIA_DOWN"
+        icon_wt_handler = "X" if display_tools.WT_handler_enable else "MOD_WIREFRAME"
+
         layout = self.layout
-        ob = context.object
 
         # Display Scene options
         box1 = self.layout.box()
         col = box1.column(align=True)
         row = col.row(align=True)
-        scene = context.scene
-#        row.alignment = 'CENTER'
-        row.prop(scene, "UTSceneDrop", icon="TRIA_DOWN")
+        row.prop(display_tools, "UiTabDrop", index=2, text="Display", icon=icon_active_2)
+
         if not SCENEDROP:
-            row.prop(ob, "show_texture_space", text="", icon='FACESEL_HLT')
-            row.prop(ob, "show_name", text="", icon='SORTALPHA')
-            row.prop(ob, "show_axis", text="", icon='AXIS_TOP')
-        if SCENEDROP:
-            col = box1.column(align=True)
+            if obj:
+                row.prop(obj, "show_texture_space", text="", icon="FACESEL_HLT")
+                row.prop(obj, "show_name", text="", icon="SORTALPHA")
+                row.prop(obj, "show_axis", text="", icon="AXIS_TOP")
+        else:
+            col = layout.column()
+            col.prop(view, "show_manipulator")
+
+            col = layout.column(align=True)
             col.alignment = 'EXPAND'
-            row = col.row()
-            scene = context.scene
-            render = scene.render
-            space = context.space_data
-            row.prop(space, "show_manipulator")
+            col.prop(view, "show_only_render", toggle=True)
+            col.prop(view, "show_world", toggle=True)
+            col.prop(view, "show_outline_selected", toggle=True)
+            col.prop(view, "show_all_objects_origin", toggle=True)
+            col.prop(view, "show_backface_culling", toggle=True)
+            if obj:
+                col.prop(obj, "show_x_ray", text="X-Ray", toggle=True)
 
-            view = context.space_data
-            scene = context.scene
+            if obj and obj_type == 'MESH':
+                col.prop(obj, "show_transparent", text="Transparency", toggle=True)
 
-            col = box1.column(align=True)
-            col.alignment = 'EXPAND'
-            row = col.row()
-            row.prop(view, "show_only_render")
-            row = col.row()
-            row.prop(view, "show_world")
-            row = col.row()
-            row.prop(space, "show_outline_selected")
-            row = col.row()
-            row.prop(space, "show_all_objects_origin")
-            row = col.row()
-            row.prop(space, "show_backface_culling")
-            row = col.row()
-            scene = context.scene
-            ob = context.object
-            ob_type = ob.type
-            row.prop(ob, "show_x_ray", text="X-Ray")
-            if ob_type == 'MESH' or is_empty_image:
-                row = col.row()
-                row.prop(ob, "show_transparent", text="Transparency")
-            row = col.row()
-            row.prop(render, "use_simplify", "Simplify")
-
-            if scene.render.use_simplify is True:
-                row.label("Settings :")
-                row = layout.row()
-                box = row.box()
-                box.prop(render, "simplify_subdivision", "Subdivision")
-                box.prop(render, "simplify_shadow_samples", "Shadow Samples")
-                box.prop(render, "simplify_child_particles", "Child Particles")
-                box.prop(render, "simplify_ao_sss", "AO and SSS")
-                layout.operator("view3d.display_simplify")
+            col = layout.column()
+            col.prop(render, "use_simplify", "Simplify", toggle=True)
+
+            if render.use_simplify is True:
+                col = layout.column(align=True)
+                col.label("Settings :")
+                col.prop(render, "simplify_subdivision", "Subdivision")
+                col.prop(render, "simplify_shadow_samples", "Shadow Samples")
+                col.prop(render, "simplify_child_particles", "Child Particles")
+                col.prop(render, "simplify_ao_sss", "AO and SSS")
 
         # Draw Type options
         box1 = self.layout.box()
         col = box1.column(align=True)
         row = col.row(align=True)
-        row.prop(scene, "UTDisplayDrop", icon="TRIA_DOWN")
+        row.prop(display_tools, "UiTabDrop", index=0, text="Draw Type", icon=icon_active_0)
+
         if not DISPLAYDROP:
-            row.operator("ut.wirehideall", icon="MATSPHERE", text="").show = False
-            row.operator("ut.wirehideall", icon="MESH_UVSPHERE", text="").show = True
+            hide_wires = row.operator("ut.wire_show_hide", icon="MATSPHERE", text="")
+            hide_wires.show = False
+            hide_wires.selected = False
+            show_wires = row.operator("ut.wire_show_hide", icon="MESH_UVSPHERE", text="")
+            show_wires.show = True
+            show_wires.selected = False
             row.operator("ut.all_edges", icon="MESH_GRID", text="").on = True
-        if DISPLAYDROP:
-            col = box1.column(align=True)
-            col.alignment = 'EXPAND'
-            row = col.row()
-            row.label(text="Maximum:")
-            row.prop(ob, "draw_type", text="", icon=self.draw_type_icons[ob.draw_type])
-
-            col = box1.column(align=True)
-            col.alignment = 'EXPAND'
+        else:
+            if obj:
+                col = layout.column(align=True)
+                col.alignment = 'EXPAND'
+                col.label(text="Maximum:")
+                col.prop(obj, "draw_type", text="", icon=self.draw_ty

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list