BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
SampleValidator.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Model/Sample/SampleValidator.cpp
6 //! @brief Implements class SampleValidator
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
22 
23 
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 }
35 
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 }
58 
59 void SampleValidator::addMessage(const QString& m)
60 {
61  m_messages += QString("* ") + m + "\n";
62 }
63 
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 }
Defines InterferenceItems's classes.
Defines class LayerItem.
Defines class MultiLayerItem.
Defines class ParticleCompositionItem.
Defines class ParticleCoreShellItem.
Defines class ParticleLayoutItem.
Defines class SampleValidator.
QVector< ParticleLayoutItem * > layouts() const
Definition: LayerItem.cpp:136
QString layerName() const
Definition: LayerItem.cpp:75
QVector< LayerItem * > layers() const
void validateInterferences(const LayerItem *item)
void addMessage(const QString &m)
Adds this message to the report.
bool isValidMultiLayer(const MultiLayerItem *sample)
void validateItem(const ItemWithParticles *item)