spinetoolbox.spine_db_editor.graphics_items

Classes for drawing graphics items on graph view’s QGraphicsScene.

Module Contents

Classes

EntityItem

param spine_db_editor

'owner'

ArcItem

Connects two EntityItems.

CrossHairsItem

Creates new relationships directly in the graph.

CrossHairsEntityItem

Represents the relationship that's being created using the CrossHairsItem.

CrossHairsArcItem

Connects a CrossHairsEntityItem with the CrossHairsItem,

EntityLabelItem

Provides a label for EntityItem.

BgItem

_ResizableQGraphicsSvgItem

_Resizer

class spinetoolbox.spine_db_editor.graphics_items.EntityItem(spine_db_editor, x, y, extent, db_map_ids, offset=None)[source]

Bases: PySide6.QtWidgets.QGraphicsRectItem

Parameters
  • spine_db_editor (SpineDBEditor) – ‘owner’

  • x (float) – x-coordinate of central point

  • y (float) – y-coordinate of central point

  • extent (int) – Preferred extent

  • db_map_ids (tuple) – tuple of (db_map, id) tuples

property has_dimensions[source]
property db_map_ids[source]
property original_db_map_ids[source]
property name[source]
property first_entity_class_id[source]
property entity_class_name[source]
property dimension_id_list[source]
property dimension_name_list[source]
property byname[source]
property element_name_list[source]
property element_byname_list[source]
property first_db_map_id[source]
property first_id[source]
property first_db_map[source]
property display_data[source]
property display_database[source]
property db_maps[source]
clone()[source]
element_id_list(db_map)[source]
entity_class_id(db_map)[source]
entity_class_ids(db_map)[source]
entity_id(db_map)[source]
db_map_data(db_map)[source]
db_map_id(db_map)[source]
db_items(db_map)[source]
boundingRect()[source]
set_pos(x, y)[source]
move_by(dx, dy)[source]
_snap(x, y)[source]
has_unique_key()[source]

Returns whether or not the item still has a single key in all the databases it represents.

Returns

bool

_get_name()[source]
_get_prop(getter, index)[source]
_get_color(index=None)[source]
_get_arc_width(index=None)[source]
_get_vertex_radius(index=None)[source]
_has_name()[source]
set_up()[source]
update_props(index)[source]
_update_bg()[source]
refresh_icon()[source]

Refreshes the icon.

_update_renderer(color, resize=True)[source]
_install_renderer(resize=True)[source]
_make_tool_tip()[source]
default_parameter_data()[source]

Return data to put as default in a parameter table when this item is selected.

shape()[source]

Returns a shape containing the entire bounding rect, to work better with icon transparency.

set_highlight_color(color)[source]
paint(painter, option, widget=None)[source]

Shows or hides the selection halo.

_paint_as_selected()[source]
_paint_as_deselected()[source]
add_arc_item(arc_item)[source]

Adds an item to the list of arcs.

Parameters

arc_item (ArcItem) –

update_entity_pos()[source]
do_update_entity_pos()[source]
apply_zoom(factor)[source]

Applies zoom.

Parameters

factor (float) – The zoom factor.

apply_rotation(angle, center)[source]

Applies rotation.

Parameters
  • angle (float) – The angle in degrees.

  • center (QPointF) – Rotates around this point.

mouseMoveEvent(event)[source]

Moves the item and all connected arcs.

Parameters

event (QGraphicsSceneMouseEvent) –

update_arcs_line()[source]

Moves arc items.

_update_arcs(color, arc_width)[source]
_update_circle(color, vertex_radius)[source]
itemChange(change, value)[source]

Keeps track of item’s movements on the scene. Rotates svg item if the relationship is 2D. This makes it possible to define e.g. an arow icon for relationships that express direction.

Parameters
  • change (GraphicsItemChange) – a flag signalling the type of the change

  • value – a value related to the change

Returns

the same value given as input

setVisible(on)[source]

Sets visibility status for this item and all arc items.

Parameters

on (bool) –

_make_menu()[source]
contextMenuEvent(e)[source]

Shows context menu.

Parameters

e (QGraphicsSceneMouseEvent) – Mouse event

remove_db_map_ids(db_map_ids)[source]

Removes db_map_ids.

add_db_map_ids(db_map_ids)[source]
_rotate_svg_item()[source]
mouseDoubleClickEvent(e)[source]
_duplicate()[source]
_refresh_db_map_entity_class_lists()[source]
_populate_expand_collapse_menu(menu)[source]

Populates the ‘Expand’ or ‘Collapse’ menu.

Parameters

menu (QMenu) –

_populate_connect_entities_menu(menu)[source]

Populates the ‘Add relationships’ menu.

Parameters

menu (QMenu) –

_get_db_map_entity_ids_to_expand_or_collapse(action)[source]
_expand(action)[source]
_collapse(action)[source]
_start_connecting_entities(action)[source]
class spinetoolbox.spine_db_editor.graphics_items.ArcItem(ent_item, el_item, width)[source]

Bases: PySide6.QtWidgets.QGraphicsPathItem

Connects two EntityItems.

Parameters
  • ent_item (spinetoolbox.widgets.graph_view_graphics_items.EntityItem) – entity item

  • el_item (spinetoolbox.widgets.graph_view_graphics_items.EntityItem) – element item

  • width (float) – Preferred line width

clone(entity_items)[source]
_make_pen()[source]
moveBy(dx, dy)[source]

Does nothing. This item is not moved the regular way, but follows the EntityItems it connects.

update_line()[source]
update_color(color)[source]
apply_value(factor, sign)[source]
mousePressEvent(event)[source]

Accepts the event so it’s not propagated.

other_item(item)[source]
apply_zoom(factor)[source]

Applies zoom.

Parameters

factor (float) – The zoom factor.

_update_width()[source]
_move_gradient(factor, sign)[source]
_do_move_gradient()[source]
class spinetoolbox.spine_db_editor.graphics_items.CrossHairsItem(*args, **kwargs)[source]

Bases: EntityItem

Creates new relationships directly in the graph.

Parameters
  • spine_db_editor (SpineDBEditor) – ‘owner’

  • x (float) – x-coordinate of central point

  • y (float) – y-coordinate of central point

  • extent (int) – Preferred extent

  • db_map_ids (tuple) – tuple of (db_map, id) tuples

property entity_class_name[source]
property name[source]
property has_dimensions[source]
_make_tool_tip()[source]
_has_name()[source]
refresh_icon()[source]

Refreshes the icon.

set_plus_icon()[source]
set_check_icon()[source]
set_normal_icon()[source]
set_ban_icon()[source]
set_icon(unicode, color=0)[source]

Refreshes the icon.

_snap(x, y)[source]
mouseMoveEvent(event)[source]

Moves the item and all connected arcs.

Parameters

event (QGraphicsSceneMouseEvent) –

contextMenuEvent(e)[source]

Shows context menu.

Parameters

e (QGraphicsSceneMouseEvent) – Mouse event

class spinetoolbox.spine_db_editor.graphics_items.CrossHairsEntityItem(*args, **kwargs)[source]

Bases: EntityItem

Represents the relationship that’s being created using the CrossHairsItem.

Parameters
  • spine_db_editor (SpineDBEditor) – ‘owner’

  • x (float) – x-coordinate of central point

  • y (float) – y-coordinate of central point

  • extent (int) – Preferred extent

  • db_map_ids (tuple) – tuple of (db_map, id) tuples

property has_dimensions[source]
_make_tool_tip()[source]
_has_name()[source]
refresh_icon()[source]

Refreshes the icon.

contextMenuEvent(e)[source]

Shows context menu.

Parameters

e (QGraphicsSceneMouseEvent) – Mouse event

class spinetoolbox.spine_db_editor.graphics_items.CrossHairsArcItem(ent_item, el_item, width)[source]

Bases: ArcItem

Connects a CrossHairsEntityItem with the CrossHairsItem, and with all the EntityItem’s in the relationship so far.

Parameters
  • ent_item (spinetoolbox.widgets.graph_view_graphics_items.EntityItem) – entity item

  • el_item (spinetoolbox.widgets.graph_view_graphics_items.EntityItem) – element item

  • width (float) – Preferred line width

_make_pen()[source]
class spinetoolbox.spine_db_editor.graphics_items.EntityLabelItem(entity_item)[source]

Bases: PySide6.QtWidgets.QGraphicsTextItem

Provides a label for EntityItem.

Initializes item.

Parameters

entity_item (spinetoolbox.widgets.graph_view_graphics_items.EntityItem) – The parent item.

entity_name_edited[source]
boundingRect()[source]
setPlainText(text)[source]

Set texts and resets position.

Parameters

text (str) –

reset_position()[source]

Adapts item geometry so text is always centered.

class spinetoolbox.spine_db_editor.graphics_items.BgItem(svg, parent=None)[source]

Bases: PySide6.QtWidgets.QGraphicsRectItem

class Anchor[source]

Bases: enum.Enum

Generic enumeration.

Derive from this class to define new enumerations.

TL[source]
TR[source]
BL[source]
BR[source]
_getter_setter[source]
_cursors[source]
clone()[source]
hoverEnterEvent(ev)[source]
hoverLeaveEvent(ev)[source]
apply_zoom(factor)[source]
_place_resizers()[source]
_resize(anchor, delta, strong)[source]
_do_resize(rect, strong)[source]
fit_rect(rect)[source]
scene_rect()[source]
class spinetoolbox.spine_db_editor.graphics_items._ResizableQGraphicsSvgItem(*args, **kwargs)[source]

Bases: PySide6.QtSvgWidgets.QGraphicsSvgItem

resize(width, height)[source]
setSharedRenderer(renderer)[source]
boundingRect()[source]
paint(painter, options, widget)[source]
class spinetoolbox.spine_db_editor.graphics_items._Resizer(rect=QRectF(0, 0, 20, 20), parent=None)[source]

Bases: PySide6.QtWidgets.QGraphicsRectItem

class SignalsProvider[source]

Bases: PySide6.QtCore.QObject

resized[source]
mousePressEvent(ev)[source]
mouseMoveEvent(ev)[source]
mouseReleaseEvent(ev)[source]