mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-19 11:43:53 +00:00
adds decorator to angle snap axis
This commit is contained in:
committed by
Bruno Perdigão
parent
17a0face6e
commit
4b4e6fa7e2
@@ -301,6 +301,8 @@ class WallPolylineDecorator:
|
|||||||
mouse_pos = None
|
mouse_pos = None
|
||||||
input_panel = None
|
input_panel = None
|
||||||
input_type = None
|
input_type = None
|
||||||
|
angle_snap_mat = None
|
||||||
|
angle_snap_loc = None
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -331,6 +333,11 @@ class WallPolylineDecorator:
|
|||||||
cls.input_panel = input_panel
|
cls.input_panel = input_panel
|
||||||
cls.input_type = input_type
|
cls.input_type = input_type
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def set_angle_axis_line(cls, angle_snap_mat, angle_snap_loc):
|
||||||
|
cls.angle_snap_mat = angle_snap_mat
|
||||||
|
cls.angle_snap_loc = angle_snap_loc
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def calculate_distance_and_angle(cls, context, is_input_on):
|
def calculate_distance_and_angle(cls, context, is_input_on):
|
||||||
try:
|
try:
|
||||||
@@ -476,9 +483,22 @@ class WallPolylineDecorator:
|
|||||||
|
|
||||||
|
|
||||||
# Line between last polyline point and mouse
|
# Line between last polyline point and mouse
|
||||||
|
|
||||||
edges = [[0, 1]]
|
edges = [[0, 1]]
|
||||||
if snap_prop.snap_type != "Plane" and snap_prop.z != 0:
|
if snap_prop.snap_type != "Plane" and snap_prop.z != 0:
|
||||||
self.draw_batch("LINES", [polyline_points[-1]] + projection_point, decorator_color_unselected, edges)
|
self.draw_batch("LINES", [polyline_points[-1]] + projection_point, decorator_color_unselected, edges)
|
||||||
else:
|
else:
|
||||||
self.draw_batch("LINES", [polyline_points[-1]] + mouse_point, decorator_color_unselected, edges)
|
self.draw_batch("LINES", [polyline_points[-1]] + mouse_point, decorator_color_unselected, edges)
|
||||||
|
|
||||||
|
# Line for angle axis snap
|
||||||
|
print("TYPE", snap_prop.snap_type)
|
||||||
|
if snap_prop.snap_type == 'Axis':
|
||||||
|
length = 1000
|
||||||
|
direction = Vector((1, 0, 0))
|
||||||
|
rot_dir = self.angle_snap_mat.inverted() @ direction
|
||||||
|
start = self.angle_snap_loc + rot_dir * length
|
||||||
|
end = self.angle_snap_loc - rot_dir * length
|
||||||
|
print("START", start)
|
||||||
|
print("END", end)
|
||||||
|
self.line_shader.uniform_float("lineWidth", 1.0)
|
||||||
|
self.draw_batch("LINES", [start, end], decorator_color_unselected, [(0,1)])
|
||||||
|
|
||||||
|
|||||||
@@ -486,7 +486,7 @@ class DrawPolylineWall(bpy.types.Operator):
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
if rot_intersection:
|
if rot_intersection:
|
||||||
tool.Snaping.update_snaping_point(rot_intersection, "Plane")
|
tool.Snaping.update_snaping_point(rot_intersection, "Axis")
|
||||||
else:
|
else:
|
||||||
tool.Snaping.update_snaping_point(intersection, "Plane")
|
tool.Snaping.update_snaping_point(intersection, "Plane")
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
import blenderbim.core.tool
|
import blenderbim.core.tool
|
||||||
|
from blenderbim.bim.module.model.decorator import WallPolylineDecorator
|
||||||
import math
|
import math
|
||||||
import mathutils
|
import mathutils
|
||||||
from mathutils import Matrix, Vector
|
from mathutils import Matrix, Vector
|
||||||
@@ -113,6 +114,7 @@ class Snaping(blenderbim.core.tool.Snaping):
|
|||||||
for i in range(12):
|
for i in range(12):
|
||||||
angle = 30 * i
|
angle = 30 * i
|
||||||
rot_mat = Matrix.Rotation(math.radians(360 - angle), 3, 'Z')
|
rot_mat = Matrix.Rotation(math.radians(360 - angle), 3, 'Z')
|
||||||
|
WallPolylineDecorator.set_angle_axis_line(rot_mat, last_point)
|
||||||
rot_intersection = rot_mat @ translated_intersection
|
rot_intersection = rot_mat @ translated_intersection
|
||||||
print("ROT_INT", rot_intersection)
|
print("ROT_INT", rot_intersection)
|
||||||
is_on_rot_axis = abs(rot_intersection.y) <= 0.60
|
is_on_rot_axis = abs(rot_intersection.y) <= 0.60
|
||||||
|
|||||||
Reference in New Issue
Block a user