spinetoolbox.graphics_items
¶
Classes for drawing graphics items on QGraphicsScene.
authors: |
|
---|---|
date: | 4.4.2018 |
Module Contents¶
-
class
spinetoolbox.graphics_items.
ConnectorButton
(parent, toolbox, position='left')[source]¶ Bases:
PySide2.QtWidgets.QGraphicsRectItem
Connector button graphics item. Used for Link drawing between project items.
Parameters: - parent (QGraphicsItem) – Project item bg rectangle
- toolbox (ToolBoxUI) – QMainWindow instance
- position (str) – Either “top”, “left”, “bottom”, or “right”
-
mousePressEvent
(self, event)[source]¶ Connector button mouse press event. Starts drawing a link.
Parameters: event (QGraphicsSceneMouseEvent) – Event
-
mouseDoubleClickEvent
(self, event)[source]¶ Connector button mouse double click event. Makes sure the LinkDrawer is hidden.
Parameters: event (QGraphicsSceneMouseEvent) – Event
-
class
spinetoolbox.graphics_items.
ExclamationIcon
(parent)[source]¶ Bases:
PySide2.QtSvg.QGraphicsSvgItem
Exclamation icon graphics item. Used to notify that a ProjectItem is missing some configuration.
Parameters: parent (ProjectItemIcon) – the parent item
-
class
spinetoolbox.graphics_items.
NotificationListItem
[source]¶ Bases:
PySide2.QtWidgets.QGraphicsTextItem
Notification list graphics item. Used to show notifications for a ProjectItem
-
class
spinetoolbox.graphics_items.
RankIcon
(parent)[source]¶ Bases:
PySide2.QtWidgets.QGraphicsTextItem
Rank icon graphics item. Used to show the rank of a ProjectItem within its DAG
Parameters: parent (ProjectItemIcon) – the parent item
-
class
spinetoolbox.graphics_items.
ProjectItemIcon
(toolbox, x, y, w, h, project_item, icon_file, icon_color, background_color)[source]¶ Bases:
PySide2.QtWidgets.QGraphicsRectItem
Base class for project item icons drawn in Design View.
Parameters: - toolbox (ToolBoxUI) – QMainWindow instance
- x (float) – Icon x coordinate
- y (float) – Icon y coordinate
- w (float) – Icon width
- h (float) – Icon height
- project_item (ProjectItem) – Item
- icon_file (str) – Path to icon resource
- icon_color (QColor) – Icon’s color
- background_color (QColor) – Background color
-
activate
(self)[source]¶ Adds items to scene and setup graphics effect. Called in the constructor and when re-adding the item to the project in the context of undo/redo.
-
_setup
(self, brush, svg, svg_color)[source]¶ Setup item’s attributes.
Parameters: - brush (QBrush) – Used in filling the background rectangle
- svg (str) – Path to SVG icon file
- svg_color (QColor) – Color of SVG icon
-
update_name_item
(self, new_name)[source]¶ Set a new text to name item. Used when a project item is renamed.
-
set_name_attributes
(self)[source]¶ Set name QGraphicsSimpleTextItem attributes (font, size, position, etc.)
Returns items connector button (QWidget).
-
hoverEnterEvent
(self, event)[source]¶ Sets a drop shadow effect to icon when mouse enters its boundaries.
Parameters: event (QGraphicsSceneMouseEvent) – Event
-
hoverLeaveEvent
(self, event)[source]¶ Disables the drop shadow when mouse leaves icon boundaries.
Parameters: event (QGraphicsSceneMouseEvent) – Event
-
mouseMoveEvent
(self, event)[source]¶ Moves icon(s) while the mouse button is pressed. Update links that are connected to selected icons.
Parameters: event (QGraphicsSceneMouseEvent) – Event
-
update_links_geometry
(self)[source]¶ Updates geometry of connected links to reflect this item’s most recent position.
-
contextMenuEvent
(self, event)[source]¶ Show item context menu.
Parameters: event (QGraphicsSceneMouseEvent) – Mouse event
-
keyPressEvent
(self, event)[source]¶ Handles deleting and rotating the selected item when dedicated keys are pressed.
Parameters: event (QKeyEvent) – Key event
-
itemChange
(self, change, value)[source]¶ Reacts to item removal and position changes.
In particular, destroys the drop shadow effect when the items is removed from a scene and keeps track of item’s movements on the scene.
Parameters: - change (GraphicsItemChange) – a flag signalling the type of the change
- value – a value related to the change
Returns: Whatever super() does with the value parameter
-
class
spinetoolbox.graphics_items.
LinkBase
(toolbox)[source]¶ Bases:
PySide2.QtWidgets.QGraphicsPathItem
Base class for Link and LinkDrawer.
Mainly provides the update_geometry method for ‘drawing’ the link on the scene.
Initializes the instance.
Parameters: toolbox (ToolboxUI) – main UI class instance -
do_update_geometry
(self, curved_links)[source]¶ Sets the path for this item.
Parameters: curved_links (bool) – Whether the path should follow a curvy line or a straight line
-
_make_guide_path
(self, curved_links)[source]¶ Returns a ‘narrow’ path connecting this item’s source and destination.
Parameters: curved_links (bool) – Whether the path should follow a curved line or just a straight line Returns: QPainterPath
-
_points_and_angles_from_path
(self, path)[source]¶ Returns a list of representative points and angles from given path.
Parameters: path (QPainterPath) – Returns: points list(float): angles Return type: list(QPointF)
-
_make_connecting_path
(self, guide_path)[source]¶ Returns a ‘thick’ path connecting source and destination, by following the given ‘guide’ path.
Parameters: guide_path (QPainterPath) – Returns: QPainterPath
-
-
class
spinetoolbox.graphics_items.
Link
(toolbox, src_connector, dst_connector)[source]¶ Bases:
spinetoolbox.graphics_items.LinkBase
A graphics item to represent the connection between two project items.
Parameters: - toolbox (ToolboxUI) – main UI class instance
- src_connector (ConnectorButton) – Source connector button
- dst_connector (ConnectorButton) – Destination connector button
-
make_execution_animation
(self)[source]¶ Returns an animation to play when execution ‘passes’ through this link.
Returns: QVariantAnimation
-
mousePressEvent
(self, e)[source]¶ Ignores event if there’s a connector button underneath, to allow creation of new links.
Parameters: e (QGraphicsSceneMouseEvent) – Mouse event
-
mouseDoubleClickEvent
(self, e)[source]¶ Accepts event if there’s a connector button underneath, to prevent unwanted creation of feedback links.
-
class
spinetoolbox.graphics_items.
LinkDrawer
(toolbox)[source]¶ Bases:
spinetoolbox.graphics_items.LinkBase
An item for drawing links between project items.
Parameters: toolbox (ToolboxUI) – main UI class instance -
start_drawing_at
(self, src_connector)[source]¶ Starts drawing a link from the given connector.
Parameters: src_connector (ConnectorButton) –
-