1
0
Fork 0
mirror of https://github.com/gwm17/Specter.git synced 2024-05-19 07:13:34 -04:00

Update some style, comments. Prepare for new round of testing

This commit is contained in:
Gordon McCann 2023-04-10 22:31:31 -04:00
parent 7abe92582c
commit c12bcd9f0e
27 changed files with 108 additions and 102 deletions

View File

@ -25,14 +25,14 @@ namespace Specter {
void OnUpdate() override;
inline void SetEventCallback(const EventCallbackFunc& function) override { m_data.event_callback_func = function; }
inline unsigned int GetWidth() const override { return m_data.width; }
inline unsigned int GetHeight() const override { return m_data.height; }
inline std::string GetName() const override { return m_data.name; }
void SetEventCallback(const EventCallbackFunc& function) override { m_data.event_callback_func = function; }
unsigned int GetWidth() const override { return m_data.width; }
unsigned int GetHeight() const override { return m_data.height; }
std::string GetName() const override { return m_data.name; }
void SetVSync(bool enabled) override;
bool IsVSync() const override;
inline virtual void* GetNativeWindow() const override { return m_window; }
virtual void* GetNativeWindow() const override { return m_window; }
private:
virtual void Init(const WindowProperties& props);
virtual void Shutdown();

View File

@ -38,23 +38,22 @@ namespace Specter {
virtual ~Application();
void Run();
inline void Close() { m_runFlag = false; }
void Close() { m_runFlag = false; }
void OnEvent(Event& event);
void PushLayer(Layer* layer);
inline void PushAnalysisStage(AnalysisStage* stage) { m_physicsLayer->PushStage(stage); }
void PushAnalysisStage(AnalysisStage* stage) { m_physicsLayer->PushStage(stage); }
void PushOverlay(Layer* layer);
inline static Application& Get() { return *s_instance; }
static Application& Get() { return *s_instance; }
inline Window& GetWindow() { return *m_window; }
Window& GetWindow() { return *m_window; }
inline const ApplicationArgs& GetArgs() { return m_args; }
const ApplicationArgs& GetArgs() { return m_args; }
private:
bool OnWindowCloseEvent(WindowCloseEvent& event);
bool OnManagerBindEvent(const std::shared_ptr<SpectrumManager>& manager);
ApplicationArgs m_args;
@ -75,8 +74,7 @@ namespace Specter {
/*
This function is left to be defined by the user. In principle we don't need to do this, as the Specter library doesn't handle creation of the application,
but I like it and might be useful for changing to a system with a pre-defined entry point.
This function must be defined by the user. It is called in by the entry point function in EntryPoint.h
*/
Application* CreateApplication(const ApplicationArgs& args);
}

View File

@ -64,13 +64,13 @@ namespace Specter {
virtual std::vector<double> GetXValues() const = 0;
virtual std::vector<double> GetYValues() const = 0;
inline const bool IsValid() const { return m_isValid; }
inline void ResetValidity() { m_isValid = false; }
inline CutType GetType() const { return m_params.type; }
inline const std::string& GetName() const { return m_params.name; }
inline const std::string& GetXParameter() const { return m_params.x_par; }
inline const std::string& GetYParameter() const { return m_params.y_par; }
inline const CutArgs& GetCutArgs() const { return m_params; }
const bool IsValid() const { return m_isValid; }
void ResetValidity() { m_isValid = false; }
CutType GetType() const { return m_params.type; }
const std::string& GetName() const { return m_params.name; }
const std::string& GetXParameter() const { return m_params.x_par; }
const std::string& GetYParameter() const { return m_params.y_par; }
const CutArgs& GetCutArgs() const { return m_params; }
protected:
CutArgs m_params;
bool m_isValid;
@ -115,7 +115,7 @@ namespace Specter {
virtual std::vector<double> GetXValues() const override { return std::vector<double>({ m_minVal, m_maxVal }); }
virtual std::vector<double> GetYValues() const override { return std::vector<double>(); }
inline const std::vector<std::string>& GetSubHistograms() const { return m_subhistos; }
const std::vector<std::string>& GetSubHistograms() const { return m_subhistos; }
private:
double m_minVal, m_maxVal;

View File

@ -8,9 +8,7 @@
HistogramArgs are the underlying data which define a histogram. This is grouped in a struct to easily pass these around for use in contexts like the Editor.
Every histogram has a set of histogram parameters.
Histogram is the base class of all histograms. Should not be used in practice. Every histogram contains functions to query what type of underlying histogram it is. If one has
the Histogram object, Is1D() or Is2D() can be called. If one only has the HistogramArgs, the values of x_par and y_par can be inspected. In particular, a 1D histogram will have
y_par set to "None", while a 2D histogram should have a valid parameter name for y_par.
Histogram is the base class of all histograms. Should not be used in practice. In the histogram args is an enum SpectrumType which indicates if it is a 1D, 2D, or Summary spectrum.
Histogram1D is a one dimensional (single parameter) histogram. Histogram2D is a two dimensional (two parameter) histogram. The only real difference between these in practice, other than
the obvious two vs. one parameter thing, is that a Histogram2D contains methods to set the z-axis range (color scale) which ImPlot does not provide intrinsic access to from the plot itself.
@ -19,6 +17,8 @@
StatResults is a struct containing statistical information about a region of a histogram.
A HistogramSummary is a 2D display of many 1D histograms. That is, a summary back-links to other Histogram1D's already created. It is important to note that the linked sub-histograms should all have the same binning.
GWM -- Feb 2022
*/
#include "Histogram.h"

View File

@ -8,9 +8,7 @@
HistogramArgs are the underlying data which define a histogram. This is grouped in a struct to easily pass these around for use in contexts like the Editor.
Every histogram has a set of histogram parameters.
Histogram is the base class of all histograms. Should not be used in practice. Every histogram contains functions to query what type of underlying histogram it is. If one has
the Histogram object, Is1D() or Is2D() can be called. If one only has the HistogramArgs, the values of x_par and y_par can be inspected. In particular, a 1D histogram will have
y_par set to "None", while a 2D histogram should have a valid parameter name for y_par.
Histogram is the base class of all histograms. Should not be used in practice. In the histogram args is an enum SpectrumType which indicates if it is a 1D, 2D, or Summary spectrum.
Histogram1D is a one dimensional (single parameter) histogram. Histogram2D is a two dimensional (two parameter) histogram. The only real difference between these in practice, other than
the obvious two vs. one parameter thing, is that a Histogram2D contains methods to set the z-axis range (color scale) which ImPlot does not provide intrinsic access to from the plot itself.
@ -19,6 +17,8 @@
StatResults is a struct containing statistical information about a region of a histogram.
A HistogramSummary is a 2D display of many 1D histograms. That is, a summary back-links to other Histogram1D's already created. It is important to note that the linked sub-histograms should all have the same binning.
GWM -- Feb 2022
*/
#ifndef HISTOGRAM_H
@ -93,15 +93,16 @@ namespace Specter {
virtual void Draw() {}
virtual void ClearData() {}
virtual StatResults AnalyzeRegion(double x_min, double x_max, double y_min = 0.0, double y_max = 0.0) { return StatResults(); }
inline virtual float* GetColorScaleRange() { return nullptr; }
inline virtual std::vector<double> GetBinData() { return std::vector<double>(); }
inline HistogramArgs& GetParameters() { return m_params; }
inline SpectrumType GetType() { return m_params.type; }
inline const std::string& GetXParam() const { return m_params.x_par; };
inline const std::string& GetYParam() const { return m_params.y_par; };
inline const std::string& GetName() const { return m_params.name; }
inline void AddCutToBeDrawn(const std::string& name) { m_params.cutsDrawnUpon.push_back(name); }
inline void AddCutToBeApplied(const std::string& name) { m_params.cutsAppliedTo.push_back(name); }
virtual float* GetColorScaleRange() { return nullptr; }
virtual std::vector<double> GetBinData() { return std::vector<double>(); }
HistogramArgs& GetParameters() { return m_params; }
SpectrumType GetType() { return m_params.type; }
const std::string& GetXParam() const { return m_params.x_par; };
const std::string& GetYParam() const { return m_params.y_par; };
const std::string& GetName() const { return m_params.name; }
void AddCutToBeDrawn(const std::string& name) { m_params.cutsDrawnUpon.push_back(name); }
void AddCutToBeApplied(const std::string& name) { m_params.cutsAppliedTo.push_back(name); }
protected:
HistogramArgs m_params;
@ -117,7 +118,7 @@ namespace Specter {
virtual void Draw() override;
virtual void ClearData() override;
virtual StatResults AnalyzeRegion(double x_min, double x_max, double y_min = 0.0, double y_max = 0.0) override;
inline virtual std::vector<double> GetBinData() override { return m_binCounts; }
virtual std::vector<double> GetBinData() override { return m_binCounts; }
private:
void InitBins();
@ -137,9 +138,9 @@ namespace Specter {
virtual void Draw() override;
virtual void ClearData() override;
virtual StatResults AnalyzeRegion(double x_min, double x_max, double y_min = 0.0, double y_max = 0.0) override;
inline virtual std::vector<double> GetBinData() override { return m_binCounts; }
virtual std::vector<double> GetBinData() override { return m_binCounts; }
inline virtual float* GetColorScaleRange() override { return m_colorScaleRange; }
virtual float* GetColorScaleRange() override { return m_colorScaleRange; }
private:
void InitBins();
@ -158,14 +159,14 @@ namespace Specter {
HistogramSummary(const HistogramArgs& params, const std::vector<std::string>& subhistos);
~HistogramSummary();
inline const std::vector<std::string>& GetSubHistograms() const { return m_subhistos; }
const std::vector<std::string>& GetSubHistograms() const { return m_subhistos; }
virtual void FillData(double x, double y) override;
virtual void ClearData() override;
virtual void Draw() override;
inline virtual float* GetColorScaleRange() override { return m_colorScaleRange; }
virtual float* GetColorScaleRange() override { return m_colorScaleRange; }
virtual StatResults AnalyzeRegion(double x_min, double x_max, double y_min = 0.0, double y_max = 0.0) override;
inline virtual std::vector<double> GetBinData() override { return m_binCounts; }
virtual std::vector<double> GetBinData() override { return m_binCounts; }
private:
void InitBins();

View File

@ -25,7 +25,7 @@ namespace Specter {
virtual void OnUpdate(Timestep& step) {}
virtual void OnEvent(Event& event) {}
inline const std::string& GetName() { return m_name; }
const std::string& GetName() { return m_name; }
private:
std::string m_name;

View File

@ -23,7 +23,7 @@ namespace Specter {
public:
static void Init();
inline static std::shared_ptr<spdlog::logger> GetLogger() { return s_logger; }
static std::shared_ptr<spdlog::logger> GetLogger() { return s_logger; }
private:
static std::shared_ptr<spdlog::logger> s_logger;

View File

@ -21,6 +21,10 @@
Credit to nscldaq and in particular NSCLSpecTcl which provided the inspiration for this parameter model.
GWM -- Feb 2022
Variables added; similar to Parameters, but intend to be an interface with UI feedback. See SpecProject for examples. -- GWM April 2023
Scalers added. In nuclear phyiscs, scalers refer to time counters of data, to track the rate of different detector components. -- GWM April 2023
*/
#include "Parameter.h"

View File

@ -21,6 +21,10 @@
Credit to nscldaq and in particular NSCLSpecTcl which provided the inspiration for this parameter model.
GWM -- Feb 2022
Variables added; similar to Parameters, but intend to be an interface with UI feedback. See SpecProject for examples. -- GWM April 2023
Scalers added. In nuclear phyiscs, scalers refer to time counters of data, to track the rate of different detector components. -- GWM April 2023
*/
#ifndef PARAMETER_H
#define PARAMETER_H
@ -45,11 +49,11 @@ namespace Specter {
Parameter(const std::string& name);
~Parameter();
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; }
bool IsValid() const { return m_pdata->validFlag; }
void Invalidate() { m_pdata->validFlag = false; }
void SetValue(double value) { m_pdata->validFlag = true; m_pdata->value = value; }
double GetValue() const { return m_pdata->value; }
const std::string& GetName() const { return m_name; }
void SetName(const std::string& name);
friend class SpectrumManager;
@ -77,9 +81,9 @@ namespace Specter {
Variable(const std::string& name);
~Variable();
inline void SetValue(double value) { m_pdata->value = value; }
inline double GetValue() { return m_pdata->value; }
inline const std::string& GetName() { return m_name; }
void SetValue(double value) { m_pdata->value = value; }
double GetValue() { return m_pdata->value; }
const std::string& GetName() { return m_name; }
void SetName(const std::string& name);
friend class SpectrumManager;
@ -106,10 +110,9 @@ namespace Specter {
Scaler(const std::string& name);
~Scaler();
inline void Increment() { ++(m_pdata->value); }
inline const std::string& GetName() { return m_name; }
inline uint64_t GetCounts() { return m_pdata->value; }
void Increment() { ++(m_pdata->value); }
const std::string& GetName() { return m_name; }
uint64_t GetCounts() { return m_pdata->value; }
void SetName(const std::string& name);
friend class SpectrumManager;

View File

@ -1,6 +1,6 @@
/*
SpectrumSerializer.h
SpectrumSerializer class providing method to write/read spectra (histograms and cuts) to/from a .spec file. These are formated text files.
SpectrumSerializer class providing method to write/read spectra (histograms and cuts) to/from a .yaml file. These are YAML files.
Note that by virtue of the way that cuts work, they are written first.
A couple of notes:

View File

@ -1,6 +1,6 @@
/*
SpectrumSerializer.h
SpectrumSerializer class providing method to write/read spectra (histograms and cuts) to/from a .nav file. These are formated text files.
SpectrumSerializer class providing method to write/read spectra (histograms and cuts) to/from a .yaml file. These are YAML files.
Note that by virtue of the way that cuts work, they are written first.
A couple of notes:

View File

@ -34,7 +34,7 @@ namespace Specter {
FileDialog();
~FileDialog();
inline void OpenDialog(Type type) { m_type = type; m_openDialogFlag = true; }
void OpenDialog(Type type) { m_type = type; m_openDialogFlag = true; }
std::pair<std::string, Type> RenderFileDialog(const std::string& ext = "");
private:

View File

@ -21,9 +21,9 @@ namespace Specter {
bool ImGuiRenderSourceDialog();
inline const SourceArgs& GetArgs() const { return m_args; }
const SourceArgs& GetArgs() const { return m_args; }
inline void OpenSourceDialog() { m_openFlag = true; }
void OpenSourceDialog() { m_openFlag = true; }
private:
bool m_openFlag;
SourceArgs m_args;

View File

@ -24,7 +24,7 @@ namespace Specter {
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; }
void SetSpectrumDialog() { m_openFlag = true; }
private:
void RenderDialog1D(const std::vector<std::string>& paramList);
void RenderDialog2D(const std::vector<std::string>& paramList);

View File

@ -35,8 +35,8 @@ namespace Specter {
~SpectrumPanel();
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 bool IsZoomed() { return m_zoomedFlag; }
const std::string& GetZoomedOnHistogram() { return m_zoomedGram.name; }
const bool IsZoomed() { return m_zoomedFlag; }
private:
void HandleCutMode();

View File

@ -29,8 +29,8 @@ namespace Specter {
{
}
inline int GetXSize() { return m_xSize; }
inline int GetYSize() { return m_ySize; }
int GetXSize() { return m_xSize; }
int GetYSize() { return m_ySize; }
std::string ToString() const override
{
std::stringstream ss;

View File

@ -49,7 +49,7 @@ namespace Specter {
virtual const char* GetName() const = 0;
virtual int GetCategoryFlags() const = 0;
virtual std::string ToString() const { return GetName(); }
inline bool IsCategory(EventCategory cat) const { return GetCategoryFlags() & cat; }
bool IsCategory(EventCategory cat) const { return GetCategoryFlags() & cat; }
bool handledFlag = false;
};

View File

@ -15,7 +15,7 @@ namespace Specter {
class KeyEvent : public Event
{
public:
inline int GetKeycode() const { return m_keycode; }
int GetKeycode() const { return m_keycode; }
EVENT_CATEGORY_SETUP(EventCategoryKey | EventCategoryInput)
protected:
KeyEvent(int code) :
@ -37,7 +37,7 @@ namespace Specter {
EVENT_TYPE_SETUP(KeyPressed)
inline int GetRepeatCount() const { return m_repeatCount; }
int GetRepeatCount() const { return m_repeatCount; }
std::string ToString() const override
{

View File

@ -19,8 +19,8 @@ namespace Specter {
{
}
inline float GetXPosition() { return m_xPos; }
inline float GetYPosition() { return m_yPos; }
float GetXPosition() { return m_xPos; }
float GetYPosition() { return m_yPos; }
std::string ToString() const override
{
std::stringstream ss;
@ -43,8 +43,8 @@ namespace Specter {
{
}
inline float GetXOffset() { return m_xOffset; }
inline float GetYOffset() { return m_yOffset; }
float GetXOffset() { return m_xOffset; }
float GetYOffset() { return m_yOffset; }
std::string ToString() const override
{
std::stringstream ss;
@ -67,7 +67,7 @@ namespace Specter {
{
}
inline int GetButtonCode() { return m_buttonCode; }
int GetButtonCode() { return m_buttonCode; }
std::string ToString() const override
{
std::stringstream ss;
@ -90,7 +90,7 @@ namespace Specter {
{
}
inline int GetButtonCode() { return m_buttonCode; }
int GetButtonCode() { return m_buttonCode; }
std::string ToString() const override
{
std::stringstream ss;

View File

@ -46,8 +46,6 @@ namespace Specter {
ImGuiIO& io = ImGui::GetIO();
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
//Viewports are real wonky on Linux and sometimes on MacOS
//Can currently cause assertion failure on checking number of monitors in ImGui sanity checks.
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;
ImGui::StyleColorsDark(); //Hacker mode
@ -62,9 +60,7 @@ namespace Specter {
}
//Setup our fonts. We have Roboto for text and FontAwesome for our icons.
//Note the .ttf files are found in NavProject, or in the bin dir. This is because
//the actual program (NavProject) is launched from either the bin/ ... /NaProject or the NavProject directory
//io.Fonts->AddFontDefault();
//These fonts are embedded in the application for better resource management. Found in FA-Solid.h, Roboto-Regular.h
ImFontConfig latin_config;
latin_config.RasterizerMultiply = 1.3f;
ImFontConfig config;

View File

@ -1,7 +1,7 @@
/*
AnalysisStage.h
Represents a step in a chain of analyses that are run on a NavEvent. These stages are where NavParameters are set and validated. Users should use this base class
to create their own analyses and inject them into their project. See template NavProject for an example of use.
Represents a step in a chain of analyses that are run on a SpecEvent. These stages are where Parameters are set and validated. Users should use this base class
to create their own analyses and inject them into their project. See template SpecProject for an example of use.
GWM -- Feb 2022
*/

View File

@ -1,7 +1,7 @@
/*
AnalysisStage.h
Represents a step in a chain of analyses that are run on a NavEvent. These stages are where Parameters are set and validated. Users should use this base class
to create their own analyses and inject them into their project. See template NavProject for an example of use.
Represents a step in a chain of analyses that are run on a SpecEvent. These stages are where Parameters are set and validated. Users should use this base class
to create their own analyses and inject them into their project. See template SpecProject for an example of use.
GWM -- Feb 2022
*/

View File

@ -1,12 +1,14 @@
/*
PhysicsEventBuilder.h
Class for taking in raw NavData and converting into a NavEvent. NavEvent is just a std::vector of NavData, where
the held NavData all falls within a time window called the coincidence window. As soon as a NavData is given that falls outside
of this window, the current event is shifted to the ready event and the AddDatumToEvent function returns true. The ready event can
then be retrieved. The hit that triggered the end of event then is used to start the new event. The current pattern is strongly associated
with digital electronics concepts for nuclear data aquisition systems.
Class for taking in raw SpecData and converting into a SpecEvent. SpecEvent is just a std::vector of SpecData, where
the held SpecData all falls within a time window called the coincidence window. As soon as a SpecData is given that falls outside
of this window, the current event is shifted to the ready event vector. The ready event can then be retrieved. The hit that triggered the end of
event then is used to start the new event. The current pattern is strongly associated with digital electronics concepts
for nuclear data aquisition systems.
GWM -- Feb 2022
Added data time sorting, make event building model more compatible with different data sources. -- GWM April 2023
*/
#include "PhysicsEventBuilder.h"
@ -36,7 +38,7 @@ namespace Specter {
m_bufferIndex++;
if (m_bufferIndex < s_maxDataBuffer) //If we haven't filled the buffer keep going
return;
else if (m_sortFlag)
else if (m_sortFlag) //do time sorting if needed
std::sort(m_dataBuffer.begin(), m_dataBuffer.end(), [](SpecData& i, SpecData& j) { return i.timestamp < j.timestamp; });
//Generate our ready events
@ -58,7 +60,7 @@ namespace Specter {
event.push_back(data);
}
}
m_bufferIndex = 0;
m_bufferIndex = 0; //Reset the buffer without reallocating
}
std::vector<SpecEvent> PhysicsEventBuilder::GetReadyEvents() const

View File

@ -1,12 +1,14 @@
/*
PhysicsEventBuilder.h
Class for taking in raw NavData and converting into a NavEvent. NavEvent is just a std::vector of NavData, where
the held NavData all falls within a time window called the coincidence window. As soon as a NavData is given that falls outside
of this window, the current event is shifted to the ready event and the AddDatumToEvent function returns true. The ready event can
then be retrieved. The hit that triggered the end of event then is used to start the new event. The current pattern is strongly associated
with digital electronics concepts for nuclear data aquisition systems.
Class for taking in raw SpecData and converting into a SpecEvent. SpecEvent is just a std::vector of SpecData, where
the held SpecData all falls within a time window called the coincidence window. As soon as a SpecData is given that falls outside
of this window, the current event is shifted to the ready event vector. The ready event can then be retrieved. The hit that triggered the end of
event then is used to start the new event. The current pattern is strongly associated with digital electronics concepts
for nuclear data aquisition systems.
GWM -- Feb 2022
Added data time sorting, make event building model more compatible with different data sources. -- GWM April 2023
*/
#ifndef PHYSICS_EVENT_BUILDER_H
#define PHYSICS_EVENT_BUILDER_H

View File

@ -24,8 +24,8 @@ namespace Specter {
ShiftMap(const std::string& filename);
~ShiftMap();
void SetFile(const std::string& filename);
inline bool IsValid() { return m_validFlag; }
inline std::string GetFilename() { return m_filename; }
bool IsValid() { return m_validFlag; }
std::string GetFilename() { return m_filename; }
uint64_t GetShift(int gchan);
private:

View File

@ -16,9 +16,9 @@ namespace Specter {
class RenderCommand
{
public:
inline static void SetClearColor(const glm::vec4& color_array) { s_api->SetClearColor(color_array); }
inline static void Clear() { s_api->Clear(); }
inline static float GetFrameTime() { return s_api->GetFrameTime(); }
static void SetClearColor(const glm::vec4& color_array) { s_api->SetClearColor(color_array); }
static void Clear() { s_api->Clear(); }
static float GetFrameTime() { return s_api->GetFrameTime(); }
private:
static RendererAPI* s_api;

View File

@ -26,7 +26,7 @@ namespace Specter {
virtual void SetClearColor(const glm::vec4& color) = 0;
virtual float GetFrameTime() = 0;
inline static API GetAPI() { return s_api; }
static API GetAPI() { return s_api; }
private:
static API s_api;