new connection editing
This commit is contained in:
@@ -235,7 +235,6 @@ class DocumentController(QObject):
|
||||
source: Endpoint,
|
||||
target: Endpoint,
|
||||
*,
|
||||
routing: str = "angled",
|
||||
waypoints: list[QPointF] | None = None,
|
||||
) -> str:
|
||||
if self.active_component_id is None:
|
||||
@@ -246,14 +245,11 @@ class DocumentController(QObject):
|
||||
raise ValueError("A connection endpoint no longer exists")
|
||||
if not PortTypeRegistry.compatible(source_port.type, target_port.type):
|
||||
raise ValueError(f"Cannot connect {source_port.type!r} to {target_port.type!r}")
|
||||
if routing not in {"direct", "angled", "spline"}:
|
||||
raise ValueError(f"Unknown connection routing: {routing}")
|
||||
connection = Connection(
|
||||
str(uuid4()),
|
||||
source,
|
||||
target,
|
||||
properties={
|
||||
"routing": routing,
|
||||
"waypoints": [{"x": point.x(), "y": point.y()} for point in (waypoints or [])],
|
||||
},
|
||||
)
|
||||
@@ -267,7 +263,6 @@ class DocumentController(QObject):
|
||||
end: QPointF,
|
||||
*,
|
||||
text: str = "",
|
||||
routing: str = "angled",
|
||||
waypoints: list[QPointF] | None = None,
|
||||
) -> str:
|
||||
if self.active_component_id is None:
|
||||
@@ -297,16 +292,13 @@ class DocumentController(QObject):
|
||||
layer=-1,
|
||||
properties={
|
||||
**style,
|
||||
"routing": routing,
|
||||
"waypoints": [{"x": point.x(), "y": point.y()} for point in (waypoints or [])],
|
||||
},
|
||||
)
|
||||
self.undo_stack.push(AddAnnotationCommand(self, self.active_component_id, annotation))
|
||||
return annotation.id
|
||||
|
||||
def set_route_waypoints(
|
||||
self, item_kind: str, item_id: str, waypoints: list[QPointF], routing: str | None = None
|
||||
) -> None:
|
||||
def set_route_waypoints(self, item_kind: str, item_id: str, waypoints: list[QPointF]) -> None:
|
||||
item = (
|
||||
self.active_graph.connections
|
||||
if item_kind == "connection"
|
||||
@@ -316,8 +308,6 @@ class DocumentController(QObject):
|
||||
return
|
||||
old = deepcopy(item.properties)
|
||||
new = deepcopy(old)
|
||||
if routing is not None:
|
||||
new["routing"] = routing
|
||||
new["waypoints"] = [{"x": point.x(), "y": point.y()} for point in waypoints]
|
||||
if old != new:
|
||||
self.undo_stack.push(
|
||||
|
||||
Reference in New Issue
Block a user