From d5b9149b37106138d062ed7d79f996a67df5735a Mon Sep 17 00:00:00 2001 From: Aang23 Date: Mon, 19 May 2025 22:26:32 +0200 Subject: [PATCH] Fix some bugs, clearly separate handlers from viewer --- Doxyfile.in | 2 +- plugins/bitview_app/bitview.h | 4 +- plugins/bitview_app/main.cpp | 2 +- .../official_products_support/main_loader.cpp | 13 +-- .../sdr_sources/airspy_sdr_support/main.cpp | 4 +- .../sdr_sources/bladerf_sdr_support/main.cpp | 4 +- .../sdr_sources/rtlsdr_sdr_support/main.cpp | 4 +- plugins/tools_app/lutgen/lut_generator.h | 4 +- plugins/tools_app/main.cpp | 2 +- plugins/wip_tracking_app/main.cpp | 2 +- plugins/wip_tracking_app/tracking.h | 2 +- .../dsp/flowgraph/dsp_flowgraph_handler.cpp | 4 +- .../dsp/flowgraph/dsp_flowgraph_handler.h | 6 +- .../dataset/TextEditor.cpp | 0 .../dataset/TextEditor.h | 0 .../dataset/dataset_handler.cpp | 12 +-- .../dataset/dataset_handler.h | 6 +- .../dataset/dataset_product_handler.cpp | 4 +- .../dataset/dataset_product_handler.h | 8 +- .../dataset/flowgraph/datasetproc_node.h | 16 ++-- .../dataset/flowgraph/flowgraph.cpp | 0 .../dataset/flowgraph/flowgraph.h | 0 .../dataset/flowgraph/image_nodes.h | 0 .../dataset/flowgraph/imageproduct_node.h | 0 .../dataset/flowgraph_processor.cpp | 4 +- .../dataset/flowgraph_processor.h | 14 +-- .../{handler => handlers}/dataset/processor.h | 12 +-- .../{handler => handlers}/dummy_handler.h | 6 +- src-core/{handler => handlers}/handler.cpp | 8 +- src-core/{handler => handlers}/handler.h | 4 +- .../image/image_handler.cpp | 6 +- .../image/image_handler.h | 4 +- .../processing_handler.h | 4 +- .../product/image_product_handler.cpp | 4 +- .../product/image_product_handler.h | 4 +- .../product/product_handler.cpp | 4 +- .../product/product_handler.h | 14 ++- .../handlers/product/product_handler_init.cpp | 26 ++++++ .../product/punctiform_product_handler.cpp | 4 +- .../product/punctiform_product_handler.h | 6 +- .../projection/proj_ui.h | 0 .../projection/projection_handler.cpp | 4 +- .../projection/projection_handler.h | 4 +- .../trash/trash_handler.cpp | 4 +- .../trash/trash_handler.h | 14 ++- src-core/{handler => handlers}/tree.h | 0 .../vector/dbf_file/dbf_file.cpp | 0 .../vector/dbf_file/dbf_file.h | 0 .../vector/shapefile_handler.cpp | 4 +- .../vector/shapefile_handler.h | 7 +- src-core/products2/product_process.cpp | 18 ++-- src-interface/processing.cpp | 22 ++--- src-interface/viewer2/dsp/cyclo_test.cpp | 4 +- src-interface/viewer2/dsp/cyclo_test.h | 6 +- src-interface/viewer2/dsp/newrec.cpp | 4 +- src-interface/viewer2/dsp/newrec.h | 6 +- src-interface/viewer2/dsp/waterfall_test.cpp | 15 ++- src-interface/viewer2/dsp/waterfall_test.h | 8 +- src-interface/viewer2/viewer.cpp | 92 +++++++++---------- src-interface/viewer2/viewer.h | 26 +++--- 60 files changed, 236 insertions(+), 225 deletions(-) rename src-core/{handler => handlers}/dataset/TextEditor.cpp (100%) rename src-core/{handler => handlers}/dataset/TextEditor.h (100%) rename src-core/{handler => handlers}/dataset/dataset_handler.cpp (77%) rename src-core/{handler => handlers}/dataset/dataset_handler.h (95%) rename src-core/{handler => handlers}/dataset/dataset_product_handler.cpp (98%) rename src-core/{handler => handlers}/dataset/dataset_product_handler.h (92%) rename src-core/{handler => handlers}/dataset/flowgraph/datasetproc_node.h (67%) rename src-core/{handler => handlers}/dataset/flowgraph/flowgraph.cpp (100%) rename src-core/{handler => handlers}/dataset/flowgraph/flowgraph.h (100%) rename src-core/{handler => handlers}/dataset/flowgraph/image_nodes.h (100%) rename src-core/{handler => handlers}/dataset/flowgraph/imageproduct_node.h (100%) rename src-core/{handler => handlers}/dataset/flowgraph_processor.cpp (98%) rename src-core/{handler => handlers}/dataset/flowgraph_processor.h (90%) rename src-core/{handler => handlers}/dataset/processor.h (92%) rename src-core/{handler => handlers}/dummy_handler.h (92%) rename src-core/{handler => handlers}/handler.cpp (98%) rename src-core/{handler => handlers}/handler.h (99%) rename src-core/{handler => handlers}/image/image_handler.cpp (99%) rename src-core/{handler => handlers}/image/image_handler.h (98%) rename src-core/{handler => handlers}/processing_handler.h (97%) rename src-core/{handler => handlers}/product/image_product_handler.cpp (99%) rename src-core/{handler => handlers}/product/image_product_handler.h (97%) rename src-core/{handler => handlers}/product/product_handler.cpp (99%) rename src-core/{handler => handlers}/product/product_handler.h (87%) create mode 100644 src-core/handlers/product/product_handler_init.cpp rename src-core/{handler => handlers}/product/punctiform_product_handler.cpp (99%) rename src-core/{handler => handlers}/product/punctiform_product_handler.h (94%) rename src-core/{handler => handlers}/projection/proj_ui.h (100%) rename src-core/{handler => handlers}/projection/projection_handler.cpp (98%) rename src-core/{handler => handlers}/projection/projection_handler.h (96%) rename src-core/{handler => handlers}/trash/trash_handler.cpp (91%) rename src-core/{handler => handlers}/trash/trash_handler.h (73%) rename src-core/{handler => handlers}/tree.h (100%) rename src-core/{handler => handlers}/vector/dbf_file/dbf_file.cpp (100%) rename src-core/{handler => handlers}/vector/dbf_file/dbf_file.h (100%) rename src-core/{handler => handlers}/vector/shapefile_handler.cpp (99%) rename src-core/{handler => handlers}/vector/shapefile_handler.h (80%) diff --git a/Doxyfile.in b/Doxyfile.in index ce604b54c..72e65cc9e 100644 --- a/Doxyfile.in +++ b/Doxyfile.in @@ -3,7 +3,7 @@ OUTPUT_DIRECTORY = @CMAKE_CURRENT_BINARY_DIR@/documentation/ PROJECT_NUMBER = @SATDUMP_VERSION@ INPUT = src-core/common/ccsds \ src-core/products2 \ - src-core/handler \ + src-core/handlers \ src-interface/viewer2 \ src-core/projection \ src-core/dsp \ diff --git a/plugins/bitview_app/bitview.h b/plugins/bitview_app/bitview.h index d6be33b69..939ff45d1 100644 --- a/plugins/bitview_app/bitview.h +++ b/plugins/bitview_app/bitview.h @@ -1,6 +1,6 @@ #pragma once -#include "handler/handler.h" +#include "handlers/handler.h" #include "imgui/imgui.h" #include "imgui/imgui_internal.h" #include @@ -16,7 +16,7 @@ namespace satdump { - class BitViewHandler : public viewer::Handler + class BitViewHandler : public handlers::Handler { protected: bool is_busy = false; diff --git a/plugins/bitview_app/main.cpp b/plugins/bitview_app/main.cpp index 4c2980f7a..50c800c1a 100644 --- a/plugins/bitview_app/main.cpp +++ b/plugins/bitview_app/main.cpp @@ -21,7 +21,7 @@ public: { if (ImGui::BeginMenu("File")) { - if (ImGui::BeginMenu("Others")) + if (ImGui::BeginMenu("Add")) { if (ImGui::MenuItem("BitView")) evt.master_handler->addSubHandler(std::make_shared()); diff --git a/plugins/official_products_support/main_loader.cpp b/plugins/official_products_support/main_loader.cpp index 3291ceb43..ec4edd73e 100644 --- a/plugins/official_products_support/main_loader.cpp +++ b/plugins/official_products_support/main_loader.cpp @@ -1,27 +1,24 @@ +#include "core/module.h" #include "core/plugin.h" #include "logger.h" -#include "core/module.h" #include "core/config.h" -#include "loader/archive_loader.h" #include "imgui/imgui_stdlib.h" +#include "loader/archive_loader.h" #include "viewer2/viewer.h" namespace { - bool _enable_loader = false; + bool _enable_loader = true; bool _loader_open = false; std::unique_ptr _loader = nullptr; -} +} // namespace class OfficalProductsLoaderSupport : public satdump::Plugin { public: - std::string getID() - { - return "official_products_loader_support"; - } + std::string getID() { return "official_products_loader_support"; } void init() { diff --git a/plugins/sdr_sources/airspy_sdr_support/main.cpp b/plugins/sdr_sources/airspy_sdr_support/main.cpp index f44a0b868..264b425de 100644 --- a/plugins/sdr_sources/airspy_sdr_support/main.cpp +++ b/plugins/sdr_sources/airspy_sdr_support/main.cpp @@ -17,7 +17,7 @@ public: satdump::eventBus->register_handler(registerDevs); satdump::eventBus->register_handler(provideDeviceInstance); - satdump::eventBus->register_handler(registerNodes); + satdump::eventBus->register_handler(registerNodes); } static void registerSources(const dsp::RegisterDSPSampleSourcesEvent &evt) @@ -40,7 +40,7 @@ public: evt.i.push_back(std::make_shared()); } - static void registerNodes(const satdump::viewer::RegisterNodesEvent &evt) + static void registerNodes(const satdump::handlers::RegisterNodesEvent &evt) { evt.r.insert({"airspy_cc", {"Device/Airspy Dev", [](const satdump::ndsp::Flowgraph *f) { return std::make_shared(f, std::make_shared()); }}}); diff --git a/plugins/sdr_sources/bladerf_sdr_support/main.cpp b/plugins/sdr_sources/bladerf_sdr_support/main.cpp index 10dc5ea8c..4e5d5c85b 100644 --- a/plugins/sdr_sources/bladerf_sdr_support/main.cpp +++ b/plugins/sdr_sources/bladerf_sdr_support/main.cpp @@ -19,7 +19,7 @@ public: satdump::eventBus->register_handler(registerDevs); satdump::eventBus->register_handler(provideDeviceInstance); - satdump::eventBus->register_handler(registerNodes); + satdump::eventBus->register_handler(registerNodes); } static void registerSources(const dsp::RegisterDSPSampleSourcesEvent &evt) @@ -41,7 +41,7 @@ public: evt.i.push_back(std::make_shared()); } - static void registerNodes(const satdump::viewer::RegisterNodesEvent &evt) + static void registerNodes(const satdump::handlers::RegisterNodesEvent &evt) { evt.r.insert({"bladerf_cc", {"Device/BladeRF Dev", [](const satdump::ndsp::Flowgraph *f) { return std::make_shared(f, std::make_shared()); }}}); diff --git a/plugins/sdr_sources/rtlsdr_sdr_support/main.cpp b/plugins/sdr_sources/rtlsdr_sdr_support/main.cpp index f39ae9c4f..a57342c79 100644 --- a/plugins/sdr_sources/rtlsdr_sdr_support/main.cpp +++ b/plugins/sdr_sources/rtlsdr_sdr_support/main.cpp @@ -18,7 +18,7 @@ public: satdump::eventBus->register_handler(registerDevs); satdump::eventBus->register_handler(provideDeviceInstance); - satdump::eventBus->register_handler(registerNodes); + satdump::eventBus->register_handler(registerNodes); } static void registerSources(const dsp::RegisterDSPSampleSourcesEvent &evt) @@ -41,7 +41,7 @@ public: evt.i.push_back(std::make_shared()); } - static void registerNodes(const satdump::viewer::RegisterNodesEvent &evt) + static void registerNodes(const satdump::handlers::RegisterNodesEvent &evt) { evt.r.insert({"rtlsdr_cc", {"Device/RTL-SDR Dev", [](const satdump::ndsp::Flowgraph *f) { return std::make_shared(f, std::make_shared()); }}}); diff --git a/plugins/tools_app/lutgen/lut_generator.h b/plugins/tools_app/lutgen/lut_generator.h index 6c8726b83..3e208e990 100644 --- a/plugins/tools_app/lutgen/lut_generator.h +++ b/plugins/tools_app/lutgen/lut_generator.h @@ -1,6 +1,6 @@ #pragma once -#include "handler/handler.h" +#include "handlers/handler.h" #include "common/widgets/image_view.h" #include "common/widgets/menuitem_fileopen.h" @@ -11,7 +11,7 @@ namespace satdump { namespace lutgen { - class LutGeneratorHandler : public viewer::Handler + class LutGeneratorHandler : public handlers::Handler { private: struct ColorPX diff --git a/plugins/tools_app/main.cpp b/plugins/tools_app/main.cpp index 2de065bb3..a10a3de81 100644 --- a/plugins/tools_app/main.cpp +++ b/plugins/tools_app/main.cpp @@ -17,7 +17,7 @@ public: { if (ImGui::BeginMenu("File")) { - if (ImGui::BeginMenu("Others")) + if (ImGui::BeginMenu("Add")) { if (ImGui::MenuItem("Lut Generator")) evt.master_handler->addSubHandler(std::make_shared()); diff --git a/plugins/wip_tracking_app/main.cpp b/plugins/wip_tracking_app/main.cpp index 65d1c6616..cc8d6502e 100644 --- a/plugins/wip_tracking_app/main.cpp +++ b/plugins/wip_tracking_app/main.cpp @@ -21,7 +21,7 @@ public: { if (ImGui::BeginMenu("File")) { - if (ImGui::BeginMenu("Others")) + if (ImGui::BeginMenu("Add")) { if (ImGui::MenuItem("WIP Tracking")) evt.master_handler->addSubHandler(std::make_shared()); diff --git a/plugins/wip_tracking_app/tracking.h b/plugins/wip_tracking_app/tracking.h index d1d9ee93e..99060bb89 100644 --- a/plugins/wip_tracking_app/tracking.h +++ b/plugins/wip_tracking_app/tracking.h @@ -1,6 +1,6 @@ #pragma once -#include "handler/handler.h" +#include "handlers/handler.h" #include "imgui/imgui.h" #include diff --git a/src-core/dsp/flowgraph/dsp_flowgraph_handler.cpp b/src-core/dsp/flowgraph/dsp_flowgraph_handler.cpp index 68d1687b0..9ba21b0ea 100644 --- a/src-core/dsp/flowgraph/dsp_flowgraph_handler.cpp +++ b/src-core/dsp/flowgraph/dsp_flowgraph_handler.cpp @@ -30,7 +30,7 @@ namespace satdump { - namespace viewer + namespace handlers { class NodeTestFileSource : public ndsp::NodeInternal { @@ -213,5 +213,5 @@ namespace satdump } void DSPFlowGraphHandler::drawContents(ImVec2 win_size) { flowgraph.render(); } - } // namespace viewer + } // namespace handlers } // namespace satdump diff --git a/src-core/dsp/flowgraph/dsp_flowgraph_handler.h b/src-core/dsp/flowgraph/dsp_flowgraph_handler.h index 29eaf4da9..765263dec 100644 --- a/src-core/dsp/flowgraph/dsp_flowgraph_handler.h +++ b/src-core/dsp/flowgraph/dsp_flowgraph_handler.h @@ -1,14 +1,14 @@ #pragma once #include "dsp/flowgraph/flowgraph.h" -#include "handler/handler.h" +#include "handlers/handler.h" #include "dsp/device/dev.h" // TODOREWORK, move into plugin? Or Core? namespace satdump { - namespace viewer + namespace handlers { class DSPFlowGraphHandler : public Handler { @@ -33,5 +33,5 @@ namespace satdump { std::map &r; }; - } // namespace viewer + } // namespace handlers } // namespace satdump diff --git a/src-core/handler/dataset/TextEditor.cpp b/src-core/handlers/dataset/TextEditor.cpp similarity index 100% rename from src-core/handler/dataset/TextEditor.cpp rename to src-core/handlers/dataset/TextEditor.cpp diff --git a/src-core/handler/dataset/TextEditor.h b/src-core/handlers/dataset/TextEditor.h similarity index 100% rename from src-core/handler/dataset/TextEditor.h rename to src-core/handlers/dataset/TextEditor.h diff --git a/src-core/handler/dataset/dataset_handler.cpp b/src-core/handlers/dataset/dataset_handler.cpp similarity index 77% rename from src-core/handler/dataset/dataset_handler.cpp rename to src-core/handlers/dataset/dataset_handler.cpp index 0c175a14a..dd4b0f9f1 100644 --- a/src-core/handler/dataset/dataset_handler.cpp +++ b/src-core/handlers/dataset/dataset_handler.cpp @@ -10,7 +10,7 @@ namespace satdump { - namespace viewer + namespace handlers { DatasetHandler::DatasetHandler(std::string path, products::DataSet d) : dataset(d) { @@ -30,13 +30,7 @@ namespace satdump for (auto &p : dataset.products_list) { auto prod = products::loadProduct(path + "/" + p); - std::shared_ptr prod_h; - if (prod->type == "image") - prod_h = std::make_shared(prod, true); - else if (prod->type == "punctiform") - prod_h = std::make_shared(prod, true); - else - logger->error("TODOREWORK!!!!!! Actually handle loading properly..."); + auto prod_h = getProductHandlerForProduct(prod); instrument_products->addSubHandler(prod_h); all_products.push_back(prod); } @@ -50,5 +44,5 @@ namespace satdump void DatasetHandler::drawMenu() {} void DatasetHandler::drawContents(ImVec2 win_size) {} - } // namespace viewer + } // namespace handlers } // namespace satdump \ No newline at end of file diff --git a/src-core/handler/dataset/dataset_handler.h b/src-core/handlers/dataset/dataset_handler.h similarity index 95% rename from src-core/handler/dataset/dataset_handler.h rename to src-core/handlers/dataset/dataset_handler.h index 94a4f84bc..8c3b1ddb1 100644 --- a/src-core/handler/dataset/dataset_handler.h +++ b/src-core/handlers/dataset/dataset_handler.h @@ -10,7 +10,7 @@ namespace satdump { - namespace viewer + namespace handlers { /** * @brief Dataset handler. @@ -53,5 +53,5 @@ namespace satdump std::string getID() { return "dataset_handler"; } }; - } -} \ No newline at end of file + } // namespace handlers +} // namespace satdump \ No newline at end of file diff --git a/src-core/handler/dataset/dataset_product_handler.cpp b/src-core/handlers/dataset/dataset_product_handler.cpp similarity index 98% rename from src-core/handler/dataset/dataset_product_handler.cpp rename to src-core/handlers/dataset/dataset_product_handler.cpp index e94784323..ebf3b58b5 100644 --- a/src-core/handler/dataset/dataset_product_handler.cpp +++ b/src-core/handlers/dataset/dataset_product_handler.cpp @@ -10,7 +10,7 @@ namespace satdump { - namespace viewer + namespace handlers { DatasetProductHandler::DatasetProductHandler() { @@ -99,5 +99,5 @@ namespace satdump else logger->error("Invalid processor!\n"); } - } // namespace viewer + } // namespace handlers } // namespace satdump \ No newline at end of file diff --git a/src-core/handler/dataset/dataset_product_handler.h b/src-core/handlers/dataset/dataset_product_handler.h similarity index 92% rename from src-core/handler/dataset/dataset_product_handler.h rename to src-core/handlers/dataset/dataset_product_handler.h index bcf565f63..61d5a8b49 100644 --- a/src-core/handler/dataset/dataset_product_handler.h +++ b/src-core/handlers/dataset/dataset_product_handler.h @@ -1,14 +1,14 @@ #pragma once #include "../handler.h" -#include "dataset_handler.h" #include "../processing_handler.h" +#include "dataset_handler.h" #include "processor.h" namespace satdump { - namespace viewer + namespace handlers { class DatasetProductHandler : public Handler, public ProcessingHandler { @@ -34,5 +34,5 @@ namespace satdump std::string getID() { return "dataset_product_handler"; } }; - } -} \ No newline at end of file + } // namespace handlers +} // namespace satdump \ No newline at end of file diff --git a/src-core/handler/dataset/flowgraph/datasetproc_node.h b/src-core/handlers/dataset/flowgraph/datasetproc_node.h similarity index 67% rename from src-core/handler/dataset/flowgraph/datasetproc_node.h rename to src-core/handlers/dataset/flowgraph/datasetproc_node.h index ce9b38e08..647f8f6cb 100644 --- a/src-core/handler/dataset/flowgraph/datasetproc_node.h +++ b/src-core/handlers/dataset/flowgraph/datasetproc_node.h @@ -1,28 +1,24 @@ #pragma once -#include "flowgraph.h" -#include "../dataset_product_handler.h" #include "../../image/image_handler.h" +#include "../dataset_product_handler.h" +#include "flowgraph.h" namespace satdump { class ImageHandlerSink_Node : public NodeInternal { private: - viewer::Handler *ptr; + handlers::Handler *ptr; public: - ImageHandlerSink_Node(viewer::Handler *ptr) - : NodeInternal("Image Handler Sink"), ptr(ptr) - { - inputs.push_back({"Image"}); - } + ImageHandlerSink_Node(handlers::Handler *ptr) : NodeInternal("Image Handler Sink"), ptr(ptr) { inputs.push_back({"Image"}); } void process() { std::shared_ptr img_pro = std::static_pointer_cast(inputs[0].ptr); - auto handler = std::make_shared(*img_pro); + auto handler = std::make_shared(*img_pro); ptr->addSubHandler(handler); has_run = true; @@ -32,4 +28,4 @@ namespace satdump nlohmann::json to_json() { return {}; } void from_json(nlohmann::json j) {} }; -} \ No newline at end of file +} // namespace satdump \ No newline at end of file diff --git a/src-core/handler/dataset/flowgraph/flowgraph.cpp b/src-core/handlers/dataset/flowgraph/flowgraph.cpp similarity index 100% rename from src-core/handler/dataset/flowgraph/flowgraph.cpp rename to src-core/handlers/dataset/flowgraph/flowgraph.cpp diff --git a/src-core/handler/dataset/flowgraph/flowgraph.h b/src-core/handlers/dataset/flowgraph/flowgraph.h similarity index 100% rename from src-core/handler/dataset/flowgraph/flowgraph.h rename to src-core/handlers/dataset/flowgraph/flowgraph.h diff --git a/src-core/handler/dataset/flowgraph/image_nodes.h b/src-core/handlers/dataset/flowgraph/image_nodes.h similarity index 100% rename from src-core/handler/dataset/flowgraph/image_nodes.h rename to src-core/handlers/dataset/flowgraph/image_nodes.h diff --git a/src-core/handler/dataset/flowgraph/imageproduct_node.h b/src-core/handlers/dataset/flowgraph/imageproduct_node.h similarity index 100% rename from src-core/handler/dataset/flowgraph/imageproduct_node.h rename to src-core/handlers/dataset/flowgraph/imageproduct_node.h diff --git a/src-core/handler/dataset/flowgraph_processor.cpp b/src-core/handlers/dataset/flowgraph_processor.cpp similarity index 98% rename from src-core/handler/dataset/flowgraph_processor.cpp rename to src-core/handlers/dataset/flowgraph_processor.cpp index 0899ac89e..de4d1478e 100644 --- a/src-core/handler/dataset/flowgraph_processor.cpp +++ b/src-core/handlers/dataset/flowgraph_processor.cpp @@ -9,7 +9,7 @@ namespace satdump { - namespace viewer + namespace handlers { Flowgraph_DatasetProductProcessor::Flowgraph_DatasetProductProcessor(DatasetHandler *dh, Handler *dp, nlohmann::json p) : DatasetProductProcessor(dh, dp, p) { @@ -48,5 +48,5 @@ namespace satdump void Flowgraph_DatasetProductProcessor::process(float *progress) { flowgraph.run(); } void Flowgraph_DatasetProductProcessor::renderUI() { flowgraph.render(); } - } // namespace viewer + } // namespace handlers } // namespace satdump \ No newline at end of file diff --git a/src-core/handler/dataset/flowgraph_processor.h b/src-core/handlers/dataset/flowgraph_processor.h similarity index 90% rename from src-core/handler/dataset/flowgraph_processor.h rename to src-core/handlers/dataset/flowgraph_processor.h index d6e238502..4ef2be4e8 100644 --- a/src-core/handler/dataset/flowgraph_processor.h +++ b/src-core/handlers/dataset/flowgraph_processor.h @@ -1,11 +1,11 @@ #pragma once -#include "processor.h" #include "flowgraph/flowgraph.h" +#include "processor.h" namespace satdump { - namespace viewer + namespace handlers { class Flowgraph_DatasetProductProcessor : public DatasetProductProcessor { @@ -21,11 +21,7 @@ namespace satdump int product_index = 0; public: - DatasetProductSource_Node(Flowgraph_DatasetProductProcessor *proc) - : NodeInternal("Dataset Product Source"), proc(proc) - { - outputs.push_back({"Product"}); - } + DatasetProductSource_Node(Flowgraph_DatasetProductProcessor *proc) : NodeInternal("Dataset Product Source"), proc(proc) { outputs.push_back({"Product"}); } void process() { @@ -65,5 +61,5 @@ namespace satdump void process(float *progress = nullptr); void renderUI(); }; - } -} \ No newline at end of file + } // namespace handlers +} // namespace satdump \ No newline at end of file diff --git a/src-core/handler/dataset/processor.h b/src-core/handlers/dataset/processor.h similarity index 92% rename from src-core/handler/dataset/processor.h rename to src-core/handlers/dataset/processor.h index 910111843..ccce06848 100644 --- a/src-core/handler/dataset/processor.h +++ b/src-core/handlers/dataset/processor.h @@ -1,11 +1,11 @@ #pragma once -#include "dataset_handler.h" #include "core/params.h" +#include "dataset_handler.h" namespace satdump { - namespace viewer + namespace handlers { class DatasetProductProcessor { @@ -43,9 +43,7 @@ namespace satdump }; public: - DatasetProductProcessor(DatasetHandler *dh, Handler *dp, nlohmann::json p) - : dataset_handler(dh), dataset_product_handler(dp), - name(p["name"]), processor(p["processor"]) + DatasetProductProcessor(DatasetHandler *dh, Handler *dp, nlohmann::json p) : dataset_handler(dh), dataset_product_handler(dp), name(p["name"]), processor(p["processor"]) { if (p.contains("cfg")) params = p["cfg"]; @@ -78,5 +76,5 @@ namespace satdump } } }; - } -} \ No newline at end of file + } // namespace handlers +} // namespace satdump \ No newline at end of file diff --git a/src-core/handler/dummy_handler.h b/src-core/handlers/dummy_handler.h similarity index 92% rename from src-core/handler/dummy_handler.h rename to src-core/handlers/dummy_handler.h index 748f3e850..e3078036a 100644 --- a/src-core/handler/dummy_handler.h +++ b/src-core/handlers/dummy_handler.h @@ -8,7 +8,7 @@ namespace satdump { - namespace viewer + namespace handlers { /** * @brief Dummy handler @@ -36,5 +36,5 @@ namespace satdump std::string getID() { return "dummy"; } }; - } -} \ No newline at end of file + } // namespace handlers +} // namespace satdump \ No newline at end of file diff --git a/src-core/handler/handler.cpp b/src-core/handlers/handler.cpp similarity index 98% rename from src-core/handler/handler.cpp rename to src-core/handlers/handler.cpp index 5a3a5f5e3..bf5dcbd30 100644 --- a/src-core/handler/handler.cpp +++ b/src-core/handlers/handler.cpp @@ -1,15 +1,13 @@ #include "handler.h" + #include "core/style.h" #include "imgui/imgui.h" #include "logger.h" - -//// TODOREWORK? -#include "product/image_product_handler.h" #include namespace satdump { - namespace viewer + namespace handlers { inline ImGuiTreeNodeFlags nodeFlags(std::shared_ptr &h, bool sec) { @@ -149,5 +147,5 @@ namespace satdump } nlohmann::json Handler::getConfig() { return {}; } - } // namespace viewer + } // namespace handlers } // namespace satdump \ No newline at end of file diff --git a/src-core/handler/handler.h b/src-core/handlers/handler.h similarity index 99% rename from src-core/handler/handler.h rename to src-core/handlers/handler.h index f2ad0293e..c38945fd6 100644 --- a/src-core/handler/handler.h +++ b/src-core/handlers/handler.h @@ -15,7 +15,7 @@ namespace satdump { - namespace viewer + namespace handlers { /** * @brief SatDump's handler base class. @@ -153,5 +153,5 @@ namespace satdump public: virtual std::string getID() = 0; // TODOREWORK }; - } // namespace viewer + } // namespace handlers } // namespace satdump \ No newline at end of file diff --git a/src-core/handler/image/image_handler.cpp b/src-core/handlers/image/image_handler.cpp similarity index 99% rename from src-core/handler/image/image_handler.cpp rename to src-core/handlers/image/image_handler.cpp index 821579c77..850006949 100644 --- a/src-core/handler/image/image_handler.cpp +++ b/src-core/handlers/image/image_handler.cpp @@ -23,7 +23,7 @@ #include "imgui/dialogs/pfd_utils.h" // TODOREWORK // TODOREWORK! -#include "handler/vector/shapefile_handler.h" +#include "handlers/vector/shapefile_handler.h" #include "products2/image/channel_transform.h" #include "resources.h" #include @@ -36,7 +36,7 @@ namespace satdump { - namespace viewer + namespace handlers { ImageHandler::ImageHandler() { @@ -452,5 +452,5 @@ namespace satdump image_calib_valid = true; } } - } // namespace viewer + } // namespace handlers } // namespace satdump diff --git a/src-core/handler/image/image_handler.h b/src-core/handlers/image/image_handler.h similarity index 98% rename from src-core/handler/image/image_handler.h rename to src-core/handlers/image/image_handler.h index 1f9aaecca..771840542 100644 --- a/src-core/handler/image/image_handler.h +++ b/src-core/handlers/image/image_handler.h @@ -12,7 +12,7 @@ namespace satdump { - namespace viewer + namespace handlers { class ImageHandler : public Handler, public ProcessingHandler { @@ -83,5 +83,5 @@ namespace satdump std::string getID() { return "image_handler"; } }; - } // namespace viewer + } // namespace handlers } // namespace satdump \ No newline at end of file diff --git a/src-core/handler/processing_handler.h b/src-core/handlers/processing_handler.h similarity index 97% rename from src-core/handler/processing_handler.h rename to src-core/handlers/processing_handler.h index 9bd161a94..2d80e4695 100644 --- a/src-core/handler/processing_handler.h +++ b/src-core/handlers/processing_handler.h @@ -9,7 +9,7 @@ namespace satdump { - namespace viewer + namespace handlers { /** * @brief ProcessingHandler base class @@ -85,5 +85,5 @@ namespace satdump static std::string getID(); static std::shared_ptr getInstance(); }; - } // namespace viewer + } // namespace handlers } // namespace satdump \ No newline at end of file diff --git a/src-core/handler/product/image_product_handler.cpp b/src-core/handlers/product/image_product_handler.cpp similarity index 99% rename from src-core/handler/product/image_product_handler.cpp rename to src-core/handlers/product/image_product_handler.cpp index 5b6135d04..895917aaf 100644 --- a/src-core/handler/product/image_product_handler.cpp +++ b/src-core/handlers/product/image_product_handler.cpp @@ -15,7 +15,7 @@ namespace satdump { - namespace viewer + namespace handlers { ImageProductHandler::ImageProductHandler(std::shared_ptr p, bool dataset_mode) : ProductHandler(p, dataset_mode, [p](auto &c) { return products::check_expression_product_composite((products::ImageProduct *)p.get(), c["expression"]); }) @@ -316,5 +316,5 @@ namespace satdump } void ImageProductHandler::drawContents(ImVec2 win_size) { img_handler->drawContents(win_size); } - } // namespace viewer + } // namespace handlers } // namespace satdump diff --git a/src-core/handler/product/image_product_handler.h b/src-core/handlers/product/image_product_handler.h similarity index 97% rename from src-core/handler/product/image_product_handler.h rename to src-core/handlers/product/image_product_handler.h index 263e39892..b9af3c13f 100644 --- a/src-core/handler/product/image_product_handler.h +++ b/src-core/handlers/product/image_product_handler.h @@ -7,7 +7,7 @@ namespace satdump { - namespace viewer + namespace handlers { class ImageProductHandler : public ProductHandler { @@ -72,5 +72,5 @@ namespace satdump std::string getID() { return "image_product_handler"; } }; - } // namespace viewer + } // namespace handlers } // namespace satdump \ No newline at end of file diff --git a/src-core/handler/product/product_handler.cpp b/src-core/handlers/product/product_handler.cpp similarity index 99% rename from src-core/handler/product/product_handler.cpp rename to src-core/handlers/product/product_handler.cpp index d9435cc0d..329b4393c 100644 --- a/src-core/handler/product/product_handler.cpp +++ b/src-core/handlers/product/product_handler.cpp @@ -10,7 +10,7 @@ namespace satdump { - namespace viewer + namespace handlers { ProductHandler::ProductHandler(std::shared_ptr p, bool dataset_mode, std::function filterPreset) : product(p) { @@ -204,5 +204,5 @@ namespace satdump } void ProductHandler::saveResult(std::string directory) { throw satdump_exception("saveResult NOT implemented for this handler! => " + directory); } - } // namespace viewer + } // namespace handlers } // namespace satdump \ No newline at end of file diff --git a/src-core/handler/product/product_handler.h b/src-core/handlers/product/product_handler.h similarity index 87% rename from src-core/handler/product/product_handler.h rename to src-core/handlers/product/product_handler.h index aa945d9db..ceae77f97 100644 --- a/src-core/handler/product/product_handler.h +++ b/src-core/handlers/product/product_handler.h @@ -10,11 +10,12 @@ #include "nlohmann/json.hpp" #include "products2/product.h" #include +#include #include namespace satdump { - namespace viewer + namespace handlers { /** * @brief Product handler base class. @@ -81,5 +82,14 @@ namespace satdump std::string getID() { return "product_handler"; }; }; - } // namespace viewer + + /** + * @brief Get the appropriate ProductHandler for the + * provided products. + * + * @param product product, loaded with loadProducts() + * @return appropriate handler pointer + */ + std::shared_ptr getProductHandlerForProduct(std::shared_ptr product); + } // namespace handlers } // namespace satdump \ No newline at end of file diff --git a/src-core/handlers/product/product_handler_init.cpp b/src-core/handlers/product/product_handler_init.cpp new file mode 100644 index 000000000..6b3967f32 --- /dev/null +++ b/src-core/handlers/product/product_handler_init.cpp @@ -0,0 +1,26 @@ +#include "product_handler.h" + +#include "logger.h" + +#include "handlers/product/image_product_handler.h" +#include "handlers/product/punctiform_product_handler.h" + +namespace satdump +{ + namespace handlers + { + std::shared_ptr getProductHandlerForProduct(std::shared_ptr prod) + { + std::shared_ptr prod_h; + + if (prod->type == "image") + prod_h = std::make_shared(prod, true); + else if (prod->type == "punctiform") + prod_h = std::make_shared(prod, true); + else + logger->error("TODOREWORK!!!!!! Actually handle loading properly..."); + + return prod_h; + } + } // namespace handlers +} // namespace satdump \ No newline at end of file diff --git a/src-core/handler/product/punctiform_product_handler.cpp b/src-core/handlers/product/punctiform_product_handler.cpp similarity index 99% rename from src-core/handler/product/punctiform_product_handler.cpp rename to src-core/handlers/product/punctiform_product_handler.cpp index 82418d2f2..18cc69f8f 100644 --- a/src-core/handler/product/punctiform_product_handler.cpp +++ b/src-core/handlers/product/punctiform_product_handler.cpp @@ -10,7 +10,7 @@ namespace satdump { - namespace viewer + namespace handlers { PunctiformProductHandler::PunctiformProductHandler(std::shared_ptr p, bool dataset_mode) : ProductHandler(p, dataset_mode) { @@ -189,5 +189,5 @@ namespace satdump img_handler.drawContents(win_size); } } - } // namespace viewer + } // namespace handlers } // namespace satdump diff --git a/src-core/handler/product/punctiform_product_handler.h b/src-core/handlers/product/punctiform_product_handler.h similarity index 94% rename from src-core/handler/product/punctiform_product_handler.h rename to src-core/handlers/product/punctiform_product_handler.h index 6dd8977cb..ce0e4345c 100644 --- a/src-core/handler/product/punctiform_product_handler.h +++ b/src-core/handlers/product/punctiform_product_handler.h @@ -1,12 +1,12 @@ #pragma once -#include "handler/image/image_handler.h" +#include "handlers/image/image_handler.h" #include "product_handler.h" #include "products2/punctiform_product.h" namespace satdump { - namespace viewer + namespace handlers { class PunctiformProductHandler : public ProductHandler { @@ -56,5 +56,5 @@ namespace satdump std::string getID() { return "punctiform_product_handler"; } }; - } // namespace viewer + } // namespace handlers } // namespace satdump \ No newline at end of file diff --git a/src-core/handler/projection/proj_ui.h b/src-core/handlers/projection/proj_ui.h similarity index 100% rename from src-core/handler/projection/proj_ui.h rename to src-core/handlers/projection/proj_ui.h diff --git a/src-core/handler/projection/projection_handler.cpp b/src-core/handlers/projection/projection_handler.cpp similarity index 98% rename from src-core/handler/projection/projection_handler.cpp rename to src-core/handlers/projection/projection_handler.cpp index ed3f10199..dc27a8adc 100644 --- a/src-core/handler/projection/projection_handler.cpp +++ b/src-core/handlers/projection/projection_handler.cpp @@ -13,7 +13,7 @@ namespace satdump { - namespace viewer + namespace handlers { ProjectionHandler::ProjectionHandler() { @@ -144,5 +144,5 @@ namespace satdump } void ProjectionHandler::drawContents(ImVec2 win_size) { img_handler.drawContents(win_size); } - } // namespace viewer + } // namespace handlers } // namespace satdump diff --git a/src-core/handler/projection/projection_handler.h b/src-core/handlers/projection/projection_handler.h similarity index 96% rename from src-core/handler/projection/projection_handler.h rename to src-core/handlers/projection/projection_handler.h index 4d48ed224..d9f4cc16d 100644 --- a/src-core/handler/projection/projection_handler.h +++ b/src-core/handlers/projection/projection_handler.h @@ -6,7 +6,7 @@ namespace satdump { - namespace viewer + namespace handlers { class ProjectionHandler : public Handler, public ProcessingHandler { @@ -53,5 +53,5 @@ namespace satdump std::string getName() { return "ProjectionToRename"; } std::string getID() { return "projection_handler"; } }; - } // namespace viewer + } // namespace handlers } // namespace satdump \ No newline at end of file diff --git a/src-core/handler/trash/trash_handler.cpp b/src-core/handlers/trash/trash_handler.cpp similarity index 91% rename from src-core/handler/trash/trash_handler.cpp rename to src-core/handlers/trash/trash_handler.cpp index 4949f3d9b..b0085ab03 100644 --- a/src-core/handler/trash/trash_handler.cpp +++ b/src-core/handlers/trash/trash_handler.cpp @@ -2,7 +2,7 @@ namespace satdump { - namespace viewer + namespace handlers { TrashHandler::TrashHandler() { handler_tree_icon = u8"\uf014"; } @@ -21,5 +21,5 @@ namespace satdump nlohmann::json p; return p; } - } // namespace viewer + } // namespace handlers } // namespace satdump diff --git a/src-core/handler/trash/trash_handler.h b/src-core/handlers/trash/trash_handler.h similarity index 73% rename from src-core/handler/trash/trash_handler.h rename to src-core/handlers/trash/trash_handler.h index 70d75ab0a..7564604b9 100644 --- a/src-core/handler/trash/trash_handler.h +++ b/src-core/handlers/trash/trash_handler.h @@ -1,11 +1,21 @@ #pragma once +/** + * @file trash_handler.h + */ + #include "../handler.h" namespace satdump { - namespace viewer + namespace handlers { + /** + * @brief A trash handler. + * + * Does what it says. Dragging anything on here + * will simply discard it! + */ class TrashHandler : public Handler { public: @@ -29,5 +39,5 @@ namespace satdump std::string getID() { return "trash_handler"; } }; - } // namespace viewer + } // namespace handlers } // namespace satdump \ No newline at end of file diff --git a/src-core/handler/tree.h b/src-core/handlers/tree.h similarity index 100% rename from src-core/handler/tree.h rename to src-core/handlers/tree.h diff --git a/src-core/handler/vector/dbf_file/dbf_file.cpp b/src-core/handlers/vector/dbf_file/dbf_file.cpp similarity index 100% rename from src-core/handler/vector/dbf_file/dbf_file.cpp rename to src-core/handlers/vector/dbf_file/dbf_file.cpp diff --git a/src-core/handler/vector/dbf_file/dbf_file.h b/src-core/handlers/vector/dbf_file/dbf_file.h similarity index 100% rename from src-core/handler/vector/dbf_file/dbf_file.h rename to src-core/handlers/vector/dbf_file/dbf_file.h diff --git a/src-core/handler/vector/shapefile_handler.cpp b/src-core/handlers/vector/shapefile_handler.cpp similarity index 99% rename from src-core/handler/vector/shapefile_handler.cpp rename to src-core/handlers/vector/shapefile_handler.cpp index 38d35289a..a097585ba 100644 --- a/src-core/handler/vector/shapefile_handler.cpp +++ b/src-core/handlers/vector/shapefile_handler.cpp @@ -9,7 +9,7 @@ namespace satdump { - namespace viewer + namespace handlers { ShapefileHandler::ShapefileHandler() { handler_tree_icon = u8"\uf84c"; } @@ -169,5 +169,5 @@ namespace satdump pointDraw(p); } } - } // namespace viewer + } // namespace handlers } // namespace satdump diff --git a/src-core/handler/vector/shapefile_handler.h b/src-core/handlers/vector/shapefile_handler.h similarity index 80% rename from src-core/handler/vector/shapefile_handler.h rename to src-core/handlers/vector/shapefile_handler.h index 3fea20d1a..5829dd053 100644 --- a/src-core/handler/vector/shapefile_handler.h +++ b/src-core/handlers/vector/shapefile_handler.h @@ -7,7 +7,7 @@ namespace satdump { - namespace viewer + namespace handlers { class ShapefileHandler : public Handler { @@ -22,8 +22,7 @@ namespace satdump ImVec4 color_to_draw = {0, 1, 0, 1}; - void draw_to_image(image::Image &img, - std::function(double, double, double, double)> projectionFunc); + void draw_to_image(image::Image &img, std::function(double, double, double, double)> projectionFunc); // The Rest void drawMenu(); @@ -37,5 +36,5 @@ namespace satdump std::string getID() { return "shapefile_handler"; } }; - } // namespace viewer + } // namespace handlers } // namespace satdump \ No newline at end of file diff --git a/src-core/products2/product_process.cpp b/src-core/products2/product_process.cpp index 3ba48283a..76a1d67b5 100644 --- a/src-core/products2/product_process.cpp +++ b/src-core/products2/product_process.cpp @@ -1,9 +1,9 @@ #include "product_process.h" #include "logger.h" -#include "handler/product/product_handler.h" -#include "handler/product/image_product_handler.h" -#include "handler/product/punctiform_product_handler.h" +#include "handlers/product/image_product_handler.h" +#include "handlers/product/product_handler.h" +#include "handlers/product/punctiform_product_handler.h" namespace satdump { @@ -11,13 +11,7 @@ namespace satdump { // TODOREWORK? void process_product_with_handler(std::shared_ptr p, std::string directory) { - std::shared_ptr handler; - if (p->type == "image") - handler = std::make_shared(p); - else if (p->type == "punctiform") - handler = std::make_shared(p); - else - logger->critical("TODOREWORK"); + std::shared_ptr handler = handlers::getProductHandlerForProduct(p); auto instr_cfg = handler->getInstrumentCfg(); if (instr_cfg.contains("presets")) @@ -30,5 +24,5 @@ namespace satdump } } } - } -} \ No newline at end of file + } // namespace products +} // namespace satdump \ No newline at end of file diff --git a/src-interface/processing.cpp b/src-interface/processing.cpp index 56369e6df..59700547a 100644 --- a/src-interface/processing.cpp +++ b/src-interface/processing.cpp @@ -1,8 +1,8 @@ #define SATDUMP_DLL_EXPORT2 1 -#include #include "processing.h" -#include "logger.h" #include "core/pipeline.h" +#include "logger.h" +#include #include "core/config.h" #include "main_ui.h" @@ -17,11 +17,7 @@ namespace satdump namespace processing { - void process(std::string downlink_pipeline, - std::string input_level, - std::string input_file, - std::string output_file, - nlohmann::json parameters) + void process(std::string downlink_pipeline, std::string input_level, std::string input_file, std::string output_file, nlohmann::json parameters) { // Get pipeline std::optional pipeline = getPipelineFromName(downlink_pipeline); @@ -34,11 +30,7 @@ namespace satdump process(pipeline.value(), input_level, input_file, output_file, parameters); } - void process(Pipeline downlink_pipeline, - std::string input_level, - std::string input_file, - std::string output_file, - nlohmann::json parameters) + void process(Pipeline downlink_pipeline, std::string input_level, std::string input_file, std::string output_file, nlohmann::json parameters) { processing_mutex.lock(); is_processing = true; @@ -75,7 +67,7 @@ namespace satdump if (std::filesystem::exists(output_file + "/dataset.json")) { logger->info("Opening viewer!"); - viewer_app2->openProductOrDataset(output_file + "/dataset.json"); + viewer_app2->tryOpenFileInViewer(output_file + "/dataset.json"); } } @@ -85,5 +77,5 @@ namespace satdump SATDUMP_DLL2 std::shared_ptr>> ui_call_list = std::make_shared>>(); SATDUMP_DLL2 std::shared_ptr ui_call_list_mutex = std::make_shared(); SATDUMP_DLL2 bool is_processing = false; - } -} \ No newline at end of file + } // namespace processing +} // namespace satdump \ No newline at end of file diff --git a/src-interface/viewer2/dsp/cyclo_test.cpp b/src-interface/viewer2/dsp/cyclo_test.cpp index 896a21a18..3eaac9890 100644 --- a/src-interface/viewer2/dsp/cyclo_test.cpp +++ b/src-interface/viewer2/dsp/cyclo_test.cpp @@ -7,7 +7,7 @@ namespace satdump { - namespace viewer + namespace handlers { CycloHelperHandler::CycloHelperHandler() { @@ -158,5 +158,5 @@ namespace satdump constell->constel.draw(); } - } // namespace viewer + } // namespace handlers } // namespace satdump \ No newline at end of file diff --git a/src-interface/viewer2/dsp/cyclo_test.h b/src-interface/viewer2/dsp/cyclo_test.h index 1056cef7a..b5877fc52 100644 --- a/src-interface/viewer2/dsp/cyclo_test.h +++ b/src-interface/viewer2/dsp/cyclo_test.h @@ -1,6 +1,6 @@ #pragma once -#include "handler/handler.h" +#include "handlers/handler.h" #include "dsp/agc/agc.h" #include "dsp/clock_recovery/clock_recovery_mm.h" @@ -23,7 +23,7 @@ // TODOREWORK, move into plugin? Or Core? namespace satdump { - namespace viewer + namespace handlers { class CycloHelperHandler : public Handler { @@ -74,5 +74,5 @@ namespace satdump std::string getID() { return "cyclo_helper_handler"; } }; - } // namespace viewer + } // namespace handlers } // namespace satdump \ No newline at end of file diff --git a/src-interface/viewer2/dsp/newrec.cpp b/src-interface/viewer2/dsp/newrec.cpp index 178a50761..cbe56da41 100644 --- a/src-interface/viewer2/dsp/newrec.cpp +++ b/src-interface/viewer2/dsp/newrec.cpp @@ -8,7 +8,7 @@ namespace satdump { - namespace viewer + namespace handlers { NewRecHandler::NewRecHandler() { @@ -184,5 +184,5 @@ namespace satdump } ImGui::EndChild(); } - } // namespace viewer + } // namespace handlers } // namespace satdump diff --git a/src-interface/viewer2/dsp/newrec.h b/src-interface/viewer2/dsp/newrec.h index e1f115b3a..67dcac120 100644 --- a/src-interface/viewer2/dsp/newrec.h +++ b/src-interface/viewer2/dsp/newrec.h @@ -3,7 +3,7 @@ #include "dsp/device/dev.h" #include "dsp/device/options_displayer.h" #include "dsp/fft/fft_pan.h" -#include "handler/handler.h" +#include "handlers/handler.h" #include "common/widgets/fft_plot.h" #include "common/widgets/waterfall_plot.h" @@ -11,7 +11,7 @@ // TODOREWORK, move into plugin? Or Core? namespace satdump { - namespace viewer + namespace handlers { class NewRecHandler : public Handler { @@ -39,5 +39,5 @@ namespace satdump std::string getID() { return "newrec_test_handler"; } }; - } // namespace viewer + } // namespace handlers } // namespace satdump diff --git a/src-interface/viewer2/dsp/waterfall_test.cpp b/src-interface/viewer2/dsp/waterfall_test.cpp index 6a83a5357..0aa998b9d 100644 --- a/src-interface/viewer2/dsp/waterfall_test.cpp +++ b/src-interface/viewer2/dsp/waterfall_test.cpp @@ -3,7 +3,7 @@ namespace satdump { - namespace viewer + namespace handlers { WaterfallTestHandler::WaterfallTestHandler() { @@ -52,10 +52,7 @@ namespace satdump listenTh = std::thread(fun); } - WaterfallTestHandler::~WaterfallTestHandler() - { - delete[] fft_buffer; - } + WaterfallTestHandler::~WaterfallTestHandler() { delete[] fft_buffer; } void WaterfallTestHandler::drawMenu() { @@ -101,7 +98,9 @@ namespace satdump ImGui::SetNextWindowSizeConstraints(ImVec2((right_width + offset * ui_scale), 50), ImVec2((right_width + offset * ui_scale), wf_size)); ImGui::SetNextWindowSize(ImVec2((right_width + offset * ui_scale), show_waterfall ? waterfall_ratio * wf_size : wf_size)); ImGui::SetNextWindowPos(ImVec2(left_width, 25 * ui_scale)); - if (ImGui::Begin("#fft", &t, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse)) + if (ImGui::Begin("#fft", &t, + ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoScrollbar | + ImGuiWindowFlags_NoScrollWithMouse)) { ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 9 * ui_scale); fft_plot->draw({float(wfft_widht), fft_height}); @@ -117,5 +116,5 @@ namespace satdump } ImGui::EndChild(); } - } -} \ No newline at end of file + } // namespace handlers +} // namespace satdump \ No newline at end of file diff --git a/src-interface/viewer2/dsp/waterfall_test.h b/src-interface/viewer2/dsp/waterfall_test.h index 5b659607b..b74cb7e6f 100644 --- a/src-interface/viewer2/dsp/waterfall_test.h +++ b/src-interface/viewer2/dsp/waterfall_test.h @@ -1,6 +1,6 @@ #pragma once -#include "handler/handler.h" +#include "handlers/handler.h" #include "common/widgets/fft_plot.h" #include "common/widgets/waterfall_plot.h" @@ -12,7 +12,7 @@ // TODOREWORK, move into plugin? Or Core? namespace satdump { - namespace viewer + namespace handlers { class WaterfallTestHandler : public Handler { @@ -37,5 +37,5 @@ namespace satdump std::string getID() { return "waterfall_test_handler"; } }; - } -} \ No newline at end of file + } // namespace handlers +} // namespace satdump \ No newline at end of file diff --git a/src-interface/viewer2/viewer.cpp b/src-interface/viewer2/viewer.cpp index 137817558..4437b82d2 100644 --- a/src-interface/viewer2/viewer.cpp +++ b/src-interface/viewer2/viewer.cpp @@ -12,12 +12,12 @@ #include "core/style.h" #include "dsp/cyclo_test.h" #include "dsp/flowgraph/dsp_flowgraph_handler.h" -#include "handler/dataset/dataset_handler.h" -#include "handler/dummy_handler.h" -#include "handler/product/image_product_handler.h" // TODOREWORK CLEAN -#include "handler/projection/projection_handler.h" -#include "handler/trash/trash_handler.h" -#include "handler/vector/shapefile_handler.h" +#include "handlers/dataset/dataset_handler.h" +#include "handlers/dummy_handler.h" +#include "handlers/product/image_product_handler.h" // TODOREWORK CLEAN +#include "handlers/projection/projection_handler.h" +#include "handlers/trash/trash_handler.h" +#include "handlers/vector/shapefile_handler.h" // TODOREWORK #include "resources.h" @@ -35,11 +35,11 @@ namespace satdump { ViewerApplication::ViewerApplication() : Application("viewer") { - master_handler = std::make_shared("MasterHandlerViewer"); + master_handler = std::make_shared("MasterHandlerViewer"); // Add trashcan - trash_handler = std::make_shared("TrashHandlerViewer"); - auto trash_h = std::make_shared(); + trash_handler = std::make_shared("TrashHandlerViewer"); + auto trash_h = std::make_shared(); trash_h->setCanBeDragged(false); trash_handler->addSubHandler(trash_h); trash_handler->setCanBeDraggedTo(false); @@ -49,19 +49,21 @@ namespace satdump [this](const imgui_utils::FileDropEvent &v) { for (auto &f : v.files) - openProductOrDataset(f); + tryOpenFileInViewer(f); }); + // TODOREWORK. Returns the last selected handler of a specific type if available eventBus->register_handler( [this](const GetLastSelectedOfTypeEvent &v) { if (last_selected_handler.count(v.type)) v.h = last_selected_handler[v.type]; else - v.h = 0; + v.h = nullptr; }); - openProductOrDataset("/home/alan/Downloads/SatDump_NEWPRODS/metop_test/dataset.json"); + // TODOREWORK remove + tryOpenFileInViewer("/home/alan/Downloads/SatDump_NEWPRODS/metop_test/dataset.json"); } ViewerApplication::~ViewerApplication() @@ -101,13 +103,11 @@ namespace satdump { // Handle File Stuff TODOREWORK? { - if (file_open_dialog && file_open_dialog->is_ready()) + if (file_open_dialog.update()) { - std::string prod_path = file_open_dialog->result(); - delete file_open_dialog; - file_open_dialog = nullptr; + std::string prod_path = file_open_dialog.getPath(); if (prod_path.size() > 0) - openProductOrDataset(prod_path); + tryOpenFileInViewer(prod_path); else logger->trace("No file selected"); } @@ -115,48 +115,49 @@ namespace satdump if (ImGui::BeginMenuBar()) { + // Main "Open" menu, for files, other handlers, etc if (ImGui::BeginMenu("File")) { - if (ImGui::MenuItem("Open File") && !file_open_dialog) // TODOREWORK switch to general thing - file_open_dialog = new fileutils::FileSelTh({{"All Files", "*"}}, ""); // TODOREWORK remember path? + file_open_dialog.render("Open File", "Open File", "", {{"All Files", "*"}}); + // TODOREWORK remove if (ImGui::BeginMenu("Hardcoded")) { if (ImGui::MenuItem("Load KMSS")) - openProductOrDataset("/home/alan/Downloads/SatDump_NEWPRODS/KMSS_24/dataset.json"); + tryOpenFileInViewer("/home/alan/Downloads/SatDump_NEWPRODS/KMSS_24/dataset.json"); if (ImGui::MenuItem("Load Sterna")) - openProductOrDataset("/home/alan/Downloads/SatDump_NEWPRODS/aws_pfm_cadu/dataset.json"); + tryOpenFileInViewer("/home/alan/Downloads/SatDump_NEWPRODS/aws_pfm_cadu/dataset.json"); if (ImGui::MenuItem("Load MSUGS")) - openProductOrDataset("/home/alan/Downloads/20241231_132953_ARKTIKA-M 2_dat/MSUGS_VIS1/product.cbor"); + tryOpenFileInViewer("/home/alan/Downloads/20241231_132953_ARKTIKA-M 2_dat/MSUGS_VIS1/product.cbor"); if (ImGui::MenuItem("Load MSUGS 2")) - openProductOrDataset("/home/alan/Downloads/SatDump_NEWPRODS/20250104_071415_ELEKTRO-L_3_dat/dataset.json"); + tryOpenFileInViewer("/home/alan/Downloads/SatDump_NEWPRODS/20250104_071415_ELEKTRO-L_3_dat/dataset.json"); if (ImGui::MenuItem("Load MetOp")) - openProductOrDataset("/home/alan/Downloads/SatDump_NEWPRODS/metop_test/dataset.json"); + tryOpenFileInViewer("/home/alan/Downloads/SatDump_NEWPRODS/metop_test/dataset.json"); if (ImGui::MenuItem("Load L3")) - openProductOrDataset("/data_ssd/ELEKTRO-L3/20250104_071415_ELEKTRO-L 3.dat_OUT/dataset.json"); + tryOpenFileInViewer("/data_ssd/ELEKTRO-L3/20250104_071415_ELEKTRO-L 3.dat_OUT/dataset.json"); if (ImGui::MenuItem("Load JPSS-1")) - openProductOrDataset("/home/alan/Downloads/SatDump_NEWPRODS/202411271228_NOAA_20/dataset.json"); + tryOpenFileInViewer("/home/alan/Downloads/SatDump_NEWPRODS/202411271228_NOAA_20/dataset.json"); if (ImGui::MenuItem("Load JPSS-2")) - openProductOrDataset("/home/alan/Downloads/SatDump_NEWPRODS/n21_day/dataset.json"); + tryOpenFileInViewer("/home/alan/Downloads/SatDump_NEWPRODS/n21_day/dataset.json"); if (ImGui::MenuItem("Load APT")) - openProductOrDataset("/home/alan/Downloads/audio_137912500Hz_11-39-56_04-03-2024_wav/dataset.json"); + tryOpenFileInViewer("/home/alan/Downloads/audio_137912500Hz_11-39-56_04-03-2024_wav/dataset.json"); if (ImGui::MenuItem("Load GOES")) - openProductOrDataset("/home/alan/Downloads/SatDump_NEWPRODS/goes_hrit_jvital2013_cadu/IMAGES/GOES-16/Full Disk/2024-04-17_18-00-20/product.cbor"); + tryOpenFileInViewer("/home/alan/Downloads/SatDump_NEWPRODS/goes_hrit_jvital2013_cadu/IMAGES/GOES-16/Full Disk/2024-04-17_18-00-20/product.cbor"); if (ImGui::MenuItem("Load Shapefile")) { - auto shp_h = std::make_shared(resources::getResourcePath("maps/ne_10m_admin_0_countries.shp")); + auto shp_h = std::make_shared(resources::getResourcePath("maps/ne_10m_admin_0_countries.shp")); master_handler->addSubHandler(shp_h); } if (ImGui::MenuItem("Load Shapefile FRA_1")) { - auto shp_h = std::make_shared("/home/alan/Downloads/gadm41_FRA_shp/gadm41_FRA_1.shp"); + auto shp_h = std::make_shared("/home/alan/Downloads/gadm41_FRA_shp/gadm41_FRA_1.shp"); master_handler->addSubHandler(shp_h); } if (ImGui::MenuItem("Load Shapefile FRA_2")) { - auto shp_h = std::make_shared("/home/alan/Downloads/gadm41_FRA_shp/gadm41_FRA_2.shp"); + auto shp_h = std::make_shared("/home/alan/Downloads/gadm41_FRA_shp/gadm41_FRA_2.shp"); master_handler->addSubHandler(shp_h); } @@ -165,24 +166,24 @@ namespace satdump ImGui::EndMenu(); } + if (ImGui::BeginMenu("Handler")) { if (ImGui::BeginMenu("Add")) - { - if (ImGui::MenuItem("Dataset")) - logger->error("Dummy Menu!"); + { // TODOREWORK? if (ImGui::MenuItem("Projection")) - master_handler->addSubHandler(std::make_shared()); + master_handler->addSubHandler(std::make_shared()); if (ImGui::MenuItem("DSP Flowgraph")) - master_handler->addSubHandler(std::make_shared()); + master_handler->addSubHandler(std::make_shared()); if (ImGui::MenuItem("Waterfall TEST")) - master_handler->addSubHandler(std::make_shared()); + master_handler->addSubHandler(std::make_shared()); if (ImGui::MenuItem("NewRec TEST")) - master_handler->addSubHandler(std::make_shared()); + master_handler->addSubHandler(std::make_shared()); if (ImGui::MenuItem("CycloHelper TEST")) - master_handler->addSubHandler(std::make_shared()); + master_handler->addSubHandler(std::make_shared()); ImGui::EndMenu(); } + if (curr_handler && ImGui::BeginMenu("Config")) { if (ImGui::MenuItem("JSON To Clipboard")) @@ -245,7 +246,7 @@ namespace satdump } } - void ViewerApplication::openProductOrDataset(std::string path) // TODOREWORK Rename! + void ViewerApplication::tryOpenFileInViewer(std::string path) { if (file_open_thread.joinable()) file_open_thread.join(); @@ -259,14 +260,13 @@ namespace satdump return; } - // TODOREWORK Load more than just image products if (std::filesystem::path(path).extension().string() == ".cbor") { logger->trace("Viewer loading product " + path); try { - std::shared_ptr prod_h = std::make_shared(products::loadProduct(path)); + auto prod_h = handlers::getProductHandlerForProduct(products::loadProduct(path)); master_handler->addSubHandler(prod_h); } catch (std::exception &e) @@ -282,7 +282,7 @@ namespace satdump { products::DataSet dataset; dataset.load(path); - std::shared_ptr dat_h = std::make_shared(std::filesystem::path(path).parent_path().string(), dataset); + std::shared_ptr dat_h = std::make_shared(std::filesystem::path(path).parent_path().string(), dataset); master_handler->addSubHandler(dat_h); } catch (std::exception &e) @@ -294,7 +294,7 @@ namespace satdump { logger->trace("Viewer loading shapefile " + path); - master_handler->addSubHandler(std::make_shared(path)); + master_handler->addSubHandler(std::make_shared(path)); } else { @@ -303,7 +303,7 @@ namespace satdump image::Image img; image::load_img(img, path); if (img.size() > 0) - master_handler->addSubHandler(std::make_shared(img, std::filesystem::path(path).stem().string())); + master_handler->addSubHandler(std::make_shared(img, std::filesystem::path(path).stem().string())); else logger->error("Could not open this file as image!"); // TODOREWORK Probably check before this? } diff --git a/src-interface/viewer2/viewer.h b/src-interface/viewer2/viewer.h index 9a8448c05..cd586f7d5 100644 --- a/src-interface/viewer2/viewer.h +++ b/src-interface/viewer2/viewer.h @@ -2,7 +2,8 @@ #include "../app.h" -#include "handler/handler.h" +#include "common/widgets/menuitem_fileopen.h" +#include "handlers/handler.h" #include "imgui/dialogs/widget.h" @@ -15,8 +16,8 @@ namespace satdump public: struct RenderLoadMenuElementsEvent { - std::shared_ptr &curr_handler; - std::shared_ptr &master_handler; + std::shared_ptr &curr_handler; + std::shared_ptr &master_handler; }; protected: @@ -30,26 +31,27 @@ namespace satdump void drawContents(); void drawMenuBar(); - std::shared_ptr curr_handler; - std::shared_ptr master_handler; - std::shared_ptr trash_handler; + // Viewer main handlers + std::shared_ptr curr_handler; + std::shared_ptr master_handler; + std::shared_ptr trash_handler; - // TODOREWORK File open - std::thread file_open_thread; - fileutils::FileSelTh *file_open_dialog = nullptr; + // File open + widget::MenuItemFileOpen file_open_dialog; + std::thread file_open_thread; // TODOREWORK? public: // TODOREWORK last opened by time - std::map> last_selected_handler; + std::map> last_selected_handler; struct GetLastSelectedOfTypeEvent { std::string type; - std::shared_ptr &h; + std::shared_ptr &h; }; public: - void openProductOrDataset(std::string path); + void tryOpenFileInViewer(std::string path); public: ViewerApplication();