mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
WIP: Started the input system
This commit is contained in:
committed by
Bruno Perdigão
parent
04a273c720
commit
350df4eee5
@@ -344,6 +344,13 @@ class WallPolylineDecorator:
|
||||
else:
|
||||
self.draw_batch("POINTS", point, decorator_color_selected)
|
||||
|
||||
if snap_prop.snap_type != "Plane":
|
||||
projection_point = [Vector((snap_prop.x, snap_prop.y, 0))] # TODO get height from default container
|
||||
self.draw_batch("POINTS", projection_point, decorator_color_special)
|
||||
edges = [[0, 1]]
|
||||
self.draw_batch("LINES", point + projection_point, decorator_color_selected, edges)
|
||||
self.line_shader.uniform_float("lineWidth", 0.5)
|
||||
|
||||
polyline_data = context.scene.BIMModelProperties.polyline_point
|
||||
polyline_points = []
|
||||
polyline_edges = []
|
||||
|
||||
@@ -300,6 +300,15 @@ class DrawPolylineWall(bpy.types.Operator):
|
||||
self.mousemove_count = 0
|
||||
self.action_count = 0
|
||||
self.visible_objs = None
|
||||
self.number_options = {'0', '1', '2', '3',
|
||||
'4', '5', '6', '7', '8', '9', '.', '-'}
|
||||
self.number_input = []
|
||||
self.number_output = ''
|
||||
self.is_input_on = False
|
||||
self.input_options = {'X', 'Y', 'D', 'A'}
|
||||
self.input_type = ''
|
||||
self.input_value_xy = [None, None]
|
||||
|
||||
|
||||
def get_visible_objects(self, context):
|
||||
depsgraph = context.evaluated_depsgraph_get()
|
||||
@@ -546,6 +555,7 @@ class DrawPolylineWall(bpy.types.Operator):
|
||||
self.snaping_movement(context, event)
|
||||
operator_time = time() - start_time
|
||||
print(f"main function was finished in {operator_time:.2f} seconds")
|
||||
print(len(bpy.context.scene.BIMModelProperties.polyline_point))
|
||||
return {'RUNNING_MODAL'}
|
||||
|
||||
if event.value == 'RELEASE' and event.type == 'LEFTMOUSE':
|
||||
@@ -554,6 +564,35 @@ class DrawPolylineWall(bpy.types.Operator):
|
||||
if event.value == 'RELEASE' and event.type == 'BACK_SPACE':
|
||||
tool.Snaping.remove_last_polyline_point()
|
||||
tool.Blender.update_viewport()
|
||||
|
||||
if event.value == 'PRESS' and event.type == 'I':
|
||||
self.is_input_on = True
|
||||
|
||||
if self.is_input_on:
|
||||
if event.value == 'PRESS' and event.type in self.input_options:
|
||||
self.input_type = event.type
|
||||
self.number_input = []
|
||||
self.number_output = ''
|
||||
|
||||
if self.input_type:
|
||||
if event.ascii and event.ascii in self.number_options:
|
||||
print(self.input_type)
|
||||
self.number_input.append(event.ascii)
|
||||
self.number_output = ''.join(self.number_input)
|
||||
print(self.number_output)
|
||||
|
||||
if event.value == 'PRESS' and event.type in {'RET', 'NUMPAD_ENTER'}:
|
||||
if not None in self.input_value_xy:
|
||||
tool.Snaping.insert_polyline_point(self.input_value_xy[0], self.input_value_xy[1])
|
||||
tool.Blender.update_viewport()
|
||||
self.is_input_on = False
|
||||
if self.number_output and self.input_type == 'X':
|
||||
print("-> ", float(self.number_output))
|
||||
self.input_value_xy[0] = float(self.number_output)
|
||||
if self.number_output and self.input_type == 'Y':
|
||||
print("-> ", float(self.number_output))
|
||||
self.input_value_xy[1] = float(self.number_output)
|
||||
|
||||
|
||||
if event.type in {'MIDDLEMOUSE', 'WHEELUPMOUSE', 'WHEELDOWNMOUSE'}:
|
||||
return {'PASS_THROUGH'}
|
||||
|
||||
@@ -76,14 +76,24 @@ class Snaping(blenderbim.core.tool.Snaping):
|
||||
snap_vertex.snap_type = snap_type
|
||||
|
||||
@classmethod
|
||||
def insert_polyline_point(cls):
|
||||
def insert_polyline_point(cls, x=None, y=None):
|
||||
snap_vertex = bpy.context.scene.BIMModelProperties.snap_mouse_point[0]
|
||||
polyline_data = bpy.context.scene.BIMModelProperties.polyline_point
|
||||
|
||||
polyline_point = bpy.context.scene.BIMModelProperties.polyline_point.add()
|
||||
polyline_point.x = snap_vertex.x
|
||||
polyline_point.y = snap_vertex.y
|
||||
polyline_point.z = 0 # TODO Update to the the default container height
|
||||
print(type(x))
|
||||
print(type(y))
|
||||
if x is not None and y is not None:
|
||||
print("Foi")
|
||||
polyline_point.x = x
|
||||
polyline_point.y = y
|
||||
polyline_point.z = 0 # TODO Update to the the default container height
|
||||
print("PL", polyline_point.x, polyline_point.y)
|
||||
else:
|
||||
polyline_point.x = snap_vertex.x
|
||||
polyline_point.y = snap_vertex.y
|
||||
polyline_point.z = 0 # TODO Update to the the default container height
|
||||
print("PL", polyline_point.x, polyline_point.y)
|
||||
|
||||
@classmethod
|
||||
def clear_polyline(cls):
|
||||
|
||||
Reference in New Issue
Block a user