From d93ba5b97efc791cfaee9b52a9807df01f61c8d3 Mon Sep 17 00:00:00 2001 From: Gordon McCann Date: Wed, 23 Feb 2022 20:54:53 -0500 Subject: [PATCH] Fixed serialization such that all existing spectra and cuts are wiped out before loading new file. Removed a few logs that are no longer relevant --- Navigator/src/Navigator/Editor/SpectrumPanel.cpp | 2 -- Navigator/src/Navigator/SpectrumManager.h | 7 +++++++ Navigator/src/Navigator/SpectrumSerializer.cpp | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Navigator/src/Navigator/Editor/SpectrumPanel.cpp b/Navigator/src/Navigator/Editor/SpectrumPanel.cpp index 50d3bf6..de3176c 100644 --- a/Navigator/src/Navigator/Editor/SpectrumPanel.cpp +++ b/Navigator/src/Navigator/Editor/SpectrumPanel.cpp @@ -55,7 +55,6 @@ namespace Navigator { SpectrumManager::GetInstance().DrawHistogram(m_zoomedGram.name); if (!m_cutModeFlag && ImPlot::IsPlotHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) { - NAV_INFO("We lost 'em, de-zoom and enhance!"); m_zoomedFlag = false; m_zoomedGram = HistogramParameters(); } @@ -190,7 +189,6 @@ namespace Navigator { SpectrumManager::GetInstance().DrawHistogram(spec.name); if (ImPlot::IsPlotHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) { - NAV_INFO("We got'em boys, they're in plot {0}. Zoom and enhance!", i); m_zoomedFlag = true; m_zoomedGram = spec; } diff --git a/Navigator/src/Navigator/SpectrumManager.h b/Navigator/src/Navigator/SpectrumManager.h index 6aa685d..3899dbf 100644 --- a/Navigator/src/Navigator/SpectrumManager.h +++ b/Navigator/src/Navigator/SpectrumManager.h @@ -19,6 +19,13 @@ namespace Navigator { inline static SpectrumManager& GetInstance() { return *s_instance; } + inline void RemoveAllSpectra() + { + std::lock_guard guard(m_managerMutex); + m_histoMap.clear(); + m_cutMap.clear(); + } + void AddHistogram(const HistogramParameters& params); void RemoveHistogram(const std::string& name); void AddCutToHistogramDraw(const std::string& cutname, const std::string& histoname); diff --git a/Navigator/src/Navigator/SpectrumSerializer.cpp b/Navigator/src/Navigator/SpectrumSerializer.cpp index b19419a..d433f5d 100644 --- a/Navigator/src/Navigator/SpectrumSerializer.cpp +++ b/Navigator/src/Navigator/SpectrumSerializer.cpp @@ -122,6 +122,7 @@ namespace Navigator { void SpectrumSerializer::DeserializeData() { SpectrumManager& manager = SpectrumManager::GetInstance(); + manager.RemoveAllSpectra(); std::ifstream input(m_filename); if (!input.is_open())