spinetoolbox.widgets.custom_qgraphicsviews
¶
Classes for custom QGraphicsViews for the Design and Graph views.
- authors
Savolainen (VTT), M. Marin (KTH)
- date
6.2.2018
Module Contents¶
Classes¶
Super class for Design and Entity QGraphicsViews. |
|
QGraphicsView for the Design View. |
- class spinetoolbox.widgets.custom_qgraphicsviews.CustomQGraphicsView(parent)[source]¶
Bases:
PySide2.QtWidgets.QGraphicsView
Super class for Design and Entity QGraphicsViews.
- parent¶
Parent widget
- Type
QWidget
Init CustomQGraphicsView.
- keyPressEvent(self, event)[source]¶
Overridden method. Enable zooming with plus and minus keys (comma resets zoom). Send event downstream to QGraphicsItems if pressed key is not handled here.
- Parameters
event (QKeyEvent) – Pressed key
- mousePressEvent(self, event)[source]¶
Set rubber band selection mode if Control pressed. Enable resetting the zoom factor from the middle mouse button.
- resizeEvent(self, event)[source]¶
Updates zoom if needed when the view is resized.
- Parameters
event (QResizeEvent) – a resize event
- setScene(self, scene)[source]¶
Sets a new scene to this view.
- Parameters
scene (ShrinkingScene) – a new scene
- _update_zoom_limits(self)[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(self, pos)[source]¶
Performs zoom whenever the smooth zoom time line advances.
- _handle_transformation_time_line_finished(self)[source]¶
Cleans up after the smooth transformation time line finishes.
- gentle_zoom(self, 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
- class spinetoolbox.widgets.custom_qgraphicsviews.DesignQGraphicsView(parent)[source]¶
Bases:
CustomQGraphicsView
QGraphicsView for the Design View.
- Parameters
parent (QWidget) – Graph View Form’s (QMainWindow) central widget (self.centralwidget)
- add_icon(self, item_name)[source]¶
Adds project item’s icon to the scene.
- Parameters
item_name (str) – project item’s name
- remove_icon(self, item_name)[source]¶
Removes project item’s icon from scene.
- Parameters
item_name (str) – name of the icon to remove
- add_link(self, 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
- make_link(self, src_connector, dst_connector, connection=None)[source]¶
Constructs a Link between given connectors.
- Parameters
src_connector (ConnectorButton) – Source connector button
dst_connector (ConnectorButton) – Destination connector button
connection (Connection, optional) – Underlying connection
- Returns
new link
- Return type
- do_add_link(self, connection)[source]¶
Adds given connection to the Design view.
- Parameters
connection (Connection) – the connection to add
- do_replace_link(self, original_connection, new_connection)[source]¶
Replaces a link on the Design view.
- Parameters
original_connection (Connection) – connection that was replaced
new_connection (Connection) – replacing connection
- remove_links(self, links)[source]¶
Pushes a RemoveConnectionsCommand to the Toolbox undo stack.
- Parameters
links (list of Link) – links to remove
- do_remove_link(self, connection)[source]¶
Removes a link from the scene.
- Parameters
connection (Connection) – link’s connection