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

Main widget of InstrumentView. More...

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

Public Slots

void onChangedEditor (const QString &)
 

Signals

void extendedDetectorEditorRequest (DetectorItem *)
 

Public Member Functions

 InstrumentEditorWidget (QWidget *parent=nullptr)
 
void setItem (SessionItem *instrument)
 
QSize sizeHint () const
 

Private Member Functions

QLayout * createTopLayout ()
 top block with instrument name More...
 
void updateWidgets ()
 

Private Attributes

bool m_block_signals
 
SessionItemm_currentItem
 
InstrumentPresenterm_instrumentPresenter
 
QLineEdit * m_nameLineEdit
 

Detailed Description

Main widget of InstrumentView.

Contains InstrumentPresenter showing proper insturment editor for given instrument type.

Definition at line 28 of file InstrumentEditorWidget.h.

Constructor & Destructor Documentation

◆ InstrumentEditorWidget()

InstrumentEditorWidget::InstrumentEditorWidget ( QWidget *  parent = nullptr)

Definition at line 25 of file InstrumentEditorWidget.cpp.

26  : QWidget(parent)
27  , m_nameLineEdit(new QLineEdit)
29  , m_currentItem(nullptr)
30  , m_block_signals(false)
31 {
32  setMinimumSize(400, 400);
33  setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
34 
35  auto mainLayout = new QVBoxLayout;
36  mainLayout->setContentsMargins(0, 20, 0, 20);
37  mainLayout->addLayout(createTopLayout());
38 
39  auto scrollArea = new AdjustingScrollArea;
40  scrollArea->setWidget(m_instrumentPresenter);
41  mainLayout->addWidget(scrollArea, 1);
42  mainLayout->addStretch();
43 
44  setLayout(mainLayout);
45 
46  connect(m_nameLineEdit, &QLineEdit::textChanged, this,
48 }
Modification of standard scroll area, which makes widget with dynamic layout ocuupy whole available s...
void setWidget(QWidget *w)
void onChangedEditor(const QString &)
InstrumentPresenter * m_instrumentPresenter
QLayout * createTopLayout()
top block with instrument name
Contains stack of instrument editors and the logic to show proper editor for certain type of instrume...

References createTopLayout(), m_instrumentPresenter, m_nameLineEdit, onChangedEditor(), and AdjustingScrollArea::setWidget().

Here is the call graph for this function:

Member Function Documentation

◆ createTopLayout()

QLayout * InstrumentEditorWidget::createTopLayout ( )
private

top block with instrument name

Definition at line 74 of file InstrumentEditorWidget.cpp.

75 {
76  auto result = new QHBoxLayout;
77 
78  m_nameLineEdit->setMinimumWidth(200);
79 
80  result->addSpacing(17);
81  result->addWidget(new QLabel("Instrument name"));
82  result->addWidget(m_nameLineEdit);
83  result->addStretch(1);
84 
85  return result;
86 }

References m_nameLineEdit.

Referenced by InstrumentEditorWidget().

◆ extendedDetectorEditorRequest

void InstrumentEditorWidget::extendedDetectorEditorRequest ( DetectorItem )
signal

◆ onChangedEditor

void InstrumentEditorWidget::onChangedEditor ( const QString &  )
slot

Definition at line 63 of file InstrumentEditorWidget.cpp.

64 {
65  if (m_block_signals)
66  return;
67 
68  if (m_currentItem)
70 }
void setItemName(const QString &name)
Set item name, add property if necessary.

References m_block_signals, m_currentItem, m_nameLineEdit, and SessionItem::setItemName().

Referenced by InstrumentEditorWidget().

Here is the call graph for this function:

◆ setItem()

void InstrumentEditorWidget::setItem ( SessionItem instrument)

Definition at line 55 of file InstrumentEditorWidget.cpp.

56 {
57  m_currentItem = instrument;
58  updateWidgets();
59 
60  m_instrumentPresenter->setItem(instrument);
61 }
virtual void setItem(SessionItem *item)

References m_currentItem, m_instrumentPresenter, SessionItemWidget::setItem(), and updateWidgets().

Here is the call graph for this function:

◆ sizeHint()

QSize InstrumentEditorWidget::sizeHint ( ) const

Definition at line 50 of file InstrumentEditorWidget.cpp.

51 {
52  return QSize(600, 600);
53 }

◆ updateWidgets()

void InstrumentEditorWidget::updateWidgets ( )
private

Definition at line 88 of file InstrumentEditorWidget.cpp.

89 {
90  m_block_signals = true;
91 
92  if (m_currentItem) {
93  m_nameLineEdit->setEnabled(true);
95  } else {
96  m_nameLineEdit->setText(QString());
97  m_nameLineEdit->setEnabled(false);
98  }
99 
100  m_block_signals = false;
101 }
QString itemName() const
Get item name, return display name if no name is set.

References SessionItem::itemName(), m_block_signals, m_currentItem, and m_nameLineEdit.

Referenced by setItem().

Here is the call graph for this function:

Member Data Documentation

◆ m_block_signals

bool InstrumentEditorWidget::m_block_signals
private

Definition at line 51 of file InstrumentEditorWidget.h.

Referenced by onChangedEditor(), and updateWidgets().

◆ m_currentItem

SessionItem* InstrumentEditorWidget::m_currentItem
private

Definition at line 50 of file InstrumentEditorWidget.h.

Referenced by onChangedEditor(), setItem(), and updateWidgets().

◆ m_instrumentPresenter

InstrumentPresenter* InstrumentEditorWidget::m_instrumentPresenter
private

Definition at line 49 of file InstrumentEditorWidget.h.

Referenced by InstrumentEditorWidget(), and setItem().

◆ m_nameLineEdit

QLineEdit* InstrumentEditorWidget::m_nameLineEdit
private

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