diff --git a/Navigator/src/Navigator/Application.cpp b/Navigator/src/Navigator/Application.cpp index ad7daa3..c4d6a3e 100644 --- a/Navigator/src/Navigator/Application.cpp +++ b/Navigator/src/Navigator/Application.cpp @@ -27,8 +27,8 @@ namespace Navigator { histMap.AddHistogram(HistogramParameters("myHisto", "joseph", 100, 0, 10)); histMap.AddHistogram(HistogramParameters("myHisto2D", "joseph", "joseph", 100, 0, 10, 100, 0, 10)); - CutMap::GetInstance().AddCut("joe_cut","joseph",0.0, 7.0); - CutMap::GetInstance().AddCut("joe2D_cut", "joseph", "joseph", { 1.0, 3.0, 3.0, 1.0, 1.0}, { 1.0, 1.0, 3.0, 3.0, 1.0}); + CutMap::GetInstance().AddCut(CutParams("joe_cut","joseph"),0.0, 7.0); + CutMap::GetInstance().AddCut(CutParams("joe2D_cut", "joseph", "joseph"), { 1.0, 3.0, 3.0, 1.0, 1.0}, { 1.0, 1.0, 3.0, 3.0, 1.0}); histMap.AddCutToHistogramDraw("joe_cut", "myHisto"); histMap.AddCutToHistogramDraw("joe2D_cut", "myHisto2D"); diff --git a/Navigator/src/Navigator/CutMap.cpp b/Navigator/src/Navigator/CutMap.cpp index c286717..db7b565 100644 --- a/Navigator/src/Navigator/CutMap.cpp +++ b/Navigator/src/Navigator/CutMap.cpp @@ -4,8 +4,8 @@ namespace Navigator { /*1D Cuts -- Can be made on and applied to either 1D or 2D histograms*/ - Cut1D::Cut1D(const std::string& name, const std::string& xpar, double min, double max) : - Cut(name, xpar), m_minVal(min), m_maxVal(max) + Cut1D::Cut1D(const CutParams& params, double min, double max) : + Cut(params), m_minVal(min), m_maxVal(max) { } @@ -24,8 +24,8 @@ namespace Navigator { } /*2D Cuts -- Can only be made on 2D histogram, but applied to either 1D or 2D histograms*/ - Cut2D::Cut2D(const std::string& name, const std::string& xpar, const std::string& ypar, const std::vector& xpoints, const std::vector& ypoints) : - Cut(name, xpar, ypar), m_xpoints(xpoints), m_ypoints(ypoints) + Cut2D::Cut2D(const CutParams& params, const std::vector& xpoints, const std::vector& ypoints) : + Cut(params), m_xpoints(xpoints), m_ypoints(ypoints) { } diff --git a/Navigator/src/Navigator/CutMap.h b/Navigator/src/Navigator/CutMap.h index a8c31c5..0964370 100644 --- a/Navigator/src/Navigator/CutMap.h +++ b/Navigator/src/Navigator/CutMap.h @@ -8,21 +8,23 @@ namespace Navigator { struct NAV_API CutParams { - CutParams(const std::string& n, const std::string& x, const std::string& y) : + CutParams() {} + CutParams(const std::string& n, const std::string& x, const std::string& y = "None") : name(n), x_par(x), y_par(y) { } - std::string name; - std::string x_par; - std::string y_par; + std::string name = "None"; + std::string x_par = "None"; + std::string y_par = "None"; }; class NAV_API Cut { public: - Cut(const std::string& name, const std::string& xpar, const std::string& ypar="None") : - m_params(name, xpar, ypar) + + Cut(const CutParams& params) : + m_params(params) { } @@ -44,7 +46,7 @@ namespace Navigator { class NAV_API Cut1D : public Cut { public: - Cut1D(const std::string& name, const std::string& xpar, double min, double max); + Cut1D(const CutParams& params, double min, double max); virtual ~Cut1D(); virtual bool IsInside(double x, double y = 0) const override; virtual void Draw() const override; @@ -58,7 +60,7 @@ namespace Navigator { class NAV_API Cut2D : public Cut { public: - Cut2D(const std::string& name, const std::string& xpar, const std::string& ypar, const std::vector& xpoints, const std::vector& ypoints); + Cut2D(const CutParams& params, const std::vector& xpoints, const std::vector& ypoints); virtual ~Cut2D(); virtual bool IsInside(double x, double y = 0) const override; virtual void Draw() const override; @@ -81,13 +83,13 @@ namespace Navigator { inline static CutMap& GetInstance() { return *s_instance; } - inline void AddCut(const std::string& name, const std::string& xpar, double min, double max) + inline void AddCut(const CutParams& params, double min, double max) { - m_map[name].reset(new Cut1D(name, xpar, min, max)); + m_map[params.name].reset(new Cut1D(params, min, max)); } - inline void AddCut(const std::string& name, const std::string& xpar, const std::string& ypar, const std::vector& xpoints, const std::vector& ypoints) + inline void AddCut(const CutParams& params, const std::vector& xpoints, const std::vector& ypoints) { - m_map[name].reset(new Cut2D(name, xpar, ypar, xpoints, ypoints)); + m_map[params.name].reset(new Cut2D(params, xpoints, ypoints)); } void DrawCut(const std::string& name); @@ -99,7 +101,6 @@ namespace Navigator { private: std::unordered_map> m_map; - std::mutex m_cutMutex; static CutMap* s_instance; }; diff --git a/Navigator/src/Navigator/Editor/SpectrumPanel.cpp b/Navigator/src/Navigator/Editor/SpectrumPanel.cpp index 3a26fb5..73d55bb 100644 --- a/Navigator/src/Navigator/Editor/SpectrumPanel.cpp +++ b/Navigator/src/Navigator/Editor/SpectrumPanel.cpp @@ -4,7 +4,7 @@ namespace Navigator { SpectrumPanel::SpectrumPanel() : - m_zoomedFlag(false), m_zoomedGram(""), m_totalSlots(1) + m_zoomedFlag(false), m_cutModeFlag("false"), m_zoomedGram(""), m_totalSlots(1) { m_tableSizes[0] = 1; m_tableSizes[1] = 1; } @@ -14,12 +14,31 @@ namespace Navigator { void SpectrumPanel::OnImGuiRender() { HistogramMap& histMap = HistogramMap::GetInstance(); + ParameterMap& paramMap = ParameterMap::GetInstance(); + CutMap& cutMap = CutMap::GetInstance(); if (ImGui::Begin("Active View")) { if (histMap.size() > 0) { if (m_zoomedFlag && m_zoomedGram != "") { + if(ImGui::Button("Draw Cut")) + { + ImGui::OpenPopup("New Cut Dialog"); + } + if(ImGui::BeginPopupModal("New Cut Dialog")) + { + if(ImGui::Button("Accept")) + { + ImGui::CloseCurrentPopup(); + } + if(ImGui::Button("Cancel")) + { + ImGui::CloseCurrentPopup(); + } + ImGui::EndPopup(); + } + if (ImPlot::BeginPlot(m_zoomedGram.c_str(), ImVec2(-1, -1))) { histMap.DrawHistogram(m_zoomedGram); @@ -89,4 +108,4 @@ namespace Navigator { ImGui::End(); } } -} \ No newline at end of file +} diff --git a/Navigator/src/Navigator/Editor/SpectrumPanel.h b/Navigator/src/Navigator/Editor/SpectrumPanel.h index 1514486..7eda1c4 100644 --- a/Navigator/src/Navigator/Editor/SpectrumPanel.h +++ b/Navigator/src/Navigator/Editor/SpectrumPanel.h @@ -2,6 +2,8 @@ #define SPECTRUM_PANEL_H #include "Navigator/HistogramMap.h" +#include "Navigator/ParameterMap.h" +#include "Navigator/CutMap.h" #include "imgui.h" namespace Navigator { @@ -19,6 +21,7 @@ namespace Navigator { private: std::vector m_selectedGrams; bool m_zoomedFlag; + bool m_cutModeFlag; std::string m_zoomedGram; int m_tableSizes[2]; int m_totalSlots; @@ -26,4 +29,4 @@ namespace Navigator { } -#endif \ No newline at end of file +#endif diff --git a/Navigator/src/Navigator/ParameterMap.cpp b/Navigator/src/Navigator/ParameterMap.cpp index d385975..e5f3486 100644 --- a/Navigator/src/Navigator/ParameterMap.cpp +++ b/Navigator/src/Navigator/ParameterMap.cpp @@ -9,7 +9,12 @@ namespace Navigator { - NavParameter::NavParameter(const std::string& name, const std::string& alias) : + NavParameter::NavParameter() : + m_name(""), m_pdata(nullptr) + { + } + + NavParameter::NavParameter(const std::string& name) : m_name(name) { NAV_INFO("Making a new parameter named {0}...",name); @@ -28,6 +33,15 @@ namespace Navigator { NavParameter::~NavParameter() {} + void NavParameter::SetParameter(const std::string& name) + { + ParameterMap& map = ParameterMap::GetInstance(); + auto iter = map.find(name); + if(iter == map.end()) + map.AddParameter(name); + map.SetParameter(name, m_pdata); + } + ParameterMap* ParameterMap::s_instance = new ParameterMap(); ParameterMap::ParameterMap() diff --git a/Navigator/src/Navigator/ParameterMap.h b/Navigator/src/Navigator/ParameterMap.h index d3b069f..e43c38a 100644 --- a/Navigator/src/Navigator/ParameterMap.h +++ b/Navigator/src/Navigator/ParameterMap.h @@ -15,13 +15,17 @@ namespace Navigator { { public: - NavParameter(const std::string& name, const std::string& alias); + NavParameter(); + NavParameter(const std::string& name); ~NavParameter(); + + void SetParameter(const std::string& name); inline bool IsValid() const { return m_pdata->validFlag; } inline void Invalidate() { m_pdata->validFlag = false; } inline void SetValue(double value) { m_pdata->validFlag = true; m_pdata->value = value; } inline double GetValue() const { return m_pdata->value; } + inline const std::string& GetName() const { return m_name; } private: std::string m_name; diff --git a/Navigator/src/Navigator/Physics/PhysicsLayer.cpp b/Navigator/src/Navigator/Physics/PhysicsLayer.cpp index dff9bf5..5782a46 100644 --- a/Navigator/src/Navigator/Physics/PhysicsLayer.cpp +++ b/Navigator/src/Navigator/Physics/PhysicsLayer.cpp @@ -9,7 +9,6 @@ namespace Navigator { PhysicsLayer::PhysicsLayer() : m_activeFlag(false), m_source(nullptr) { - } PhysicsLayer::~PhysicsLayer() @@ -18,7 +17,7 @@ namespace Navigator { void PhysicsLayer::OnAttach() { - NavParameter par("joseph", "mama"); + NavParameter par("joseph"); par.SetValue(8); NAV_INFO("Does the par exist? {0}", ParameterMap::GetInstance().IsParameterValid("joseph")); NAV_INFO("What is its value? {0}", ParameterMap::GetInstance().GetParameterValue("joseph"));