BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
RealSpaceBuilderUtils.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Realspace/RealSpaceBuilderUtils.h
6 //! @brief Defines GUI::RealSpace::BuilderUtils namespace
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 #ifndef BORNAGAIN_GUI_VIEW_REALSPACE_REALSPACEBUILDERUTILS_H
16 #define BORNAGAIN_GUI_VIEW_REALSPACE_REALSPACEBUILDERUTILS_H
17 
18 #include "Sample/Scattering/Rotations.h"
19 #include <QVector3D>
20 #include <functional>
21 #include <memory>
22 #include <utility>
23 
24 class SessionItem;
25 struct SceneGeometry;
26 class RealSpaceBuilder;
27 class IRotation;
28 class MesoCrystalItem;
29 class Particle;
30 class ParticleComposition;
31 class ParticleCoreShell;
32 class ParticleLayoutItem;
33 class IInterference;
35 class Interference2DParaCrystal;
36 
37 namespace GUI::RealSpace {
38 
39 struct Vector3D;
40 class Model;
41 namespace Particles {
42 
43 class Particle;
44 }
45 
46 } // namespace GUI::RealSpace
47 
48 namespace GUI::RealSpace {
49 
50 class BuilderUtils {
51 public:
52  BuilderUtils(std::function<QColor(const QString&)> fnColorFromMaterialName);
53 
54  // compute cumulative abundances of particles
55  QVector<double> computeCumulativeAbundances(const ParticleLayoutItem& layoutItem);
56 
58  const std::vector<std::vector<double>>& lattice_positions,
59  const std::vector<Particle3DContainer>& particle3DContainer_vector,
60  GUI::RealSpace::Model* model, const SceneGeometry& sceneGeometry,
61  const RealSpaceBuilder* builder3D);
62 
63  // Implement Rotation of a 3D particle using parameters from IRotation Object
65 
66  //! Apply transformations (translation, rotation) to a 3D Particle
67  //! or to a particle belonging to a ParticleComposition
68  void applyParticleTransformations(const Particle& particle,
70  const R3& origin = R3(0, 0, 0));
71 
72  //! Apply transformations (translation, rotation) to a particle (core/shell) in a
73  //! ParticleCoreShell
74  void applyParticleCoreShellTransformations(const Particle& particle,
76  const ParticleCoreShell& particleCoreShell,
77  const R3& origin = R3(0, 0, 0));
78 
79  // Apply color to a 3D particle
80  void applyParticleColor(const Particle& particle,
81  GUI::RealSpace::Particles::Particle& particle3D, double alpha = 1);
82 
83  std::vector<Particle3DContainer> particle3DContainerVector(const ParticleLayoutItem& layoutItem,
84  const QVector3D& origin = {});
85 
86  Particle3DContainer singleParticle3DContainer(const Particle& particle,
87  double total_abundance = 1.0,
88  const QVector3D& origin = {});
89 
90  Particle3DContainer particleCoreShell3DContainer(const ParticleCoreShell& particleCoreShell,
91  double total_abundance = 1.0,
92  const QVector3D& origin = {});
93 
96  double total_abundance = 1.0, const QVector3D& origin = {});
97 
99  double total_abundance = 1.0,
100  const QVector3D& origin = {});
101 
102 private:
103  std::function<QColor(const QString&)> m_fnColorFromMaterialName;
104 };
105 
106 } // namespace GUI::RealSpace
107 
108 #endif // BORNAGAIN_GUI_VIEW_REALSPACE_REALSPACEBUILDERUTILS_H
GUI::RealSpace::Vector3D implementParticleRotationfromIRotation(const IRotation *&rotation)
Particle3DContainer mesoCrystal3DContainer(const MesoCrystalItem &mesoCrystalItem, double total_abundance=1.0, const QVector3D &origin={})
void applyParticleCoreShellTransformations(const Particle &particle, GUI::RealSpace::Particles::Particle &particle3D, const ParticleCoreShell &particleCoreShell, const R3 &origin=R3(0, 0, 0))
Apply transformations (translation, rotation) to a particle (core/shell) in a ParticleCoreShell.
void applyParticleColor(const Particle &particle, GUI::RealSpace::Particles::Particle &particle3D, double alpha=1)
Particle3DContainer particleCoreShell3DContainer(const ParticleCoreShell &particleCoreShell, double total_abundance=1.0, const QVector3D &origin={})
std::vector< Particle3DContainer > particle3DContainerVector(const ParticleLayoutItem &layoutItem, const QVector3D &origin={})
QVector< double > computeCumulativeAbundances(const ParticleLayoutItem &layoutItem)
BuilderUtils(std::function< QColor(const QString &)> fnColorFromMaterialName)
std::function< QColor(const QString &)> m_fnColorFromMaterialName
void populateParticlesAtLatticePositions(const std::vector< std::vector< double >> &lattice_positions, const std::vector< Particle3DContainer > &particle3DContainer_vector, GUI::RealSpace::Model *model, const SceneGeometry &sceneGeometry, const RealSpaceBuilder *builder3D)
void applyParticleTransformations(const Particle &particle, GUI::RealSpace::Particles::Particle &particle3D, const R3 &origin=R3(0, 0, 0))
Apply transformations (translation, rotation) to a 3D Particle or to a particle belonging to a Partic...
Particle3DContainer singleParticle3DContainer(const Particle &particle, double total_abundance=1.0, const QVector3D &origin={})
Particle3DContainer particleComposition3DContainer(const ParticleComposition &particleComposition3DContainer, double total_abundance=1.0, const QVector3D &origin={})
Base class for a GUI data item.
Definition: SessionItem.h:204
Size and thickness information of layers.