From 459a070796ae408d57fcce3bc396b7dd2ecbf58b Mon Sep 17 00:00:00 2001 From: Aang23 Date: Sun, 18 May 2025 20:05:55 +0200 Subject: [PATCH] Random small things --- plugins/bitview_app/main.cpp | 29 +++++++++++++++--------- plugins/wip_tracking_app/main.cpp | 22 +++++++++++++----- plugins/wip_tracking_app/station.h | 22 ++++++++++++++++++ src-core/handler/handler.h | 5 ---- src-core/handler/image/image_handler.cpp | 19 +++++++++------- src-interface/viewer2/viewer.cpp | 11 +-------- src-interface/viewer2/viewer.h | 2 ++ 7 files changed, 70 insertions(+), 40 deletions(-) create mode 100644 plugins/wip_tracking_app/station.h diff --git a/plugins/bitview_app/main.cpp b/plugins/bitview_app/main.cpp index 3b1ab9f22..4c2980f7a 100644 --- a/plugins/bitview_app/main.cpp +++ b/plugins/bitview_app/main.cpp @@ -1,29 +1,36 @@ +#include "core/module.h" #include "core/plugin.h" #include "logger.h" -#include "core/module.h" #include "app.h" #include "bitview.h" +#include "viewer2/viewer.h" class BitViewAppPlugin : public satdump::Plugin { public: - std::string getID() - { - return "bitview_app"; - } + std::string getID() { return "bitview_app"; } void init() { - // satdump::eventBus->register_handler(provideAppToRegister); - satdump::eventBus->register_handler(provideAppToRegister); + // TODOREWORK maybe a way to call up/init a handler? + satdump::eventBus->register_handler(renderViewerLoaderButton); } - static void provideAppToRegister(const satdump::viewer::RequestHandlersEvent &evt) + static void renderViewerLoaderButton(const satdump::viewer::ViewerApplication::RenderLoadMenuElementsEvent &evt) { - evt.h.push_back(std::make_shared()); - // evt.applications.push_back(std::make_shared()); - } + if (ImGui::BeginMenu("File")) + { + if (ImGui::BeginMenu("Others")) + { + if (ImGui::MenuItem("BitView")) + evt.master_handler->addSubHandler(std::make_shared()); + ImGui::EndMenu(); + } + + ImGui::EndMenu(); + } + } // TODOREWORK }; PLUGIN_LOADER(BitViewAppPlugin) \ No newline at end of file diff --git a/plugins/wip_tracking_app/main.cpp b/plugins/wip_tracking_app/main.cpp index 49699c50d..65d1c6616 100644 --- a/plugins/wip_tracking_app/main.cpp +++ b/plugins/wip_tracking_app/main.cpp @@ -4,6 +4,7 @@ #include "app.h" #include "tracking.h" +#include "viewer2/viewer.h" class WipTrackingAppPlugin : public satdump::Plugin { @@ -12,15 +13,24 @@ public: void init() { - // satdump::eventBus->register_handler(provideAppToRegister); - satdump::eventBus->register_handler(provideAppToRegister); + // TODOREWORK maybe a way to call up/init a handler? + satdump::eventBus->register_handler(renderViewerLoaderButton); } - static void provideAppToRegister(const satdump::viewer::RequestHandlersEvent &evt) + static void renderViewerLoaderButton(const satdump::viewer::ViewerApplication::RenderLoadMenuElementsEvent &evt) { - evt.h.push_back(std::make_shared()); - // evt.applications.push_back(std::make_shared()); - } + if (ImGui::BeginMenu("File")) + { + if (ImGui::BeginMenu("Others")) + { + if (ImGui::MenuItem("WIP Tracking")) + evt.master_handler->addSubHandler(std::make_shared()); + ImGui::EndMenu(); + } + + ImGui::EndMenu(); + } + } // TODOREWORK }; PLUGIN_LOADER(WipTrackingAppPlugin) \ No newline at end of file diff --git a/plugins/wip_tracking_app/station.h b/plugins/wip_tracking_app/station.h new file mode 100644 index 000000000..1fcb8a259 --- /dev/null +++ b/plugins/wip_tracking_app/station.h @@ -0,0 +1,22 @@ +#pragma once + +namespace satdump +{ + namespace tracking + { + enum backend_type_t + { + BKD_TYPE_PREDICT, + BKD_TYPE_NOVAS, + BKD_TYPE_HORIZONS, + }; + + class StationBackend + { + }; + + class Station + { + }; + } // namespace tracking +} // namespace satdump \ No newline at end of file diff --git a/src-core/handler/handler.h b/src-core/handler/handler.h index 6cd868f84..f2ad0293e 100644 --- a/src-core/handler/handler.h +++ b/src-core/handler/handler.h @@ -153,10 +153,5 @@ namespace satdump public: virtual std::string getID() = 0; // TODOREWORK }; - - struct RequestHandlersEvent - { - std::vector> &h; - }; } // namespace viewer } // namespace satdump \ No newline at end of file diff --git a/src-core/handler/image/image_handler.cpp b/src-core/handler/image/image_handler.cpp index 004c0c92e..821579c77 100644 --- a/src-core/handler/image/image_handler.cpp +++ b/src-core/handler/image/image_handler.cpp @@ -240,14 +240,17 @@ namespace satdump image_view.autoFitNextFrame |= ImGui::MenuItem("Fit"); image_view.select_crop_next |= ImGui::MenuItem("Crop"); - if (ImGui::MenuItem("Add To Proj")) + if (image_proj_valid) { - std::shared_ptr h; - eventBus->fire_event({"projection_handler", h}); - if (h) - h->addSubHandler(std::make_shared(get_current_img(), getName())); - else - logger->warn("No projection selected"); + if (ImGui::MenuItem("Add To Proj")) + { + std::shared_ptr h; + eventBus->fire_event({"projection_handler", h}); + if (h) + h->addSubHandler(std::make_shared(get_current_img(), getName())); + else + logger->warn("No projection selected"); + } } ImGui::EndMenuBar(); @@ -268,7 +271,7 @@ namespace satdump median_blur_img = getValueOrDefault(p["median_blur"], false); despeckle_img = getValueOrDefault(p["despeckle"], false); rotate180_image = getValueOrDefault(p["rotate180"], rotate180_image); - geocorrect_image = getValueOrDefault(p["geocorrect"], false); + geocorrect_image = getValueOrDefault(p["geocorrect"], geocorrect_image); brightness_contrast_image = getValueOrDefault(p["brightness_contrast"], false); brightness_contrast_brightness_image = getValueOrDefault(p["brightness_contrast_brightness"], 0); brightness_contrast_constrast_image = getValueOrDefault(p["brightness_contrast_constrast"], 0); diff --git a/src-interface/viewer2/viewer.cpp b/src-interface/viewer2/viewer.cpp index 239295e0d..445311268 100644 --- a/src-interface/viewer2/viewer.cpp +++ b/src-interface/viewer2/viewer.cpp @@ -177,15 +177,6 @@ namespace satdump master_handler->addSubHandler(std::make_shared()); if (ImGui::MenuItem("DSP Flowgraph")) master_handler->addSubHandler(std::make_shared()); - if (ImGui::MenuItem("BitView TEST")) - { - std::vector> e; - eventBus->fire_event({e}); - // if (e.size() > 0) - // master_handler->addSubHandler(e[0]); - for (auto &h : e) - master_handler->addSubHandler(h); - } if (ImGui::MenuItem("Waterfall TEST")) master_handler->addSubHandler(std::make_shared()); if (ImGui::MenuItem("NewRec TEST")) @@ -216,7 +207,7 @@ namespace satdump } } - eventBus->fire_event({}); + eventBus->fire_event({curr_handler, master_handler}); ImGui::EndMenuBar(); } diff --git a/src-interface/viewer2/viewer.h b/src-interface/viewer2/viewer.h index 727bdf31a..9a8448c05 100644 --- a/src-interface/viewer2/viewer.h +++ b/src-interface/viewer2/viewer.h @@ -15,6 +15,8 @@ namespace satdump public: struct RenderLoadMenuElementsEvent { + std::shared_ptr &curr_handler; + std::shared_ptr &master_handler; }; protected: