spinetoolbox.spine_db_editor.graphics_items

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

authors
  1. Marin (KTH), P. Savolainen (VTT)

date

4.4.2018

Module Contents

Classes

EntityItem

Base class for ObjectItem and RelationshipItem.

RelationshipItem

Represents a relationship in the Entity graph.

ObjectItem

Represents an object in the Entity graph.

ArcItem

Connects a RelationshipItem to an ObjectItem.

CrossHairsItem

Creates new relationships directly in the graph.

CrossHairsRelationshipItem

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

CrossHairsArcItem

Connects a CrossHairsRelationshipItem with the CrossHairsItem,

ObjectLabelItem

Provides a label for ObjectItem’s.

Functions

make_figure_graphics_item(scene, z=0, static=True)

Creates a FigureCanvas and adds it to the given scene.

spinetoolbox.spine_db_editor.graphics_items.make_figure_graphics_item(scene, z=0, static=True)[source]

Creates a FigureCanvas and adds it to the given scene. Used for creating heatmaps and associated colorbars.

Parameters
  • scene (QGraphicsScene) –

  • z (int, optional) – z value. Defaults to 0.

  • static (bool, optional) – if True (the default) the figure canvas is not movable

Returns

the graphics item that represents the canvas Figure: the figure in the canvas

Return type

QGraphicsProxyWidget

class spinetoolbox.spine_db_editor.graphics_items.EntityItem(spine_db_editor, x, y, extent, db_map_entity_id)[source]

Bases: PySide2.QtWidgets.QGraphicsRectItem

Base class for ObjectItem and RelationshipItem.

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_entity_id (tuple) – db_map, entity id

abstract _make_tool_tip(self)[source]
property entity_type(self)[source]
property entity_name(self)[source]
property entity_class_type(self)[source]
property entity_class_id(self)[source]
property entity_class_name(self)[source]
property db_map(self)[source]
property entity_id(self)[source]
property first_db_map(self)[source]
property display_data(self)[source]
property display_database(self)[source]
property db_maps(self)[source]
db_map_data(self, _db_map)[source]
db_map_id(self, _db_map)[source]
boundingRect(self)[source]
moveBy(self, dx, dy)[source]
_init_bg(self)[source]
refresh_icon(self)[source]

Refreshes the icon.

_set_renderer(self, renderer)[source]
shape(self)[source]

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

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

Shows or hides the selection halo.

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

Adds an item to the list of arcs.

Parameters

arc_item (ArcItem) –

apply_zoom(self, factor)[source]

Applies zoom.

Parameters

factor (float) – The zoom factor.

apply_rotation(self, angle, center)[source]

Applies rotation.

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

  • center (QPointF) – Rotates around this point.

block_move_by(self, dx, dy)[source]
mouseMoveEvent(self, event)[source]

Moves the item and all connected arcs.

Parameters

event (QGraphicsSceneMouseEvent) –

update_arcs_line(self)[source]

Moves arc items.

itemChange(self, change, value)[source]

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

the same value given as input

set_all_visible(self, on)[source]

Sets visibility status for this item and all arc items.

Parameters

on (bool) –

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

Shows context menu.

Parameters

e (QGraphicsSceneMouseEvent) – Mouse event

class spinetoolbox.spine_db_editor.graphics_items.RelationshipItem(spine_db_editor, x, y, extent, db_map_entity_id)[source]

Bases: EntityItem

Represents a relationship in the Entity graph.

Initializes the item.

Parameters
  • spine_db_editor (GraphViewForm) – ‘owner’

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

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

  • extent (int) – preferred extent

  • db_map_entity_id (tuple) – db_map, relationship id

property entity_type(self)[source]
property object_class_id_list(self)[source]
property object_name_list(self)[source]
property object_id_list(self)[source]
property entity_class_name(self)[source]
property db_representation(self)[source]
_make_tool_tip(self)[source]
_init_bg(self)[source]
follow_object_by(self, dx, dy)[source]
class spinetoolbox.spine_db_editor.graphics_items.ObjectItem(spine_db_editor, x, y, extent, db_map_entity_id)[source]

Bases: EntityItem

Represents an object in the Entity graph.

Initializes the item.

Parameters
  • spine_db_editor (GraphViewForm) – ‘owner’

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

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

  • extent (int) – preferred extent

  • db_map_entity_id (tuple) – db_map, object id

property entity_type(self)[source]
property db_representation(self)[source]
shape(self)[source]

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

update_name(self, name)[source]

Refreshes the name.

_make_tool_tip(self)[source]
block_move_by(self, dx, dy)[source]
mouseDoubleClickEvent(self, e)[source]
_make_menu(self)[source]
_refresh_relationship_classes(self)[source]
_populate_expand_collapse_menu(self, menu)[source]

Populates the ‘Expand’ or ‘Collapse’ menu.

Parameters

menu (QMenu) –

_populate_add_relationships_menu(self, menu)[source]

Populates the ‘Add relationships’ menu.

Parameters

menu (QMenu) –

_get_relationship_ids_to_expand_or_collapse(self, action)[source]
_expand(self, action)[source]
_collapse(self, action)[source]
_start_relationship(self, action)[source]
class spinetoolbox.spine_db_editor.graphics_items.ArcItem(rel_item, obj_item, width)[source]

Bases: PySide2.QtWidgets.QGraphicsPathItem

Connects a RelationshipItem to an ObjectItem.

Initializes item.

Parameters
  • rel_item (spinetoolbox.widgets.graph_view_graphics_items.RelationshipItem) – relationship item

  • obj_item (spinetoolbox.widgets.graph_view_graphics_items.ObjectItem) – object item

  • width (float) – Preferred line width

_make_pen(self)[source]
moveBy(self, dx, dy)[source]

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

update_line(self)[source]
mousePressEvent(self, event)[source]

Accepts the event so it’s not propagated.

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

Applies zoom.

Parameters

factor (float) – The zoom factor.

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

Bases: RelationshipItem

Creates new relationships directly in the graph.

Initializes the item.

Parameters
  • spine_db_editor (GraphViewForm) – ‘owner’

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

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

  • extent (int) – preferred extent

  • db_map_entity_id (tuple) – db_map, relationship id

property entity_class_name(self)[source]
property entity_name(self)[source]
_make_tool_tip(self)[source]
refresh_icon(self)[source]

Refreshes the icon.

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

Refreshes the icon.

mouseMoveEvent(self, event)[source]

Moves the item and all connected arcs.

Parameters

event (QGraphicsSceneMouseEvent) –

block_move_by(self, dx, dy)[source]
contextMenuEvent(self, e)[source]

Shows context menu.

Parameters

e (QGraphicsSceneMouseEvent) – Mouse event

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

Bases: RelationshipItem

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

Initializes the item.

Parameters
  • spine_db_editor (GraphViewForm) – ‘owner’

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

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

  • extent (int) – preferred extent

  • db_map_entity_id (tuple) – db_map, relationship id

_make_tool_tip(self)[source]
refresh_icon(self)[source]

Refreshes the icon.

contextMenuEvent(self, e)[source]

Shows context menu.

Parameters

e (QGraphicsSceneMouseEvent) – Mouse event

class spinetoolbox.spine_db_editor.graphics_items.CrossHairsArcItem(rel_item, obj_item, width)[source]

Bases: ArcItem

Connects a CrossHairsRelationshipItem with the CrossHairsItem, and with all the ObjectItem’s in the relationship so far.

Initializes item.

Parameters
  • rel_item (spinetoolbox.widgets.graph_view_graphics_items.RelationshipItem) – relationship item

  • obj_item (spinetoolbox.widgets.graph_view_graphics_items.ObjectItem) – object item

  • width (float) – Preferred line width

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

Bases: PySide2.QtWidgets.QGraphicsTextItem

Provides a label for ObjectItem’s.

Initializes item.

Parameters

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

entity_name_edited[source]
setPlainText(self, text)[source]

Set texts and resets position.

Parameters

text (str) –

reset_position(self)[source]

Adapts item geometry so text is always centered.