mirror of
https://github.com/gwm17/Specter.git
synced 2025-04-18 05:48:52 -04:00
Fixed janky summary spectrum dialog. Now better displays params and allows for multiple selections at once
This commit is contained in:
parent
deea375007
commit
c325e29b73
|
@ -17,7 +17,12 @@
|
||||||
#include "IconsFontAwesome5.h"
|
#include "IconsFontAwesome5.h"
|
||||||
|
|
||||||
namespace Navigator {
|
namespace Navigator {
|
||||||
|
|
||||||
|
bool SortByString(const std::string& p1, const std::string& p2)
|
||||||
|
{
|
||||||
|
return p1 < p2;
|
||||||
|
}
|
||||||
|
|
||||||
EditorLayer::EditorLayer() :
|
EditorLayer::EditorLayer() :
|
||||||
Layer("EditorLayer"), m_removeHistogram(false), m_removeCut(false), m_exportHistogram(false)
|
Layer("EditorLayer"), m_removeHistogram(false), m_removeCut(false), m_exportHistogram(false)
|
||||||
{
|
{
|
||||||
|
@ -45,16 +50,19 @@ namespace Navigator {
|
||||||
void EditorLayer::UpdateHistogramList()
|
void EditorLayer::UpdateHistogramList()
|
||||||
{
|
{
|
||||||
m_histoList = SpectrumManager::GetInstance().GetListOfHistograms();
|
m_histoList = SpectrumManager::GetInstance().GetListOfHistograms();
|
||||||
|
std::sort(m_histoList.begin(), m_histoList.end(), SortByName<HistogramParameters>);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorLayer::UpdateCutList()
|
void EditorLayer::UpdateCutList()
|
||||||
{
|
{
|
||||||
m_cutList = SpectrumManager::GetInstance().GetListOfCuts();
|
m_cutList = SpectrumManager::GetInstance().GetListOfCuts();
|
||||||
|
std::sort(m_cutList.begin(), m_cutList.end(), SortByName<CutParams>);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorLayer::UpdateParameterList()
|
void EditorLayer::UpdateParameterList()
|
||||||
{
|
{
|
||||||
m_paramList = SpectrumManager::GetInstance().GetListOfParameters();
|
m_paramList = SpectrumManager::GetInstance().GetListOfParameters();
|
||||||
|
std::sort(m_paramList.begin(), m_paramList.end(), SortByString);
|
||||||
}
|
}
|
||||||
|
|
||||||
//The main function
|
//The main function
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace Navigator {
|
||||||
virtual void OnUpdate() override;
|
virtual void OnUpdate() override;
|
||||||
virtual void OnEvent(Event& event) override;
|
virtual void OnEvent(Event& event) override;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void RemoveCutDialog();
|
void RemoveCutDialog();
|
||||||
void RemoveHistogramDialog();
|
void RemoveHistogramDialog();
|
||||||
|
@ -70,6 +70,12 @@ namespace Navigator {
|
||||||
bool m_exportHistogram;
|
bool m_exportHistogram;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
bool SortByName(const T& p1, const T& p2)
|
||||||
|
{
|
||||||
|
return p1.name < p2.name;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -17,6 +17,7 @@ namespace Navigator {
|
||||||
m_openFlag(false), m_openCutFlag(false)
|
m_openFlag(false), m_openCutFlag(false)
|
||||||
{
|
{
|
||||||
selectFlags = ImGuiSelectableFlags_DontClosePopups;
|
selectFlags = ImGuiSelectableFlags_DontClosePopups;
|
||||||
|
tableFlags = ImGuiTableFlags_BordersH | ImGuiTableFlags_SizingStretchProp | ImGuiTableFlags_BordersOuterV | ImGuiTableFlags_RowBg;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpectrumDialog::~SpectrumDialog()
|
SpectrumDialog::~SpectrumDialog()
|
||||||
|
@ -171,7 +172,6 @@ namespace Navigator {
|
||||||
|
|
||||||
void SpectrumDialog::RenderDialogSummary(const std::vector<std::string>& paramList)
|
void SpectrumDialog::RenderDialogSummary(const std::vector<std::string>& paramList)
|
||||||
{
|
{
|
||||||
static std::string selectedParam = "";
|
|
||||||
if (ImGui::BeginTable("SpecParamsTable", 3))
|
if (ImGui::BeginTable("SpecParamsTable", 3))
|
||||||
{
|
{
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
|
@ -193,30 +193,55 @@ namespace Navigator {
|
||||||
}
|
}
|
||||||
if (ImGui::Button("Add Parameter"))
|
if (ImGui::Button("Add Parameter"))
|
||||||
{
|
{
|
||||||
selectedParam = "";
|
m_subhistos.clear();
|
||||||
ImGui::OpenPopup("Param List");
|
ImGui::OpenPopup("Param List");
|
||||||
}
|
}
|
||||||
if (ImGui::BeginPopup("Param List"))
|
if (ImGui::BeginPopupModal("Param List"))
|
||||||
{
|
{
|
||||||
if (ImGui::BeginCombo("Parameter", selectedParam.c_str()))
|
|
||||||
{
|
|
||||||
for (auto& param : paramList)
|
|
||||||
{
|
|
||||||
if (ImGui::Selectable(param.c_str(), param == selectedParam, selectFlags))
|
|
||||||
selectedParam = param;
|
|
||||||
}
|
|
||||||
ImGui::EndCombo();
|
|
||||||
}
|
|
||||||
if (ImGui::Button("Ok"))
|
if (ImGui::Button("Ok"))
|
||||||
{
|
{
|
||||||
m_subhistos.push_back(selectedParam);
|
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::Button("Cancel"))
|
if (ImGui::Button("Cancel"))
|
||||||
{
|
{
|
||||||
|
m_subhistos.clear();
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto check_func = [this](const std::string& name)
|
||||||
|
{
|
||||||
|
for (auto& par : m_subhistos)
|
||||||
|
{
|
||||||
|
if (name == par)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (ImGui::BeginTable("Parameters", 1, tableFlags, ImVec2(-1, -1)))
|
||||||
|
{
|
||||||
|
for (auto& param : paramList)
|
||||||
|
{
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
if (ImGui::Selectable(param.c_str(), check_func(param), selectFlags))
|
||||||
|
{
|
||||||
|
if (!check_func(param))
|
||||||
|
{
|
||||||
|
m_subhistos.push_back(param);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto iter = std::remove(m_subhistos.begin(), m_subhistos.end(), param);
|
||||||
|
m_subhistos.erase(iter, m_subhistos.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndTable();
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ namespace Navigator {
|
||||||
std::vector<std::string> m_subhistos;
|
std::vector<std::string> m_subhistos;
|
||||||
|
|
||||||
ImGuiSelectableFlags selectFlags;
|
ImGuiSelectableFlags selectFlags;
|
||||||
|
ImGuiTableFlags tableFlags;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user