From 21f7a1bfcba31632ecb6e59e445384d3f7f57b13 Mon Sep 17 00:00:00 2001 From: Evgeni Raikhel Date: Mon, 8 Mar 2021 13:14:11 +0200 Subject: [PATCH 1/5] Fix imgui rounding operation that caused range boundary override Change-Id: I8bebb33e36bf8aa429c05f77975df9db1c71a8f1 --- third-party/imgui/imgui.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/third-party/imgui/imgui.cpp b/third-party/imgui/imgui.cpp index fcfb604890..784bf96f05 100644 --- a/third-party/imgui/imgui.cpp +++ b/third-party/imgui/imgui.cpp @@ -6455,10 +6455,12 @@ bool ImGui::SliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v new_value = ImLerp(v_min, v_max, normalized_pos); } - // Round past decimal precision + // Round past decimal precision, verify that it remains within min/max range new_value = RoundScalar(new_value, decimal_precision); if (*v != new_value) { + if (new_value >v_max ) new_value = v_max; + if (new_value < v_min) new_value = v_min; *v = new_value; value_changed = true; } From 4f6509aaa2c5a0333e0501be1d9676bab6a3091d Mon Sep 17 00:00:00 2001 From: Evgeni Raikhel Date: Thu, 8 Apr 2021 19:01:01 +0300 Subject: [PATCH 2/5] small refactoring + adding validation for manual values inhection --- common/realsense-ui-advanced-mode.h | 26 ++++++++++++++++++++++---- third-party/imgui/imgui.cpp | 5 +++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/common/realsense-ui-advanced-mode.h b/common/realsense-ui-advanced-mode.h index 4a7a5ba3d4..7e25afd18a 100644 --- a/common/realsense-ui-advanced-mode.h +++ b/common/realsense-ui-advanced-mode.h @@ -102,8 +102,17 @@ inline void slider_int(std::string& error_message, const char* id, T* val, S T:: } else { - val->*field = static_cast(new_value); - to_set = true; + if ((new_value > max) || (new_value < min)) + { + std::stringstream ss; + ss << "New value " << new_value << " to be within [" << min << ", " << max << "] range"; + error_message = ss.str().c_str(); + } + else + { + val->*field = static_cast(new_value); + to_set = true; + } } *edit_mode = false; @@ -158,8 +167,17 @@ inline void slider_float(std::string& error_message, const char* id, T* val, S T } else { - val->*field = static_cast(new_value); - to_set = true; + if ((new_value > max) || (new_value*field = static_cast(new_value); + to_set = true; + } } *edit_mode = false; diff --git a/third-party/imgui/imgui.cpp b/third-party/imgui/imgui.cpp index 784bf96f05..279cac6b63 100644 --- a/third-party/imgui/imgui.cpp +++ b/third-party/imgui/imgui.cpp @@ -6457,10 +6457,11 @@ bool ImGui::SliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v // Round past decimal precision, verify that it remains within min/max range new_value = RoundScalar(new_value, decimal_precision); + if (new_value > v_max) new_value = v_max; + if (new_value < v_min) new_value = v_min; + if (*v != new_value) { - if (new_value >v_max ) new_value = v_max; - if (new_value < v_min) new_value = v_min; *v = new_value; value_changed = true; } From 432ab233216562c761af369f6110e45b4c985f53 Mon Sep 17 00:00:00 2001 From: Evgeni Raikhel Date: Thu, 8 Apr 2021 19:02:02 +0300 Subject: [PATCH 3/5] Handle MSVC warnings --- common/model-views.cpp | 2 +- common/output-model.cpp | 2 +- common/viewer.cpp | 2 +- src/gl/yuy2rgb-gl.cpp | 2 +- tools/realsense-viewer/realsense-viewer.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/model-views.cpp b/common/model-views.cpp index 08f68f5a60..f36c45b472 100644 --- a/common/model-views.cpp +++ b/common/model-views.cpp @@ -6023,7 +6023,7 @@ namespace rs2 model.add_log(to_string() << "Setting " << opt_model.opt << " to " << new_val << " (" << labels[selected] << ")"); - opt_model.set_option(opt_model.opt, new_val, error_message); + opt_model.set_option(opt_model.opt, static_cast(new_val), error_message); // Only apply preset to GUI if set_option was succesful selected_file_preset = ""; diff --git a/common/output-model.cpp b/common/output-model.cpp index e2fd2bd850..03dbcfffe6 100644 --- a/common/output-model.cpp +++ b/common/output-model.cpp @@ -156,7 +156,7 @@ void output_model::open(ux_window& win) { is_output_open = true; config_file::instance().set(configurations::viewer::output_open, true); - default_log_h = (int)((win.height() - 100) / 2); + default_log_h = static_cast((win.height() - 100) / 2); new_log = true; } diff --git a/common/viewer.cpp b/common/viewer.cpp index ba293b000b..35a85ac46a 100644 --- a/common/viewer.cpp +++ b/common/viewer.cpp @@ -274,7 +274,7 @@ namespace rs2 for (auto& option : curr_exporter->second.options) { - exporter->set_option(option.first, option.second); + exporter->set_option(option.first, static_cast(option.second)); } export_frame(fname, std::move(exporter), *not_model, data); diff --git a/src/gl/yuy2rgb-gl.cpp b/src/gl/yuy2rgb-gl.cpp index 45fa2b82e5..0029b0541b 100644 --- a/src/gl/yuy2rgb-gl.cpp +++ b/src/gl/yuy2rgb-gl.cpp @@ -11,7 +11,7 @@ #ifndef NOMINMAX #define NOMINMAX -#endif +#endif // NOMINMAX #include diff --git a/tools/realsense-viewer/realsense-viewer.cpp b/tools/realsense-viewer/realsense-viewer.cpp index 36ffed8200..6843faa034 100644 --- a/tools/realsense-viewer/realsense-viewer.cpp +++ b/tools/realsense-viewer/realsense-viewer.cpp @@ -628,7 +628,7 @@ int main(int argc, const char** argv) try auto output_rect = rect{ viewer_model.panel_width, window.height() - viewer_model.get_output_height(), - window.width() - viewer_model.panel_width, viewer_model.get_output_height() }; + window.width() - viewer_model.panel_width, float(viewer_model.get_output_height()) }; viewer_model.not_model->output.draw(window, output_rect, *device_models); From 4556bfc36c9502718853bedc1dd6a935be5b69cc Mon Sep 17 00:00:00 2001 From: Evgeni Raikhel Date: Sun, 11 Apr 2021 09:20:55 +0300 Subject: [PATCH 4/5] LibCI - Update expected warnings numbers --- unit-tests/LRS_windows_compile_pipeline.stats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unit-tests/LRS_windows_compile_pipeline.stats b/unit-tests/LRS_windows_compile_pipeline.stats index 8f4042cbfd..11eb5ef1b6 100644 --- a/unit-tests/LRS_windows_compile_pipeline.stats +++ b/unit-tests/LRS_windows_compile_pipeline.stats @@ -1,2 +1,2 @@ -warnings 342 +warnings 340 From fe42beaf234c4931436d31eb2b559a450dfe9385 Mon Sep 17 00:00:00 2001 From: Evgeni Raikhel Date: Sun, 11 Apr 2021 09:39:55 +0300 Subject: [PATCH 5/5] CR fixes --- common/realsense-ui-advanced-mode.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/realsense-ui-advanced-mode.h b/common/realsense-ui-advanced-mode.h index 7e25afd18a..b1cd98ffce 100644 --- a/common/realsense-ui-advanced-mode.h +++ b/common/realsense-ui-advanced-mode.h @@ -105,8 +105,8 @@ inline void slider_int(std::string& error_message, const char* id, T* val, S T:: if ((new_value > max) || (new_value < min)) { std::stringstream ss; - ss << "New value " << new_value << " to be within [" << min << ", " << max << "] range"; - error_message = ss.str().c_str(); + ss << "New value " << new_value << " must be within [" << min << ", " << max << "] range"; + error_message = ss.str(); } else { @@ -170,8 +170,8 @@ inline void slider_float(std::string& error_message, const char* id, T* val, S T if ((new_value > max) || (new_value