ux: Add slider to entropy plot
This commit is contained in:
parent
959988a670
commit
1e6b493b41
1
external/ImGui/include/imgui_memory_editor.h
vendored
1
external/ImGui/include/imgui_memory_editor.h
vendored
@ -717,7 +717,6 @@ struct MemoryEditor
|
||||
ImGui::EndChild();
|
||||
DataEditingAddr = DataPreviewAddr = HighlightMin;
|
||||
DataPreviewAddrEnd = HighlightMax;
|
||||
DataEditingTakeFocus = true;
|
||||
}
|
||||
GotoAddr = (size_t)-1;
|
||||
}
|
||||
|
@ -26,6 +26,8 @@ namespace hex {
|
||||
float m_highestBlockEntropy = 0;
|
||||
std::vector<float> m_blockEntropy;
|
||||
|
||||
double m_entropyHandlePosition;
|
||||
|
||||
std::array<ImU64, 256> m_valueCounts = { 0 };
|
||||
bool m_analyzing = false;
|
||||
|
||||
|
@ -30,10 +30,15 @@ namespace hex {
|
||||
this->m_fileDescription = "";
|
||||
this->m_analyzedRegion = { 0, 0 };
|
||||
});
|
||||
|
||||
EventManager::subscribe<EventRegionSelected>(this, [this](Region region) {
|
||||
this->m_entropyHandlePosition = region.address / this->m_blockSize;
|
||||
});
|
||||
}
|
||||
|
||||
ViewInformation::~ViewInformation() {
|
||||
EventManager::unsubscribe<EventDataChanged>(this);
|
||||
EventManager::unsubscribe<EventRegionSelected>(this);
|
||||
}
|
||||
|
||||
static float calculateEntropy(std::array<ImU64, 256> &valueCounts, size_t numBytes) {
|
||||
@ -196,7 +201,9 @@ namespace hex {
|
||||
return result;
|
||||
}();
|
||||
|
||||
|
||||
ImPlot::PlotBars<ImU64>("##bytes", x.data(), this->m_valueCounts.data(), x.size(), 0.67);
|
||||
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
|
||||
@ -208,8 +215,9 @@ namespace hex {
|
||||
if (ImPlot::BeginPlot("##entropy", "Address", "Entropy", ImVec2(-1,0), ImPlotFlags_CanvasOnly, ImPlotAxisFlags_Lock | ImPlotAxisFlags_NoTickLabels, ImPlotAxisFlags_Lock)) {
|
||||
ImPlot::PlotLine("##entropy_line", this->m_blockEntropy.data(), this->m_blockEntropy.size());
|
||||
|
||||
if (ImGui::IsItemClicked())
|
||||
EventManager::post<RequestSelectionChange>( Region{ u64(ImPlot::GetPlotMousePos().x) * this->m_blockSize, 1 });
|
||||
if (ImPlot::DragLineX("Position", &this->m_entropyHandlePosition, false)) {
|
||||
EventManager::post<RequestSelectionChange>( Region{ u64(this->m_entropyHandlePosition * this->m_blockSize), 1 });
|
||||
}
|
||||
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
@ -218,7 +226,7 @@ namespace hex {
|
||||
|
||||
ImGui::NewLine();
|
||||
|
||||
ImGui::LabelText("hex.view.information.block_size"_lang, "hex.view.information.block_size.desc"_lang, this->m_blockEntropy.size(), this->m_blockSize);
|
||||
ImGui::LabelText("hex.view.information.block_size"_lang, "%s", hex::format("hex.view.information.block_size.desc"_lang, this->m_blockEntropy.size(), this->m_blockSize).c_str());
|
||||
ImGui::LabelText("hex.view.information.file_entropy"_lang, "%.8f", this->m_averageEntropy);
|
||||
ImGui::LabelText("hex.view.information.highest_entropy"_lang, "%.8f", this->m_highestBlockEntropy);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user