From ec401030e128cbdf104878689ad23d69c4c51d34 Mon Sep 17 00:00:00 2001 From: Gordon McCann Date: Thu, 3 Feb 2022 16:18:24 -0500 Subject: [PATCH] Fixed some semantics to reduce warnings from strings in ImGui widgets. HistogramMap now has a nullResult member --- .../src/Navigator/Editor/EditorLayer.cpp | 12 +++++------ Navigator/src/Navigator/Editor/FileDialog.cpp | 20 +++++++++---------- .../src/Navigator/Editor/SpectrumDialog.cpp | 2 +- .../src/Navigator/Editor/SpectrumPanel.cpp | 4 ++-- Navigator/src/Navigator/HistogramMap.cpp | 8 +------- Navigator/src/Navigator/HistogramMap.h | 2 ++ .../src/Navigator/Physics/DataSource.cpp | 4 ++++ navigator.sublime-project | 2 +- 8 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Navigator/src/Navigator/Editor/EditorLayer.cpp b/Navigator/src/Navigator/Editor/EditorLayer.cpp index 35e7bbf..fb4dc48 100644 --- a/Navigator/src/Navigator/Editor/EditorLayer.cpp +++ b/Navigator/src/Navigator/Editor/EditorLayer.cpp @@ -165,23 +165,23 @@ namespace Navigator { auto& params = gram.second->GetParameters(); if (ImGui::TreeNode(params.name.c_str())) { - ImGui::BulletText(("X Parameter: "+params.x_par).c_str()); + ImGui::BulletText("%s", ("X Parameter: "+params.x_par).c_str()); ImGui::BulletText("X Bins: %d X Min: %f X Max: %f", params.nbins_x, params.min_x, params.max_x); if (params.y_par != "None") { - ImGui::BulletText(("Y Parameter: "+params.y_par).c_str()); + ImGui::BulletText("%s", ("Y Parameter: "+params.y_par).c_str()); ImGui::BulletText("Y Bins: %d Y Min: %f Y Max: %f", params.nbins_y, params.min_y, params.max_y); } if(params.cutsDrawnUpon.size() != 0 && ImGui::TreeNode("Cuts Drawn")) { for(auto& cut : params.cutsDrawnUpon) - ImGui::BulletText(cut.c_str()); + ImGui::BulletText("%s", cut.c_str()); ImGui::TreePop(); } if(params.cutsAppliedTo.size() != 0 && ImGui::TreeNode("Cuts Applied")) { for(auto& cut : params.cutsAppliedTo) - ImGui::BulletText(cut.c_str()); + ImGui::BulletText("%s", cut.c_str()); ImGui::TreePop(); } ImGui::TreePop(); @@ -197,9 +197,9 @@ namespace Navigator { auto& params = cut.second->GetCutParams(); if(ImGui::TreeNode(params.name.c_str())) { - ImGui::BulletText(("X Parameter: "+params.x_par).c_str()); + ImGui::BulletText("%s", ("X Parameter: "+params.x_par).c_str()); if(params.y_par != "None") - ImGui::BulletText(("Y Parameter: "+params.y_par).c_str()); + ImGui::BulletText("%s", ("Y Parameter: "+params.y_par).c_str()); ImGui::TreePop(); } } diff --git a/Navigator/src/Navigator/Editor/FileDialog.cpp b/Navigator/src/Navigator/Editor/FileDialog.cpp index d239202..53f7b6d 100644 --- a/Navigator/src/Navigator/Editor/FileDialog.cpp +++ b/Navigator/src/Navigator/Editor/FileDialog.cpp @@ -16,7 +16,7 @@ namespace Navigator { FileDialog::FileDialog() : m_currentPath(std::filesystem::current_path()), m_openFileName(ICON_FA_FILE " Open File"), m_saveFileName(ICON_FA_SAVE " Save File"), m_openDirName(ICON_FA_FOLDER " Open Directory"), - m_selectedItem(""), m_openFileFlag(false), m_openDirFlag(false), m_saveFileFlag(false) + m_selectedItem(""), m_openFileFlag(false), m_saveFileFlag(false), m_openDirFlag(false) { table_flags = ImGuiTableFlags_BordersH | ImGuiTableFlags_SizingStretchProp | ImGuiTableFlags_BordersOuterV | ImGuiTableFlags_RowBg; select_flags = ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_DontClosePopups; @@ -37,9 +37,9 @@ namespace Navigator { std::string text = ""; if (ImGui::BeginPopupModal(m_openFileName.c_str())) { - ImGui::Text(("Current Directory: " + m_currentPath.lexically_normal().string()).c_str()); + ImGui::Text("%s", ("Current Directory: " + m_currentPath.lexically_normal().string()).c_str()); ImGui::SameLine(); - ImGui::Text(("Extension Filter: "+ext).c_str()); + ImGui::Text("%s", ("Extension Filter: "+ext).c_str()); ImGui::InputText("Selected", &m_selectedItem); if (ImGui::Button("Ok")) { @@ -87,7 +87,7 @@ namespace Navigator { if (ImGui::Selectable(text.c_str(), false, select_flags)) m_selectedItem = entry.path().filename().string(); ImGui::TableNextColumn(); - ImGui::Text(ConvertFileSystemSizeToString(entry.file_size()).c_str()); + ImGui::Text("%s", ConvertFileSystemSizeToString(entry.file_size()).c_str()); } } ImGui::EndTable(); @@ -112,9 +112,9 @@ namespace Navigator { std::string text = ""; if (ImGui::BeginPopupModal(m_saveFileName.c_str())) { - ImGui::Text(("Current Directory: "+m_currentPath.lexically_normal().string()).c_str()); + ImGui::Text("%s", ("Current Directory: "+m_currentPath.lexically_normal().string()).c_str()); ImGui::SameLine(); - ImGui::Text(("Extension Filter: "+ext).c_str()); + ImGui::Text("%s", ("Extension Filter: "+ext).c_str()); ImGui::InputText("Selected", &m_selectedItem); if (ImGui::Button("Ok")) { @@ -162,7 +162,7 @@ namespace Navigator { if (ImGui::Selectable(text.c_str(), false, select_flags)) m_selectedItem = entry.path().filename().string(); ImGui::TableNextColumn(); - ImGui::Text(ConvertFileSystemSizeToString(entry.file_size()).c_str()); + ImGui::Text("%s", ConvertFileSystemSizeToString(entry.file_size()).c_str()); } } ImGui::EndTable(); @@ -185,7 +185,7 @@ namespace Navigator { std::string text = ""; if (ImGui::BeginPopupModal(m_openDirName.c_str())) { - ImGui::Text(("Current Directory: "+m_currentPath.lexically_normal().string()).c_str()); + ImGui::Text("%s", ("Current Directory: "+m_currentPath.lexically_normal().string()).c_str()); ImGui::InputText("Selected", &m_selectedItem); if (ImGui::Button("Ok")) { @@ -228,9 +228,9 @@ namespace Navigator { { text = ICON_FA_FILE " " + entry.path().filename().string(); ImGui::TableNextColumn(); - ImGui::Text(text.c_str()); + ImGui::Text("%s", text.c_str()); ImGui::TableNextColumn(); - ImGui::Text(ConvertFileSystemSizeToString(entry.file_size()).c_str()); + ImGui::Text("%s", ConvertFileSystemSizeToString(entry.file_size()).c_str()); } } ImGui::EndTable(); diff --git a/Navigator/src/Navigator/Editor/SpectrumDialog.cpp b/Navigator/src/Navigator/Editor/SpectrumDialog.cpp index 45feccc..fed8a80 100644 --- a/Navigator/src/Navigator/Editor/SpectrumDialog.cpp +++ b/Navigator/src/Navigator/Editor/SpectrumDialog.cpp @@ -82,7 +82,7 @@ namespace Navigator { { for (auto& name : m_newParams.cutsAppliedTo) { - ImGui::BulletText(name.c_str()); + ImGui::BulletText("%s", name.c_str()); } ImGui::TreePop(); } diff --git a/Navigator/src/Navigator/Editor/SpectrumPanel.cpp b/Navigator/src/Navigator/Editor/SpectrumPanel.cpp index 73f0ade..c99bd53 100644 --- a/Navigator/src/Navigator/Editor/SpectrumPanel.cpp +++ b/Navigator/src/Navigator/Editor/SpectrumPanel.cpp @@ -38,8 +38,8 @@ namespace Navigator { m_newCutParams.x_par = zoomed_params.x_par; m_newCutParams.y_par = zoomed_params.y_par; ImGui::InputText("Cut Name", &m_newCutParams.name); - ImGui::BulletText(("X Parameter: "+m_newCutParams.x_par).c_str()); - ImGui::BulletText(("Y Parameter: "+m_newCutParams.y_par).c_str()); + ImGui::BulletText("%s", ("X Parameter: "+m_newCutParams.x_par).c_str()); + ImGui::BulletText("%s", ("Y Parameter: "+m_newCutParams.y_par).c_str()); if(ImGui::Button("Accept & Draw")) { m_cutModeFlag = true; diff --git a/Navigator/src/Navigator/HistogramMap.cpp b/Navigator/src/Navigator/HistogramMap.cpp index 3e28a47..2cd34e9 100644 --- a/Navigator/src/Navigator/HistogramMap.cpp +++ b/Navigator/src/Navigator/HistogramMap.cpp @@ -64,12 +64,8 @@ namespace Navigator { void HistogramMap::UpdateHistograms() { - std::string xpar, ypar; - ParameterMap& pmap = ParameterMap::GetInstance(); for (auto& pair : m_map) - { pair.second->FillData(); - } } const HistogramParameters& HistogramMap::GetHistogramParams(const std::string& name) @@ -79,9 +75,7 @@ namespace Navigator { if (iter != m_map.end()) return iter->second->GetParameters(); else - { - return HistogramParameters(); - } + return m_nullResult; } //Only to be used within ImGui context!! diff --git a/Navigator/src/Navigator/HistogramMap.h b/Navigator/src/Navigator/HistogramMap.h index daa390f..9712860 100644 --- a/Navigator/src/Navigator/HistogramMap.h +++ b/Navigator/src/Navigator/HistogramMap.h @@ -40,6 +40,8 @@ namespace Navigator { private: std::unordered_map> m_map; + HistogramParameters m_nullResult; + static HistogramMap* s_instance; }; diff --git a/Navigator/src/Navigator/Physics/DataSource.cpp b/Navigator/src/Navigator/Physics/DataSource.cpp index 491acab..6e76c06 100644 --- a/Navigator/src/Navigator/Physics/DataSource.cpp +++ b/Navigator/src/Navigator/Physics/DataSource.cpp @@ -12,6 +12,8 @@ namespace Navigator { case DataSource::SourceType::CompassOnline : return new CompassOnlineSource(loc, port); case DataSource::SourceType::None : return nullptr; } + NAV_WARN("Invalid DataSourceType at CreateDataSource!"); + return nullptr; } std::string ConvertDataSourceTypeToString(DataSource::SourceType type) @@ -22,5 +24,7 @@ namespace Navigator { case DataSource::SourceType::CompassOnline : return "CompassOnline"; case DataSource::SourceType::CompassOffline : return "CompassOffline"; } + + return "None"; } } diff --git a/navigator.sublime-project b/navigator.sublime-project index 74c977f..2b9e2fa 100644 --- a/navigator.sublime-project +++ b/navigator.sublime-project @@ -7,6 +7,6 @@ ], "settings": { - "SublimeLinter.linters.g++.args": ["-c","-Wall","-fsyntax-only","-std=c++17","-include${folder}/Navigator/src/navpch.h","-INavigator/src/", "-INavigator/src/Navigator/","-INavigator/vendor/spdlog/include", "-INavigator/vendor/glfw/include/","-INavigator/vendor/glad/include","-INavigator/vendor/imgui","-INavigator/vendor/implot"] + "SublimeLinter.linters.g++.args": ["-c","-Wall","-fsyntax-only","-std=c++17","-include${folder}/Navigator/src/navpch.h","-INavigator/src/", "-INavigator/src/Navigator/","-INavigator/vendor/spdlog/include", "-INavigator/vendor/glfw/include/","-INavigator/vendor/glad/include","-INavigator/vendor/imgui","-INavigator/vendor/implot","-INavigator/vendor/asio/asio/include","-INavigator/vendor/IconFontCppHeaders","-INavigator/vendor/glm"] } } \ No newline at end of file