satdump/src-interface/viewer/image_handler.h

120 lines
3.6 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 "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"
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;
image::Image<uint16_t> rgb_image, current_image;
std::vector<image::Image<uint16_t>> images_obj;
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;
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 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;
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>> disaplay_ranges;
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;
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;
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
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;
2023-10-01 22:15:14 +02:00
bool project_old_algorithm = 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();
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>(); }
};
}