BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
GUI::Transform::ToCore Namespace Reference

Description

Contains functions to build the domain simulation from instrument and sample models.

Functions

std::unique_ptr< ISimulation > itemsToSimulation (const MultiLayerItem *sampleItem, const InstrumentItem *instrumentItem, const SimulationOptionsItem &optionsItem)
 Creates domain simulation from sample and instrument items. More...
 
std::unique_ptr< MultiLayer > itemToSample (const MultiLayerItem &item)
 

Function Documentation

◆ itemsToSimulation()

std::unique_ptr< ISimulation > GUI::Transform::ToCore::itemsToSimulation ( const MultiLayerItem sampleItem,
const InstrumentItem instrumentItem,
const SimulationOptionsItem optionsItem 
)

Creates domain simulation from sample and instrument items.

Definition at line 161 of file SimulationToCore.cpp.

164 {
165  ASSERT(sampleItem);
166  ASSERT(instrumentItem);
167 
168  std::unique_ptr<MultiLayer> sample = GUI::Transform::ToCore::itemToSample(*sampleItem);
169  std::unique_ptr<ISimulation> result;
170 
171  if (const auto* gisasInstrument = dynamic_cast<const GISASInstrumentItem*>(instrumentItem))
172  result.reset(createScatteringSimulation(std::move(sample), gisasInstrument));
173  else if (const auto* offspecInstrument =
174  dynamic_cast<const OffspecInstrumentItem*>(instrumentItem))
175  result.reset(createOffspecSimulation(std::move(sample), offspecInstrument));
176  else if (const auto* specular_instrument =
177  dynamic_cast<const SpecularInstrumentItem*>(instrumentItem))
178  result.reset(createSpecularSimulation(std::move(sample), specular_instrument));
179  else if (const auto* penetrator = dynamic_cast<const DepthProbeInstrumentItem*>(instrumentItem))
180  result.reset(createDepthProbeSimulation(std::move(sample), penetrator));
181  else
182  ASSERT(0);
183 
184  setSimulationOptions(result.get(), optionsItem);
185 
186  return result;
187 }
std::unique_ptr< MultiLayer > itemToSample(const MultiLayerItem &item)

References itemToSample().

Referenced by FitObjectiveBuilder::buildSimulation(), PythonScriptWidget::generatePythonScript(), and JobQueueData::runJob().

Here is the call graph for this function:

◆ itemToSample()

std::unique_ptr< MultiLayer > GUI::Transform::ToCore::itemToSample ( const MultiLayerItem item)

Definition at line 125 of file SampleToCore.cpp.

126 {
127  auto sample = createMultiLayer(sampleItem);
128  for (auto* layerItem : sampleItem.layers()) {
129  auto layer = buildLayer(*layerItem);
130  ASSERT(layer);
131  const auto roughnessItem = layerItem->roughness().currentItem();
132  auto roughness = itemToLayerRoughness(roughnessItem);
133  if (roughness && !layerItem->isTopLayer())
134  sample->addLayerWithTopRoughness(*layer, *roughness);
135  else
136  sample->addLayer(*layer);
137  }
138  return sample;
139 }

References MultiLayerItem::layers().

Referenced by ScriptPanel::generateCodeSnippet(), and itemsToSimulation().

Here is the call graph for this function: