satdump/src-interface/viewer/image_handler.h

111 lines
3.2 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;
2023-01-02 01:06:49 +01:00
bool active_channel_calibrated = false;
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;
2023-09-04 18:00:34 +02:00
bool individual_equalize_image = false;
2022-04-12 20:18:44 +02:00
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;
2023-03-18 23:49:29 +01:00
int cities_size = 50;
int cities_type = 0;
int cities_scale_rank = 3;
2022-09-05 22:30:53 +02:00
2023-01-22 01:54:24 +01:00
// GUI
bool range_window = false;
std::vector<std::pair<double, double>> disaplay_ranges;
bool update_needed;
2023-07-05 23:25:38 +02:00
// Calibration
bool is_temp = false;
2023-01-22 18:21:08 +01:00
bool show_scale = false;
2023-01-22 20:44:44 +01:00
image::Image<uint16_t> scale_image; // 512x25
2023-01-22 18:21:08 +01:00
ImageViewWidget scale_view;
2023-07-05 23:25:38 +02:00
// LUT
bool using_lut = false;
image::Image<uint16_t> lut_image;
// Geo-Correction
std::vector<int> correction_factors;
2023-01-22 01:54:24 +01:00
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-12-15 21:43:39 +01:00
nlohmann::json current_proj_metadata;
2022-09-05 22:30:53 +02:00
2022-09-07 22:20:48 +02:00
// Projections
2022-09-08 17:24:54 +02:00
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};
2023-07-05 23:25:38 +02:00
// Utils
void updateScaleImage();
void updateCorrectionFactors(bool first = false);
// The Rest
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>(); }
};
}