From 7b70854a96528d5442fe85caefef333f2ab32796 Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Wed, 31 Jan 2024 13:48:08 +0100 Subject: [PATCH] Make Arithmetic a normal GR block --- .../dashboard/defaultDashboard.flowgraph | 2 +- src/ui/CMakeLists.txt | 1 - .../assets/sampleDashboards/DemoDashboard.grc | 2 +- .../ExtendedDemoDashboard.grc | 6 ++--- .../Arithmetic.hpp} | 25 ++++++++----------- src/ui/flowgraph/arithmetic_block.h | 10 -------- src/ui/main.cpp | 4 +-- 7 files changed, 18 insertions(+), 32 deletions(-) rename src/ui/{flowgraph/arithmetic_block.cpp => blocks/Arithmetic.hpp} (53%) delete mode 100644 src/ui/flowgraph/arithmetic_block.h diff --git a/src/service/dashboard/defaultDashboard.flowgraph b/src/service/dashboard/defaultDashboard.flowgraph index 70d88aca..71476da0 100644 --- a/src/service/dashboard/defaultDashboard.flowgraph +++ b/src/service/dashboard/defaultDashboard.flowgraph @@ -2,7 +2,7 @@ blocks: - name: FFT id: FFT - name: sum sigs - id: Arithmetic + id: opendigitizer::Arithmetic - name: sine source 1 id: opendigitizer::SineSource parameters: diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 919ca252..a0f996b4 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -17,7 +17,6 @@ set(sources flowgraphitem.cpp dashboard.cpp flowgraph/datasink.cpp - flowgraph/arithmetic_block.cpp dashboardpage.cpp opendashboardpage.cpp imguiutils.cpp diff --git a/src/ui/assets/sampleDashboards/DemoDashboard.grc b/src/ui/assets/sampleDashboards/DemoDashboard.grc index 47b9b52d..53304bdc 100644 --- a/src/ui/assets/sampleDashboards/DemoDashboard.grc +++ b/src/ui/assets/sampleDashboards/DemoDashboard.grc @@ -1,6 +1,6 @@ blocks: - name: sum sigs - id: Arithmetic + id: opendigitizer::Arithmetic - name: FFT id: FFT - name: sine source 1 diff --git a/src/ui/assets/sampleDashboards/ExtendedDemoDashboard.grc b/src/ui/assets/sampleDashboards/ExtendedDemoDashboard.grc index 4ea408e0..63ff0f09 100644 --- a/src/ui/assets/sampleDashboards/ExtendedDemoDashboard.grc +++ b/src/ui/assets/sampleDashboards/ExtendedDemoDashboard.grc @@ -1,10 +1,10 @@ blocks: - name: sum sigs1 - id: Arithmetic + id: opendigitizer::Arithmetic - name: sum sigs2 - id: Arithmetic + id: opendigitizer::Arithmetic - name: sum sigs3 - id: Arithmetic + id: opendigitizer::Arithmetic - name: FFT id: FFT - name: sine source 3 diff --git a/src/ui/flowgraph/arithmetic_block.cpp b/src/ui/blocks/Arithmetic.hpp similarity index 53% rename from src/ui/flowgraph/arithmetic_block.cpp rename to src/ui/blocks/Arithmetic.hpp index 1516811e..b5bcaceb 100644 --- a/src/ui/flowgraph/arithmetic_block.cpp +++ b/src/ui/blocks/Arithmetic.hpp @@ -1,16 +1,17 @@ -#include "arithmetic_block.h" +#ifndef OPENDIGITIZER_ARITHMETIC_HPP +#define OPENDIGITIZER_ARITHMETIC_HPP -#include +#include -#include "../flowgraph.h" +namespace opendigitizer { template requires std::is_arithmetic_v -struct MathNode : public gr::Block> { - gr::PortIn in1{}; - gr::PortIn in2{}; +struct Arithmetic : public gr::Block> { + gr::PortIn in1; + gr::PortIn in2; - gr::PortOut out{}; + gr::PortOut out; gr::Annotated operation = std::string("+"); @@ -33,12 +34,8 @@ struct MathNode : public gr::Block> { } }; -ENABLE_REFLECTION_FOR_TEMPLATE_FULL((typename T), (MathNode), in1, in2, out, operation); +} // namespace opendigitizer -namespace DigitizerUi { +ENABLE_REFLECTION_FOR_TEMPLATE(opendigitizer::Arithmetic, in1, in2, out, operation) -void ArithmeticBlock::registerBlockType() { - BlockType::registry().addBlockType("Arithmetic"); -} - -} // namespace DigitizerUi +#endif diff --git a/src/ui/flowgraph/arithmetic_block.h b/src/ui/flowgraph/arithmetic_block.h deleted file mode 100644 index 6478f541..00000000 --- a/src/ui/flowgraph/arithmetic_block.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -namespace DigitizerUi { - -class ArithmeticBlock { -public: - static void registerBlockType(); -}; - -} // namespace DigitizerUi diff --git a/src/ui/main.cpp b/src/ui/main.cpp index b2b59834..1594a196 100644 --- a/src/ui/main.cpp +++ b/src/ui/main.cpp @@ -24,13 +24,13 @@ #include #include "app.h" +#include "blocks/Arithmetic.hpp" #include "blocks/RemoteSource.hpp" #include "blocks/SineSource.hpp" #include "dashboard.h" #include "dashboardpage.h" #include "fair_header.h" #include "flowgraph.h" -#include "flowgraph/arithmetic_block.h" #include "flowgraph/datasink.h" #include "flowgraphitem.h" #include "utils/TouchHandler.hpp" @@ -239,9 +239,9 @@ int main(int argc, char **argv) { DigitizerUi::DataSink::registerBlockType(); DigitizerUi::DataSinkSource::registerBlockType(); - DigitizerUi::ArithmeticBlock::registerBlockType(); DigitizerUi::BlockType::registry().addBlockType("opendigitizer::SineSource"); DigitizerUi::BlockType::registry().addBlockType("opendigitizer::RemoteSource"); + DigitizerUi::BlockType::registry().addBlockType("opendigitizer::Arithmetic"); DigitizerUi::BlockType::registry().addBlockType("FFT"); loadFonts(app);