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

Description

The RealDataPropertiesWidget class holds instrument selector to link with RealDataItem. Part of RealDataSelectorWidget, resides at lower left corner of ImportDataView.

Definition at line 27 of file RealDataPropertiesWidget.h.

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

Public Member Functions

 RealDataPropertiesWidget (QWidget *parent, ProjectDocument *document)
 
QSize minimumSizeHint () const override
 
void setItem (RealDataItem *item)
 Set current RealDataItem to display in instrument selector. More...
 
QSize sizeHint () const override
 

Private Member Functions

void onInstrumentComboIndexChanged (int index)
 Processes user interaction with instrument selector combo. If there is realDataItem, it will be linked with selected instrument. More...
 
void updateInstrumentComboEntries ()
 Updates instrument selector for new instruments and their names. Current selection will be preserved. More...
 
void updateInstrumentComboIndex ()
 Sets instrument combo selector to the state corresponding to given instrument identifier. More...
 

Private Attributes

RealDataItemm_currentDataItem
 
ProjectDocumentm_document
 
QComboBox * m_instrumentCombo
 

Constructor & Destructor Documentation

◆ RealDataPropertiesWidget()

RealDataPropertiesWidget::RealDataPropertiesWidget ( QWidget *  parent,
ProjectDocument document 
)

Definition at line 26 of file RealDataPropertiesWidget.cpp.

27  : QWidget(parent)
28  , m_instrumentCombo(new QComboBox)
29  , m_currentDataItem(nullptr)
30  , m_document(document)
31 {
32  setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
33  setWindowTitle("RealDataPropertiesWidget");
34 
35  auto* mainLayout = new QVBoxLayout;
36  mainLayout->setMargin(5);
37  mainLayout->setSpacing(2);
38 
39  m_instrumentCombo->setToolTip("Select instrument to link with real data");
40 
41  mainLayout->addWidget(new QLabel("Linked instrument"));
42  mainLayout->addWidget(m_instrumentCombo);
43 
44  mainLayout->addStretch();
45  setLayout(mainLayout);
46 
48  setEnabled(false);
49 
50  connect(m_instrumentCombo,
51  static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
53 
57 
61 
64 }
void instrumentNameChanged(const InstrumentItem *instrument)
Signals name change of the given instrument.
void instrumentAddedOrRemoved()
Signals a change in the list of instruments.
void linkToInstrumentChanged(const RealDataItem *realDataItem)
LinkInstrumentManager * linkInstrumentManager()
InstrumentsEditController * instrumentsEditController()
The edit controller for the instruments in this project document.
void updateInstrumentComboEntries()
Updates instrument selector for new instruments and their names. Current selection will be preserved.
void updateInstrumentComboIndex()
Sets instrument combo selector to the state corresponding to given instrument identifier.
void onInstrumentComboIndexChanged(int index)
Processes user interaction with instrument selector combo. If there is realDataItem,...

References InstrumentsEditController::instrumentAddedOrRemoved(), InstrumentsEditController::instrumentNameChanged(), ProjectDocument::instrumentsEditController(), ProjectDocument::linkInstrumentManager(), LinkInstrumentManager::linkToInstrumentChanged(), m_document, m_instrumentCombo, onInstrumentComboIndexChanged(), updateInstrumentComboEntries(), and updateInstrumentComboIndex().

Here is the call graph for this function:

Member Function Documentation

◆ minimumSizeHint()

QSize RealDataPropertiesWidget::minimumSizeHint ( ) const
inlineoverride

Definition at line 33 of file RealDataPropertiesWidget.h.

33 { return QSize(64, 128); }

◆ onInstrumentComboIndexChanged()

void RealDataPropertiesWidget::onInstrumentComboIndexChanged ( int  index)
private

Processes user interaction with instrument selector combo. If there is realDataItem, it will be linked with selected instrument.

Definition at line 73 of file RealDataPropertiesWidget.cpp.

74 {
75  if (!m_currentDataItem)
76  return;
77 
78  const QString newSelectedInstrumentId = m_instrumentCombo->currentData().toString();
79 
80  if (newSelectedInstrumentId == m_currentDataItem->instrumentId())
81  return;
82 
84  m_currentDataItem, newSelectedInstrumentId, GUI::Global::mainWindow)) {
85  const auto* newSelectedInstrument =
86  m_document->collectedItems()->findInstrumentById(newSelectedInstrumentId);
87  m_currentDataItem->linkToInstrument(newSelectedInstrument);
88  } else
89  // Linking was impossible or denied. Set combo to previous state
91 }
InstrumentItem * findInstrumentById(const QString &instrumentId) const
bool canLinkDataToInstrument(const RealDataItem *realDataItem, const QString &identifier, QWidget *parent)
Returns true if RealDataItem can be linked to the instrument (same number of bins)....
InstrumentCollection * collectedItems() const
void linkToInstrument(const InstrumentItem *instrument)
QString instrumentId() const
static QMainWindow * mainWindow
Definition: Globals.h:22

References LinkInstrumentManager::canLinkDataToInstrument(), ProjectDocument::collectedItems(), InstrumentCollection::findInstrumentById(), RealDataItem::instrumentId(), ProjectDocument::linkInstrumentManager(), RealDataItem::linkToInstrument(), m_currentDataItem, m_document, m_instrumentCombo, GUI::Global::mainWindow, and updateInstrumentComboIndex().

Referenced by RealDataPropertiesWidget().

Here is the call graph for this function:

◆ setItem()

void RealDataPropertiesWidget::setItem ( RealDataItem item)

Set current RealDataItem to display in instrument selector.

Definition at line 66 of file RealDataPropertiesWidget.cpp.

67 {
68  m_currentDataItem = item;
70  setEnabled(m_currentDataItem != nullptr);
71 }

References m_currentDataItem, and updateInstrumentComboIndex().

Referenced by RealDataSelectorWidget::onSelectionChanged().

Here is the call graph for this function:

◆ sizeHint()

QSize RealDataPropertiesWidget::sizeHint ( ) const
inlineoverride

Definition at line 32 of file RealDataPropertiesWidget.h.

32 { return QSize(64, 135); }

◆ updateInstrumentComboEntries()

void RealDataPropertiesWidget::updateInstrumentComboEntries ( )
private

Updates instrument selector for new instruments and their names. Current selection will be preserved.

Definition at line 96 of file RealDataPropertiesWidget.cpp.

97 {
98  QSignalBlocker b(m_instrumentCombo);
99 
100  m_instrumentCombo->clear();
101 
102  // fill the combo. Userdata contains instrument's uid
103  m_instrumentCombo->addItem("Undefined", ""); // undefined instrument
104  for (auto* instrumentItem : m_document->collectedItems()->collectedItems())
105  m_instrumentCombo->addItem(instrumentItem->instrumentName(), instrumentItem->id());
106 
108 }
QVector< InstrumentItem * > collectedItems() const

References InstrumentCollection::collectedItems(), ProjectDocument::collectedItems(), m_document, m_instrumentCombo, and updateInstrumentComboIndex().

Referenced by RealDataPropertiesWidget().

Here is the call graph for this function:

◆ updateInstrumentComboIndex()

void RealDataPropertiesWidget::updateInstrumentComboIndex ( )
private

Sets instrument combo selector to the state corresponding to given instrument identifier.

Definition at line 112 of file RealDataPropertiesWidget.cpp.

113 {
114  const QString instrumentId =
115  m_currentDataItem != nullptr ? m_currentDataItem->instrumentId() : "";
116 
117  QSignalBlocker b(m_instrumentCombo);
118  m_instrumentCombo->setCurrentIndex(m_instrumentCombo->findData(instrumentId));
119 }

References RealDataItem::instrumentId(), m_currentDataItem, and m_instrumentCombo.

Referenced by RealDataPropertiesWidget(), onInstrumentComboIndexChanged(), setItem(), and updateInstrumentComboEntries().

Here is the call graph for this function:

Member Data Documentation

◆ m_currentDataItem

RealDataItem* RealDataPropertiesWidget::m_currentDataItem
private

◆ m_document

ProjectDocument* RealDataPropertiesWidget::m_document
private

◆ m_instrumentCombo

QComboBox* RealDataPropertiesWidget::m_instrumentCombo
private

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