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.

Initialize self. See help(type(self)) for accurate signature.

_POS_PARAM_NAME = entity_graph_position[source]
_VERTEX_EXTENT = 64[source]
_ARC_WIDTH[source]
_ARC_LENGTH_HINT[source]
graph_selection_changed[source]
graph_build_finished[source]
populate_graph_db_action_group(self)[source]
_update_graph_db_map(self, action)[source]
add_menu_actions(self)[source]

Adds toggle view actions to View menu.

init_models(self)[source]
connect_signals(self)[source]

Connects signals.

_handle_scene_selection_changed(self)[source]

Filters parameters by selected objects in the graph.

set_show_cascading_relationships(self, checked)[source]
setup_widget_actions(self)[source]

Setups zoom and rotate widget action in view menu.

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_menu_graph_about_to_show(self)[source]

Enables or disables actions according to current selection in the graph.

_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, builds the graph on top of the current one.
_complete_graph(self, x, y)[source]
Parameters:
  • 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]
_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]
hide_selected_items(self, checked=False)[source]

Hides selected items.

show_hidden_items(self, checked=False)[source]

Shows hidden items.

_get_selected_entity_names(self)[source]
_get_selected_class_names(self)[source]
prune_selected_entities(self, checked=False)[source]

Prunes selected items.

prune_selected_classes(self, checked=False)[source]

Prunes selected items.

restore_all_pruned_items(self, checked=False)[source]

Reinstates all pruned items.

restore_pruned_items(self, key)[source]

Reinstates last pruned items.

edit_entity_graph_items(self)[source]

Starts editing given indexes.

remove_entity_graph_items(self, checked=False)[source]

Removes all selected items in the graph.

save_positions(self, checked=False)[source]
clear_saved_positions(self, checked=False)[source]
export_as_pdf(self, checked=False)[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]
_populate_menu_add_parameter_heat_map(self)[source]

Populates the menu ‘Add parameter heat map’ with parameters for currently shown items in the graph.

add_heat_map(self, action)[source]

Adds heat map for the parameter in the action text.

_clean_up_heat_map_items(self)[source]
closeEvent(self, event)[source]

Handle close window.

Parameters:event (QCloseEvent) – Closing event