mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 04:00:08 +00:00
black format
This commit is contained in:
@@ -353,15 +353,12 @@ class PolylineDecorator:
|
|||||||
def set_tool_state(cls, tool_state):
|
def set_tool_state(cls, tool_state):
|
||||||
cls.tool_state = tool_state
|
cls.tool_state = tool_state
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def draw_batch(self, shader_type, content_pos, color, indices=None):
|
def draw_batch(self, shader_type, content_pos, color, indices=None):
|
||||||
shader = self.line_shader if shader_type == "LINES" else self.shader
|
shader = self.line_shader if shader_type == "LINES" else self.shader
|
||||||
batch = batch_for_shader(shader, shader_type, {"pos": content_pos}, indices=indices)
|
batch = batch_for_shader(shader, shader_type, {"pos": content_pos}, indices=indices)
|
||||||
shader.uniform_float("color", color)
|
shader.uniform_float("color", color)
|
||||||
batch.draw(shader)
|
batch.draw(shader)
|
||||||
|
|
||||||
|
|
||||||
def draw_input_ui(self, context):
|
def draw_input_ui(self, context):
|
||||||
texts = {
|
texts = {
|
||||||
"D": "Distance: ",
|
"D": "Distance: ",
|
||||||
@@ -373,7 +370,6 @@ class PolylineDecorator:
|
|||||||
}
|
}
|
||||||
mouse_pos = self.event.mouse_region_x, self.event.mouse_region_y
|
mouse_pos = self.event.mouse_region_x, self.event.mouse_region_y
|
||||||
|
|
||||||
|
|
||||||
self.addon_prefs = tool.Blender.get_addon_preferences()
|
self.addon_prefs = tool.Blender.get_addon_preferences()
|
||||||
self.font_id = 0
|
self.font_id = 0
|
||||||
font_size = tool.Blender.scale_font_size(12)
|
font_size = tool.Blender.scale_font_size(12)
|
||||||
@@ -400,7 +396,6 @@ class PolylineDecorator:
|
|||||||
blf.position(self.font_id, mouse_pos[0] + offset, mouse_pos[1] - (new_line * i), 0)
|
blf.position(self.font_id, mouse_pos[0] + offset, mouse_pos[1] - (new_line * i), 0)
|
||||||
blf.draw(self.font_id, field_name + formatted_value)
|
blf.draw(self.font_id, field_name + formatted_value)
|
||||||
|
|
||||||
|
|
||||||
def draw_measurements(self, context):
|
def draw_measurements(self, context):
|
||||||
region = context.region
|
region = context.region
|
||||||
rv3d = region.data
|
rv3d = region.data
|
||||||
@@ -433,8 +428,6 @@ class PolylineDecorator:
|
|||||||
blf.position(self.font_id, coords_angle[0], coords_angle[1], 0)
|
blf.position(self.font_id, coords_angle[0], coords_angle[1], 0)
|
||||||
blf.draw(self.font_id, "a: " + measurement_prop[i].angle)
|
blf.draw(self.font_id, "a: " + measurement_prop[i].angle)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def __call__(self, context):
|
def __call__(self, context):
|
||||||
|
|
||||||
self.addon_prefs = tool.Blender.get_addon_preferences()
|
self.addon_prefs = tool.Blender.get_addon_preferences()
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ class PolylineOperator:
|
|||||||
Snap: {self.snapping_points[0][1]}
|
Snap: {self.snapping_points[0][1]}
|
||||||
"""
|
"""
|
||||||
context.workspace.status_text_set(self.instructions + self.snap_info)
|
context.workspace.status_text_set(self.instructions + self.snap_info)
|
||||||
|
|
||||||
def handle_keyboard_input(self, context, event):
|
def handle_keyboard_input(self, context, event):
|
||||||
|
|
||||||
if self.tool_state.is_input_on and event.value == "PRESS" and event.type == "TAB":
|
if self.tool_state.is_input_on and event.value == "PRESS" and event.type == "TAB":
|
||||||
@@ -331,7 +331,6 @@ class PolylineOperator:
|
|||||||
tool.Snap.remove_last_polyline_point()
|
tool.Snap.remove_last_polyline_point()
|
||||||
tool.Blender.update_viewport()
|
tool.Blender.update_viewport()
|
||||||
|
|
||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
PolylineDecorator.install(context)
|
PolylineDecorator.install(context)
|
||||||
tool.Snap.clear_snapping_point()
|
tool.Snap.clear_snapping_point()
|
||||||
|
|||||||
@@ -335,7 +335,11 @@ class DrawPolylineWall(bpy.types.Operator, PolylineOperator):
|
|||||||
|
|
||||||
self.handle_snap_selection(context, event)
|
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"}:
|
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)
|
self.create_walls_from_polyline(context)
|
||||||
context.workspace.status_text_set(text=None)
|
context.workspace.status_text_set(text=None)
|
||||||
PolylineDecorator.uninstall()
|
PolylineDecorator.uninstall()
|
||||||
|
|||||||
@@ -2308,7 +2308,11 @@ class MeasureTool(bpy.types.Operator, PolylineOperator):
|
|||||||
|
|
||||||
self.handle_snap_selection(context, event)
|
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"}:
|
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)
|
context.workspace.status_text_set(text=None)
|
||||||
PolylineDecorator.uninstall()
|
PolylineDecorator.uninstall()
|
||||||
tool.Snap.clear_polyline()
|
tool.Snap.clear_polyline()
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ from bonsai.bim.module.drawing.helper import format_distance
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from lark import Lark, Transformer
|
from lark import Lark, Transformer
|
||||||
from math import radians
|
from math import radians
|
||||||
from mathutils import Vector
|
from mathutils import Vector
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
@@ -66,8 +66,8 @@ class Polyline(bonsai.core.tool.Polyline):
|
|||||||
context = bpy.context
|
context = bpy.context
|
||||||
if value is None:
|
if value is None:
|
||||||
return None
|
return None
|
||||||
if attribute_name == 'A':
|
if attribute_name == "A":
|
||||||
value = float(self.get_text_value(attribute_name))
|
value = float(self.get_text_value(attribute_name))
|
||||||
return f"{value:.2f}"
|
return f"{value:.2f}"
|
||||||
else:
|
else:
|
||||||
return self.format_input_ui_units(context, value)
|
return self.format_input_ui_units(context, value)
|
||||||
@@ -277,7 +277,6 @@ class Polyline(bonsai.core.tool.Polyline):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def validate_input(cls, input_number, input_type):
|
def validate_input(cls, input_number, input_type):
|
||||||
|
|
||||||
|
|||||||
@@ -301,7 +301,9 @@ class Snap(bonsai.core.tool.Snap):
|
|||||||
view_direction = Vector((0, 0, -1)) @ camera_rotation.to_matrix().transposed()
|
view_direction = Vector((0, 0, -1)) @ camera_rotation.to_matrix().transposed()
|
||||||
plane_normal = view_direction.normalized()
|
plane_normal = view_direction.normalized()
|
||||||
|
|
||||||
if tool_state.plane_method == "XY" or (not tool_state.plane_method and tool_state.axis_method in {"X", "Y"}):
|
if tool_state.plane_method == "XY" or (
|
||||||
|
not tool_state.plane_method and tool_state.axis_method in {"X", "Y"}
|
||||||
|
):
|
||||||
if cls.tool_state.use_default_container:
|
if cls.tool_state.use_default_container:
|
||||||
plane_origin = Vector((0, 0, elevation))
|
plane_origin = Vector((0, 0, elevation))
|
||||||
elif not last_polyline_point:
|
elif not last_polyline_point:
|
||||||
@@ -425,7 +427,9 @@ class Snap(bonsai.core.tool.Snap):
|
|||||||
# Doesn't update snap_angle so that it keeps in the same axis
|
# Doesn't update snap_angle so that it keeps in the same axis
|
||||||
rot_intersection, _, axis_start, axis_end = cls.snap_on_axis(intersection, tool_state, True)
|
rot_intersection, _, axis_start, axis_end = cls.snap_on_axis(intersection, tool_state, True)
|
||||||
else:
|
else:
|
||||||
rot_intersection, tool_state.snap_angle, axis_start, axis_end = cls.snap_on_axis(intersection, tool_state, False)
|
rot_intersection, tool_state.snap_angle, axis_start, axis_end = cls.snap_on_axis(
|
||||||
|
intersection, tool_state, False
|
||||||
|
)
|
||||||
if rot_intersection:
|
if rot_intersection:
|
||||||
detected_snaps.append({"Axis": (rot_intersection, axis_start, axis_end)})
|
detected_snaps.append({"Axis": (rot_intersection, axis_start, axis_end)})
|
||||||
|
|
||||||
@@ -466,7 +470,6 @@ class Snap(bonsai.core.tool.Snap):
|
|||||||
snapping_points.append(op)
|
snapping_points.append(op)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
for origin in detected_snaps:
|
for origin in detected_snaps:
|
||||||
if "Axis" in list(origin.keys()):
|
if "Axis" in list(origin.keys()):
|
||||||
intersection = origin["Axis"]
|
intersection = origin["Axis"]
|
||||||
@@ -498,4 +501,3 @@ class Snap(bonsai.core.tool.Snap):
|
|||||||
shifted_list = snapping_points[1:] + snapping_points[:1]
|
shifted_list = snapping_points[1:] + snapping_points[:1]
|
||||||
cls.update_snapping_point(shifted_list[0][0], shifted_list[0][1])
|
cls.update_snapping_point(shifted_list[0][0], shifted_list[0][1])
|
||||||
return shifted_list
|
return shifted_list
|
||||||
|
|
||||||
|
|||||||
@@ -535,7 +535,7 @@ class Web(bonsai.core.tool.Web):
|
|||||||
"cost_items": json_data,
|
"cost_items": json_data,
|
||||||
"cost_schedule_id": cost_schedule.id(),
|
"cost_schedule_id": cost_schedule.id(),
|
||||||
"currency": tool.Cost.currency(),
|
"currency": tool.Cost.currency(),
|
||||||
},
|
},
|
||||||
data_key="cost_items",
|
data_key="cost_items",
|
||||||
event="cost_items",
|
event="cost_items",
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user