BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
SimulationDataSelectorWidget Class Reference

The SimulationDataSelectorWidget class represents widget to select instrument, sample and real data. More...

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

Public Member Functions

 SimulationDataSelectorWidget (QWidget *parent=0)
 
const InstrumentItem * selectedInstrumentItem () const
 Returns selected InstrumentItem taking into account that there might be several instruments with same name. More...
 
const MultiLayerItem * selectedMultiLayerItem () const
 Returns selected MultiLayerItem taking into account that there might be several multilayers with same name. More...
 
const RealDataItem * selectedRealDataItem () const
 Returns selected real data item taking into account that there might be several items with same name. More...
 
void setApplicationModels (ApplicationModels *applicationModels)
 
void updateViewElements ()
 

Private Member Functions

int selectedInstrumentIndex () const
 
int selectedRealDataIndex () const
 
int selectedSampleIndex () const
 
void updateSelection (QComboBox *comboBox, QStringList itemList, bool allow_none=false)
 Updates selection combo with string list while preserving previous selection. More...
 

Private Attributes

ApplicationModels * m_applicationModels
 
QComboBox * m_instrumentCombo
 
QComboBox * m_realDataCombo
 
QComboBox * m_sampleCombo
 

Detailed Description

The SimulationDataSelectorWidget class represents widget to select instrument, sample and real data.

Located at the top of SimulationView.

Definition at line 29 of file SimulationDataSelectorWidget.h.

Constructor & Destructor Documentation

◆ SimulationDataSelectorWidget()

SimulationDataSelectorWidget::SimulationDataSelectorWidget ( QWidget *  parent = 0)

Definition at line 38 of file SimulationDataSelectorWidget.cpp.

39  : QWidget(parent)
40  , m_instrumentCombo(new QComboBox)
41  , m_sampleCombo(new QComboBox)
42  , m_realDataCombo(new QComboBox)
44 {
45  QVBoxLayout* mainLayout = new QVBoxLayout;
46  mainLayout->setMargin(0);
47  mainLayout->setSpacing(0);
48 
49  // selection of input parameters
50  QGroupBox* groupBox = new QGroupBox("Data selection");
51 
52  QLabel* instrumentSelectionLabel = new QLabel("Instrument:");
53  instrumentSelectionLabel->setToolTip(select_instrument_tooltip);
54  m_instrumentCombo->setToolTip(select_instrument_tooltip);
55  m_instrumentCombo->setAttribute(Qt::WA_MacShowFocusRect, false);
56  m_instrumentCombo->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
57 
58  QLabel* sampleSelectionLabel = new QLabel("Sample:");
59  sampleSelectionLabel->setToolTip(select_sample_tooltip);
60  m_sampleCombo->setToolTip(select_sample_tooltip);
61 
62  QLabel* readDataSelectionLabel = new QLabel("Real Data:");
63  readDataSelectionLabel->setToolTip(select_realdata_tooltip);
64  m_realDataCombo->setToolTip(select_realdata_tooltip);
65 
66  // layout
67  QGridLayout* dataSelectionLayout = new QGridLayout;
68  dataSelectionLayout->setMargin(12); // to match margin in SimulationOptionsWidget
69 
70  dataSelectionLayout->addWidget(instrumentSelectionLabel, 0, 0);
71  dataSelectionLayout->addWidget(m_instrumentCombo, 0, 1);
72  dataSelectionLayout->addWidget(sampleSelectionLabel, 1, 0);
73  dataSelectionLayout->addWidget(m_sampleCombo, 1, 1);
74  dataSelectionLayout->addWidget(readDataSelectionLabel, 2, 0);
75  dataSelectionLayout->addWidget(m_realDataCombo, 2, 1);
76  groupBox->setLayout(dataSelectionLayout);
77 
78  mainLayout->addWidget(groupBox);
79  setLayout(mainLayout);
80 }

References m_instrumentCombo, m_realDataCombo, and m_sampleCombo.

Member Function Documentation

◆ selectedInstrumentIndex()

int SimulationDataSelectorWidget::selectedInstrumentIndex ( ) const
private

Definition at line 133 of file SimulationDataSelectorWidget.cpp.

134 {
135  return m_instrumentCombo->currentIndex();
136 }

References m_instrumentCombo.

Referenced by selectedInstrumentItem().

◆ selectedInstrumentItem()

const InstrumentItem * SimulationDataSelectorWidget::selectedInstrumentItem ( ) const

Returns selected InstrumentItem taking into account that there might be several instruments with same name.

Definition at line 102 of file SimulationDataSelectorWidget.cpp.

103 {
105  return items.isEmpty() ? nullptr : items.at(selectedInstrumentIndex());
106 }
InstrumentModel * instrumentModel()
QVector< T * > topItems() const
Definition: SessionModel.h:147

References ApplicationModels::instrumentModel(), m_applicationModels, selectedInstrumentIndex(), and SessionModel::topItems().

Referenced by SimulationSetupWidget::onExportToPythonScript(), and SimulationSetupWidget::onRunSimulation().

Here is the call graph for this function:

◆ selectedMultiLayerItem()

const MultiLayerItem * SimulationDataSelectorWidget::selectedMultiLayerItem ( ) const

Returns selected MultiLayerItem taking into account that there might be several multilayers with same name.

Definition at line 91 of file SimulationDataSelectorWidget.cpp.

92 {
94  if (items.isEmpty())
95  return nullptr;
96  return dynamic_cast<const MultiLayerItem*>(items.at(selectedSampleIndex()));
97 }
SampleModel * sampleModel()

References m_applicationModels, ApplicationModels::sampleModel(), selectedSampleIndex(), and SessionModel::topItems().

Referenced by SimulationSetupWidget::onExportToPythonScript(), and SimulationSetupWidget::onRunSimulation().

Here is the call graph for this function:

◆ selectedRealDataIndex()

int SimulationDataSelectorWidget::selectedRealDataIndex ( ) const
private

Definition at line 143 of file SimulationDataSelectorWidget.cpp.

144 {
145  // -1 because m_realDataCombo always contains "None" as a first entry
146  return m_realDataCombo->currentIndex() - 1;
147 }

References m_realDataCombo.

Referenced by selectedRealDataItem().

◆ selectedRealDataItem()

const RealDataItem * SimulationDataSelectorWidget::selectedRealDataItem ( ) const

Returns selected real data item taking into account that there might be several items with same name.

Definition at line 111 of file SimulationDataSelectorWidget.cpp.

112 {
114  if (items.isEmpty())
115  return nullptr;
116  if (selectedRealDataIndex() >= 0 && selectedRealDataIndex() < items.size())
117  return items.at(selectedRealDataIndex());
118 
119  return nullptr;
120 }
RealDataModel * realDataModel()
QVector< RealDataItem * > realDataItems() const

References m_applicationModels, RealDataModel::realDataItems(), ApplicationModels::realDataModel(), and selectedRealDataIndex().

Referenced by SimulationSetupWidget::onRunSimulation().

Here is the call graph for this function:

◆ selectedSampleIndex()

int SimulationDataSelectorWidget::selectedSampleIndex ( ) const
private

Definition at line 138 of file SimulationDataSelectorWidget.cpp.

139 {
140  return m_sampleCombo->currentIndex();
141 }

References m_sampleCombo.

Referenced by selectedMultiLayerItem().

◆ setApplicationModels()

void SimulationDataSelectorWidget::setApplicationModels ( ApplicationModels *  applicationModels)

Definition at line 82 of file SimulationDataSelectorWidget.cpp.

83 {
84  m_applicationModels = applicationModels;
86 }

References m_applicationModels, and updateViewElements().

Referenced by SimulationSetupWidget::setApplicationModels().

Here is the call graph for this function:

◆ updateSelection()

void SimulationDataSelectorWidget::updateSelection ( QComboBox *  comboBox,
QStringList  itemList,
bool  allow_none = false 
)
private

Updates selection combo with string list while preserving previous selection.

If allow_none == true, additional "None" item will be added to the combo.

Definition at line 152 of file SimulationDataSelectorWidget.cpp.

154 {
155  QString previousItem = comboBox->currentText();
156 
157  comboBox->clear();
158  if (itemList.isEmpty()) {
159  comboBox->setEnabled(false);
160  comboBox->addItem("Not yet defined");
161  } else {
162  comboBox->setEnabled(true);
163  // qSort(itemList.begin(), itemList.end()); // uncomment, if we want alphabetical order
164  if (allow_none)
165  itemList.insert(-1, "None");
166  comboBox->addItems(itemList);
167  if (itemList.contains(previousItem))
168  comboBox->setCurrentIndex(itemList.indexOf(previousItem));
169  }
170 }

Referenced by updateViewElements().

◆ updateViewElements()

void SimulationDataSelectorWidget::updateViewElements ( )

Definition at line 122 of file SimulationDataSelectorWidget.cpp.

123 {
130  true);
131 }
#define ASSERT(condition)
Definition: Assert.h:31
void updateSelection(QComboBox *comboBox, QStringList itemList, bool allow_none=false)
Updates selection combo with string list while preserving previous selection.
QStringList topItemNames(SessionModel *model, const QString &modelType="")
Returns list of top iten manes.
Definition: ModelUtils.cpp:20

References ASSERT, ApplicationModels::instrumentModel(), m_applicationModels, m_instrumentCombo, m_realDataCombo, m_sampleCombo, ApplicationModels::realDataModel(), ApplicationModels::sampleModel(), ModelUtils::topItemNames(), and updateSelection().

Referenced by setApplicationModels(), and SimulationSetupWidget::updateViewElements().

Here is the call graph for this function:

Member Data Documentation

◆ m_applicationModels

ApplicationModels* SimulationDataSelectorWidget::m_applicationModels
private

◆ m_instrumentCombo

QComboBox* SimulationDataSelectorWidget::m_instrumentCombo
private

◆ m_realDataCombo

QComboBox* SimulationDataSelectorWidget::m_realDataCombo
private

◆ m_sampleCombo

QComboBox* SimulationDataSelectorWidget::m_sampleCombo
private

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