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

Description

Definition at line 24 of file ParticleCompositionItem.h.

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

Public Member Functions

 ParticleCompositionItem (const MaterialItems *materials)
 
DoubleDescriptor abundance () const
 
void addParticle (ItemWithParticles *particle)
 
QVector< ItemWithParticles * > containedItemsWithParticles () const override
 Return full hierarchical contained items with particles. More...
 
std::unique_ptr< ParticleComposition > createParticleComposition () const
 
std::unique_ptr< IRotation > createRotation () const
 nullptr only if "no rotation". Can contain identity! More...
 
QVector< ItemWithParticles * > particles () const
 
R3 position () const
 
VectorDescriptor positionVector () const
 
void removeParticle (ItemWithParticles *particle)
 
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...
 

Protected Attributes

DoubleProperty m_abundance
 
VectorProperty m_position
 
SelectionProperty< RotationItem * > m_rotation
 

Private Attributes

const MaterialItemsm_materials
 
QVector< ItemWithParticles * > m_particles
 

Constructor & Destructor Documentation

◆ ParticleCompositionItem()

ParticleCompositionItem::ParticleCompositionItem ( const MaterialItems materials)

Definition at line 38 of file ParticleCompositionItem.cpp.

39  : ItemWithParticles(abundance_tooltip, position_tooltip)
40  , m_materials(materials)
41 {
42  ASSERT(m_materials);
43 }
ItemWithParticles(const QString &abundanceTooltip, const QString &positionTooltip)
const MaterialItems * m_materials

References m_materials.

Member Function Documentation

◆ abundance()

◆ addParticle()

void ParticleCompositionItem::addParticle ( ItemWithParticles particle)

Definition at line 86 of file ParticleCompositionItem.cpp.

87 {
88  m_particles << particle;
89 }
QVector< ItemWithParticles * > m_particles

References m_particles.

Referenced by SampleEditorController::addParticle().

◆ containedItemsWithParticles()

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

Return full hierarchical contained items with particles.

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

Implements ItemWithParticles.

Definition at line 97 of file ParticleCompositionItem.cpp.

98 {
99  QVector<ItemWithParticles*> result;
100  for (auto* particle : m_particles)
101  result << particle << particle->containedItemsWithParticles();
102  return result;
103 }

References m_particles.

◆ createParticleComposition()

std::unique_ptr< ParticleComposition > ParticleCompositionItem::createParticleComposition ( ) const

Definition at line 54 of file ParticleCompositionItem.cpp.

55 {
56  auto P_composition = std::make_unique<ParticleComposition>();
57  P_composition->setAbundance(abundance());
58  for (auto* p : m_particles) {
59  if (auto* particleItem = dynamic_cast<ParticleItem*>(p)) {
60  if (auto P_particle = particleItem->createParticle())
61  P_composition->addParticle(*P_particle);
62  } else if (auto* coreShellItem = dynamic_cast<ParticleCoreShellItem*>(p)) {
63  if (auto P_particle_coreshell = coreShellItem->createParticleCoreShell())
64  P_composition->addParticle(*P_particle_coreshell);
65  } else if (auto* compositionItem = dynamic_cast<ParticleCompositionItem*>(p)) {
66  if (auto P_child_composition = compositionItem->createParticleComposition())
67  P_composition->addParticle(*P_child_composition);
68  } else if (auto* mesoCrystalItem = dynamic_cast<MesoCrystalItem*>(p)) {
69  if (auto P_meso = mesoCrystalItem->createMesoCrystal())
70  P_composition->addParticle(*P_meso);
71  }
72  }
73 
74  P_composition->setParticlePosition(position());
75  if (const auto r = createRotation(); r && !r->isIdentity())
76  P_composition->setRotation(*r);
77 
78  return P_composition;
79 }
std::unique_ptr< IRotation > createRotation() const
nullptr only if "no rotation". Can contain identity!
DoubleDescriptor abundance() const

References ItemWithParticles::abundance(), ItemWithParticles::createRotation(), m_particles, 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(), createParticleComposition(), and ParticleCoreShellItem::createParticleCoreShell().

Here is the call graph for this function:

◆ particles()

QVector< ItemWithParticles * > ParticleCompositionItem::particles ( ) const

◆ position()

◆ positionVector()

◆ removeParticle()

void ParticleCompositionItem::removeParticle ( ItemWithParticles particle)

Definition at line 91 of file ParticleCompositionItem.cpp.

92 {
93  m_particles.removeAll(particle);
94  delete particle;
95 }

References m_particles.

◆ rotation()

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

◆ serialize()

void ParticleCompositionItem::serialize ( Streamer s)
overridevirtual

Implements ItemWithParticles.

Definition at line 45 of file ParticleCompositionItem.cpp.

46 {
47  s.assertVersion(0);
50  Serialize::rwSelected<RotationItemCatalog>(s, m_rotation);
51  Serialize::rwCatalogized<ItemWithParticlesCatalog>(s, "Particles", m_particles, m_materials);
52 }
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_materials, m_particles, ItemWithParticles::m_position, ItemWithParticles::m_rotation, 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:

Member Data Documentation

◆ m_abundance

◆ m_materials

const MaterialItems* ParticleCompositionItem::m_materials
private

Definition at line 39 of file ParticleCompositionItem.h.

Referenced by ParticleCompositionItem(), and serialize().

◆ m_particles

QVector<ItemWithParticles*> ParticleCompositionItem::m_particles
private

◆ m_position

◆ m_rotation


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