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

Description

Definition at line 26 of file ParticleItem.h.

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

Public Member Functions

 ParticleItem (const MaterialItems *materials)
 
DoubleDescriptor abundance () const
 
QVector< ItemWithParticles * > containedItemsWithParticles () const override
 Return full hierarchical contained items with particles. More...
 
std::unique_ptr< Particle > createParticle () const
 
std::unique_ptr< IRotation > createRotation () const
 nullptr only if "no rotation". Can contain identity! More...
 
FormFactorItem * formfactor_at_bottom () const
 
QColor materialColor () const
 
QString materialIdentifier () const
 
MaterialItem * materialItem () const
 Returns the material item this item links to. More...
 
QString materialName () 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 setFormFactor (FormFactorItem *p)
 
template<typename T >
T * setFormFactorType ()
 
void setMaterial (const MaterialItem *materialItem)
 Set the material this item shall use. Stores the identifier, not the pointer! More...
 
void setMaterial (const QString &materialIdentifier)
 Set the material this item shall use. Stores the given identifier, not a pointer to the material! More...
 
void setMaterialUndefined ()
 Set "no material defined". More...
 
void setPosition (const R3 &position)
 
void setRotation (RotationItem *p)
 nullptr is allowed and sets to "no rotation" More...
 

Protected Attributes

DoubleProperty m_abundance
 
QString m_materialIdentifier
 
const MaterialItems * m_materialItems
 
VectorProperty m_position
 
SelectionProperty< RotationItem * > m_rotation
 

Private Attributes

SelectionProperty< FormFactorItem * > m_formFactor
 

Constructor & Destructor Documentation

◆ ParticleItem()

ParticleItem::ParticleItem ( const MaterialItems *  materials)

Definition at line 35 of file ParticleItem.cpp.

36  : ItemWithMaterial(materials)
37  , ItemWithParticles(abundance_tooltip, position_tooltip)
38 {
39  m_formFactor.init<FormFactorItemCatalog>("Form Factor", "", "formFactor");
41 }
ItemWithMaterial(const MaterialItems *materials)
Overhand the material list where the current material has to be searched for.
ItemWithParticles(const QString &abundanceTooltip, const QString &positionTooltip)
SelectionProperty< FormFactorItem * > m_formFactor
Definition: ParticleItem.h:40
void set(T t, bool callInitializer=false)
Directly set the new item.
void init(const QString &label, const QString &tooltip, const QString &persistentTag, ArgsForCreation... argsForCreation)
Initialize by means of a catalog class and optional creation arguments.

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

Here is the call graph for this function:

Member Function Documentation

◆ abundance()

◆ containedItemsWithParticles()

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

Return full hierarchical contained items with particles.

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

Implements ItemWithParticles.

Definition at line 76 of file ParticleItem.cpp.

77 {
78  return {};
79 }

Referenced by ParticleCoreShellItem::containedItemsWithParticles().

◆ createParticle()

std::unique_ptr< Particle > ParticleItem::createParticle ( ) const

Definition at line 53 of file ParticleItem.cpp.

54 {
55  auto domainMaterial = materialItem()->createMaterial();
56 
57  auto particle = std::make_unique<Particle>(*domainMaterial, *m_formFactor->createFormFactor());
58  particle->setAbundance(abundance());
59  particle->setParticlePosition(position());
60  if (auto r = createRotation(); r && !r->isIdentity())
61  particle->setRotation(*r);
62 
63  return particle;
64 }
virtual std::unique_ptr< IFormFactor > createFormFactor() const =0
MaterialItem * materialItem() const
Returns the material item this item links to.
std::unique_ptr< IRotation > createRotation() const
nullptr only if "no rotation". Can contain identity!
DoubleDescriptor abundance() const
std::unique_ptr< Material > createMaterial() const

References ItemWithParticles::abundance(), FormFactorItem::createFormFactor(), MaterialItem::createMaterial(), ItemWithParticles::createRotation(), m_formFactor, ItemWithMaterial::materialItem(), 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(), createParticle(), ParticleCompositionItem::createParticleComposition(), and ParticleCoreShellItem::createParticleCoreShell().

Here is the call graph for this function:

◆ formfactor_at_bottom()

FormFactorItem * ParticleItem::formfactor_at_bottom ( ) const

Definition at line 71 of file ParticleItem.cpp.

72 {
73  return m_formFactor.get();
74 }

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

Referenced by ParticleCoreShellForm::ParticleCoreShellForm(), and ParticleForm::ParticleForm().

Here is the call graph for this function:

◆ materialColor()

QColor ItemWithMaterial::materialColor ( ) const
inherited

Definition at line 42 of file ItemWithMaterial.cpp.

43 {
44  ASSERT(materialItem());
45  return materialItem()->color();
46 }
QColor color() const

References MaterialItem::color(), and ItemWithMaterial::materialItem().

Referenced by GUI::View::TransformTo3D::createLayer().

Here is the call graph for this function:

◆ materialIdentifier()

QString ItemWithMaterial::materialIdentifier ( ) const
inherited

◆ materialItem()

MaterialItem * ItemWithMaterial::materialItem ( ) const
inherited

Returns the material item this item links to.

Definition at line 59 of file ItemWithMaterial.cpp.

60 {
61  if (materialIdentifier().isEmpty())
62  return nullptr;
63 
65 }
QString materialIdentifier() const
const MaterialItems * m_materialItems
MaterialItem * materialFromIdentifier(const QString &identifier) const

References ItemWithMaterial::m_materialItems, MaterialItems::materialFromIdentifier(), and ItemWithMaterial::materialIdentifier().

Referenced by createParticle(), MaterialInplaceForm::createWidgets(), ItemWithMaterial::materialColor(), ItemWithMaterial::materialName(), MaterialInplaceForm::selectMaterial(), and ItemWithMaterial::setMaterial().

Here is the call graph for this function:

◆ materialName()

QString ItemWithMaterial::materialName ( ) const
inherited

Definition at line 48 of file ItemWithMaterial.cpp.

49 {
50  ASSERT(materialItem());
51  return materialItem()->matItemName();
52 }
QString matItemName() const

References ItemWithMaterial::materialItem(), and MaterialItem::matItemName().

Referenced by LayerForm::updateTitle().

Here is the call graph for this function:

◆ position()

◆ positionVector()

◆ rotation()

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

◆ serialize()

void ParticleItem::serialize ( Streamer &  s)
overridevirtual

Implements ItemWithParticles.

Definition at line 43 of file ParticleItem.cpp.

44 {
45  s.assertVersion(0);
46  Serialize::rwValue(s, "MaterialIdentifier", m_materialIdentifier);
49  Serialize::rwSelected<RotationItemCatalog>(s, m_rotation);
50  Serialize::rwSelected<FormFactorItemCatalog>(s, m_formFactor);
51 }
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 rwValue(Streamer &s, const QString &tag, bool &val)
Definition: Serialize.cpp:19

References Streamer::assertVersion(), ItemWithParticles::m_abundance, m_formFactor, ItemWithMaterial::m_materialIdentifier, ItemWithParticles::m_position, ItemWithParticles::m_rotation, Serialize::rwProperty(), and Serialize::rwValue().

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:

◆ setFormFactor()

void ParticleItem::setFormFactor ( FormFactorItem *  p)

Definition at line 66 of file ParticleItem.cpp.

67 {
68  m_formFactor.set(p);
69 }

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

Referenced by SampleEditorController::setCoreFormFactor(), setFormFactorType(), and SampleEditorController::setShellFormFactor().

Here is the call graph for this function:

◆ setFormFactorType()

template<typename T >
T * ParticleItem::setFormFactorType

Definition at line 44 of file ParticleItem.h.

45 {
46  T* p = new T();
47  setFormFactor(p);
48  return p;
49 }
void setFormFactor(FormFactorItem *p)

References setFormFactor().

Here is the call graph for this function:

◆ setMaterial() [1/2]

void ItemWithMaterial::setMaterial ( const MaterialItem *  materialItem)
inherited

Set the material this item shall use. Stores the identifier, not the pointer!

Definition at line 20 of file ItemWithMaterial.cpp.

21 {
23 }
QString identifier() const

References MaterialItem::identifier(), ItemWithMaterial::m_materialIdentifier, and ItemWithMaterial::materialItem().

Referenced by SampleEditorController::addLayerFromUndo(), GUI::Transform::FromCore::itemizeSample(), and SampleEditorController::selectMaterial().

Here is the call graph for this function:

◆ setMaterial() [2/2]

void ItemWithMaterial::setMaterial ( const QString &  materialIdentifier)
inherited

Set the material this item shall use. Stores the given identifier, not a pointer to the material!

Definition at line 25 of file ItemWithMaterial.cpp.

References ItemWithMaterial::m_materialIdentifier, and ItemWithMaterial::materialIdentifier().

Here is the call graph for this function:

◆ setMaterialUndefined()

void ItemWithMaterial::setMaterialUndefined ( )
inherited

Set "no material defined".

Definition at line 37 of file ItemWithMaterial.cpp.

38 {
39  m_materialIdentifier.clear();
40 }

References ItemWithMaterial::m_materialIdentifier.

◆ 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 }

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

Here is the call graph for this function:

Member Data Documentation

◆ m_abundance

◆ m_formFactor

SelectionProperty<FormFactorItem*> ParticleItem::m_formFactor
private

◆ m_materialIdentifier

QString ItemWithMaterial::m_materialIdentifier
protectedinherited

◆ m_materialItems

const MaterialItems* ItemWithMaterial::m_materialItems
protectedinherited

◆ m_position

◆ m_rotation


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