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

Description

Use this to edit an AxisProperty.

An AxisProperty handles values for a FixedBinAxis. The values will be already written into the data element. For each change of values, a signal will be emitted. Use this e.g. to update dependent values or to set the document to modified.

Definition at line 29 of file AxisPropertyEditor.h.

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

Signals

void dataChanged ()
 

Public Member Functions

 AxisPropertyEditor (QWidget *parent, const QString &groupTitle, AxisProperty *axisProperty)
 
void updateData ()
 Reload UI from data. More...
 

Private Attributes

AxisPropertym_axisProperty
 
DoubleSpinBoxm_maxSpinBox
 
DoubleSpinBoxm_minSpinBox
 
QSpinBox * m_nbinsSpinBox
 

Constructor & Destructor Documentation

◆ AxisPropertyEditor()

AxisPropertyEditor::AxisPropertyEditor ( QWidget *  parent,
const QString &  groupTitle,
AxisProperty axisProperty 
)

Definition at line 24 of file AxisPropertyEditor.cpp.

26  : QGroupBox(groupTitle, parent)
27  , m_axisProperty(axisProperty)
28 {
29  setProperty("subgroup", true); // for stylesheet addressing
30  auto* formLayout = new QFormLayout(this);
31  formLayout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
32 
33  m_nbinsSpinBox = GUI::Util::createSpinBox(formLayout, axisProperty->nbins());
34  m_minSpinBox = GUI::Util::createSpinBox(formLayout, axisProperty->min());
35  m_maxSpinBox = GUI::Util::createSpinBox(formLayout, axisProperty->max());
36 
38 
39  connect(m_nbinsSpinBox, qOverload<int>(&QSpinBox::valueChanged), [=](int v) {
40  if (axisProperty->nbins() != static_cast<uint>(v)) {
41  axisProperty->setNbins(v);
42  emit dataChanged();
43  }
44  });
45 
46  connect(m_minSpinBox, qOverload<double>(&DoubleSpinBox::baseValueChanged), [=](double v) {
47  if (m_axisProperty->min() != v) {
48  m_axisProperty->setMin(v);
49  emit dataChanged();
50  if (m_axisProperty->max() < v) {
51  m_axisProperty->setMax(v);
52  m_maxSpinBox->updateValue();
53  }
54  }
55  });
56 
57  connect(m_maxSpinBox, qOverload<double>(&DoubleSpinBox::baseValueChanged), [=](double v) {
58  if (m_axisProperty->max() != v) {
59  m_axisProperty->setMax(v);
60  emit dataChanged();
61  if (m_axisProperty->min() > v) {
62  m_axisProperty->setMin(v);
63  m_minSpinBox->updateValue();
64  }
65  }
66  });
67 }
DoubleSpinBox * m_minSpinBox
DoubleSpinBox * m_maxSpinBox
AxisProperty * m_axisProperty
void baseValueChanged(double newBaseValue)
Emitted whenever the value changes.
static GroupBoxCollapser * installIntoGroupBox(QGroupBox *groupBox, bool expanded=true)
QSpinBox * createSpinBox(QWidget *parent, const UIntDescriptor &d, std::function< void(uint)> slot=nullptr)
Create a spin box with the information found in a UIntDescriptor.
Definition: WidgetUtils.cpp:24

References DoubleSpinBox::baseValueChanged(), GUI::Util::createSpinBox(), GroupBoxCollapser::installIntoGroupBox(), m_axisProperty, m_maxSpinBox, m_minSpinBox, and m_nbinsSpinBox.

Here is the call graph for this function:

Member Function Documentation

◆ dataChanged

◆ updateData()

void AxisPropertyEditor::updateData ( )

Reload UI from data.

Definition at line 69 of file AxisPropertyEditor.cpp.

70 {
71  QSignalBlocker b(m_nbinsSpinBox);
72  m_nbinsSpinBox->setValue(m_axisProperty->nbins());
75 }
void updateValue()
Update the shown value to the one contained in the value descriptor.

References m_axisProperty, m_maxSpinBox, m_minSpinBox, m_nbinsSpinBox, and DoubleSpinBox::updateValue().

Here is the call graph for this function:

Member Data Documentation

◆ m_axisProperty

AxisProperty* AxisPropertyEditor::m_axisProperty
private

Definition at line 42 of file AxisPropertyEditor.h.

Referenced by AxisPropertyEditor(), and updateData().

◆ m_maxSpinBox

DoubleSpinBox* AxisPropertyEditor::m_maxSpinBox
private

Definition at line 44 of file AxisPropertyEditor.h.

Referenced by AxisPropertyEditor(), and updateData().

◆ m_minSpinBox

DoubleSpinBox* AxisPropertyEditor::m_minSpinBox
private

Definition at line 43 of file AxisPropertyEditor.h.

Referenced by AxisPropertyEditor(), and updateData().

◆ m_nbinsSpinBox

QSpinBox* AxisPropertyEditor::m_nbinsSpinBox
private

Definition at line 41 of file AxisPropertyEditor.h.

Referenced by AxisPropertyEditor(), and updateData().


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