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

Description

Properties widget for the QREDataLoader.

Definition at line 33 of file QREDataLoaderProperties.h.

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

Signals

void propertiesChanged ()
 

Public Member Functions

 QREDataLoaderProperties ()
 
void allowFactors (bool b)
 Factors shall not be supported. However, since the requirements have been there, they are only deactivated. Call allowFactors(true) to enable them. More...
 
QSpinBox * columnSpinBox (int dataType) const
 
double factor (int dataType) const
 
QDoubleSpinBox * factorSpinBox (int dataType) const
 

Public Attributes

Ui::QREDataLoaderProperties * m_ui
 

Private Member Functions

QLabel * factorLabel (int dataType) const
 
void onErrorEnablingChanged ()
 
void updateErrorEnabling (bool enabled) const
 

Private Attributes

bool m_allowFactors
 

Static Private Attributes

static const int columnColumn = 3
 
static const int factorColumn = factorLabelColumn + 1
 
static const int factorLabelColumn = 4
 

Constructor & Destructor Documentation

◆ QREDataLoaderProperties()

QREDataLoaderProperties::QREDataLoaderProperties ( )

Definition at line 20 of file QREDataLoaderProperties.cpp.

21  : m_allowFactors(false)
22 {
23  m_ui = new Ui::QREDataLoaderProperties;
24  m_ui->setupUi(this);
25 
26  allowFactors(false);
27 
28  connect(m_ui->headerPrefixEdit, &QLineEdit::textChanged, [=]() { emit propertiesChanged(); });
29  connect(m_ui->linesToSkipEdit, &QLineEdit::textChanged, [=]() { emit propertiesChanged(); });
30  connect(m_ui->separatorCombo, &QComboBox::currentTextChanged,
31  [=]() { emit propertiesChanged(); });
32 
33  connect(m_ui->enableErrorCheckBox, &QCheckBox::stateChanged, this,
35 
36  connect(m_ui->qUnitCombo, QOverload<int>::of(&QComboBox::currentIndexChanged),
37  [=]() { emit propertiesChanged(); });
38 
39  for (int dataType = 0; dataType < 3; dataType++) {
40  // In the following: disable the checkbox before signaling propertyChanged to suppress ghost
41  // value changes in case the propertiesChanged signals triggers long calculations (the
42  // spinbox would see a timeout in its "pressed"-loop and generate a second value change)
43  connect(columnSpinBox(dataType), QOverload<int>::of(&QSpinBox::valueChanged), [=]() {
44  columnSpinBox(dataType)->setEnabled(false);
45  emit propertiesChanged();
46  columnSpinBox(dataType)->setEnabled(true);
47  });
48 
49  connect(factorSpinBox(dataType), QOverload<double>::of(&QDoubleSpinBox::valueChanged),
50  [=]() {
51  factorSpinBox(dataType)->setEnabled(false);
52  emit propertiesChanged();
53  factorSpinBox(dataType)->setEnabled(true);
54  });
55  }
56 }
void allowFactors(bool b)
Factors shall not be supported. However, since the requirements have been there, they are only deacti...
QSpinBox * columnSpinBox(int dataType) const
QDoubleSpinBox * factorSpinBox(int dataType) const
Ui::QREDataLoaderProperties * m_ui

References allowFactors(), columnSpinBox(), factorSpinBox(), m_ui, onErrorEnablingChanged(), and propertiesChanged().

Here is the call graph for this function:

Member Function Documentation

◆ allowFactors()

void QREDataLoaderProperties::allowFactors ( bool  b)

Factors shall not be supported. However, since the requirements have been there, they are only deactivated. Call allowFactors(true) to enable them.

Definition at line 58 of file QREDataLoaderProperties.cpp.

59 {
60  m_allowFactors = b;
61  for (int dataType = 0; dataType < 3; dataType++) {
62  factorLabel(dataType)->setVisible(b);
63  factorSpinBox(dataType)->setVisible(b);
64  }
65 
66  updateErrorEnabling(m_ui->enableErrorCheckBox->isChecked());
67 }
QLabel * factorLabel(int dataType) const
void updateErrorEnabling(bool enabled) const

References factorLabel(), factorSpinBox(), m_allowFactors, m_ui, and updateErrorEnabling().

Referenced by QREDataLoaderProperties().

Here is the call graph for this function:

◆ columnSpinBox()

QSpinBox * QREDataLoaderProperties::columnSpinBox ( int  dataType) const

Definition at line 100 of file QREDataLoaderProperties.cpp.

101 {
102  const int lineInLayout = dataType;
103  return dynamic_cast<QSpinBox*>(
104  m_ui->gridLayout->itemAtPosition(lineInLayout, columnColumn)->widget());
105 }

References columnColumn, and m_ui.

Referenced by QREDataLoaderProperties().

◆ factor()

double QREDataLoaderProperties::factor ( int  dataType) const

Definition at line 69 of file QREDataLoaderProperties.cpp.

70 {
71  auto* const spinBox = factorSpinBox(dataType);
72  return spinBox->isVisible() ? spinBox->value() : 1.0;
73 }

References factorSpinBox().

Here is the call graph for this function:

◆ factorLabel()

QLabel * QREDataLoaderProperties::factorLabel ( int  dataType) const
private

Definition at line 114 of file QREDataLoaderProperties.cpp.

115 {
116  const int lineInLayout = dataType;
117  return dynamic_cast<QLabel*>(
118  m_ui->gridLayout->itemAtPosition(lineInLayout, factorLabelColumn)->widget());
119 }

References factorLabelColumn, and m_ui.

Referenced by allowFactors().

◆ factorSpinBox()

QDoubleSpinBox * QREDataLoaderProperties::factorSpinBox ( int  dataType) const

Definition at line 107 of file QREDataLoaderProperties.cpp.

108 {
109  const int lineInLayout = dataType;
110  return dynamic_cast<QDoubleSpinBox*>(
111  m_ui->gridLayout->itemAtPosition(lineInLayout, factorColumn)->widget());
112 }

References factorColumn, and m_ui.

Referenced by QREDataLoaderProperties(), allowFactors(), and factor().

◆ onErrorEnablingChanged()

void QREDataLoaderProperties::onErrorEnablingChanged ( )
private

Definition at line 91 of file QREDataLoaderProperties.cpp.

92 {
93  const bool isEnabled = m_ui->enableErrorCheckBox->isChecked();
94 
95  updateErrorEnabling(isEnabled);
96 
97  emit propertiesChanged();
98 }

References m_ui, propertiesChanged(), and updateErrorEnabling().

Referenced by QREDataLoaderProperties().

Here is the call graph for this function:

◆ propertiesChanged

void QREDataLoaderProperties::propertiesChanged ( )
signal

◆ updateErrorEnabling()

void QREDataLoaderProperties::updateErrorEnabling ( bool  enabled) const
private

Definition at line 75 of file QREDataLoaderProperties.cpp.

76 {
77  const int lineInLayout = 2;
78 
79  for (int col = 2; col < m_ui->gridLayout->columnCount(); col++) {
80  auto* const layoutItem = m_ui->gridLayout->itemAtPosition(lineInLayout, col);
81  if (layoutItem) {
82  QWidget* w = layoutItem->widget();
83  if (w) {
84  const bool belongsToFactor = col == factorColumn || col == factorLabelColumn;
85  w->setVisible(enabled && (!belongsToFactor || m_allowFactors));
86  }
87  }
88  }
89 }

References factorColumn, factorLabelColumn, m_allowFactors, and m_ui.

Referenced by allowFactors(), and onErrorEnablingChanged().

Member Data Documentation

◆ columnColumn

const int QREDataLoaderProperties::columnColumn = 3
staticprivate

Definition at line 61 of file QREDataLoaderProperties.h.

Referenced by columnSpinBox().

◆ factorColumn

const int QREDataLoaderProperties::factorColumn = factorLabelColumn + 1
staticprivate

Definition at line 63 of file QREDataLoaderProperties.h.

Referenced by factorSpinBox(), and updateErrorEnabling().

◆ factorLabelColumn

const int QREDataLoaderProperties::factorLabelColumn = 4
staticprivate

Definition at line 62 of file QREDataLoaderProperties.h.

Referenced by factorLabel(), and updateErrorEnabling().

◆ m_allowFactors

bool QREDataLoaderProperties::m_allowFactors
private

Definition at line 59 of file QREDataLoaderProperties.h.

Referenced by allowFactors(), and updateErrorEnabling().

◆ m_ui

Ui::QREDataLoaderProperties* QREDataLoaderProperties::m_ui

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