From d31839e80e08fb1d0df1579f46e07ff7a846b391 Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Thu, 30 Jul 2020 14:04:50 +0200 Subject: [PATCH] roi constructor added --- slsDetectorGui/src/qTabAdvanced.cpp | 4 +--- slsDetectorSoftware/src/CmdProxy.cpp | 4 +--- slsSupportLib/include/sls_detector_defs.h | 2 ++ slsSupportLib/tests/test-ToString.cpp | 4 ++-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/slsDetectorGui/src/qTabAdvanced.cpp b/slsDetectorGui/src/qTabAdvanced.cpp index 5974e6141..e5ad30cab 100644 --- a/slsDetectorGui/src/qTabAdvanced.cpp +++ b/slsDetectorGui/src/qTabAdvanced.cpp @@ -560,9 +560,7 @@ void qTabAdvanced::ClearROI() { void qTabAdvanced::SetROI() { - slsDetectorDefs::ROI roi; - roi.xmin = spinXmin->value(); - roi.xmax = spinXmax->value(); + slsDetectorDefs::ROI roi(spinXmin->value(), spinXmax->value()); // set roi LOG(logINFO) << "Setting ROI: [" << roi.xmin << ", " << roi.xmax << "]"; diff --git a/slsDetectorSoftware/src/CmdProxy.cpp b/slsDetectorSoftware/src/CmdProxy.cpp index 984f240a0..a4d2d266c 100644 --- a/slsDetectorSoftware/src/CmdProxy.cpp +++ b/slsDetectorSoftware/src/CmdProxy.cpp @@ -1559,9 +1559,7 @@ std::string CmdProxy::ROI(int action) { if (args.size() != 2) { WrongNumberOfParameters(2); } - defs::ROI t; - t.xmin = StringTo(args[0]); - t.xmax = StringTo(args[1]); + defs::ROI t(StringTo(args[0]), StringTo(args[1])); det->setROI(t, det_id); os << '[' << t.xmin << ", " << t.xmax << "]\n"; } else { diff --git a/slsSupportLib/include/sls_detector_defs.h b/slsSupportLib/include/sls_detector_defs.h index 733d4afb2..f0d9b6ca5 100644 --- a/slsSupportLib/include/sls_detector_defs.h +++ b/slsSupportLib/include/sls_detector_defs.h @@ -160,6 +160,8 @@ class slsDetectorDefs { struct ROI { int xmin{-1}; int xmax{-1}; + ROI() = default; + ROI(int xmin, int xmax) : xmin(xmin), xmax(xmax){}; } __attribute__((packed)); #else typedef struct { diff --git a/slsSupportLib/tests/test-ToString.cpp b/slsSupportLib/tests/test-ToString.cpp index 06f9253ae..6eabadc4b 100644 --- a/slsSupportLib/tests/test-ToString.cpp +++ b/slsSupportLib/tests/test-ToString.cpp @@ -221,13 +221,13 @@ TEST_CASE("Detector type") { } TEST_CASE("Formatting slsDetectorDefs::ROI") { - slsDetectorDefs::ROI roi{5, 159}; + slsDetectorDefs::ROI roi(5, 159); REQUIRE(ToString(roi) == "[5, 159]"); } TEST_CASE("Streaming of slsDetectorDefs::ROI") { using namespace sls; - slsDetectorDefs::ROI roi{-10, 1}; + slsDetectorDefs::ROI roi(-10, 1); std::ostringstream oss; oss << roi; REQUIRE(oss.str() == "[-10, 1]");