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

Description

Polarization analysis editor (beam polarization, analyzer properties) for instrument editors. Operates on Instrument2DItem.

Definition at line 29 of file PolarizationAnalysisEditor.h.

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

Signals

void dataChanged ()
 

Public Member Functions

 PolarizationAnalysisEditor (QWidget *parent, InstrumentItem *instrument)
 

Private Member Functions

void addVector (QFormLayout *parentLayout, const VectorDescriptor &d)
 
DoubleSpinBoxcreateSpinBox (QWidget *parent, const DoubleDescriptor &d)
 

Private Attributes

InstrumentItemm_instrument
 

Constructor & Destructor Documentation

◆ PolarizationAnalysisEditor()

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

Definition at line 24 of file PolarizationAnalysisEditor.cpp.

25  : QGroupBox("Polarization analysis", parent)
26  , m_instrument(instrument)
27 {
28  ASSERT(instrument);
29 
30  auto* layout = new QVBoxLayout(this);
31 
32  auto* checkbox = new QCheckBox(QString("Enable %1").arg(title()));
33  checkbox->setChecked(m_instrument->withPolarizerAnalyzer());
34  layout->addWidget(checkbox);
35 
36  auto* polarizerAnalyzerWidget = new QWidget(this);
37  auto* formlayout = new QFormLayout(polarizerAnalyzerWidget);
38  formlayout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
39 
40  addVector(formlayout, m_instrument->polarization());
41  addVector(formlayout, m_instrument->analyzerDirection());
42  formlayout->addRow(GUI::Util::labelWithUnit(m_instrument->analyzerEfficiency()) + ":",
43  createSpinBox(polarizerAnalyzerWidget, m_instrument->analyzerEfficiency()));
44  formlayout->addRow(
45  GUI::Util::labelWithUnit(m_instrument->analyzerTotalTransmission()) + ":",
46  createSpinBox(polarizerAnalyzerWidget, m_instrument->analyzerTotalTransmission()));
47 
48  layout->addWidget(polarizerAnalyzerWidget);
49  polarizerAnalyzerWidget->setVisible(m_instrument->withPolarizerAnalyzer());
50 
51  connect(checkbox, &QCheckBox::toggled, [=](bool b) {
52  polarizerAnalyzerWidget->setVisible(b);
54  emit dataChanged();
55  });
56 
58 }
static GroupBoxCollapser * installIntoGroupBox(QGroupBox *groupBox, bool expanded=true)
bool withPolarizerAnalyzer() const
void setWithPolarizerAnalyzer(bool with)
DoubleSpinBox * createSpinBox(QWidget *parent, const DoubleDescriptor &d)
void addVector(QFormLayout *parentLayout, const VectorDescriptor &d)
QString labelWithUnit(const QString &label, std::variant< QString, Unit > unit)
Create a label with an optional unit in brackets.

References addVector(), createSpinBox(), dataChanged(), GroupBoxCollapser::installIntoGroupBox(), GUI::Util::labelWithUnit(), m_instrument, InstrumentItem::setWithPolarizerAnalyzer(), and InstrumentItem::withPolarizerAnalyzer().

Here is the call graph for this function:

Member Function Documentation

◆ addVector()

void PolarizationAnalysisEditor::addVector ( QFormLayout *  parentLayout,
const VectorDescriptor d 
)
private

Definition at line 72 of file PolarizationAnalysisEditor.cpp.

73 {
74  auto* layout = new QHBoxLayout;
75 
76  const auto add = [&](const DoubleDescriptor& d) {
77  layout->addWidget(new QLabel(GUI::Util::labelWithUnit(d) + ":"));
78  layout->addWidget(createSpinBox(parentLayout->parentWidget(), d));
79  };
80 
81  add(d.x);
82  add(d.y);
83  add(d.z);
84 
85  layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding));
86 
87  parentLayout->addRow(d.label + ":", layout);
88 }
Describes properties of a double value which are necessary to allow GUI representation,...
DoubleDescriptor y
DoubleDescriptor x
QString label
A label text (short, no trailing colon)
DoubleDescriptor z

References createSpinBox(), VectorDescriptor::label, GUI::Util::labelWithUnit(), VectorDescriptor::x, VectorDescriptor::y, and VectorDescriptor::z.

Referenced by PolarizationAnalysisEditor().

Here is the call graph for this function:

◆ createSpinBox()

DoubleSpinBox * PolarizationAnalysisEditor::createSpinBox ( QWidget *  parent,
const DoubleDescriptor d 
)
private

Definition at line 60 of file PolarizationAnalysisEditor.cpp.

61 {
62  auto* sb = new DoubleSpinBox(parent, d);
63  connect(sb, &DoubleSpinBox::baseValueChanged, [=](double v) {
64  if (d.get() != v) {
65  d.set(v);
66  emit dataChanged();
67  }
68  });
69  return sb;
70 }
function< double()> get
function to get the current value
SpinBox for DoubleDescriptors, supporting units.
Definition: DoubleSpinBox.h:22
void baseValueChanged(double newBaseValue)
Emitted whenever the value changes.

References DoubleSpinBox::baseValueChanged(), and DoubleDescriptor::get.

Referenced by PolarizationAnalysisEditor(), and addVector().

◆ dataChanged

Member Data Documentation

◆ m_instrument

InstrumentItem* PolarizationAnalysisEditor::m_instrument
private

Definition at line 42 of file PolarizationAnalysisEditor.h.

Referenced by PolarizationAnalysisEditor().


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