diff --git a/source/Gui/BrowserWindow.cpp b/source/Gui/BrowserWindow.cpp index c00200e19..aef1e2024 100644 --- a/source/Gui/BrowserWindow.cpp +++ b/source/Gui/BrowserWindow.cpp @@ -30,8 +30,6 @@ #include "StyleRepository.h" #include "StatisticsWindow.h" #include "Viewport.h" -#include "SerializationHelperService.h" -#include "TemporalControlWindow.h" #include "MessageDialog.h" #include "LoginDialog.h" #include "UploadSimulationDialog.h" @@ -75,16 +73,11 @@ namespace {WorkspaceType_Private, std::string("private")}}; } -void BrowserWindow::init( - SimulationFacade const& simulationFacade, - PersisterFacade const& persisterFacade, - StatisticsWindow const& statisticsWindow, - TemporalControlWindow const& temporalControlWindow) +void BrowserWindow::init(SimulationFacade const& simulationFacade, PersisterFacade const& persisterFacade, StatisticsWindow const& statisticsWindow) { _simulationFacade = simulationFacade; _persisterFacade = persisterFacade; _statisticsWindow = statisticsWindow; - _temporalControlWindow = temporalControlWindow; _downloadCache = std::make_shared<_DownloadCache>(); _refreshProcessor = _TaskProcessor::createTaskProcessor(_persisterFacade); diff --git a/source/Gui/BrowserWindow.h b/source/Gui/BrowserWindow.h index b603de38c..046ef3546 100644 --- a/source/Gui/BrowserWindow.h +++ b/source/Gui/BrowserWindow.h @@ -22,11 +22,7 @@ class BrowserWindow : public AlienWindow MAKE_SINGLETON_NO_DEFAULT_CONSTRUCTION(BrowserWindow); public: - void init( - SimulationFacade const& simulationFacade, - PersisterFacade const& persisterFacade, - StatisticsWindow const& statisticsWindow, - TemporalControlWindow const& temporalControlWindow); + void init(SimulationFacade const& simulationFacade, PersisterFacade const& persisterFacade, StatisticsWindow const& statisticsWindow); void shutdown(); void onRefresh(); @@ -142,5 +138,4 @@ class BrowserWindow : public AlienWindow SimulationFacade _simulationFacade; PersisterFacade _persisterFacade; StatisticsWindow _statisticsWindow; - TemporalControlWindow _temporalControlWindow; }; diff --git a/source/Gui/Definitions.h b/source/Gui/Definitions.h index a177d6a4d..d72a65678 100644 --- a/source/Gui/Definitions.h +++ b/source/Gui/Definitions.h @@ -20,8 +20,7 @@ class Viewport; class StyleRepository; -class _TemporalControlWindow; -using TemporalControlWindow = std::shared_ptr<_TemporalControlWindow>; +class TemporalControlWindow; class _SpatialControlWindow; using SpatialControlWindow = std::shared_ptr<_SpatialControlWindow>; diff --git a/source/Gui/FileTransferController.cpp b/source/Gui/FileTransferController.cpp index 91d693f28..e74b22ba4 100644 --- a/source/Gui/FileTransferController.cpp +++ b/source/Gui/FileTransferController.cpp @@ -15,14 +15,10 @@ namespace auto constexpr FileTransferSenderId = "FileTransfer"; } -void FileTransferController::init( - PersisterFacade const& persisterFacade, - SimulationFacade const& simulationFacade, - TemporalControlWindow const& temporalControlWindow) +void FileTransferController::init(PersisterFacade const& persisterFacade, SimulationFacade const& simulationFacade) { _persisterFacade = persisterFacade; _simulationFacade = simulationFacade; - _temporalControlWindow = temporalControlWindow; _openSimulationProcessor = _TaskProcessor::createTaskProcessor(_persisterFacade); } @@ -77,7 +73,7 @@ void FileTransferController::onOpenSimulation() Viewport::get().setCenterInWorldPos(data.deserializedSimulation.auxiliaryData.center); Viewport::get().setZoomFactor(data.deserializedSimulation.auxiliaryData.zoom); - _temporalControlWindow->onSnapshot(); + TemporalControlWindow::get().onSnapshot(); printOverlayMessage(data.simulationName + ".sim"); }, [](auto const& criticalErrors) { MessageDialog::get().information("Error", criticalErrors); }); diff --git a/source/Gui/FileTransferController.h b/source/Gui/FileTransferController.h index 169e4d211..3f4659316 100644 --- a/source/Gui/FileTransferController.h +++ b/source/Gui/FileTransferController.h @@ -12,7 +12,7 @@ class FileTransferController MAKE_SINGLETON(FileTransferController); public: - void init(PersisterFacade const& persisterFacade, SimulationFacade const& simulationFacade, TemporalControlWindow const& temporalControlWindow); + void init(PersisterFacade const& persisterFacade, SimulationFacade const& simulationFacade); void onOpenSimulation(); void onSaveSimulation(); @@ -22,7 +22,6 @@ class FileTransferController private: PersisterFacade _persisterFacade; SimulationFacade _simulationFacade; - TemporalControlWindow _temporalControlWindow; TaskProcessor _openSimulationProcessor; diff --git a/source/Gui/MainWindow.cpp b/source/Gui/MainWindow.cpp index 8846295b5..956df7f53 100644 --- a/source/Gui/MainWindow.cpp +++ b/source/Gui/MainWindow.cpp @@ -131,22 +131,22 @@ _MainWindow::_MainWindow(SimulationFacade const& simulationFacade, PersisterFaca _SimulationView::get().init(_simulationFacade); SimulationInteractionController::get().init(_simulationFacade); _statisticsWindow = std::make_shared<_StatisticsWindow>(_simulationFacade); - _temporalControlWindow = std::make_shared<_TemporalControlWindow>(_simulationFacade, _statisticsWindow); - _spatialControlWindow = std::make_shared<_SpatialControlWindow>(_simulationFacade, _temporalControlWindow); + TemporalControlWindow::get().init(_simulationFacade, _statisticsWindow); + _spatialControlWindow = std::make_shared<_SpatialControlWindow>(_simulationFacade); _radiationSourcesWindow = std::make_shared<_RadiationSourcesWindow>(_simulationFacade); _simulationParametersWindow = std::make_shared<_SimulationParametersWindow>(_simulationFacade, _radiationSourcesWindow); _gpuSettingsDialog = std::make_shared<_GpuSettingsDialog>(_simulationFacade); - _startupController = std::make_shared<_StartupController>(_simulationFacade, _persisterFacade, _temporalControlWindow); + _startupController = std::make_shared<_StartupController>(_simulationFacade, _persisterFacade); _exitDialog = std::make_shared<_ExitDialog>(_onExit); _aboutDialog = std::make_shared<_AboutDialog>(); _massOperationsDialog = std::make_shared<_MassOperationsDialog>(_simulationFacade); _logWindow = std::make_shared<_LogWindow>(_logger); _gettingStartedWindow = std::make_shared<_GettingStartedWindow>(); - _newSimulationDialog = std::make_shared<_NewSimulationDialog>(_simulationFacade, _temporalControlWindow, _statisticsWindow); + _newSimulationDialog = std::make_shared<_NewSimulationDialog>(_simulationFacade, _statisticsWindow); _displaySettingsDialog = std::make_shared<_DisplaySettingsDialog>(); _patternAnalysisDialog = std::make_shared<_PatternAnalysisDialog>(_simulationFacade); _fpsController = std::make_shared<_FpsController>(); - BrowserWindow::get().init(_simulationFacade, _persisterFacade, _statisticsWindow, _temporalControlWindow); + BrowserWindow::get().init(_simulationFacade, _persisterFacade, _statisticsWindow); ActivateUserDialog::get().init(_simulationFacade); _newPasswordDialog = std::make_shared<_NewPasswordDialog>(_simulationFacade); _resetPasswordDialog = std::make_shared<_ResetPasswordDialog>(_newPasswordDialog); @@ -158,8 +158,8 @@ _MainWindow::_MainWindow(SimulationFacade const& simulationFacade, PersisterFaca _shaderWindow = std::make_shared<_ShaderWindow>(); _autosaveWindow = std::make_shared<_AutosaveWindow>(_simulationFacade, _persisterFacade); OverlayMessageController::get().init(_persisterFacade); - FileTransferController::get().init(_persisterFacade, _simulationFacade, _temporalControlWindow); - NetworkTransferController::get().init(_simulationFacade, _persisterFacade, _temporalControlWindow); + FileTransferController::get().init(_persisterFacade, _simulationFacade); + NetworkTransferController::get().init(_simulationFacade, _persisterFacade); LoginController::get().init(_simulationFacade, _persisterFacade); ifd::FileDialog::Instance().CreateTexture = [](uint8_t* data, int w, int h, char fmt) -> void* { @@ -432,8 +432,8 @@ void _MainWindow::processMenubar() } if (AlienImGui::BeginMenuButton(" " ICON_FA_WINDOW_RESTORE " Windows ", _windowMenuToggled, "Windows")) { - if (ImGui::MenuItem("Temporal control", "ALT+1", _temporalControlWindow->isOn())) { - _temporalControlWindow->setOn(!_temporalControlWindow->isOn()); + if (ImGui::MenuItem("Temporal control", "ALT+1", TemporalControlWindow::get().isOn())) { + TemporalControlWindow::get().setOn(!TemporalControlWindow::get().isOn()); } if (ImGui::MenuItem("Spatial control", "ALT+2", _spatialControlWindow->isOn())) { _spatialControlWindow->setOn(!_spatialControlWindow->isOn()); @@ -611,7 +611,7 @@ void _MainWindow::processMenubar() } if (io.KeyAlt && ImGui::IsKeyPressed(ImGuiKey_1)) { - _temporalControlWindow->setOn(!_temporalControlWindow->isOn()); + TemporalControlWindow::get().setOn(!TemporalControlWindow::get().isOn()); } if (io.KeyAlt && ImGui::IsKeyPressed(ImGuiKey_2)) { _spatialControlWindow->setOn(!_spatialControlWindow->isOn()); @@ -736,7 +736,7 @@ void _MainWindow::processDialogs() void _MainWindow::processWindows() { - _temporalControlWindow->process(); + TemporalControlWindow::get().process(); _spatialControlWindow->process(); _statisticsWindow->process(); _simulationParametersWindow->process(); diff --git a/source/Gui/MainWindow.h b/source/Gui/MainWindow.h index ca2cd7370..cf5be3cc1 100644 --- a/source/Gui/MainWindow.h +++ b/source/Gui/MainWindow.h @@ -40,7 +40,6 @@ class _MainWindow GLFWwindow* _window; GuiLogger _logger; - TemporalControlWindow _temporalControlWindow; SpatialControlWindow _spatialControlWindow; SimulationParametersWindow _simulationParametersWindow; StatisticsWindow _statisticsWindow; diff --git a/source/Gui/NetworkTransferController.cpp b/source/Gui/NetworkTransferController.cpp index 8e4252e49..7162ae3be 100644 --- a/source/Gui/NetworkTransferController.cpp +++ b/source/Gui/NetworkTransferController.cpp @@ -12,11 +12,10 @@ #include "BrowserWindow.h" #include "OverlayMessageController.h" -void NetworkTransferController::init(SimulationFacade const& simulationFacade, PersisterFacade const& persisterFacade, TemporalControlWindow const& temporalControlWindow) +void NetworkTransferController::init(SimulationFacade const& simulationFacade, PersisterFacade const& persisterFacade) { _simulationFacade = simulationFacade; _persisterFacade = persisterFacade; - _temporalControlWindow = temporalControlWindow; _downloadProcessor = _TaskProcessor::createTaskProcessor(_persisterFacade); _uploadProcessor = _TaskProcessor::createTaskProcessor(_persisterFacade); _replaceProcessor = _TaskProcessor::createTaskProcessor(_persisterFacade); @@ -67,7 +66,7 @@ void NetworkTransferController::onDownload(DownloadNetworkResourceRequestData co Viewport::get().setCenterInWorldPos(deserializedSimulation.auxiliaryData.center); Viewport::get().setZoomFactor(deserializedSimulation.auxiliaryData.zoom); - _temporalControlWindow->onSnapshot(); + TemporalControlWindow::get().onSnapshot(); } else { EditorController::get().setOn(true); EditorController::get().getGenomeEditorWindow()->openTab(std::get(data.resourceData)); diff --git a/source/Gui/NetworkTransferController.h b/source/Gui/NetworkTransferController.h index 89c84458d..a869fc239 100644 --- a/source/Gui/NetworkTransferController.h +++ b/source/Gui/NetworkTransferController.h @@ -17,7 +17,7 @@ class NetworkTransferController MAKE_SINGLETON(NetworkTransferController); public: - void init(SimulationFacade const& simulationFacade, PersisterFacade const& persisterFacade, TemporalControlWindow const& temporalControlWindow); + void init(SimulationFacade const& simulationFacade, PersisterFacade const& persisterFacade); void onDownload(DownloadNetworkResourceRequestData const& requestData); void onUpload(UploadNetworkResourceRequestData const& requestData); @@ -29,7 +29,6 @@ class NetworkTransferController private: SimulationFacade _simulationFacade; PersisterFacade _persisterFacade; - TemporalControlWindow _temporalControlWindow; TaskProcessor _downloadProcessor; TaskProcessor _uploadProcessor; diff --git a/source/Gui/NewSimulationDialog.cpp b/source/Gui/NewSimulationDialog.cpp index 081663830..558d12b95 100644 --- a/source/Gui/NewSimulationDialog.cpp +++ b/source/Gui/NewSimulationDialog.cpp @@ -18,11 +18,9 @@ namespace _NewSimulationDialog::_NewSimulationDialog( SimulationFacade const& simulationFacade, - TemporalControlWindow const& temporalControlWindow, StatisticsWindow const& statisticsWindow) : AlienDialog("New simulation") , _simulationFacade(simulationFacade) - , _temporalControlWindow(temporalControlWindow) , _statisticsWindow(statisticsWindow) { _adoptSimulationParameters = GlobalSettings::get().getBool("dialogs.new simulation.adopt simulation parameters", true); @@ -80,5 +78,5 @@ void _NewSimulationDialog::onNewSimulation() _simulationFacade->newSimulation(std::nullopt, 0, generalSettings, parameters); Viewport::get().setCenterInWorldPos({toFloat(_width) / 2, toFloat(_height) / 2}); Viewport::get().setZoomFactor(4.0f); - _temporalControlWindow->onSnapshot(); + TemporalControlWindow::get().onSnapshot(); } diff --git a/source/Gui/NewSimulationDialog.h b/source/Gui/NewSimulationDialog.h index f3c5c0c5f..b98578c1a 100644 --- a/source/Gui/NewSimulationDialog.h +++ b/source/Gui/NewSimulationDialog.h @@ -8,10 +8,7 @@ class _NewSimulationDialog : public AlienDialog { public: - _NewSimulationDialog( - SimulationFacade const& simulationFacade, - TemporalControlWindow const& temporalControlWindow, - StatisticsWindow const& statisticsWindow); + _NewSimulationDialog(SimulationFacade const& simulationFacade, StatisticsWindow const& statisticsWindow); ~_NewSimulationDialog() override; private: @@ -21,7 +18,6 @@ class _NewSimulationDialog : public AlienDialog void onNewSimulation(); SimulationFacade _simulationFacade; - TemporalControlWindow _temporalControlWindow; StatisticsWindow _statisticsWindow; bool _adoptSimulationParameters = true; diff --git a/source/Gui/ResizeWorldDialog.cpp b/source/Gui/ResizeWorldDialog.cpp index af7607dd8..96d7dab17 100644 --- a/source/Gui/ResizeWorldDialog.cpp +++ b/source/Gui/ResizeWorldDialog.cpp @@ -8,10 +8,9 @@ #include "AlienImGui.h" #include "TemporalControlWindow.h" -_ResizeWorldDialog::_ResizeWorldDialog(SimulationFacade const& simulationFacade, TemporalControlWindow const& temporalControlWindow) +_ResizeWorldDialog::_ResizeWorldDialog(SimulationFacade const& simulationFacade) : AlienDialog("Resize world") , _simulationFacade(simulationFacade) - , _temporalControlWindow(temporalControlWindow) {} void _ResizeWorldDialog::open() @@ -94,5 +93,5 @@ void _ResizeWorldDialog::onResizing() _simulationFacade->setClusteredSimulationData(content); _simulationFacade->setStatisticsHistory(statistics); _simulationFacade->setRealTime(realtime); - _temporalControlWindow->onSnapshot(); + TemporalControlWindow::get().onSnapshot(); } diff --git a/source/Gui/ResizeWorldDialog.h b/source/Gui/ResizeWorldDialog.h index 63a8eb697..3a8b2eb93 100644 --- a/source/Gui/ResizeWorldDialog.h +++ b/source/Gui/ResizeWorldDialog.h @@ -6,7 +6,7 @@ class _ResizeWorldDialog : public AlienDialog { public: - _ResizeWorldDialog(SimulationFacade const& simulationFacade, TemporalControlWindow const& temporalControlWindow); + _ResizeWorldDialog(SimulationFacade const& simulationFacade); void open(); @@ -16,7 +16,6 @@ class _ResizeWorldDialog : public AlienDialog void onResizing(); SimulationFacade _simulationFacade; - TemporalControlWindow _temporalControlWindow; bool _scaleContent = false; int _width = 0; diff --git a/source/Gui/SpatialControlWindow.cpp b/source/Gui/SpatialControlWindow.cpp index 768354020..398832ba4 100644 --- a/source/Gui/SpatialControlWindow.cpp +++ b/source/Gui/SpatialControlWindow.cpp @@ -13,11 +13,11 @@ #include "AlienImGui.h" #include "ResizeWorldDialog.h" -_SpatialControlWindow::_SpatialControlWindow(SimulationFacade const& simulationFacade, TemporalControlWindow const& temporalControlWindow) +_SpatialControlWindow::_SpatialControlWindow(SimulationFacade const& simulationFacade) : AlienWindow("Spatial control", "windows.spatial control", true) , _simulationFacade(simulationFacade) { - _resizeWorldDialog = std::make_shared<_ResizeWorldDialog>(simulationFacade, temporalControlWindow); + _resizeWorldDialog = std::make_shared<_ResizeWorldDialog>(simulationFacade); auto& settings = GlobalSettings::get(); Viewport::get().setZoomSensitivity(settings.getFloat("windows.spatial control.zoom sensitivity factor", Viewport::get().getZoomSensitivity())); diff --git a/source/Gui/SpatialControlWindow.h b/source/Gui/SpatialControlWindow.h index a45194667..c67221a45 100644 --- a/source/Gui/SpatialControlWindow.h +++ b/source/Gui/SpatialControlWindow.h @@ -9,7 +9,7 @@ class _SpatialControlWindow : public AlienWindow { public: - _SpatialControlWindow(SimulationFacade const& simulationFacade, TemporalControlWindow const& temporalControlWindow); + _SpatialControlWindow(SimulationFacade const& simulationFacade); ~_SpatialControlWindow() override; private: diff --git a/source/Gui/StartupController.cpp b/source/Gui/StartupController.cpp index 065446070..83887dbbe 100644 --- a/source/Gui/StartupController.cpp +++ b/source/Gui/StartupController.cpp @@ -26,12 +26,8 @@ namespace auto const StartupSenderId = "Startup"; } -_StartupController::_StartupController( - SimulationFacade const& simulationFacade, - PersisterFacade const& persisterFacade, - TemporalControlWindow const& temporalControlWindow) +_StartupController::_StartupController(SimulationFacade const& simulationFacade, PersisterFacade const& persisterFacade) : _simulationFacade(simulationFacade) - , _temporalControlWindow(temporalControlWindow) , _persisterFacade(persisterFacade) { log(Priority::Important, "starting ALIEN v" + Const::ProgramVersion); @@ -65,7 +61,7 @@ void _StartupController::process() _simulationFacade->setRealTime(deserializedSim.auxiliaryData.realTime); Viewport::get().setCenterInWorldPos(deserializedSim.auxiliaryData.center); Viewport::get().setZoomFactor(deserializedSim.auxiliaryData.zoom); - _temporalControlWindow->onSnapshot(); + TemporalControlWindow::get().onSnapshot(); _lastActivationTimepoint = std::chrono::steady_clock::now(); _state = State::FadeOutLoadingScreen; @@ -91,7 +87,7 @@ void _StartupController::process() _simulationFacade->setRealTime(deserializedSim.auxiliaryData.realTime); Viewport::get().setCenterInWorldPos(deserializedSim.auxiliaryData.center); Viewport::get().setZoomFactor(deserializedSim.auxiliaryData.zoom); - _temporalControlWindow->onSnapshot(); + TemporalControlWindow::get().onSnapshot(); _lastActivationTimepoint = std::chrono::steady_clock::now(); _state = State::FadeOutLoadingScreen; diff --git a/source/Gui/StartupController.h b/source/Gui/StartupController.h index 69a2c1876..fe6f369a5 100644 --- a/source/Gui/StartupController.h +++ b/source/Gui/StartupController.h @@ -10,10 +10,7 @@ class _StartupController { public: - _StartupController( - SimulationFacade const& simulationFacade, - PersisterFacade const& persisterFacade, - TemporalControlWindow const& temporalControlWindow); + _StartupController(SimulationFacade const& simulationFacade, PersisterFacade const& persisterFacade); void process(); enum class State @@ -34,7 +31,6 @@ class _StartupController void drawGrid(float yPos, float alpha); SimulationFacade _simulationFacade; - TemporalControlWindow _temporalControlWindow; PersisterFacade _persisterFacade; PersisterRequestId _startupSimRequestId; diff --git a/source/Gui/TemporalControlWindow.cpp b/source/Gui/TemporalControlWindow.cpp index abd87359c..6b96600a5 100644 --- a/source/Gui/TemporalControlWindow.cpp +++ b/source/Gui/TemporalControlWindow.cpp @@ -20,20 +20,25 @@ namespace auto constexpr LeftColumnWidth = 180.0f; } -_TemporalControlWindow::_TemporalControlWindow( +void TemporalControlWindow::init( SimulationFacade const& simulationFacade, StatisticsWindow const& statisticsWindow) - : AlienWindow("Temporal control", "windows.temporal control", true) - , _simulationFacade(simulationFacade) - , _statisticsWindow(statisticsWindow) -{} +{ + _simulationFacade = simulationFacade; + _statisticsWindow = statisticsWindow; +} -void _TemporalControlWindow::onSnapshot() +void TemporalControlWindow::onSnapshot() { _snapshot = createSnapshot(); } -void _TemporalControlWindow::processIntern() +TemporalControlWindow::TemporalControlWindow() + : AlienWindow("Temporal control", "windows.temporal control", true) +{ +} + +void TemporalControlWindow::processIntern() { processRunButton(); ImGui::SameLine(); @@ -64,7 +69,7 @@ void _TemporalControlWindow::processIntern() ImGui::EndChild(); } -void _TemporalControlWindow::processTpsInfo() +void TemporalControlWindow::processTpsInfo() { ImGui::Text("Time steps per second"); @@ -75,7 +80,7 @@ void _TemporalControlWindow::processTpsInfo() ImGui::PopFont(); } -void _TemporalControlWindow::processTotalTimestepsInfo() +void TemporalControlWindow::processTotalTimestepsInfo() { ImGui::Text("Total time steps"); @@ -86,7 +91,7 @@ void _TemporalControlWindow::processTotalTimestepsInfo() ImGui::PopFont(); } -void _TemporalControlWindow::processRealTimeInfo() +void TemporalControlWindow::processRealTimeInfo() { ImGui::Text("Real-time"); @@ -97,7 +102,7 @@ void _TemporalControlWindow::processRealTimeInfo() ImGui::PopFont(); } -void _TemporalControlWindow::processTpsRestriction() +void TemporalControlWindow::processTpsRestriction() { AlienImGui::ToggleButton(AlienImGui::ToggleButtonParameters().name("Slow down"), _slowDown); ImGui::SameLine(scale(LeftColumnWidth) - (ImGui::GetWindowWidth() - ImGui::GetContentRegionAvail().x)); @@ -126,7 +131,7 @@ void _TemporalControlWindow::processTpsRestriction() ImGui::EndDisabled(); } -void _TemporalControlWindow::processRunButton() +void TemporalControlWindow::processRunButton() { ImGui::BeginDisabled(_simulationFacade->isSimulationRunning()); auto result = AlienImGui::ToolbarButton(ICON_FA_PLAY); @@ -139,7 +144,7 @@ void _TemporalControlWindow::processRunButton() ImGui::EndDisabled(); } -void _TemporalControlWindow::processPauseButton() +void TemporalControlWindow::processPauseButton() { ImGui::BeginDisabled(!_simulationFacade->isSimulationRunning()); auto result = AlienImGui::ToolbarButton(ICON_FA_PAUSE); @@ -151,7 +156,7 @@ void _TemporalControlWindow::processPauseButton() ImGui::EndDisabled(); } -void _TemporalControlWindow::processStepBackwardButton() +void TemporalControlWindow::processStepBackwardButton() { ImGui::BeginDisabled(_history.empty() || _simulationFacade->isSimulationRunning()); auto result = AlienImGui::ToolbarButton(ICON_FA_CHEVRON_LEFT); @@ -166,7 +171,7 @@ void _TemporalControlWindow::processStepBackwardButton() ImGui::EndDisabled(); } -void _TemporalControlWindow::processStepForwardButton() +void TemporalControlWindow::processStepForwardButton() { ImGui::BeginDisabled(_simulationFacade->isSimulationRunning()); auto result = AlienImGui::ToolbarButton(ICON_FA_CHEVRON_RIGHT); @@ -178,7 +183,7 @@ void _TemporalControlWindow::processStepForwardButton() ImGui::EndDisabled(); } -void _TemporalControlWindow::processCreateFlashbackButton() +void TemporalControlWindow::processCreateFlashbackButton() { auto result = AlienImGui::ToolbarButton(ICON_FA_CAMERA); AlienImGui::Tooltip("Creating in-memory flashback: It saves the content of the current world to the memory."); @@ -189,7 +194,7 @@ void _TemporalControlWindow::processCreateFlashbackButton() } } -void _TemporalControlWindow::processLoadFlashbackButton() +void TemporalControlWindow::processLoadFlashbackButton() { ImGui::BeginDisabled(!_snapshot); auto result = AlienImGui::ToolbarButton(ICON_FA_UNDO); @@ -205,7 +210,7 @@ void _TemporalControlWindow::processLoadFlashbackButton() ImGui::EndDisabled(); } -_TemporalControlWindow::Snapshot _TemporalControlWindow::createSnapshot() +TemporalControlWindow::Snapshot TemporalControlWindow::createSnapshot() { Snapshot result; result.timestep = _simulationFacade->getCurrentTimestep(); @@ -216,7 +221,7 @@ _TemporalControlWindow::Snapshot _TemporalControlWindow::createSnapshot() } -void _TemporalControlWindow::applySnapshot(Snapshot const& snapshot) +void TemporalControlWindow::applySnapshot(Snapshot const& snapshot) { auto parameters = _simulationFacade->getSimulationParameters(); auto const& origParameters = snapshot.parameters; @@ -247,7 +252,7 @@ void _TemporalControlWindow::applySnapshot(Snapshot const& snapshot) } template -void _TemporalControlWindow::restorePosition(MovedObjectType& movedObject, MovedObjectType const& origMovedObject, uint64_t origTimestep) +void TemporalControlWindow::restorePosition(MovedObjectType& movedObject, MovedObjectType const& origMovedObject, uint64_t origTimestep) { auto origMovedObjectClone = origMovedObject; auto movedObjectClone = movedObject; diff --git a/source/Gui/TemporalControlWindow.h b/source/Gui/TemporalControlWindow.h index 1c9de35b9..0cd2ce776 100644 --- a/source/Gui/TemporalControlWindow.h +++ b/source/Gui/TemporalControlWindow.h @@ -2,6 +2,7 @@ #include +#include "Base/Singleton.h" #include "EngineInterface/Definitions.h" #include "EngineInterface/Descriptions.h" #include "EngineInterface/SimulationParameters.h" @@ -9,14 +10,18 @@ #include "Definitions.h" #include "AlienWindow.h" -class _TemporalControlWindow : public AlienWindow +class TemporalControlWindow : public AlienWindow { + MAKE_SINGLETON_NO_DEFAULT_CONSTRUCTION(TemporalControlWindow); + public: - _TemporalControlWindow(SimulationFacade const& simulationFacade, StatisticsWindow const& statisticsWindow); + void init(SimulationFacade const& simulationFacade, StatisticsWindow const& statisticsWindow); void onSnapshot(); private: + TemporalControlWindow(); + struct Snapshot { uint64_t timestep;