Correct links
[blender-addons.git] / object_print3d_utils / ui.py
blob2bcf4d55a62d153fe6932ffa3dab35aafad1c2e8
1 # ##### BEGIN GPL LICENSE BLOCK #####
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.
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.
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.
17 # ##### END GPL LICENSE BLOCK #####
19 # <pep8-80 compliant>
21 # Interface for this addon.
23 import bmesh
24 from bpy.types import Panel
25 from . import report
27 class Print3DToolBar:
28 bl_label = "Print3D"
29 bl_space_type = 'VIEW_3D'
30 bl_region_type = 'TOOLS'
32 _type_to_icon = {
33 bmesh.types.BMVert: 'VERTEXSEL',
34 bmesh.types.BMEdge: 'EDGESEL',
35 bmesh.types.BMFace: 'FACESEL',
38 @classmethod
39 def poll(cls, context):
40 obj = context.active_object
41 return (obj and obj.type == 'MESH')
43 @staticmethod
44 def draw_report(layout, context):
45 """Display Reports"""
46 info = report.info()
47 if info:
48 obj = context.edit_object
50 layout.label("Output:")
51 box = layout.box()
52 col = box.column(align=False)
53 # box.alert = True
54 for i, (text, data) in enumerate(info):
55 if obj and data and data[1]:
56 bm_type, bm_array = data
57 col.operator("mesh.print3d_select_report",
58 text=text,
59 icon=Print3DToolBar._type_to_icon[bm_type]).index = i
60 else:
61 col.label(text)
63 def draw(self, context):
64 layout = self.layout
66 scene = context.scene
67 print_3d = scene.print_3d
68 obj = context.object
70 # TODO, presets
72 row = layout.row()
73 row.label("Statistics:")
74 rowsub = layout.row(align=True)
75 rowsub.operator("mesh.print3d_info_volume", text="Volume")
76 rowsub.operator("mesh.print3d_info_area", text="Area")
78 row = layout.row()
79 row.label("Checks:")
80 col = layout.column(align=True)
81 col.operator("mesh.print3d_check_solid", text="Solid")
82 col.operator("mesh.print3d_check_intersect", text="Intersections")
83 rowsub = col.row(align=True)
84 rowsub.operator("mesh.print3d_check_degenerate", text="Degenerate")
85 rowsub.prop(print_3d, "threshold_zero", text="")
86 rowsub = col.row(align=True)
87 rowsub.operator("mesh.print3d_check_distort", text="Distorted")
88 rowsub.prop(print_3d, "angle_distort", text="")
89 rowsub = col.row(align=True)
90 rowsub.operator("mesh.print3d_check_thick", text="Thickness")
91 rowsub.prop(print_3d, "thickness_min", text="")
92 rowsub = col.row(align=True)
93 rowsub.operator("mesh.print3d_check_sharp", text="Edge Sharp")
94 rowsub.prop(print_3d, "angle_sharp", text="")
95 rowsub = col.row(align=True)
96 rowsub.operator("mesh.print3d_check_overhang", text="Overhang")
97 rowsub.prop(print_3d, "angle_overhang", text="")
98 col = layout.column()
99 col.operator("mesh.print3d_check_all", text="Check All")
101 row = layout.row()
102 row.label("Cleanup:")
103 col = layout.column(align=True)
104 col.operator("mesh.print3d_clean_isolated", text="Isolated")
105 rowsub = col.row(align=True)
106 rowsub.operator("mesh.print3d_clean_distorted", text="Distorted")
107 rowsub.prop(print_3d, "angle_distort", text="")
108 col = layout.column()
109 col.operator("mesh.print3d_clean_non_manifold", text="Make Manifold")
110 # XXX TODO
111 # col.operator("mesh.print3d_clean_thin", text="Wall Thickness")
113 row = layout.row()
114 row.label("Scale To:")
115 rowsub = layout.row(align=True)
116 rowsub.operator("mesh.print3d_scale_to_volume", text="Volume")
117 rowsub.operator("mesh.print3d_scale_to_bounds", text="Bounds")
119 col = layout.column()
120 rowsub = col.row(align=True)
121 rowsub.label("Export Path:")
122 rowsub.prop(print_3d, "use_apply_scale", text="", icon='MAN_SCALE')
123 rowsub.prop(print_3d, "use_export_texture", text="", icon='FILE_IMAGE')
124 rowsub = col.row()
125 rowsub.prop(print_3d, "export_path", text="")
127 rowsub = col.row(align=True)
128 rowsub.prop(print_3d, "export_format", text="")
129 rowsub.operator("mesh.print3d_export", text="Export", icon='EXPORT')
131 Print3DToolBar.draw_report(layout, context)
133 # So we can have a panel in both object mode and editmode
134 class Print3DToolBarObject(Panel, Print3DToolBar):
135 bl_category = "3D Printing"
136 bl_idname = "MESH_PT_print3d_object"
137 bl_context = "objectmode"
139 class Print3DToolBarMesh(Panel, Print3DToolBar):
140 bl_category = "3D Printing"
141 bl_idname = "MESH_PT_print3d_mesh"
142 bl_context = "mesh_edit"