pySimBlocks.gui.widgets.diagram_view¶
- class pySimBlocks.gui.widgets.diagram_view.DiagramView[source]¶
Bases:
QGraphicsViewInteractive Qt graphics view for the block diagram canvas.
- group_view_changed¶
- view_stack_changed¶
- add_block(block_instance: BlockInstance, block_layout: dict[str, Any] | None = None) None[source]¶
Add a visual block item to the scene for the given block instance.
- Parameters:
block_instance – The block model to represent visually.
block_layout – Optional dict with position/size hints.
- refresh_block_port(block_instance: BlockInstance) None[source]¶
Refresh the port visuals of the block item for the given instance.
- Parameters:
block_instance – The block whose port items should be refreshed.
- remove_block(block_instance: BlockInstance) None[source]¶
Remove the visual block item for the given instance from the scene.
- Parameters:
block_instance – The block whose visual item should be removed.
- add_connection(connection_instance: ConnectionInstance, points: list[QPointF] | None = None) None[source]¶
Add a visual wire to the scene for the given connection instance.
- Parameters:
connection_instance – The connection model to represent visually.
points – Optional list of intermediate waypoints for the wire.
- remove_connection(connection_instance: ConnectionInstance) None[source]¶
Remove the visual wire for the given connection instance from the scene.
- Parameters:
connection_instance – The connection whose visual item should be removed.
- get_selected_block_instances() list[BlockInstance][source]¶
Return block instances currently selected on the diagram.
- group_item_for_block_drop(block_item: BlockItem) GroupItem | None[source]¶
Return the group under a block’s center, for drag-and-drop membership.
- try_drop_block_onto_group(block_item: BlockItem) bool[source]¶
Add a root-level block to the group it was dropped onto.
- property current_view_group_uid: str | None¶
UID of the innermost group in the current view stack.
Navigate to a breadcrumb depth (0 = root diagram).
Leave a group and its nested views in the navigation stack.
- refresh_manual_boundary_wires() None[source]¶
Rebuild visual-only wires for incomplete group boundaries.
- connection_anchor_for_port_item(port_item: PortItem) QPointF[source]¶
Return the scene anchor for a port, redirecting through group borders when collapsed.
- proxy_item_for_port_item(port_item: PortItem) GroupProxyItem | None[source]¶
Return the proxy that currently owns a port’s routed anchor.
- routing_rect_for_port_item(port_item: PortItem) QRectF[source]¶
Return the obstacle rectangle used when routing wires to a port.
- on_proxy_moved(_proxy_item: GroupProxyItem) None[source]¶
Refresh wires after a group proxy is moved.
- on_connection_route_edited(connection_item: ConnectionItem, old_points: list[QPointF] | None, new_points: list[QPointF] | None) None[source]¶
Record a manual wire route edit on the undo/redo stack.
- get_block_item_from_instance(block_instance: BlockInstance) BlockItem | None[source]¶
Return the visual BlockItem for the given block instance, or None.
- Parameters:
block_instance – The block model to look up.
- Returns:
The corresponding
BlockItem, orNoneif not found.
- create_connection_event(port: PortItem | GroupProxyPortItem | GroupBoundaryPortItem) None[source]¶
Begin a wire-drag interaction from the given port item.
- update_block_param_event(block_instance: BlockInstance, params: dict[str, Any]) None[source]¶
Delegate a parameter update for the given block to the project controller.
- Parameters:
block_instance – The block to update.
params – New parameter dict to apply.
- on_block_moved(block_item: BlockItem) None[source]¶
Mark the project dirty and refresh all wires connected to the moved block.
- Parameters:
block_item – The block item that was repositioned.
- on_block_ports_refreshed(block_item: BlockItem) None[source]¶
Refresh all wire positions after the ports of a block have been updated.
- Parameters:
block_item – The block item whose ports were refreshed.
- dragEnterEvent(event) None[source]¶
Accept drag events that carry text MIME data.
- Parameters:
event – Qt drag-enter event.
- dragMoveEvent(event) None[source]¶
Accept proposed drag-move actions unconditionally.
- Parameters:
event – Qt drag-move event.
- dropEvent(event) None[source]¶
Handle a block drop by adding the corresponding block to the project.
- Parameters:
event – Qt drop event carrying
"category:block_type"text.
- keyPressEvent(event) None[source]¶
Handle keyboard shortcuts for copy, paste, delete, zoom, rotate, and center.
- Parameters:
event – Qt key-press event.
- wheelEvent(event) None[source]¶
Zoom the view when Ctrl is held, otherwise scroll normally.
- Parameters:
event – Qt wheel event.
- mouseMoveEvent(event) None[source]¶
Update the temporary wire endpoint while dragging from a port.
- Parameters:
event – Qt mouse-move event.
- mouseReleaseEvent(event) None[source]¶
Complete or cancel a wire drag on mouse release.
- Parameters:
event – Qt mouse-release event.
- scale_view(factor: float) None[source]¶
Scale the view by
factor, clamped to the allowed zoom range.- Parameters:
factor – Multiplicative zoom factor to apply.
- staticMetaObject = PySide6.QtCore.QMetaObject("DiagramView" inherits "QGraphicsView": Methods: #45 type=Signal, signature=group_view_changed() #46 type=Signal, signature=view_stack_changed() )¶