You can now remove ports

This commit is contained in:
Dion Moult
2022-05-06 10:35:12 +10:00
parent 4b6ebe7b1c
commit 92432f453d
5 changed files with 47 additions and 1 deletions
@@ -31,6 +31,7 @@ classes = (
operator.EnableEditingSystem,
operator.HidePorts,
operator.LoadSystems,
operator.RemovePort,
operator.RemoveSystem,
operator.SelectSystemProducts,
operator.SetFlowDirection,
@@ -154,13 +154,22 @@ class HidePorts(bpy.types.Operator, Operator):
class AddPort(bpy.types.Operator, Operator):
bl_idname = "bim.add_port"
bl_label = "Add Ports"
bl_label = "Add Port"
bl_options = {"REGISTER", "UNDO"}
def _execute(self, context):
core.add_port(tool.Ifc, tool.System, element=tool.Ifc.get_entity(context.active_object))
class RemovePort(bpy.types.Operator, Operator):
bl_idname = "bim.remove_port"
bl_label = "Remove Port"
bl_options = {"REGISTER", "UNDO"}
def _execute(self, context):
core.remove_port(tool.Ifc, tool.System, port=tool.Ifc.get_entity(context.active_object))
class ConnectPort(bpy.types.Operator, Operator):
bl_idname = "bim.connect_port"
bl_label = "Connect Ports"
@@ -185,6 +185,7 @@ class BIM_PT_port(Panel):
row.operator("bim.set_flow_direction", icon="BACK", text="").direction = "SINK"
row.operator("bim.set_flow_direction", icon="ARROW_LEFTRIGHT", text="").direction = "SOURCEANDSINK"
row.operator("bim.set_flow_direction", icon="RESTRICT_INSTANCED_ON", text="").direction = "NOTDEFINED"
row.operator("bim.remove_port", icon="X", text="")
class BIM_UL_systems(UIList):
+5
View File
@@ -97,6 +97,11 @@ def add_port(ifc, system, element=None):
ifc.run("system.assign_port", element=element, port=port)
def remove_port(ifc, system, port=None):
system.delete_element_objects([port])
ifc.run("root.remove_product", product=port)
def connect_port(ifc, port1=None, port2=None):
ifc.run("system.connect_port", port1=port1, port2=port2)
+30
View File
@@ -92,6 +92,15 @@ class TestSelectSystemProducts:
class TestShowPorts:
def test_run(self, ifc, system):
ifc.get_object("element").should_be_called().will_return("obj")
ifc.is_moved("obj").should_be_called().will_return(False)
system.get_ports("element").should_be_called().will_return(["port"])
system.load_ports("element", ["port"]).should_be_called()
system.select_elements(["port"]).should_be_called()
subject.show_ports(ifc, system, element="element")
def test_syncing_locations_if_objects_moved_prior_to_showing_ports(self, ifc, system):
ifc.get_object("element").should_be_called().will_return("obj")
ifc.is_moved("obj").should_be_called().will_return(True)
system.run_geometry_edit_object_placement(obj="obj").should_be_called()
@@ -104,6 +113,20 @@ class TestShowPorts:
class TestHidePorts:
def test_run(self, ifc, system):
ifc.get_object("element").should_be_called().will_return("obj")
ifc.is_moved("obj").should_be_called().will_return(False)
system.get_ports("element").should_be_called().will_return(["port"])
ifc.get_object("port").should_be_called().will_return("port_obj")
ifc.is_moved("port_obj").should_be_called().will_return(True)
system.run_geometry_edit_object_placement(obj="port_obj").should_be_called()
system.delete_element_objects(["port"]).should_be_called()
subject.hide_ports(ifc, system, element="element")
def test_syncing_locations_if_objects_moved_prior_to_hiding_ports(self, ifc, system):
ifc.get_object("element").should_be_called().will_return("obj")
ifc.is_moved("obj").should_be_called().will_return(True)
system.run_geometry_edit_object_placement(obj="obj").should_be_called()
@@ -128,6 +151,13 @@ class TestAddPort:
subject.add_port(ifc, system, element="element")
class TestRemovePort:
def test_run(self, ifc, system):
system.delete_element_objects(["port"]).should_be_called()
ifc.run("root.remove_product", product="port").should_be_called()
subject.remove_port(ifc, system, port="port")
class TestSetFlowDirection:
def test_run(self, ifc, system):
system.get_connected_port("port").should_be_called().will_return("port2")