2024-12-29 20:13:58 +01:00
|
|
|
#include "viewer.h"
|
|
|
|
|
// #include "image_handler.h"
|
|
|
|
|
// #include "radiation_handler.h"
|
|
|
|
|
// #include "scatterometer_handler.h"
|
2024-12-31 17:01:12 +01:00
|
|
|
// #include "core/config.h"
|
|
|
|
|
// #include "products/dataset.h"
|
2024-12-29 20:13:58 +01:00
|
|
|
#include "common/utils.h"
|
2024-12-31 17:01:12 +01:00
|
|
|
// #include "resources.h"
|
2024-12-29 20:13:58 +01:00
|
|
|
#include "main_ui.h"
|
|
|
|
|
|
2025-01-01 05:57:58 +01:00
|
|
|
#include "handler/dummy_handler.h"
|
|
|
|
|
#include "handler/product/image_product_handler.h" // TODO CLEAN
|
|
|
|
|
#include "handler/dataset/dataset_handler.h"
|
2024-12-29 20:13:58 +01:00
|
|
|
|
|
|
|
|
namespace satdump
|
|
|
|
|
{
|
2024-12-31 17:01:12 +01:00
|
|
|
namespace viewer
|
2024-12-29 20:13:58 +01:00
|
|
|
{
|
2024-12-31 17:01:12 +01:00
|
|
|
ViewerApplication::ViewerApplication()
|
|
|
|
|
: Application("viewer")
|
2024-12-29 20:13:58 +01:00
|
|
|
{
|
2025-01-02 17:04:32 +01:00
|
|
|
master_handler = std::make_shared<DummyHandler>("MasterHandlerViewer");
|
2024-12-31 17:01:12 +01:00
|
|
|
}
|
2024-12-29 20:13:58 +01:00
|
|
|
|
2024-12-31 17:01:12 +01:00
|
|
|
ViewerApplication::~ViewerApplication()
|
2024-12-29 20:13:58 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-31 17:01:12 +01:00
|
|
|
void ViewerApplication::drawPanel()
|
2024-12-29 20:13:58 +01:00
|
|
|
{
|
2024-12-31 17:01:12 +01:00
|
|
|
ImGui::SetNextItemWidth(ImGui::GetWindowWidth() / 2);
|
2024-12-29 20:13:58 +01:00
|
|
|
|
2024-12-31 17:01:12 +01:00
|
|
|
if (ImGui::CollapsingHeader("General", ImGuiTreeNodeFlags_DefaultOpen))
|
2024-12-29 20:13:58 +01:00
|
|
|
{
|
2024-12-31 17:01:12 +01:00
|
|
|
if (ImGui::BeginTable("##masterhandlertable", 1, ImGuiTableFlags_RowBg | ImGuiTableFlags_Borders))
|
|
|
|
|
{
|
|
|
|
|
ImGui::TableSetupColumn("##masterhandlertable_col", ImGuiTableColumnFlags_None);
|
|
|
|
|
ImGui::TableNextColumn();
|
2024-12-29 20:13:58 +01:00
|
|
|
|
2024-12-31 17:01:12 +01:00
|
|
|
master_handler->drawTreeMenu(curr_handler);
|
2024-12-29 20:13:58 +01:00
|
|
|
|
2024-12-31 17:01:12 +01:00
|
|
|
ImGui::EndTable();
|
|
|
|
|
}
|
2024-12-29 20:13:58 +01:00
|
|
|
|
2025-01-02 17:04:32 +01:00
|
|
|
if (curr_handler)
|
|
|
|
|
curr_handler->drawMenu();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ViewerApplication::drawMenuBar()
|
|
|
|
|
{
|
|
|
|
|
if (ImGui::BeginMenuBar())
|
|
|
|
|
{
|
|
|
|
|
if (ImGui::BeginMenu("File"))
|
2025-01-01 05:57:58 +01:00
|
|
|
{
|
2025-01-02 17:04:32 +01:00
|
|
|
ImGui::MenuItem("Open Dataset");
|
|
|
|
|
ImGui::MenuItem("Open Product");
|
|
|
|
|
ImGui::MenuItem("Open Image");
|
|
|
|
|
|
|
|
|
|
if (ImGui::BeginMenu("Hardcoded"))
|
2025-01-01 05:57:58 +01:00
|
|
|
{
|
2025-01-02 17:04:32 +01:00
|
|
|
if (ImGui::MenuItem("Load KMSS"))
|
|
|
|
|
{
|
|
|
|
|
std::shared_ptr<ProductHandler> prod_h = std::make_shared<ImageProductHandler>(products::loadProduct("/home/alan/Downloads/SatDump_NEWPRODS/KMSS_24/KMSS_MSU100_1/product.cbor"));
|
|
|
|
|
master_handler->addSubHandler(prod_h);
|
|
|
|
|
}
|
|
|
|
|
if (ImGui::MenuItem("Load Sterna"))
|
|
|
|
|
{
|
|
|
|
|
std::shared_ptr<ProductHandler> prod_h = std::make_shared<ImageProductHandler>(products::loadProduct("/home/alan/Downloads/SatDump_NEWPRODS/aws_pfm_cadu/STERNA_Dump/product.cbor"));
|
|
|
|
|
master_handler->addSubHandler(prod_h);
|
|
|
|
|
}
|
|
|
|
|
if (ImGui::MenuItem("Dataset"))
|
|
|
|
|
{
|
|
|
|
|
std::shared_ptr<DatasetHandler> dat_h = std::make_shared<DatasetHandler>();
|
|
|
|
|
{
|
|
|
|
|
std::shared_ptr<ProductHandler> prod_h = std::make_shared<ImageProductHandler>(products::loadProduct("/home/alan/Downloads/SatDump_NEWPRODS/KMSS_24/KMSS_MSU100_1/product.cbor"));
|
|
|
|
|
dat_h->instrument_products->addSubHandler(prod_h);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
std::shared_ptr<ProductHandler> prod_h = std::make_shared<ImageProductHandler>(products::loadProduct("/home/alan/Downloads/SatDump_NEWPRODS/KMSS_24/KMSS_MSU100_2/product.cbor"));
|
|
|
|
|
dat_h->instrument_products->addSubHandler(prod_h);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
std::shared_ptr<ProductHandler> prod_h = std::make_shared<ImageProductHandler>(products::loadProduct("/home/alan/Downloads/SatDump_NEWPRODS/aws_pfm_cadu/STERNA_Dump/product.cbor"));
|
|
|
|
|
dat_h->instrument_products->addSubHandler(prod_h);
|
|
|
|
|
}
|
|
|
|
|
master_handler->addSubHandler(dat_h);
|
|
|
|
|
}
|
|
|
|
|
if (ImGui::MenuItem("Load MSUGS"))
|
|
|
|
|
{
|
|
|
|
|
std::shared_ptr<ProductHandler> prod_h = std::make_shared<ImageProductHandler>(products::loadProduct("/home/alan/Downloads/20241231_132953_ARKTIKA-M 2_dat/MSUGS_VIS1/product.cbor"));
|
|
|
|
|
master_handler->addSubHandler(prod_h);
|
|
|
|
|
}
|
|
|
|
|
if (ImGui::MenuItem("Load MSUGS 2"))
|
|
|
|
|
{
|
|
|
|
|
std::shared_ptr<ProductHandler> prod_h = std::make_shared<ImageProductHandler>(products::loadProduct("/home/alan/Downloads/20241231_154404_ARKTIKA-M 2_dat/MSUGS_VIS1/product.cbor"));
|
|
|
|
|
master_handler->addSubHandler(prod_h);
|
|
|
|
|
}
|
|
|
|
|
ImGui::EndMenu();
|
2025-01-01 05:57:58 +01:00
|
|
|
}
|
2025-01-02 17:04:32 +01:00
|
|
|
|
|
|
|
|
ImGui::EndMenu();
|
|
|
|
|
}
|
|
|
|
|
if (ImGui::BeginMenu("Handler"))
|
|
|
|
|
{
|
|
|
|
|
if (ImGui::BeginMenu("Add"))
|
2025-01-01 05:57:58 +01:00
|
|
|
{
|
2025-01-02 17:04:32 +01:00
|
|
|
ImGui::MenuItem("Dataset");
|
|
|
|
|
ImGui::MenuItem("Projection");
|
|
|
|
|
ImGui::EndMenu();
|
2025-01-01 05:57:58 +01:00
|
|
|
}
|
2025-01-02 17:04:32 +01:00
|
|
|
ImGui::EndMenu();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (curr_handler)
|
|
|
|
|
{
|
|
|
|
|
if (ImGui::BeginMenu("Current"))
|
2025-01-01 05:57:58 +01:00
|
|
|
{
|
2025-01-02 17:04:32 +01:00
|
|
|
curr_handler->drawMenuBar();
|
|
|
|
|
ImGui::EndMenu();
|
2025-01-01 05:57:58 +01:00
|
|
|
}
|
|
|
|
|
}
|
2024-12-29 20:13:58 +01:00
|
|
|
|
2025-01-02 17:04:32 +01:00
|
|
|
ImGui::EndMenuBar();
|
2024-12-29 20:13:58 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-02 17:04:32 +01:00
|
|
|
void ViewerApplication::drawContents()
|
2024-12-29 20:13:58 +01:00
|
|
|
{
|
2025-01-02 17:04:32 +01:00
|
|
|
ImGui::Text("No handler selected!");
|
2024-12-29 20:13:58 +01:00
|
|
|
}
|
|
|
|
|
|
2024-12-31 17:01:12 +01:00
|
|
|
void ViewerApplication::drawUI()
|
2024-12-29 20:13:58 +01:00
|
|
|
{
|
2024-12-31 17:01:12 +01:00
|
|
|
ImVec2 viewer_size = ImGui::GetContentRegionAvail();
|
2024-12-29 20:13:58 +01:00
|
|
|
|
2025-01-02 17:04:32 +01:00
|
|
|
if (ImGui::BeginTable("##wiever_table", 2, /*ImGuiTableFlags_NoBordersInBodyUntilResize |*/ ImGuiTableFlags_Resizable | ImGuiTableFlags_SizingStretchProp | ImGuiTableFlags_BordersInnerV))
|
2024-12-29 20:13:58 +01:00
|
|
|
{
|
2024-12-31 17:01:12 +01:00
|
|
|
ImGui::TableSetupColumn("##panel_v", ImGuiTableColumnFlags_None, viewer_size.x * panel_ratio);
|
|
|
|
|
ImGui::TableSetupColumn("##view", ImGuiTableColumnFlags_None, viewer_size.x * (1.0f - panel_ratio));
|
|
|
|
|
ImGui::TableNextColumn();
|
2024-12-29 20:13:58 +01:00
|
|
|
|
2024-12-31 17:01:12 +01:00
|
|
|
float left_width = ImGui::GetColumnWidth(0);
|
|
|
|
|
float right_width = viewer_size.x - left_width;
|
|
|
|
|
if (left_width != last_width && last_width != -1)
|
|
|
|
|
panel_ratio = left_width / viewer_size.x;
|
|
|
|
|
last_width = left_width;
|
2024-12-29 20:13:58 +01:00
|
|
|
|
2025-01-02 17:04:32 +01:00
|
|
|
ImGui::BeginChild("ViewerChildPanel", {left_width, float(viewer_size.y - 10)}, false, ImGuiWindowFlags_MenuBar);
|
|
|
|
|
drawMenuBar();
|
2024-12-31 17:01:12 +01:00
|
|
|
drawPanel();
|
|
|
|
|
ImGui::EndChild();
|
2024-12-29 20:13:58 +01:00
|
|
|
|
2024-12-31 17:01:12 +01:00
|
|
|
ImGui::TableNextColumn();
|
|
|
|
|
ImGui::BeginGroup();
|
2024-12-29 20:13:58 +01:00
|
|
|
|
2024-12-31 17:01:12 +01:00
|
|
|
if (curr_handler)
|
|
|
|
|
curr_handler->drawContents({float(right_width - 4), float(viewer_size.y)});
|
2025-01-02 17:04:32 +01:00
|
|
|
else
|
|
|
|
|
drawContents();
|
2024-12-29 20:13:58 +01:00
|
|
|
|
2024-12-31 17:01:12 +01:00
|
|
|
ImGui::EndGroup();
|
|
|
|
|
ImGui::EndTable();
|
2024-12-29 20:13:58 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|