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

Description

Environment editor (i.e. background) for instrument editors. Operates on InstrumentItem.

Definition at line 26 of file EnvironmentEditor.h.

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

Signals

void dataChanged ()
 

Public Member Functions

 EnvironmentEditor (QWidget *parent, InstrumentItem *instrument)
 

Private Member Functions

void createBackgroundWidgets ()
 

Private Attributes

QFormLayout * m_formLayout
 
InstrumentItemm_instrument
 

Constructor & Destructor Documentation

◆ EnvironmentEditor()

EnvironmentEditor::EnvironmentEditor ( QWidget *  parent,
InstrumentItem instrument 
)

Definition at line 23 of file EnvironmentEditor.cpp.

24  : QGroupBox("Environment", parent)
25  , m_instrument(instrument)
26 {
27  ASSERT(instrument);
28  m_formLayout = new QFormLayout(this);
29  m_formLayout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
30 
31  auto* backgroundTypeCombo =
32  GUI::Util::createSelectionCombo(this, instrument->backgroundSelection(), [=](int) {
33  createBackgroundWidgets();
34  emit dataChanged();
35  });
36  m_formLayout->addRow("Background type:", backgroundTypeCombo);
37 
40 }
InstrumentItem * m_instrument
QFormLayout * m_formLayout
static GroupBoxCollapser * installIntoGroupBox(QGroupBox *groupBox, bool expanded=true)
SelectionDescriptor< BackgroundItem * > backgroundSelection() const
QComboBox * createSelectionCombo(QWidget *parent, const SelectionDescriptor< T > d, std::function< void(int)> slot=nullptr)
Create a combo box with the information found in a selection descriptor.
Definition: WidgetUtils.h:45

References InstrumentItem::backgroundSelection(), createBackgroundWidgets(), GUI::Util::createSelectionCombo(), GroupBoxCollapser::installIntoGroupBox(), and m_formLayout.

Here is the call graph for this function:

Member Function Documentation

◆ createBackgroundWidgets()

void EnvironmentEditor::createBackgroundWidgets ( )
private

Definition at line 42 of file EnvironmentEditor.cpp.

43 {
44  while (m_formLayout->rowCount() > 1)
45  m_formLayout->removeRow(1);
46 
47  auto* backgroundItem = m_instrument->backgroundSelection().currentItem();
48  if (auto* p = dynamic_cast<ConstantBackgroundItem*>(backgroundItem)) {
49  auto* spinbox = new DoubleSpinBox(this, p->backgroundValue());
50  spinbox->setSingleStep(0.01);
51  m_formLayout->addRow("Background value:", spinbox);
52 
53  connect(spinbox, &DoubleSpinBox::baseValueChanged, [=](double newValue) {
54  p->setBackgroundValue(newValue);
55  emit dataChanged();
56  });
57  }
58 }
SpinBox for DoubleDescriptors, supporting units.
Definition: DoubleSpinBox.h:22
void baseValueChanged(double newBaseValue)
Emitted whenever the value changes.

References InstrumentItem::backgroundSelection(), DoubleSpinBox::baseValueChanged(), dataChanged(), m_formLayout, and m_instrument.

Referenced by EnvironmentEditor().

Here is the call graph for this function:

◆ dataChanged

Member Data Documentation

◆ m_formLayout

QFormLayout* EnvironmentEditor::m_formLayout
private

Definition at line 40 of file EnvironmentEditor.h.

Referenced by EnvironmentEditor(), and createBackgroundWidgets().

◆ m_instrument

InstrumentItem* EnvironmentEditor::m_instrument
private

Definition at line 39 of file EnvironmentEditor.h.

Referenced by createBackgroundWidgets().


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