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, entity_id=None)[source]

Bases: PySide2.QtWidgets.QGraphicsPixmapItem

Base class for ObjectItem and RelationshipItem.

Initializes item

Parameters:
  • spine_db_editor (SpineDBEditor) – ‘owner’
  • x (float) – x-coordinate of central point
  • y (float) – y-coordinate of central point
  • extent (int) – Preferred extent
  • entity_id (int) – The entity id
entity_type[source]
entity_name[source]
entity_class_type[source]
entity_class_id[source]
entity_class_name[source]
first_db_map[source]
display_data[source]
display_database[source]
db_maps[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.

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 (QPoint) – Rotates around this point.
block_move_by(self, dx, dy)[source]
mouseMoveEvent(self, event)[source]

Moves the item and all connected arcs. Also checks for a merge target and sets an appropriate mouse cursor.

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, entity_id=None)[source]

Bases: spinetoolbox.spine_db_editor.graphics_items.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
  • entity_id (int) – object id
entity_type[source]
object_class_id_list[source]
object_name_list[source]
object_id_list[source]
entity_class_name[source]
db_representation[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, entity_id=None)[source]

Bases: spinetoolbox.spine_db_editor.graphics_items.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
  • entity_id (int) – object id
entity_type[source]
db_representation[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.

update_description(self, description)[source]
block_move_by(self, dx, dy)[source]
_make_menu(self)[source]
_populate_add_relationships_menu(self, add_title=False)[source]

Populates the ‘Add relationships’ menu.

contextMenuEvent(self, e)[source]

Shows context menu.

Parameters:e (QGraphicsSceneMouseEvent) – Mouse event
mouseDoubleClickEvent(self, e)[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(spine_db_editor, x, y, extent)[source]

Bases: spinetoolbox.spine_db_editor.graphics_items.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
  • entity_id (int) – object id
entity_class_name[source]
entity_name[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. Also checks for a merge target and sets an appropriate mouse cursor.

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: spinetoolbox.spine_db_editor.graphics_items.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
  • entity_id (int) – object 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: spinetoolbox.spine_db_editor.graphics_items.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.