satdump/src-interface/viewer/radiation_handler.cpp

91 lines
2.9 KiB
C++
Raw Normal View History

2022-04-16 08:10:25 +02:00
#include "radiation_handler.h"
#include "core/config.h"
#include "resources.h"
namespace satdump
{
void RadiationViewerHandler::init()
{
products = (RadiationProducts *)ViewerHandler::products;
2022-05-12 18:19:01 +02:00
for (int c = 0; c < (int)products->channel_counts.size(); c++)
2022-04-16 08:10:25 +02:00
select_channel_image_str += "Channel " + std::to_string(c + 1) + '\0';
update();
}
void RadiationViewerHandler::update()
{
if (selected_visualization_id == 0)
{
2022-05-21 13:41:21 +02:00
RadiationMapCfg cfg;
cfg.channel = select_channel_image_id + 1;
cfg.radius = 5;
cfg.min = map_min;
cfg.max = map_max;
image::Image<uint16_t> map = make_radiation_map(*products, cfg);
2022-04-16 08:10:25 +02:00
image_view.update(map);
}
else if (selected_visualization_id == 1)
{
2022-09-09 22:12:42 +02:00
graph_values.clear();
2022-04-16 08:10:25 +02:00
graph_values.resize(products->channel_counts.size());
2022-05-12 18:19:01 +02:00
for (int c = 0; c < (int)products->channel_counts.size(); c++)
2022-04-16 08:10:25 +02:00
{
2022-05-12 18:19:01 +02:00
for (int i = 0; i < (int)products->channel_counts[c].size(); i++)
2022-04-16 08:10:25 +02:00
graph_values[c].push_back(products->channel_counts[c][i]);
}
}
}
void RadiationViewerHandler::drawMenu()
{
if (ImGui::CollapsingHeader("Vizualisation"))
{
2022-09-09 22:12:42 +02:00
if (ImGui::RadioButton("\uf84c Map", &selected_visualization_id, 0))
2022-04-16 08:10:25 +02:00
update();
2022-09-09 22:12:42 +02:00
if (ImGui::RadioButton("\uf437 Graph", &selected_visualization_id, 1))
2022-04-16 08:10:25 +02:00
update();
if (selected_visualization_id == 0)
{
if (ImGui::Combo("###mapchannelcomboid", &select_channel_image_id, select_channel_image_str.c_str()))
update();
2022-09-09 22:28:43 +02:00
ImGui::SetNextItemWidth(ImGui::GetWindowWidth()/2);
if (ImGui::DragInt("##Min", &map_min, 1.0f, 0, 255, "Min: %d", ImGuiSliderFlags_AlwaysClamp))
2022-09-09 22:12:42 +02:00
update();
2022-09-09 22:28:43 +02:00
ImGui::SameLine();
ImGui::SetNextItemWidth(ImGui::GetWindowWidth()/2);
if(ImGui::DragInt("##Max", &map_max, 1.0f, 0, 255, "Max: %d", ImGuiSliderFlags_AlwaysClamp))
2022-09-09 22:12:42 +02:00
update();
2022-04-16 08:10:25 +02:00
}
}
}
void RadiationViewerHandler::drawContents(ImVec2 win_size)
{
if (selected_visualization_id == 0)
{
image_view.draw(win_size);
}
else if (selected_visualization_id == 1)
{
ImGui::BeginChild("RadiationPlotChild");
2022-09-09 22:12:42 +02:00
for (int i = 0; i < (int)products->channel_counts.size(); i++){
2022-04-16 08:10:25 +02:00
ImGui::PlotLines(std::string("Channel " + std::to_string(i + 1)).c_str(), graph_values[i].data(), graph_values[i].size());
2022-09-09 22:12:42 +02:00
ImGui::Spacing();
ImGui::Separator();
ImGui::Spacing();
}
2022-04-16 08:10:25 +02:00
ImGui::EndChild();
}
}
float RadiationViewerHandler::drawTreeMenu()
{
return 0;
}
}