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

Description

Form for editing interference functions.

Definition at line 27 of file InterferenceForm.h.

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

Public Member Functions

 InterferenceForm (QWidget *parent, ParticleLayoutItem *layoutItem, SampleEditorController *ec)
 
ParticleLayoutItemlayoutItem () const
 
void onInterferenceTypeChanged ()
 

Private Member Functions

void createInterferenceWidgets ()
 
void updateTitle ()
 

Private Attributes

GroupBoxCollapserm_collapser = nullptr
 
SampleEditorControllerm_ec
 
QComboBox * m_interferenceTypeCombo
 
ParticleLayoutItemm_layoutItem
 

Constructor & Destructor Documentation

◆ InterferenceForm()

InterferenceForm::InterferenceForm ( QWidget *  parent,
ParticleLayoutItem layoutItem,
SampleEditorController ec 
)

Definition at line 27 of file InterferenceForm.cpp.

29  : QGroupBox(parent)
31  , m_ec(ec)
32 {
33  setTitle("Interference Function");
34 
35  FormLayouter layouter(this, ec);
36  layouter.setContentsMargins(6, 6, 0, 6);
38 
39  m_interferenceTypeCombo = new QComboBox(this);
41  auto d = layoutItem->interference();
42  m_interferenceTypeCombo->addItems(d.options);
43  m_interferenceTypeCombo->setCurrentIndex(d.currentIndex());
44  m_interferenceTypeCombo->setMaxVisibleItems(m_interferenceTypeCombo->count());
45  m_interferenceTypeCombo->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
46  layouter.addRow("Type:", m_interferenceTypeCombo);
47 
49  updateTitle();
50 
51  connect(m_interferenceTypeCombo, QOverload<int>::of(&QComboBox::currentIndexChanged),
52  [=](int newIndex) { m_ec->selectInterference(this, newIndex); });
53 }
Utility class to populate a QFormLayout.
Definition: FormLayouter.h:36
static GroupBoxCollapser * installIntoGroupBox(QGroupBox *groupBox, bool expanded=true)
ParticleLayoutItem * layoutItem() const
GroupBoxCollapser * m_collapser
QComboBox * m_interferenceTypeCombo
ParticleLayoutItem * m_layoutItem
void createInterferenceWidgets()
SampleEditorController * m_ec
SelectionDescriptor< InterferenceItem * > interference() const
void selectInterference(InterferenceForm *widget, int newIndex)
static void install(QObject *obj)

References FormLayouter::addRow(), createInterferenceWidgets(), WheelEventEater::install(), GroupBoxCollapser::installIntoGroupBox(), ParticleLayoutItem::interference(), layoutItem(), m_collapser, m_ec, m_interferenceTypeCombo, SampleEditorController::selectInterference(), FormLayouter::setContentsMargins(), and updateTitle().

Here is the call graph for this function:

Member Function Documentation

◆ createInterferenceWidgets()

void InterferenceForm::createInterferenceWidgets ( )
private

Definition at line 70 of file InterferenceForm.cpp.

71 {
72  FormLayouter layouter(this, m_ec);
73  auto* interference = m_layoutItem->interference().currentItem();
74 
75  // Some values in interference settings affect the total density in the particle layout. To
76  // provide all the updating (data & UI), the method
77  // SampleEditorController::setDensityRelatedValueValue has to be called (instead of
78  // SampleEditorController::setDouble). For this we have the following lambda to add a value:
79  const auto addDensityRelatedValue = [&](DoubleDescriptor d) {
80  layouter.addValue(
81  d, [=](double newValue) { m_ec->setDensityRelatedValue(interference, newValue, d); });
82  };
83 
84  if (auto* itf = dynamic_cast<Interference1DLatticeItem*>(interference)) {
85  layouter.addValue(itf->positionVariance());
86  layouter.addValue(itf->length());
87  layouter.addValue(itf->rotationAngle());
88  layouter.addSelection(itf->decayFunction());
89  } else if (auto* itf = dynamic_cast<InterferenceRadialParaCrystalItem*>(interference)) {
90  layouter.addValue(itf->positionVariance());
91  layouter.addValue(itf->peakDistance());
92  layouter.addValue(itf->dampingLength());
93  layouter.addValue(itf->domainSize());
94  layouter.addValue(itf->kappa());
95  layouter.addSelection(itf->probabilityDistribution());
96  } else if (auto* itf = dynamic_cast<InterferenceHardDiskItem*>(interference)) {
97  layouter.addValue(itf->positionVariance());
98  layouter.addValue(itf->radius());
99  addDensityRelatedValue(itf->density());
100  } else if (auto* itf = dynamic_cast<Interference2DLatticeItem*>(interference)) {
101  layouter.addValue(itf->positionVariance());
102  auto* w = new LatticeTypeSelectionForm(this, itf, m_ec);
103  layouter.addRow(itf->latticeType().label, w);
104  layouter.addSelection(itf->decayFunction());
105  } else if (auto* itf = dynamic_cast<InterferenceFinite2DLatticeItem*>(interference)) {
106  layouter.addValue(itf->positionVariance());
107  layouter.addValue(itf->domainSize1());
108  layouter.addValue(itf->domainSize2());
109  auto* w = new LatticeTypeSelectionForm(this, itf, m_ec);
110  layouter.addRow(itf->latticeType().label, w);
111  } else if (auto* itf = dynamic_cast<Interference2DParaCrystalItem*>(interference)) {
112  layouter.addValue(itf->positionVariance());
113  layouter.addValue(itf->dampingLength());
114  layouter.addValue(itf->domainSize1());
115  layouter.addValue(itf->domainSize2());
116  auto* w = new LatticeTypeSelectionForm(this, itf, m_ec);
117  layouter.addRow(itf->latticeType().label, w);
118  layouter.addSelection(itf->probabilityDistribution1());
119  layouter.addSelection(itf->probabilityDistribution2());
120  }
121 }
Describes properties of a double value which are necessary to allow GUI representation,...
Form for editing lattice type values.
void setDensityRelatedValue(InterferenceItem *interferenceItem, double newValue, DoubleDescriptor d)
Set an interference function's value which affects the total particle density of the containing parti...

References FormLayouter::addRow(), FormLayouter::addSelection(), FormLayouter::addValue(), ParticleLayoutItem::interference(), m_ec, m_layoutItem, and SampleEditorController::setDensityRelatedValue().

Referenced by InterferenceForm(), and onInterferenceTypeChanged().

Here is the call graph for this function:

◆ layoutItem()

ParticleLayoutItem * InterferenceForm::layoutItem ( ) const

Definition at line 55 of file InterferenceForm.cpp.

56 {
57  return m_layoutItem;
58 }

References m_layoutItem.

Referenced by InterferenceForm(), and SampleEditorController::selectInterference().

◆ onInterferenceTypeChanged()

void InterferenceForm::onInterferenceTypeChanged ( )

Definition at line 60 of file InterferenceForm.cpp.

61 {
62  FormLayouter layouter(this, m_ec);
63  while (layouter.layout()->rowCount() > 1)
64  layouter.layout()->removeRow(1);
65 
67  updateTitle();
68 }

References createInterferenceWidgets(), FormLayouter::layout(), m_ec, and updateTitle().

Referenced by SampleEditorController::selectInterference().

Here is the call graph for this function:

◆ updateTitle()

void InterferenceForm::updateTitle ( )
private

Definition at line 123 of file InterferenceForm.cpp.

124 {
125  m_collapser->setTitle("Interference Function (" + m_interferenceTypeCombo->currentText() + ")");
126 }
void setTitle(const QString &title)
Set the title of the group box. Do not use the method groupBox->setTitle() any more once the add-on i...

References m_collapser, m_interferenceTypeCombo, and GroupBoxCollapser::setTitle().

Referenced by InterferenceForm(), and onInterferenceTypeChanged().

Here is the call graph for this function:

Member Data Documentation

◆ m_collapser

GroupBoxCollapser* InterferenceForm::m_collapser = nullptr
private

Definition at line 39 of file InterferenceForm.h.

Referenced by InterferenceForm(), and updateTitle().

◆ m_ec

SampleEditorController* InterferenceForm::m_ec
private

◆ m_interferenceTypeCombo

QComboBox* InterferenceForm::m_interferenceTypeCombo
private

Definition at line 40 of file InterferenceForm.h.

Referenced by InterferenceForm(), and updateTitle().

◆ m_layoutItem

ParticleLayoutItem* InterferenceForm::m_layoutItem
private

Definition at line 41 of file InterferenceForm.h.

Referenced by createInterferenceWidgets(), and layoutItem().


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