2023-12-05 10:49:51 +01:00
|
|
|
#include <implot.h>
|
|
|
|
#include <imgui.h>
|
|
|
|
#include <content/helpers/diagrams.hpp>
|
|
|
|
|
|
|
|
#include <hex/ui/imgui_imhex_extensions.h>
|
|
|
|
|
2023-12-23 21:09:41 +01:00
|
|
|
#include <pl/patterns/pattern.hpp>
|
|
|
|
|
2023-12-05 10:49:51 +01:00
|
|
|
namespace hex::plugin::builtin {
|
|
|
|
|
2024-07-10 20:50:58 +02:00
|
|
|
void drawChunkBasedEntropyVisualizer(pl::ptrn::Pattern &, bool shouldReset, std::span<const pl::core::Token::Literal> arguments) {
|
2023-12-05 10:49:51 +01:00
|
|
|
// Variable used to store the result to avoid having to recalculate the result at each frame
|
|
|
|
static DiagramChunkBasedEntropyAnalysis analyzer;
|
|
|
|
|
|
|
|
// Compute data
|
|
|
|
if (shouldReset) {
|
|
|
|
auto pattern = arguments[0].toPattern();
|
|
|
|
auto chunkSize = arguments[1].toUnsigned();
|
|
|
|
analyzer.process(pattern->getBytes(), chunkSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Show results
|
|
|
|
analyzer.draw(ImVec2(400, 250), ImPlotFlags_CanvasOnly);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|