BornAgain
1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
|
Describes a selection (various possibilities and the current one).
Usually a selection is presented as a combo box. Right now with SessionModel still in place, in many cases a selection changes the current item of a group item, i.e. it changes the class of a certain child item (e.g. XRotationItem*/YRotationItem*/...). Also a SessionItem holding only a ComboProperty (but not switching children like GroupItem) can be wrapped. For example IntensityDataItem::gradient() is simply a list of QStrings.
With the migration, more and more SelectionDescriptor operate on a SelectionProperty. Please refer to this class for more information.
The template parameter defines the type of the current item. This can be a pointer to a common base class (like RotationItem*), but it also can be a std::variant<...>, which is useful if no dedicated common base class exists (like for the roughness items LayerZeroRoughnessItem and LayerBasicRoughnessItem). If not used with a GroupItem, but with a "normal" ComboProperty holder, the template parameter can be a QString, so currentItem() returns the currently selected string.
Note that this class does not provide (implement) a selection, but provide information about a selection. For implementing a selection, please see SelectionProperty.
By using this class, the underlying data scheme is hidden from the user of the data. This e.g. eases SessionItem migration. The underlying implementation can be a GroupItem, a simple pointer member, a std::variant or any other construction to define a selection.
For easy UI creation, there are functions like GUI:Util::createSelectionCombo() which take a descriptor and fully initialize the created combo box.
Definition at line 70 of file SelectionDescriptor.h.
Public Member Functions | |
SelectionDescriptor ()=default | |
SelectionDescriptor (SessionItem *item) | |
Initialize the members by means of a SessionItem containing a ComboProperty. This can be a GroupItem or any other property. More... | |
int | currentIndex () const override |
Get currently selected option. More... | |
operator T () const | |
void | setCurrentIndex (int newIndex) const override |
Set currently selected option. More... | |
Public Attributes | |
function< int()> | currentIndexGetter |
Function to get currently selected option. More... | |
function< void(int)> | currentIndexSetter |
Function to set currently selected option. More... | |
function< T()> | currentItem |
Function to get currently selected item. More... | |
QString | label |
A label text (short, no trailing colon) More... | |
QStringList | options |
List of options, usually presented as combo entries. More... | |
QString | tooltip |
Tooltip text. More... | |
|
default |
|
inlineexplicit |
Initialize the members by means of a SessionItem containing a ComboProperty. This can be a GroupItem or any other property.
currentItem can only be initialized if the template parameter is a pointer (like RotationItem*). If it is e.g. a std::variant<>, the currentItem has to be initialized by the caller. Only for easier migration. Should be removed after SessionItem refactoring.
Definition at line 80 of file SelectionDescriptor.h.
References SelectionDescriptor< T >::currentIndex(), SelectionDescriptor< T >::currentIndexGetter, SelectionDescriptor< T >::currentIndexSetter, SelectionDescriptor< T >::currentItem, SessionItem::displayName(), SelectionDescriptor< T >::label, SelectionDescriptor< T >::options, ComboProperty::setCurrentIndex(), SessionItem::setValue(), SessionItem::toolTip(), SelectionDescriptor< T >::tooltip, and SessionItem::value().
|
inlineoverridevirtual |
Get currently selected option.
Implements AbstractSelectionDescriptor.
Definition at line 106 of file SelectionDescriptor.h.
References SelectionDescriptor< T >::currentIndexGetter.
Referenced by SelectionDescriptor< T >::SelectionDescriptor(), MinimizerSettingsWidget::createComboBox(), IntensityDataPropertyWidget::createComboBox(), SpecularDataPropertyWidget::createComboBox(), GUI::Util::createSelectionCombo(), and AbstractSelectionContainerForm::initUI().
|
inline |
Definition at line 102 of file SelectionDescriptor.h.
References SelectionDescriptor< T >::currentItem.
|
inlineoverridevirtual |
Set currently selected option.
Implements AbstractSelectionDescriptor.
Definition at line 104 of file SelectionDescriptor.h.
References SelectionDescriptor< T >::currentIndexSetter.
Referenced by MinimizerSettingsWidget::createComboBox(), IntensityDataPropertyWidget::createComboBox(), SpecularDataPropertyWidget::createComboBox(), and GUI::Util::createSelectionCombo().
function<int()> SelectionDescriptor< T >::currentIndexGetter |
Function to get currently selected option.
Definition at line 112 of file SelectionDescriptor.h.
Referenced by SelectionDescriptor< T >::SelectionDescriptor(), SelectionDescriptor< T >::currentIndex(), RectangularDetectorItem::detectorAlignmentSelection(), and LayerItem::roughness().
function<void(int)> SelectionDescriptor< T >::currentIndexSetter |
Function to set currently selected option.
Definition at line 111 of file SelectionDescriptor.h.
Referenced by SelectionDescriptor< T >::SelectionDescriptor(), RectangularDetectorItem::detectorAlignmentSelection(), LayerItem::roughness(), and SelectionDescriptor< T >::setCurrentIndex().
function<T()> SelectionDescriptor< T >::currentItem |
Function to get currently selected item.
Definition at line 113 of file SelectionDescriptor.h.
Referenced by SelectionContainerForm::SelectionContainerForm(), SelectionDescriptor< T >::SelectionDescriptor(), SelectionDescriptor< T >::operator T(), and LayerItem::roughness().
QString SelectionDescriptor< T >::label |
A label text (short, no trailing colon)
Definition at line 108 of file SelectionDescriptor.h.
Referenced by SelectionDescriptor< T >::SelectionDescriptor(), FormLayouter::addSelection(), RectangularDetectorItem::detectorAlignmentSelection(), and LayerItem::roughness().
QStringList SelectionDescriptor< T >::options |
List of options, usually presented as combo entries.
Definition at line 110 of file SelectionDescriptor.h.
Referenced by SelectionDescriptor< T >::SelectionDescriptor(), MinimizerSettingsWidget::createComboBox(), IntensityDataPropertyWidget::createComboBox(), SpecularDataPropertyWidget::createComboBox(), GUI::Util::createSelectionCombo(), RectangularDetectorItem::detectorAlignmentSelection(), AbstractSelectionContainerForm::initUI(), and LayerItem::roughness().
QString SelectionDescriptor< T >::tooltip |
Tooltip text.
Definition at line 109 of file SelectionDescriptor.h.
Referenced by SelectionDescriptor< T >::SelectionDescriptor(), MinimizerSettingsWidget::createComboBox(), GUI::Util::createSelectionCombo(), and LayerItem::roughness().