diff --git a/view/inc/Vapp.hpp b/view/inc/Vapp.hpp index 506ccee..58bac2c 100644 --- a/view/inc/Vapp.hpp +++ b/view/inc/Vapp.hpp @@ -28,6 +28,7 @@ public: private: bool showSelection; bool showStats; + bool saveToFile; sqlite3 *db; sqlite3_stmt *get_gen_num; std::vector ids; diff --git a/view/src/Vapp.cpp b/view/src/Vapp.cpp index 5231658..a39eee9 100644 --- a/view/src/Vapp.cpp +++ b/view/src/Vapp.cpp @@ -110,7 +110,7 @@ void Vapp::update() stageOfDrawing = DrawingStage::save; break; case DrawingStage::save: - drawToFile(); + if(saveToFile) drawToFile(); stageOfDrawing = DrawingStage::done; break; case DrawingStage::done: @@ -140,6 +140,10 @@ void Vapp::draw() { setUpTable(); } + if(ImGui::MenuItem("Save to File", nullptr, saveToFile, true)) + { + saveToFile = !saveToFile; + } ImGui::EndMainMenuBar(); } @@ -335,27 +339,28 @@ void Vapp::setUpTable() } sql::reset(get_gen_stmt); - - int64_t id = ids[selected_id_index]; - char buff[50]; - sprintf(buff, "%ld.txt", id); - std::ofstream file(buff); - - file << "| index | euclidean_distance | cosine_similarity | cosine_similarity_int | hamming_distance | levenshtein_distance | dot_minmax |\n"; - file << "| --- | --- | --- | --- | --- | --- | --- |\n"; - - - - for (size_t i = 0; i < similTable.size(); i++) + if(saveToFile) { - file << "|" << i << "|"; - for (size_t j = 0; j < similTable[i].size(); j++) + int64_t id = ids[selected_id_index]; + const char* buff = TextFormat("%ld.txt", id); + std::ofstream file(buff); + + file << "| index | euclidean_distance | cosine_similarity | cosine_similarity_int | hamming_distance | levenshtein_distance | dot_minmax |\n"; + file << "| --- | --- | --- | --- | --- | --- | --- |\n"; + + + + for (size_t i = 0; i < similTable.size(); i++) { - file << similTable[i][j] << "|"; + file << "|" << i << "|"; + for (size_t j = 0; j < similTable[i].size(); j++) + { + file << similTable[i][j] << "|"; + } + file << "\n"; } - file << "\n"; } - } + } sql::finalize(get_gen_stmt); }