mirror of
https://github.com/gwm17/Specter.git
synced 2024-11-22 18:28:52 -05:00
Fixed CutMap and ParameterMap to also use their underlying parameter structs in creation. Started cut UI
This commit is contained in:
parent
021358a620
commit
ee28fef0c4
|
@ -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");
|
||||
|
|
|
@ -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<double>& xpoints, const std::vector<double>& ypoints) :
|
||||
Cut(name, xpar, ypar), m_xpoints(xpoints), m_ypoints(ypoints)
|
||||
Cut2D::Cut2D(const CutParams& params, const std::vector<double>& xpoints, const std::vector<double>& ypoints) :
|
||||
Cut(params), m_xpoints(xpoints), m_ypoints(ypoints)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -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<double>& xpoints, const std::vector<double>& ypoints);
|
||||
Cut2D(const CutParams& params, const std::vector<double>& xpoints, const std::vector<double>& 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<double>& xpoints, const std::vector<double>& ypoints)
|
||||
inline void AddCut(const CutParams& params, const std::vector<double>& xpoints, const std::vector<double>& 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<std::string, std::unique_ptr<Cut>> m_map;
|
||||
std::mutex m_cutMutex;
|
||||
|
||||
static CutMap* s_instance;
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<std::string> m_selectedGrams;
|
||||
bool m_zoomedFlag;
|
||||
bool m_cutModeFlag;
|
||||
std::string m_zoomedGram;
|
||||
int m_tableSizes[2];
|
||||
int m_totalSlots;
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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"));
|
||||
|
|
Loading…
Reference in New Issue
Block a user