graphics_items¶
Classes for drawing graphics items on QGraphicsScene.
| authors: |
|
|---|---|
| date: | 4.4.2018 |
Module Contents¶
-
class
graphics_items.ConnectorButton(parent, toolbox, position='left')[source]¶ Bases:
PySide2.QtWidgets.QGraphicsRectItemConnector button graphics item. Used for Link drawing between project items.
-
parent¶ Project item bg rectangle
Type: QGraphicsItem
-
toolbox¶ QMainWindow instance
Type: ToolBoxUI
-
position¶ Either “top”, “left”, “bottom”, or “right”
Type: str
-
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
graphics_items.ProjectItemIcon(toolbox, x, y, w, h, name)[source]¶ Bases:
PySide2.QtWidgets.QGraphicsRectItemBase class for Tool and View project item icons drawn in Design View.
-
toolbox¶ QMainWindow instance
Type: ToolBoxUI
-
x¶ Icon x coordinate
Type: int
-
y¶ Icon y coordinate
Type: int
-
w¶ Icon width
Type: int
-
h¶ Icon height
Type: int
-
setup(self, pen, brush, svg, svg_color)[source]¶ Setup item’s attributes according to project item type. Intended to be called in the constructor’s of classes that inherit from ItemImage class.
Parameters: - pen (QPen) – Used in drawing the background rectangle outline
- brush (QBrush) – Used in filling the background rectangle
- svg (str) – Path to SVG icon file
- svg_color (QColor) – Color of SVG icon
-
name(self)[source] Returns name of the item that is represented by this 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
-
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
-
-
class
graphics_items.DataConnectionIcon(toolbox, x, y, w, h, name)[source]¶ Bases:
graphics_items.ProjectItemIconData Connection icon for the Design View.
-
toolbox¶ QMainWindow instance
Type: ToolBoxUI
-
x¶ Icon x coordinate
Type: int
-
y¶ Icon y coordinate
Type: int
-
w¶ Width of master icon
Type: int
-
h¶ Height of master icon
Type: int
-
name¶ Item name
Type: str
-
dragEnterEvent(self, event)[source]¶ Drag and drop action enters. Accept file drops from the filesystem.
Parameters: event (QGraphicsSceneDragDropEvent) – Event
-
dragLeaveEvent(self, event)[source]¶ Drag and drop action leaves.
Parameters: event (QGraphicsSceneDragDropEvent) – Event
-
-
class
graphics_items.ToolIcon(toolbox, x, y, w, h, name)[source]¶ Bases:
graphics_items.ProjectItemIconTool image with a rectangular background, an SVG icon, a name label, and a connector button.
-
toolbox¶ QMainWindow instance
Type: ToolBoxUI
-
x¶ Icon x coordinate
Type: int
-
y¶ Icon y coordinate
Type: int
-
w¶ Width of master icon
Type: int
-
h¶ Height of master icon
Type: int
-
name¶ Item name
Type: str
-
-
class
graphics_items.DataStoreIcon(toolbox, x, y, w, h, name)[source]¶ Bases:
graphics_items.ProjectItemIconData Store item that is drawn into QGraphicsScene. NOTE: Make sure to set self._master as the parent of all drawn items. This groups the individual QGraphicsItems together.
-
toolbox¶ QMainWindow instance
Type: ToolBoxUI
-
x¶ Icon x coordinate
Type: int
-
y¶ Icon y coordinate
Type: int
-
w¶ Width of master icon
Type: int
-
h¶ Height of master icon
Type: int
-
name¶ Item name
Type: str
-
-
class
graphics_items.ViewIcon(toolbox, x, y, w, h, name)[source]¶ Bases:
graphics_items.ProjectItemIconView icon for the Design View
-
toolbox¶ QMainWindow instance
Type: ToolBoxUI
-
x¶ Icon x coordinate
Type: int
-
y¶ Icon y coordinate
Type: int
-
w¶ Width of background rectangle
Type: int
-
h¶ Height of background rectangle
Type: int
-
name¶ Item name
Type: str
-
-
class
graphics_items.DataInterfaceIcon(toolbox, x, y, w, h, name)[source]¶ Bases:
graphics_items.ProjectItemIconData Interface item that is drawn into QGraphicsScene. NOTE: Make sure to set self._master as the parent of all drawn items. This groups the individual QGraphicsItems together.
-
toolbox¶ QMainWindow instance
Type: ToolBoxUI
-
x¶ Icon x coordinate
Type: int
-
y¶ Icon y coordinate
Type: int
-
w¶ Width of master icon
Type: int
-
h¶ Height of master icon
Type: int
-
name¶ Item name
Type: str
-
-
class
graphics_items.Link(toolbox, src_connector, dst_connector)[source]¶ Bases:
PySide2.QtWidgets.QGraphicsPathItemAn item that represents a connection between project items.
-
src_connector¶ Source connector button
Type: ConnectorButton
-
dst_connector¶ Destination connector button
Type: ConnectorButton
-
mousePressEvent(self, e)[source]¶ Trigger slot button if it is underneath.
Parameters: e (QGraphicsSceneMouseEvent) – Mouse event
-
mouseDoubleClickEvent(self, e)[source]¶ Accept event to prevent unwanted feedback links to be created when propagating this event to connector buttons underneath.
-
contextMenuEvent(self, e)[source]¶ Show context menu unless mouse is over one of the slot buttons.
Parameters: e (QGraphicsSceneMouseEvent) – Mouse event
-
-
class
graphics_items.LinkDrawer[source]¶ Bases:
PySide2.QtWidgets.QGraphicsPathItemAn item that allows one to draw links between slot buttons in QGraphicsView.
-
class
graphics_items.ObjectItem(graph_view_form, object_name, object_class_id, object_class_name, x, y, extent, object_id=0, label_color=Qt.transparent)[source]¶ Bases:
PySide2.QtWidgets.QGraphicsPixmapItemObject item to use with GraphViewForm.
-
graph_view_form¶ ‘owner’
Type: GraphViewForm
-
object_name¶ object name
Type: str
-
object_class_id¶ object class id
Type: int
-
object_class_name¶ object class name
Type: str
-
x¶ x-coordinate of central point
Type: float
-
y¶ y-coordinate of central point
Type: float
-
extent¶ preferred extent
Type: int
-
object_id¶ object id (for filtering parameters)
Type: int
-
label_font¶ label font
Type: QFont
-
label_color¶ label bg color
Type: QColor
-
paint(self, painter, option, widget=None)[source]¶ Try and make it more clear when an item is selected.
-
check_for_merge_target(self, scene_pos)[source]¶ Checks if this item is touching another item so they can merge (this happens when building a relationship).
-
merge_item(self, other)[source]¶ Merges this item with another. Tries to create a relationship if needed.
Moves related items.
-
-
class
graphics_items.ArcItem(graph_view_form, relationship_class_id, src_item, dst_item, width, arc_color, object_id_list='', token_color=QColor(), token_object_extent=0, token_object_label_color=QColor(), token_object_name_tuple_list=())[source]¶ Bases:
PySide2.QtWidgets.QGraphicsLineItemArc item to use with GraphViewForm.
-
graph_view_form¶ ‘owner’
Type: GraphViewForm
-
relationship_class_id¶ relationship class id
Type: int
-
src_item¶ source item
Type: ObjectItem
-
dst_item¶ destination item
Type: ObjectItem
-
width¶ Preferred line width
Type: int
-
arc_color¶ arc color
Type: QColor
-
object_id_list¶ object id comma separated list
Type: str
-
token_object_extent¶ token preferred extent
Type: int
-
token_color¶ token bg color
Type: QColor
-
token_object_name_tuple_list¶ token (object class name, object name) tuple list
Type: list
-
paint(self, painter, option, widget=None)[source]¶ Try and make it more clear when an item is selected.
-
move_src_by(self, pos_diff)[source]¶ Move source point by pos_diff. Used when moving ObjectItems around.
-
-
class
graphics_items.ObjectLabelItem(object_item, text, width, bg_color)[source]¶ Bases:
PySide2.QtWidgets.QGraphicsTextItemObject label item to use with GraphViewForm.
-
object_item¶ the ObjectItem instance
Type: ObjectItem
-
text¶ text
Type: str
-
width¶ maximum width
Type: int
-
bg_color¶ color to paint the label
Type: QColor
-
set_text(self, text)[source]¶ Store real text, and then try and fit it as best as possible in the width (reduce font point size, elide text…)
-
-
class
graphics_items.ArcTokenItem(arc_item, color, object_extent, object_label_color, *object_name_tuples)[source]¶ Bases:
PySide2.QtWidgets.QGraphicsEllipseItemArc token item to use with GraphViewForm.
-
color¶ color to paint the token
Type: QColor
-
object_extent¶ Preferred extent
Type: int
-
object_label_color¶ Preferred extent
Type: QColor
-
object_name_tuples¶ one or more (object class name, object name) tuples
Type: Iterable
-
-
class
graphics_items.SimpleObjectItem(parent, extent, label_color, object_class_name, object_name)[source]¶ Bases:
PySide2.QtWidgets.QGraphicsPixmapItemObject item to use with GraphViewForm.
-
parent¶ arc token item
Type: ArcTokenItem
-
extent¶ preferred extent
Type: int
-
label_color¶ label bg color
Type: QColor
-
object_class_name¶ object class name
Type: str
-
object_name¶ object name
Type: str
-
-
class
graphics_items.OutlinedTextItem(text, font, brush=QBrush(Qt.black), outline_pen=QPen(Qt.white, 3, Qt.SolidLine))[source]¶ Bases:
PySide2.QtWidgets.QGraphicsSimpleTextItemOutlined text item to use with GraphViewForm.
-
text¶ text to show
Type: str
-
font¶ font to display the text
Type: QFont
-
brush¶ Type: QBrus
-
outline_pen¶ Type: QPen
-