From 390adb5652b44f9eb0b023e8201b9970fd962443 Mon Sep 17 00:00:00 2001 From: AKMaily Date: Thu, 5 Sep 2024 08:38:23 +0200 Subject: [PATCH] Ran clang-format --- src/handler.cpp | 28 ++++++++++++++-------------- src/handler.hpp | 25 ++++++++++++++----------- src/main.cpp | 37 ++++++++++++++++++++----------------- src/saves_popup.cpp | 10 +++++----- src/style.cpp | 10 +++++----- src/style.hpp | 4 ++-- 6 files changed, 60 insertions(+), 54 deletions(-) diff --git a/src/handler.cpp b/src/handler.cpp index 22c1ecd0..bf806d32 100644 --- a/src/handler.cpp +++ b/src/handler.cpp @@ -1,16 +1,16 @@ #include "handler.hpp" +#include "../imgui-stdlib/imgui_stdlib.h" +#include "get_from_github.hpp" +#include "popups.hpp" #include -#include #include -#include "popups.hpp" -#include "get_from_github.hpp" -#include "../imgui-stdlib/imgui_stdlib.h" +#include std::vector getDeviceInfos() { std::vector axisInfos; std::vector samplerDvcs; // store live devices std::vector> assignedEgus; - if (sampler.has_value()) + if (sampler.has_value()) for (auto const &device : sampler->sampleDevices) { // TODO replace ADC counts with language variable std::string egu = device.first->getEgu().value_or("ADC counts"); @@ -40,17 +40,17 @@ std::vector getDeviceInfos() { *eguIterator, timebase}; axisInfos.push_back(axisInfo); } - } else + } else fmt::println("Error no device id found"); } - // also add loaded files into plotAxes - for (auto &[device, values] : captureData) - if (std::ranges::find(samplerDvcs, device.serial, - &Omniscope::Id::serial) == samplerDvcs.end()) { - axisInfos.push_back({{device, values}, - {"y [Volts]", ImAxis_Y1}, - std::to_string(device.sampleRate)}); - } + // also add loaded files into plotAxes + for (auto &[device, values] : captureData) + if (std::ranges::find(samplerDvcs, device.serial, &Omniscope::Id::serial) == + samplerDvcs.end()) { + axisInfos.push_back({{device, values}, + {"y [Volts]", ImAxis_Y1}, + std::to_string(device.sampleRate)}); + } return axisInfos; } diff --git a/src/handler.hpp b/src/handler.hpp index 9d0987d3..831c44d1 100644 --- a/src/handler.hpp +++ b/src/handler.hpp @@ -4,20 +4,20 @@ #include "../ai_omniscope-v2-communication_sw/src/OmniscopeSampler.hpp" #include "languages.hpp" +#include #include #include #include -#include struct AxisInfo { - std::pair>&> data; - std::pair egu; - std::string timebase; + std::pair> &> data; + std::pair egu; + std::string timebase; - AxisInfo( - std::pair>&> data_, - std::pair egu_, std::string timebase_) - : data{data_}, egu{egu_}, timebase{timebase_} {} + AxisInfo( + std::pair> &> data_, + std::pair egu_, std::string timebase_) + : data{data_}, egu{egu_}, timebase{timebase_} {} }; // global variables @@ -30,10 +30,13 @@ inline std::map>> captureData; inline std::vector plotAxes; -void addPlots(const char *, const bool, std::function); -void parseDeviceMetaData(Omniscope::MetaData, std::shared_ptr&); +void addPlots( + const char *, const bool, + std::function); +void parseDeviceMetaData(Omniscope::MetaData, + std::shared_ptr &); void initDevices(); -void devicesList(bool const& flagPaused); +void devicesList(bool const &flagPaused); void load_files(decltype(captureData) &, std::map &, bool &); void set_config(const std::string &); diff --git a/src/main.cpp b/src/main.cpp index aee0f868..775bf348 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -39,7 +39,7 @@ int main() { ImGuiWindowFlags_NoTitleBar); if (Development && ImGui::Button("Development")) - ImGui::OpenPopup("Development Colors"); + ImGui::OpenPopup("Development Colors"); // Popup-Window content if (ImGui::BeginPopup("Development Colors")) { @@ -91,37 +91,40 @@ int main() { // ############################ addPlots("Recording the data", ...) ImGui::Dummy({0.f, windowSize.y * .01f}); PushPlotRegionColors(); - ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, - windowSize.x * .009f); + ImGui::PushStyleVar(ImGuiStyleVar_ChildBorderSize, windowSize.x * .009f); ImGui::BeginChild("Record Data", {0.f, windowSize.y * 0.62f}, - ImGuiChildFlags_Border); + ImGuiChildFlags_Border); // Axes 1 to 3 // Check if time base for axes are same // check if egu and timescale for plot are same // error if third device is added - addPlots("Recording the data", flagPaused, [&flagPaused](double x_max, std::string yLabel, ImAxis_ axis, double yMin, double yMax) { - ImPlot::SetupLegend(ImPlotLocation_NorthEast | - ImPlotLegendFlags_Outside); - auto auxFlagsMeasuring = - ImPlotAxisFlags_AutoFit | ImPlotAxisFlags_NoGridLines; - auto auxFlagsPaused = ImPlotAxisFlags_NoGridLines; - ImPlot::SetupAxisTicks(ImAxis_Y1, -10, 200, 22, nullptr, true); + addPlots( + "Recording the data", flagPaused, + [&flagPaused](double x_max, std::string yLabel, ImAxis_ axis, + double yMin, double yMax) { + ImPlot::SetupLegend(ImPlotLocation_NorthEast | + ImPlotLegendFlags_Outside); + auto auxFlagsMeasuring = + ImPlotAxisFlags_AutoFit | ImPlotAxisFlags_NoGridLines; + auto auxFlagsPaused = ImPlotAxisFlags_NoGridLines; + ImPlot::SetupAxisTicks(ImAxis_Y1, -10, 200, 22, nullptr, true); - if(!flagPaused){ + if (!flagPaused) { ImPlot::SetupAxis(axis, yLabel.c_str(), ImPlotAxisFlags_AutoFit); ImPlot::SetupAxis(ImAxis_X1, "time [s]", ImPlotAxisFlags_AutoFit); ImPlot::SetupAxisLimits(axis, yMin - 2, yMax + 2, ImGuiCond_Always); - ImPlot::SetupAxisLimits(ImAxis_X1, x_max - 1, x_max + 9, ImGuiCond_Always); + ImPlot::SetupAxisLimits(ImAxis_X1, x_max - 1, x_max + 9, + ImGuiCond_Always); - }else{ + } else { ImPlot::SetupAxis(ImAxis_X1, "time [s]"); ImPlot::SetupAxis(axis, yLabel.c_str()); ImPlot::SetupAxisLimits(ImAxis_X1, 0, 10); ImPlot::SetupAxisLimits(axis, yMin - 2, yMax + 2); - } - }); - ImGui::EndChild(); // end child Record Data + } + }); + ImGui::EndChild(); // end child Record Data ImGui::PopStyleVar(); PopPlotRegionColors(); // ############################ Devicelist diff --git a/src/saves_popup.cpp b/src/saves_popup.cpp index 751f1d11..e5c3e642 100644 --- a/src/saves_popup.cpp +++ b/src/saves_popup.cpp @@ -1,11 +1,11 @@ -#include -#include -#include -#include "popups.hpp" -#include "look_up_saves.hpp" #include "imgui_stdlib.h" #include "languages.hpp" +#include "look_up_saves.hpp" +#include "popups.hpp" #include "style.hpp" +#include +#include +#include static void save(const Omniscope::Id &device, const std::vector> &values, diff --git a/src/style.cpp b/src/style.cpp index d9d402f3..9bde81fc 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -4,14 +4,14 @@ #include #define IMGUI_DEFINE_MATH_OPERATORS #define STB_IMAGE_IMPLEMENTATION -#include "style.hpp" +#include "../imgui-filebrowser/imfilebrowser.h" #include "../stb_image/stb_image.h" #include "imagesHeader.hpp" #include "imgui_internal.h" #include "jasonhandler.hpp" #include "languages.hpp" -#include "../imgui-filebrowser/imfilebrowser.h" #include "popups.hpp" +#include "style.hpp" void SetupImGuiStyle(bool bStyleDark_, float alpha_) { @@ -66,7 +66,7 @@ void SetupImGuiStyle(bool bStyleDark_, float alpha_) { colors[ImGuiCol_PlotHistogram] = {0.9f, 0.7f, 0.f, 1.f}; colors[ImGuiCol_PlotHistogramHovered] = {1.f, 0.6f, 0.f, 1.f}; colors[ImGuiCol_TextSelectedBg] = {0.26f, 0.59f, 0.98f, 0.35f}; - colors[ImGuiCol_DragDropTarget] = {0.2f, 0.2f, 0.2f, 0.35f}; + colors[ImGuiCol_DragDropTarget] = {0.2f, 0.2f, 0.2f, 0.35f}; if (bStyleDark_) { for (int i = 0; i < ImGuiCol_COUNT; i++) { @@ -498,8 +498,8 @@ void set_toolbar(const nlohmann::json &config, const nlohmann::json &language, (void *)(intptr_t)image_texture[PngRenderedCnt], ImVec2(image_width[PngRenderedCnt] * iconsSacle, image_height[PngRenderedCnt] * iconsSacle))) { - liveDvcs.clear(); // get updated live devices for saving - if (!loadedFiles.empty()) { + liveDvcs.clear(); // get updated live devices for saving + if (!loadedFiles.empty()) { has_loaded_file = true; for (const auto &[device, values] : captureData) if (!loadedFiles.contains(device)) diff --git a/src/style.hpp b/src/style.hpp index 8c6375c2..0377b4cb 100644 --- a/src/style.hpp +++ b/src/style.hpp @@ -22,8 +22,8 @@ void set_side_menu(const nlohmann::json &, bool &, bool &, void set_toolbar(const nlohmann::json &, const nlohmann::json &, bool &, const decltype(captureData) &); void PopupStyleEditor(); -void PushPlotRegionColors(); -void PopPlotRegionColors(); +void PushPlotRegionColors(); +void PopPlotRegionColors(); void SetDeviceMenuStyle(); namespace ImGui {