parent
a125408410
commit
44bbbb03af
@ -51,14 +51,13 @@ namespace hex::plugin::builtin {
|
||||
auto dataPattern = arguments[0].toPattern();
|
||||
|
||||
if (ImPlot::BeginPlot("##plot", ImVec2(400, 250), ImPlotFlags_NoChild | ImPlotFlags_CanvasOnly)) {
|
||||
ImPlot::SetupAxes("X", "Y", ImPlotAxisFlags_AutoFit, ImPlotAxisFlags_AutoFit);
|
||||
|
||||
if (shouldReset) {
|
||||
values.clear();
|
||||
values = sampleData(patternToArray<float>(dataPattern), ImPlot::GetPlotSize().x * 4);
|
||||
}
|
||||
|
||||
ImPlot::SetupAxes("X", "Y", ImPlotAxisFlags_AutoFit, ImPlotAxisFlags_AutoFit);
|
||||
|
||||
ImPlot::PlotLine("##line", values.data(), values.size());
|
||||
|
||||
ImPlot::EndPlot();
|
||||
@ -72,6 +71,7 @@ namespace hex::plugin::builtin {
|
||||
auto yPattern = arguments[1].toPattern();
|
||||
|
||||
if (ImPlot::BeginPlot("##plot", ImVec2(400, 250), ImPlotFlags_NoChild | ImPlotFlags_CanvasOnly)) {
|
||||
ImPlot::SetupAxes("X", "Y", ImPlotAxisFlags_AutoFit, ImPlotAxisFlags_AutoFit);
|
||||
|
||||
if (shouldReset) {
|
||||
xValues.clear(); yValues.clear();
|
||||
@ -79,8 +79,6 @@ namespace hex::plugin::builtin {
|
||||
yValues = sampleData(patternToArray<float>(yPattern), ImPlot::GetPlotSize().x * 4);
|
||||
}
|
||||
|
||||
ImPlot::SetupAxes("X", "Y", ImPlotAxisFlags_AutoFit, ImPlotAxisFlags_AutoFit);
|
||||
|
||||
ImPlot::PlotScatter("##scatter", xValues.data(), yValues.data(), xValues.size());
|
||||
|
||||
ImPlot::EndPlot();
|
||||
|
@ -251,10 +251,17 @@ namespace hex::plugin::builtin::ui {
|
||||
if (const auto &arguments = pattern.getAttributeArguments("hex::visualize"); !arguments.empty()) {
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0, 0.5F));
|
||||
|
||||
bool shouldReset = false;
|
||||
if (ImGui::Button(hex::format("{} {}", ICON_VS_EYE_WATCH, value).c_str(), ImVec2(width, ImGui::GetTextLineHeight()))) {
|
||||
auto previousPattern = this->m_currVisualizedPattern;
|
||||
|
||||
this->m_currVisualizedPattern = &pattern;
|
||||
this->m_lastVisualizerError.clear();
|
||||
|
||||
if (this->m_currVisualizedPattern != previousPattern)
|
||||
shouldReset = true;
|
||||
|
||||
ImGui::OpenPopup("Visualizer");
|
||||
}
|
||||
ImGui::PopStyleVar(2);
|
||||
@ -263,7 +270,7 @@ namespace hex::plugin::builtin::ui {
|
||||
|
||||
if (ImGui::BeginPopup("Visualizer")) {
|
||||
if (this->m_currVisualizedPattern == &pattern) {
|
||||
drawVisualizer(arguments, pattern, dynamic_cast<pl::ptrn::IIterable&>(pattern), !this->m_visualizedPatterns.contains(&pattern));
|
||||
drawVisualizer(arguments, pattern, dynamic_cast<pl::ptrn::IIterable&>(pattern), !this->m_visualizedPatterns.contains(&pattern) || shouldReset);
|
||||
this->m_visualizedPatterns.insert(&pattern);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user