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
15
#include "
GUI/Model/Sample/SampleValidator.h
"
16
#include "
GUI/Model/Sample/InterferenceItems.h
"
17
#include "
GUI/Model/Sample/LayerItem.h
"
18
#include "
GUI/Model/Sample/MultiLayerItem.h
"
19
#include "
GUI/Model/Sample/ParticleCompositionItem.h
"
20
#include "
GUI/Model/Sample/ParticleCoreShellItem.h
"
21
#include "
GUI/Model/Sample/ParticleLayoutItem.h
"
22
23
24
void
SampleValidator::validateItem
(
const
ItemWithParticles
* item)
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
36
void
SampleValidator::validateInterferences
(
const
LayerItem
* layer)
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
64
bool
SampleValidator::isValidMultiLayer
(
const
MultiLayerItem
* sample)
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
}
InterferenceItems.h
Defines InterferenceItems's classes.
LayerItem.h
Defines class LayerItem.
MultiLayerItem.h
Defines class MultiLayerItem.
ParticleCompositionItem.h
Defines class ParticleCompositionItem.
ParticleCoreShellItem.h
Defines class ParticleCoreShellItem.
ParticleLayoutItem.h
Defines class ParticleLayoutItem.
SampleValidator.h
Defines class SampleValidator.
Interference2DAbstractLatticeItem
Definition:
InterferenceItems.h:65
ItemWithParticles
Definition:
ItemWithParticles.h:27
LayerItem
Definition:
LayerItem.h:36
LayerItem::layouts
QVector< ParticleLayoutItem * > layouts() const
Definition:
LayerItem.cpp:136
LayerItem::layerName
QString layerName() const
Definition:
LayerItem.cpp:75
MultiLayerItem
Definition:
MultiLayerItem.h:31
MultiLayerItem::layers
QVector< LayerItem * > layers() const
Definition:
MultiLayerItem.cpp:91
ParticleCompositionItem
Definition:
ParticleCompositionItem.h:24
ParticleCoreShellItem
Definition:
ParticleCoreShellItem.h:25
SampleValidator::validateInterferences
void validateInterferences(const LayerItem *item)
Definition:
SampleValidator.cpp:36
SampleValidator::m_messages
QString m_messages
Definition:
SampleValidator.h:39
SampleValidator::addMessage
void addMessage(const QString &m)
Adds this message to the report.
Definition:
SampleValidator.cpp:59
SampleValidator::isValidMultiLayer
bool isValidMultiLayer(const MultiLayerItem *sample)
Definition:
SampleValidator.cpp:64
SampleValidator::validateItem
void validateItem(const ItemWithParticles *item)
Definition:
SampleValidator.cpp:24
GUI
Model
Sample
SampleValidator.cpp
Generated by
1.9.1