BornAgain
1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
|
Class for representing a selection, its attributes and its accessors.
A "selection" in this context is a class instance out of a range of possible class instances.
Example: A distribution can be represented by DistributionGateItem, DistributionLorentzItem and more. The common base class is DistributionItem. To store the currently distribution, you may use a member of DistributionItem* which than holds an instance of the currently selected distribution (e.g. DistributionGateItem*). To select between distributions, you need a combo box filled with the distribution names, a label for the combo box, and so on.
This class provides many of these attributes and functionalities:
For the initialization of a SelectionProperty there are helper methods. They are not necessarily to be called if they are not convenient. They are only there to help initialization e.g by using a catalog. If no catalog exists for the given case, the initialization can be done by any means.
This means especially that this class is not relying on the existence of a related catalog class - a catalog helps but is not mandatory.
Definition at line 52 of file SelectionProperty.h.
Public Member Functions | |
~SelectionProperty () | |
SelectionDescriptor< T > | descriptor () const |
Returns a descriptor working on this property. More... | |
T | get () const |
Direct access to the stored pointer. More... | |
template<typename Catalog , typename... ArgsForCreation> | |
void | init (const QString &label, const QString &tooltip, const QString &persistentTag, ArgsForCreation... argsForCreation) |
Initialize by means of a catalog class and optional creation arguments. More... | |
template<typename Catalog > | |
void | initWithInitializer (const QString &label, const QString &tooltip, const QString &persistentTag, const QVector< typename Catalog::Type > &types, std::function< void(T newItem, const T oldItem)> initializer) |
Initialize by means of a catalog class, a subsection of allowed types and an initializer function. More... | |
template<typename Catalog > | |
void | initWithInitializer (const QString &label, const QString &tooltip, const QString &persistentTag, std::function< void(T newItem, const T oldItem)> initializer) |
Initialize by means of a catalog class and an initializer function. More... | |
operator SelectionDescriptor< T > () const | |
Cast to a descriptor working on this property. More... | |
T | operator-> () const |
Direct access to the stored pointer. More... | |
QString | persistentTag () const |
Persistent tag for serializing. More... | |
template<typename S , typename... ArgsForConstructor> | |
S * | set (ArgsForConstructor... argsForConstructor) |
Directly set the new item. More... | |
void | set (T t, bool callInitializer=false) |
Directly set the new item. More... | |
Private Member Functions | |
template<typename Catalog , typename... ArgsForCreation> | |
void | initDescriptor (const QString &label, const QString &tooltip, const QVector< typename Catalog::Type > &types, ArgsForCreation... argsForCreation) |
Private Attributes | |
SelectionDescriptor< T > | m_descriptor |
descriptor, holding attributes like label, tooltip More... | |
std::function< void(T newItem, const T oldItem)> | m_initializer |
initializer function. Can be empty. The first argument is the new item, the second is the old one if present; can be null. This is intended to maybe copy values from the old to the new selection. oldItem also can be ignored if not relevant, More... | |
T | m_p = nullptr |
Current selection. More... | |
QString | m_persistentTag |
Persistent tag for serializing. More... | |
|
inline |
|
inline |
Returns a descriptor working on this property.
Definition at line 120 of file SelectionProperty.h.
References SelectionProperty< T >::m_descriptor.
|
inline |
Direct access to the stored pointer.
Definition at line 129 of file SelectionProperty.h.
References SelectionProperty< T >::m_p.
Referenced by InstrumentItem::backgroundItem(), MesoCrystalItem::basisParticle(), ItemWithParticles::createRotation(), Instrument2DItem::detectorItem(), BeamDistributionItem::distribution(), SpecularBeamItem::footprint(), ParticleItem::formfactor_at_bottom(), MesoCrystalItem::getBasis(), DetectorItem::resolutionFunction(), Serialize::rwSelected(), InstrumentItem::setBackgroundType(), BeamDistributionItem::setDistributionType(), DetectorItem::setResolutionFunctionType(), ParticleLayoutItem::totalDensityIsDefinedByInterference(), and ParticleLayoutItem::totalDensityValue().
|
inline |
Initialize by means of a catalog class and optional creation arguments.
The current selection will be initialized with the first type in the catalog types. The optional arguments are the arguments which may be necessary for the creation method in the catalog.
Definition at line 62 of file SelectionProperty.h.
References SelectionProperty< T >::m_descriptor, SelectionProperty< T >::m_persistentTag, and SelectionProperty< T >::persistentTag().
Referenced by Instrument2DItem::Instrument2DItem(), InstrumentItem::InstrumentItem(), Interference1DLatticeItem::Interference1DLatticeItem(), Interference2DAbstractLatticeItem::Interference2DAbstractLatticeItem(), Interference2DLatticeItem::Interference2DLatticeItem(), Interference2DParaCrystalItem::Interference2DParaCrystalItem(), InterferenceRadialParaCrystalItem::InterferenceRadialParaCrystalItem(), ItemWithParticles::ItemWithParticles(), MesoCrystalItem::MesoCrystalItem(), ParticleItem::ParticleItem(), ParticleLayoutItem::ParticleLayoutItem(), and SpecularBeamItem::SpecularBeamItem().
|
inlineprivate |
Definition at line 157 of file SelectionProperty.h.
References SelectionProperty< T >::m_descriptor, SelectionProperty< T >::m_initializer, and SelectionProperty< T >::m_p.
|
inline |
Initialize by means of a catalog class, a subsection of allowed types and an initializer function.
Same as before, but only a subset of types available in a catalog shall be used. The current selection will be initialized with the first type in the given types subset. Each newly created item can be initialized with the given initializer method. Note that the item creation will take place also after a call to this method, so take care that the given initializer stays valid throughout the lifetime of this SelectionProperty instance.
The initializer function takes two arguments: The first is the new item, the second is the old one (if present; can be null). This is intended to maybe copy values from the old to the new selection. The old item also can be ignored, always according to the current needs.
Definition at line 107 of file SelectionProperty.h.
References SelectionProperty< T >::m_descriptor, SelectionProperty< T >::m_initializer, SelectionProperty< T >::m_persistentTag, and SelectionProperty< T >::persistentTag().
|
inline |
Initialize by means of a catalog class and an initializer function.
The current selection will be initialized with the first type in the catalog types. Each newly created item can be initialized with the given initializer method. Note that the item creation will take place also after a call to this method, so take care that the given initializer stays valid throughout the lifetime of this SelectionProperty instance.
The initializer function takes two arguments: The first is the new item, the second is the old one (if present; can be null). This is intended to maybe copy values from the old to the new selection. The old item also can be ignored, always according to the current needs.
Definition at line 82 of file SelectionProperty.h.
References SelectionProperty< T >::m_descriptor, SelectionProperty< T >::m_initializer, SelectionProperty< T >::m_persistentTag, and SelectionProperty< T >::persistentTag().
Referenced by BeamAzimuthalAngleItem::BeamAzimuthalAngleItem(), BeamInclinationAngleItem::BeamInclinationAngleItem(), BeamWavelengthItem::BeamWavelengthItem(), RectangularDetectorItem::RectangularDetectorItem(), SpecularBeamInclinationItem::SpecularBeamInclinationItem(), and SphericalDetectorItem::SphericalDetectorItem().
|
inline |
|
inline |
Direct access to the stored pointer.
Definition at line 126 of file SelectionProperty.h.
References SelectionProperty< T >::m_p.
|
inline |
Persistent tag for serializing.
Definition at line 152 of file SelectionProperty.h.
References SelectionProperty< T >::m_persistentTag.
Referenced by SelectionProperty< T >::init(), SelectionProperty< T >::initWithInitializer(), and Serialize::rwSelected().
|
inline |
Directly set the new item.
Definition at line 142 of file SelectionProperty.h.
References SelectionProperty< T >::m_initializer, and SelectionProperty< T >::m_p.
|
inline |
Directly set the new item.
Definition at line 132 of file SelectionProperty.h.
References SelectionProperty< T >::m_initializer, and SelectionProperty< T >::m_p.
Referenced by Interference2DAbstractLatticeItem::Interference2DAbstractLatticeItem(), ParticleItem::ParticleItem(), ParticleLayoutItem::removeInterference(), BeamDistributionItem::resetToValue(), Serialize::rwSelected(), InstrumentItem::setBackgroundType(), MesoCrystalItem::setBasis(), Interference1DLatticeItem::setDecayFunction(), Interference2DLatticeItem::setDecayFunctionType(), BeamDistributionItem::setDistribution(), BeamDistributionItem::setDistributionType(), ParticleItem::setFormFactor(), SpecularBeamItem::setGaussianFootprint(), ParticleLayoutItem::setInterference(), Interference2DAbstractLatticeItem::setLatticeType(), MesoCrystalItem::setOuterShape(), Interference2DParaCrystalItem::setPDF1Type(), Interference2DParaCrystalItem::setPDF2Type(), InterferenceRadialParaCrystalItem::setPDFType(), DetectorItem::setResolutionFunctionType(), ItemWithParticles::setRotation(), and SpecularBeamItem::setSquareFootprint().
|
private |
descriptor, holding attributes like label, tooltip
Definition at line 180 of file SelectionProperty.h.
Referenced by SelectionProperty< T >::descriptor(), SelectionProperty< T >::init(), SelectionProperty< T >::initDescriptor(), SelectionProperty< T >::initWithInitializer(), and SelectionProperty< BackgroundItem * >::operator SelectionDescriptor< BackgroundItem * >().
|
private |
initializer function. Can be empty. The first argument is the new item, the second is the old one if present; can be null. This is intended to maybe copy values from the old to the new selection. oldItem also can be ignored if not relevant,
Definition at line 187 of file SelectionProperty.h.
Referenced by SelectionProperty< T >::initDescriptor(), SelectionProperty< T >::initWithInitializer(), and SelectionProperty< T >::set().
|
private |
Current selection.
Definition at line 181 of file SelectionProperty.h.
Referenced by SelectionProperty< T >::~SelectionProperty(), SelectionProperty< T >::get(), SelectionProperty< T >::initDescriptor(), SelectionProperty< T >::operator->(), and SelectionProperty< T >::set().
|
private |
Persistent tag for serializing.
Definition at line 179 of file SelectionProperty.h.
Referenced by SelectionProperty< T >::init(), SelectionProperty< T >::initWithInitializer(), and SelectionProperty< T >::persistentTag().