mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
@@ -474,6 +474,7 @@ class PolylineOperator:
|
|||||||
return context.space_data.type == "VIEW_3D"
|
return context.space_data.type == "VIEW_3D"
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
||||||
self.mousemove_count = 0
|
self.mousemove_count = 0
|
||||||
self.action_count = 0
|
self.action_count = 0
|
||||||
self.visible_objs = []
|
self.visible_objs = []
|
||||||
@@ -509,19 +510,21 @@ class PolylineOperator:
|
|||||||
self.is_typing = False
|
self.is_typing = False
|
||||||
self.snap_angle = None
|
self.snap_angle = None
|
||||||
self.snapping_points = []
|
self.snapping_points = []
|
||||||
self.instructions = """TAB: Cycle Input
|
self.instructions = {
|
||||||
D: Distance Input
|
'Cycle Input': {'icons':True, 'keys': ['EVENT_TAB']},
|
||||||
A: Angle Lock
|
'Distance Input': {'icons':True, 'keys': ['EVENT_D']},
|
||||||
M: Modify Snap Point
|
'Angle Lock': {'icons':True, 'keys': ['EVENT_A']},
|
||||||
C: Close Polyline
|
'Increment Angle': {'icons':True, 'keys': ['EVENT_SHIFT', 'MOUSE_MMB_SCROLL']},
|
||||||
BACKSPACE: Remove Point
|
'Modify Snap Point': {'icons':True, 'keys': ['EVENT_M']},
|
||||||
X, Y: Choose Axis
|
'Close Polyline': {'icons':True, 'keys': ['EVENT_C']},
|
||||||
"""
|
'Remove Point': {'icons':True, 'keys': ['EVENT_BACKSPACE']},
|
||||||
self.snap_info = """
|
}
|
||||||
Snap:
|
|
||||||
Axis:
|
self.info = [
|
||||||
Plane:
|
"Axis: ",
|
||||||
"""
|
"Plane: ",
|
||||||
|
"Snap: ",
|
||||||
|
]
|
||||||
|
|
||||||
self.tool_state = tool.Polyline.create_tool_state()
|
self.tool_state = tool.Polyline.create_tool_state()
|
||||||
|
|
||||||
@@ -586,23 +589,30 @@ class PolylineOperator:
|
|||||||
self.tool_state.axis_method = None
|
self.tool_state.axis_method = None
|
||||||
tool.Blender.update_viewport()
|
tool.Blender.update_viewport()
|
||||||
|
|
||||||
def handle_instructions(self, context: bpy.types.Context, custom_instructions: str = "") -> None:
|
def handle_instructions(self, context: bpy.types.Context, custom_instructions: dict = {}, custom_info: str = "") -> None:
|
||||||
self.snap_info = f"""|
|
self.info = [
|
||||||
Axis: {self.tool_state.axis_method}
|
f"Axis: {self.tool_state.axis_method}",
|
||||||
Plane: {self.tool_state.plane_method}
|
f"Plane: {self.tool_state.plane_method}",
|
||||||
Snap: {self.snapping_points[0][1]}
|
f"Snap: {self.snapping_points[0][1]}",
|
||||||
"""
|
]
|
||||||
instructions = self.instructions + custom_instructions + self.snap_info
|
instructions = self.instructions | custom_instructions if custom_instructions else self.instructions
|
||||||
|
|
||||||
|
infos = self.info + custom_info if custom_info else self.info
|
||||||
|
|
||||||
def draw_instructions(self: bpy.types.Header, context: bpy.types.Context) -> None:
|
def draw_instructions(self: bpy.types.Header, context: bpy.types.Context) -> None:
|
||||||
for line in instructions.splitlines():
|
for action, settings in instructions.items():
|
||||||
line = line.strip()
|
if settings["icons"]:
|
||||||
split = line.split(":", 1)
|
for key in settings["keys"]:
|
||||||
if (key := split[0]) not in ("TAB", "D", "A", "M", "C", "E", "BACKSPACE"):
|
self.layout.label(text="", icon=key)
|
||||||
self.layout.label(text=line)
|
self.layout.label(text=action)
|
||||||
continue
|
else:
|
||||||
|
key = settings["keys"][0]
|
||||||
|
self.layout.label(text=key+action)
|
||||||
|
|
||||||
self.layout.label(text=split[1], icon=f"EVENT_{key}")
|
self.layout.label(text="|")
|
||||||
|
|
||||||
|
for info in infos:
|
||||||
|
self.layout.label(text=info)
|
||||||
|
|
||||||
context.workspace.status_text_set(draw_instructions)
|
context.workspace.status_text_set(draw_instructions)
|
||||||
|
|
||||||
|
|||||||
@@ -433,6 +433,18 @@ class DrawPolylineWall(bpy.types.Operator, PolylineOperator):
|
|||||||
"""
|
"""
|
||||||
self.handle_instructions(context, wall_config)
|
self.handle_instructions(context, wall_config)
|
||||||
|
|
||||||
|
custom_instructions = {
|
||||||
|
'Choose Axis': {'icons':True, 'keys': ['EVENT_X', 'EVENT_Y']}
|
||||||
|
}
|
||||||
|
|
||||||
|
wall_config = [
|
||||||
|
f"Direction: {props.direction_sense}",
|
||||||
|
f"Offset Type: {props.offset_type}",
|
||||||
|
f"Offset Value: {tool.Polyline.format_input_ui_units(props.offset * self.unit_scale)}",
|
||||||
|
]
|
||||||
|
|
||||||
|
self.handle_instructions(context, custom_instructions, wall_config)
|
||||||
|
|
||||||
self.handle_mouse_move(context, event, should_round=True)
|
self.handle_mouse_move(context, event, should_round=True)
|
||||||
|
|
||||||
self.choose_axis(event)
|
self.choose_axis(event)
|
||||||
|
|||||||
@@ -2388,17 +2388,6 @@ class MeasureTool(bpy.types.Operator, PolylineOperator):
|
|||||||
else:
|
else:
|
||||||
self.input_ui = tool.Polyline.create_input_ui(init_z=True)
|
self.input_ui = tool.Polyline.create_input_ui(init_z=True)
|
||||||
self.input_options = ["D", "A", "X", "Y", "Z"]
|
self.input_options = ["D", "A", "X", "Y", "Z"]
|
||||||
self.instructions = """TAB: Cycle Input
|
|
||||||
D: Distance Input
|
|
||||||
A: Angle Input
|
|
||||||
M: Modify Snap Point
|
|
||||||
C: Close Polyline
|
|
||||||
E: Erase previous polylines
|
|
||||||
BACKSPACE: Remove Point
|
|
||||||
X, Y, Z: Choose Axis
|
|
||||||
S-X, S-Y, S-Z: Choose Plane
|
|
||||||
L: Lock axis
|
|
||||||
"""
|
|
||||||
|
|
||||||
def modal(self, context, event):
|
def modal(self, context, event):
|
||||||
PolylineDecorator.update(event, self.tool_state, self.input_ui, self.snapping_points[0])
|
PolylineDecorator.update(event, self.tool_state, self.input_ui, self.snapping_points[0])
|
||||||
@@ -2410,7 +2399,11 @@ class MeasureTool(bpy.types.Operator, PolylineOperator):
|
|||||||
self.handle_mouse_move(context, event)
|
self.handle_mouse_move(context, event)
|
||||||
return {"PASS_THROUGH"}
|
return {"PASS_THROUGH"}
|
||||||
|
|
||||||
self.handle_instructions(context)
|
custom_instructions = {
|
||||||
|
'Choose Axis': {'icons':True, 'keys': ['EVENT_X', 'EVENT_Y', 'EVENT_Z']},
|
||||||
|
'Choose Plane': {'icons':True, 'keys': ['EVENT_SHIFT', 'EVENT_X', 'EVENT_Y', 'EVENT_Z']},
|
||||||
|
}
|
||||||
|
self.handle_instructions(context, custom_instructions)
|
||||||
|
|
||||||
self.handle_mouse_move(context, event)
|
self.handle_mouse_move(context, event)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user