SatDump 2.0.0-alpha-76a915210
Loading...
Searching...
No Matches
imageproduct_node.h
1#pragma once
2
3#include "flowgraph.h"
6
7namespace satdump
8{
9 class ImageProductSource_Node : public NodeInternal
10 {
11 private:
12 std::string product_path;
13
14 public:
15 ImageProductSource_Node()
16 : NodeInternal("Image Product Source")
17 {
18 outputs.push_back({"Product"});
19 }
20
21 void process()
22 {
23 outputs[0].ptr = products::loadProduct(product_path); //"/home/alan/Downloads/SatDump_NEWPRODS/metop_test/AVHRR/product.cbor");
24
25 has_run = true;
26 }
27
28 void render()
29 {
30 ImGui::SetNextItemWidth(200 * ui_scale);
31 ImGui::InputText("Path", &product_path);
32 }
33
34 nlohmann::json to_json()
35 {
36 nlohmann::json j;
37 j["path"] = product_path;
38 return j;
39 }
40
41 void from_json(nlohmann::json j)
42 {
43 product_path = j["path"];
44 }
45 };
46
47 class ImageProductExpression_Node : public NodeInternal
48 {
49 private:
50 std::string expression;
51
52 bool processing = false;
53 float progress = 0;
54
55 public:
56 ImageProductExpression_Node()
57 : NodeInternal("Image Product Expression")
58 {
59 inputs.push_back({"Product"});
60 outputs.push_back({"Image"});
61 }
62
63 void process()
64 {
65 processing = true;
66 std::shared_ptr<satdump::products::ImageProduct> img_pro = std::static_pointer_cast<satdump::products::ImageProduct>(inputs[0].ptr);
67
68 std::shared_ptr<image::Image> img_out = std::make_shared<image::Image>();
69 *img_out = products::generate_expression_product_composite(img_pro.get(), expression, &progress);
70
71 outputs[0].ptr = img_out;
72
73 has_run = true;
74 processing = false;
75 }
76
77 void render()
78 {
79 ImGui::SetNextItemWidth(200 * ui_scale);
80 ImGui::InputTextMultiline("Expression", &expression);
81
82 if (processing)
83 ImGui::ProgressBar(progress, {200 * ui_scale, 0});
84 }
85
86 nlohmann::json to_json()
87 {
88 nlohmann::json j;
89 j["expression"] = expression;
90 return j;
91 }
92
93 void from_json(nlohmann::json j)
94 {
95 expression = j["expression"];
96 }
97 };
98}
ImageProduct implementation.