spinetoolbox.widgets.custom_qgraphicsviews
Classes for custom QGraphicsViews for the Design and Graph views.
Module Contents
Classes
Super class for Design and Entity QGraphicsViews. |
|
QGraphicsView for the Design View. |
Functions
|
Makes a left-click mouse event that is otherwise close of given event. |
- class spinetoolbox.widgets.custom_qgraphicsviews.CustomQGraphicsView(parent)[source]
Bases:
PySide6.QtWidgets.QGraphicsView
Super class for Design and Entity QGraphicsViews.
- Parameters
parent (QWidget) – parent widget
- keyPressEvent(event)[source]
Enables zooming with plus and minus keys (comma resets zoom).
- Parameters
event (QKeyEvent) – key press event
- mousePressEvent(event)[source]
Sets rubber band selection mode if Control or right mouse button is pressed. Enables resetting the zoom factor from the middle mouse button.
- _drag_duration_passed(mouse_event)[source]
Test is drag duration has passed.
- Parameters
mouse_event (QMouseEvent) – current mouse event
- resizeEvent(event)[source]
Updates zoom if needed when the view is resized.
- Parameters
event (QResizeEvent) – a resize event
- setScene(scene)[source]
Sets a new scene to this view.
- Parameters
scene (DesignGraphicsScene) – a new scene
- _update_zoom_limits()[source]
Updates the minimum zoom limit and the zoom level with which the view fits all the items in the scene.
- _handle_zoom_time_line_advanced(pos)[source]
Performs zoom whenever the smooth zoom time line advances.
- _handle_transformation_time_line_finished()[source]
Cleans up after the smooth transformation time line finishes.
- gentle_zoom(factor, zoom_focus=None)[source]
Perform a zoom by a given factor.
- Parameters
factor (float) – a scaling factor relative to the current scene scaling
zoom_focus (QPoint) – focus of the zoom, e.g. mouse pointer position
- _set_preferred_scene_rect()[source]
Sets the scene rect to the result of uniting the scene viewport rect and the items bounding rect.
Disables the context menu.
Enables the context menu.
- class spinetoolbox.widgets.custom_qgraphicsviews.DesignQGraphicsView(parent)[source]
Bases:
CustomQGraphicsView
QGraphicsView for the Design View.
- Parameters
parent (QWidget) – parent widget
- add_icon(item_name)[source]
Adds project item’s icon to the scene.
- Parameters
item_name (str) – project item’s name
- remove_icon(item_name)[source]
Removes project item’s icon from scene.
- Parameters
item_name (str) – name of the icon to remove
- add_link(src_connector, dst_connector)[source]
Pushes an AddLinkCommand to the toolbox undo stack.
- Parameters
src_connector (ConnectorButton) – source connector button
dst_connector (ConnectorButton) – destination connector button
- do_add_link(connection)[source]
Adds given connection to the Design view.
- Parameters
connection (Connection) – the connection to add
- do_update_link(updated_connection)[source]
Replaces a link on the Design view.
- Parameters
updated_connection (Connection) – connection that was updated
- remove_links(links)[source]
Pushes a RemoveConnectionsCommand to the Toolbox undo stack.
- Parameters
links (list of Link) – links to remove
- do_remove_link(connection)[source]
Removes a link from the scene.
- Parameters
connection (ConnectionBase) – link’s connection
- take_link(link)[source]
Remove link, then start drawing another one from the same source connector.
- add_jump(src_connector, dst_connector)[source]
Pushes an AddJumpCommand to the Toolbox undo stack.
- Parameters
src_connector (ConnectorButton) – source connector button
dst_connector (ConnectorButton) – destination connector button