Skip to content

Commit

Permalink
fixed call_once
Browse files Browse the repository at this point in the history
  • Loading branch information
R-Abbasi committed Aug 28, 2024
1 parent 79a434f commit 73179c5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 25 deletions.
2 changes: 1 addition & 1 deletion ai_omniscope-v2-communication_sw
47 changes: 23 additions & 24 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ int main() {
set_config(configpath);
nlohmann::json config = load_json_file(configpath);
set_json(config);
set_inital_config(config);
nlohmann::json language =
load_json_file(load_json<std::string>(config, "languagepath") +
load_json<std::string>(config, "language") + ".json");
// local variables
bool flagPaused{true}, development{false}, open_generate_training_data{false},
open_settings{false};
std::once_flag flag;
auto loadedFiles = captureData;
std::map<Omniscope::Id, std::string> loadedFilenames;

// main loop
auto render = [&]() {
std::call_once(flag, set_inital_config, std::ref(config));
SetupImGuiStyle(false, 0.99f);
ImGui::SetNextWindowPos({0.f, 0.f});
auto windowSize{ImGui::GetIO().DisplaySize};
Expand Down Expand Up @@ -88,31 +89,29 @@ int main() {
// 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](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](
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) {
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);
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);

} 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);
}
});
} 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::PopStyleVar();
PopPlotRegionColors();
Expand Down

0 comments on commit 73179c5

Please sign in to comment.