BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
SampleValidator Class Reference

Description

Validates whether MultiLayerItem is suitable for simulation.

Definition at line 25 of file SampleValidator.h.

Public Member Functions

QString getValidationMessage () const
 
bool isValidMultiLayer (const MultiLayerItem *sample)
 

Private Member Functions

void addMessage (const QString &m)
 Adds this message to the report. More...
 
void validateInterferences (const LayerItem *item)
 
void validateItem (const ItemWithParticles *item)
 

Private Attributes

QString m_messages
 

Member Function Documentation

◆ addMessage()

void SampleValidator::addMessage ( const QString &  m)
private

Adds this message to the report.

Definition at line 59 of file SampleValidator.cpp.

60 {
61  m_messages += QString("* ") + m + "\n";
62 }

References m_messages.

Referenced by isValidMultiLayer(), validateInterferences(), and validateItem().

◆ getValidationMessage()

QString SampleValidator::getValidationMessage ( ) const
inline

Definition at line 29 of file SampleValidator.h.

29 { return m_messages; }

References m_messages.

Referenced by SimulationView::validateSimulationSetup().

◆ isValidMultiLayer()

bool SampleValidator::isValidMultiLayer ( const MultiLayerItem sample)

Definition at line 64 of file SampleValidator.cpp.

65 {
66  m_messages.clear();
67 
68  QVector<LayerItem*> layers = sample->layers();
69 
70  if (layers.isEmpty())
71  addMessage("MultiLayer should contain at least one layer.");
72  if (layers.size() == 1)
73  if (layers.front()->layouts().isEmpty())
74  addMessage("The single layer in your MultiLayer should contain a particle layout.");
75 
76  for (const auto* layer : layers) {
77  validateInterferences(layer);
78  for (const auto* layout : layer->layouts()) {
79  if (layout->particles().isEmpty())
80  addMessage("Particle layout doesn't contain any particles.");
81  for (const auto* particle : layout->containedItemsWithParticles()) {
82  validateItem(particle);
83  }
84  }
85  }
86  if (!m_messages.isEmpty())
87  m_messages = "Can't setup DWBA simulation for given MultiLayer.\n" + m_messages;
88 
89  return m_messages.isEmpty();
90 }
QVector< LayerItem * > layers() const
void validateInterferences(const LayerItem *item)
void addMessage(const QString &m)
Adds this message to the report.
void validateItem(const ItemWithParticles *item)

References addMessage(), MultiLayerItem::layers(), m_messages, validateInterferences(), and validateItem().

Referenced by SimulationView::validateSimulationSetup().

Here is the call graph for this function:

◆ validateInterferences()

void SampleValidator::validateInterferences ( const LayerItem item)
private

Definition at line 36 of file SampleValidator.cpp.

37 {
38  ASSERT(layer);
39 #ifdef WIN32
40 
41  int iLayout = 0;
42  for (const auto* layout : layer->layouts()) {
43  iLayout++;
44  if (const auto* c = dynamic_cast<const Interference2DAbstractLatticeItem*>(
45  layout->interference().currentItem()))
46  if (c->xiIntegration()) {
47  const QString message =
48  QString("Interference function of layer '%1', Particle layout %2: "
49  "Integration over Xi is currently not supported "
50  "under Windows")
51  .arg(layer->layerName())
52  .arg(iLayout);
53  addMessage(message);
54  }
55  }
56 #endif
57 }

References addMessage(), LayerItem::layerName(), and LayerItem::layouts().

Referenced by isValidMultiLayer().

Here is the call graph for this function:

◆ validateItem()

void SampleValidator::validateItem ( const ItemWithParticles item)
private

Definition at line 24 of file SampleValidator.cpp.

25 {
26  if (const auto* p = dynamic_cast<const ParticleCoreShellItem*>(item)) {
27  if (!p->core())
28  addMessage("Sim/shell particle doesn't have core defined.");
29  if (!p->shell())
30  addMessage("Sim/shell particle doesn't have shell defined.");
31  } else if (const auto* p = dynamic_cast<const ParticleCompositionItem*>(item))
32  if (p->particles().isEmpty())
33  addMessage("Particle composition doesn't have any particles.");
34 }

References addMessage().

Referenced by isValidMultiLayer().

Here is the call graph for this function:

Member Data Documentation

◆ m_messages

QString SampleValidator::m_messages
private

Definition at line 39 of file SampleValidator.h.

Referenced by addMessage(), getValidationMessage(), and isValidMultiLayer().


The documentation for this class was generated from the following files: