mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-30 05:05:19 -05:00
impr: Vastly improved 3D Visualizer (#1456)
Based entirely on @paxcut's amazing PR #1443 --------- Co-authored-by: paxcut <paxcut@outlook.com> Co-authored-by: paxcut <53811119+paxcut@users.noreply.github.com>
This commit is contained in:
30
plugins/builtin/source/content/pl_visualizers/line_plot.cpp
Normal file
30
plugins/builtin/source/content/pl_visualizers/line_plot.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <hex/helpers/utils.hpp>
|
||||
|
||||
#include <content/pl_visualizers/visualizer_helpers.hpp>
|
||||
|
||||
#include <implot.h>
|
||||
#include <imgui.h>
|
||||
|
||||
#include <hex/ui/imgui_imhex_extensions.h>
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
void drawLinePlotVisualizer(pl::ptrn::Pattern &, pl::ptrn::IIterable &, bool shouldReset, std::span<const pl::core::Token::Literal> arguments) {
|
||||
static std::vector<float> values;
|
||||
auto dataPattern = arguments[0].toPattern();
|
||||
|
||||
if (ImPlot::BeginPlot("##plot", ImVec2(400, 250), ImPlotFlags_CanvasOnly)) {
|
||||
ImPlot::SetupAxes("X", "Y", ImPlotAxisFlags_AutoFit, ImPlotAxisFlags_AutoFit);
|
||||
|
||||
if (shouldReset) {
|
||||
values.clear();
|
||||
values = sampleData(patternToArray<float>(dataPattern.get()), ImPlot::GetPlotSize().x * 4);
|
||||
}
|
||||
|
||||
ImPlot::PlotLine("##line", values.data(), values.size());
|
||||
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user