mirror of
https://github.com/gwm17/Specter.git
synced 2024-11-22 18:28:52 -05:00
Editor now in a semi-usable state, with spectrum panel, spectrum list, file dialog
This commit is contained in:
parent
74ae4818ab
commit
3e6a429bb9
|
@ -42,6 +42,13 @@ namespace Navigator {
|
|||
}
|
||||
}
|
||||
|
||||
void Application::SetParameterList()
|
||||
{
|
||||
m_parameterList = ParameterMap::GetInstance().GetListOfParameters();
|
||||
PhysicsParamEvent event;
|
||||
OnEvent(event);
|
||||
}
|
||||
|
||||
void Application::OnEvent(Event& event)
|
||||
{
|
||||
EventDispatcher dispatch(event);
|
||||
|
|
|
@ -26,11 +26,14 @@ namespace Navigator {
|
|||
void OnEvent(Event& event);
|
||||
void PushLayer(Layer* layer);
|
||||
void PushOverlay(Layer* layer);
|
||||
void SetParameterList();
|
||||
|
||||
inline void AttachHistogramMap() { PhysicsEventBuilder::Get().AttachHistogramMap(&m_histMap); }
|
||||
inline const std::vector<std::string>& GetParameterList() { return m_parameterList; } //Thread-safe way to access a list of the available parameters (i.e. for the editor)
|
||||
|
||||
inline static Application& Get() { return *s_instance; }
|
||||
inline static void LinkHistogramMap() { s_instance->AttachHistogramMap(); }
|
||||
inline static void LinkHistogramMap() { s_instance->AttachHistogramMap(); } //IMPORTANT: Only use BEFORE calling Run(). NO guarantee of thread safety.
|
||||
inline static void LinkParameterList() { s_instance->SetParameterList(); } //IMPORTANT: Only use BEFORE calling Run(). NO guarantee of thread safety.
|
||||
|
||||
inline Window& GetWindow() { return *m_window; }
|
||||
|
||||
|
@ -47,6 +50,7 @@ namespace Navigator {
|
|||
HistogramMap m_histMap;
|
||||
std::unique_ptr<Window> m_window;
|
||||
ImGuiLayer* m_imgui_layer;
|
||||
std::vector<std::string> m_parameterList;
|
||||
bool m_runFlag;
|
||||
|
||||
float m_bckgnd_color[4] = {0.1, 0.1, 0.1, 1.0};
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
#include "EditorLayer.h"
|
||||
#include "imgui.h"
|
||||
#include "implot.h"
|
||||
#include "FileDialog.h"
|
||||
#include "Navigator/Application.h"
|
||||
|
||||
namespace Navigator {
|
||||
|
||||
EditorLayer::EditorLayer(HistogramMap* hmap) :
|
||||
Layer("EditorLayer"), m_histMap(hmap)
|
||||
Layer("EditorLayer"), m_histMap(hmap), m_spectrumPanel(hmap)
|
||||
{
|
||||
zoomFlag = false;
|
||||
zoomed_gram = "";
|
||||
}
|
||||
|
||||
EditorLayer::~EditorLayer() {}
|
||||
|
@ -27,18 +27,20 @@ namespace Navigator {
|
|||
|
||||
void EditorLayer::OnEvent(Event& e)
|
||||
{
|
||||
EventDispatcher dispatch(e);
|
||||
dispatch.Dispatch<PhysicsParamEvent>(BIND_EVENT_FUNCTION(EditorLayer::OnPhysicsParamEvent));
|
||||
}
|
||||
|
||||
void EditorLayer::UpdateHistogramLists()
|
||||
{
|
||||
m_histoList = m_histMap->GetListOfHistogramParams();
|
||||
m_spectrumPanel.UpdateActiveList(m_histoList);
|
||||
}
|
||||
|
||||
void EditorLayer::OnImGuiRender()
|
||||
{
|
||||
static bool dockspaceOpen = true;
|
||||
static bool opt_fullscreen_persistant = true;
|
||||
bool opt_fullscreen = opt_fullscreen_persistant;
|
||||
static ImGuiDockNodeFlags dockspace_flags = ImGuiDockNodeFlags_None;
|
||||
|
||||
// We are using the ImGuiWindowFlags_NoDocking flag to make the parent window not dockable into,
|
||||
// because it would be confusing to have two docking targets within each others.
|
||||
ImGuiWindowFlags window_flags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking;
|
||||
if (opt_fullscreen)
|
||||
{
|
||||
ImGuiViewport* viewport = ImGui::GetMainViewport();
|
||||
|
@ -86,12 +88,14 @@ namespace Navigator {
|
|||
{
|
||||
if(ImGui::MenuItem("Open"))
|
||||
{
|
||||
m_fileDialog.SetOpenFileDialog(true);
|
||||
}
|
||||
if(ImGui::MenuItem("Exit"))
|
||||
{
|
||||
}
|
||||
if(ImGui::MenuItem("Save"))
|
||||
{
|
||||
m_fileDialog.SetSaveFileDialog(true);
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
@ -110,9 +114,6 @@ namespace Navigator {
|
|||
if (ImGui::MenuItem("Spectrum"))
|
||||
{
|
||||
}
|
||||
if (ImGui::MenuItem("Cut"))
|
||||
{
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if (ImGui::BeginMenu("Remove"))
|
||||
|
@ -128,89 +129,21 @@ namespace Navigator {
|
|||
ImGui::EndMenuBar();
|
||||
}
|
||||
|
||||
static std::vector<HistogramParameters> paramList = m_histMap->GetListOfHistogramParams();
|
||||
if (ImGui::Begin("Active View"))
|
||||
{
|
||||
if (paramList.size() > 0)
|
||||
{
|
||||
static std::vector<std::string> s_selectedGrams;
|
||||
static int sizes[2] = { 1,1 };
|
||||
static int total = 1;
|
||||
|
||||
if(zoomFlag && zoomed_gram != "")
|
||||
{
|
||||
if(ImPlot::BeginPlot(zoomed_gram.c_str(), ImVec2(-1,-1)))
|
||||
{
|
||||
m_histMap->DrawHistogram(zoomed_gram);
|
||||
if (ImPlot::IsPlotHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
|
||||
{
|
||||
NAV_INFO("We lost 'em, de-zoom and enhance!");
|
||||
zoomFlag = false;
|
||||
zoomed_gram = "";
|
||||
}
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::SliderInt2("Rows, Columns", sizes, 1, 3);
|
||||
total = sizes[0] * sizes[1];
|
||||
s_selectedGrams.resize(total);
|
||||
for (auto& gram : s_selectedGrams)
|
||||
gram = paramList[0].name;
|
||||
if (ImGui::BeginTable("Select Histograms", sizes[1]))
|
||||
{
|
||||
std::string label;
|
||||
int this_gram;
|
||||
for (int i = 0; i < sizes[0]; i++)
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
for (int j = 0; j < sizes[1]; j++)
|
||||
{
|
||||
ImGui::TableNextColumn();
|
||||
this_gram = i * sizes[1] + j;
|
||||
label = "Histogram" + std::to_string(this_gram);
|
||||
if (ImGui::BeginCombo(label.c_str(), paramList[0].name.c_str()))
|
||||
{
|
||||
for (auto& params : paramList)
|
||||
if (ImGui::Selectable(params.name.c_str(), params.name == s_selectedGrams[this_gram]))
|
||||
s_selectedGrams[this_gram] = params.name;
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::EndTable();
|
||||
}
|
||||
std::string open_file_result = m_fileDialog.ImGuiRenderOpenFile(".nav");
|
||||
std::string save_file_result = m_fileDialog.ImGuiRenderSaveFile(".nav");
|
||||
if (!open_file_result.empty())
|
||||
NAV_INFO("Found a Open File!");
|
||||
else if (!save_file_result.empty())
|
||||
NAV_INFO("Found a Save File!");
|
||||
|
||||
if (ImPlot::BeginSubplots("Histograms", sizes[0], sizes[1], ImVec2(-1, -1)))
|
||||
{
|
||||
int i = 0;
|
||||
for (auto& spec : s_selectedGrams)
|
||||
{
|
||||
if (ImPlot::BeginPlot(spec.c_str()))
|
||||
{
|
||||
m_histMap->DrawHistogram(spec);
|
||||
if (ImPlot::IsPlotHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
|
||||
{
|
||||
NAV_INFO("We got'em boys, they're in plot {0}. Zoom and enhance!", i);
|
||||
zoomFlag = true;
|
||||
zoomed_gram = spec;
|
||||
}
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
i++;
|
||||
}
|
||||
ImPlot::EndSubplots();
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
UpdateHistogramLists();
|
||||
m_spectrumPanel.OnImGuiRender();
|
||||
|
||||
if (ImGui::Begin("Spectra"))
|
||||
{
|
||||
for (auto& params : paramList)
|
||||
for (auto& params : m_histoList)
|
||||
{
|
||||
if (ImGui::TreeNode(params.name.c_str()))
|
||||
{
|
||||
|
@ -229,8 +162,12 @@ namespace Navigator {
|
|||
}
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool EditorLayer::OnPhysicsParamEvent(PhysicsParamEvent& event)
|
||||
{
|
||||
NAV_INFO("{0}", event.ToString());
|
||||
m_paramList = Application::Get().GetParameterList();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,10 @@
|
|||
|
||||
#include "Navigator/Layer.h"
|
||||
#include "Navigator/Events/Event.h"
|
||||
#include "Navigator/Events/PhysicsEvent.h"
|
||||
#include "Navigator/HistogramMap.h"
|
||||
#include "SpectrumPanel.h"
|
||||
#include "FileDialog.h"
|
||||
|
||||
namespace Navigator {
|
||||
|
||||
|
@ -19,12 +22,24 @@ namespace Navigator {
|
|||
virtual void OnUpdate() override;
|
||||
virtual void OnEvent(Event& event) override;
|
||||
|
||||
private:
|
||||
HistogramMap* m_histMap; //Not owned by the EditorLayer!!
|
||||
|
||||
//temp
|
||||
bool zoomFlag;
|
||||
std::string zoomed_gram;
|
||||
private:
|
||||
void UpdateHistogramLists();
|
||||
bool OnPhysicsParamEvent(PhysicsParamEvent& event);
|
||||
HistogramMap* m_histMap; //Not owned by the EditorLayer!!
|
||||
std::vector<HistogramParameters> m_histoList;
|
||||
std::vector<std::string> m_paramList;
|
||||
SpectrumPanel m_spectrumPanel;
|
||||
FileDialog m_fileDialog;
|
||||
|
||||
//ImGui Settings
|
||||
bool dockspaceOpen = true;
|
||||
bool opt_fullscreen = true;
|
||||
bool opt_fullscreen_persistant = true;
|
||||
ImGuiDockNodeFlags dockspace_flags = ImGuiDockNodeFlags_None;
|
||||
ImGuiWindowFlags window_flags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking;
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
243
Navigator/src/Navigator/Editor/FileDialog.cpp
Normal file
243
Navigator/src/Navigator/Editor/FileDialog.cpp
Normal file
|
@ -0,0 +1,243 @@
|
|||
#include "FileDialog.h"
|
||||
#include "misc/cpp/imgui_stdlib.cpp"
|
||||
|
||||
namespace Navigator {
|
||||
|
||||
std::string ConvertFileSystemSizeToString(std::uintmax_t value)
|
||||
{
|
||||
int i = 0;
|
||||
double mantissa = value;
|
||||
for (; mantissa >= 1024.0; ++i)
|
||||
mantissa /= 1024.0;
|
||||
mantissa = std::ceil(mantissa * 10.0) / 10.0;
|
||||
return std::to_string(int(mantissa)) + "BKMGTPE"[i];
|
||||
}
|
||||
|
||||
FileDialog::FileDialog() :
|
||||
m_currentPath(std::filesystem::current_path()), m_openFileName("Open File"), m_saveFileName("Save File"), m_openDirName("Open Directory"),
|
||||
m_selectedItem(""), m_openFileFlag(false), m_openDirFlag(false), m_saveFileFlag(false)
|
||||
{
|
||||
table_flags = ImGuiTableFlags_BordersH | ImGuiTableFlags_SizingStretchProp | ImGuiTableFlags_BordersOuterV | ImGuiTableFlags_RowBg;
|
||||
select_flags = ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_DontClosePopups;
|
||||
}
|
||||
|
||||
FileDialog::~FileDialog() {}
|
||||
|
||||
std::string FileDialog::ImGuiRenderOpenFile(const std::string& ext)
|
||||
{
|
||||
if (m_openFileFlag)
|
||||
{
|
||||
m_openFileFlag = false;
|
||||
m_selectedItem = "";
|
||||
m_currentPath = std::filesystem::current_path();
|
||||
ImGui::OpenPopup(m_openFileName.c_str());
|
||||
}
|
||||
std::string result = "";
|
||||
std::string text = "";
|
||||
if (ImGui::BeginPopupModal(m_openFileName.c_str()))
|
||||
{
|
||||
ImGui::Text("Current Directory: %s", m_currentPath.string().c_str());
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("Extension Filter: %s", ext.c_str());
|
||||
ImGui::InputText("Selected", &m_selectedItem);
|
||||
if (ImGui::Button("Ok"))
|
||||
{
|
||||
result = m_currentPath.string() + m_selectedItem;
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Cancel"))
|
||||
ImGui::CloseCurrentPopup();
|
||||
if (ImGui::BeginTable("File System", 2, table_flags, ImVec2(-1,-1)))
|
||||
{
|
||||
ImGui::TableSetupColumn("Name");
|
||||
ImGui::TableSetupColumn("Size");
|
||||
ImGui::TableHeadersRow();
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
if (ImGui::Selectable("[DIR] ..", false, select_flags))
|
||||
{
|
||||
m_selectedItem.clear();
|
||||
m_currentPath.append("..");
|
||||
m_currentPath = std::filesystem::absolute(m_currentPath);
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("N/A");
|
||||
for (auto& entry : std::filesystem::directory_iterator(m_currentPath))
|
||||
{
|
||||
if (entry.is_directory())
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
text = "[DIR] " + std::filesystem::relative(entry.path(), m_currentPath).string();
|
||||
ImGui::TableNextColumn();
|
||||
if (ImGui::Selectable(text.c_str(), false, select_flags))
|
||||
{
|
||||
m_selectedItem.clear();
|
||||
m_currentPath /= entry.path();
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("N/A");
|
||||
}
|
||||
else if(entry.path().filename().extension() == ext)
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
text = "[FILE] " + entry.path().filename().string();
|
||||
ImGui::TableNextColumn();
|
||||
if (ImGui::Selectable(text.c_str(), false, select_flags))
|
||||
m_selectedItem = entry.path().filename().string();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text(ConvertFileSystemSizeToString(entry.file_size()).c_str());
|
||||
}
|
||||
}
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string FileDialog::ImGuiRenderSaveFile(const std::string& ext)
|
||||
{
|
||||
if (m_saveFileFlag)
|
||||
{
|
||||
m_saveFileFlag = false;
|
||||
m_selectedItem = "";
|
||||
m_currentPath = std::filesystem::current_path();
|
||||
ImGui::OpenPopup(m_saveFileName.c_str());
|
||||
}
|
||||
std::string result = "";
|
||||
std::string text = "";
|
||||
if (ImGui::BeginPopupModal(m_saveFileName.c_str()))
|
||||
{
|
||||
ImGui::Text("Current Directory: %s", m_currentPath.string().c_str());
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("Extension Filter: %s", ext.c_str());
|
||||
ImGui::InputText("Selected", &m_selectedItem);
|
||||
if (ImGui::Button("Ok"))
|
||||
{
|
||||
result = m_currentPath.string() + m_selectedItem;
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Cancel"))
|
||||
ImGui::CloseCurrentPopup();
|
||||
if (ImGui::BeginTable("File System", 2, table_flags, ImVec2(-1, -1)))
|
||||
{
|
||||
ImGui::TableSetupColumn("Name");
|
||||
ImGui::TableSetupColumn("Size");
|
||||
ImGui::TableHeadersRow();
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
if (ImGui::Selectable("[DIR] ..", false, select_flags))
|
||||
{
|
||||
m_selectedItem.clear();
|
||||
m_currentPath.append("..");
|
||||
m_currentPath = std::filesystem::absolute(m_currentPath);
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("N/A");
|
||||
for (auto& entry : std::filesystem::directory_iterator(m_currentPath))
|
||||
{
|
||||
if (entry.is_directory())
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
text = "[DIR] " + std::filesystem::relative(entry.path(), m_currentPath).string();
|
||||
ImGui::TableNextColumn();
|
||||
if (ImGui::Selectable(text.c_str(), false, select_flags))
|
||||
{
|
||||
m_selectedItem.clear();
|
||||
m_currentPath /= entry.path();
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("N/A");
|
||||
}
|
||||
else if (entry.path().filename().extension() == ext)
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
text = "[FILE] " + entry.path().filename().string();
|
||||
ImGui::TableNextColumn();
|
||||
if (ImGui::Selectable(text.c_str(), false, select_flags))
|
||||
m_selectedItem = entry.path().filename().string();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text(ConvertFileSystemSizeToString(entry.file_size()).c_str());
|
||||
}
|
||||
}
|
||||
ImGui::EndTable();
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string FileDialog::ImGuiRenderOpenDir()
|
||||
{
|
||||
if (m_openDirFlag)
|
||||
{
|
||||
m_openDirFlag = false;
|
||||
m_currentPath = std::filesystem::current_path();
|
||||
m_selectedItem = m_currentPath.string();
|
||||
ImGui::OpenPopup(m_openDirName.c_str());
|
||||
}
|
||||
std::string result = "";
|
||||
std::string text = "";
|
||||
if (ImGui::BeginPopupModal(m_openDirName.c_str()))
|
||||
{
|
||||
ImGui::Text("Current Directory: %s", m_currentPath.string().c_str());
|
||||
ImGui::InputText("Selected", &m_selectedItem);
|
||||
if (ImGui::Button("Ok"))
|
||||
{
|
||||
result = m_selectedItem;
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Cancel"))
|
||||
ImGui::CloseCurrentPopup();
|
||||
if (ImGui::BeginTable("File System", 2, table_flags, ImVec2(-1, -1)))
|
||||
{
|
||||
ImGui::TableSetupColumn("Name");
|
||||
ImGui::TableSetupColumn("Size");
|
||||
ImGui::TableHeadersRow();
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
if (ImGui::Selectable("[DIR] ..", false, select_flags))
|
||||
{
|
||||
m_currentPath.append("..");
|
||||
m_currentPath = std::filesystem::absolute(m_currentPath);
|
||||
m_selectedItem = m_currentPath.string();
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("N/A");
|
||||
for (auto& entry : std::filesystem::directory_iterator(m_currentPath))
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
if (entry.is_directory())
|
||||
{
|
||||
text = "[DIR] " + std::filesystem::relative(entry.path(), m_currentPath).string();
|
||||
ImGui::TableNextColumn();
|
||||
if (ImGui::Selectable(text.c_str(), false, select_flags))
|
||||
{
|
||||
m_currentPath /= entry.path();
|
||||
m_selectedItem = m_currentPath.string();
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("N/A");
|
||||
}
|
||||
else
|
||||
{
|
||||
text = "[FILE] " + entry.path().filename().string();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text(text.c_str());
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text(ConvertFileSystemSizeToString(entry.file_size()).c_str());
|
||||
}
|
||||
}
|
||||
ImGui::EndTable();
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
51
Navigator/src/Navigator/Editor/FileDialog.h
Normal file
51
Navigator/src/Navigator/Editor/FileDialog.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
#ifndef FILE_DIALOG_H
|
||||
#define FILE_DIALOG_H
|
||||
|
||||
#include <filesystem>
|
||||
#include "imgui.h"
|
||||
|
||||
namespace Navigator {
|
||||
|
||||
class NAV_API FileDialog
|
||||
{
|
||||
public:
|
||||
FileDialog();
|
||||
~FileDialog();
|
||||
|
||||
std::string ImGuiRenderOpenFile(const std::string& ext);
|
||||
std::string ImGuiRenderSaveFile(const std::string& ext);
|
||||
std::string ImGuiRenderOpenDir();
|
||||
|
||||
inline void ResetCurrentDirectory() { m_currentPath = std::filesystem::current_path(); }
|
||||
|
||||
inline void SetOpenFileDialog(bool value) { m_openFileFlag = value; }
|
||||
inline void SetSaveFileDialog(bool value) { m_saveFileFlag = value; }
|
||||
inline void SetOpenDirDialog(bool value) { m_openDirFlag = value; }
|
||||
|
||||
inline bool IsOpenFileOpen() { return m_openFileFlag; }
|
||||
inline bool IsOpenDirOpen() { return m_openDirFlag; }
|
||||
inline bool IsSaveFileOpen() { return m_saveFileFlag; }
|
||||
|
||||
inline const std::string& GetOpenFileWindowName() { return m_openFileName; }
|
||||
inline const std::string& GetSaveFileWindowName() { return m_saveFileName; }
|
||||
inline const std::string& GetOpenDirWindowName() { return m_openDirName; }
|
||||
|
||||
private:
|
||||
std::filesystem::path m_currentPath;
|
||||
std::string m_openFileName;
|
||||
std::string m_saveFileName;
|
||||
std::string m_openDirName;
|
||||
|
||||
std::string m_selectedItem;
|
||||
|
||||
bool m_openFileFlag;
|
||||
bool m_saveFileFlag;
|
||||
bool m_openDirFlag;
|
||||
|
||||
ImGuiTableFlags table_flags;
|
||||
ImGuiSelectableFlags select_flags;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
90
Navigator/src/Navigator/Editor/SpectrumPanel.cpp
Normal file
90
Navigator/src/Navigator/Editor/SpectrumPanel.cpp
Normal file
|
@ -0,0 +1,90 @@
|
|||
#include "SpectrumPanel.h"
|
||||
#include "implot.h"
|
||||
|
||||
namespace Navigator {
|
||||
|
||||
SpectrumPanel::SpectrumPanel(HistogramMap* map) :
|
||||
m_histMap(map), m_zoomedFlag(false), m_zoomedGram(""), m_totalSlots(1)
|
||||
{
|
||||
m_tableSizes[0] = 1; m_tableSizes[1] = 1;
|
||||
}
|
||||
|
||||
SpectrumPanel::~SpectrumPanel() {}
|
||||
|
||||
void SpectrumPanel::OnImGuiRender()
|
||||
{
|
||||
if (ImGui::Begin("Active View"))
|
||||
{
|
||||
if (m_activeList.size() > 0)
|
||||
{
|
||||
if (m_zoomedFlag && m_zoomedGram != "")
|
||||
{
|
||||
if (ImPlot::BeginPlot(m_zoomedGram.c_str(), ImVec2(-1, -1)))
|
||||
{
|
||||
m_histMap->DrawHistogram(m_zoomedGram);
|
||||
if (ImPlot::IsPlotHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
|
||||
{
|
||||
NAV_INFO("We lost 'em, de-zoom and enhance!");
|
||||
m_zoomedFlag = false;
|
||||
m_zoomedGram = "";
|
||||
}
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::SliderInt2("Rows, Columns", m_tableSizes, 1, 3);
|
||||
m_totalSlots = m_tableSizes[0] * m_tableSizes[1];
|
||||
m_selectedGrams.resize(m_totalSlots);
|
||||
for (auto& gram : m_selectedGrams)
|
||||
gram = m_activeList[0].name;
|
||||
if (ImGui::BeginTable("Select Histograms", m_tableSizes[1]))
|
||||
{
|
||||
std::string label;
|
||||
int this_gram;
|
||||
for (int i = 0; i < m_tableSizes[0]; i++)
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
for (int j = 0; j < m_tableSizes[1]; j++)
|
||||
{
|
||||
ImGui::TableNextColumn();
|
||||
this_gram = i * m_tableSizes[1] + j;
|
||||
label = "Histogram" + std::to_string(this_gram);
|
||||
if (ImGui::BeginCombo(label.c_str(), m_activeList[0].name.c_str()))
|
||||
{
|
||||
for (auto& params : m_activeList)
|
||||
if (ImGui::Selectable(params.name.c_str(), params.name == m_selectedGrams[this_gram]))
|
||||
m_selectedGrams[this_gram] = params.name;
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::EndTable();
|
||||
}
|
||||
|
||||
if (ImPlot::BeginSubplots("Histograms", m_tableSizes[0], m_tableSizes[1], ImVec2(-1, -1)))
|
||||
{
|
||||
int i = 0;
|
||||
for (auto& spec : m_selectedGrams)
|
||||
{
|
||||
if (ImPlot::BeginPlot(spec.c_str()))
|
||||
{
|
||||
m_histMap->DrawHistogram(spec);
|
||||
if (ImPlot::IsPlotHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
|
||||
{
|
||||
NAV_INFO("We got'em boys, they're in plot {0}. Zoom and enhance!", i);
|
||||
m_zoomedFlag = true;
|
||||
m_zoomedGram = spec;
|
||||
}
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
i++;
|
||||
}
|
||||
ImPlot::EndSubplots();
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
||||
}
|
33
Navigator/src/Navigator/Editor/SpectrumPanel.h
Normal file
33
Navigator/src/Navigator/Editor/SpectrumPanel.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
#ifndef SPECTRUM_PANEL_H
|
||||
#define SPECTRUM_PANEL_H
|
||||
|
||||
#include "Navigator/HistogramMap.h"
|
||||
#include "imgui.h"
|
||||
|
||||
namespace Navigator {
|
||||
|
||||
class NAV_API SpectrumPanel
|
||||
{
|
||||
public:
|
||||
SpectrumPanel(HistogramMap* map);
|
||||
~SpectrumPanel();
|
||||
|
||||
inline void AttachHistogramMap(HistogramMap* map) { m_histMap = map; }
|
||||
void OnImGuiRender();
|
||||
inline const std::string& GetZoomedOnHistogram() { return m_zoomedGram; }
|
||||
inline const bool IsZoomed() { return m_zoomedFlag; }
|
||||
inline void UpdateActiveList(const std::vector<HistogramParameters>& list) { m_activeList = list; }
|
||||
|
||||
private:
|
||||
HistogramMap* m_histMap; //Not owned by SpectrumPanel
|
||||
std::vector<HistogramParameters> m_activeList; //This is where we get our info from. Reduces thread crossings
|
||||
std::vector<std::string> m_selectedGrams;
|
||||
bool m_zoomedFlag;
|
||||
std::string m_zoomedGram;
|
||||
int m_tableSizes[2];
|
||||
int m_totalSlots;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -12,7 +12,7 @@ namespace Navigator {
|
|||
KeyPressed, KeyReleased, KeyTyped,
|
||||
MouseButtonPressed, MouseButtonReleased, MouseScrolled, MouseMoved,
|
||||
AppUpdate,
|
||||
PhysicsStart, PhysicsStop
|
||||
PhysicsStart, PhysicsStop, PhysicsParam
|
||||
};
|
||||
|
||||
enum NAV_API EventCategory
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Navigator {
|
|||
{
|
||||
public:
|
||||
PhysicsStartEvent(const std::string& loc, DataSource::SourceType type, uint64_t window) :
|
||||
m_sourceLocation(loc), m_sourceType(type)
|
||||
m_sourceLocation(loc), m_sourceType(type), m_coincidenceWindow(window)
|
||||
{}
|
||||
|
||||
inline std::string GetSourceLocation() { return m_sourceLocation; }
|
||||
|
@ -46,6 +46,19 @@ namespace Navigator {
|
|||
EVENT_TYPE_SETUP(PhysicsStop);
|
||||
};
|
||||
|
||||
class NAV_API PhysicsParamEvent : public Event
|
||||
{
|
||||
public:
|
||||
PhysicsParamEvent() {}
|
||||
|
||||
std::string ToString() const override
|
||||
{
|
||||
return "Updating Parameter lists!";
|
||||
}
|
||||
|
||||
EVENT_CATEGORY_SETUP(EventCategoryPhysics);
|
||||
EVENT_TYPE_SETUP(PhysicsParam);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -69,4 +69,16 @@ namespace Navigator {
|
|||
iter.second->value = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> ParameterMap::GetListOfParameters()
|
||||
{
|
||||
std::vector<std::string> list;
|
||||
list.reserve(m_map.size());
|
||||
for (auto iter : m_map)
|
||||
{
|
||||
list.push_back(iter.first);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ namespace Navigator {
|
|||
double GetParameterValue(const std::string& name);
|
||||
bool IsParameterValid(const std::string& name);
|
||||
void InvalidateParameters();
|
||||
std::vector<std::string> GetListOfParameters(); //Dangerous! Should only be used when GUARANTEED no phys thread is running.
|
||||
inline Iter end() { return m_map.end(); }
|
||||
inline Iter begin() { return m_map.begin(); }
|
||||
inline Iter find(const std::string& name) { return m_map.find(name); }
|
||||
|
|
Loading…
Reference in New Issue
Block a user