Skip to content
Snippets Groups Projects
Commit 0926c1e7 authored by Mikhail Rachinskiy's avatar Mikhail Rachinskiy
Browse files

Bool Tool: Do not hide the panel

Do not hide the panel when no selected objects, no good for user experience, greyout instead.
parent c613fb19
No related branches found
No related tags found
No related merge requests found
...@@ -587,7 +587,6 @@ class BTool_Slice(Operator): ...@@ -587,7 +587,6 @@ class BTool_Slice(Operator):
# Auto Boolean operators (maintainer Mikhail Rachinskiy) ------------------------------- # Auto Boolean operators (maintainer Mikhail Rachinskiy) -------------------------------
class AutoBoolean: class AutoBoolean:
bl_options = {'REGISTER', 'UNDO'}
solver = EnumProperty( solver = EnumProperty(
name="Boolean Solver", name="Boolean Solver",
...@@ -614,8 +613,10 @@ class AutoBoolean: ...@@ -614,8 +613,10 @@ class AutoBoolean:
scene.objects.active = ob scene.objects.active = ob
bpy.ops.object.mode_set(mode='EDIT') bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.reveal() bpy.ops.mesh.reveal()
bpy.ops.mesh.select_all(action=select_action) bpy.ops.mesh.select_all(action=select_action)
bpy.ops.object.mode_set(mode='OBJECT') bpy.ops.object.mode_set(mode='OBJECT')
scene.objects.active = obj scene.objects.active = obj
...@@ -648,6 +649,7 @@ class Auto_Union(AutoBoolean, Operator): ...@@ -648,6 +649,7 @@ class Auto_Union(AutoBoolean, Operator):
"""Combine selected objects""" """Combine selected objects"""
bl_idname = "btool.auto_union" bl_idname = "btool.auto_union"
bl_label = "Union" bl_label = "Union"
bl_options = {'REGISTER', 'UNDO'}
mode = 'UNION' mode = 'UNION'
...@@ -661,6 +663,7 @@ class Auto_Difference(AutoBoolean, Operator): ...@@ -661,6 +663,7 @@ class Auto_Difference(AutoBoolean, Operator):
"""Subtract selected objects from active object""" """Subtract selected objects from active object"""
bl_idname = "btool.auto_difference" bl_idname = "btool.auto_difference"
bl_label = "Difference" bl_label = "Difference"
bl_options = {'REGISTER', 'UNDO'}
mode = 'DIFFERENCE' mode = 'DIFFERENCE'
...@@ -674,6 +677,7 @@ class Auto_Intersect(AutoBoolean, Operator): ...@@ -674,6 +677,7 @@ class Auto_Intersect(AutoBoolean, Operator):
"""Keep only intersecting geometry""" """Keep only intersecting geometry"""
bl_idname = "btool.auto_intersect" bl_idname = "btool.auto_intersect"
bl_label = "Intersect" bl_label = "Intersect"
bl_options = {'REGISTER', 'UNDO'}
mode = 'INTERSECT' mode = 'INTERSECT'
...@@ -687,6 +691,7 @@ class Auto_Slice(AutoBoolean, Operator): ...@@ -687,6 +691,7 @@ class Auto_Slice(AutoBoolean, Operator):
"""Slice active object along the selected object (can handle only two objects at a time)""" """Slice active object along the selected object (can handle only two objects at a time)"""
bl_idname = "btool.auto_slice" bl_idname = "btool.auto_slice"
bl_label = "Slice" bl_label = "Slice"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context): def execute(self, context):
self.objects_prepare() self.objects_prepare()
...@@ -707,7 +712,7 @@ class Auto_Slice(AutoBoolean, Operator): ...@@ -707,7 +712,7 @@ class Auto_Slice(AutoBoolean, Operator):
scene.objects.active = obj_copy scene.objects.active = obj_copy
self.boolean_mod(obj_copy, ob, 'INTERSECT') self.boolean_mod(obj_copy, ob, 'INTERSECT')
obj_copy.select = True obj_copy.select = True
return {'FINISHED'} return {'FINISHED'}
...@@ -716,6 +721,7 @@ class Auto_Subtract(AutoBoolean, Operator): ...@@ -716,6 +721,7 @@ class Auto_Subtract(AutoBoolean, Operator):
"""subtracted object not removed (can handle only two objects at a time)""" """subtracted object not removed (can handle only two objects at a time)"""
bl_idname = "btool.auto_subtract" bl_idname = "btool.auto_subtract"
bl_label = "Subtract" bl_label = "Subtract"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context): def execute(self, context):
self.objects_prepare() self.objects_prepare()
...@@ -935,37 +941,45 @@ class BoolTool_Tools(Panel): ...@@ -935,37 +941,45 @@ class BoolTool_Tools(Panel):
bl_idname = "BoolTool_Tools" bl_idname = "BoolTool_Tools"
bl_space_type = "VIEW_3D" bl_space_type = "VIEW_3D"
bl_region_type = "TOOLS" bl_region_type = "TOOLS"
bl_context = 'objectmode'
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
obj = context.object return context.active_object is not None
if len(context.selected_objects) > 0:
return obj and obj.type == 'MESH' and obj.mode in {'OBJECT'}
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
row = layout.split(0.70) obj = context.active_object
row.label("Bool Tools:", icon="MODIFIER") obs_len = len(context.selected_objects)
row = layout.split(0.7)
row.label("Bool Tools:")
row.operator("help.bool_tool", text="", icon="QUESTION") row.operator("help.bool_tool", text="", icon="QUESTION")
col = layout.column(align=True) main = layout.column(align=True)
col.enabled = len(context.selected_objects) > 1 main.enabled = obj.type == 'MESH' and obs_len > 0
col.separator()
main.separator()
col = main.column(align=True)
col.enabled = obs_len > 1
col.label("Auto Boolean:", icon="MODIFIER") col.label("Auto Boolean:", icon="MODIFIER")
col.separator() col.separator()
col.operator(Auto_Difference.bl_idname, icon="ROTACTIVE") col.operator(Auto_Difference.bl_idname, icon="ROTACTIVE")
col.operator(Auto_Union.bl_idname, icon="ROTATECOLLECTION") col.operator(Auto_Union.bl_idname, icon="ROTATECOLLECTION")
col.operator(Auto_Intersect.bl_idname, icon="ROTATECENTER") col.operator(Auto_Intersect.bl_idname, icon="ROTATECENTER")
col = layout.column(align=True) main.separator()
col.enabled = len(context.selected_objects) == 2
col = main.column(align=True)
col.enabled = obs_len == 2
col.operator(Auto_Slice.bl_idname, icon="ROTATECENTER") col.operator(Auto_Slice.bl_idname, icon="ROTATECENTER")
col.operator(Auto_Subtract.bl_idname, icon="ROTACTIVE") col.operator(Auto_Subtract.bl_idname, icon="ROTACTIVE")
layout.separator() main.separator()
col = layout.column(align=True) col = main.column(align=True)
col.enabled = len(context.selected_objects) > 1 col.enabled = obs_len > 1
col.label("Brush Boolean:", icon="MODIFIER") col.label("Brush Boolean:", icon="MODIFIER")
col.separator() col.separator()
col.operator(BTool_Diff.bl_idname, text="Difference", icon="ROTACTIVE") col.operator(BTool_Diff.bl_idname, text="Difference", icon="ROTACTIVE")
...@@ -973,10 +987,9 @@ class BoolTool_Tools(Panel): ...@@ -973,10 +987,9 @@ class BoolTool_Tools(Panel):
col.operator(BTool_Inters.bl_idname, text="Intersect", icon="ROTATECENTER") col.operator(BTool_Inters.bl_idname, text="Intersect", icon="ROTATECENTER")
col.operator(BTool_Slice.bl_idname, text="Slice", icon="ROTATECENTER") col.operator(BTool_Slice.bl_idname, text="Slice", icon="ROTATECENTER")
layout.separator() main.separator()
col = layout.column(align=True)
col = main.column(align=True)
col.label("Draw:", icon="MESH_CUBE") col.label("Draw:", icon="MESH_CUBE")
col.separator() col.separator()
col.operator(BTool_DrawPolyBrush.bl_idname, icon="LINE_DATA") col.operator(BTool_DrawPolyBrush.bl_idname, icon="LINE_DATA")
...@@ -1151,17 +1164,18 @@ class BoolTool_BViwer(Panel): ...@@ -1151,17 +1164,18 @@ class BoolTool_BViwer(Panel):
# ------------------ BOOL TOOL Help ---------------------------- # ------------------ BOOL TOOL Help ----------------------------
class BoolTool_help(Operator): class BoolTool_help(Operator):
"""Tip"""
bl_idname = "help.bool_tool" bl_idname = "help.bool_tool"
bl_label = "" bl_label = ""
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
layout.label('To use:') layout.label("To use:")
layout.label('Select two or more objects.') layout.label("Select two or more objects.")
layout.label('Auto Boolean:') layout.label("Auto Boolean:")
layout.label('Apply boolean operation directly.') layout.label("Apply boolean operation directly.")
layout.label('Brush Boolean:') layout.label("Brush Boolean:")
layout.label('Create boolean brush set up.') layout.label("Create boolean brush set up.")
def execute(self, context): def execute(self, context):
return {'FINISHED'} return {'FINISHED'}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment