2023-12-05 10:49:51 +01:00
|
|
|
#include <hex/helpers/utils.hpp>
|
|
|
|
|
2023-12-23 21:09:41 +01:00
|
|
|
#include <content/visualizer_helpers.hpp>
|
2023-12-05 10:49:51 +01:00
|
|
|
|
|
|
|
#include <implot.h>
|
|
|
|
#include <imgui.h>
|
|
|
|
|
|
|
|
#include <hex/ui/imgui_imhex_extensions.h>
|
|
|
|
|
2023-12-23 21:09:41 +01:00
|
|
|
namespace hex::plugin::visualizers {
|
2023-12-05 10:49:51 +01:00
|
|
|
|
2024-07-10 20:50:58 +02:00
|
|
|
void drawScatterPlotVisualizer(pl::ptrn::Pattern &, bool shouldReset, std::span<const pl::core::Token::Literal> arguments) {
|
2023-12-05 10:49:51 +01:00
|
|
|
static std::vector<float> xValues, yValues;
|
|
|
|
|
|
|
|
auto xPattern = arguments[0].toPattern();
|
|
|
|
auto yPattern = arguments[1].toPattern();
|
|
|
|
|
|
|
|
if (ImPlot::BeginPlot("##plot", ImVec2(400, 250), ImPlotFlags_CanvasOnly)) {
|
|
|
|
ImPlot::SetupAxes("X", "Y", ImPlotAxisFlags_AutoFit, ImPlotAxisFlags_AutoFit);
|
|
|
|
|
|
|
|
if (shouldReset) {
|
|
|
|
xValues.clear(); yValues.clear();
|
|
|
|
xValues = sampleData(patternToArray<float>(xPattern.get()), ImPlot::GetPlotSize().x * 4);
|
|
|
|
yValues = sampleData(patternToArray<float>(yPattern.get()), ImPlot::GetPlotSize().x * 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
ImPlot::PlotScatter("##scatter", xValues.data(), yValues.data(), xValues.size());
|
|
|
|
|
|
|
|
ImPlot::EndPlot();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|