mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
Instructions in polyline tools were moved to the status bar.
Previously the instructions were shown on screen with decorators. Now it is handled by the modal function of the polyline tools.
This commit is contained in:
@@ -316,9 +316,6 @@ class PolylineDecorator:
|
||||
if cls.is_installed:
|
||||
cls.uninstall()
|
||||
handler = cls()
|
||||
cls.handlers.append(
|
||||
SpaceView3D.draw_handler_add(handler.draw_on_screen_menu, (context,), "WINDOW", "POST_PIXEL")
|
||||
)
|
||||
cls.handlers.append(SpaceView3D.draw_handler_add(handler.draw_measurements, (context,), "WINDOW", "POST_PIXEL"))
|
||||
cls.handlers.append(SpaceView3D.draw_handler_add(handler.draw_input_ui, (context,), "WINDOW", "POST_PIXEL"))
|
||||
cls.handlers.append(SpaceView3D.draw_handler_add(handler, (context,), "WINDOW", "POST_VIEW"))
|
||||
@@ -338,9 +335,6 @@ class PolylineDecorator:
|
||||
cls.event = event
|
||||
cls.tool_state = tool_state
|
||||
cls.input_ui = input_ui
|
||||
cls.snap_info = f"""Snap: {snapping_point[1]}
|
||||
Axis:{tool_state.axis_method}
|
||||
Plane: {tool_state.plane_method}"""
|
||||
|
||||
@classmethod
|
||||
def set_input_ui(cls, input_ui):
|
||||
@@ -440,27 +434,6 @@ class PolylineDecorator:
|
||||
blf.draw(self.font_id, "a: " + measurement_prop[i].angle)
|
||||
|
||||
|
||||
def draw_on_screen_menu(self, context):
|
||||
region = context.region
|
||||
|
||||
self.addon_prefs = tool.Blender.get_addon_preferences()
|
||||
self.font_id = 2
|
||||
font_size = tool.Blender.scale_font_size(12)
|
||||
blf.size(self.font_id, font_size)
|
||||
blf.enable(self.font_id, blf.SHADOW)
|
||||
blf.shadow(self.font_id, 6, 0, 0, 0, 1)
|
||||
color = self.addon_prefs.decorations_colour
|
||||
blf.color(self.font_id, *color)
|
||||
|
||||
text_w, text_h = blf.dimensions(0, self.tool_state.instructions)
|
||||
position = (region.width / 2) - (text_w / 2)
|
||||
blf.position(self.font_id, position, 10, 0)
|
||||
blf.draw(self.font_id, self.tool_state.instructions)
|
||||
|
||||
text_w, text_h = blf.dimensions(0, self.snap_info)
|
||||
position = (region.width / 2) - (text_w / 2)
|
||||
blf.position(self.font_id, position, 30, 0)
|
||||
blf.draw(self.font_id, self.snap_info)
|
||||
|
||||
def __call__(self, context):
|
||||
|
||||
|
||||
@@ -88,12 +88,20 @@ class PolylineOperator:
|
||||
self.snap_angle = None
|
||||
self.snapping_points = []
|
||||
self.instructions = """TAB: Cycle Input
|
||||
M: Modify Snap Point
|
||||
C: Close
|
||||
Backspace: Remove
|
||||
X Y: Axis
|
||||
Shift: Lock axis
|
||||
"""
|
||||
D: Distance Input
|
||||
A: Angle Input
|
||||
M: Modify Snap Point
|
||||
C: Close Polyline
|
||||
BACKSPACE: Remove Point
|
||||
X, Y: Choose Axis
|
||||
SHIFT: Lock axis
|
||||
"""
|
||||
self.snap_info = """
|
||||
Snap:
|
||||
Axis:
|
||||
Plane:
|
||||
"""
|
||||
|
||||
self.tool_state = tool.Polyline.create_tool_state()
|
||||
|
||||
def recalculate_inputs(self, context):
|
||||
@@ -154,6 +162,14 @@ class PolylineOperator:
|
||||
self.tool_state.axis_method = None
|
||||
tool.Blender.update_viewport()
|
||||
|
||||
def handle_instructions(self, context):
|
||||
self.snap_info = f"""|
|
||||
Axis: {self.tool_state.axis_method}
|
||||
Plane: {self.tool_state.plane_method}
|
||||
Snap: {self.snapping_points[0][1]}
|
||||
"""
|
||||
context.workspace.status_text_set(self.instructions + self.snap_info)
|
||||
|
||||
def handle_keyboard_input(self, context, event):
|
||||
|
||||
if self.tool_state.is_input_on and event.value == "PRESS" and event.type == "TAB":
|
||||
@@ -279,6 +295,7 @@ class PolylineOperator:
|
||||
else:
|
||||
if event.value == "RELEASE" and event.type in {"ESC"}:
|
||||
self.tool_state.axis_method = None
|
||||
context.workspace.status_text_set(text=None)
|
||||
PolylineDecorator.uninstall()
|
||||
tool.Snap.clear_polyline()
|
||||
tool.Blender.update_viewport()
|
||||
|
||||
@@ -327,6 +327,8 @@ class DrawPolylineWall(bpy.types.Operator, PolylineOperator):
|
||||
if event.type in {"MIDDLEMOUSE", "WHEELUPMOUSE", "WHEELDOWNMOUSE"}:
|
||||
return {"PASS_THROUGH"}
|
||||
|
||||
self.handle_instructions(context)
|
||||
|
||||
self.handle_mouse_move(context, event)
|
||||
|
||||
self.choose_axis(event)
|
||||
@@ -335,6 +337,7 @@ class DrawPolylineWall(bpy.types.Operator, PolylineOperator):
|
||||
|
||||
if not self.tool_state.is_input_on and event.value == "RELEASE" and event.type in {"RET", "NUMPAD_ENTER", "RIGHTMOUSE"}:
|
||||
self.create_walls_from_polyline(context)
|
||||
context.workspace.status_text_set(text=None)
|
||||
PolylineDecorator.uninstall()
|
||||
tool.Snap.clear_polyline()
|
||||
tool.Blender.update_viewport()
|
||||
|
||||
@@ -2283,18 +2283,22 @@ class MeasureTool(bpy.types.Operator, PolylineOperator):
|
||||
self.input_ui = tool.Polyline.create_input_ui(init_z=True)
|
||||
self.input_options = ["D", "A", "X", "Y", "Z"]
|
||||
self.instructions = """TAB: Cycle Input
|
||||
M: Modify Snap Point
|
||||
C: Close
|
||||
Backspace: Remove
|
||||
X Y Z: Axis
|
||||
S-(X Y Z): Plane
|
||||
Shift: Lock axis
|
||||
"""
|
||||
D: Distance Input
|
||||
A: Angle Input
|
||||
M: Modify Snap Point
|
||||
C: Close Polyline
|
||||
BACKSPACE: Remove Point
|
||||
X, Y, Z: Choose Axis
|
||||
S-X, S-Y, S-Z: Choose Plane
|
||||
SHIFT: Lock axis
|
||||
"""
|
||||
|
||||
def modal(self, context, event):
|
||||
if event.type in {"MIDDLEMOUSE", "WHEELUPMOUSE", "WHEELDOWNMOUSE"}:
|
||||
return {"PASS_THROUGH"}
|
||||
|
||||
self.handle_instructions(context)
|
||||
|
||||
self.handle_mouse_move(context, event)
|
||||
|
||||
self.choose_axis(event, z=True)
|
||||
@@ -2304,6 +2308,7 @@ class MeasureTool(bpy.types.Operator, PolylineOperator):
|
||||
self.handle_snap_selection(context, event)
|
||||
|
||||
if not self.tool_state.is_input_on and event.value == "RELEASE" and event.type in {"RET", "NUMPAD_ENTER", "RIGHTMOUSE"}:
|
||||
context.workspace.status_text_set(text=None)
|
||||
PolylineDecorator.uninstall()
|
||||
tool.Snap.clear_polyline()
|
||||
tool.Blender.update_viewport()
|
||||
|
||||
Reference in New Issue
Block a user