|
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 95 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 784 of file DynExpManager.cpp.
|
private |
Definition at line 724 of file DynExpManager.cpp.
|
private |
Definition at line 660 of file DynExpManager.cpp.
|
private |
Definition at line 740 of file DynExpManager.cpp.
|
private |
Definition at line 753 of file DynExpManager.cpp.
|
private |
Definition at line 692 of file DynExpManager.cpp.
|
private |
Definition at line 676 of file DynExpManager.cpp.
|
private |
Definition at line 708 of file DynExpManager.cpp.
|
overrideprivatevirtual |
Definition at line 1044 of file DynExpManager.cpp.
|
privatenoexcept |
Closes the current project and opens a new, empty one.
Definition at line 819 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 945 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 156 of file DynExpManager.cpp.
|
noexcept |
Focuses/activates DynExp's main window and moves it on top of other windows if possible.
Definition at line 1145 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 1006 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 137 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 769 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 1845 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1935 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1940 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1945 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1874 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1906 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1653 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1733 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1831 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1599 of file DynExpManager.cpp.
|
privateslot |
Definition at line 2009 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1950 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1869 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1864 of file DynExpManager.cpp.
|
privateslot |
Definition at line 2014 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1224 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1230 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1472 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1408 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1604 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1441 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1503 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1317 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1298 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1306 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1839 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1850 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1556 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1375 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1203 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1157 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1825 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1818 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 1151 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 1061 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 800 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 190 of file DynExpManager.cpp.
|
private |
Definition at line 253 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 914 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 635 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 871 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 1090 of file DynExpManager.cpp.
|
private |
Definition at line 368 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 396 of file DynExpManager.cpp.
|
private |
Definition at line 421 of file DynExpManager.cpp.
|
private |
Definition at line 477 of file DynExpManager.cpp.
|
private |
Definition at line 533 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 615 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 226 of file DynExpManager.cpp.
|
privatenoexcept |
Definition at line 260 of file DynExpManager.cpp.
|
privatenoexcept |
Invokes DynExp::QModuleBase::UpdateModuleWindowFocusAction() on each module.
Definition at line 971 of file DynExpManager.cpp.
|
privatenoexcept |
Establishes shortcuts to switch between module windows. Refer to ModuleWindowsActionGroup.
Definition at line 957 of file DynExpManager.cpp.
|
private |
Definition at line 323 of file DynExpManager.cpp.
|
private |
Definition at line 309 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.