BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
MesoCrystalItem Class Reference

Description

Definition at line 30 of file MesoCrystalItem.h.

Inheritance diagram for MesoCrystalItem:
[legend]
Collaboration diagram for MesoCrystalItem:
[legend]

Public Member Functions

 MesoCrystalItem (const MaterialItems *materials)
 
DoubleDescriptor abundance () const
 
ItemWithParticlesbasisParticle () const
 
QVector< ItemWithParticles * > containedItemsWithParticles () const override
 Return full hierarchical contained items with particles. More...
 
std::unique_ptr< MesoCrystal > createMesoCrystal () const
 
std::unique_ptr< IRotation > createRotation () const
 nullptr only if "no rotation". Can contain identity! More...
 
std::unique_ptr< IParticle > getBasis () const
 
Lattice3D getLattice () const
 
std::unique_ptr< IFormFactor > getOuterShape () const
 
SelectionDescriptor< FormFactorItem * > outerShape () const
 
R3 position () const
 
VectorDescriptor positionVector () const
 
SelectionDescriptor< RotationItem * > rotation ()
 Returns selection descriptor for rotation methods. More...
 
void serialize (Streamer &s) override
 
void setAbundance (double abundance)
 
void setBasis (ItemWithParticles *basis)
 
void setOuterShape (FormFactorItem *p)
 
template<typename T >
T * setOuterShapeType ()
 
void setPosition (const R3 &position)
 
void setRawDataVectorA (const R3 &vector_a)
 
void setRawDataVectorB (const R3 &vector_b)
 
void setRawDataVectorC (const R3 &vector_c)
 
void setRotation (RotationItem *p)
 nullptr is allowed and sets to "no rotation" More...
 
VectorDescriptor vectorA () const
 
VectorDescriptor vectorB () const
 
VectorDescriptor vectorC () const
 

Protected Attributes

DoubleProperty m_abundance
 
VectorProperty m_position
 
SelectionProperty< RotationItem * > m_rotation
 

Private Attributes

SelectionProperty< ItemWithParticles * > m_basisParticle
 
const MaterialItemsm_materials
 
SelectionProperty< FormFactorItem * > m_outerShape
 
VectorProperty m_vectorA
 
VectorProperty m_vectorB
 
VectorProperty m_vectorC
 

Constructor & Destructor Documentation

◆ MesoCrystalItem()

MesoCrystalItem::MesoCrystalItem ( const MaterialItems materials)
explicit

Definition at line 42 of file MesoCrystalItem.cpp.

43  : ItemWithParticles(abundance_tooltip, position_tooltip)
44  , m_materials(materials)
45 {
46  m_vectorA.init("First lattice vector", "Coordinates of the first lattice vector",
47  Unit::nanometer, "vectorA");
48  m_vectorB.init("Second lattice vector", "Coordinates of the second lattice vector",
49  Unit::nanometer, "vectorB");
50  m_vectorC.init("Third lattice vector", "Coordinates of the third lattice vector",
51  Unit::nanometer, "vectorC");
52 
53  m_outerShape.init<FormFactorItemCatalog>("Outer Shape", "", "outerShape");
54  m_basisParticle.init<ItemWithParticlesCatalog>("Basis", "", "basis", materials);
55 }
@ nanometer
ItemWithParticles(const QString &abundanceTooltip, const QString &positionTooltip)
VectorProperty m_vectorB
const MaterialItems * m_materials
VectorProperty m_vectorC
SelectionProperty< FormFactorItem * > m_outerShape
VectorProperty m_vectorA
SelectionProperty< ItemWithParticles * > m_basisParticle
void init(const QString &label, const QString &tooltip, const QString &persistentTag, ArgsForCreation... argsForCreation)
Initialize by means of a catalog class and optional creation arguments.
void init(const QString &label, const QString &tooltip, const variant< QString, Unit > &unit, const QString &persistentTag)

References SelectionProperty< T >::init(), VectorProperty::init(), m_basisParticle, m_outerShape, m_vectorA, m_vectorB, m_vectorC, and nanometer.

Here is the call graph for this function:

Member Function Documentation

◆ abundance()

◆ basisParticle()

ItemWithParticles * MesoCrystalItem::basisParticle ( ) const

Definition at line 132 of file MesoCrystalItem.cpp.

133 {
134  return m_basisParticle.get();
135 }
T get() const
Direct access to the stored pointer.

References SelectionProperty< T >::get(), and m_basisParticle.

Referenced by MesoCrystalForm::MesoCrystalForm(), containedItemsWithParticles(), SampleEditorController::createAndInitParticle(), and MesoCrystalForm::createBasisWidgets().

Here is the call graph for this function:

◆ containedItemsWithParticles()

QVector< ItemWithParticles * > MesoCrystalItem::containedItemsWithParticles ( ) const
overridevirtual

Return full hierarchical contained items with particles.

For example ParticleCompositionItem contains other items, ParticleItem doesn't.

Implements ItemWithParticles.

Definition at line 172 of file MesoCrystalItem.cpp.

173 {
174  QVector<ItemWithParticles*> result;
175  if (basisParticle())
177  return result;
178 }
virtual QVector< ItemWithParticles * > containedItemsWithParticles() const =0
Return full hierarchical contained items with particles.
ItemWithParticles * basisParticle() const

References basisParticle(), and ItemWithParticles::containedItemsWithParticles().

Here is the call graph for this function:

◆ createMesoCrystal()

std::unique_ptr< MesoCrystal > MesoCrystalItem::createMesoCrystal ( ) const

Definition at line 70 of file MesoCrystalItem.cpp.

71 {
72  const Lattice3D& lattice = getLattice();
73  if (!(lattice.unitCellVolume() > 0.0))
74  throw Error("MesoCrystalItem::createMesoCrystal(): "
75  "Lattice volume not strictly positive");
76  std::unique_ptr<IParticle> basis = getBasis();
77  if (!basis)
78  throw Error("MesoCrystalItem::createMesoCrystal(): "
79  "No basis particle defined");
80  Crystal crystal(*basis, lattice);
81 
82  std::unique_ptr<IFormFactor> ff = getOuterShape();
83  if (!ff)
84  throw Error("MesoCrystalItem::createMesoCrystal(): "
85  "No outer shape defined");
86 
87  auto result = std::make_unique<MesoCrystal>(crystal, *ff);
88  result->setParticlePosition(position());
89  if (auto r = createRotation(); r && !r->isIdentity())
90  result->setRotation(*r);
91 
92  return result;
93 }
std::unique_ptr< IRotation > createRotation() const
nullptr only if "no rotation". Can contain identity!
std::unique_ptr< IFormFactor > getOuterShape() const
std::unique_ptr< IParticle > getBasis() const
Lattice3D getLattice() const

References ItemWithParticles::createRotation(), Error, getBasis(), getLattice(), getOuterShape(), and ItemWithParticles::position().

Referenced by RealSpaceMesoCrystal::populateMesoCrystal().

Here is the call graph for this function:

◆ createRotation()

std::unique_ptr< IRotation > ItemWithParticles::createRotation ( ) const
inherited

nullptr only if "no rotation". Can contain identity!

Definition at line 67 of file ItemWithParticles.cpp.

68 {
69  if (!m_rotation.get())
70  return {};
71  const auto matrix = m_rotation->rotation();
72  return std::unique_ptr<IRotation>(IRotation::createRotation(matrix));
73 }
SelectionProperty< RotationItem * > m_rotation
RotMatrix rotation() const

References SelectionProperty< T >::get(), ItemWithParticles::m_rotation, and RotationItem::rotation().

Referenced by createMesoCrystal(), ParticleItem::createParticle(), ParticleCompositionItem::createParticleComposition(), and ParticleCoreShellItem::createParticleCoreShell().

Here is the call graph for this function:

◆ getBasis()

std::unique_ptr< IParticle > MesoCrystalItem::getBasis ( ) const

Definition at line 100 of file MesoCrystalItem.cpp.

101 {
102  if (auto* p = dynamic_cast<ParticleItem*>(m_basisParticle.get()))
103  return p->createParticle();
104 
105  if (auto* p = dynamic_cast<ParticleCoreShellItem*>(m_basisParticle.get()))
106  return p->createParticleCoreShell();
107 
108  if (auto* p = dynamic_cast<ParticleCompositionItem*>(m_basisParticle.get()))
109  return p->createParticleComposition();
110 
111  if (auto* p = dynamic_cast<MesoCrystalItem*>(m_basisParticle.get()))
112  return p->createMesoCrystal();
113 
114  return {};
115 }

References SelectionProperty< T >::get(), and m_basisParticle.

Referenced by createMesoCrystal(), and RealSpaceMesoCrystal::populateMesoCrystal().

Here is the call graph for this function:

◆ getLattice()

Lattice3D MesoCrystalItem::getLattice ( ) const

Definition at line 95 of file MesoCrystalItem.cpp.

96 {
97  return Lattice3D(m_vectorA, m_vectorB, m_vectorC);
98 }

References m_vectorA, m_vectorB, and m_vectorC.

Referenced by createMesoCrystal(), and RealSpaceMesoCrystal::populateMesoCrystal().

◆ getOuterShape()

std::unique_ptr< IFormFactor > MesoCrystalItem::getOuterShape ( ) const

Definition at line 117 of file MesoCrystalItem.cpp.

118 {
119  return m_outerShape->createFormFactor();
120 }
virtual std::unique_ptr< IFormFactor > createFormFactor() const =0

References FormFactorItem::createFormFactor(), and m_outerShape.

Referenced by createMesoCrystal(), and RealSpaceMesoCrystal::populateMesoCrystal().

Here is the call graph for this function:

◆ outerShape()

SelectionDescriptor< FormFactorItem * > MesoCrystalItem::outerShape ( ) const

Definition at line 122 of file MesoCrystalItem.cpp.

123 {
124  return m_outerShape;
125 }

References m_outerShape.

Referenced by MesoCrystalForm::MesoCrystalForm().

◆ position()

◆ positionVector()

◆ rotation()

SelectionDescriptor< RotationItem * > ItemWithParticles::rotation ( )
inherited

◆ serialize()

void MesoCrystalItem::serialize ( Streamer s)
overridevirtual

Implements ItemWithParticles.

Definition at line 57 of file MesoCrystalItem.cpp.

58 {
59  s.assertVersion(0);
62  Serialize::rwSelected<RotationItemCatalog>(s, m_rotation);
66  Serialize::rwSelected<FormFactorItemCatalog>(s, m_outerShape);
67  Serialize::rwSelected<ItemWithParticlesCatalog>(s, m_basisParticle, m_materials);
68 }
void assertVersion(unsigned expectedVersion) const
As reader, throws DeserializationException unless the expected version is read. As writer,...
Definition: Streamer.cpp:26
void rwProperty(Streamer &s, DoubleProperty &d)

References Streamer::assertVersion(), ItemWithParticles::m_abundance, m_basisParticle, m_materials, m_outerShape, ItemWithParticles::m_position, ItemWithParticles::m_rotation, m_vectorA, m_vectorB, m_vectorC, and Serialize::rwProperty().

Here is the call graph for this function:

◆ setAbundance()

void ItemWithParticles::setAbundance ( double  abundance)
inherited

Definition at line 37 of file ItemWithParticles.cpp.

38 {
40 }
void set(double d)
Set the contained value.
DoubleDescriptor abundance() const

References ItemWithParticles::abundance(), ItemWithParticles::m_abundance, and DoubleProperty::set().

Here is the call graph for this function:

◆ setBasis()

void MesoCrystalItem::setBasis ( ItemWithParticles basis)

Definition at line 137 of file MesoCrystalItem.cpp.

138 {
139  m_basisParticle.set(basis);
140 }
void set(T t, bool callInitializer=false)
Directly set the new item.

References m_basisParticle, and SelectionProperty< T >::set().

Referenced by SampleEditorController::setMesoCrystalBasis().

Here is the call graph for this function:

◆ setOuterShape()

void MesoCrystalItem::setOuterShape ( FormFactorItem p)

Definition at line 127 of file MesoCrystalItem.cpp.

128 {
129  m_outerShape.set(p);
130 }

References m_outerShape, and SelectionProperty< T >::set().

Referenced by setOuterShapeType().

Here is the call graph for this function:

◆ setOuterShapeType()

template<typename T >
T * MesoCrystalItem::setOuterShapeType

Definition at line 70 of file MesoCrystalItem.h.

71 {
72  auto* p = new T();
73  setOuterShape(p);
74  return p;
75 }
void setOuterShape(FormFactorItem *p)

References setOuterShape().

Here is the call graph for this function:

◆ setPosition()

void ItemWithParticles::setPosition ( const R3 &  position)
inherited

Definition at line 47 of file ItemWithParticles.cpp.

48 {
50 }
void set(const R3 &d)

References ItemWithParticles::m_position, ItemWithParticles::position(), and VectorProperty::set().

Here is the call graph for this function:

◆ setRawDataVectorA()

void MesoCrystalItem::setRawDataVectorA ( const R3 &  vector_a)

Definition at line 142 of file MesoCrystalItem.cpp.

143 {
144  m_vectorA.set(v);
145 }

References m_vectorA, and VectorProperty::set().

Here is the call graph for this function:

◆ setRawDataVectorB()

void MesoCrystalItem::setRawDataVectorB ( const R3 &  vector_b)

Definition at line 147 of file MesoCrystalItem.cpp.

148 {
149  m_vectorB.set(v);
150 }

References m_vectorB, and VectorProperty::set().

Here is the call graph for this function:

◆ setRawDataVectorC()

void MesoCrystalItem::setRawDataVectorC ( const R3 &  vector_c)

Definition at line 152 of file MesoCrystalItem.cpp.

153 {
154  m_vectorC.set(v);
155 }

References m_vectorC, and VectorProperty::set().

Here is the call graph for this function:

◆ setRotation()

void ItemWithParticles::setRotation ( RotationItem p)
inherited

nullptr is allowed and sets to "no rotation"

Definition at line 62 of file ItemWithParticles.cpp.

63 {
64  m_rotation.set(p);
65 }

References ItemWithParticles::m_rotation, and SelectionProperty< T >::set().

Here is the call graph for this function:

◆ vectorA()

VectorDescriptor MesoCrystalItem::vectorA ( ) const

Definition at line 157 of file MesoCrystalItem.cpp.

158 {
159  return m_vectorA;
160 }

References m_vectorA.

Referenced by MesoCrystalForm::MesoCrystalForm().

◆ vectorB()

VectorDescriptor MesoCrystalItem::vectorB ( ) const

Definition at line 162 of file MesoCrystalItem.cpp.

163 {
164  return m_vectorB;
165 }

References m_vectorB.

Referenced by MesoCrystalForm::MesoCrystalForm().

◆ vectorC()

VectorDescriptor MesoCrystalItem::vectorC ( ) const

Definition at line 167 of file MesoCrystalItem.cpp.

168 {
169  return m_vectorC;
170 }

References m_vectorC.

Referenced by MesoCrystalForm::MesoCrystalForm().

Member Data Documentation

◆ m_abundance

◆ m_basisParticle

SelectionProperty<ItemWithParticles*> MesoCrystalItem::m_basisParticle
private

Definition at line 65 of file MesoCrystalItem.h.

Referenced by MesoCrystalItem(), basisParticle(), getBasis(), serialize(), and setBasis().

◆ m_materials

const MaterialItems* MesoCrystalItem::m_materials
private

Definition at line 66 of file MesoCrystalItem.h.

Referenced by serialize().

◆ m_outerShape

SelectionProperty<FormFactorItem*> MesoCrystalItem::m_outerShape
private

◆ m_position

◆ m_rotation

◆ m_vectorA

VectorProperty MesoCrystalItem::m_vectorA
private

Definition at line 61 of file MesoCrystalItem.h.

Referenced by MesoCrystalItem(), getLattice(), serialize(), setRawDataVectorA(), and vectorA().

◆ m_vectorB

VectorProperty MesoCrystalItem::m_vectorB
private

Definition at line 62 of file MesoCrystalItem.h.

Referenced by MesoCrystalItem(), getLattice(), serialize(), setRawDataVectorB(), and vectorB().

◆ m_vectorC

VectorProperty MesoCrystalItem::m_vectorC
private

Definition at line 63 of file MesoCrystalItem.h.

Referenced by MesoCrystalItem(), getLattice(), serialize(), setRawDataVectorC(), and vectorC().


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