Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Rachinskiy <mikhail.rachinskiy@gmail.com>2019-09-17 12:02:45 +0300
committerMikhail Rachinskiy <mikhail.rachinskiy@gmail.com>2019-09-17 12:02:45 +0300
commit7e79878338be4a2895d0a24e2afdaebee2df35df (patch)
treef5e29b6dca1724ed00ba549decc18082cc3fd4ad /object_boolean_tools.py
parentac7043b7e5bf3f986655c2fcfca89dc4a4bf70fb (diff)
Bool Tool: use more descriptive icons
Also put additional panels under the main panel and mark unported code for TODO.
Diffstat (limited to 'object_boolean_tools.py')
-rw-r--r--object_boolean_tools.py273
1 files changed, 137 insertions, 136 deletions
diff --git a/object_boolean_tools.py b/object_boolean_tools.py
index b14263e2..dc0012f0 100644
--- a/object_boolean_tools.py
+++ b/object_boolean_tools.py
@@ -330,98 +330,98 @@ def ApplyThisBrush(context, brush):
# ------------------ Bool Tool OPERATORS --------------------------------------
-
-class BTool_DrawPolyBrush(Operator):
- bl_idname = "btool.draw_polybrush"
- bl_label = "Draw Poly Brush"
- bl_description = (
- "Draw Polygonal Mask, can be applied to Canvas > Brush or Directly\n"
- "Note: ESC to Cancel, Enter to Apply, Right Click to erase the Lines"
- )
-
- count = 0
- store_cont_draw = False
-
- @classmethod
- def poll(cls, context):
- return context.active_object is not None
-
- def set_cont_draw(self, context, start=False):
- # store / restore GP continuous drawing (see T52321)
- scene = context.scene
- tool_settings = scene.tool_settings
- continuous = tool_settings.use_gpencil_continuous_drawing
- if start:
- self.store_cont_draw = continuous
- tool_settings.use_gpencil_continuous_drawing = True
- else:
- tool_settings.use_gpencil_continuous_drawing = self.store_cont_draw
-
- def modal(self, context, event):
- self.count += 1
- actObj = bpy.context.active_object
- if self.count == 1:
- actObj.select_set(state=True)
- bpy.ops.gpencil.draw("INVOKE_DEFAULT", mode="DRAW_POLY")
-
- if event.type == "RIGHTMOUSE":
- # use this to pass to the Grease Pencil eraser (see T52321)
- pass
-
- if event.type in {"RET", "NUMPAD_ENTER"}:
-
- bpy.ops.gpencil.convert(type="POLY")
- self.set_cont_draw(context)
-
- for obj in context.selected_objects:
- if obj.type == "CURVE":
- obj.name = "PolyDraw"
- bpy.context.view_layer.objects.active = obj
- bpy.ops.object.select_all(action="DESELECT")
- obj.select_set(state=True)
- bpy.ops.object.convert(target="MESH")
- bpy.ops.object.mode_set(mode="EDIT")
- bpy.ops.mesh.select_all(action="SELECT")
- bpy.ops.mesh.edge_face_add()
- bpy.ops.mesh.flip_normals()
- bpy.ops.object.mode_set(mode="OBJECT")
- bpy.ops.object.origin_set(type="ORIGIN_CENTER_OF_MASS")
- bpy.ops.object.modifier_add(type="SOLIDIFY")
- for mod in obj.modifiers:
- if mod.name == "Solidify":
- mod.name = "BTool_PolyBrush"
- mod.thickness = 1
- mod.offset = 0
- obj["BoolToolPolyBrush"] = True
-
- bpy.ops.object.select_all(action="DESELECT")
- bpy.context.view_layer.objects.active = actObj
- bpy.context.view_layer.update()
- actObj.select_set(state=True)
- obj.select_set(state=True)
-
- bpy.context.view_layer.grease_pencil.clear()
- bpy.ops.gpencil.data_unlink()
-
- return {"FINISHED"}
-
- if event.type == "ESC":
- bpy.ops.ed.undo() # remove o Grease Pencil
- self.set_cont_draw(context)
-
- self.report({"INFO"}, "Draw Poly Brush: Operation Cancelled by User")
- return {"CANCELLED"}
-
- return {"RUNNING_MODAL"}
-
- def invoke(self, context, event):
- if context.object:
- self.set_cont_draw(context, start=True)
- context.window_manager.modal_handler_add(self)
- return {"RUNNING_MODAL"}
- else:
- self.report({"WARNING"}, "No active object, could not finish")
- return {"CANCELLED"}
+# TODO
+# class BTool_DrawPolyBrush(Operator):
+# bl_idname = "btool.draw_polybrush"
+# bl_label = "Draw Poly Brush"
+# bl_description = (
+# "Draw Polygonal Mask, can be applied to Canvas > Brush or Directly\n"
+# "Note: ESC to Cancel, Enter to Apply, Right Click to erase the Lines"
+# )
+
+# count = 0
+# store_cont_draw = False
+
+# @classmethod
+# def poll(cls, context):
+# return context.active_object is not None
+
+# def set_cont_draw(self, context, start=False):
+# # store / restore GP continuous drawing (see T52321)
+# scene = context.scene
+# tool_settings = scene.tool_settings
+# continuous = tool_settings.use_gpencil_continuous_drawing
+# if start:
+# self.store_cont_draw = continuous
+# tool_settings.use_gpencil_continuous_drawing = True
+# else:
+# tool_settings.use_gpencil_continuous_drawing = self.store_cont_draw
+
+# def modal(self, context, event):
+# self.count += 1
+# actObj = bpy.context.active_object
+# if self.count == 1:
+# actObj.select_set(state=True)
+# bpy.ops.gpencil.draw("INVOKE_DEFAULT", mode="DRAW_POLY")
+
+# if event.type == "RIGHTMOUSE":
+# # use this to pass to the Grease Pencil eraser (see T52321)
+# pass
+
+# if event.type in {"RET", "NUMPAD_ENTER"}:
+
+# bpy.ops.gpencil.convert(type="POLY")
+# self.set_cont_draw(context)
+
+# for obj in context.selected_objects:
+# if obj.type == "CURVE":
+# obj.name = "PolyDraw"
+# bpy.context.view_layer.objects.active = obj
+# bpy.ops.object.select_all(action="DESELECT")
+# obj.select_set(state=True)
+# bpy.ops.object.convert(target="MESH")
+# bpy.ops.object.mode_set(mode="EDIT")
+# bpy.ops.mesh.select_all(action="SELECT")
+# bpy.ops.mesh.edge_face_add()
+# bpy.ops.mesh.flip_normals()
+# bpy.ops.object.mode_set(mode="OBJECT")
+# bpy.ops.object.origin_set(type="ORIGIN_CENTER_OF_MASS")
+# bpy.ops.object.modifier_add(type="SOLIDIFY")
+# for mod in obj.modifiers:
+# if mod.name == "Solidify":
+# mod.name = "BTool_PolyBrush"
+# mod.thickness = 1
+# mod.offset = 0
+# obj["BoolToolPolyBrush"] = True
+
+# bpy.ops.object.select_all(action="DESELECT")
+# bpy.context.view_layer.objects.active = actObj
+# bpy.context.view_layer.update()
+# actObj.select_set(state=True)
+# obj.select_set(state=True)
+
+# bpy.context.view_layer.grease_pencil.clear()
+# bpy.ops.gpencil.data_unlink()
+
+# return {"FINISHED"}
+
+# if event.type == "ESC":
+# bpy.ops.ed.undo() # remove o Grease Pencil
+# self.set_cont_draw(context)
+
+# self.report({"INFO"}, "Draw Poly Brush: Operation Cancelled by User")
+# return {"CANCELLED"}
+
+# return {"RUNNING_MODAL"}
+
+# def invoke(self, context, event):
+# if context.object:
+# self.set_cont_draw(context, start=True)
+# context.window_manager.modal_handler_add(self)
+# return {"RUNNING_MODAL"}
+# else:
+# self.report({"WARNING"}, "No active object, could not finish")
+# return {"CANCELLED"}
# Fast Transform
@@ -834,30 +834,30 @@ class VIEW3D_MT_booltool_menu(Menu):
layout = self.layout
layout.label(text="Auto Boolean")
- layout.operator(OBJECT_OT_BoolTool_Auto_Difference.bl_idname, text="Difference", icon="PIVOT_ACTIVE")
- layout.operator(OBJECT_OT_BoolTool_Auto_Union.bl_idname, text="Union", icon="PIVOT_INDIVIDUAL")
- layout.operator(OBJECT_OT_BoolTool_Auto_Intersect.bl_idname, text="Intersect", icon="PIVOT_MEDIAN")
- layout.operator(OBJECT_OT_BoolTool_Auto_Slice.bl_idname, text="Slice", icon="PIVOT_MEDIAN")
+ layout.operator(OBJECT_OT_BoolTool_Auto_Difference.bl_idname, text="Difference", icon="SELECT_SUBTRACT")
+ layout.operator(OBJECT_OT_BoolTool_Auto_Union.bl_idname, text="Union", icon="SELECT_EXTEND")
+ layout.operator(OBJECT_OT_BoolTool_Auto_Intersect.bl_idname, text="Intersect", icon="SELECT_INTERSECT")
+ layout.operator(OBJECT_OT_BoolTool_Auto_Slice.bl_idname, text="Slice", icon="SELECT_DIFFERENCE")
layout.separator()
layout.label(text="Brush Boolean")
- layout.operator(BTool_Diff.bl_idname, icon="PIVOT_ACTIVE")
- layout.operator(BTool_Union.bl_idname, icon="PIVOT_INDIVIDUAL")
- layout.operator(BTool_Inters.bl_idname, icon="PIVOT_MEDIAN")
- layout.operator(BTool_Slice.bl_idname, icon="PIVOT_MEDIAN")
+ layout.operator(BTool_Diff.bl_idname, text="Difference", icon="SELECT_SUBTRACT")
+ layout.operator(BTool_Union.bl_idname, text="Union", icon="SELECT_EXTEND")
+ layout.operator(BTool_Inters.bl_idname, text="Intersect", icon="SELECT_INTERSECT")
+ layout.operator(BTool_Slice.bl_idname, text="Slice", icon="SELECT_DIFFERENCE")
if isCanvas(context.active_object):
layout.separator()
layout.operator(BTool_AllBrushToMesh.bl_idname, icon="MOD_LATTICE", text="Apply All")
- Rem = layout.operator(BTool_Remove.bl_idname, icon="CANCEL", text="Remove All")
+ Rem = layout.operator(BTool_Remove.bl_idname, icon="X", text="Remove All")
Rem.thisObj = ""
Rem.Prop = "CANVAS"
if isBrush(context.active_object):
layout.separator()
layout.operator(BTool_BrushToMesh.bl_idname, icon="MOD_LATTICE", text="Apply Brush")
- Rem = layout.operator(BTool_Remove.bl_idname, icon="CANCEL", text="Remove Brush")
+ Rem = layout.operator(BTool_Remove.bl_idname, icon="X", text="Remove Brush")
Rem.thisObj = ""
Rem.Prop = "BRUSH"
@@ -880,40 +880,39 @@ class VIEW3D_PT_booltool_tools(Panel):
def poll(cls, context):
return context.active_object is not None
+ def draw_header(self, context):
+ layout = self.layout
+ layout.operator("wm.booltool_help", text="", icon="QUESTION")
+
def draw(self, context):
layout = self.layout
obj = context.active_object
obs_len = len(context.selected_objects)
- row = layout.row()
- row.alignment = "RIGHT"
- row.scale_x = 1.5
- row.operator("wm.booltool_help", text="", icon="QUESTION")
-
main = layout.column(align=True)
main.enabled = obj.type == "MESH" and obs_len > 0
col = main.column(align=True)
col.enabled = obs_len > 1
- col.label(text="Auto Boolean", icon="MODIFIER")
+ col.label(text="Auto Boolean")
col.separator()
- col.operator(OBJECT_OT_BoolTool_Auto_Difference.bl_idname, text="Difference", icon="PIVOT_ACTIVE")
- col.operator(OBJECT_OT_BoolTool_Auto_Union.bl_idname, text="Union", icon="PIVOT_INDIVIDUAL")
- col.operator(OBJECT_OT_BoolTool_Auto_Intersect.bl_idname, text="Intersect", icon="PIVOT_MEDIAN")
+ col.operator(OBJECT_OT_BoolTool_Auto_Difference.bl_idname, text="Difference", icon="SELECT_SUBTRACT")
+ col.operator(OBJECT_OT_BoolTool_Auto_Union.bl_idname, text="Union", icon="SELECT_EXTEND")
+ col.operator(OBJECT_OT_BoolTool_Auto_Intersect.bl_idname, text="Intersect", icon="SELECT_INTERSECT")
sub = col.column(align=True)
sub.enabled = obs_len == 2
- sub.operator(OBJECT_OT_BoolTool_Auto_Slice.bl_idname, text="Slice", icon="PIVOT_MEDIAN")
+ sub.operator(OBJECT_OT_BoolTool_Auto_Slice.bl_idname, text="Slice", icon="SELECT_DIFFERENCE")
main.separator()
col = main.column(align=True)
col.enabled = obs_len > 1
- col.label(text="Brush Boolean", icon="MODIFIER")
+ col.label(text="Brush Boolean")
col.separator()
- col.operator(BTool_Diff.bl_idname, text="Difference", icon="PIVOT_ACTIVE")
- col.operator(BTool_Union.bl_idname, text="Union", icon="PIVOT_INDIVIDUAL")
- col.operator(BTool_Inters.bl_idname, text="Intersect", icon="PIVOT_MEDIAN")
- col.operator(BTool_Slice.bl_idname, text="Slice", icon="PIVOT_MEDIAN")
+ col.operator(BTool_Diff.bl_idname, text="Difference", icon="SELECT_SUBTRACT")
+ col.operator(BTool_Union.bl_idname, text="Union", icon="SELECT_EXTEND")
+ col.operator(BTool_Inters.bl_idname, text="Intersect", icon="SELECT_INTERSECT")
+ col.operator(BTool_Slice.bl_idname, text="Slice", icon="SELECT_DIFFERENCE")
# TODO Draw Poly Brush
# main.separator()
@@ -933,6 +932,7 @@ class VIEW3D_PT_booltool_config(Panel):
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_context = "objectmode"
+ bl_parent_id = "VIEW3D_PT_booltool_tools"
@classmethod
def poll(cls, context):
@@ -959,7 +959,7 @@ class VIEW3D_PT_booltool_config(Panel):
row.operator(BTool_AllBrushToMesh.bl_idname, icon="MOD_LATTICE", text="Apply All")
row = layout.row(align=True)
- Rem = row.operator(BTool_Remove.bl_idname, icon="CANCEL", text="Remove All")
+ Rem = row.operator(BTool_Remove.bl_idname, icon="X", text="Remove All")
Rem.thisObj = ""
Rem.Prop = "CANVAS"
@@ -969,14 +969,14 @@ class VIEW3D_PT_booltool_config(Panel):
# BRUSH ------------------------------------------------------
if isBrush(actObj):
- if actObj["BoolToolBrush"] == "UNION":
- icon = "PIVOT_INDIVIDUAL"
if actObj["BoolToolBrush"] == "DIFFERENCE":
- icon = "PIVOT_MEDIAN"
- if actObj["BoolToolBrush"] == "INTERSECT":
- icon = "PIVOT_ACTIVE"
- if actObj["BoolToolBrush"] == "SLICE":
- icon = "PIVOT_MEDIAN"
+ icon = "SELECT_SUBTRACT"
+ elif actObj["BoolToolBrush"] == "UNION":
+ icon = "SELECT_EXTEND"
+ elif actObj["BoolToolBrush"] == "INTERSECT":
+ icon = "SELECT_INTERSECT"
+ elif actObj["BoolToolBrush"] == "SLICE":
+ icon = "SELECT_DIFFERENCE"
row = layout.row(align=True)
row.label(text="BRUSH", icon=icon)
@@ -1010,7 +1010,7 @@ class VIEW3D_PT_booltool_config(Panel):
row = layout.row(align=True)
row.operator(BTool_BrushToMesh.bl_idname, icon="MOD_LATTICE", text="Apply Brush")
row = layout.row(align=True)
- Rem = row.operator(BTool_Remove.bl_idname, icon="CANCEL", text="Remove Brush")
+ Rem = row.operator(BTool_Remove.bl_idname, icon="X", text="Remove Brush")
Rem.thisObj = ""
Rem.Prop = "BRUSH"
@@ -1026,6 +1026,7 @@ class VIEW3D_PT_booltool_bviewer(Panel):
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_context = "objectmode"
+ bl_parent_id = "VIEW3D_PT_booltool_tools"
@classmethod
def poll(cls, context):
@@ -1048,14 +1049,14 @@ class VIEW3D_PT_booltool_bviewer(Panel):
row = container.row(align=True)
icon = ""
if "BTool_" in mod.name:
- if mod.operation == "UNION":
- icon = "PIVOT_INDIVIDUAL"
if mod.operation == "DIFFERENCE":
- icon = "PIVOT_MEDIAN"
- if mod.operation == "INTERSECT":
- icon = "PIVOT_ACTIVE"
- if mod.operation == "SLICE":
- icon = "PIVOT_MEDIAN"
+ icon = "SELECT_SUBTRACT"
+ elif mod.operation == "UNION":
+ icon = "SELECT_EXTEND"
+ elif mod.operation == "INTERSECT":
+ icon = "SELECT_INTERSECT"
+ elif mod.operation == "SLICE":
+ icon = "SELECT_DIFFERENCE"
objSelect = row.operator("btool.find_brush", text=mod.object.name, icon=icon, emboss=False)
objSelect.obj = mod.object.name
@@ -1066,7 +1067,7 @@ class VIEW3D_PT_booltool_bviewer(Panel):
Enable = row.operator(BTool_EnableBrush.bl_idname, icon=EnableIcon, emboss=False)
Enable.thisObj = mod.object.name
- Remove = row.operator("btool.remove", icon="CANCEL", emboss=False)
+ Remove = row.operator("btool.remove", icon="X", emboss=False)
Remove.thisObj = mod.object.name
Remove.Prop = "THIS"
@@ -1110,12 +1111,12 @@ class WM_OT_BoolTool_Help(Operator):
layout.separator()
layout.label(text="Auto Boolean:")
- layout.label(text="Apply Boolean operation directly.")
+ layout.label(text="Apply Boolean operation directly to mesh.")
layout.separator()
layout.label(text="Brush Boolean:")
- layout.label(text="Create a Boolean brush setup.")
+ layout.label(text="Create a Boolean brush modifier setup.")
def execute(self, context):
return {"FINISHED"}