13.2. The GUI: gui
¶
Contents
Subpackages of rafcon.gui
¶
- MVC Controllers:
rafcon.gui.controllers
- Subpackages of
rafcon.gui.controllers
- MVC State Editor Controllers (rafcon.gui.controllers.state_editor)
- LinkageOverviewController (in linkage_overview)
- ScopedVariableListController (in scoped_variable_list)
- SourceEditorController (in source_editor)
- StateDataFlowsListController (in data_flows)
- DescriptionEditorController (in description_editor)
- StateEditorController (in state_editor)
- StateOutcomesListController (in outcomes)
- StateOverviewController (in overview)
- StateTransitionsListController (in transitions)
- MVC Controller Utils (rafcon.gui.controllers.utils)
- MVC State Editor Controllers (rafcon.gui.controllers.state_editor)
- MainWindowController (in main_window)
- GraphicalEditorController (in graphical_editor_gaphas)
- StateMachinesEditorController (in state_machines_editor)
- ExecutionHistoryTreeController (in execution_history)
- GlobalVariableManagerController (in global_variable_manager)
- LoggingConsoleController (in logging_console)
- LibraryTreeController (in library_tree)
- MenuBarController (in menu_bar)
- ModificationHistoryTreeController (in modification_history)
- StateMachineTreeController (in state_machine_tree)
- StatesEditorController (in states_editor)
- ToolBarController (in tool_bar)
- TopToolBarController (in top_tool_bar)
- StateIconController (in state_icons)
- UndockedWindowController (in undocked_window)
- Subpackages of
- MVC Models:
rafcon.gui.models
- AbstractStateModel (in abstract_state)
- StateModel (in state)
- ContainerStateModel (in container_state)
- LibraryStateModel (in library_state)
- StateElementModel (in state_element)
- TransitionModel (in transition)
- DataFlowModel (in data_flow)
- DataPortModel (in data_port)
- ScopedVariableModel (in scoped_variable)
- Selection (in selection)
- LogicalPortModel (in logical_port)
- StateMachineModel (in state_machine)
- ModificationsHistoryModel (in modification_history)
- AutoBackupModel (in auto_backup)
- StateMachineManagerModel (in state_machine_manager)
- GlobalVariableManagerModel (in global_variable_manager)
- LibraryManagerModel (in library_manager)
- StateMachineExecutionEngineModel (in state_machine_execution_engine)
- MVC Views:
rafcon.gui.views
- Subpackages of
rafcon.gui.views
- MVC State Editor Views (rafcon.gui.views.state_editor)
- StateEditorView (in state_editor)
- LinkageOverviewView (in linkage_overview)
- InputPortsListView (in input_port_list)
- OutputPortsListView (in output_port_list)
- ScopedVariablesListView (in scoped_variables_list)
- SourceEditorView (in source_editor)
- StateDataFlowsListView (in data_flows)
- DescriptionEditorView (in description_editor)
- StateOutcomesEditorView (in state_outcomes)
- StateOverviewView (in state_overview)
- StateTransitionsEditorView (in state_transitions)
- MVC View Utils (rafcon.gui.views.utils)
- MVC State Editor Views (rafcon.gui.views.state_editor)
- GraphicalEditor (in graphical_editor_gaphas)
- ExecutionHistoryTreeView (in execution_history)
- GlobalVariableEditorView (in global_variable_editor)
- LibraryTreeView (in library_tree)
- LoggingConsoleView (in logging_console)
- MainWindowView (in main_window)
- MenuBarView (in menu_bar)
- ModificationHistoryView (in modification_history)
- StateMachineTreeView (in state_machine_tree)
- StateMachinesEditorView (in state_machines_editor)
- StatesEditorView (in states_editor)
- ToolBarView (in tool_bar)
- Subpackages of
- Helper functions:
rafcon.gui.helpers
- Gaphas extensions for RAFCON:
rafcon.gui.mygaphas
action¶
Action class for history
The Action-Class provides a general redo or undo functionality for any action, as long as the the class object was initialized with consistent arguments.
This general Action (one procedure for all possible edition) procedure is expansive and complex, therefore it is aimed to define specific _-Action-Classes for simple/specific edit actions.
- class rafcon.gui.action.AbstractAction(parent_path, state_machine_model, overview=None)¶
Bases:
object
- action_type = None¶
- after_overview = None¶
- after_state_image = None¶
- as_dict()¶
- description()¶
- get_state_image()¶
- prepare_destruction()¶
- redo()¶
- set_after(overview)¶
- undo()¶
- class rafcon.gui.action.Action(parent_path, state_machine_model, overview)¶
Bases:
rafcon.design_patterns.mvc.model.ModelMT
,rafcon.gui.action.AbstractAction
- action_signal(model, prop_name, info)¶
- static add_core_object_to_state(state, core_obj)¶
- compare_models(previous_model, actual_model)¶
- emit_undo_redo_signal(action_parent_m, affected_models, after)¶
- get_state_changed()¶
- get_state_image()¶
- redo()¶
General Redo, that takes all elements in the parent path state stored of the before action state machine status. :return:
- static remove_core_object_from_state(state, core_obj)¶
- undo()¶
General Undo, that takes all elements in the parent path state stored of the after action state machine status. :return:
- update_state(state, stored_state)¶
- update_state_from_image(state, state_image)¶
- class rafcon.gui.action.ActionDummy(parent_path=None, state_machine_model=None, overview=None)¶
- class rafcon.gui.action.AddObjectAction(parent_path, state_machine_model, overview)¶
Bases:
rafcon.gui.action.Action
The class handles all adding object action of 7 valid kinds (of In-OutputDataPort, ScopedVariable, DataFlow, Outcome, Transition and State)
- correct_reference_state(state, state_image_of_state, storage_path)¶
- possible_method_names = ['add_state', 'add_outcome', 'add_input_data_port', 'add_output_data_port', 'add_transition', 'add_data_flow', 'add_scoped_variable']¶
- redo()¶
- Returns
Redo of adding object action is simply done by adding the object again from the after_state_image of the parent state.
- set_after(overview)¶
- undo()¶
General Undo, that takes all elements in the parent path state stored of the after action state machine status. :return:
- class rafcon.gui.action.DataFlowAction(parent_path, state_machine_model, overview)¶
Bases:
rafcon.gui.action.StateElementAction
- static get_set_of_arguments(df)¶
- possible_args = ['from_state', 'from_key', 'to_state', 'to_key']¶
- possible_method_names = ['modify_origin', 'from_state', 'from_key', 'modify_target', 'to_state', 'to_key']¶
- redo()¶
- undo()¶
- update_data_flow_from_image(df, arguments)¶
- class rafcon.gui.action.DataPortAction(parent_path, state_machine_model, overview)¶
Bases:
rafcon.gui.action.StateElementAction
- static get_set_of_arguments(dp)¶
- possible_args = ['name', 'default_value']¶
- possible_method_names = ['name', 'data_type', 'default_value', 'change_data_type']¶
- redo()¶
- undo()¶
- update_data_port_from_image(dp, arguments)¶
- class rafcon.gui.action.MetaDataAction(parent_path, state_machine_model, overview)¶
Bases:
rafcon.gui.action.AbstractAction
- get_state_image()¶
- get_state_model_changed()¶
- redo()¶
- undo()¶
- class rafcon.gui.action.OutcomeAction(parent_path, state_machine_model, overview)¶
Bases:
rafcon.gui.action.StateElementAction
- static get_set_of_arguments(oc)¶
- possible_args = ['name']¶
- possible_method_names = ['name']¶
- redo()¶
- undo()¶
- update_outcome_from_image(oc, arguments)¶
- class rafcon.gui.action.RemoveObjectAction(parent_path, state_machine_model, overview)¶
Bases:
rafcon.gui.action.Action
- adjust_linkage()¶
- as_dict()¶
- correct_reference_state(state, state_image_of_state, storage_path)¶
- get_object_identifier()¶
- possible_method_names = ['remove_state', 'remove_outcome', 'remove_input_data_port', 'remove_output_data_port', 'remove_transition', 'remove_data_flow', 'remove_scoped_variable']¶
- redo()¶
General Redo, that takes all elements in the parent path state stored of the before action state machine status. :return:
- set_after(overview)¶
- undo()¶
General Undo, that takes all elements in the parent path state stored of the after action state machine status. :return:
- class rafcon.gui.action.ScopedVariableAction(parent_path, state_machine_model, overview)¶
- class rafcon.gui.action.StateAction(parent_path, state_machine_model, overview)¶
Bases:
rafcon.gui.action.Action
- as_dict()¶
- static get_set_of_arguments(s)¶
- possible_args = ['name', 'description', 'script_text', 'start_state_id', 'library_name', 'library_path', 'version', 'state_copy', 'input_data_port_runtime_values', 'output_data_port_runtime_values', 'use_runtime_value_input_data_ports', 'use_runtime_value_output_data_ports', 'set_input_runtime_value', 'set_output_runtime_value', 'set_use_input_runtime_value', 'set_use_output_runtime_value', 'semantic_data']¶
- possible_method_names = ['parent', 'name', 'description', 'script', 'script_text', 'outcomes', 'input_data_ports', 'output_data_ports', 'states', 'scoped_variables', 'data_flows', 'transitions', 'start_state_id', 'change_state_type', 'add_input_data_port', 'remove_input_data_port', 'add_output_data_port', 'remove_output_data_port', 'set_input_runtime_value', 'set_output_runtime_value', 'set_use_input_runtime_value', 'set_use_output_runtime_value', 'input_data_port_runtime_values', 'output_data_port_runtime_values', 'use_runtime_value_input_data_ports', 'use_runtime_value_output_data_ports', 'group_states', 'ungroup_state', 'substitute_state', 'paste', 'cut', 'semantic_data', 'add_semantic_data', 'remove_semantic_data']¶
- redo()¶
General Redo, that takes all elements in the parent path state stored of the before action state machine status. :return:
- set_after(overview)¶
- substitute_dict = {'set_input_runtime_value': 'input_data_port_runtime_values', 'set_output_runtime_value': 'output_data_port_runtime_values', 'set_use_input_runtime_value': 'use_runtime_value_input_data_ports', 'set_use_output_runtime_value': 'use_runtime_value_output_data_ports'}¶
- undo()¶
General Undo, that takes all elements in the parent path state stored of the after action state machine status. :return:
- update_property_from_image(s, arguments)¶
- class rafcon.gui.action.StateElementAction(parent_path, state_machine_model, overview)¶
Bases:
rafcon.gui.action.AbstractAction
- after_arguments = None¶
- as_dict()¶
- static get_set_of_arguments(elem)¶
- get_state_image()¶
- possible_args = []¶
- possible_method_names = []¶
- set_after(overview)¶
- class rafcon.gui.action.StateImage(core_data, meta_data, state_path, semantic_data, file_system_path, script_text, children)¶
Bases:
tuple
- children¶
Alias for field number 6
- core_data¶
Alias for field number 0
- file_system_path¶
Alias for field number 4
- meta_data¶
Alias for field number 1
- script_text¶
Alias for field number 5
- semantic_data¶
Alias for field number 3
- state_path¶
Alias for field number 2
- class rafcon.gui.action.StateMachineAction(parent_path, state_machine_model, overview)¶
Bases:
rafcon.gui.action.Action
,rafcon.design_patterns.mvc.model.ModelMT
The state machine action is currently only used for root state type changes and their undo/redo functionality.
- action_signal(model, prop_name, info)¶
- redo()¶
General Redo, that takes all elements in the parent path state stored of the before action state machine status. :return:
- undo()¶
General Undo, that takes all elements in the parent and :return:
- update_root_state_from_image(state, state_image)¶
- class rafcon.gui.action.TransitionAction(parent_path, state_machine_model, overview)¶
Bases:
rafcon.gui.action.StateElementAction
- static get_set_of_arguments(t)¶
- possible_args = ['from_state', 'from_outcome', 'to_state', 'to_key']¶
- possible_method_names = ['modify_origin', 'from_state', 'from_outcome', 'modify_target', 'to_state', 'to_outcome']¶
- redo()¶
- undo()¶
- update_transition_from_image(t, arguments)¶
- rafcon.gui.action.check_state_model_for_is_start_state(state_model)¶
- rafcon.gui.action.create_state_from_image(state_image)¶
- rafcon.gui.action.create_state_image(state_m)¶
Generates a tuple that holds the state as yaml-strings and its meta data in a dictionary. The tuple consists of: [0] json_str for state, [1] dict of child_state tuples, [2] dict of model_meta-data of self and elements [3] path of state in state machine [4] script_text [5] file system path [6] semantic data # states-meta - [state-, transitions-, data_flows-, outcomes-, inputs-, outputs-, scopes, states-meta]
- Parameters
state (rafcon.core.states.state.State) – The state that should be stored
- Returns
state_tuple tuple
- rafcon.gui.action.get_state_element_meta(state_model, with_parent_linkage=True, with_verbose=False, level=None)¶
- rafcon.gui.action.insert_state_meta_data(meta_dict, state_model, with_verbose=False, level=None)¶
- rafcon.gui.action.meta_dump_or_deepcopy(meta)¶
Function to observe meta data vivi-dict copy process and to debug it at one point
clipboard¶
- class rafcon.gui.clipboard.Clipboard¶
Bases:
rafcon.design_patterns.observer.observable.Observable
A class to hold models and selection for later usage in cut/paste or copy/paste actions. In cut/paste action the selection stored is used while later paste. In a copy/paste actions
- copy(selection, smart_selection_adaption=True)¶
Copy all selected items to the clipboard using smart selection adaptation by default
- Parameters
selection – the current selection
smart_selection_adaption (bool) – flag to enable smart selection adaptation mode
- Returns
- cut(selection, smart_selection_adaption=False)¶
Cuts all selected items and copy them to the clipboard using smart selection adaptation by default
- Parameters
selection – the current selection
smart_selection_adaption (bool) – flag to enable smart selection adaptation mode
- Returns
- destroy()¶
Destroys the clipboard by relieving all model references.
- static destroy_all_models_in_dict(target_dict)¶
Method runs the prepare destruction method of models which are assumed in list or tuple as values within a dict
- static do_selection_reduction_to_one_parent(selection)¶
Find and reduce selection to one parent state.
- Parameters
selection –
- Returns
state model which is parent of selection or None if root state
- static do_smart_selection_adaption(selection, parent_m)¶
Reduce and extend transition and data flow element selection if already enclosed by selection
The smart selection adaptation checks and ignores directly data flows and transitions which are selected without selected related origin or targets elements. Additional the linkage (data flows and transitions) if those origins and targets are covered by the selected elements is added to the selection. Thereby the selection it self is manipulated to provide direct feedback to the user.
- Parameters
selection –
parent_m –
- Returns
- get_action_arguments(target_state_m)¶
Collect argument attributes for action signal
Use non empty list dict to create arguments for action signal msg and logger messages. The action parent model can be different then the target state model because logical and data port changes also may influence the linkage, see action-module (undo/redo).
- Parameters
target_state_m (rafcon.gui.models.abstract_state.AbstractStateModel) – State model of target of action
- Returns
dict with lists of elements part of the action, action parent model
- get_semantic_dictionary_list()¶
- paste(target_state_m, cursor_position=None, limited=None, convert=False)¶
Paste objects to target state
The method checks whether the target state is a execution state or a container state and inserts respective elements and notifies the user if the parts can not be insert to the target state. - for ExecutionStates outcomes, input- and output-data ports can be inserted - for ContainerState additional states, scoped variables and data flows and/or transitions (if related) can be inserted
Related data flows and transitions are determined by origin and target keys and respective objects which has to be in the state machine selection, too. Thus, transitions or data flows without the related objects are not copied. :param target_state_m: state in which the copied/cut elements should be insert :param cursor_position: cursor position relative to the target_state_m as item coordinates, used to adapt meta data positioning of elements e.g states and via points. :return:
- prepare_new_copy()¶
- reset_clipboard_mapping_dicts()¶
Reset mapping dictionaries
- set_semantic_dictionary_list(semantic_data)¶
- rafcon.gui.clipboard.singular_form(name)¶
shortcut_manager¶
- class rafcon.gui.shortcut_manager.ShortcutManager(window)¶
Bases:
object
Handles shortcuts
Holds a mapping between shortcuts and action. Actions can be subscribed to. When a listed shortcut is triggered, all subscribers are notified.
- add_callback_for_action(action, callback)¶
Adds a callback function to an action
The method checks whether both action and callback are valid. If so, the callback is added to the list of functions called when the action is triggered.
- destroy()¶
- register_shortcuts()¶
- remove_callback_for_action(action, callback)¶
Remove a callback for a specific action
This is mainly for cleanup purposes or a plugin that replaces a GUI widget.
- Parameters
action (str) – the cation of which the callback is going to be remove
callback – the callback to be removed
- remove_callbacks_for_controller(controller)¶
- remove_shortcuts()¶
- trigger_action(action, key_value, modifier_mask, **kwargs)¶
Calls the appropriate callback function(s) for the given action
- Parameters
action (str) – The name of the action that was triggered
key_value – The key value of the shortcut that caused the trigger
modifier_mask – The modifier mask of the shortcut that caused the trigger
cursor_position – The position of the cursor, relative to the main window.
- Returns
Whether a callback was triggered
- Return type
- update_shortcuts()¶