spinetoolbox.spine_db_editor.widgets.graph_view_mixin

Contains the GraphViewMixin class.

author
  1. Marin (KTH)

date

26.11.2018

Module Contents

Classes

GraphViewMixin

Provides the graph view for the DS form.

class spinetoolbox.spine_db_editor.widgets.graph_view_mixin.GraphViewMixin(*args, **kwargs)[source]

Provides the graph view for the DS form.

VERTEX_EXTENT = 64[source]
_ARC_WIDTH[source]
_ARC_LENGTH_HINT[source]
init_models(self)[source]
connect_signals(self)[source]

Connects signals.

receive_objects_added(self, db_map_data)[source]

Runs when objects are added to the db. Adds the new objects to the graph if needed.

Parameters

db_map_data (dict) – list of dictionary-items keyed by DiffDatabaseMapping instance.

receive_relationships_added(self, db_map_data)[source]

Runs when relationships are added to the db. Adds the new relationships to the graph if needed.

Parameters

db_map_data (dict) – list of dictionary-items keyed by DiffDatabaseMapping instance.

receive_object_classes_updated(self, db_map_data)[source]
receive_relationship_classes_updated(self, db_map_data)[source]
receive_objects_updated(self, db_map_data)[source]

Runs when objects are updated in the db. Refreshes names of objects in graph.

Parameters

db_map_data (dict) – list of dictionary-items keyed by DiffDatabaseMapping instance.

receive_objects_removed(self, db_map_data)[source]

Runs when objects are removed from the db. Rebuilds graph if needed.

Parameters

db_map_data (dict) – list of dictionary-items keyed by DiffDatabaseMapping instance.

receive_relationships_removed(self, db_map_data)[source]

Runs when relationships are removed from the db. Rebuilds graph if needed.

Parameters

db_map_data (dict) – list of dictionary-items keyed by DiffDatabaseMapping instance.

restore_removed_entities(self, added_ids)[source]

Restores any entities that have been previously removed and returns their ids. This happens in the context of undo/redo.

Parameters

added_ids (set(int)) – Set of newly added ids.

Returns

set(int)

hide_removed_entities(self, db_map_data)[source]

Hides removed entities while saving them into a list attribute. This allows entities to be restored in case the user undoes the operation.

refresh_icons(self, db_map_data)[source]

Runs when entity classes are updated in the db. Refreshes icons of entities in graph.

Parameters

db_map_data (dict) – list of dictionary-items keyed by DiffDatabaseMapping instance.

_handle_entity_graph_visibility_changed(self, visible)[source]
rebuild_graph(self, selected)[source]

Stores the given selection of entity tree indexes and builds graph.

build_graph(self, persistent=False)[source]

Builds the graph.

Parameters

persistent (bool, optional) – If True, elements in the current graph (if any) retain their position in the new one.

_stop_layout_generators(self)[source]
_complete_graph(self, layout_gen_id, x, y)[source]
Parameters
  • layout_gen_id (object) –

  • x (list) – Horizontal coordinates

  • y (list) – Vertical coordinates

_get_selected_entity_ids(self)[source]

Returns a set of ids corresponding to selected entities in the trees.

Returns

selected object ids set: selected relationship ids

Return type

set

_get_all_relationships_for_graph(self, object_ids, relationship_ids)[source]
_update_graph_data(self)[source]

Updates data for graph according to selection in trees.

_update_src_dst_inds(self, object_id_lists)[source]
_get_parameter_positions(self, parameter_name)[source]
_make_layout_generator(self)[source]

Returns a layout generator for the current graph.

Returns

GraphLayoutGenerator

_make_new_items(self, x, y)[source]

Returns new items for the graph.

Parameters
  • x (list) –

  • y (list) –

_add_new_items(self)[source]
start_relationship(self, relationship_class, obj_item)[source]

Starts a relationship from the given object item.

Parameters
  • relationship_class (dict) –

  • obj_item (.graphics_items.ObjectItem) –

finalize_relationship(self, relationship_class, *object_items)[source]

Tries to add relationships between the given object items.

Parameters
  • relationship_class (dict) –

  • object_items (.graphics_items.ObjectItem) –

_begin_add_relationships(self)[source]
_end_add_relationships(self)[source]
add_objects_at_position(self, pos)[source]
get_pdf_file_path(self)[source]
closeEvent(self, event)[source]

Handle close window.

Parameters

event (QCloseEvent) – Closing event