satdump/src-interface/viewer/image_handler.h

119 lines
3.5 KiB
C
Raw Permalink 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 "core/style.h"
2023-10-22 14:52:06 -04:00
#include "libs/ctpl/ctpl_stl.h"
2023-11-14 21:31:59 +01:00
#include "common/widgets/markdown_helper.h"
2024-02-28 17:16:05 +01:00
#include "common/widgets/timed_message.h"
2022-04-12 20:18:44 +02:00
namespace satdump
{
class ImageViewerHandler : public ViewerHandler
{
public:
2023-10-22 14:52:06 -04:00
~ImageViewerHandler();
2022-04-12 20:18:44 +02:00
// 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;
2024-05-09 01:16:08 +02:00
image::Image rgb_image, current_image;
2022-04-12 20:18:44 +02:00
ImageViewWidget image_view;
2024-01-02 17:06:14 -05:00
// Map projection stuff
std::function<std::pair<int, int>(float, float, int, int)> proj_func;
nlohmann::json last_proj_cfg;
2024-01-02 17:06:14 -05:00
bool last_correct_image = false;
bool last_rotate_image = false;
2024-01-03 22:53:32 -05:00
size_t last_width = 0;
size_t last_height = 0;
2024-01-02 17:06:14 -05:00
2022-04-12 20:18:44 +02:00
// Other controls
bool remove_background = false;
bool median_blur = false;
2023-11-09 23:58:15 -05:00
bool despeckle = 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;
2024-04-26 17:44:12 +02:00
bool manual_brightness_contrast = false;
float manual_brightness_contrast_brightness = 0.0;
float manual_brightness_contrast_contrast = 0.0;
2022-04-12 20:18:44 +02:00
2023-01-22 01:54:24 +01:00
// GUI
bool range_window = false;
std::vector<std::pair<double, double>> temp_ranges, radiance_ranges;
2023-01-22 01:54:24 +01:00
bool update_needed;
bool is_updating = false;
2023-07-05 23:25:38 +02:00
OverlayHandler overlay_handler;
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;
2024-05-09 01:16:08 +02:00
image::Image scale_image; // 512x25
2024-09-08 17:08:52 -04:00
unsigned int scale_texture_id = 0;
uint32_t *scale_buffer = nullptr;
bool scale_has_update = false;
2023-07-05 23:25:38 +02:00
// LUT
bool using_lut = false;
2024-05-09 01:16:08 +02:00
image::Image lut_image;
2023-07-05 23:25:38 +02:00
// 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;
2023-11-25 10:27:43 -05:00
std::string preset_search_str;
2022-04-12 20:18:44 +02:00
int select_rgb_presets = -1;
2023-11-14 21:31:59 +01:00
bool show_markdown_description = false;
widgets::MarkdownHelper markdown_composite_info;
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
bool projection_use_old_algo = false;
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();
2023-10-22 14:52:06 -04:00
ctpl::thread_pool handler_thread_pool = ctpl::thread_pool(1);
2022-04-12 20:18:44 +02:00
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();
void addCurrentToProjections();
2022-09-07 21:11:44 +02:00
2024-02-28 17:16:05 +01:00
widgets::TimedMessage proj_notif;
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>(); }
};
}