Skip to content

Commit

Permalink
Ran clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
AKMaily committed Sep 5, 2024
1 parent 0c8085d commit 390adb5
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 54 deletions.
28 changes: 14 additions & 14 deletions src/handler.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#include "handler.hpp"
#include "../imgui-stdlib/imgui_stdlib.h"
#include "get_from_github.hpp"
#include "popups.hpp"
#include <functional>
#include <set>
#include <implot.h>
#include "popups.hpp"
#include "get_from_github.hpp"
#include "../imgui-stdlib/imgui_stdlib.h"
#include <set>

std::vector<AxisInfo> getDeviceInfos() {
std::vector<AxisInfo> axisInfos;
std::vector<Omniscope::Id> samplerDvcs; // store live devices
std::vector<std::pair<std::string, ImAxis_>> 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");
Expand Down Expand Up @@ -40,17 +40,17 @@ std::vector<AxisInfo> 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;
}

Expand Down
25 changes: 14 additions & 11 deletions src/handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@

#include "../ai_omniscope-v2-communication_sw/src/OmniscopeSampler.hpp"
#include "languages.hpp"
#include <implot.h>
#include <nlohmann/json.hpp>
#include <nlohmann/json_fwd.hpp>
#include <set>
#include <implot.h>

struct AxisInfo {
std::pair<Omniscope::Id, std::vector<std::pair<double, double>>&> data;
std::pair<std::string, ImAxis_> egu;
std::string timebase;
std::pair<Omniscope::Id, std::vector<std::pair<double, double>> &> data;
std::pair<std::string, ImAxis_> egu;
std::string timebase;

AxisInfo(
std::pair<Omniscope::Id, std::vector<std::pair<double, double>>&> data_,
std::pair<std::string, ImAxis_> egu_, std::string timebase_)
: data{data_}, egu{egu_}, timebase{timebase_} {}
AxisInfo(
std::pair<Omniscope::Id, std::vector<std::pair<double, double>> &> data_,
std::pair<std::string, ImAxis_> egu_, std::string timebase_)
: data{data_}, egu{egu_}, timebase{timebase_} {}
};

// global variables
Expand All @@ -30,10 +30,13 @@ inline std::map<Omniscope::Id, std::vector<std::pair<double, double>>>
captureData;

inline std::vector<AxisInfo> plotAxes;
void addPlots(const char *, const bool, std::function<void(double, std::string, ImAxis_, double, double)>);
void parseDeviceMetaData(Omniscope::MetaData, std::shared_ptr<OmniscopeDevice>&);
void addPlots(
const char *, const bool,
std::function<void(double, std::string, ImAxis_, double, double)>);
void parseDeviceMetaData(Omniscope::MetaData,
std::shared_ptr<OmniscopeDevice> &);
void initDevices();
void devicesList(bool const& flagPaused);
void devicesList(bool const &flagPaused);
void load_files(decltype(captureData) &, std::map<Omniscope::Id, std::string> &,
bool &);
void set_config(const std::string &);
Expand Down
37 changes: 20 additions & 17 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down Expand Up @@ -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 |

Check warning on line 106 in src/main.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-latest-C++ CI

bitwise operation between different enumeration types ‘ImPlotLocation_’ and ‘ImPlotLegendFlags_’ is deprecated [-Wdeprecated-enum-enum-conversion]
ImPlotLegendFlags_Outside);
auto auxFlagsMeasuring =

Check warning on line 108 in src/main.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-latest-C++ CI

unused variable ‘auxFlagsMeasuring’ [-Wunused-variable]
ImPlotAxisFlags_AutoFit | ImPlotAxisFlags_NoGridLines;
auto auxFlagsPaused = ImPlotAxisFlags_NoGridLines;

Check warning on line 110 in src/main.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-latest-C++ CI

unused variable ‘auxFlagsPaused’ [-Wunused-variable]
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
Expand Down
10 changes: 5 additions & 5 deletions src/saves_popup.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include <fstream>
#include <future>
#include <charconv>
#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 <charconv>
#include <fstream>
#include <future>

static void save(const Omniscope::Id &device,
const std::vector<std::pair<double, double>> &values,
Expand Down
10 changes: 5 additions & 5 deletions src/style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
#include <vector>
#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_) {

Expand Down Expand Up @@ -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++) {
Expand Down Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions src/style.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 390adb5

Please sign in to comment.