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

Description

Contains set of methods to populate GUI models with content from domain.

Functions

InstrumentCollectionitemizeInstruments (const ISimulation &simulation)
 
SimulationOptionsItemitemizeOptions (const ISimulation &simulation)
 
MultiLayerItemitemizeSample (const MultiLayer &sample, const QString &nodeName="")
 Builds GUI sample structure from a domain sample structure. More...
 

Function Documentation

◆ itemizeInstruments()

InstrumentCollection * GUI::Transform::FromCore::itemizeInstruments ( const ISimulation &  simulation)

Definition at line 500 of file ItemizeSimulation.cpp.

501 {
502  InstrumentItem* item;
503 
504  if (const auto* gisasSimulation = dynamic_cast<const ScatteringSimulation*>(&simulation))
505  item = createGISASInstrumentItem(*gisasSimulation);
506  else if (const auto* offspecSimulation = dynamic_cast<const OffspecSimulation*>(&simulation))
507  item = createOffspecInstrumentItem(*offspecSimulation);
508  else if (const auto* spec_simulation = dynamic_cast<const SpecularSimulation*>(&simulation))
509  item = createSpecularInstrumentItem(*spec_simulation);
510  else
511  ASSERT(0);
512 
513  setBackground(item, simulation);
514 
515  auto* collection = new InstrumentCollection;
516  collection->emplace_back(item);
517  return collection;
518 }
void emplace_back(InstrumentItem *item)
Abstract base class for instrument-specific item classes.

References InstrumentCollection::emplace_back().

Here is the call graph for this function:

◆ itemizeOptions()

SimulationOptionsItem * GUI::Transform::FromCore::itemizeOptions ( const ISimulation &  simulation)

Definition at line 520 of file ItemizeSimulation.cpp.

521 {
522  auto* result = new SimulationOptionsItem;
523 
524  if (simulation.options().isIntegrate())
526  static_cast<unsigned>(simulation.options().getMcPoints()));
527  else
528  result->setUseAnalytical();
529 
530  result->setUseAverageMaterials(simulation.options().useAvgMaterials());
531  result->setIncludeSpecularPeak(simulation.options().includeSpecular());
532 
533  return result;
534 }
The SimulationOptionsItem class holds simulation status (run policy, number of threads,...
void setUseMonteCarloIntegration(unsigned numberOfPoints)

References SimulationOptionsItem::setUseMonteCarloIntegration().

Here is the call graph for this function:

◆ itemizeSample()

MultiLayerItem * GUI::Transform::FromCore::itemizeSample ( const MultiLayer &  sample,
const QString &  nodeName 
)

Builds GUI sample structure from a domain sample structure.

Definition at line 634 of file ItemizeSample.cpp.

635 {
636  auto* result = new MultiLayerItem();
637  result->setSampleName(nodeName.isEmpty() ? QString::fromStdString(sample.sampleName())
638  : nodeName);
639  result->crossCorrLength().set(sample.crossCorrLength());
640  result->setExternalField(sample.externalField());
641 
642  MaterialItems& matItems = result->materialItems();
643 
644  // iterate over layers
645  for (size_t layerIndex = 0; layerIndex < sample.numberOfLayers(); layerIndex++) {
646  const auto* layer = sample.layer(layerIndex);
647 
648  const LayerInterface* top_interface =
649  layerIndex == 0 ? nullptr : sample.layerInterface(layerIndex - 1);
650 
651  auto* layerItem = result->addLayer();
652  layerItem->setMaterial(findMaterialItem(matItems, layer));
653  layerItem->setIsTopLayer(layerIndex == 0);
654  layerItem->setIsBottomLayer(layerIndex == sample.numberOfLayers() - 1);
655 
656  setLayerItem(layerItem, layer, top_interface);
657 
658  // iterate over particle layouts
659  for (const auto* layout : layer->layouts()) {
660  auto* layoutItem = layerItem->addLayout();
661  layoutItem->ownDensity().set(layout->totalParticleSurfaceDensity());
662  layoutItem->weight().set(layout->weight());
663  setInterference(layoutItem, layout->interferenceFunction());
664 
665  // create particles/particle compositions
666  for (const IParticle* particle : layout->particles())
667  copyParticle(particle, matItems,
668  [=](ItemWithParticles* p) { layoutItem->addParticle(p); });
669  }
670  }
671 
672  return result;
673 }
const QVector< MaterialItem * > & materialItems() const

References LayerItem::addLayout(), ParticleLayoutItem::addParticle(), MaterialItems::materialItems(), ParticleLayoutItem::ownDensity(), DoubleDescriptor::set, LayerItem::setIsBottomLayer(), LayerItem::setIsTopLayer(), ItemWithMaterial::setMaterial(), and ParticleLayoutItem::weight().

Referenced by PyImportAssistant::itemizeSample(), and GUI::ExamplesFactory::itemizeSample().

Here is the call graph for this function: