Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
R-Abbasi committed Sep 2, 2024
1 parent b60c437 commit 0e728b5
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/saves_popup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ static void save(const Omniscope::Id &device,
device.sampleRate);
std::string fileContent;
fileContent.resize_and_overwrite(
// ten bytes for each y_value, nine for the number
// and one new line as a separator between the numbers
values.size() * 10, // take const ref to values
[&values = std::as_const(values), &y_indx](char *begin, std::size_t) {
auto end = begin;
constexpr unsigned factor{100'000};
for (; y_indx < values.size(); y_indx++) {
double value = values[y_indx].second * factor;
value = std::floor(value);
value /= factor;
end = std::to_chars(end, end + 9, value).ptr;
*end++ = '\n';
}
return end - begin;
});
// ten bytes for each y_value, nine for the number
// and one new line as a separator between the numbers
values.size() * 10, // take const ref to values
[&values = std::as_const(values), &y_indx](char *begin, std::size_t) {
auto end = begin;
constexpr unsigned factor{100'000};
for (; y_indx < values.size(); y_indx++) {
double value = values[y_indx].second * factor;
value = std::floor(value);
value /= factor;
end = std::to_chars(end, end + 9, value).ptr;
*end++ = '\n';
}
return end - begin;
});
// create a .csv file to write to it
std::ofstream file(outFile, std::ios::app);
if (!file.is_open()) {
Expand Down Expand Up @@ -221,7 +221,7 @@ void saves_popup(nlohmann::json const &config, nlohmann::json const &language,

ImGui::Separator();
ImGui::NewLine();
if (ImGui::Button(appLanguage[Key::Back]))
if (ImGui::Button(appLanguage[Key::Back]))
ImGui::CloseCurrentPopup();
ImGui::SameLine(ImGui::GetWindowWidth() * 0.75f); // offset from start x

Expand All @@ -234,7 +234,7 @@ void saves_popup(nlohmann::json const &config, nlohmann::json const &language,
if (ImGui::Button(appLanguage[Key::Save])) {
checked_devices_cnt = count_checked_devices();
flagDataNotSaved = false;
future = std::async( // const reference to the container
future = std::async( // const reference to the container
std::launch::async, [=, &liveDvcs = std::as_const(liveDvcs)] {
for (size_t i{}; const auto &[device, values] : liveDvcs) {
// measurement saving preparation if device is checked
Expand All @@ -259,11 +259,11 @@ void saves_popup(nlohmann::json const &config, nlohmann::json const &language,
});
progress = true;
}
if (progress) { // check selected devices are saved
if (progress) { // check selected devices are saved
if (saved_files_cnt == checked_devices_cnt) {
future.get();
progress = false;
inptTxtFields.clear(); // reset storage location(s)
inptTxtFields.clear(); // reset storage location(s)
dvcCheckedArr.clear(); // rest check boxes
saved_files_cnt = 0;
ImGui::CloseCurrentPopup();
Expand Down

0 comments on commit 0e728b5

Please sign in to comment.