2025-02-09 16:34:06 +01:00
|
|
|
#include "projection_handler.h"
|
|
|
|
|
#include "core/style.h"
|
2025-04-14 19:03:42 +01:00
|
|
|
#include "logger.h"
|
2025-02-09 16:34:06 +01:00
|
|
|
|
|
|
|
|
#include "../image/image_handler.h"
|
2025-04-14 19:03:42 +01:00
|
|
|
#include "../vector/shapefile_handler.h"
|
2025-02-09 16:34:06 +01:00
|
|
|
|
2025-02-14 15:55:03 +01:00
|
|
|
// TODOREWORK
|
|
|
|
|
#include "projection/reprojector.h"
|
|
|
|
|
|
2025-02-09 16:34:06 +01:00
|
|
|
namespace satdump
|
|
|
|
|
{
|
|
|
|
|
namespace viewer
|
|
|
|
|
{
|
2025-04-14 19:03:42 +01:00
|
|
|
ProjectionHandler::ProjectionHandler() { handler_tree_icon = "\uf6e6"; }
|
2025-02-09 16:34:06 +01:00
|
|
|
|
2025-04-14 19:03:42 +01:00
|
|
|
ProjectionHandler::~ProjectionHandler() {}
|
2025-02-09 16:34:06 +01:00
|
|
|
|
|
|
|
|
void ProjectionHandler::drawMenu()
|
|
|
|
|
{
|
|
|
|
|
bool needs_to_be_disabled = is_processing;
|
|
|
|
|
|
|
|
|
|
if (ImGui::CollapsingHeader("Projection"))
|
|
|
|
|
{
|
|
|
|
|
if (needs_to_be_disabled)
|
|
|
|
|
style::beginDisabled();
|
|
|
|
|
|
2025-02-14 15:55:03 +01:00
|
|
|
projui.drawUI();
|
|
|
|
|
|
|
|
|
|
// needs_to_update |= TODO; // TODOREWORK move in top drawMenu?
|
|
|
|
|
if (ImGui::Button("TEST"))
|
|
|
|
|
needs_to_update = true;
|
|
|
|
|
|
2025-02-09 16:34:06 +01:00
|
|
|
if (needs_to_be_disabled)
|
|
|
|
|
style::endDisabled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// TODOREWORK UPDATE
|
|
|
|
|
if (needs_to_update)
|
|
|
|
|
{
|
|
|
|
|
asyncProcess();
|
|
|
|
|
needs_to_update = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
img_handler.drawMenu();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProjectionHandler::setConfig(nlohmann::json p)
|
|
|
|
|
{
|
|
|
|
|
if (p.contains("image"))
|
|
|
|
|
img_handler.setConfig(p["image"]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nlohmann::json ProjectionHandler::getConfig()
|
|
|
|
|
{
|
|
|
|
|
nlohmann::json p;
|
|
|
|
|
|
|
|
|
|
p["image"] = img_handler.getConfig();
|
|
|
|
|
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProjectionHandler::do_process()
|
|
|
|
|
{
|
|
|
|
|
for (auto &h : subhandlers)
|
|
|
|
|
{
|
|
|
|
|
if (h->getID() == "image_handler")
|
|
|
|
|
{
|
|
|
|
|
ImageHandler *im_h = (ImageHandler *)h.get();
|
|
|
|
|
logger->critical("Drawing IMAGE!");
|
|
|
|
|
// sh_h->draw_to_image(curr_image, pfunc);
|
2025-02-14 15:55:03 +01:00
|
|
|
|
|
|
|
|
// TODOREWORK!!!!
|
|
|
|
|
proj::ReprojectionOperation op;
|
|
|
|
|
op.img = &im_h->get_current_img();
|
|
|
|
|
op.target_prj_info = projui.get_proj();
|
|
|
|
|
// op.target_prj_info["width"] = width;
|
|
|
|
|
// op.target_prj_info["height"] = height;
|
|
|
|
|
op.output_width = op.target_prj_info["width"];
|
|
|
|
|
op.output_height = op.target_prj_info["height"];
|
|
|
|
|
auto cfg = image::get_metadata_proj_cfg(*op.img);
|
|
|
|
|
cfg["width"] = op.img->width();
|
|
|
|
|
cfg["height"] = op.img->height();
|
|
|
|
|
image::set_metadata_proj_cfg(*op.img, cfg);
|
|
|
|
|
auto img = proj::reproject(op);
|
2025-03-09 10:16:40 +01:00
|
|
|
logger->critical("DONE REPROJECTING!");
|
2025-02-14 15:55:03 +01:00
|
|
|
img_handler.updateImage(img);
|
2025-02-09 16:34:06 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-14 17:37:36 +01:00
|
|
|
/* for (auto &h : subhandlers)
|
|
|
|
|
{
|
|
|
|
|
if (h->getID() == "shapefile_handler")
|
|
|
|
|
{
|
|
|
|
|
ShapefileHandler *sh_h = (ShapefileHandler *)h.get();
|
|
|
|
|
logger->critical("Drawing OVERLAY!");
|
|
|
|
|
// sh_h->draw_to_image(curr_image, pfunc);
|
|
|
|
|
}
|
|
|
|
|
}*/
|
2025-02-09 16:34:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProjectionHandler::drawMenuBar()
|
|
|
|
|
{
|
|
|
|
|
img_handler.drawMenuBar();
|
|
|
|
|
/*if (ImGui::MenuItem("Image To Handler"))
|
|
|
|
|
{
|
|
|
|
|
std::shared_ptr<ImageHandler> a = std::make_shared<ImageHandler>();
|
|
|
|
|
a->setConfig(img_handler.getConfig());
|
|
|
|
|
a->updateImage(img_handler.image);
|
|
|
|
|
addSubHandler(a);
|
|
|
|
|
}*/
|
|
|
|
|
// TODOREWORK
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-14 19:03:42 +01:00
|
|
|
void ProjectionHandler::drawContents(ImVec2 win_size) { img_handler.drawContents(win_size); }
|
|
|
|
|
} // namespace viewer
|
|
|
|
|
} // namespace satdump
|