BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
ItemWithParticles.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Model/Sample/ItemWithParticles.cpp
6 //! @brief Implements class ItemWithParticles
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2021
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
16 #include "Base/Vector/RotMatrix.h"
19 #include "Sample/Particle/IParticle.h"
20 #include "Sample/Scattering/Rotations.h"
21 
22 
23 ItemWithParticles::ItemWithParticles(const QString& abundanceTooltip,
24  const QString& positionTooltip)
25 {
26  m_abundance.init("Abundance", abundanceTooltip, 1.0, Unit::unitless, 3,
27  RealLimits::limited(0.0, 1.0), "abundance");
28  m_position.init("Position Offset", positionTooltip, Unit::nanometer, "pos");
29  m_rotation.init<RotationItemCatalog>("Rotation", "", "rotation");
30 }
31 
33 {
34  return m_abundance;
35 }
36 
37 void ItemWithParticles::setAbundance(const double abundance)
38 {
40 }
41 
43 {
44  return m_position;
45 }
46 
47 void ItemWithParticles::setPosition(const R3& position)
48 {
50 }
51 
53 {
54  return m_position;
55 }
56 
58 {
59  return m_rotation;
60 }
61 
63 {
64  m_rotation.set(p);
65 }
66 
67 std::unique_ptr<IRotation> ItemWithParticles::createRotation() const
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 }
Defines abstract item with a material property.
Defines class RotationItemCatalog.
Defines class Streamer.
@ unitless
@ nanometer
Describes properties of a double value which are necessary to allow GUI representation,...
void set(double d)
Set the contained value.
void init(const QString &label, const QString &tooltip, double value, const variant< QString, Unit > &unit, const QString &persistentTag)
ItemWithParticles(const QString &abundanceTooltip, const QString &positionTooltip)
void setPosition(const R3 &position)
VectorProperty m_position
SelectionProperty< RotationItem * > m_rotation
std::unique_ptr< IRotation > createRotation() const
nullptr only if "no rotation". Can contain identity!
DoubleDescriptor abundance() const
void setAbundance(double abundance)
DoubleProperty m_abundance
SelectionDescriptor< RotationItem * > rotation()
Returns selection descriptor for rotation methods.
VectorDescriptor positionVector() const
void setRotation(RotationItem *p)
nullptr is allowed and sets to "no rotation"
RotMatrix rotation() const
Describes a selection (various possibilities and the current one).
void set(T t, bool callInitializer=false)
Directly set the new item.
T get() const
Direct access to the stored pointer.
void init(const QString &label, const QString &tooltip, const QString &persistentTag, ArgsForCreation... argsForCreation)
Initialize by means of a catalog class and optional creation arguments.
Describes properties of a 3D vector, consisting of three double values.
void set(const R3 &d)
void init(const QString &label, const QString &tooltip, const variant< QString, Unit > &unit, const QString &persistentTag)