4 #include "moc_DynExpManager.cpp"
8 : QMainWindow(parent), DynExpCore(DynExpCore),
9 UpdateUITimer(new QTimer(this)),
11 ModuleWindowsActionGroup(new QActionGroup(this)),
12 UIThemeActionGroup(new QActionGroup(this)), UIBrightThemeAction(nullptr), UIDarkThemeAction(nullptr),
13 LogContextMenu(new QMenu(this)),
14 ItemTreeContextMenu(new QMenu(this)), ClearWarningAction(nullptr),
15 ItemTreeHardwareAdapters(nullptr), ItemTreeInstruments(nullptr), ItemTreeModules(nullptr),
16 StatusBar(this), IsResetting(false), ShouldRedrawCircuitDiagram(true), ShouldUpdateCircuitDiagram(false)
18 qApp->setStyle(QStyleFactory::create(
"Fusion"));
44 ui.tableLog->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
45 ui.tableLog->verticalHeader()->setMinimumSectionSize(18);
46 ui.tableLog->verticalHeader()->setDefaultSectionSize(
ui.tableLog->verticalHeader()->minimumSectionSize());
47 ui.tableLog->setColumnWidth(0, 140);
71 ui.treeItems->header()->resizeSection(0, 120);
72 ui.treeItems->header()->resizeSection(1, 180);
73 ui.treeItems->header()->resizeSection(2, 100);
74 ui.splitterInstrListMain->setStretchFactor(0, 16);
75 ui.splitterInstrListMain->setStretchFactor(1, 5);
96 : NumItemsInWarningState(0), NumItemsInErrorState(0),
97 State(new QPushButton(Owner)),
98 NumRunningInstrGroup(new QWidget(Owner)), NumRunningInstrLayout(new QHBoxLayout),
99 NumRunningInstrImage(new QLabel(Owner)), NumRunningInstr(new QLabel(Owner)),
100 NumRunningModuleGroup(new QWidget(Owner)), NumRunningModuleLayout(new QHBoxLayout),
101 NumRunningModuleImage(new QLabel(Owner)), NumRunningModule(new QLabel(Owner))
103 constexpr
int Height = 16;
105 State->setFlat(
true);
106 State->setMinimumHeight(24);
107 State->setFocusPolicy(Qt::FocusPolicy::NoFocus);
111 NumRunningInstrImage->setSizePolicy({ QSizePolicy::Policy::Minimum, QSizePolicy::Policy::Minimum });
114 NumRunningInstr->setSizePolicy({ QSizePolicy::Policy::Expanding, QSizePolicy::Policy::Expanding });
118 NumRunningModuleImage->setSizePolicy({ QSizePolicy::Policy::Minimum, QSizePolicy::Policy::Minimum });
121 NumRunningModule->setSizePolicy({ QSizePolicy::Policy::Expanding, QSizePolicy::Policy::Expanding });
135 std::string ObjectName =
"< Unknown >";
145 ObjectName =
"< Error while fetching name >";
157 std::string ErrorMessage =
"";
165 ErrorMessage = e.what();
167 catch (
const std::exception& e)
169 ErrorMessage = e.what();
173 ErrorMessage =
"Unknown Error";
176 if (!ErrorMessage.empty())
178 QMessageBox::warning(
this,
"DynExp - Error",
179 QString::fromStdString(
180 "Starting up the item " +
GetObjectNameSafe(Object) +
", the following error occurred:\n\n"
191 std::string ErrorMessage =
"";
199 ErrorMessage = e.what();
201 catch (
const std::exception& e)
203 ErrorMessage = e.what();
207 ErrorMessage =
"Unknown Error";
210 if (!ErrorMessage.empty())
214 QMessageBox::warning(
this,
"DynExp - Error",
215 QString::fromStdString(
216 "Resetting the item " + ObjectName +
", the following error occurred:\n\n"
225 if (EventLogSize >= std::numeric_limits<int>::max())
228 if (
ui.tableLog->rowCount() <
static_cast<int>(EventLogSize))
231 for (
const auto& LogEntry : Log)
233 const auto Row =
ui.tableLog->rowCount();
235 ui.tableLog->setRowCount(Row + 1);
236 ui.tableLog->setItem(Row, 0,
new QTableWidgetItem(QString::fromStdString(
Util::ToStr(LogEntry.TimePoint))));
238 ui.tableLog->setItem(Row, 2,
new QTableWidgetItem(QString::fromStdString(LogEntry.Message)));
240 for (
int i = 0; i < 3; ++i)
243 ui.tableLog->resizeColumnToContents(2);
244 ui.tableLog->scrollToBottom();
251 for (
auto i =
ui.tableLog->rowCount() - 1; i >= 0; --i)
252 for (
int j = 0; j < 3; ++j)
260 for (
auto ModuleIter = ModuleManager.cbegin(); ModuleIter != ModuleManager.cend(); ++ModuleIter)
264 auto Module = ModuleIter->second.ResourcePointer.get();
273 if (!QModule.IsRunning())
275 else if (QModule.IsPaused())
293 catch (
const std::exception& e)
310 setWindowTitle(QString::fromStdString(std::string(
"DynExp Manager - ") + ProjectFilename.string()));
313 setWindowTitle(
"DynExp Manager");
316 DynExp::ProjectParams::StoreWindowStatesType::ApplyStoredWindowStates);
345 if (NumRunningInstr + NumRunningModule > 0)
405 ItemToSelect = LastAdded;
408 ItemToSelect = LastAdded;
412 ui.treeItems->clearSelection();
413 ItemToSelect->setSelected(
true);
427 std::string ObjectName;
451 else if (!IsConnected)
455 "This hardware adapter is not connected yet, and thus it cannot be used now.");
464 constexpr
auto Msg =
"This hardware adapter does not respond.";
482 std::string ObjectName;
515 "This instrument is ready to be run.",
"Stopped");
520 constexpr
auto Msg =
"This instrument does not respond.";
533 static constexpr
auto PausedString =
"This module is paused because one or more linked instruments have been terminated. Restart these instruments in order to continue.";
534 static bool DisplayWarning =
false;
535 static auto DisplayWarningLastSwitchTime = std::chrono::system_clock::now();
539 DisplayWarning = !DisplayWarning;
540 DisplayWarningLastSwitchTime = std::chrono::system_clock::now();
548 std::string ObjectName;
572 ErrorEntries.emplace_back(QString::fromStdString(ObjectName),
573 QString(PausedString) +
"\n\n" + QString::fromStdString(Resource.
ResourcePointer->GetReasonWhyPaused().Description),
597 "This module is ready to be run.",
"Stopped");
602 constexpr
auto Msg =
"This module does not respond.";
614 bool FetchingObjectNameFailed =
false;
618 ObjectName = QString::fromStdString(Object->
GetObjectName());
622 ObjectName =
"< Error >";
623 FetchingObjectNameFailed =
true;
626 Item->setText(0, ObjectName);
627 Item->setToolTip(0, ObjectName);
628 Item->setData(0, Qt::ItemDataRole::UserRole, QVariant::fromValue(FetchingObjectNameFailed));
636 for (
int i = 0; i <
ui.treeItems->topLevelItemCount(); ++i)
638 QTreeWidgetItem* ParentItem =
ui.treeItems->topLevelItem(i);
639 for (
int j = 0; j < ParentItem->childCount(); ++j)
641 QTreeWidgetItem* ChildItem = ParentItem->child(j);
642 if (ChildItem->data(1, Qt::ItemDataRole::UserRole).value<decltype(SelectedEntry)>() == SelectedEntry)
646 ui.treeItems->clearSelection();
647 ui.treeItems->setFocus();
648 ChildItem->setSelected(
true);
657 const QString& Description,
const QString& StateTitle,
const char* IconPath)
659 ItemTreeItem.setData(2, Qt::ItemDataRole::UserRole,
661 ItemTreeItem.setIcon(2, QIcon(IconPath));
662 ItemTreeItem.setText(2, StateTitle);
663 ItemTreeItem.setForeground(2, QApplication::palette().text().color());
664 ItemTreeItem.setToolTip(2, Description);
673 const QString& Description)
675 ItemTreeItem.setData(2, Qt::ItemDataRole::UserRole,
678 ItemTreeItem.setText(2,
"Running");
680 ItemTreeItem.setToolTip(2, Description);
689 const QString& Description)
691 ItemTreeItem.setData(2, Qt::ItemDataRole::UserRole,
694 ItemTreeItem.setText(2,
"Paused");
696 ItemTreeItem.setToolTip(2, Description);
705 const QString& Description)
707 ItemTreeItem.setData(2, Qt::ItemDataRole::UserRole,
710 ItemTreeItem.setText(2,
"Warning");
712 ItemTreeItem.setToolTip(2, Description);
721 const std::exception_ptr& ExceptionPtr)
723 ItemTreeItem.setData(2, Qt::ItemDataRole::UserRole,
726 ItemTreeItem.setText(2,
"Error");
737 const QString& Description)
739 ItemTreeItem.setData(2, Qt::ItemDataRole::UserRole,
742 ItemTreeItem.setText(2,
"Connecting...");
743 ItemTreeItem.setForeground(2, QApplication::palette().text().color());
744 ItemTreeItem.setToolTip(2, Description);
750 const QString& Description)
752 ItemTreeItem.setData(2, Qt::ItemDataRole::UserRole,
755 ItemTreeItem.setText(2,
"Not responding");
757 ItemTreeItem.setToolTip(2, Description);
767 QString HTMLColorQ = QString::fromStdString(HTMLColor);
771 if (HTMLColorQ.toLower() ==
"blue")
773 if (HTMLColorQ.toLower() ==
"green")
777 return QColor(HTMLColorQ);
785 return QColor(
"blue");
789 if (Color == QColor(
"blue"))
818 if (QMessageBox::question(
this,
"DynExp - Close project?",
819 "Really close the current project? All running items will be stopped and unsaved changes will be lost.",
820 QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, QMessageBox::StandardButton::No)
821 != QMessageBox::StandardButton::Yes)
824 std::string ErrorMessage =
"";
832 ErrorMessage = e.what();
834 catch (
const std::exception& e)
836 ErrorMessage = e.what();
840 ErrorMessage =
"Unknown Error";
843 if (!ErrorMessage.empty())
845 auto Result = QMessageBox::critical(
this,
"DynExp - Critical error",
846 QString::fromStdString(
847 "Closing a project and stopping all running items, the following error occurred:\n\n"
848 + ErrorMessage +
"\n\n- Click 'Retry' to try again to close the project."
849 +
"\n- Click 'Ignore' to force the project to be closed. This may cause DynExp to be terminated without properly shutting down."
850 +
"\n- Click 'Cancel' to return to the project without closing it."
851 ), QMessageBox::StandardButton::Cancel | QMessageBox::StandardButton::Retry | QMessageBox::StandardButton::Ignore,
852 QMessageBox::StandardButton::Cancel);
856 case QMessageBox::StandardButton::Cancel:
return false;
857 case QMessageBox::StandardButton::Ignore:
return true;
869 std::string ErrorMessage =
"";
877 ErrorMessage = e.what();
879 catch (
const std::exception& e)
881 ErrorMessage = e.what();
885 ErrorMessage =
"Unknown Error";
888 if (!ErrorMessage.empty())
890 auto Result = QMessageBox::critical(
this,
"DynExp - Critical error",
891 QString::fromStdString(
892 "Stopping a worker thread, the following error occurred:\n\n"
893 + ErrorMessage +
"\n\n- Click 'Retry' to try again to stop the thread."
894 +
"\n- Click 'Ignore' to force DynExp to be terminated without properly shutting down."
895 +
"\n- Click 'Cancel' to return to DynExp without closing it."
896 ), QMessageBox::StandardButton::Cancel | QMessageBox::StandardButton::Retry | QMessageBox::StandardButton::Ignore,
897 QMessageBox::StandardButton::Cancel);
901 case QMessageBox::StandardButton::Cancel:
return false;
902 case QMessageBox::StandardButton::Ignore: std::terminate();
912 std::string ErrorMessage =
"";
920 ErrorMessage = e.what();
922 catch (
const std::exception& e)
924 ErrorMessage = e.what();
928 ErrorMessage =
"Unknown Error";
931 if (!ErrorMessage.empty())
933 QMessageBox::warning(
this,
"DynExp - Error",
934 QString::fromStdString(
935 std::string(
"Saving the project to file ").append(Filename)
936 +
", the following error occurred:\n\n" + ErrorMessage
943 ui.action_Run_Item->setEnabled(
false);
944 ui.action_Stop_Item->setEnabled(
false);
945 ui.action_Force_Stop_Item->setEnabled(
false);
946 ui.action_Reset_Item->setEnabled(
false);
947 ui.action_Configure_Item->setEnabled(
false);
948 ui.action_Delete_Item->setEnabled(
false);
958 for (std::remove_const_t<decltype(NumModules)> i = 0; i < NumModules; ++i)
971 for (
auto ModuleIter = ModuleManager.cbegin(); ModuleIter != ModuleManager.cend(); ++ModuleIter)
975 auto Module = ModuleIter->second.ResourcePointer.get();
990 catch (
const std::exception& e)
1006 for (
auto ModuleIter = ModuleManager.cbegin(); ModuleIter != ModuleManager.cend(); ++ModuleIter)
1010 auto Module = ModuleIter->second.ResourcePointer.get();
1018 if (QModule.IsActiveWindow())
1026 catch (
const std::exception& e)
1067 if (!
Module->IsRunning())
1072 auto const Action = &
Module->InitUI(*
this,
ui.mdiMain);
1075 ui.menu_Window->addAction(Action);
1091 std::string ErrorMessage =
"";
1092 std::string ObjectName =
"< Unknown >";
1096 Object->Terminate(Force);
1104 if (QMessageBox::warning(
this,
"DynExp - Force-terminate item?",
1105 QString(
"This runnable is currently being used by at least another item. Force-terminate the item?\n\n")
1107 QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, QMessageBox::StandardButton::No)
1108 == QMessageBox::StandardButton::Yes)
1116 ErrorMessage = e.what();
1118 catch (
const std::exception& e)
1120 ErrorMessage = e.what();
1124 ErrorMessage =
"Unknown Error";
1127 if (!ErrorMessage.empty())
1129 QMessageBox::warning(
this,
"DynExp - Error",
1130 QString::fromStdString(
1131 "Stopping the item " + ObjectName +
", the following error occurred:\n\n"
1150 QCoreApplication::postEvent(
this, Event->clone());
1156 if (std::uncaught_exceptions())
1180 catch (
const std::exception& e)
1203 qApp->setPalette(QPalette());
1204 qApp->setStyleSheet(
"");
1231 auto Filename =
Util::PromptOpenFilePath(
this,
"Open project",
".dynp",
"DynExp project files (*.dynp)").toStdString();
1232 if (Filename.empty())
1235 std::string ErrorMessage =
"";
1243 ErrorMessage = e.what();
1245 catch (
const std::exception& e)
1247 ErrorMessage = e.what();
1251 ErrorMessage =
"Unknown Error";
1254 if (!ErrorMessage.empty())
1256 QMessageBox::warning(
this,
"DynExp - Error",
1257 QString::fromStdString(
1258 "Opening a project from file " + Filename +
", the following error occurred:\n\n"
1269 Util::EventLog().
Log(
"Error occurred while resetting project. Execution cannot continue.",
1304 auto Filename =
Util::PromptSaveFilePath(
this,
"Save project as",
".dynp",
"DynExp project files (*.dynp)").toStdString();
1305 if (Filename.empty())
1315 std::string ErrorMessage =
"";
1321 auto BusyDlg = std::make_unique<BusyDialog>(
this);
1322 BusyDlg->SetDescriptionText(
"Connecting hardware adapters...");
1326 auto Result = BusyDlg->exec();
1327 ConnectingHardwareAdaptersFuture.wait();
1329 if (Result == QDialog::Accepted)
1331 BusyDlg->SetDescriptionText(
"Starting instruments...");
1335 Result = BusyDlg->exec();
1337 if (Result == QDialog::Accepted)
1339 else if (BusyDlg->GetException())
1340 std::rethrow_exception(BusyDlg->GetException());
1342 else if (BusyDlg->GetException())
1343 std::rethrow_exception(BusyDlg->GetException());
1348 ErrorMessage = e.what();
1350 catch (
const std::exception& e)
1352 ErrorMessage = e.what();
1356 ErrorMessage =
"Unknown Error";
1359 if (!ErrorMessage.empty())
1361 QMessageBox::warning(
this,
"DynExp - Error",
1362 QString::fromStdString(
1363 "Starting up the project, the following error occurred:\n\n"
1373 std::string ErrorMessage =
"";
1381 ErrorMessage = e.what();
1383 catch (
const std::exception& e)
1385 ErrorMessage = e.what();
1389 ErrorMessage =
"Unknown Error";
1392 if (!ErrorMessage.empty())
1394 QMessageBox::warning(
this,
"DynExp - Error",
1395 QString::fromStdString(
1396 "Shutting down the project, the following error occurred:\n\n"
1406 std::string ErrorMessage =
"";
1414 ErrorMessage = e.what();
1416 catch (
const std::exception& e)
1418 ErrorMessage = e.what();
1422 ErrorMessage =
"Unknown Error";
1425 if (!ErrorMessage.empty())
1427 QMessageBox::warning(
this,
"DynExp - Error",
1428 QString::fromStdString(
1429 "Resetting the project's failed items, the following error occurred:\n\n"
1439 std::string ErrorMessage =
"";
1447 ErrorMessage = e.what();
1449 catch (
const std::exception& e)
1451 ErrorMessage = e.what();
1455 ErrorMessage =
"Unknown Error";
1458 if (!ErrorMessage.empty())
1460 QMessageBox::warning(
this,
"DynExp - Error",
1461 QString::fromStdString(
1462 "Restoring the main and module windows' geometries and states from the project file, the following error occurred:\n\n"
1470 std::string ErrorMessage =
"";
1478 ErrorMessage = e.what();
1480 catch (
const std::exception& e)
1482 ErrorMessage = e.what();
1486 ErrorMessage =
"Unknown Error";
1489 if (!ErrorMessage.empty())
1491 QMessageBox::warning(
this,
"DynExp - Error",
1492 QString::fromStdString(
1493 "Editing the project settings, the following error occurred:\n\n"
1501 if (
ui.treeItems->selectedItems().length() != 1)
1504 auto Item =
ui.treeItems->selectedItems()[0];
1507 std::string ErrorMessage =
"";
1508 std::string ObjectName =
"< Unknown >";
1529 ErrorMessage = e.what();
1531 catch (
const std::exception& e)
1533 ErrorMessage = e.what();
1537 ErrorMessage =
"Unknown Error";
1540 if (!ErrorMessage.empty())
1542 QMessageBox::warning(
this,
"DynExp - Error",
1543 QString::fromStdString(
1544 "Starting the item " + ObjectName +
", the following error occurred:\n\n"
1554 if (
ui.treeItems->selectedItems().length() != 1)
1557 auto Item =
ui.treeItems->selectedItems()[0];
1561 std::string ErrorMessage =
"";
1572 ErrorMessage = e.what();
1574 catch (
const std::exception& e)
1576 ErrorMessage = e.what();
1580 ErrorMessage =
"Unknown Error";
1583 if (!ErrorMessage.empty())
1585 QMessageBox::warning(
this,
"DynExp - Error",
1586 QString::fromStdString(
1587 "Determining the object to be stopped, the following error occurred:\n\n"
1602 if (
ui.treeItems->selectedItems().length() != 1)
1605 auto Item =
ui.treeItems->selectedItems()[0];
1609 std::string ErrorMessage =
"";
1622 ErrorMessage = e.what();
1624 catch (
const std::exception& e)
1626 ErrorMessage = e.what();
1630 ErrorMessage =
"Unknown Error";
1633 if (!ErrorMessage.empty())
1637 QMessageBox::warning(
this,
"DynExp - Error",
1638 QString::fromStdString(
1639 "Resetting the item " + ObjectName +
", the following error occurred:\n\n"
1651 if (
ui.treeItems->selectedItems().length() != 1)
1654 auto Item =
ui.treeItems->selectedItems()[0];
1658 bool ResetRequired =
false;
1660 std::string ErrorMessage =
"";
1668 Object = RunnableObject;
1673 Object = RunnableObject;
1689 ErrorMessage = e.what();
1691 catch (
const std::exception& e)
1693 ErrorMessage = e.what();
1697 ErrorMessage =
"Unknown Error";
1702 if (!ErrorMessage.empty())
1703 QMessageBox::warning(
this,
"DynExp - Error",
1704 QString::fromStdString(
1705 "Configuring the item " + ObjectName +
", the following error occurred:\n\n"
1713 if ((Object && !RunnableObject) || (RunnableObject && RunnableObject->
IsRunning()) )
1715 if (QMessageBox::question(
this,
"DynExp - Reset item?",
1716 QString::fromStdString(
"The item " + ObjectName +
" needs to be reset in order to apply the changes. Should it be reset now?"),
1717 QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, QMessageBox::StandardButton::No)
1718 == QMessageBox::StandardButton::Yes)
1731 if (
ui.treeItems->selectedItems().length() != 1)
1734 auto Item =
ui.treeItems->selectedItems()[0];
1737 std::string ErrorMessage =
"";
1738 std::string ObjectName =
"< Unknown >";
1766 if (QMessageBox::question(
this,
"DynExp - Stop item?",
1767 QString::fromStdString(
"The item " + ObjectName +
" is currently running. Should it be stopped in order to be deleted?"),
1768 QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, QMessageBox::StandardButton::No)
1769 != QMessageBox::StandardButton::Yes)
1789 ErrorMessage = e.what();
1791 catch (
const std::exception& e)
1793 ErrorMessage = e.what();
1797 ErrorMessage =
"Unknown Error";
1802 if (!ErrorMessage.empty())
1804 QMessageBox::warning(
this,
"DynExp - Error",
1805 QString::fromStdString(
1806 "Deleting the item " + ObjectName +
", the following error occurred:\n\n"
1824 ui.action_Dock_Undock_Window->setEnabled(
true);
1832 QModule->DockUndockWindow();
1872 std::string ErrorMessage =
"";
1876 ui.tableLog->setRowCount(0);
1881 ErrorMessage = e.what();
1883 catch (
const std::exception& e)
1885 ErrorMessage = e.what();
1889 ErrorMessage =
"Unknown Error";
1892 if (!ErrorMessage.empty())
1894 QMessageBox::warning(
this,
"DynExp - Error",
1895 QString::fromStdString(
1896 "Clearing the event log, the following error occurred:\n\n"
1904 if (
ui.treeItems->selectedItems().length() != 1)
1907 auto Item =
ui.treeItems->selectedItems()[0];
1923 Object->ClearWarning();
1951 if (
ui.treeItems->selectedItems().length() != 1)
1957 auto Item =
ui.treeItems->selectedItems()[0];
1962 ui.action_Reset_Item->setEnabled(
true);
1963 ui.action_Configure_Item->setEnabled(
true);
1964 ui.action_Delete_Item->setEnabled(
true);
1971 ui.action_Run_Item->setEnabled(
false);
1972 ui.action_Stop_Item->setEnabled(
false);
1973 ui.action_Force_Stop_Item->setEnabled(
false);
1982 bool IsRunning =
false;
1995 ui.action_Run_Item->setEnabled(!IsRunning);
1996 ui.action_Stop_Item->setEnabled(IsRunning);
1997 ui.action_Force_Stop_Item->setEnabled(IsRunning);
2019 ui.treeItems->clearSelection();
Implements DynExp's main UI window called DynExpManager.
Implements DynExp's main window as a Qt-based user interface (UI).
void SelectItemTreeItem(QTreeWidgetItem *SelectedEntry)
Selects the given QTreeWidgetItem instance and brings this DynExpManager window to the front.
DynExpAbout * AboutDialog
Dialog showing license and copyright information.
void ChangeItemTreeItemToRunningState(QTreeWidgetItem &ItemTreeItem, const ItemTreeItemDataType &ItemTreeItemData, const QString &Description)
void OnProjectSettingsClicked()
QColor HTMLColorStringToThemeColor(const std::string &HTMLColor) const
Constructs a QColor instance from an HTML color string depending on the currently active UI theme.
void Reset(bool Force=false)
Resets the currently loaded project removing all resources from the resource managers....
void UpdateCircuitDiagram()
void OnAddHardwareAdapter()
void OnStatusBarStateClicked()
void OnWindowMenuClosed()
void OnItemDoubleClicked(QTreeWidgetItem *Item, int Column)
QMenu * ItemTreeContextMenu
Context menu appearing when right-clicking on the main tree widget showing DynExp::Object instances.
ErrorListDialog * ErrorListDlg
Dialog showing the list of currently active warnings and errors (ErrorEntries)
void MakeItem(QAction *SenderAction, LibraryVectorT &Lib, ManagerT &ResourceManager)
Creates a DynExp::Object instance according to a QAction instance SenderAction, which contains the in...
DynExp::DynExpCore & DynExpCore
Handle to DynExp's internal data.
QTreeWidgetItem * ItemTreeHardwareAdapters
Item for the hardware adapters section within the main tree widget showing DynExp::Object instances.
QColor AdjustColorToThemeColor(const QColor &Color) const
Transforms a QColor instance depending on the currently active UI theme.
void OnResetFailedItems()
void OnItemSelectionChanged()
bool Shutdown() noexcept
Terminates DynExpCore::WorkerThread and waits until the thread has ended.
static std::string GetObjectNameSafe(DynExp::Object *Object)
Retrieves the name of a DynExp::Object instance from its parameter class instance.
void OnWindowMenuOpened()
void OnStopItem(bool Force=false)
void ChangeItemTreeItemToNotRespondingState(QTreeWidgetItem &ItemTreeItem, const ItemTreeItemDataType &ItemTreeItemData, const QString &Description)
void OnDockUndockWindow()
void ResetItem(DynExp::Object *Object)
Calls DynExp::Object::Reset() on a DynExp::Object instance.
void OnRestoreWindowStatesFromParams()
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 Slo...
void UpdateModuleWindowsActionShortcuts() noexcept
Establishes shortcuts to switch between module windows. Refer to ModuleWindowsActionGroup.
QTreeWidgetItem * ItemTreeModules
Item for the modules section within the main tree widget showing DynExp::Object instances.
virtual void closeEvent(QCloseEvent *event) override
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 OnLogContextMenuRequested(const QPoint &Position)
void ChangeItemTreeItemToNotConnectedState(QTreeWidgetItem &ItemTreeItem, const ItemTreeItemDataType &ItemTreeItemData, const QString &Description)
void OnModuleWindowActivated(QMdiSubWindow *Window)
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 ma...
void FocusMainWindow() noexcept
Focuses/activates DynExp's main window and moves it on top of other windows if possible.
void DisableAllActions() noexcept
Disables all user interface actions such that item-specific ones can be reenabled upon a selection ch...
void OnShowCircuitDiagram()
struct DynExpManager::StatusBarType StatusBar
DynExp::QModuleBase * GetModuleByActiveUIWindow() noexcept
Determines the DynExp::QModuleBase instance of the current project whose UI window is active (has the...
void UpdateItemTreeItemObjectName(QTreeWidgetItem *Item, const DynExp::Object *Object)
Updates the text of a QTreeWidgetItem instance to match it to the related DynExp::Object instance.
Ui::DynExpManagerClass ui
Qt widgets belonging to the main window's user interface.
QMenu * LogContextMenu
Context menu appearing when right-clicking on the message log widget.
void UpdateModuleWindowsActionIcons() noexcept
Invokes DynExp::QModuleBase::UpdateModuleWindowFocusAction() on each module.
QActionGroup * UIThemeActionGroup
Actions to switch in between different UI themes.
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...
bool IsResetting
Indicates whether DynExpManager is currently deleting all resources to empty the project.
QActionGroup * ModuleWindowsActionGroup
Actions to switch between module windows with CTRL + < number key > shortcuts.
QAction * UIBrightThemeAction
Action for a bright UI theme.
void ChangeItemTreeItemToPausedState(QTreeWidgetItem &ItemTreeItem, const ItemTreeItemDataType &ItemTreeItemData, const QString &Description)
QTreeWidgetItem * ItemTreeInstruments
Item for the instruments section within the main tree widget showing DynExp::Object instances.
void UpdateModulesUI() noexcept
void OnUIThemeChanged(QAction *ThemeAction)
void UpdateItemTreeItem(const DynExp::HardwareAdapterManager::ResourceType &Resource)
void RegisterModuleUI(DynExp::Object *const Object)
Initializes the UI of the module Object (expecting that Object is a DynExp::QModuleBase instance....
void SaveProject(std::string_view Filename) noexcept
Saves the current DynExp project to an XML project file.
QAction * ClearWarningAction
Action to clear the warning of an item within the main tree widget showing DynExp::Object instances.
QTreeWidgetItem * UpdateItemTreeSection(QTreeWidgetItem *Section, ManagerT &ResourceManager)
Loops through resources managed by ResourceManager and adds respective QTreeWidgetItem instances as c...
void ChangeItemTreeItemToErrorState(QTreeWidgetItem &ItemTreeItem, const ItemTreeItemDataType &ItemTreeItemData, const std::exception_ptr &ExceptionPtr)
bool StopItem(DynExp::RunnableObject *Object, bool Force=false) noexcept
Calls DynExp::RunnableObject::Terminate() on a DynExp::RunnableObject instance.
void ChangeItemTreeItemToNormalState(QTreeWidgetItem &ItemTreeItem, const ItemTreeItemDataType &ItemTreeItemData, const QString &Description, const QString &StateTitle, const char *IconPath=DynExpUI::Icons::Stopped)
bool ShouldRedrawCircuitDiagram
Indicates whether the circuit diagram has to be rebuilt. Particularly, this must be set to true direc...
void EnsureItemReadyState(DynExp::Object *Object)
Calls DynExp::Object::EnsureReadyState() on a DynExp::Object instance.
void OnItemTreeContextMenuRequested(const QPoint &Position)
void ChangeItemTreeItemToWarningState(QTreeWidgetItem &ItemTreeItem, const ItemTreeItemDataType &ItemTreeItemData, const QString &Description)
ErrorListDialog::ErrorEntriesType ErrorEntries
List of all currently active warnings and errors.
bool CloseProject() noexcept
Closes the current project and opens a new, empty one.
DynExpManager(DynExp::DynExpCore &DynExpCore, QWidget *parent=Q_NULLPTR)
Constructs a DynExpManager instance.
bool ShouldUpdateCircuitDiagram
Indicates whether any item state has changed. Set to true to update the circuit diagram....
QAction * UIDarkThemeAction
Action for a dark UI theme.
QTimer * UpdateUITimer
Timer for periodically updating the user interface.
DynExp's core class acts as the interface between the user interface and DynExp's internal data like ...
void SaveProject(std::string_view Filename, const QMainWindow &MainWindow, const QDialog &CircuitDiagramDlg, QSplitter &HSplitter, QSplitter &VSplitter)
Saves the current DynExp project to an XML project file.
auto ConnectHardwareAdapters(CommonResourceManagerBase::FunctionToCallWhenObjectStartedType FunctionToCallWhenHardwareAdapterConnecting=nullptr)
Connects all hardware adapters contained in HardwareAdapterMgr asynchronously calling ResourceManager...
void ShutdownProject()
Terminates all running instruments and modules.
bool AllInstrumentsInitialized() const
Checks whether all instruments contained in InstrumentMgr have been initialized successfully.
auto & GetHardwareAdapterLib() const noexcept
Getter for the hardware adapter library.
auto & GetModuleManager() noexcept
Getter for the module manager.
void OpenProject(std::string_view Filename)
Loads a DynExp project from an XML project file.
bool IsProjectOpened(const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const noexcept
Locks Params and determines whether a project has been openend from a project file.
auto & GetHardwareAdapterManager() noexcept
Getter for the hardware adapter manager.
void EditProjectSettings(QWidget *const DialogParent)
Opens a settings dialog (ParamsConfigDialog) to let the user configure the parameter values of the cu...
void RestoreWindowStatesFromParams(QMainWindow &MainWindow, QDialog &CircuitDiagramDlg, QSplitter &HSplitter, QSplitter &VSplitter, bool OnlyMainWindow=false)
Sets module and main windows' positions, sizes and styles according to parameters stored in the curre...
auto & GetInstrumentManager() noexcept
Getter for the instrument manager.
void Reset(bool Force=false)
Resets the currently loaded project removing all resources from the resource managers....
bool HasLoadedProjectFromCommandlineParams() noexcept
Indicates whether a DynExp project has been loaded from a path specified as a command line argument w...
auto & GetModuleLib() const noexcept
Getter for the module library.
auto GetProjectFilename(const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const
Locks Params and returns the current DynExp project's filename.
void RunModules(CommonResourceManagerBase::FunctionToCallWhenObjectStartedType FunctionToCallWhenModuleStarted=nullptr)
Runs all modules contained in ModuleMgr with RunnableObjectParams::StartupType::OnCreation startup se...
void RunInstruments(CommonResourceManagerBase::FunctionToCallWhenObjectStartedType FunctionToCallWhenInstrumentStarted=nullptr)
Runs all instruments contained in InstrumentMgr with RunnableObjectParams::StartupType::OnCreation st...
bool AllHardwareAdaptersConnected() const
Checks whether all hardware adapters contained in HardwareAdapterMgr have been connected successfully...
void ResetFailedItems(QWidget &ParentWindow)
Calls Object::Reset() and Object::ClearWarning() on all owned DynExp::Object instances which are in a...
auto & GetInstrumentLib() const noexcept
Getter for the instrument library.
void Shutdown()
Terminates DynExpCore::WorkerThread and waits until the thread has ended.
Base class for all DynExp Objects like hardware adapters (DynExp::HardwareAdapterBase),...
void Reset()
Resets this Object instance (including all its derived classes) by calling ResetImpl()....
void EnsureReadyState(bool IsAutomaticStartup)
Ensures that this Object instance is ready by possibly starting its worker thread or by opening conne...
auto GetObjectName(const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const
Returns the name of this Object instance.
Base class for modules with a Qt-based user interface. Derive from this class to implement modules wi...
void HideUI()
Removes MdiSubWindow, DockWidget, and ModuleWindowFocusAction setting them to nullptr.
void UpdateModuleWindowFocusAction()
Updates the icon assigned to ModuleWindowFocusAction depending on whether Widget is docked to or undo...
Exception type thrown by TerminateImpl() if the RunnableObject cannot be terminated for being used by...
std::string_view GetUserNames() const
Getter for UserNames.
std::string GetErrorMessage() const
Genereates a user-readable error message containing the content of UserNames.
Defines an Object which possesses a thread it runs in. The RunnableObject can be started and stopped ...
bool Run(QWidget *ParentWidget=nullptr)
Starts the RunnableObject instance's thread and ensures that all Object instances linked to this inst...
bool IsRunning() const noexcept
Returns Running.
void Terminate(bool Force=false, const std::chrono::milliseconds Timeout=TerminateTimeoutDefault)
Notifies the RunnableObject instance's thread to terminate and waits until it has ended....
QTreeWidgetItem * GetSelectedEntry()
void SetErrorEntries(const ErrorEntriesType &ErrorEntries)
void ResetClosedByClickingOpenWidget() noexcept
bool HasBeenClosedByClickingOpenWidget() const noexcept
void Log(const std::string &Message, const ErrorType Type=ErrorType::Info, const size_t Line=0, const std::string &Function="", const std::string &File="", const int ErrorCode=0, const std::stacktrace &Trace={}) noexcept
Logs an event from information specified manually.
auto GetLogSize() const
Determines the number of entries in the internal event log.
void ClearLog()
Clears the internal event log.
std::vector< LogEntry > GetLog(size_t FirstElement=0) const
Returns the internal event log starting from the n-th stored element.
DynExp exceptions are derived from this class. It contains basic information about the cause of the e...
constexpr const char * GetErrorLabel() const
const ErrorType Type
DynExp error type from Util::ErrorType
constexpr const char * GetErrorLabelColor() const
An invalid argument like a null pointer has been passed to a function.
Thrown when an operation timed out before it could be completed, especially used for locking shared d...
const QColor green("lime")
constexpr auto GetStyleSheet()
const QColor blue(42, 130, 218)
constexpr auto Instrument
constexpr auto HardwareAdapter
constexpr auto NotResponding
static const auto PushButtonReadyStyleSheetBright
static const auto PushButtonRunningStyleSheet
static const auto PushButtonErrorStyleSheet
static const auto PushButtonReadyStyleSheetDark
static const auto PushButtonWarningStyleSheet
std::string ToStr(const T &Value, int Precision=-1)
Converts a (numeric) value of type T to a std::string using operator<< of std::stringstream.
std::string ExceptionToStr(const std::exception_ptr ExceptionPtr)
Returns the what() information of an exception derived from std::exception and stored in an exception...
EventLogger & EventLog()
This function holds a static EventLogger instance and returns a reference to it. DynExp uses only one...
QString PromptOpenFilePath(QWidget *Parent, const QString &Title, const QString &DefaultSuffix, const QString &NameFilter, const QString &InitialDirectory)
Opens a file dialog to ask the user to select a single existing file.
void ActivateWindow(QWidget &Widget)
Renders a window active and brings it to the front.
std::chrono::duration< double > seconds
Extends std::chrono by a duration data type for seconds capable of storing fractions of seconds.
QString PromptSaveFilePath(QWidget *Parent, const QString &Title, const QString &DefaultSuffix, const QString &NameFilter, const QString &InitialDirectory)
Works as PromptOpenFilePath() but asks the user to select a single file which does not need to exist.
Accumulates include statements to provide a precompiled header.
Bundles data which is assigned to items of the main QTreeWidget. Each item refers to a DynExp::Object...
const DynExp::ItemIDType ID
ID of the DynExp::Object instance assigned to this item.
QLabel * NumRunningModule
QWidget * NumRunningInstrGroup
StatusBarType(DynExpManager *Owner)
Constructs a StatusBarType instance.
QHBoxLayout * NumRunningInstrLayout
QHBoxLayout * NumRunningModuleLayout
QLabel * NumRunningInstrImage
size_t NumItemsInErrorState
QWidget * NumRunningModuleGroup
QLabel * NumRunningModuleImage
size_t NumItemsInWarningState
Defines a DynExp resource, which mainly owns a DynExp::Object instance wrapping a pointer to it.
std::unique_ptr< QTreeWidgetItem > TreeWidgetItem
For visualization of the resource and its state in DynExp's main window (DynExpManager)....
PointerType ResourcePointer
Pointer to the DynExp::Object instance owned by this resource.