mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-10 22:16:41 +00:00
Updates on polyline decorator to match standard colors.
This commit is contained in:
@@ -371,13 +371,16 @@ class PolylineDecorator:
|
|||||||
self.line_shader.uniform_float("viewportSize", (context.region.width, context.region.height))
|
self.line_shader.uniform_float("viewportSize", (context.region.width, context.region.height))
|
||||||
self.shader = gpu.shader.from_builtin("UNIFORM_COLOR")
|
self.shader = gpu.shader.from_builtin("UNIFORM_COLOR")
|
||||||
self.line_shader.uniform_float("lineWidth", 0.5)
|
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
|
polyline = context.scene.BIMPolylineProperties.polyline_point
|
||||||
prop = context.scene.BIMPolylineProperties.product_preview
|
prop = context.scene.BIMPolylineProperties.product_preview
|
||||||
|
|
||||||
points = []
|
points = []
|
||||||
edges = []
|
edges = []
|
||||||
|
|
||||||
for i in range(len(prop)):
|
for i in range(len(prop)):
|
||||||
points.append(Vector((prop[i].x, prop[i].y, prop[i].z)))
|
points.append(Vector((prop[i].x, prop[i].y, prop[i].z)))
|
||||||
|
|
||||||
n = len(points) // 2
|
n = len(points) // 2
|
||||||
bottom_loop = [[i, (i + 1) % (n)] for i in range(n)]
|
bottom_loop = [[i, (i + 1) % (n)] for i in range(n)]
|
||||||
edges.extend(bottom_loop)
|
edges.extend(bottom_loop)
|
||||||
@@ -498,6 +501,12 @@ class PolylineDecorator:
|
|||||||
snap_prop = context.scene.BIMPolylineProperties.snap_mouse_point[0]
|
snap_prop = context.scene.BIMPolylineProperties.snap_mouse_point[0]
|
||||||
mouse_point = Vector((snap_prop.x, snap_prop.y, snap_prop.z))
|
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)
|
coords = view3d_utils.location_3d_to_region_2d(region, rv3d, mouse_point)
|
||||||
padding = 6
|
padding = 6
|
||||||
verts = []
|
verts = []
|
||||||
@@ -549,18 +558,12 @@ class PolylineDecorator:
|
|||||||
|
|
||||||
# general shader
|
# general shader
|
||||||
self.shader = gpu.shader.from_builtin("UNIFORM_COLOR")
|
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]
|
snap_prop = context.scene.BIMPolylineProperties.snap_mouse_point[0]
|
||||||
# Point related to the mouse
|
# Point related to the mouse
|
||||||
mouse_point = [Vector((snap_prop.x, snap_prop.y, snap_prop.z))]
|
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
|
default_container_elevation = tool.Ifc.get_object(tool.Root.get_default_container()).location.z
|
||||||
projection_point = []
|
projection_point = []
|
||||||
if self.tool_state and self.tool_state.use_default_container:
|
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))]
|
projection_point = [Vector((snap_prop.x, snap_prop.y, default_container_elevation))]
|
||||||
self.draw_batch("POINTS", projection_point, decorator_color_unselected)
|
self.draw_batch("POINTS", projection_point, decorator_color_unselected)
|
||||||
edges = [[0, 1]]
|
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
|
# Create polyline with selected points
|
||||||
polyline_data = context.scene.BIMPolylineProperties.polyline_point
|
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)
|
# self.draw_batch("TRIS", polyline_points, (0, 1, 0, 0.1), edges)
|
||||||
|
|
||||||
# Mouse points
|
# Mouse points
|
||||||
if snap_prop.snap_type in ["Plane"]:
|
print("DECO", snap_prop.snap_type)
|
||||||
self.draw_batch("POINTS", mouse_point, decorator_color)
|
if snap_prop.snap_type in ["Plane", "Axis", "Mix"]:
|
||||||
|
self.draw_batch("POINTS", mouse_point, decorator_color_unselected)
|
||||||
if ref_point:
|
|
||||||
self.draw_batch("POINTS", ref_point, decorator_color_object_active)
|
|
||||||
|
|
||||||
# Line between last polyline point and mouse
|
# Line between last polyline point and mouse
|
||||||
|
self.line_shader.uniform_float("lineWidth", 2.0)
|
||||||
edges = [[0, 1]]
|
edges = [[0, 1]]
|
||||||
if polyline_points:
|
if polyline_points:
|
||||||
if snap_prop.snap_type != "Plane" and projection_point:
|
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:
|
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
|
# Draw polyline with selected points
|
||||||
self.line_shader.uniform_float("lineWidth", 2.0)
|
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:
|
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)
|
||||||
|
|||||||
@@ -500,6 +500,7 @@ class Snap(bonsai.core.tool.Snap):
|
|||||||
if point[1] == "Axis":
|
if point[1] == "Axis":
|
||||||
if snapping_points[0][1] not in {"Axis", "Plane"}:
|
if snapping_points[0][1] not in {"Axis", "Plane"}:
|
||||||
mixed_snap = cls.mix_snap_and_axis(snapping_points[0], axis_start, axis_end)
|
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])
|
cls.update_snapping_point(mixed_snap[0], mixed_snap[1])
|
||||||
return snapping_points
|
return snapping_points
|
||||||
cls.update_snapping_point(point[0], point[1])
|
cls.update_snapping_point(point[0], point[1])
|
||||||
|
|||||||
Reference in New Issue
Block a user