|
DynExp
Highly flexible laboratory automation for dynamically changing experiments.
|
Implements DynExp's main window as a Qt-based user interface (UI). More...
#include <DynExpManager.h>
Inheritance diagram for DynExpManager:Classes | |
| struct | ItemTreeItemDataType |
Bundles data which is assigned to items of the main QTreeWidget. Each item refers to a DynExp::Object instance. More... | |
| struct | StatusBarType |
| Type bundling widgets to be displayed in the main window's status bar. More... | |
Public Member Functions | |
| DynExpManager (DynExp::DynExpCore &DynExpCore, QWidget *parent=Q_NULLPTR) | |
Constructs a DynExpManager instance. | |
| ~DynExpManager () | |
| void | RegisterModuleUI (DynExp::Object *const Object) |
Initializes the UI of the module Object (expecting that Object is a DynExp::QModuleBase instance. Does nothing if this is not the case or if the module is not running. Resets the module in case the initialization of its UI fails. | |
| bool | StopItem (DynExp::RunnableObject *Object, bool Force=false) noexcept |
| Calls DynExp::RunnableObject::Terminate() on a DynExp::RunnableObject instance. | |
| void | FocusMainWindow () noexcept |
| Focuses/activates DynExp's main window and moves it on top of other windows if possible. | |
| void | PostKeyPressEvent (QKeyEvent *Event) noexcept |
| Delegates a Qt key press event (e.g. the key sequences Ctrl+1 - Ctrl+9) from module widgets to the main window. | |
| std::string | GetDataSaveDirectory () const |
| Recalls a path where modules might save recorded data to. Used by Util::PromptSaveFilePathModule() to recall the directory the user has chosen last for saving a file. This directory is the same across all modules. | |
| void | SetDataSaveDirectory (std::string_view Directory) const |
| Sets a path where modules might save recorded data to. Used by Util::PromptSaveFilePathModule() to store the directory the user has chosen last for saving a file. This directory is the same across all modules. | |
Private Member Functions | |
| template<typename LibraryVectorT > | |
| void | RegisterItemsFromLibrary (const LibraryVectorT &Lib, QMenu *const MenuBase, const QString IconPath, void(DynExpManager::*Slot)()) |
Adds the library entries from Lib to submenus below MenuBase and assigns actions to them invoking Slot when clicked. Submenus are defined by the library entries' categories and the actions assigned to the submenus by the entries' names. | |
| template<typename LibraryVectorT , typename ManagerT > | |
| void | MakeItem (QAction *SenderAction, LibraryVectorT &Lib, ManagerT &ResourceManager) |
Creates a DynExp::Object instance according to a QAction instance SenderAction, which contains the index (as its data property) of the item within a library vector Lib to instantiate. Displays a configuration dialog (ParamsConfigDialog) to let the user set the object's parameters. | |
| template<typename LibraryVectorT , typename ManagerT > | |
| bool | UpdateItemConfig (DynExp::Object *Object, LibraryVectorT &Lib, ManagerT &ResourceManager) |
| Invokes a configuration dialog to let the user adjust the parameters of a DynExp::Object instance. | |
| void | EnsureItemReadyState (DynExp::Object *Object) |
| Calls DynExp::Object::EnsureReadyState() on a DynExp::Object instance. | |
| void | ResetItem (DynExp::Object *Object) |
| Calls DynExp::Object::Reset() on a DynExp::Object instance. | |
| QColor | HTMLColorStringToThemeColor (const std::string &HTMLColor) const |
Constructs a QColor instance from an HTML color string depending on the currently active UI theme. | |
| QColor | AdjustColorToThemeColor (const QColor &Color) const |
Transforms a QColor instance depending on the currently active UI theme. | |
| void | Reset (bool Force=false) |
| Resets the currently loaded project removing all resources from the resource managers. After a call to this function, a new empty project is available. | |
| bool | CloseProject () noexcept |
| Closes the current project and opens a new, empty one. | |
| bool | Shutdown () noexcept |
| Terminates DynExpCore::WorkerThread and waits until the thread has ended. | |
| void | SaveProject (std::string_view Filename) noexcept |
| Saves the current DynExp project to an XML project file. | |
| void | DisableAllActions () noexcept |
| Disables all user interface actions such that item-specific ones can be reenabled upon a selection change in the main tree widget showing DynExp::Object instances. | |
| void | UpdateModuleWindowsActionShortcuts () noexcept |
| Establishes shortcuts to switch between module windows. Refer to ModuleWindowsActionGroup. | |
| void | UpdateModuleWindowsActionIcons () noexcept |
| Invokes DynExp::QModuleBase::UpdateModuleWindowFocusAction() on each module. | |
| DynExp::QModuleBase * | GetModuleByActiveUIWindow () noexcept |
| Determines the DynExp::QModuleBase instance of the current project whose UI window is active (has the focus). | |
UI functions | |
Functions updating the user interface. Called periodically in | |
| void | UpdateLog () |
| void | ResetLogColors () |
| void | UpdateModulesUI () noexcept |
| void | UpdateTitleBar () |
| void | UpdateStatusBar () |
| void | UpdateCircuitDiagram () |
| void | UpdateItemTree () |
| void | UpdateItemTreeItem (const DynExp::HardwareAdapterManager::ResourceType &Resource) |
| void | UpdateItemTreeItem (const DynExp::InstrumentManager::ResourceType &Resource) |
| void | UpdateItemTreeItem (const DynExp::ModuleManager::ResourceType &Resource) |
UI item tree functions | |
Functions to update and manipulate the main | |
| template<typename ManagerT > | |
| QTreeWidgetItem * | UpdateItemTreeSection (QTreeWidgetItem *Section, ManagerT &ResourceManager) |
Loops through resources managed by ResourceManager and adds respective QTreeWidgetItem instances as childs to Section. Data is assigned to the user role of the columns of added items: column 0's data contains a boolean flag which is true if column 0's text (object name) needs to be updated. column 1's data contains a pointer (QTreeWidgetItem*) to the respectve item. column 2's data contains a ItemTreeItemDataType instance. | |
| void | UpdateItemTreeItemObjectName (QTreeWidgetItem *Item, const DynExp::Object *Object) |
Updates the text of a QTreeWidgetItem instance to match it to the related DynExp::Object instance. | |
| void | SelectItemTreeItem (QTreeWidgetItem *SelectedEntry) |
Selects the given QTreeWidgetItem instance and brings this DynExpManager window to the front. | |
| void | ChangeItemTreeItemToNormalState (QTreeWidgetItem &ItemTreeItem, const ItemTreeItemDataType &ItemTreeItemData, const QString &Description, const QString &StateTitle, const char *IconPath=DynExpUI::Icons::Stopped) |
| void | ChangeItemTreeItemToRunningState (QTreeWidgetItem &ItemTreeItem, const ItemTreeItemDataType &ItemTreeItemData, const QString &Description) |
| void | ChangeItemTreeItemToPausedState (QTreeWidgetItem &ItemTreeItem, const ItemTreeItemDataType &ItemTreeItemData, const QString &Description) |
| void | ChangeItemTreeItemToWarningState (QTreeWidgetItem &ItemTreeItem, const ItemTreeItemDataType &ItemTreeItemData, const QString &Description) |
| void | ChangeItemTreeItemToErrorState (QTreeWidgetItem &ItemTreeItem, const ItemTreeItemDataType &ItemTreeItemData, const std::exception_ptr &ExceptionPtr) |
| void | ChangeItemTreeItemToNotConnectedState (QTreeWidgetItem &ItemTreeItem, const ItemTreeItemDataType &ItemTreeItemData, const QString &Description) |
| void | ChangeItemTreeItemToNotRespondingState (QTreeWidgetItem &ItemTreeItem, const ItemTreeItemDataType &ItemTreeItemData, const QString &Description) |
Qt events | |
Overridden Qt event functions | |
| virtual void | closeEvent (QCloseEvent *event) override |
Static Private Member Functions | |
| static std::string | GetObjectNameSafe (DynExp::Object *Object) |
| Retrieves the name of a DynExp::Object instance from its parameter class instance. | |
Private Attributes | |
| DynExp::DynExpCore & | DynExpCore |
| Handle to DynExp's internal data. | |
| std::unique_ptr< Ui::DynExpManagerClass > | ui |
| Qt widgets belonging to the main window's user interface. | |
| QTimer * | UpdateUITimer |
| Timer for periodically updating the user interface. | |
| DynExpAbout * | AboutDialog |
| Dialog showing license and copyright information. | |
| std::unique_ptr< CircuitDiagram > | CircuitDiagramDlg |
| Dialog showing the circuit diagram of the current project. It has no parent to not stay on top of the main window, so delete it manually. | |
| ErrorListDialog * | ErrorListDlg |
| Dialog showing the list of currently active warnings and errors (ErrorEntries) | |
| QActionGroup * | ModuleWindowsActionGroup |
| Actions to switch between module windows with CTRL + < number key > shortcuts. | |
| QActionGroup * | UIThemeActionGroup |
| Actions to switch in between different UI themes. | |
| QAction * | UIBrightThemeAction |
| Action for a bright UI theme. | |
| QAction * | UIDarkThemeAction |
| Action for a dark UI theme. | |
| QMenu * | LogContextMenu |
| Context menu appearing when right-clicking on the message log widget. | |
| QMenu * | ItemTreeContextMenu |
| Context menu appearing when right-clicking on the main tree widget showing DynExp::Object instances. | |
| QAction * | ClearWarningAction |
| Action to clear the warning of an item within the main tree widget showing DynExp::Object instances. | |
| QTreeWidgetItem * | ItemTreeHardwareAdapters |
| Item for the hardware adapters section within the main tree widget showing DynExp::Object instances. | |
| QTreeWidgetItem * | ItemTreeInstruments |
| Item for the instruments section within the main tree widget showing DynExp::Object instances. | |
| QTreeWidgetItem * | ItemTreeModules |
| Item for the modules section within the main tree widget showing DynExp::Object instances. | |
| struct DynExpManager::StatusBarType | StatusBar |
| ErrorListDialog::ErrorEntriesType | ErrorEntries |
| List of all currently active warnings and errors. | |
| bool | IsResetting |
| Indicates whether DynExpManager is currently deleting all resources to empty the project. | |
| bool | ShouldRedrawCircuitDiagram |
| Indicates whether the circuit diagram has to be rebuilt. Particularly, this must be set to true directly after invalidating any pointers to QTreeWidgetItem instances of the main window's item tree. | |
| bool | ShouldUpdateCircuitDiagram |
| Indicates whether any item state has changed. Set to true to update the circuit diagram. The circuit diagram saves pointers to QTreeWidgetItem instances of the main window's item tree. Make sure that these pointers are still valid. If they have been invalidated, rebuild the circuit diagram first! | |
Implements DynExp's main window as a Qt-based user interface (UI).
Definition at line 24 of file DynExpManager.h.
| DynExpManager::DynExpManager | ( | DynExp::DynExpCore & | DynExpCore, |
| QWidget * | parent = Q_NULLPTR |
||
| ) |
Constructs a DynExpManager instance.
| DynExpCore | DynExp's internal data managed by this DynExpManager instance |
| parent | Parent Qt widget owning this main window. Pass nullptr. |
Definition at line 8 of file DynExpManager.cpp.
| DynExpManager::~DynExpManager | ( | ) |
Definition at line 97 of file DynExpManager.cpp.
|
private |
Transforms a QColor instance depending on the currently active UI theme.
| Color | Original QColor instance |
QColor instance. Definition at line 786 of file DynExpManager.cpp.
|
private |
Definition at line 726 of file DynExpManager.cpp.
|
private |
Definition at line 662 of file DynExpManager.cpp.
|
private |
Definition at line 742 of file DynExpManager.cpp.
|
private |
Definition at line 755 of file DynExpManager.cpp.
|
private |
Definition at line 694 of file DynExpManager.cpp.
|
private |
Definition at line 678 of file DynExpManager.cpp.
|
private |
Definition at line 710 of file DynExpManager.cpp.
|
overrideprivatevirtual |
Definition at line 1046 of file DynExpManager.cpp.
|
privatenoexcept |
Closes the current project and opens a new, empty one.
Definition at line 821 of file DynExpManager.cpp.
|
privatenoexcept |
Disables all user interface actions such that item-specific ones can be reenabled upon a selection change in the main tree widget showing DynExp::Object instances.
Definition at line 947 of file DynExpManager.cpp.
|
private |
Calls DynExp::Object::EnsureReadyState() on a DynExp::Object instance.
| Object | DynExp::Object instance to make ready. Does nothing if Object is nullptr. |
Definition at line 158 of file DynExpManager.cpp.
|
noexcept |
Focuses/activates DynExp's main window and moves it on top of other windows if possible.
Definition at line 1147 of file DynExpManager.cpp.
|
inline |
Recalls a path where modules might save recorded data to. Used by Util::PromptSaveFilePathModule() to recall the directory the user has chosen last for saving a file. This directory is the same across all modules.
Definition at line 366 of file DynExpManager.h.
|
privatenoexcept |
Determines the DynExp::QModuleBase instance of the current project whose UI window is active (has the focus).
Definition at line 1008 of file DynExpManager.cpp.
|
staticprivate |
Retrieves the name of a DynExp::Object instance from its parameter class instance.
| Object | DynExp::Object whose name to retrieve |
Object or a string indicating an error if retrieving the name failed. Definition at line 139 of file DynExpManager.cpp.
|
private |
Constructs a QColor instance from an HTML color string depending on the currently active UI theme.
| HTMLColor | HTML color string to construct a QColor instance from |
QColor instance. Definition at line 771 of file DynExpManager.cpp.
|
private |
Creates a DynExp::Object instance according to a QAction instance SenderAction, which contains the index (as its data property) of the item within a library vector Lib to instantiate. Displays a configuration dialog (ParamsConfigDialog) to let the user set the object's parameters.
| LibraryVectorT | Type of a list of library entries (DynExp::LibraryEntry) |
| ManagerT | Type of the resource manager managing instances of type extracted from SenderAction |
| SenderAction | QAction which has been triggered to generate a certain DynExp::Object instance. |
| Lib | List of library entries to select the entry to be instantiated from according to the QAction::data() property stored in SenderAction |
| ResourceManager | Resource manager to insert the newly generated DynExp::Object instance into |
Definition at line 445 of file DynExpManager.h.
|
privateslot |
Definition at line 1847 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1937 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1942 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1947 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1876 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1908 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1655 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1735 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1833 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1601 of file DynExpManager.cpp.
|
privateslot |
Definition at line 2011 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1952 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1871 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1866 of file DynExpManager.cpp.
|
privateslot |
Definition at line 2016 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1226 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1232 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1474 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1410 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1606 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1443 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1505 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1319 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1300 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1308 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1841 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1852 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1558 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1377 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1205 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1159 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1827 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1820 of file DynExpManager.cpp.
|
noexcept |
Delegates a Qt key press event (e.g. the key sequences Ctrl+1 - Ctrl+9) from module widgets to the main window.
| Event | Qt event to delegate. Refer to Qt documentation. |
Definition at line 1153 of file DynExpManager.cpp.
|
private |
Adds the library entries from Lib to submenus below MenuBase and assigns actions to them invoking Slot when clicked. Submenus are defined by the library entries' categories and the actions assigned to the submenus by the entries' names.
| LibraryVectorT | Type of the library vector |
| Lib | Library vector whose items to add to the menu |
| MenuBase | Parent menu where to add submenus to |
| IconPath | Icon to display next to the actions |
| Slot | Qt slot function to call when the action related to a library entry is triggered. |
Definition at line 417 of file DynExpManager.h.
| void DynExpManager::RegisterModuleUI | ( | DynExp::Object *const | Object | ) |
Initializes the UI of the module Object (expecting that Object is a DynExp::QModuleBase instance. Does nothing if this is not the case or if the module is not running. Resets the module in case the initialization of its UI fails.
| Object | Module whose UI to initialize |
| Util::InvalidArgException | is thrown if Object is nullptr. |
Definition at line 1063 of file DynExpManager.cpp.
|
private |
Resets the currently loaded project removing all resources from the resource managers. After a call to this function, a new empty project is available.
| Force | If false, ResourceManagerBase::PrepareReset() is called on each owned resource manager, before calls to ResourceManagerBase::Reset() follow. If true, only the latter method is called. |
Definition at line 802 of file DynExpManager.cpp.
|
private |
Calls DynExp::Object::Reset() on a DynExp::Object instance.
| Object | DynExp::Object instance to reset. Does nothing if Object is nullptr. |
Definition at line 192 of file DynExpManager.cpp.
|
private |
Definition at line 255 of file DynExpManager.cpp.
|
privatenoexcept |
Saves the current DynExp project to an XML project file.
| Filename | Path where to save the DynExp project XML file |
Definition at line 916 of file DynExpManager.cpp.
|
private |
Selects the given QTreeWidgetItem instance and brings this DynExpManager window to the front.
| SelectedEntry | QTreeWidgetItem instance to select |
Definition at line 637 of file DynExpManager.cpp.
|
inline |
Sets a path where modules might save recorded data to. Used by Util::PromptSaveFilePathModule() to store the directory the user has chosen last for saving a file. This directory is the same across all modules.
| Directory | Path to show by default in the modules' file open/save dialogs. |
Definition at line 371 of file DynExpManager.h.
|
privatenoexcept |
Terminates DynExpCore::WorkerThread and waits until the thread has ended.
If the worker thread cannot be stopped, offers to terminate the application.
Definition at line 873 of file DynExpManager.cpp.
|
noexcept |
Calls DynExp::RunnableObject::Terminate() on a DynExp::RunnableObject instance.
| Object | DynExp::RunnableObject instance to terminate. Does nothing if Object is nullptr. |
| Force | If true, Object is terminated even if it is still used. |
Definition at line 1092 of file DynExpManager.cpp.
|
private |
Definition at line 370 of file DynExpManager.cpp.
|
private |
Invokes a configuration dialog to let the user adjust the parameters of a DynExp::Object instance.
| LibraryVectorT | Type of the library vector the object to be configured belongs to |
| ManagerT | Type of the resource manager owning the object to be configured |
| Object | DynExp::Object instance to be configured |
| Lib | Library vector the object to be configured belongs to |
| ResourceManager | Resource manager owning the object to be configured |
| Util::InvalidArgException | is thrown if Object is nullptr. |
Definition at line 517 of file DynExpManager.h.
|
private |
Definition at line 398 of file DynExpManager.cpp.
|
private |
Definition at line 423 of file DynExpManager.cpp.
|
private |
Definition at line 479 of file DynExpManager.cpp.
|
private |
Definition at line 535 of file DynExpManager.cpp.
|
private |
Updates the text of a QTreeWidgetItem instance to match it to the related DynExp::Object instance.
| Item | QTreeWidgetItem instance to adjust |
| Object | DynExp::Object instance related to Item |
Definition at line 617 of file DynExpManager.cpp.
|
private |
Loops through resources managed by ResourceManager and adds respective QTreeWidgetItem instances as childs to Section. Data is assigned to the user role of the columns of added items: column 0's data contains a boolean flag which is true if column 0's text (object name) needs to be updated. column 1's data contains a pointer (QTreeWidgetItem*) to the respectve item. column 2's data contains a ItemTreeItemDataType instance.
| ManagerT | Type of ResourceManager (type derived from class DynExp::ResourceManagerBase). |
| Section | Parent QTreeWidgetItem listing ResourceManager's resources as child items. |
| ResourceManager | Instance of type ManagerT containing resources to be processed. |
Section. Definition at line 532 of file DynExpManager.h.
|
private |
Definition at line 228 of file DynExpManager.cpp.
|
privatenoexcept |
Definition at line 262 of file DynExpManager.cpp.
|
privatenoexcept |
Invokes DynExp::QModuleBase::UpdateModuleWindowFocusAction() on each module.
Definition at line 973 of file DynExpManager.cpp.
|
privatenoexcept |
Establishes shortcuts to switch between module windows. Refer to ModuleWindowsActionGroup.
Definition at line 959 of file DynExpManager.cpp.
|
private |
Definition at line 325 of file DynExpManager.cpp.
|
private |
Definition at line 311 of file DynExpManager.cpp.
|
private |
Dialog showing license and copyright information.
Definition at line 264 of file DynExpManager.h.
|
private |
Dialog showing the circuit diagram of the current project. It has no parent to not stay on top of the main window, so delete it manually.
Definition at line 270 of file DynExpManager.h.
|
private |
Action to clear the warning of an item within the main tree widget showing DynExp::Object instances.
Definition at line 279 of file DynExpManager.h.
|
private |
Handle to DynExp's internal data.
Definition at line 259 of file DynExpManager.h.
|
private |
List of all currently active warnings and errors.
Definition at line 312 of file DynExpManager.h.
|
private |
Dialog showing the list of currently active warnings and errors (ErrorEntries)
Definition at line 272 of file DynExpManager.h.
|
private |
Indicates whether DynExpManager is currently deleting all resources to empty the project.
Definition at line 317 of file DynExpManager.h.
|
private |
Context menu appearing when right-clicking on the main tree widget showing DynExp::Object instances.
Definition at line 278 of file DynExpManager.h.
|
private |
Item for the hardware adapters section within the main tree widget showing DynExp::Object instances.
Definition at line 280 of file DynExpManager.h.
|
private |
Item for the instruments section within the main tree widget showing DynExp::Object instances.
Definition at line 281 of file DynExpManager.h.
|
private |
Item for the modules section within the main tree widget showing DynExp::Object instances.
Definition at line 282 of file DynExpManager.h.
|
private |
Context menu appearing when right-clicking on the message log widget.
Definition at line 277 of file DynExpManager.h.
|
private |
Actions to switch between module windows with CTRL + < number key > shortcuts.
Definition at line 273 of file DynExpManager.h.
|
private |
Indicates whether the circuit diagram has to be rebuilt. Particularly, this must be set to true directly after invalidating any pointers to QTreeWidgetItem instances of the main window's item tree.
Definition at line 323 of file DynExpManager.h.
|
private |
Indicates whether any item state has changed. Set to true to update the circuit diagram. The circuit diagram saves pointers to QTreeWidgetItem instances of the main window's item tree. Make sure that these pointers are still valid. If they have been invalidated, rebuild the circuit diagram first!
Definition at line 331 of file DynExpManager.h.
|
private |
|
private |
Qt widgets belonging to the main window's user interface.
Definition at line 261 of file DynExpManager.h.
|
private |
Action for a bright UI theme.
Definition at line 275 of file DynExpManager.h.
|
private |
Action for a dark UI theme.
Definition at line 276 of file DynExpManager.h.
|
private |
Actions to switch in between different UI themes.
Definition at line 274 of file DynExpManager.h.
|
private |
Timer for periodically updating the user interface.
Definition at line 263 of file DynExpManager.h.