From c9dad553c4d59662924450e587f326588c7f3296 Mon Sep 17 00:00:00 2001 From: Walter Van Herck <w.van.herck@fz-juelich.de> Date: Wed, 29 Nov 2017 14:04:43 +0100 Subject: [PATCH] Use background value of GUI in simulation --- GUI/coregui/Models/BackgroundItem.cpp | 4 +++- GUI/coregui/Models/DomainObjectBuilder.cpp | 11 ++++++----- GUI/coregui/Models/DomainSimulationBuilder.cpp | 6 ++++++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/GUI/coregui/Models/BackgroundItem.cpp b/GUI/coregui/Models/BackgroundItem.cpp index c0c1853cd5f..666b7d8fa1f 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 9e6aaa2be04..589e71c4073 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 830d9dd5e51..72ae94d8583 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); -- GitLab