Moving operators to Spatial Tool

Changes:
- Moved Shift A "Add boundary" from BIM Tool to Spatial Tool
- Moved Alt B "Show boundaries" from BIM Tool to Spatial Tool
This commit is contained in:
Andrej730
2023-06-02 18:20:11 +05:00
parent e7509ccc3f
commit 2ab4213e01
5 changed files with 43 additions and 25 deletions
@@ -106,7 +106,6 @@ classes = (
prop.BIMDoorProperties,
prop.BIMRailingProperties,
prop.BIMRoofProperties,
ui.BIM_PT_authoring,
ui.BIM_PT_array,
ui.BIM_PT_stair,
ui.BIM_PT_sverchok,
@@ -185,7 +185,7 @@ class GenerateSpacesFromWalls(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.generate_spaces_from_walls"
bl_label = "Generate Spaces From Walls"
bl_options = {"REGISTER", "UNDO"}
bl_description = "Generate spaces from selected walls. The active object must be a wall."
bl_description = "Generate spaces from selected walls. The active object must be a wall"
@classmethod
def poll(cls, context):
@@ -57,7 +57,6 @@ class BimTool(WorkSpaceTool):
("bim.hotkey", {"type": "V", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_V")]}),
("bim.hotkey", {"type": "X", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_X")]}),
("bim.hotkey", {"type": "Y", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_Y")]}),
("bim.hotkey", {"type": "B", "value": "PRESS", "alt": True}, {"properties": [("hotkey", "A_B")]}),
("bim.hotkey", {"type": "D", "value": "PRESS", "alt": True}, {"properties": [("hotkey", "A_D")]}),
("bim.hotkey", {"type": "E", "value": "PRESS", "alt": True}, {"properties": [("hotkey", "A_E")]}),
("bim.hotkey", {"type": "O", "value": "PRESS", "alt": True}, {"properties": [("hotkey", "A_O")]}),
@@ -271,12 +270,6 @@ class BimToolUI:
else:
row.operator("bim.show_openings", icon="HIDE_OFF", text="")
row = cls.layout.row(align=True)
row.label(text="", icon="EVENT_SHIFT")
row.label(text="", icon="EVENT_B")
row.prop(cls.props, "boundary_class", text="")
row.operator("bim.add_boundary", text="Add Boundary")
cls.layout.row(align=True).label(text="Align")
add_layout_hotkey_operator(cls.layout, "Align Exterior", "S_X", "")
add_layout_hotkey_operator(cls.layout, "Align Centerline", "S_C", "")
@@ -286,7 +279,6 @@ class BimToolUI:
cls.layout.row(align=True).label(text="Mode")
add_layout_hotkey_operator(cls.layout, "Void", "A_O", "Toggle openings")
add_layout_hotkey_operator(cls.layout, "Decomposition", "A_D", "Select decomposition")
add_layout_hotkey_operator(cls.layout, "Boundaries", "A_B", "Toggle boundaries")
@classmethod
def draw_header_interface(cls):
@@ -602,14 +594,6 @@ class Hotkey(bpy.types.Operator, tool.Ifc.Operator):
self.props.y = self.y
self.props.z = self.z
def hotkey_A_B(self):
if not bpy.context.selected_objects:
return
if AuthoringData.data["has_visible_boundaries"]:
bpy.ops.bim.hide_boundaries()
else:
bpy.ops.bim.show_boundaries()
def hotkey_A_D(self):
if not bpy.context.selected_objects:
return
@@ -21,6 +21,7 @@ import os
import bpy
import blenderbim.tool as tool
from blenderbim.bim.helper import prop_with_search
from blenderbim.bim.module.model.data import AuthoringData
from bpy.types import WorkSpaceTool
from blenderbim.bim.ifc import IfcStore
import blenderbim.bim.handler
@@ -41,10 +42,12 @@ class SpatialTool(WorkSpaceTool):
bl_label = "Spatial Tool"
bl_description = "Gives you Spatial related superpowers"
# TODO: replace with spatial icon
bl_icon = os.path.join(os.path.dirname(__file__), "ops.authoring.annotation")
bl_icon = os.path.join(os.path.dirname(__file__), "ops.authoring.spatial")
bl_widget = None
bl_keymap = tool.Blender.get_default_selection_keypmap() + (
("bim.spatial_hotkey", {"type": "B", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_B")]}),
("bim.spatial_hotkey", {"type": "A", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_A")]}),
("bim.spatial_hotkey", {"type": "B", "value": "PRESS", "alt": True}, {"properties": [("hotkey", "A_B")]}),
)
def draw_settings(context, layout, ws_tool):
@@ -67,6 +70,7 @@ class SpatialToolUI:
def draw(cls, context, layout):
cls.layout = layout
# cls.props = context.scene.BIMSpatialProperties
cls.model_props = context.scene.BIMModelProperties
row = cls.layout.row(align=True)
if not tool.Ifc.get():
@@ -76,19 +80,34 @@ class SpatialToolUI:
# if not SpatialData.is_loaded:
# SpatialData.load()
if not AuthoringData.is_loaded:
AuthoringData.load()
cls.draw_type_selection_interface(context)
cls.draw_default_interface(context)
if context.active_object and context.selected_objects:
cls.draw_selected_object_interface(context)
cls.draw_default_interface()
@classmethod
def draw_default_interface(cls):
add_layout_hotkey(cls.layout, "Placeholder", "S_A", "Placeholder Operator")
def draw_default_interface(cls, context):
row = cls.layout.row(align=True)
row.label(text="", icon="EVENT_SHIFT")
row.label(text="", icon="EVENT_A")
if context.selected_objects:
row.operator("bim.generate_spaces_from_walls")
else:
row.operator("bim.generate_space")
@classmethod
def draw_selected_object_interface(cls, context):
pass
row = cls.layout.row(align=True)
row.label(text="", icon="EVENT_SHIFT")
row.label(text="", icon="EVENT_B")
row.prop(cls.model_props, "boundary_class", text="")
row.operator("bim.add_boundary", text="Add Boundary")
add_layout_hotkey(cls.layout, "Boundaries", "A_B", "Toggle boundaries")
@classmethod
def draw_type_selection_interface(cls, context):
@@ -123,4 +142,20 @@ class Hotkey(bpy.types.Operator, Operator):
pass
def hotkey_S_A(self):
pass
active_obj = bpy.context.active_object
element = tool.Ifc.get_entity(active_obj)
if element and bpy.context.selected_objects and element.is_a("IfcWall"):
bpy.ops.bim.generate_spaces_from_walls()
else:
bpy.ops.bim.generate_space()
def hotkey_S_B(self):
bpy.ops.bim.add_boundary()
def hotkey_A_B(self):
if not bpy.context.selected_objects:
return
if AuthoringData.data["has_visible_boundaries"]:
bpy.ops.bim.hide_boundaries()
else:
bpy.ops.bim.show_boundaries()
@@ -41,7 +41,7 @@ class StructuralTool(WorkSpaceTool):
bl_label = "Structural Tool"
bl_description = "Gives you Structure related superpowers"
# TODO: replace with structural icon
bl_icon = os.path.join(os.path.dirname(__file__), "ops.authoring.annotation")
bl_icon = os.path.join(os.path.dirname(__file__), "ops.authoring.structural")
bl_widget = None
bl_keymap = tool.Blender.get_default_selection_keypmap() + (
("bim.structural_hotkey", {"type": "A", "value": "PRESS", "shift": True}, {"properties": [("hotkey", "S_A")]}),