DynExp
Highly flexible laboratory automation for dynamically changing experiments.
|
Implements DynExp's main window as a Qt-based user interface (UI). More...
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. More... | |
~DynExpManager ()=default | |
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. More... | |
bool | StopItem (DynExp::RunnableObject *Object, bool Force=false) noexcept |
Calls DynExp::RunnableObject::Terminate() on a DynExp::RunnableObject instance. More... | |
void | FocusMainWindow () noexcept |
Focuses/activates DynExp's main window and moves it on top of other windows if possible. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
void | EnsureItemReadyState (DynExp::Object *Object) |
Calls DynExp::Object::EnsureReadyState() on a DynExp::Object instance. More... | |
void | ResetItem (DynExp::Object *Object) |
Calls DynExp::Object::Reset() on a DynExp::Object instance. More... | |
QColor | HTMLColorStringToThemeColor (const std::string &HTMLColor) const |
Constructs a QColor instance from an HTML color string depending on the currently active UI theme. More... | |
QColor | AdjustColorToThemeColor (const QColor &Color) const |
Transforms a QColor instance depending on the currently active UI theme. More... | |
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. More... | |
bool | CloseProject () noexcept |
Closes the current project and opens a new, empty one. More... | |
bool | Shutdown () noexcept |
Terminates DynExpCore::WorkerThread and waits until the thread has ended. More... | |
void | SaveProject (std::string_view Filename) noexcept |
Saves the current DynExp project to an XML project file. More... | |
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. More... | |
void | UpdateModuleWindowsActionShortcuts () noexcept |
Establishes shortcuts to switch between module windows. Refer to ModuleWindowsActionGroup. More... | |
void | UpdateModuleWindowsActionIcons () noexcept |
Invokes DynExp::QModuleBase::UpdateModuleWindowFocusAction() on each module. More... | |
DynExp::QModuleBase * | GetModuleByActiveUIWindow () noexcept |
Determines the DynExp::QModuleBase instance of the current project whose UI window is active (has the focus). More... | |
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. More... | |
void | UpdateItemTreeItemObjectName (QTreeWidgetItem *Item, const DynExp::Object *Object) |
Updates the text of a QTreeWidgetItem instance to match it to the related DynExp::Object instance. More... | |
void | SelectItemTreeItem (QTreeWidgetItem *SelectedEntry) |
Selects the given QTreeWidgetItem instance and brings this DynExpManager window to the front. More... | |
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. More... | |
Private Attributes | |
DynExp::DynExpCore & | DynExpCore |
Handle to DynExp's internal data. More... | |
Ui::DynExpManagerClass | ui |
Qt widgets belonging to the main window's user interface. More... | |
QTimer * | UpdateUITimer |
Timer for periodically updating the user interface. More... | |
DynExpAbout * | AboutDialog |
Dialog showing license and copyright information. More... | |
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. More... | |
ErrorListDialog * | ErrorListDlg |
Dialog showing the list of currently active warnings and errors (ErrorEntries) More... | |
QActionGroup * | ModuleWindowsActionGroup |
Actions to switch between module windows with CTRL + < number key > shortcuts. More... | |
QActionGroup * | UIThemeActionGroup |
Actions to switch in between different UI themes. More... | |
QAction * | UIBrightThemeAction |
Action for a bright UI theme. More... | |
QAction * | UIDarkThemeAction |
Action for a dark UI theme. More... | |
QMenu * | LogContextMenu |
Context menu appearing when right-clicking on the message log widget. More... | |
QMenu * | ItemTreeContextMenu |
Context menu appearing when right-clicking on the main tree widget showing DynExp::Object instances. More... | |
QAction * | ClearWarningAction |
Action to clear the warning of an item within the main tree widget showing DynExp::Object instances. More... | |
QTreeWidgetItem * | ItemTreeHardwareAdapters |
Item for the hardware adapters section within the main tree widget showing DynExp::Object instances. More... | |
QTreeWidgetItem * | ItemTreeInstruments |
Item for the instruments section within the main tree widget showing DynExp::Object instances. More... | |
QTreeWidgetItem * | ItemTreeModules |
Item for the modules section within the main tree widget showing DynExp::Object instances. More... | |
struct DynExpManager::StatusBarType | StatusBar |
ErrorListDialog::ErrorEntriesType | ErrorEntries |
List of all currently active warnings and errors. More... | |
bool | IsResetting |
Indicates whether DynExpManager is currently deleting all resources to empty the project. More... | |
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. More... | |
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! More... | |
Implements DynExp's main window as a Qt-based user interface (UI).
Definition at line 20 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 7 of file DynExpManager.cpp.
|
default |
|
private |
Transforms a QColor
instance depending on the currently active UI theme.
Color | Original QColor instance |
QColor
instance. Definition at line 780 of file DynExpManager.cpp.
|
private |
Definition at line 720 of file DynExpManager.cpp.
|
private |
Definition at line 656 of file DynExpManager.cpp.
|
private |
Definition at line 736 of file DynExpManager.cpp.
|
private |
Definition at line 749 of file DynExpManager.cpp.
|
private |
Definition at line 688 of file DynExpManager.cpp.
|
private |
Definition at line 672 of file DynExpManager.cpp.
|
private |
Definition at line 704 of file DynExpManager.cpp.
|
overrideprivatevirtual |
Definition at line 1040 of file DynExpManager.cpp.
|
privatenoexcept |
Closes the current project and opens a new, empty one.
Definition at line 815 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 941 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 152 of file DynExpManager.cpp.
|
noexcept |
Focuses/activates DynExp's main window and moves it on top of other windows if possible.
Definition at line 1141 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 362 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 1002 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 133 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 765 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 441 of file DynExpManager.h.
|
privateslot |
Definition at line 1841 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1931 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1936 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1941 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1870 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1902 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1649 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1729 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1827 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1595 of file DynExpManager.cpp.
|
privateslot |
Definition at line 2005 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1946 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1865 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1860 of file DynExpManager.cpp.
|
privateslot |
Definition at line 2010 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1220 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1226 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1468 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1404 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1600 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1437 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1499 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1313 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1294 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1302 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1835 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1846 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1552 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1371 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1199 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1153 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1821 of file DynExpManager.cpp.
|
privateslot |
Definition at line 1814 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 1147 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 413 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 1057 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 796 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 186 of file DynExpManager.cpp.
|
private |
Definition at line 249 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 910 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 631 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 367 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 867 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 1086 of file DynExpManager.cpp.
|
private |
Definition at line 364 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 513 of file DynExpManager.h.
|
private |
Definition at line 392 of file DynExpManager.cpp.
|
private |
Definition at line 417 of file DynExpManager.cpp.
|
private |
Definition at line 473 of file DynExpManager.cpp.
|
private |
Definition at line 529 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 611 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 528 of file DynExpManager.h.
|
private |
Definition at line 222 of file DynExpManager.cpp.
|
privatenoexcept |
Definition at line 256 of file DynExpManager.cpp.
|
privatenoexcept |
Invokes DynExp::QModuleBase::UpdateModuleWindowFocusAction() on each module.
Definition at line 967 of file DynExpManager.cpp.
|
privatenoexcept |
Establishes shortcuts to switch between module windows. Refer to ModuleWindowsActionGroup.
Definition at line 953 of file DynExpManager.cpp.
|
private |
Definition at line 319 of file DynExpManager.cpp.
|
private |
Definition at line 305 of file DynExpManager.cpp.
|
private |
Dialog showing license and copyright information.
Definition at line 260 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 266 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 275 of file DynExpManager.h.
|
private |
Handle to DynExp's internal data.
Definition at line 255 of file DynExpManager.h.
|
private |
List of all currently active warnings and errors.
Definition at line 308 of file DynExpManager.h.
|
private |
Dialog showing the list of currently active warnings and errors (ErrorEntries)
Definition at line 268 of file DynExpManager.h.
|
private |
Indicates whether DynExpManager is currently deleting all resources to empty the project.
Definition at line 313 of file DynExpManager.h.
|
private |
Context menu appearing when right-clicking on the main tree widget showing DynExp::Object instances.
Definition at line 274 of file DynExpManager.h.
|
private |
Item for the hardware adapters section within the main tree widget showing DynExp::Object instances.
Definition at line 276 of file DynExpManager.h.
|
private |
Item for the instruments section within the main tree widget showing DynExp::Object instances.
Definition at line 277 of file DynExpManager.h.
|
private |
Item for the modules section within the main tree widget showing DynExp::Object instances.
Definition at line 278 of file DynExpManager.h.
|
private |
Context menu appearing when right-clicking on the message log widget.
Definition at line 273 of file DynExpManager.h.
|
private |
Actions to switch between module windows with CTRL + < number key > shortcuts.
Definition at line 269 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 319 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 327 of file DynExpManager.h.
|
private |
|
private |
Qt widgets belonging to the main window's user interface.
Definition at line 257 of file DynExpManager.h.
|
private |
Action for a bright UI theme.
Definition at line 271 of file DynExpManager.h.
|
private |
Action for a dark UI theme.
Definition at line 272 of file DynExpManager.h.
|
private |
Actions to switch in between different UI themes.
Definition at line 270 of file DynExpManager.h.
|
private |
Timer for periodically updating the user interface.
Definition at line 259 of file DynExpManager.h.