1
0
Fork 0
mirror of https://github.com/gwm17/Specter.git synced 2024-11-22 18:28:52 -05:00

Added in feature to zoom in on a specific plot with double click

This commit is contained in:
Gordon McCann 2022-01-13 17:29:43 -05:00
parent f91a3dce69
commit 74ae4818ab
2 changed files with 63 additions and 37 deletions

View File

@ -7,6 +7,8 @@ namespace Navigator {
EditorLayer::EditorLayer(HistogramMap* hmap) :
Layer("EditorLayer"), m_histMap(hmap)
{
zoomFlag = false;
zoomed_gram = "";
}
EditorLayer::~EditorLayer() {}
@ -135,6 +137,22 @@ namespace Navigator {
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);
@ -173,14 +191,18 @@ namespace Navigator {
{
m_histMap->DrawHistogram(spec);
if (ImPlot::IsPlotHovered() && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left))
NAV_INFO("We got'em boys, they're in plot {0}", i);
{
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();
}
@ -193,11 +215,11 @@ namespace Navigator {
if (ImGui::TreeNode(params.name.c_str()))
{
ImGui::BulletText("X Parameter: %s", params.x_par.c_str());
ImGui::BulletText("X Bins: %d X Min: %d X Max: %d", params.nbins_x, params.min_x, params.max_x);
ImGui::BulletText("X Bins: %d X Min: %f X Max: %f", params.nbins_x, params.min_x, params.max_x);
if (params.y_par != "None")
{
ImGui::BulletText("Y Parameter: %s", params.y_par.c_str());
ImGui::BulletText("Y Bins: %d Y Min: %d Y Max: %d", params.nbins_y, params.min_y, params.max_y);
ImGui::BulletText("Y Bins: %d Y Min: %f Y Max: %f", params.nbins_y, params.min_y, params.max_y);
}
ImGui::TreePop();

View File

@ -21,6 +21,10 @@ namespace Navigator {
private:
HistogramMap* m_histMap; //Not owned by the EditorLayer!!
//temp
bool zoomFlag;
std::string zoomed_gram;
};
}