From d868eeb77dba2097cf96e2bf903023b64032112e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Perdig=C3=A3o?= Date: Tue, 24 Sep 2024 17:30:34 -0300 Subject: [PATCH] Updates on polyline decorator to match standard colors. --- .../bonsai/bim/module/model/decorator.py | 38 ++++++++++--------- src/bonsai/bonsai/tool/snap.py | 1 + 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/model/decorator.py b/src/bonsai/bonsai/bim/module/model/decorator.py index e5ce831bff..57dd3bf2e7 100644 --- a/src/bonsai/bonsai/bim/module/model/decorator.py +++ b/src/bonsai/bonsai/bim/module/model/decorator.py @@ -371,13 +371,16 @@ class PolylineDecorator: self.line_shader.uniform_float("viewportSize", (context.region.width, context.region.height)) self.shader = gpu.shader.from_builtin("UNIFORM_COLOR") self.line_shader.uniform_float("lineWidth", 0.5) - decorator_color = self.addon_prefs.decorations_colour + decorator_color = self.addon_prefs.decorator_color_special polyline = context.scene.BIMPolylineProperties.polyline_point prop = context.scene.BIMPolylineProperties.product_preview + points = [] edges = [] + for i in range(len(prop)): points.append(Vector((prop[i].x, prop[i].y, prop[i].z))) + n = len(points) // 2 bottom_loop = [[i, (i + 1) % (n)] for i in range(n)] edges.extend(bottom_loop) @@ -498,6 +501,12 @@ class PolylineDecorator: snap_prop = context.scene.BIMPolylineProperties.snap_mouse_point[0] mouse_point = Vector((snap_prop.x, snap_prop.y, snap_prop.z)) + try: + snap_prop = context.scene.BIMPolylineProperties.snap_mouse_ref[0] + mouse_point = Vector((snap_prop.x, snap_prop.y, snap_prop.z)) + except: + pass + coords = view3d_utils.location_3d_to_region_2d(region, rv3d, mouse_point) padding = 6 verts = [] @@ -549,18 +558,12 @@ class PolylineDecorator: # general shader self.shader = gpu.shader.from_builtin("UNIFORM_COLOR") - gpu.state.point_size_set(10) + gpu.state.point_size_set(6) snap_prop = context.scene.BIMPolylineProperties.snap_mouse_point[0] # Point related to the mouse mouse_point = [Vector((snap_prop.x, snap_prop.y, snap_prop.z))] - try: - snap_ref = context.scene.BIMPolylineProperties.snap_mouse_ref[0] - ref_point = [Vector((snap_ref.x, snap_ref.y, snap_ref.z))] - except: - ref_point = None - default_container_elevation = tool.Ifc.get_object(tool.Root.get_default_container()).location.z projection_point = [] if self.tool_state and self.tool_state.use_default_container: @@ -571,7 +574,7 @@ class PolylineDecorator: projection_point = [Vector((snap_prop.x, snap_prop.y, default_container_elevation))] self.draw_batch("POINTS", projection_point, decorator_color_unselected) edges = [[0, 1]] - self.draw_batch("LINES", mouse_point + projection_point, (1.0, 0.6, 0.0, 1.0), edges) + self.draw_batch("LINES", mouse_point + projection_point, decorator_color_unselected, edges) # Create polyline with selected points polyline_data = context.scene.BIMPolylineProperties.polyline_point @@ -617,22 +620,21 @@ class PolylineDecorator: # self.draw_batch("TRIS", polyline_points, (0, 1, 0, 0.1), edges) # Mouse points - if snap_prop.snap_type in ["Plane"]: - self.draw_batch("POINTS", mouse_point, decorator_color) - - if ref_point: - self.draw_batch("POINTS", ref_point, decorator_color_object_active) + print("DECO", snap_prop.snap_type) + if snap_prop.snap_type in ["Plane", "Axis", "Mix"]: + self.draw_batch("POINTS", mouse_point, decorator_color_unselected) # Line between last polyline point and mouse + self.line_shader.uniform_float("lineWidth", 2.0) edges = [[0, 1]] if polyline_points: if snap_prop.snap_type != "Plane" and projection_point: - self.draw_batch("LINES", [polyline_points[-1]] + projection_point, decorator_color, edges) + self.draw_batch("LINES", [polyline_points[-1]] + projection_point, decorator_color_selected, edges) else: - self.draw_batch("LINES", [polyline_points[-1]] + mouse_point, decorator_color, edges) + self.draw_batch("LINES", [polyline_points[-1]] + mouse_point, decorator_color_selected, edges) # Draw polyline with selected points self.line_shader.uniform_float("lineWidth", 2.0) - self.draw_batch("POINTS", polyline_points, decorator_color_special) + self.draw_batch("POINTS", polyline_points, decorator_color_unselected) if len(polyline_points) > 1: - self.draw_batch("LINES", polyline_points, decorator_color_special, polyline_edges) + self.draw_batch("LINES", polyline_points, decorator_color_unselected, polyline_edges) diff --git a/src/bonsai/bonsai/tool/snap.py b/src/bonsai/bonsai/tool/snap.py index 0b178f400b..7ffbbf6806 100644 --- a/src/bonsai/bonsai/tool/snap.py +++ b/src/bonsai/bonsai/tool/snap.py @@ -500,6 +500,7 @@ class Snap(bonsai.core.tool.Snap): if point[1] == "Axis": if snapping_points[0][1] not in {"Axis", "Plane"}: mixed_snap = cls.mix_snap_and_axis(snapping_points[0], axis_start, axis_end) + snapping_points.insert(0, (mixed_snap[0], mixed_snap[1])) cls.update_snapping_point(mixed_snap[0], mixed_snap[1]) return snapping_points cls.update_snapping_point(point[0], point[1])