diff --git a/GUI/Models/DetectorItems.cpp b/GUI/Models/DetectorItems.cpp index 7ae91c933e9a935dcf10360b335b3ed2b1a06ebf..fb29855af38b70020fda08880898d2caa37afcdf 100644 --- a/GUI/Models/DetectorItems.cpp +++ b/GUI/Models/DetectorItems.cpp @@ -93,6 +93,16 @@ void DetectorItem::importMasks(const MaskContainerItem* maskContainer) model()->copyItem(maskContainer, this, T_MASKS); } +SessionItem* DetectorItem::setResolutionFunctionType(const QString& model_type) +{ + return setGroupProperty(P_RESOLUTION_FUNCTION, model_type); +} + +SessionItem* DetectorItem::resolutionFunctionItem() const +{ + return getItem(P_RESOLUTION_FUNCTION); +} + void DetectorItem::register_resolution_function() { auto item = addGroupProperty(P_RESOLUTION_FUNCTION, "Resolution function group"); diff --git a/GUI/Models/DetectorItems.h b/GUI/Models/DetectorItems.h index 7867623db99232aae8934e0168148f7bbe3e412f..7f3f858d841f96dc051b807219c923ebd446ae4f 100644 --- a/GUI/Models/DetectorItems.h +++ b/GUI/Models/DetectorItems.h @@ -25,9 +25,9 @@ class DetectorItem; class BA_CORE_API_ DetectorItem : public SessionItem { private: static const QString T_MASKS; + static const QString P_RESOLUTION_FUNCTION; public: - static const QString P_RESOLUTION_FUNCTION; static const QString P_ANALYZER_DIRECTION; static const QString P_ANALYZER_EFFICIENCY; static const QString P_ANALYZER_TOTAL_TRANSMISSION; @@ -57,6 +57,9 @@ public: void importMasks(const MaskContainerItem* maskContainer); + SessionItem* setResolutionFunctionType(const QString& model_type); + SessionItem* resolutionFunctionItem() const; + protected: void register_resolution_function(); void update_resolution_function_tooltips(); diff --git a/GUI/Models/TransformFromDomain.cpp b/GUI/Models/TransformFromDomain.cpp index e77e865d1e5f140d31157c232cf67301112af6eb..da51896711a59f73f31debd9ccf18d0b0081c25e 100644 --- a/GUI/Models/TransformFromDomain.cpp +++ b/GUI/Models/TransformFromDomain.cpp @@ -322,8 +322,8 @@ void TransformFromDomain::setDetectorResolution(DetectorItem* detector_item, if (auto p_convfunc = dynamic_cast<const ConvolutionDetectorResolution*>(p_resfunc)) { if (auto resfunc = dynamic_cast<const ResolutionFunction2DGaussian*>( p_convfunc->getResolutionFunction2D())) { - SessionItem* item = detector_item->setGroupProperty(DetectorItem::P_RESOLUTION_FUNCTION, - "ResolutionFunction2DGaussian"); + SessionItem* item = detector_item->setResolutionFunctionType + ("ResolutionFunction2DGaussian"); double scale(1.0); if (detector_item->modelType() == "SphericalDetector") scale = 1. / Units::deg; diff --git a/GUI/Views/InstrumentWidgets/RectangularDetectorEditor.cpp b/GUI/Views/InstrumentWidgets/RectangularDetectorEditor.cpp index b1bcc87c27ee44b424ca7e058f50529de6e62796..df7ba4e6fc01bcc8cc8aade43fcce6c40f473144 100644 --- a/GUI/Views/InstrumentWidgets/RectangularDetectorEditor.cpp +++ b/GUI/Views/InstrumentWidgets/RectangularDetectorEditor.cpp @@ -108,7 +108,7 @@ void RectangularDetectorEditor::init_editors() m_yAxisEditor->setItem(detectorItem()->yAxisItem()); m_resolutionFunctionEditor->clearEditor(); - auto resFuncGroup = detectorItem()->getItem(RectangularDetectorItem::P_RESOLUTION_FUNCTION); + auto resFuncGroup = detectorItem()->resolutionFunctionItem(); m_resolutionFunctionEditor->setItem(resFuncGroup); m_alignmentEditor->clearEditor(); diff --git a/GUI/Views/InstrumentWidgets/SphericalDetectorEditor.cpp b/GUI/Views/InstrumentWidgets/SphericalDetectorEditor.cpp index 535855aa3c27db2b40944452a3be915e7af8937d..f68528cc662cb4d80cd82655e79ef7ec73e92045 100644 --- a/GUI/Views/InstrumentWidgets/SphericalDetectorEditor.cpp +++ b/GUI/Views/InstrumentWidgets/SphericalDetectorEditor.cpp @@ -52,7 +52,7 @@ void SphericalDetectorEditor::subscribeToItem() auto alphaAxisItem = detectorItem()->alphaAxisItem(); m_alphaAxisEditor->setItem(alphaAxisItem); - auto resFuncGroup = detectorItem()->getItem(SphericalDetectorItem::P_RESOLUTION_FUNCTION); + auto resFuncGroup = detectorItem()->resolutionFunctionItem(); m_resolutionFunctionEditor->setItem(resFuncGroup); } diff --git a/Tests/UnitTests/GUI/TestDetectorItems.cpp b/Tests/UnitTests/GUI/TestDetectorItems.cpp index 82b68e2ddf30ce074da23732b58cb40ab4b74e96..7f5866fdd22fe7efe0737c7ad05ee9183610f6af 100644 --- a/Tests/UnitTests/GUI/TestDetectorItems.cpp +++ b/Tests/UnitTests/GUI/TestDetectorItems.cpp @@ -38,8 +38,7 @@ TEST_F(TestDetectorItems, test_resolutionFunction) DetectorItem* detectorItem = instrument->detectorItem(); - detectorItem->setGroupProperty(DetectorItem::P_RESOLUTION_FUNCTION, - "ResolutionFunction2DGaussian"); + detectorItem->setResolutionFunctionType("ResolutionFunction2DGaussian"); auto detector = detectorItem->createDetector(); auto convol =