feat: 暴露布线路径容量属性

dev
Zhaowenlong 3 weeks ago
parent 87d44f8eca
commit 26d227240b

@ -409,6 +409,20 @@ def _ensure_vector_list_property(obj, prop_name, description):
)
def _ensure_integer_property(obj, prop_name, description, value):
if prop_name not in getattr(obj, "PropertiesList", []):
obj.addProperty(
"App::PropertyInteger",
prop_name,
PROPERTY_GROUP,
description,
)
try:
setattr(obj, prop_name, int(value))
except Exception:
setattr(obj, prop_name, 0)
def _set_route_carrier_semantics(obj, project_uuid="", kind=ROUTE_CARRIER_KIND):
TerminalObjects.ensure_string_property(
obj,
@ -438,6 +452,12 @@ def _set_route_carrier_semantics(obj, project_uuid="", kind=ROUTE_CARRIER_KIND):
"Whether routing connections can use this path",
True,
)
_ensure_integer_property(
obj,
"QetRouteCarrierCapacity",
"How many routed wires can reuse this carrier segment before detouring is preferred",
1,
)
return obj

@ -613,6 +613,23 @@ class AutoRoutingTest(unittest.TestCase):
self.assertEqual((0.65, 0.2, 1.0), terminal_access.ViewObject.LineColor)
self.assertEqual("Solid", terminal_access.ViewObject.DrawStyle)
def test_route_carrier_exposes_capacity_property_for_auto_routing(self):
_install_fake_freecad()
terminal_objects, _wiring_objects, routing_network, _auto_routing = _reload_modules()
app = sys.modules["FreeCAD"]
doc = FakeDocument()
terminal_objects.ensure_root_group(doc, "project-1")
carrier = routing_network.create_route_carrier(
doc,
[app.Vector(0, 0, 20), app.Vector(100, 0, 20)],
project_uuid="project-1",
kind="WireDuct",
)
self.assertIn("QetRouteCarrierCapacity", carrier.PropertiesList)
self.assertEqual(1, carrier.QetRouteCarrierCapacity)
def test_route_graph_connects_crossing_carriers_at_intersection(self):
_install_fake_freecad()
terminal_objects, _wiring_objects, routing_network, auto_routing = _reload_modules()

Loading…
Cancel
Save