mirror of
https://github.com/gwm17/Specter.git
synced 2024-11-22 18:28:52 -05:00
Changed SpectrumManager from global static instance to memory allocated owned by App and passed to layers as needed. Better data encapsulation and hopefully make some things easier down the line
This commit is contained in:
parent
830aef4f9f
commit
798fb85687
|
@ -9,43 +9,42 @@
|
||||||
namespace Specter {
|
namespace Specter {
|
||||||
|
|
||||||
//Construct each NavParameter with their unique name. Then bind them to the SpectrumManager.
|
//Construct each NavParameter with their unique name. Then bind them to the SpectrumManager.
|
||||||
SPSAnalysisStage::SPSAnalysisStage() :
|
SPSAnalysisStage::SPSAnalysisStage(const SpectrumManager::Ref& manager) :
|
||||||
AnalysisStage("SPSAnalysis"), delayFLTime("delayFLTime"), delayFRTime("delayFRTime"), delayBLTime("delayBLTime"), delayBRTime("delayBRTime"), x1("x1"), x2("x2"), xavg("xavg"),
|
AnalysisStage("SPSAnalysis"), delayFLTime("delayFLTime"), delayFRTime("delayFRTime"), delayBLTime("delayBLTime"), delayBRTime("delayBRTime"), x1("x1"), x2("x2"), xavg("xavg"),
|
||||||
scintLeft("scintLeft"), anodeBack("anodeBack"), anodeFront("anodeFront"), cathode("cathode"), xavg_sabreCoinc("xavg_sabreCoinc"), x1_weight("x1_weight"), x2_weight("x2_weight"),
|
scintLeft("scintLeft"), anodeBack("anodeBack"), anodeFront("anodeFront"), cathode("cathode"), xavg_sabreCoinc("xavg_sabreCoinc"), x1_weight("x1_weight"), x2_weight("x2_weight"),
|
||||||
beamIntegrator("beamIntegrator")
|
beamIntegrator("beamIntegrator")
|
||||||
{
|
{
|
||||||
SPEC_PROFILE_FUNCTION();
|
SPEC_PROFILE_FUNCTION();
|
||||||
SpectrumManager& manager = SpectrumManager::GetInstance();
|
manager->BindParameter(delayFLTime);
|
||||||
manager.BindParameter(delayFLTime);
|
manager->BindParameter(delayFRTime);
|
||||||
manager.BindParameter(delayFRTime);
|
manager->BindParameter(delayBLTime);
|
||||||
manager.BindParameter(delayBLTime);
|
manager->BindParameter(delayBRTime);
|
||||||
manager.BindParameter(delayBRTime);
|
|
||||||
//Bind parameters with some default histograms. Saves us the effort of making them in the UI.
|
//Bind parameters with some default histograms. Saves us the effort of making them in the UI.
|
||||||
manager.BindParameter(x1, 600, -300.0, 300.0);
|
manager->BindParameter(x1, 600, -300.0, 300.0);
|
||||||
manager.BindParameter(x2, 600, -300.0, 300.0);
|
manager->BindParameter(x2, 600, -300.0, 300.0);
|
||||||
manager.BindParameter(xavg, 600, -300.0, 300.0);
|
manager->BindParameter(xavg, 600, -300.0, 300.0);
|
||||||
manager.BindParameter(scintLeft, 4096, 0.0, 4096.0);
|
manager->BindParameter(scintLeft, 4096, 0.0, 4096.0);
|
||||||
manager.BindParameter(anodeBack, 4096, 0.0, 4096.0);
|
manager->BindParameter(anodeBack, 4096, 0.0, 4096.0);
|
||||||
manager.BindParameter(anodeFront, 4096, 0.0, 4096.0);
|
manager->BindParameter(anodeFront, 4096, 0.0, 4096.0);
|
||||||
manager.BindParameter(cathode, 4096, 0.0, 4096);
|
manager->BindParameter(cathode, 4096, 0.0, 4096);
|
||||||
manager.BindParameter(xavg_sabreCoinc, 600, -300.0, 300.0);
|
manager->BindParameter(xavg_sabreCoinc, 600, -300.0, 300.0);
|
||||||
|
|
||||||
std::vector<std::string> sabre_list;
|
std::vector<std::string> sabre_list;
|
||||||
for (int i = 0; i < 127; i++)
|
for (int i = 0; i < 127; i++)
|
||||||
{
|
{
|
||||||
sabre_list.push_back("sabre_" + std::to_string(i));
|
sabre_list.push_back("sabre_" + std::to_string(i));
|
||||||
sabre.emplace_back(sabre_list[i]);
|
sabre.emplace_back(sabre_list[i]);
|
||||||
manager.BindParameter(sabre[i]);
|
manager->BindParameter(sabre[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//If you want to make a histogram default available, you can add one like this.
|
//If you want to make a histogram default available, you can add one like this.
|
||||||
manager.AddHistogramSummary(HistogramArgs("sabre_summary", "", 512, 0.0, 16384), sabre_list);
|
manager->AddHistogramSummary(HistogramArgs("sabre_summary", "", 512, 0.0, 16384), sabre_list);
|
||||||
//Note that if you save a config, the config rep of this histogram will supercede this version.
|
//Note that if you save a config, the config rep of this histogram will supercede this version.
|
||||||
|
|
||||||
manager.BindVariable(x1_weight);
|
manager->BindVariable(x1_weight);
|
||||||
manager.BindVariable(x2_weight);
|
manager->BindVariable(x2_weight);
|
||||||
|
|
||||||
manager.BindScaler(beamIntegrator);
|
manager->BindScaler(beamIntegrator);
|
||||||
}
|
}
|
||||||
|
|
||||||
SPSAnalysisStage::~SPSAnalysisStage() {}
|
SPSAnalysisStage::~SPSAnalysisStage() {}
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace Specter {
|
||||||
class SPSAnalysisStage : public AnalysisStage
|
class SPSAnalysisStage : public AnalysisStage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SPSAnalysisStage();
|
SPSAnalysisStage(const SpectrumManager::Ref& manager);
|
||||||
virtual ~SPSAnalysisStage();
|
virtual ~SPSAnalysisStage();
|
||||||
|
|
||||||
virtual void AnalyzePhysicsEvent(const SpecEvent& event) override;
|
virtual void AnalyzePhysicsEvent(const SpecEvent& event) override;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
namespace Specter {
|
namespace Specter {
|
||||||
|
|
||||||
SPSInputLayer::SPSInputLayer() :
|
SPSInputLayer::SPSInputLayer(const SpectrumManager::Ref& manager) :
|
||||||
Layer("SPSInputLayer"), x1_weight("x1_weight"), x2_weight("x2_weight"), m_bfield(0.0), m_theta(0.0), m_beamKE(0.0),
|
Layer("SPSInputLayer"), x1_weight("x1_weight"), x2_weight("x2_weight"), m_bfield(0.0), m_theta(0.0), m_beamKE(0.0),
|
||||||
m_rxnEqn("")
|
m_rxnEqn("")
|
||||||
{
|
{
|
||||||
|
@ -28,9 +28,8 @@ namespace Specter {
|
||||||
m_residNums[i] = 0;
|
m_residNums[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpectrumManager& manager = SpectrumManager::GetInstance();
|
manager->BindVariable(x1_weight);
|
||||||
manager.BindVariable(x1_weight);
|
manager->BindVariable(x2_weight);
|
||||||
manager.BindVariable(x2_weight);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SPSInputLayer::~SPSInputLayer() {}
|
SPSInputLayer::~SPSInputLayer() {}
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace Specter {
|
||||||
class SPSInputLayer : public Layer
|
class SPSInputLayer : public Layer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SPSInputLayer();
|
SPSInputLayer(const SpectrumManager::Ref& manager);
|
||||||
~SPSInputLayer();
|
~SPSInputLayer();
|
||||||
|
|
||||||
virtual void OnAttach() override;
|
virtual void OnAttach() override;
|
||||||
|
|
|
@ -16,9 +16,9 @@ public:
|
||||||
SPSApp(const Specter::ApplicationArgs& args) :
|
SPSApp(const Specter::ApplicationArgs& args) :
|
||||||
Specter::Application(args)
|
Specter::Application(args)
|
||||||
{
|
{
|
||||||
PushLayer(new Specter::SPSInputLayer());
|
PushLayer(new Specter::SPSInputLayer(m_manager));
|
||||||
//PushLayer(new Navigator::TestServerLayer());
|
//PushLayer(new Navigator::TestServerLayer());
|
||||||
PushAnalysisStage(new Specter::SPSAnalysisStage());
|
PushAnalysisStage(new Specter::SPSAnalysisStage(m_manager));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -34,9 +34,12 @@ namespace Specter {
|
||||||
m_window = std::unique_ptr<Window>(Window::Create({m_args.name, 1280, 720}));
|
m_window = std::unique_ptr<Window>(Window::Create({m_args.name, 1280, 720}));
|
||||||
m_window->SetEventCallback(BIND_EVENT_FUNCTION(Application::OnEvent)); //Allow window to pass events back
|
m_window->SetEventCallback(BIND_EVENT_FUNCTION(Application::OnEvent)); //Allow window to pass events back
|
||||||
|
|
||||||
m_physicsLayer = new PhysicsLayer();
|
//Create the manager
|
||||||
|
m_manager = std::make_shared<SpectrumManager>();
|
||||||
|
|
||||||
|
m_physicsLayer = new PhysicsLayer(m_manager);
|
||||||
PushLayer(m_physicsLayer);
|
PushLayer(m_physicsLayer);
|
||||||
EditorLayer* editor = new EditorLayer(); //memory handled by layer stack
|
EditorLayer* editor = new EditorLayer(m_manager); //memory handled by layer stack
|
||||||
editor->SetEventCallbackFunc(BIND_EVENT_FUNCTION(Application::OnEvent)); //Allow editor to pass events back
|
editor->SetEventCallbackFunc(BIND_EVENT_FUNCTION(Application::OnEvent)); //Allow editor to pass events back
|
||||||
PushLayer(editor);
|
PushLayer(editor);
|
||||||
m_imgui_layer = new ImGuiLayer();
|
m_imgui_layer = new ImGuiLayer();
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "Specter/Core/Window.h"
|
#include "Specter/Core/Window.h"
|
||||||
#include "Specter/ImGui/ImGuiLayer.h"
|
#include "Specter/ImGui/ImGuiLayer.h"
|
||||||
#include "Specter/Physics/PhysicsLayer.h"
|
#include "Specter/Physics/PhysicsLayer.h"
|
||||||
|
#include "SpectrumManager.h"
|
||||||
#include "glm/vec4.hpp"
|
#include "glm/vec4.hpp"
|
||||||
|
|
||||||
namespace Specter {
|
namespace Specter {
|
||||||
|
@ -44,6 +45,7 @@ namespace Specter {
|
||||||
inline void PushAnalysisStage(AnalysisStage* stage) { m_physicsLayer->PushStage(stage); }
|
inline void PushAnalysisStage(AnalysisStage* stage) { m_physicsLayer->PushStage(stage); }
|
||||||
void PushOverlay(Layer* layer);
|
void PushOverlay(Layer* layer);
|
||||||
|
|
||||||
|
|
||||||
inline static Application& Get() { return *s_instance; }
|
inline static Application& Get() { return *s_instance; }
|
||||||
|
|
||||||
inline Window& GetWindow() { return *m_window; }
|
inline Window& GetWindow() { return *m_window; }
|
||||||
|
@ -52,6 +54,7 @@ namespace Specter {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool OnWindowCloseEvent(WindowCloseEvent& event);
|
bool OnWindowCloseEvent(WindowCloseEvent& event);
|
||||||
|
bool OnManagerBindEvent(const std::shared_ptr<SpectrumManager>& manager);
|
||||||
|
|
||||||
ApplicationArgs m_args;
|
ApplicationArgs m_args;
|
||||||
|
|
||||||
|
@ -65,6 +68,9 @@ namespace Specter {
|
||||||
glm::vec4 m_bckgnd_color = {0.1f, 0.1f, 0.1f, 1.0f};
|
glm::vec4 m_bckgnd_color = {0.1f, 0.1f, 0.1f, 1.0f};
|
||||||
|
|
||||||
static Application* s_instance;
|
static Application* s_instance;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
SpectrumManager::Ref m_manager; //manager needs to be available to derived classes
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
|
|
||||||
namespace Specter {
|
namespace Specter {
|
||||||
|
|
||||||
SpectrumManager* SpectrumManager::s_instance = new SpectrumManager();
|
|
||||||
|
|
||||||
SpectrumManager::SpectrumManager()
|
SpectrumManager::SpectrumManager()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
/*
|
/*
|
||||||
SpectrumManager.h
|
SpectrumManager.h
|
||||||
SpectrumManager is the global resource management class. Controls everything related to spectra (histograms, cuts, parameters). Since
|
SpectrumManager is the application resource management class. Controls everything related to spectra (histograms, cuts, parameters). Since
|
||||||
the manager must traverse threads, explicit synchronoization is handled through a mutex. To this end, excessive calls to the manager should be
|
the manager must traverse threads, explicit synchronoization is handled through a mutex. To this end, excessive calls to the manager should be
|
||||||
avoided if possible, as this will increase the lock deadtime in the application, which is especially bad for online data sources.
|
avoided if possible, as this will increase the lock deadtime in the application, which is especially bad for online data sources.
|
||||||
|
|
||||||
Note that SpectrumManager is a singleton. There should only ever be one SpectrumManager with a given application.
|
Note that SpectrumManager is a singleton. There should only ever be one SpectrumManager with a given application.
|
||||||
|
|
||||||
GWM -- Feb 2022
|
GWM -- Feb 2022
|
||||||
|
|
||||||
|
Modified to be non-singleton. Singleton implementation was going to hold us back from some future development.
|
||||||
|
|
||||||
|
GWM -- July 2022
|
||||||
*/
|
*/
|
||||||
#ifndef SPECTRUM_MANAGER_H
|
#ifndef SPECTRUM_MANAGER_H
|
||||||
#define SPECTRUM_MANAGER_H
|
#define SPECTRUM_MANAGER_H
|
||||||
|
@ -26,11 +30,11 @@ namespace Specter {
|
||||||
class SpectrumManager
|
class SpectrumManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
using Ref = std::shared_ptr<SpectrumManager>;
|
||||||
|
|
||||||
SpectrumManager();
|
SpectrumManager();
|
||||||
~SpectrumManager();
|
~SpectrumManager();
|
||||||
|
|
||||||
inline static SpectrumManager& GetInstance() { return *s_instance; }
|
|
||||||
|
|
||||||
//To clear all managed spectra. Note that Parameters are left untouched.
|
//To clear all managed spectra. Note that Parameters are left untouched.
|
||||||
inline void RemoveAllSpectra()
|
inline void RemoveAllSpectra()
|
||||||
{
|
{
|
||||||
|
@ -105,8 +109,6 @@ namespace Specter {
|
||||||
bool IsCutValid(const std::string& name);
|
bool IsCutValid(const std::string& name);
|
||||||
void ResetCutValidities();
|
void ResetCutValidities();
|
||||||
|
|
||||||
static SpectrumManager* s_instance;
|
|
||||||
|
|
||||||
//Actual data
|
//Actual data
|
||||||
std::unordered_map<std::string, std::shared_ptr<Histogram>> m_histoMap;
|
std::unordered_map<std::string, std::shared_ptr<Histogram>> m_histoMap;
|
||||||
std::unordered_map<std::string, std::shared_ptr<Cut>> m_cutMap;
|
std::unordered_map<std::string, std::shared_ptr<Cut>> m_cutMap;
|
||||||
|
|
|
@ -12,16 +12,14 @@
|
||||||
GWM -- Feb 2022
|
GWM -- Feb 2022
|
||||||
*/
|
*/
|
||||||
#include "SpectrumSerializer.h"
|
#include "SpectrumSerializer.h"
|
||||||
#include "SpectrumManager.h"
|
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include "yaml-cpp/yaml.h"
|
#include "yaml-cpp/yaml.h"
|
||||||
|
|
||||||
namespace Specter {
|
namespace Specter {
|
||||||
|
|
||||||
static void SerializeCut(YAML::Emitter& output, const CutArgs& args)
|
static void SerializeCut(YAML::Emitter& output, const std::shared_ptr<SpectrumManager>& manager, const CutArgs& args)
|
||||||
{
|
{
|
||||||
SpectrumManager& manager = SpectrumManager::GetInstance();
|
|
||||||
output << YAML::BeginMap;
|
output << YAML::BeginMap;
|
||||||
output << YAML::Key << "Cut" << YAML::Value << args.name;
|
output << YAML::Key << "Cut" << YAML::Value << args.name;
|
||||||
output << YAML::Key << "Type" << YAML::Value << ConvertCutTypeToString(args.type);
|
output << YAML::Key << "Type" << YAML::Value << ConvertCutTypeToString(args.type);
|
||||||
|
@ -29,21 +27,21 @@ namespace Specter {
|
||||||
output << YAML::Key << "YParameter" << YAML::Value << args.y_par;
|
output << YAML::Key << "YParameter" << YAML::Value << args.y_par;
|
||||||
if (args.type == CutType::Cut1D)
|
if (args.type == CutType::Cut1D)
|
||||||
{
|
{
|
||||||
std::vector<double> xpoints = manager.GetCutXPoints(args.name);
|
std::vector<double> xpoints = manager->GetCutXPoints(args.name);
|
||||||
output << YAML::Key << "XMin" << YAML::Value << xpoints[0];
|
output << YAML::Key << "XMin" << YAML::Value << xpoints[0];
|
||||||
output << YAML::Key << "XMax" << YAML::Value << xpoints[1];
|
output << YAML::Key << "XMax" << YAML::Value << xpoints[1];
|
||||||
}
|
}
|
||||||
else if (args.type == CutType::Cut2D)
|
else if (args.type == CutType::Cut2D)
|
||||||
{
|
{
|
||||||
std::vector<double> xpoints = manager.GetCutXPoints(args.name);
|
std::vector<double> xpoints = manager->GetCutXPoints(args.name);
|
||||||
std::vector<double> ypoints = manager.GetCutYPoints(args.name);
|
std::vector<double> ypoints = manager->GetCutYPoints(args.name);
|
||||||
output << YAML::Key << "XPoints" << YAML::Value << xpoints;
|
output << YAML::Key << "XPoints" << YAML::Value << xpoints;
|
||||||
output << YAML::Key << "YPoints" << YAML::Value << ypoints;
|
output << YAML::Key << "YPoints" << YAML::Value << ypoints;
|
||||||
}
|
}
|
||||||
else if (args.type == CutType::CutSummaryAll || args.type == CutType::CutSummaryAny)
|
else if (args.type == CutType::CutSummaryAll || args.type == CutType::CutSummaryAny)
|
||||||
{
|
{
|
||||||
std::vector<std::string> subhistos = manager.GetCutSubHistograms(args.name);
|
std::vector<std::string> subhistos = manager->GetCutSubHistograms(args.name);
|
||||||
std::vector<double> xpoints = manager.GetCutXPoints(args.name);
|
std::vector<double> xpoints = manager->GetCutXPoints(args.name);
|
||||||
output << YAML::Key << "XMin" << YAML::Value << xpoints[0];
|
output << YAML::Key << "XMin" << YAML::Value << xpoints[0];
|
||||||
output << YAML::Key << "XMax" << YAML::Value << xpoints[1];
|
output << YAML::Key << "XMax" << YAML::Value << xpoints[1];
|
||||||
output << YAML::Key << "SubHistos" << YAML::Value << subhistos;
|
output << YAML::Key << "SubHistos" << YAML::Value << subhistos;
|
||||||
|
@ -51,7 +49,7 @@ namespace Specter {
|
||||||
output << YAML::EndMap;
|
output << YAML::EndMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SerializeHistogram(YAML::Emitter& output, const HistogramArgs& args)
|
static void SerializeHistogram(YAML::Emitter& output, const std::shared_ptr<SpectrumManager>& manager, const HistogramArgs& args)
|
||||||
{
|
{
|
||||||
output << YAML::BeginMap;
|
output << YAML::BeginMap;
|
||||||
output << YAML::Key << "Histogram" << YAML::Value << args.name;
|
output << YAML::Key << "Histogram" << YAML::Value << args.name;
|
||||||
|
@ -66,7 +64,7 @@ namespace Specter {
|
||||||
output << YAML::Key << "YBins" << YAML::Value << args.nbins_y;
|
output << YAML::Key << "YBins" << YAML::Value << args.nbins_y;
|
||||||
if (args.type == SpectrumType::Summary)
|
if (args.type == SpectrumType::Summary)
|
||||||
{
|
{
|
||||||
std::vector<std::string> subhistos = SpectrumManager::GetInstance().GetSubHistograms(args.name);
|
std::vector<std::string> subhistos = manager->GetSubHistograms(args.name);
|
||||||
output << YAML::Key << "SubHistos" << YAML::Value << subhistos;
|
output << YAML::Key << "SubHistos" << YAML::Value << subhistos;
|
||||||
}
|
}
|
||||||
output << YAML::Key << "CutsDrawn" << YAML::Value << args.cutsDrawnUpon;
|
output << YAML::Key << "CutsDrawn" << YAML::Value << args.cutsDrawnUpon;
|
||||||
|
@ -82,7 +80,7 @@ namespace Specter {
|
||||||
|
|
||||||
SpectrumSerializer::~SpectrumSerializer() {}
|
SpectrumSerializer::~SpectrumSerializer() {}
|
||||||
|
|
||||||
void SpectrumSerializer::SerializeData(const std::vector<HistogramArgs>& histoList, const std::vector<CutArgs>& cutList)
|
void SpectrumSerializer::SerializeData(const SpectrumManager::Ref& manager, const std::vector<HistogramArgs>& histoList, const std::vector<CutArgs>& cutList)
|
||||||
{
|
{
|
||||||
std::ofstream output(m_filename);
|
std::ofstream output(m_filename);
|
||||||
if (!output.is_open())
|
if (!output.is_open())
|
||||||
|
@ -96,13 +94,13 @@ namespace Specter {
|
||||||
yamlStream << YAML::Key << "Cuts" << YAML::Value << YAML::BeginSeq;
|
yamlStream << YAML::Key << "Cuts" << YAML::Value << YAML::BeginSeq;
|
||||||
for (auto& cut : cutList)
|
for (auto& cut : cutList)
|
||||||
{
|
{
|
||||||
SerializeCut(yamlStream, cut);
|
SerializeCut(yamlStream, manager, cut);
|
||||||
}
|
}
|
||||||
yamlStream << YAML::EndSeq;
|
yamlStream << YAML::EndSeq;
|
||||||
yamlStream << YAML::Key << "Histograms" << YAML::Value << YAML::BeginSeq;
|
yamlStream << YAML::Key << "Histograms" << YAML::Value << YAML::BeginSeq;
|
||||||
for (auto& histo : histoList)
|
for (auto& histo : histoList)
|
||||||
{
|
{
|
||||||
SerializeHistogram(yamlStream, histo);
|
SerializeHistogram(yamlStream, manager, histo);
|
||||||
}
|
}
|
||||||
yamlStream << YAML::EndSeq << YAML::EndMap;
|
yamlStream << YAML::EndSeq << YAML::EndMap;
|
||||||
|
|
||||||
|
@ -111,10 +109,9 @@ namespace Specter {
|
||||||
output.close();
|
output.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpectrumSerializer::DeserializeData()
|
void SpectrumSerializer::DeserializeData(const SpectrumManager::Ref& manager)
|
||||||
{
|
{
|
||||||
SpectrumManager& manager = SpectrumManager::GetInstance();
|
manager->RemoveAllSpectra(); //When loading in, we remove all extant data, to avoid any potential collisions.
|
||||||
manager.RemoveAllSpectra(); //When loading in, we remove all extant data, to avoid any potential collisions.
|
|
||||||
|
|
||||||
YAML::Node data;
|
YAML::Node data;
|
||||||
try
|
try
|
||||||
|
@ -139,15 +136,15 @@ namespace Specter {
|
||||||
tempArgs.y_par = cut["YParameter"].as<std::string>();
|
tempArgs.y_par = cut["YParameter"].as<std::string>();
|
||||||
if (tempArgs.type == CutType::Cut1D)
|
if (tempArgs.type == CutType::Cut1D)
|
||||||
{
|
{
|
||||||
manager.AddCut(tempArgs, cut["XMin"].as<double>(), cut["XMax"].as<double>());
|
manager->AddCut(tempArgs, cut["XMin"].as<double>(), cut["XMax"].as<double>());
|
||||||
}
|
}
|
||||||
else if (tempArgs.type == CutType::Cut2D)
|
else if (tempArgs.type == CutType::Cut2D)
|
||||||
{
|
{
|
||||||
manager.AddCut(tempArgs, cut["XPoints"].as<std::vector<double>>(), cut["YPoints"].as<std::vector<double>>());
|
manager->AddCut(tempArgs, cut["XPoints"].as<std::vector<double>>(), cut["YPoints"].as<std::vector<double>>());
|
||||||
}
|
}
|
||||||
else if (tempArgs.type == CutType::CutSummaryAll || tempArgs.type == CutType::CutSummaryAny)
|
else if (tempArgs.type == CutType::CutSummaryAll || tempArgs.type == CutType::CutSummaryAny)
|
||||||
{
|
{
|
||||||
manager.AddCut(tempArgs, cut["SubHistos"].as<std::vector<std::string>>(), cut["XMin"].as<double>(), cut["XMax"].as<double>());
|
manager->AddCut(tempArgs, cut["SubHistos"].as<std::vector<std::string>>(), cut["XMin"].as<double>(), cut["XMax"].as<double>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,11 +169,11 @@ namespace Specter {
|
||||||
tempArgs.cutsAppliedTo = histo["CutsApplied"].as<std::vector<std::string>>();
|
tempArgs.cutsAppliedTo = histo["CutsApplied"].as<std::vector<std::string>>();
|
||||||
if (tempArgs.type == SpectrumType::Summary)
|
if (tempArgs.type == SpectrumType::Summary)
|
||||||
{
|
{
|
||||||
manager.AddHistogramSummary(tempArgs, histo["SubHistos"].as<std::vector<std::string>>());
|
manager->AddHistogramSummary(tempArgs, histo["SubHistos"].as<std::vector<std::string>>());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
manager.AddHistogram(tempArgs);
|
manager->AddHistogram(tempArgs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include "Histogram.h"
|
#include "Histogram.h"
|
||||||
#include "Cut.h"
|
#include "Cut.h"
|
||||||
|
#include "SpectrumManager.h"
|
||||||
|
|
||||||
namespace Specter {
|
namespace Specter {
|
||||||
|
|
||||||
|
@ -25,8 +26,8 @@ namespace Specter {
|
||||||
SpectrumSerializer(const std::string& filepath);
|
SpectrumSerializer(const std::string& filepath);
|
||||||
~SpectrumSerializer();
|
~SpectrumSerializer();
|
||||||
|
|
||||||
void SerializeData(const std::vector<HistogramArgs>& histoList, const std::vector<CutArgs>& cutList);
|
void SerializeData(const SpectrumManager::Ref& manager, const std::vector<HistogramArgs>& histoList, const std::vector<CutArgs>& cutList);
|
||||||
void DeserializeData();
|
void DeserializeData(const SpectrumManager::Ref& manager);
|
||||||
|
|
||||||
inline const std::string& GetFilename() { return m_filename; }
|
inline const std::string& GetFilename() { return m_filename; }
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include "FileDialog.h"
|
#include "FileDialog.h"
|
||||||
#include "Specter/Core/Application.h"
|
#include "Specter/Core/Application.h"
|
||||||
#include "Specter/Core/SpectrumSerializer.h"
|
#include "Specter/Core/SpectrumSerializer.h"
|
||||||
#include "Specter/Core/SpectrumManager.h"
|
|
||||||
|
|
||||||
#include "IconsFontAwesome5.h"
|
#include "IconsFontAwesome5.h"
|
||||||
|
|
||||||
|
@ -23,8 +22,8 @@ namespace Specter {
|
||||||
return p1 < p2;
|
return p1 < p2;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorLayer::EditorLayer() :
|
EditorLayer::EditorLayer(const SpectrumManager::Ref& manager) :
|
||||||
Layer("EditorLayer"), m_removeHistogram(false), m_removeCut(false), m_exportHistogram(false)
|
Layer("EditorLayer"), m_manager(manager), m_removeHistogram(false), m_removeCut(false), m_exportHistogram(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +39,7 @@ namespace Specter {
|
||||||
|
|
||||||
void EditorLayer::OnUpdate(Timestep& step)
|
void EditorLayer::OnUpdate(Timestep& step)
|
||||||
{
|
{
|
||||||
SpectrumManager::GetInstance().UpdateGraphs(step);
|
m_manager->UpdateGraphs(step);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorLayer::OnEvent(Event& e)
|
void EditorLayer::OnEvent(Event& e)
|
||||||
|
@ -50,31 +49,31 @@ namespace Specter {
|
||||||
//These updates are used whenever a new object is added to the manager.
|
//These updates are used whenever a new object is added to the manager.
|
||||||
void EditorLayer::UpdateHistogramList()
|
void EditorLayer::UpdateHistogramList()
|
||||||
{
|
{
|
||||||
m_histoList = SpectrumManager::GetInstance().GetListOfHistograms();
|
m_histoList = m_manager->GetListOfHistograms();
|
||||||
std::sort(m_histoList.begin(), m_histoList.end(), SortByName<HistogramArgs>);
|
std::sort(m_histoList.begin(), m_histoList.end(), SortByName<HistogramArgs>);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorLayer::UpdateCutList()
|
void EditorLayer::UpdateCutList()
|
||||||
{
|
{
|
||||||
m_cutList = SpectrumManager::GetInstance().GetListOfCuts();
|
m_cutList = m_manager->GetListOfCuts();
|
||||||
std::sort(m_cutList.begin(), m_cutList.end(), SortByName<CutArgs>);
|
std::sort(m_cutList.begin(), m_cutList.end(), SortByName<CutArgs>);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorLayer::UpdateParameterList()
|
void EditorLayer::UpdateParameterList()
|
||||||
{
|
{
|
||||||
m_paramList = SpectrumManager::GetInstance().GetListOfParameters();
|
m_paramList = m_manager->GetListOfParameters();
|
||||||
std::sort(m_paramList.begin(), m_paramList.end(), SortByString);
|
std::sort(m_paramList.begin(), m_paramList.end(), SortByString);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorLayer::UpdateScalerList()
|
void EditorLayer::UpdateScalerList()
|
||||||
{
|
{
|
||||||
m_scalerList = SpectrumManager::GetInstance().GetListOfScalers();
|
m_scalerList = m_manager->GetListOfScalers();
|
||||||
std::sort(m_scalerList.begin(), m_scalerList.end(), SortByString);
|
std::sort(m_scalerList.begin(), m_scalerList.end(), SortByString);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorLayer::UpdateGraphList()
|
void EditorLayer::UpdateGraphList()
|
||||||
{
|
{
|
||||||
m_graphList = SpectrumManager::GetInstance().GetListOfGraphs();
|
m_graphList = m_manager->GetListOfGraphs();
|
||||||
std::sort(m_graphList.begin(), m_graphList.end(), SortByName<GraphArgs>);
|
std::sort(m_graphList.begin(), m_graphList.end(), SortByName<GraphArgs>);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,7 +205,7 @@ namespace Specter {
|
||||||
case FileDialog::Type::OpenFile:
|
case FileDialog::Type::OpenFile:
|
||||||
{
|
{
|
||||||
SpectrumSerializer serializer(fd_result.first);
|
SpectrumSerializer serializer(fd_result.first);
|
||||||
serializer.DeserializeData();
|
serializer.DeserializeData(m_manager);
|
||||||
UpdateHistogramList();
|
UpdateHistogramList();
|
||||||
UpdateCutList();
|
UpdateCutList();
|
||||||
break;
|
break;
|
||||||
|
@ -215,17 +214,17 @@ namespace Specter {
|
||||||
{
|
{
|
||||||
SPEC_INFO("Found a Save File! {0}", fd_result.first);
|
SPEC_INFO("Found a Save File! {0}", fd_result.first);
|
||||||
SpectrumSerializer serializer(fd_result.first);
|
SpectrumSerializer serializer(fd_result.first);
|
||||||
serializer.SerializeData(m_histoList, m_cutList);
|
serializer.SerializeData(m_manager, m_histoList, m_cutList);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(m_spectrumDialog.ImGuiRenderSpectrumDialog(m_histoList, m_cutList, m_paramList))
|
if(m_spectrumDialog.ImGuiRenderSpectrumDialog(m_manager, m_histoList, m_cutList, m_paramList))
|
||||||
UpdateHistogramList();
|
UpdateHistogramList();
|
||||||
|
|
||||||
m_scalerPanel.OnImGuiRender(m_scalerList, m_graphList);
|
m_scalerPanel.OnImGuiRender(m_manager, m_scalerList, m_graphList);
|
||||||
|
|
||||||
m_sourceDialog.ImGuiRenderSourceDialog();
|
m_sourceDialog.ImGuiRenderSourceDialog();
|
||||||
|
|
||||||
|
@ -235,7 +234,7 @@ namespace Specter {
|
||||||
|
|
||||||
ExportHistogramDialog();
|
ExportHistogramDialog();
|
||||||
|
|
||||||
if(m_spectrumPanel.OnImGuiRender(m_histoList, m_cutList, m_paramList))
|
if(m_spectrumPanel.OnImGuiRender(m_manager, m_histoList, m_cutList, m_paramList))
|
||||||
{
|
{
|
||||||
UpdateCutList();
|
UpdateCutList();
|
||||||
UpdateHistogramList();
|
UpdateHistogramList();
|
||||||
|
@ -315,7 +314,7 @@ namespace Specter {
|
||||||
}
|
}
|
||||||
if (ImGui::Button("Ok"))
|
if (ImGui::Button("Ok"))
|
||||||
{
|
{
|
||||||
SpectrumManager::GetInstance().RemoveHistogram(selectedGram);
|
m_manager->RemoveHistogram(selectedGram);
|
||||||
UpdateHistogramList();
|
UpdateHistogramList();
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
|
@ -351,7 +350,7 @@ namespace Specter {
|
||||||
}
|
}
|
||||||
if (ImGui::Button("Ok"))
|
if (ImGui::Button("Ok"))
|
||||||
{
|
{
|
||||||
SpectrumManager::GetInstance().RemoveCut(selectedCut);
|
m_manager->RemoveCut(selectedCut);
|
||||||
UpdateHistogramList();
|
UpdateHistogramList();
|
||||||
UpdateCutList();
|
UpdateCutList();
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
|
@ -418,7 +417,7 @@ namespace Specter {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<double> data = SpectrumManager::GetInstance().GetBinData(selectedGram.name);
|
std::vector<double> data = m_manager->GetBinData(selectedGram.name);
|
||||||
|
|
||||||
output<<"Histogram Name,"<<selectedGram.name<<std::endl;
|
output<<"Histogram Name,"<<selectedGram.name<<std::endl;
|
||||||
output<<"Min X,"<<selectedGram.min_x<<std::endl<<"Max X,"<<selectedGram.max_x<<std::endl;
|
output<<"Min X,"<<selectedGram.min_x<<std::endl<<"Max X,"<<selectedGram.max_x<<std::endl;
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "FileDialog.h"
|
#include "FileDialog.h"
|
||||||
#include "SpectrumDialog.h"
|
#include "SpectrumDialog.h"
|
||||||
#include "SourceDialog.h"
|
#include "SourceDialog.h"
|
||||||
|
#include "Specter/Core/SpectrumManager.h"
|
||||||
|
|
||||||
namespace Specter {
|
namespace Specter {
|
||||||
|
|
||||||
|
@ -27,7 +28,7 @@ namespace Specter {
|
||||||
public:
|
public:
|
||||||
using EventCallbackFunc = std::function<void(Event&)>;
|
using EventCallbackFunc = std::function<void(Event&)>;
|
||||||
|
|
||||||
EditorLayer();
|
EditorLayer(const SpectrumManager::Ref& manager);
|
||||||
~EditorLayer();
|
~EditorLayer();
|
||||||
|
|
||||||
void SetEventCallbackFunc(const EventCallbackFunc& f) { m_callbackFunc = f; }
|
void SetEventCallbackFunc(const EventCallbackFunc& f) { m_callbackFunc = f; }
|
||||||
|
@ -50,6 +51,8 @@ namespace Specter {
|
||||||
void UpdateGraphList(); //Same
|
void UpdateGraphList(); //Same
|
||||||
void ExportHistogram(HistogramArgs selectedGram, const std::string& filename);
|
void ExportHistogram(HistogramArgs selectedGram, const std::string& filename);
|
||||||
|
|
||||||
|
SpectrumManager::Ref m_manager;
|
||||||
|
|
||||||
EventCallbackFunc m_callbackFunc;
|
EventCallbackFunc m_callbackFunc;
|
||||||
|
|
||||||
SpectrumPanel m_spectrumPanel;
|
SpectrumPanel m_spectrumPanel;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#include "ScalerPanel.h"
|
#include "ScalerPanel.h"
|
||||||
#include "Specter/Core/SpectrumManager.h"
|
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "implot.h"
|
#include "implot.h"
|
||||||
|
@ -10,9 +9,8 @@ namespace Specter {
|
||||||
|
|
||||||
ScalerPanel::~ScalerPanel() {}
|
ScalerPanel::~ScalerPanel() {}
|
||||||
|
|
||||||
void ScalerPanel::OnImGuiRender(const std::vector<std::string>& scalerList, const std::vector<GraphArgs>& graphList)
|
void ScalerPanel::OnImGuiRender(const SpectrumManager::Ref& manager, const std::vector<std::string>& scalerList, const std::vector<GraphArgs>& graphList)
|
||||||
{
|
{
|
||||||
SpectrumManager& manager = SpectrumManager::GetInstance();
|
|
||||||
if (ImGui::Begin("ScalerPanel"))
|
if (ImGui::Begin("ScalerPanel"))
|
||||||
{
|
{
|
||||||
if (ImGui::TreeNode("Scalers"))
|
if (ImGui::TreeNode("Scalers"))
|
||||||
|
@ -34,7 +32,7 @@ namespace Specter {
|
||||||
}
|
}
|
||||||
if (ImPlot::BeginPlot("Scaler Graphs"))
|
if (ImPlot::BeginPlot("Scaler Graphs"))
|
||||||
{
|
{
|
||||||
manager.DrawGraph(m_selectedGraph.name);
|
manager->DrawGraph(m_selectedGraph.name);
|
||||||
ImPlot::EndPlot();
|
ImPlot::EndPlot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define SCALER_PANEL_H
|
#define SCALER_PANEL_H
|
||||||
|
|
||||||
#include "Specter/Core/Graph.h"
|
#include "Specter/Core/Graph.h"
|
||||||
|
#include "Specter/Core/SpectrumManager.h"
|
||||||
|
|
||||||
namespace Specter {
|
namespace Specter {
|
||||||
|
|
||||||
|
@ -11,7 +12,7 @@ namespace Specter {
|
||||||
ScalerPanel();
|
ScalerPanel();
|
||||||
~ScalerPanel();
|
~ScalerPanel();
|
||||||
|
|
||||||
void OnImGuiRender(const std::vector<std::string>& scalerList, const std::vector<GraphArgs>& graphList);
|
void OnImGuiRender(const SpectrumManager::Ref& manager, const std::vector<std::string>& scalerList, const std::vector<GraphArgs>& graphList);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GraphArgs m_selectedGraph;
|
GraphArgs m_selectedGraph;
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
GWM -- Feb 2022
|
GWM -- Feb 2022
|
||||||
*/
|
*/
|
||||||
#include "SpectrumDialog.h"
|
#include "SpectrumDialog.h"
|
||||||
#include "Specter/Core/SpectrumManager.h"
|
|
||||||
|
|
||||||
#include "misc/cpp/imgui_stdlib.h"
|
#include "misc/cpp/imgui_stdlib.h"
|
||||||
|
|
||||||
|
@ -24,7 +23,7 @@ namespace Specter {
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpectrumDialog::ImGuiRenderSpectrumDialog(const std::vector<HistogramArgs>& histoList, const std::vector<CutArgs>& cutList, const std::vector<std::string>& paramList)
|
bool SpectrumDialog::ImGuiRenderSpectrumDialog(const SpectrumManager::Ref& manager, const std::vector<HistogramArgs>& histoList, const std::vector<CutArgs>& cutList, const std::vector<std::string>& paramList)
|
||||||
{
|
{
|
||||||
SPEC_PROFILE_FUNCTION();
|
SPEC_PROFILE_FUNCTION();
|
||||||
static std::string selectedCut = "";
|
static std::string selectedCut = "";
|
||||||
|
@ -78,9 +77,9 @@ namespace Specter {
|
||||||
{
|
{
|
||||||
switch (m_newParams.type)
|
switch (m_newParams.type)
|
||||||
{
|
{
|
||||||
case SpectrumType::Histo1D: SpectrumManager::GetInstance().AddHistogram(m_newParams); break;
|
case SpectrumType::Histo1D: manager->AddHistogram(m_newParams); break;
|
||||||
case SpectrumType::Histo2D: SpectrumManager::GetInstance().AddHistogram(m_newParams); break;
|
case SpectrumType::Histo2D: manager->AddHistogram(m_newParams); break;
|
||||||
case SpectrumType::Summary: SpectrumManager::GetInstance().AddHistogramSummary(m_newParams, m_subhistos); break;
|
case SpectrumType::Summary: manager->AddHistogramSummary(m_newParams, m_subhistos); break;
|
||||||
case SpectrumType::None: break;
|
case SpectrumType::None: break;
|
||||||
}
|
}
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
#include "Specter/Core/Histogram.h"
|
#include "Specter/Core/Histogram.h"
|
||||||
#include "Specter/Core/Cut.h"
|
#include "Specter/Core/Cut.h"
|
||||||
|
#include "Specter/Core/SpectrumManager.h"
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
|
||||||
|
@ -21,7 +22,7 @@ namespace Specter {
|
||||||
SpectrumDialog();
|
SpectrumDialog();
|
||||||
~SpectrumDialog();
|
~SpectrumDialog();
|
||||||
|
|
||||||
bool ImGuiRenderSpectrumDialog(const std::vector<HistogramArgs>& histoList, const std::vector<CutArgs>& cutList, const std::vector<std::string>& paramList);
|
bool ImGuiRenderSpectrumDialog(const SpectrumManager::Ref& manager, const std::vector<HistogramArgs>& histoList, const std::vector<CutArgs>& cutList, const std::vector<std::string>& paramList);
|
||||||
|
|
||||||
inline void SetSpectrumDialog() { m_openFlag = true; }
|
inline void SetSpectrumDialog() { m_openFlag = true; }
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
GWM -- Feb 2022
|
GWM -- Feb 2022
|
||||||
*/
|
*/
|
||||||
#include "SpectrumPanel.h"
|
#include "SpectrumPanel.h"
|
||||||
#include "Specter/Core/SpectrumManager.h"
|
|
||||||
#include "misc/cpp/imgui_stdlib.h"
|
#include "misc/cpp/imgui_stdlib.h"
|
||||||
#include "IconsFontAwesome5.h"
|
#include "IconsFontAwesome5.h"
|
||||||
|
|
||||||
|
@ -35,7 +34,7 @@ namespace Specter {
|
||||||
SpectrumPanel::~SpectrumPanel() {}
|
SpectrumPanel::~SpectrumPanel() {}
|
||||||
|
|
||||||
//Main render function. Handles generating subplot regions as well as the zoomed in region
|
//Main render function. Handles generating subplot regions as well as the zoomed in region
|
||||||
bool SpectrumPanel::OnImGuiRender(const std::vector<HistogramArgs>& histoList, const std::vector<CutArgs>& cutList, const std::vector<std::string>& paramList)
|
bool SpectrumPanel::OnImGuiRender(const SpectrumManager::Ref& manager, const std::vector<HistogramArgs>& histoList, const std::vector<CutArgs>& cutList, const std::vector<std::string>& paramList)
|
||||||
{
|
{
|
||||||
SPEC_PROFILE_FUNCTION();
|
SPEC_PROFILE_FUNCTION();
|
||||||
static bool acceptCutFlag = false;
|
static bool acceptCutFlag = false;
|
||||||
|
@ -50,20 +49,20 @@ namespace Specter {
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if(ImGui::Button("Clear"))
|
if(ImGui::Button("Clear"))
|
||||||
{
|
{
|
||||||
SpectrumManager::GetInstance().ClearHistogram(m_zoomedGram.name);
|
manager->ClearHistogram(m_zoomedGram.name);
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
RenderRemoveRegionButton();
|
RenderRemoveRegionButton();
|
||||||
if (m_zoomedGram.type == SpectrumType::Histo2D || m_zoomedGram.type == SpectrumType::Summary)
|
if (m_zoomedGram.type == SpectrumType::Histo2D || m_zoomedGram.type == SpectrumType::Summary)
|
||||||
{
|
{
|
||||||
float* scale = SpectrumManager::GetInstance().GetColorScaleRange(m_zoomedGram.name);
|
float* scale = manager->GetColorScaleRange(m_zoomedGram.name);
|
||||||
ImGui::DragFloatRange2("Min / Max", &(scale[0]), &(scale[1]), 0.01f);
|
ImGui::DragFloatRange2("Min / Max", &(scale[0]), &(scale[1]), 0.01f);
|
||||||
ImPlot::ColormapScale("##HistogramScale", scale[0], scale[1], ImVec2(0, -1), ImPlotColormap_Viridis);
|
ImPlot::ColormapScale("##HistogramScale", scale[0], scale[1], ImVec2(0, -1), ImPlotColormap_Viridis);
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
}
|
}
|
||||||
if (ImPlot::BeginPlot(m_zoomedGram.name.c_str(), ImVec2(-1, -1)))
|
if (ImPlot::BeginPlot(m_zoomedGram.name.c_str(), ImVec2(-1, -1)))
|
||||||
{
|
{
|
||||||
SpectrumManager::GetInstance().DrawHistogram(m_zoomedGram.name);
|
manager->DrawHistogram(m_zoomedGram.name);
|
||||||
if (!m_cutModeFlag && ImPlot::IsPlotHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
|
if (!m_cutModeFlag && ImPlot::IsPlotHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
|
||||||
{
|
{
|
||||||
m_zoomedFlag = false;
|
m_zoomedFlag = false;
|
||||||
|
@ -88,14 +87,14 @@ namespace Specter {
|
||||||
if (m_zoomedGram.name == region.histogram_name)
|
if (m_zoomedGram.name == region.histogram_name)
|
||||||
{
|
{
|
||||||
ImPlot::DragRect(int(i), ®ion.region.X.Min, ®ion.region.Y.Min, ®ion.region.X.Max, ®ion.region.Y.Max, ImVec4(1, 0, 1, 1), ImPlotDragToolFlags_NoFit);
|
ImPlot::DragRect(int(i), ®ion.region.X.Min, ®ion.region.Y.Min, ®ion.region.X.Max, ®ion.region.Y.Max, ImVec4(1, 0, 1, 1), ImPlotDragToolFlags_NoFit);
|
||||||
StatResults results = SpectrumManager::GetInstance().AnalyzeHistogramRegion(m_zoomedGram.name, region.region);
|
StatResults results = manager->AnalyzeHistogramRegion(m_zoomedGram.name, region.region);
|
||||||
ImPlot::PlotText(GenerateStatString(region.name, results, m_zoomedGram.y_par != "None").c_str(), (region.region.X.Max + region.region.X.Min) * 0.5,
|
ImPlot::PlotText(GenerateStatString(region.name, results, m_zoomedGram.y_par != "None").c_str(), (region.region.X.Max + region.region.X.Min) * 0.5,
|
||||||
(region.region.Y.Min + region.region.Y.Max) * 0.5);
|
(region.region.Y.Min + region.region.Y.Max) * 0.5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImPlot::EndPlot();
|
ImPlot::EndPlot();
|
||||||
}
|
}
|
||||||
RenderAcceptCutDialog();
|
RenderAcceptCutDialog(manager);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -103,7 +102,7 @@ namespace Specter {
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Button("Clear All"))
|
if (ImGui::Button("Clear All"))
|
||||||
{
|
{
|
||||||
SpectrumManager::GetInstance().ClearHistograms();
|
manager->ClearHistograms();
|
||||||
}
|
}
|
||||||
m_totalSlots = m_tableSizes[0] * m_tableSizes[1];
|
m_totalSlots = m_tableSizes[0] * m_tableSizes[1];
|
||||||
m_selectedGrams.resize(m_totalSlots);
|
m_selectedGrams.resize(m_totalSlots);
|
||||||
|
@ -140,7 +139,7 @@ namespace Specter {
|
||||||
{
|
{
|
||||||
if (ImPlot::BeginPlot(spec.name.c_str()))
|
if (ImPlot::BeginPlot(spec.name.c_str()))
|
||||||
{
|
{
|
||||||
SpectrumManager::GetInstance().DrawHistogram(spec.name);
|
manager->DrawHistogram(spec.name);
|
||||||
if (ImPlot::IsPlotHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
|
if (ImPlot::IsPlotHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
|
||||||
{
|
{
|
||||||
m_zoomedFlag = true;
|
m_zoomedFlag = true;
|
||||||
|
@ -223,7 +222,7 @@ namespace Specter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpectrumPanel::RenderAcceptCutDialog()
|
void SpectrumPanel::RenderAcceptCutDialog(const SpectrumManager::Ref& manager)
|
||||||
{
|
{
|
||||||
if (m_acceptCutFlag)
|
if (m_acceptCutFlag)
|
||||||
{
|
{
|
||||||
|
@ -236,36 +235,35 @@ namespace Specter {
|
||||||
ImGui::Text("Save this Cut?");
|
ImGui::Text("Save this Cut?");
|
||||||
if (ImGui::Button("Yes"))
|
if (ImGui::Button("Yes"))
|
||||||
{
|
{
|
||||||
SpectrumManager& manager = SpectrumManager::GetInstance();
|
|
||||||
switch (m_newCutArgs.type)
|
switch (m_newCutArgs.type)
|
||||||
{
|
{
|
||||||
case CutType::Cut1D:
|
case CutType::Cut1D:
|
||||||
{
|
{
|
||||||
std::sort(m_newCutX.begin(), m_newCutX.end());
|
std::sort(m_newCutX.begin(), m_newCutX.end());
|
||||||
manager.AddCut(m_newCutArgs, m_newCutX[0], m_newCutX[1]);
|
manager->AddCut(m_newCutArgs, m_newCutX[0], m_newCutX[1]);
|
||||||
manager.AddCutToHistogramDraw(m_newCutArgs.name, m_zoomedGram.name);
|
manager->AddCutToHistogramDraw(m_newCutArgs.name, m_zoomedGram.name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CutType::Cut2D:
|
case CutType::Cut2D:
|
||||||
{
|
{
|
||||||
manager.AddCut(m_newCutArgs, m_newCutX, m_newCutY);
|
manager->AddCut(m_newCutArgs, m_newCutX, m_newCutY);
|
||||||
manager.AddCutToHistogramDraw(m_newCutArgs.name, m_zoomedGram.name);
|
manager->AddCutToHistogramDraw(m_newCutArgs.name, m_zoomedGram.name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CutType::CutSummaryAny:
|
case CutType::CutSummaryAny:
|
||||||
{
|
{
|
||||||
std::sort(m_newCutX.begin(), m_newCutX.end());
|
std::sort(m_newCutX.begin(), m_newCutX.end());
|
||||||
std::vector<std::string> subhistos = manager.GetSubHistograms(m_zoomedGram.name);
|
std::vector<std::string> subhistos = manager->GetSubHistograms(m_zoomedGram.name);
|
||||||
manager.AddCut(m_newCutArgs, subhistos, m_newCutX[0], m_newCutX[1]);
|
manager->AddCut(m_newCutArgs, subhistos, m_newCutX[0], m_newCutX[1]);
|
||||||
manager.AddCutToHistogramDraw(m_newCutArgs.name, m_zoomedGram.name);
|
manager->AddCutToHistogramDraw(m_newCutArgs.name, m_zoomedGram.name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CutType::CutSummaryAll:
|
case CutType::CutSummaryAll:
|
||||||
{
|
{
|
||||||
std::sort(m_newCutX.begin(), m_newCutX.end());
|
std::sort(m_newCutX.begin(), m_newCutX.end());
|
||||||
std::vector<std::string> subhistos = manager.GetSubHistograms(m_zoomedGram.name);
|
std::vector<std::string> subhistos = manager->GetSubHistograms(m_zoomedGram.name);
|
||||||
manager.AddCut(m_newCutArgs, subhistos, m_newCutX[0], m_newCutX[1]);
|
manager->AddCut(m_newCutArgs, subhistos, m_newCutX[0], m_newCutX[1]);
|
||||||
manager.AddCutToHistogramDraw(m_newCutArgs.name, m_zoomedGram.name);
|
manager->AddCutToHistogramDraw(m_newCutArgs.name, m_zoomedGram.name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CutType::None:
|
case CutType::None:
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#ifndef SPECTRUM_PANEL_H
|
#ifndef SPECTRUM_PANEL_H
|
||||||
#define SPECTRUM_PANEL_H
|
#define SPECTRUM_PANEL_H
|
||||||
|
|
||||||
|
#include "Specter/Core/SpectrumManager.h"
|
||||||
#include "Specter/Core/Histogram.h"
|
#include "Specter/Core/Histogram.h"
|
||||||
#include "Specter/Core/Cut.h"
|
#include "Specter/Core/Cut.h"
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
@ -33,16 +34,17 @@ namespace Specter {
|
||||||
SpectrumPanel();
|
SpectrumPanel();
|
||||||
~SpectrumPanel();
|
~SpectrumPanel();
|
||||||
|
|
||||||
bool OnImGuiRender(const std::vector<HistogramArgs>& histoList, const std::vector<CutArgs>& cutList, const std::vector<std::string>& paramList);
|
bool OnImGuiRender(const SpectrumManager::Ref& manager, const std::vector<HistogramArgs>& histoList, const std::vector<CutArgs>& cutList, const std::vector<std::string>& paramList);
|
||||||
inline const std::string& GetZoomedOnHistogram() { return m_zoomedGram.name; }
|
inline const std::string& GetZoomedOnHistogram() { return m_zoomedGram.name; }
|
||||||
inline const bool IsZoomed() { return m_zoomedFlag; }
|
inline const bool IsZoomed() { return m_zoomedFlag; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void HandleCutMode();
|
void HandleCutMode();
|
||||||
void RenderAcceptCutDialog();
|
void RenderAcceptCutDialog(const SpectrumManager::Ref& manager);
|
||||||
void RenderCutButton();
|
void RenderCutButton();
|
||||||
void RenderRemoveRegionButton();
|
void RenderRemoveRegionButton();
|
||||||
void RemoveSelectedRegion(const std::string& region);
|
void RemoveSelectedRegion(const std::string& region);
|
||||||
|
|
||||||
std::vector<HistogramArgs> m_selectedGrams;
|
std::vector<HistogramArgs> m_selectedGrams;
|
||||||
std::vector<IntegrationRegion> m_integralRegions;
|
std::vector<IntegrationRegion> m_integralRegions;
|
||||||
bool m_zoomedFlag;
|
bool m_zoomedFlag;
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace Specter {
|
||||||
|
|
||||||
m_file->seekg(0, std::ios_base::end);
|
m_file->seekg(0, std::ios_base::end);
|
||||||
m_size = (unsigned int)m_file->tellg();
|
m_size = (unsigned int)m_file->tellg();
|
||||||
if(m_size == 0)
|
if(m_size == 2)
|
||||||
{
|
{
|
||||||
m_eofFlag = true;
|
m_eofFlag = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,8 +33,8 @@ namespace Specter {
|
||||||
enum CompassHeaders
|
enum CompassHeaders
|
||||||
{
|
{
|
||||||
Energy = 0x0001,
|
Energy = 0x0001,
|
||||||
EnergyShort = 0x0002,
|
EnergyShort = 0x0004,
|
||||||
EnergyCalibrated = 0x0004,
|
EnergyCalibrated = 0x0002,
|
||||||
Waves = 0x0008
|
Waves = 0x0008
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace Specter {
|
||||||
bool GetHitsFromFiles();
|
bool GetHitsFromFiles();
|
||||||
|
|
||||||
std::filesystem::path m_directory;
|
std::filesystem::path m_directory;
|
||||||
const std::string m_extension = ".bin";
|
const std::string m_extension = ".BIN";
|
||||||
|
|
||||||
std::vector<CompassFile> m_datafiles;
|
std::vector<CompassFile> m_datafiles;
|
||||||
unsigned int m_startIndex; //this is the file we start looking at; increases as we finish files.
|
unsigned int m_startIndex; //this is the file we start looking at; increases as we finish files.
|
||||||
|
|
|
@ -8,13 +8,12 @@
|
||||||
GWM -- Feb 2022
|
GWM -- Feb 2022
|
||||||
*/
|
*/
|
||||||
#include "PhysicsLayer.h"
|
#include "PhysicsLayer.h"
|
||||||
#include "Specter/Core/SpectrumManager.h"
|
|
||||||
#include "SpecData.h"
|
#include "SpecData.h"
|
||||||
|
|
||||||
namespace Specter {
|
namespace Specter {
|
||||||
|
|
||||||
PhysicsLayer::PhysicsLayer() :
|
PhysicsLayer::PhysicsLayer(const SpectrumManager::Ref& manager) :
|
||||||
m_activeFlag(false), m_source(nullptr), m_eventBuilder(0), m_physThread(nullptr)
|
m_manager(manager), m_activeFlag(false), m_source(nullptr), m_eventBuilder(0), m_physThread(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,6 +88,7 @@ namespace Specter {
|
||||||
|
|
||||||
void PhysicsLayer::OnUpdate(Timestep& step) {}
|
void PhysicsLayer::OnUpdate(Timestep& step) {}
|
||||||
|
|
||||||
|
|
||||||
/*Threaded functions*/
|
/*Threaded functions*/
|
||||||
|
|
||||||
void PhysicsLayer::DestroyPhysThread()
|
void PhysicsLayer::DestroyPhysThread()
|
||||||
|
@ -143,7 +143,6 @@ namespace Specter {
|
||||||
void PhysicsLayer::RunSource()
|
void PhysicsLayer::RunSource()
|
||||||
{
|
{
|
||||||
SPEC_PROFILE_FUNCTION();
|
SPEC_PROFILE_FUNCTION();
|
||||||
SpectrumManager& manager = SpectrumManager::GetInstance();
|
|
||||||
|
|
||||||
std::vector<SpecEvent> events;
|
std::vector<SpecEvent> events;
|
||||||
SpecData datum;
|
SpecData datum;
|
||||||
|
@ -178,9 +177,9 @@ namespace Specter {
|
||||||
stage->AnalyzePhysicsEvent(event);
|
stage->AnalyzePhysicsEvent(event);
|
||||||
|
|
||||||
//Now that the analysis stack has filled all our NavParameters with data, update the histogram counts
|
//Now that the analysis stack has filled all our NavParameters with data, update the histogram counts
|
||||||
manager.UpdateHistograms();
|
m_manager->UpdateHistograms();
|
||||||
//Invalidate all parameters to get ready for next event
|
//Invalidate all parameters to get ready for next event
|
||||||
manager.InvalidateParameters();
|
m_manager->InvalidateParameters();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "AnalysisStage.h"
|
#include "AnalysisStage.h"
|
||||||
#include "DataSource.h"
|
#include "DataSource.h"
|
||||||
#include "PhysicsEventBuilder.h"
|
#include "PhysicsEventBuilder.h"
|
||||||
|
#include "Specter/Core/SpectrumManager.h"
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
@ -27,7 +28,7 @@ namespace Specter {
|
||||||
class PhysicsLayer : public Layer
|
class PhysicsLayer : public Layer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PhysicsLayer();
|
PhysicsLayer(const SpectrumManager::Ref& manager);
|
||||||
virtual ~PhysicsLayer();
|
virtual ~PhysicsLayer();
|
||||||
|
|
||||||
virtual void OnAttach() override;
|
virtual void OnAttach() override;
|
||||||
|
@ -47,6 +48,7 @@ namespace Specter {
|
||||||
void DetachDataSource();
|
void DetachDataSource();
|
||||||
void RunSource();
|
void RunSource();
|
||||||
|
|
||||||
|
SpectrumManager::Ref m_manager;
|
||||||
AnalysisStack m_physStack;
|
AnalysisStack m_physStack;
|
||||||
std::atomic<bool> m_activeFlag; //safe read/write across thread, but more expensive
|
std::atomic<bool> m_activeFlag; //safe read/write across thread, but more expensive
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user