Skip to content

Commit

Permalink
Multiple Files can be loaded, no seperate axis
Browse files Browse the repository at this point in the history
  • Loading branch information
AKMaily committed Oct 24, 2024
1 parent 938340d commit 253c1c1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
34 changes: 30 additions & 4 deletions src/loadingFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,28 @@ void externData::loadDataFromFile() {
if (std::getline(file, line)) {
std::istringstream iss(line);
double potential_x, potential_y;
std::string unit;
if (line.find("Omniscope") != std::string::npos) {
isOmnAIScope = true;
std::cout << "Old OmnAIScope file detected\n";
sampling_rate = 100000; // Set the sampling rate for the OmniScope format
} else if (iss >> potential_x >> potential_y) {
}
else if (std::getline(iss, unit, ',') && !std::isdigit(unit[0])) {
// Speichere den ersten Teil der Zeile
std::string unit1 = unit;

// Versuche, den zweiten Teil der Zeile zu lesen
std::string unit2;
if (std::getline(iss, unit2) && !std::isdigit(unit2[0])) {
// Wenn beide Einheiten weniger als oder genau 5 Zeichen haben
if (unit1.length() <= 5 && unit2.length() <= 5) {
units.push_back(unit1);
units.push_back(unit2);
}
}
else units.clear();
}
else if (iss >> potential_x >> potential_y) {
// If the first line contains two doubles, it is treated as data
firstLineIsData = true;
xValues.push_back(potential_x);
Expand Down Expand Up @@ -188,14 +205,18 @@ void externData::loadDataFromFile() {
}


void filesList(std::vector<externData> &dataObjects) { // Show list of files in Devices Region
void filesList(std::vector<std::filesystem::path> &externDataFilePaths, std::vector<externData> &dataObjects) { // Show list of files in Devices Region
ImGui::BeginGroup();
int index = 0;

if (!dataObjects.empty()) {
for (auto it = dataObjects.begin(); it != dataObjects.end(); ) {
externData& obj = *it;

if (ImGui::Checkbox("##", &obj.loadChecked)) {
std::string checkboxId = "##Checkbox" + std::to_string(index); // every checkbox needs its own ID
std::string resetButtonId = std::string(appLanguage[Key::Reset]) + "##" + std::to_string(index);

if (ImGui::Checkbox(checkboxId.c_str(), &obj.loadChecked)) {
if (obj.loadChecked) {
obj.showData = true;
//TODO:: Filter if FFT and Plot a Histogram
Expand All @@ -210,11 +231,16 @@ void filesList(std::vector<externData> &dataObjects) { // Show list of files in
ImGui::SameLine();

//Deleting Loaded Data
if (ImGui::Button(appLanguage[Key::Reset])) {
if (ImGui::Button(resetButtonId.c_str())) {
it = dataObjects.erase(it);
if (index < externDataFilePaths.size()) {

Check warning on line 236 in src/loadingFiles.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-24.04-C++ CI

comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<std::filesystem::__cxx11::path>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
externDataFilePaths.erase(externDataFilePaths.begin() + index);
}

} else {
++it;
}
index++;
}
}

Expand Down
5 changes: 1 addition & 4 deletions src/loadingFiles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ void generateLoadFilesMenu(std::vector<std::filesystem::path> &, std::vector<ext

void loadMultipleExternFiles(std::vector<std::filesystem::path> &, std::vector<externData> &);

void filesList(std::vector<externData> &); // generates, shows and functionality of the filesList in the DeviceRegion

void addPlotFromFile(externData &);
void addPlotFromFFTFile(externData &);
void filesList(std::vector<std::filesystem::path> &, std::vector<externData> &); // generates, shows and functionality of the filesList in the DeviceRegion

#endif
6 changes: 1 addition & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,7 @@ int main() {
ImGui::SameLine();
ImGui::Text(appLanguage[Key::Devices_found]);

Check warning on line 94 in src/main.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-24.04-C++ CI

format not a string literal and no format arguments [-Wformat-security]
devicesList(mWindow.flagPaused);
filesList(mWindow.externDatas);

// TODO:: Load File names
// function:: filesCheckboxList(std::vector<externData>)
// instead of captureData.emplace() --> externData[i].loadChecked = true;
filesList(mWindow.externDataFilePaths, mWindow.externDatas);
ImGui::EndChild(); // end child "Devicelist"
ImGui::EndChild(); // end child "Right Side"
ImGui::End();
Expand Down

0 comments on commit 253c1c1

Please sign in to comment.