[Bf-extensions-cvs] [aae47dca] master: Print3D: use subpanels to declutter UI

Mikhail Rachinskiy noreply at git.blender.org
Tue Sep 24 11:48:19 CEST 2019


Commit: aae47dca778b8f9c8a60b3c0c5c938b0f402915d
Author: Mikhail Rachinskiy
Date:   Tue Sep 24 13:48:07 2019 +0400
Branches: master
https://developer.blender.org/rBAaae47dca778b8f9c8a60b3c0c5c938b0f402915d

Print3D: use subpanels to declutter UI

Print3D has three tool categories: Mesh Check, Cleanup & Modify, Export. The first category being the main point of the add-on, the rest are supplementary and should not take visual space by default. Notes: Ideally Cleanup & Modify should be their own categories, but there are only two Modify tools so I decided to merge into one category. There is a point to make that Cleanup & Modify panel should be open by default, I am not strongly agains that and it could be done upon receiving feedba [...]

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

M	object_print3d_utils/__init__.py
M	object_print3d_utils/ui.py

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

diff --git a/object_print3d_utils/__init__.py b/object_print3d_utils/__init__.py
index 09be0501..eab7ffd1 100644
--- a/object_print3d_utils/__init__.py
+++ b/object_print3d_utils/__init__.py
@@ -128,8 +128,9 @@ class SceneProperties(PropertyGroup):
 classes = (
     SceneProperties,
 
-    ui.VIEW3D_PT_print3d_object,
-    ui.VIEW3D_PT_print3d_mesh,
+    ui.VIEW3D_PT_print3d,
+    ui.VIEW3D_PT_print3d_cleanup,
+    ui.VIEW3D_PT_print3d_export,
 
     operators.MESH_OT_print3d_info_volume,
     operators.MESH_OT_print3d_info_area,
diff --git a/object_print3d_utils/ui.py b/object_print3d_utils/ui.py
index 4b472a8d..2a7e74f2 100644
--- a/object_print3d_utils/ui.py
+++ b/object_print3d_utils/ui.py
@@ -26,8 +26,9 @@ import bmesh
 from . import report
 
 
-class Print3DToolBar:
+class VIEW3D_PT_print3d(Panel):
     bl_label = "Print3D"
+    bl_category = "3D Printing"
     bl_space_type = 'VIEW_3D'
     bl_region_type = 'UI'
 
@@ -40,107 +41,116 @@ class Print3DToolBar:
     @classmethod
     def poll(cls, context):
         obj = context.active_object
-        return obj and obj.type == 'MESH'
+        return obj is not None and obj.type == 'MESH' and obj.mode in {'OBJECT', 'EDIT'}
 
-    @staticmethod
-    def draw_report(layout, context):
-        """Display Reports"""
+    def draw_report(self, context):
+        layout = self.layout
         info = report.info()
+
         if info:
             obj = context.edit_object
+            show_select = False
 
-            layout.label(text="Output:")
+            layout.label(text="Report")
             box = layout.box()
-            col = box.column(align=False)
+            col = box.column()
 
             for i, (text, data) in enumerate(info):
                 if obj and data and data[1]:
                     bm_type, bm_array = data
-                    col.operator(
-                        "mesh.print3d_select_report",
-                        text=text,
-                        icon=Print3DToolBar._type_to_icon[bm_type],
-                    ).index = i
-                    layout.operator("mesh.select_non_manifold", text="Non Manifold Extended")
+                    col.operator("mesh.print3d_select_report", text=text, icon=self._type_to_icon[bm_type],).index = i
+                    show_select = True
                 else:
                     col.label(text=text)
 
+            if show_select:
+                layout.operator("mesh.select_non_manifold")
+
     def draw(self, context):
         layout = self.layout
 
-        scene = context.scene
-        print_3d = scene.print_3d
+        print_3d = context.scene.print_3d
 
         # TODO, presets
 
-        row = layout.row()
-        row.label(text="Statistics:")
-        rowsub = layout.row(align=True)
-        rowsub.operator("mesh.print3d_info_volume", text="Volume")
-        rowsub.operator("mesh.print3d_info_area", text="Area")
+        layout.label(text="Statistics")
+        row = layout.row(align=True)
+        row.operator("mesh.print3d_info_volume", text="Volume")
+        row.operator("mesh.print3d_info_area", text="Area")
 
-        row = layout.row()
-        row.label(text="Checks:")
+        layout.label(text="Checks")
         col = layout.column(align=True)
         col.operator("mesh.print3d_check_solid", text="Solid")
         col.operator("mesh.print3d_check_intersect", text="Intersections")
-        rowsub = col.row(align=True)
-        rowsub.operator("mesh.print3d_check_degenerate", text="Degenerate")
-        rowsub.prop(print_3d, "threshold_zero", text="")
-        rowsub = col.row(align=True)
-        rowsub.operator("mesh.print3d_check_distort", text="Distorted")
-        rowsub.prop(print_3d, "angle_distort", text="")
-        rowsub = col.row(align=True)
-        rowsub.operator("mesh.print3d_check_thick", text="Thickness")
-        rowsub.prop(print_3d, "thickness_min", text="")
-        rowsub = col.row(align=True)
-        rowsub.operator("mesh.print3d_check_sharp", text="Edge Sharp")
-        rowsub.prop(print_3d, "angle_sharp", text="")
-        rowsub = col.row(align=True)
-        rowsub.operator("mesh.print3d_check_overhang", text="Overhang")
-        rowsub.prop(print_3d, "angle_overhang", text="")
+        row = col.row(align=True)
+        row.operator("mesh.print3d_check_degenerate", text="Degenerate")
+        row.prop(print_3d, "threshold_zero", text="")
+        row = col.row(align=True)
+        row.operator("mesh.print3d_check_distort", text="Distorted")
+        row.prop(print_3d, "angle_distort", text="")
+        row = col.row(align=True)
+        row.operator("mesh.print3d_check_thick", text="Thickness")
+        row.prop(print_3d, "thickness_min", text="")
+        row = col.row(align=True)
+        row.operator("mesh.print3d_check_sharp", text="Edge Sharp")
+        row.prop(print_3d, "angle_sharp", text="")
+        row = col.row(align=True)
+        row.operator("mesh.print3d_check_overhang", text="Overhang")
+        row.prop(print_3d, "angle_overhang", text="")
         col = layout.column()
         col.operator("mesh.print3d_check_all", text="Check All")
 
-        row = layout.row()
-        row.label(text="Cleanup:")
+        self.draw_report(context)
+
+
+class VIEW3D_PT_print3d_cleanup(Panel):
+    bl_label = "Cleanup & Modify"
+    bl_space_type = 'VIEW_3D'
+    bl_region_type = 'UI'
+    bl_options = {"DEFAULT_CLOSED"}
+    bl_parent_id = "VIEW3D_PT_print3d"
+
+    def draw(self, context):
+        layout = self.layout
+
+        print_3d = context.scene.print_3d
+
+        layout.label(text="Cleanup")
         col = layout.column(align=True)
         col.operator("mesh.print3d_clean_isolated", text="Isolated")
-        rowsub = col.row(align=True)
-        rowsub.operator("mesh.print3d_clean_distorted", text="Distorted")
-        rowsub.prop(print_3d, "angle_distort", text="")
+        row = col.row(align=True)
+        row.operator("mesh.print3d_clean_distorted", text="Distorted")
+        row.prop(print_3d, "angle_distort", text="")
         col = layout.column()
         col.operator("mesh.print3d_clean_non_manifold", text="Make Manifold")
         # XXX TODO
         # col.operator("mesh.print3d_clean_thin", text="Wall Thickness")
 
-        row = layout.row()
-        row.label(text="Scale To:")
-        rowsub = layout.row(align=True)
-        rowsub.operator("mesh.print3d_scale_to_volume", text="Volume")
-        rowsub.operator("mesh.print3d_scale_to_bounds", text="Bounds")
+        layout.label(text="Scale To")
+        row = layout.row(align=True)
+        row.operator("mesh.print3d_scale_to_volume", text="Volume")
+        row.operator("mesh.print3d_scale_to_bounds", text="Bounds")
 
-        col = layout.column()
-        rowsub = col.row(align=True)
-        rowsub.label(text="Export Path:")
-        rowsub.prop(print_3d, "use_apply_scale", text="", icon='ORIENTATION_GLOBAL')
-        rowsub.prop(print_3d, "use_export_texture", text="", icon='FILE_IMAGE')
-        rowsub = col.row()
-        rowsub.prop(print_3d, "export_path", text="")
 
-        rowsub = col.row(align=True)
-        rowsub.prop(print_3d, "export_format", text="")
-        rowsub.operator("mesh.print3d_export", text="Export", icon='EXPORT')
+class VIEW3D_PT_print3d_export(Panel):
+    bl_label = "Export"
+    bl_space_type = 'VIEW_3D'
+    bl_region_type = 'UI'
+    bl_options = {"DEFAULT_CLOSED"}
+    bl_parent_id = "VIEW3D_PT_print3d"
 
-        Print3DToolBar.draw_report(layout, context)
+    def draw(self, context):
+        layout = self.layout
+        layout.use_property_split = True
+        layout.use_property_decorate = False
 
+        print_3d = context.scene.print_3d
 
-# So we can have a panel in both object mode and editmode
-class VIEW3D_PT_print3d_object(Panel, Print3DToolBar):
-    bl_category = "3D Printing"
-    bl_context = "objectmode"
+        layout.prop(print_3d, "export_path", text="")
 
+        col = layout.column()
+        col.prop(print_3d, "use_apply_scale")
+        col.prop(print_3d, "use_export_texture")
 
-class VIEW3D_PT_print3d_mesh(Panel, Print3DToolBar):
-    bl_category = "3D Printing"
-    bl_context = "mesh_edit"
+        layout.prop(print_3d, "export_format")
+        layout.operator("mesh.print3d_export", text="Export", icon='EXPORT')



More information about the Bf-extensions-cvs mailing list