satdump/src-interface/viewer/image_handler.h

84 lines
2.5 KiB
C
Raw Normal View History

2022-04-12 20:18:44 +02:00
#pragma once
#include "viewer.h"
#include "logger.h"
2022-04-13 13:40:44 +02:00
#include "products/image_products.h"
2022-04-12 20:18:44 +02:00
#include "common/widgets/image_view.h"
#include "imgui/imgui_stdlib.h"
#include "common/image/composite.h"
#include "main_ui.h"
#include "core/style.h"
2022-05-04 19:50:23 +02:00
#include "imgui/pfd/portable-file-dialogs.h"
2022-04-12 20:18:44 +02:00
namespace satdump
{
class ImageViewerHandler : public ViewerHandler
{
public:
// Products
ImageProducts *products;
// Image handling
2022-04-13 17:51:30 +02:00
int active_channel_id = 0, select_image_id = 1;
2022-04-12 20:18:44 +02:00
std::string select_image_str;
image::Image<uint16_t> rgb_image, current_image;
std::vector<image::Image<uint16_t>> images_obj;
ImageViewWidget image_view;
// Other controls
bool median_blur = false;
2022-04-12 20:18:44 +02:00
bool rotate_image = false;
bool equalize_image = false;
bool invert_image = false;
bool correct_image = false;
2022-04-12 21:37:36 +02:00
bool normalize_image = false;
2022-04-13 13:40:44 +02:00
bool white_balance_image = false;
2022-04-12 20:18:44 +02:00
2022-09-05 22:30:53 +02:00
bool map_overlay = false;
bool cities_overlay = false;
float cities_scale = 0.5;
2022-04-12 20:18:44 +02:00
// RGB Handling
2022-04-20 15:57:17 +02:00
ImageCompositeCfg rgb_compo_cfg;
2022-04-12 20:18:44 +02:00
std::vector<std::string> channel_numbers;
float rgb_progress = 0;
bool rgb_processing = false;
2022-04-20 15:57:17 +02:00
std::vector<std::pair<std::string, ImageCompositeCfg>> rgb_presets;
2022-04-12 20:18:44 +02:00
std::string rgb_presets_str;
int select_rgb_presets = -1;
2022-09-05 22:30:53 +02:00
std::vector<double> current_timestamps;
2022-09-07 22:20:48 +02:00
// Projections
2022-09-08 17:24:54 +02:00
bool use_draw_proj_algo = false;
bool projection_ready = false, should_project = false;
2022-09-07 22:20:48 +02:00
image::Image<uint16_t> projected_img;
ImVec4 color_borders = {0, 1, 0, 1};
ImVec4 color_cities = {1, 0, 0, 1};
2022-04-12 20:18:44 +02:00
void init();
void updateImage();
std::mutex async_image_mutex;
void asyncUpdate();
void updateRGB();
void drawMenu();
void drawContents(ImVec2 win_size);
2022-04-16 08:10:25 +02:00
float drawTreeMenu();
2022-04-12 20:18:44 +02:00
2022-09-07 21:11:44 +02:00
bool canBeProjected();
bool hasProjection();
2022-09-08 17:24:54 +02:00
bool shouldProject();
2022-09-07 22:20:48 +02:00
void updateProjection(int width, int height, nlohmann::json settings, float *progess);
2022-09-07 21:11:44 +02:00
image::Image<uint16_t> &getProjection();
2022-09-13 22:54:11 +02:00
unsigned int getPreviewImageTexture() { return image_view.getTextID(); }
2022-09-14 10:10:59 +02:00
void setShouldProject(bool proj) { should_project = proj; }
2022-09-07 21:11:44 +02:00
2022-04-12 20:18:44 +02:00
static std::string getID() { return "image_handler"; }
static std::shared_ptr<ViewerHandler> getInstance() { return std::make_shared<ImageViewerHandler>(); }
};
}