diff --git a/GUI/coregui/Models/BackgroundItem.cpp b/GUI/coregui/Models/BackgroundItem.cpp index c0c1853cd5fce782f01d023cd2e014e25ecbcc4c..666b7d8fa1f41a92d889e7d4a97172fa1722bc30 100644 --- a/GUI/coregui/Models/BackgroundItem.cpp +++ b/GUI/coregui/Models/BackgroundItem.cpp @@ -48,5 +48,7 @@ void BackgroundItem::setBackgroundValue(double value) std::unique_ptr<IBackground> BackgroundItem::createBackground() const { - return std::make_unique<ConstantBackground>(getBackgroundValue()); + if (getBackgroundValue()>0.0) + return std::make_unique<ConstantBackground>(getBackgroundValue()); + return {}; } diff --git a/GUI/coregui/Models/DomainObjectBuilder.cpp b/GUI/coregui/Models/DomainObjectBuilder.cpp index 9e6aaa2be047ee9466271be07a337dad0ebed150..589e71c4073a190d10a92bf98b9c27804383fa0f 100644 --- a/GUI/coregui/Models/DomainObjectBuilder.cpp +++ b/GUI/coregui/Models/DomainObjectBuilder.cpp @@ -15,20 +15,21 @@ // ************************************************************************** // #include "DomainObjectBuilder.h" +#include "BackgroundItem.h" +#include "BeamItem.h" #include "ComboProperty.h" +#include "DetectorItems.h" #include "GISASSimulation.h" #include "GUIHelpers.h" #include "IInterferenceFunction.h" +#include "Instrument.h" +#include "InstrumentItem.h" +#include "InterferenceFunctionItems.h" #include "LayerItem.h" #include "MultiLayer.h" #include "ParticleDistributionItem.h" #include "ParticleLayoutItem.h" -#include "InterferenceFunctionItems.h" #include "TransformToDomain.h" -#include "InstrumentItem.h" -#include "Instrument.h" -#include "BeamItem.h" -#include "DetectorItems.h" std::unique_ptr<MultiLayer> DomainObjectBuilder::buildMultiLayer( diff --git a/GUI/coregui/Models/DomainSimulationBuilder.cpp b/GUI/coregui/Models/DomainSimulationBuilder.cpp index 830d9dd5e51e97c92d0cc143ca2a428418fd49b8..72ae94d858368bb2eeccf9cdf5972ea2c8af0567 100644 --- a/GUI/coregui/Models/DomainSimulationBuilder.cpp +++ b/GUI/coregui/Models/DomainSimulationBuilder.cpp @@ -15,11 +15,13 @@ // ************************************************************************** // #include "DomainSimulationBuilder.h" +#include "BackgroundItem.h" #include "BeamItem.h" #include "DetectorItems.h" #include "DomainObjectBuilder.h" #include "GISASSimulation.h" #include "GUIHelpers.h" +#include "IBackground.h" #include "InstrumentItem.h" #include "MultiLayer.h" #include "MultiLayerItem.h" @@ -41,8 +43,12 @@ GISASSimulation *DomainSimulationBuilder::getSimulation(const MultiLayerItem *sa GISASSimulation *result = new GISASSimulation; auto P_multilayer = builder.buildMultiLayer(*sampleItem); auto P_instrument = builder.buildInstrument(*instrumentItem); + auto P_background = instrumentItem->backgroundItem()->createBackground(); result->setSample(*P_multilayer); result->setInstrument(*P_instrument); + if (P_background) { + result->setBackGround(*P_background); + } TransformToDomain::addDistributionParametersToSimulation(*instrumentItem->beamItem(), result);