diff --git a/GUI/Models/BackgroundItems.cpp b/GUI/Models/BackgroundItems.cpp index 5925b6c722784b1bb4d9db7b6383d28282b792c7..a5ae25b91a59bf9f53e43398e4d7a80327d27452 100644 --- a/GUI/Models/BackgroundItems.cpp +++ b/GUI/Models/BackgroundItems.cpp @@ -35,7 +35,7 @@ namespace { const QString constant_background_value_tooltip = "Constant background value [counts/pixel]"; } -const QString ConstantBackgroundItem::P_VALUE = QString::fromStdString("BackgroundValue"); +const QString ConstantBackgroundItem::P_VALUE = "BackgroundValue"; ConstantBackgroundItem::ConstantBackgroundItem() : BackgroundItem("ConstantBackground") { @@ -49,6 +49,11 @@ std::unique_ptr<IBackground> ConstantBackgroundItem::createBackground() const return std::make_unique<ConstantBackground>(getItemValue(P_VALUE).toDouble()); } +void ConstantBackgroundItem::setBackgroundValue(double value) +{ + setItemValue(P_VALUE, value); +} + // Background consisting of Poisson noise /* ------------------------------------------------ */ diff --git a/GUI/Models/BackgroundItems.h b/GUI/Models/BackgroundItems.h index 85c0056a986a1d84bb47f1375a53cebc017abf9e..96b3f83b75610952c8a41a8d1fa42a6fb51db6a1 100644 --- a/GUI/Models/BackgroundItems.h +++ b/GUI/Models/BackgroundItems.h @@ -33,11 +33,13 @@ public: }; class BA_CORE_API_ ConstantBackgroundItem : public BackgroundItem { -public: +private: static const QString P_VALUE; +public: ConstantBackgroundItem(); std::unique_ptr<IBackground> createBackground() const; + void setBackgroundValue(double value); }; class BA_CORE_API_ PoissonNoiseBackgroundItem : public BackgroundItem { diff --git a/GUI/Models/TransformFromDomain.cpp b/GUI/Models/TransformFromDomain.cpp index 14ecf8eb04a353bdf2cd6415e8ad22b78f797e32..02f3ea4abc063e7b3d7b59c9b489b175bc0262f8 100644 --- a/GUI/Models/TransformFromDomain.cpp +++ b/GUI/Models/TransformFromDomain.cpp @@ -558,10 +558,11 @@ void TransformFromDomain::setBackground(InstrumentItem* instrument_item, { auto p_bg = simulation.background(); if (auto p_constant_bg = dynamic_cast<const ConstantBackground*>(p_bg)) { - auto constant_bg_item = - instrument_item->setGroupProperty(InstrumentItem::P_BACKGROUND, "ConstantBackground"); + ConstantBackgroundItem* constant_bg_item = + dynamic_cast<ConstantBackgroundItem*> + (instrument_item->setGroupProperty(InstrumentItem::P_BACKGROUND, "ConstantBackground")); double value = p_constant_bg->backgroundValue(); - constant_bg_item->setItemValue(ConstantBackgroundItem::P_VALUE, value); + constant_bg_item->setBackgroundValue(value); } else if (dynamic_cast<const PoissonNoiseBackground*>(p_bg)) { instrument_item->setGroupProperty(InstrumentItem::P_BACKGROUND, "PoissonNoiseBackground"); }