BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
GUIExamplesFactory.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Model/FromCore/GUIExamplesFactory.cpp
6 //! @brief Implements class GUI::ExamplesFactory
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 
16 #include "Base/Util/Assert.h"
19 #include "Sample/Multilayer/MultiLayer.h"
20 #include "Sample/StandardSamples/ExemplarySamples.h"
21 #include <QMap>
22 #include <functional>
23 #include <memory>
24 
25 namespace {
26 
27 const QMap<QString, std::tuple<QString, QString, std::function<MultiLayer*()>>> builders{
28  {"CylindersAndPrismsBuilder",
29  {"Cylinder and prisms", "Mixture of cylinders and prisms without interference",
30  ExemplarySamples::createCylindersAndPrisms}},
31 
32  {"RadialParaCrystalBuilder",
33  {"Interference 1D paracrystal", "Interference 1D radial paracrystal",
34  ExemplarySamples::createRadialParaCrystal}},
35 
36  {"HexParaCrystalBuilder",
37  {"Interference 2D paracrystal", "Interference 2D paracrystal",
38  ExemplarySamples::createHexParaCrystal}},
39 
40  {"CoreShellParticleBuilder",
41  {"Core shell particles", "Core shell particles", ExemplarySamples::createCoreShellParticle}},
42 
43  {"MultiLayerWithRoughnessBuilder",
44  {"Multilayer with correlated roughness", "Multilayer with correlated roughness",
45  ExemplarySamples::createMultiLayerWithRoughness}},
46 
47  {"SquareLattice2DBuilder",
48  {"Interference 2D square lattice", "Interference 2D lattice",
49  ExemplarySamples::createSquareLattice2D}},
50 
51  {"RotatedPyramidsBuilder",
52  {"Rotated pyramids", "Rotated pyramids on top of substrate",
53  ExemplarySamples::createRotatedPyramids}},
54 
55  {"ParticleCompositionBuilder",
56  {"Hexagonal lattice with basis",
57  "Hexagonal lattice with basis to represent two layers of spheres",
58  ExemplarySamples::createParticleComposition}},
59 
60  {"MesoCrystalBuilder", {"Mesocrystal", "", ExemplarySamples::createMesoCrystal}}};
61 
62 } // namespace
63 
64 
66 {
67  return builders.find(name) != builders.end();
68 }
69 
71 {
72  ASSERT(isValidExampleName(name));
73  MultiLayer* sample = std::get<2>(builders[name])();
74 
76 }
77 
79 {
80  return builders.keys();
81 }
82 
83 std::tuple<QString, QString> GUI::ExamplesFactory::exampleInfo(const QString& name)
84 {
85  ASSERT(isValidExampleName(name));
86  auto [title, description, builder] = builders[name];
87  return {title, description};
88 }
Defines class GUI::ExamplesFactory.
Defines class GUISampleBuilder.
Defines namespace GUI::Model::ObjectBuilder.
MultiLayerItem * itemizeSample(const QString &name)
Create a sample item of the built-in example with the given internal name.
QStringList exampleNames()
The internal example name, e.g. for creation with itemizeSample.
std::tuple< QString, QString > exampleInfo(const QString &name)
Returns human readable name and description.
bool isValidExampleName(const QString &name)
QString const & name(EShape k)
Definition: particles.cpp:20
MultiLayerItem * itemizeSample(const MultiLayer &sample, const QString &nodeName)
Builds GUI sample structure from a domain sample structure.