BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
ParticleCoreShellItem Class Reference

Description

Definition at line 25 of file ParticleCoreShellItem.h.

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

Public Member Functions

 ParticleCoreShellItem (const MaterialItems *materials)
 
DoubleDescriptor abundance () const
 
void clearCore ()
 
void clearShell ()
 
QVector< ItemWithParticles * > containedItemsWithParticles () const override
 Return full hierarchical contained items with particles. More...
 
ParticleItemcore () const
 
ParticleItemcreateCore (const MaterialItems *materials)
 
std::unique_ptr< ParticleCoreShell > createParticleCoreShell () const
 
std::unique_ptr< IRotation > createRotation () const
 nullptr only if "no rotation". Can contain identity! More...
 
ParticleItemcreateShell (const MaterialItems *materials)
 
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 setPosition (const R3 &position)
 
void setRotation (RotationItem *p)
 nullptr is allowed and sets to "no rotation" More...
 
ParticleItemshell () const
 

Protected Attributes

DoubleProperty m_abundance
 
VectorProperty m_position
 
SelectionProperty< RotationItem * > m_rotation
 

Private Attributes

std::unique_ptr< ParticleItemm_core
 
const MaterialItemsm_materials
 
std::unique_ptr< ParticleItemm_shell
 

Constructor & Destructor Documentation

◆ ParticleCoreShellItem()

ParticleCoreShellItem::ParticleCoreShellItem ( const MaterialItems materials)

Definition at line 35 of file ParticleCoreShellItem.cpp.

36  : ItemWithParticles(abundance_tooltip, position_tooltip)
37  , m_materials(materials)
38 {
39 }
ItemWithParticles(const QString &abundanceTooltip, const QString &positionTooltip)
const MaterialItems * m_materials

Member Function Documentation

◆ abundance()

◆ clearCore()

void ParticleCoreShellItem::clearCore ( )

Definition at line 75 of file ParticleCoreShellItem.cpp.

76 {
77  m_core.reset();
78 }
std::unique_ptr< ParticleItem > m_core

References m_core.

◆ clearShell()

void ParticleCoreShellItem::clearShell ( )

Definition at line 92 of file ParticleCoreShellItem.cpp.

93 {
94  m_shell.reset();
95 }
std::unique_ptr< ParticleItem > m_shell

References m_shell.

◆ containedItemsWithParticles()

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

Return full hierarchical contained items with particles.

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

Implements ItemWithParticles.

Definition at line 107 of file ParticleCoreShellItem.cpp.

108 {
109  QVector<ItemWithParticles*> result;
110  if (core())
111  result << core() << core()->containedItemsWithParticles();
112  if (shell())
113  result << shell() << shell()->containedItemsWithParticles();
114  return result;
115 }
ParticleItem * shell() const
ParticleItem * core() const
QVector< ItemWithParticles * > containedItemsWithParticles() const override
Return full hierarchical contained items with particles.

References ParticleItem::containedItemsWithParticles(), core(), and shell().

Here is the call graph for this function:

◆ core()

ParticleItem * ParticleCoreShellItem::core ( ) const

◆ createCore()

ParticleItem * ParticleCoreShellItem::createCore ( const MaterialItems materials)

Definition at line 80 of file ParticleCoreShellItem.cpp.

81 {
82  m_core.reset(new ParticleItem(materials));
83  m_core->setMaterial(materials->defaultMaterial());
84  return m_core.get();
85 }
MaterialItem * defaultMaterial() const

References MaterialItems::defaultMaterial(), and m_core.

Referenced by SampleEditorController::setCoreFormFactor().

Here is the call graph for this function:

◆ createParticleCoreShell()

std::unique_ptr< ParticleCoreShell > ParticleCoreShellItem::createParticleCoreShell ( ) const

Definition at line 50 of file ParticleCoreShellItem.cpp.

51 {
52  std::unique_ptr<Particle> P_core{};
53  std::unique_ptr<Particle> P_shell{};
54  if (m_core)
55  P_core = m_core->createParticle();
56  if (m_shell)
57  P_shell = m_shell->createParticle();
58  if (!P_core || !P_shell)
59  throw Error("ParticleCoreShellItem::createParticleCoreShell -> Error. Either "
60  "core or shell particle is undefined.");
61  auto P_coreshell = std::make_unique<ParticleCoreShell>(*P_shell, *P_core);
62  P_coreshell->setAbundance(abundance());
63  P_coreshell->setParticlePosition(position());
64  if (auto r = createRotation(); r && !r->isIdentity())
65  P_coreshell->setRotation(*r);
66 
67  return P_coreshell;
68 }
std::unique_ptr< IRotation > createRotation() const
nullptr only if "no rotation". Can contain identity!
DoubleDescriptor abundance() const

References ItemWithParticles::abundance(), ItemWithParticles::createRotation(), Error, m_core, m_shell, and ItemWithParticles::position().

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
T get() const
Direct access to the stored pointer.

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

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

Here is the call graph for this function:

◆ createShell()

ParticleItem * ParticleCoreShellItem::createShell ( const MaterialItems materials)

Definition at line 97 of file ParticleCoreShellItem.cpp.

98 {
99  m_shell.reset(new ParticleItem(materials));
100  m_shell->setMaterial(materials->defaultMaterial());
101 
102  // position is not used for shell item
103  m_shell->setPosition({});
104  return m_shell.get();
105 }

References MaterialItems::defaultMaterial(), and m_shell.

Referenced by SampleEditorController::setShellFormFactor().

Here is the call graph for this function:

◆ position()

◆ positionVector()

◆ rotation()

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

◆ serialize()

void ParticleCoreShellItem::serialize ( Streamer s)
overridevirtual

Implements ItemWithParticles.

Definition at line 41 of file ParticleCoreShellItem.cpp.

42 {
43  s.assertVersion(0);
48 }
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)
void rwOptional(Streamer &s, const QString &tag, std::unique_ptr< ItemClass > &up, ArgsForConstructor... argsForConstructor)
Serializes an optional item of known type. Passes optional arguments to the constructor.
Definition: Serialize.h:142

References Streamer::assertVersion(), ItemWithParticles::m_abundance, m_core, m_materials, ItemWithParticles::m_position, m_shell, Serialize::rwOptional(), 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.

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

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:

◆ 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 }
void set(T t, bool callInitializer=false)
Directly set the new item.

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

Here is the call graph for this function:

◆ shell()

ParticleItem * ParticleCoreShellItem::shell ( ) const

Member Data Documentation

◆ m_abundance

◆ m_core

std::unique_ptr<ParticleItem> ParticleCoreShellItem::m_core
private

◆ m_materials

const MaterialItems* ParticleCoreShellItem::m_materials
private

Definition at line 45 of file ParticleCoreShellItem.h.

Referenced by serialize().

◆ m_position

◆ m_rotation

◆ m_shell

std::unique_ptr<ParticleItem> ParticleCoreShellItem::m_shell
private

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