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

Description

Definition at line 27 of file InstrumentView.h.

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

Public Member Functions

 InstrumentView (QWidget *parent, ProjectDocument *document)
 

Protected Member Functions

void hideEvent (QHideEvent *) override
 
void showEvent (QShowEvent *) override
 

Private Member Functions

void createWidgetsForCurrentInstrument ()
 
void onInstrumentChangedByEditor ()
 
void onInstrumentChangedFromExternal (const InstrumentItem *instrument)
 
void onInstrumentdescriptionEdited (const QString &t)
 
void onInstrumentNameEdited (const QString &newName)
 
void updateSingleInstrumentMode ()
 

Private Attributes

ProjectDocumentm_document
 
InstrumentListViewm_instrumentListView
 
QScrollArea * m_scrollArea
 

Constructor & Destructor Documentation

◆ InstrumentView()

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

Definition at line 33 of file InstrumentView.cpp.

34  : QWidget(parent)
35  , m_document(document)
36 {
37  setAttribute(Qt::WA_StyledBackground, true);
38  setProperty("stylable", true); // for stylesheet addressing
39 
40  auto* horizontalLayout = new QHBoxLayout;
41  m_instrumentListView = new InstrumentListView(document, this);
42  horizontalLayout->addWidget(m_instrumentListView);
43 
44  m_scrollArea = new QScrollArea(this);
45  m_scrollArea->setWidgetResizable(true);
46  m_scrollArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
47  horizontalLayout->addWidget(m_scrollArea, 1);
48 
49  auto* toolbar = new StyledToolbar(this);
50  toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
51  toolbar->addActions(m_instrumentListView->toolbarActions());
52 
53  auto* mainLayout = new QVBoxLayout(this);
54  mainLayout->setMargin(0);
55  mainLayout->setSpacing(0);
56  mainLayout->addWidget(toolbar);
57  mainLayout->addLayout(horizontalLayout);
58 
61 
64 
67 }
Instrument selector on the left side of InstrumentView.
void instrumentSelected(InstrumentItem *instrument)
QList< QAction * > toolbarActions() const
void createWidgetsForCurrentInstrument()
QScrollArea * m_scrollArea
InstrumentListView * m_instrumentListView
ProjectDocument * m_document
void updateSingleInstrumentMode()
void singleInstrumentModeChanged()
Emitted when single instrument mode has changed.
The StyledToolbar class represents our standard narrow toolbar with the height 24 pixels.
Definition: StyledToolbar.h:22

References createWidgetsForCurrentInstrument(), InstrumentListView::instrumentSelected(), m_document, m_instrumentListView, m_scrollArea, ProjectDocument::singleInstrumentModeChanged(), InstrumentListView::toolbarActions(), and updateSingleInstrumentMode().

Here is the call graph for this function:

Member Function Documentation

◆ createWidgetsForCurrentInstrument()

void InstrumentView::createWidgetsForCurrentInstrument ( )
private

Definition at line 87 of file InstrumentView.cpp.

88 {
89  auto* currentInstrument = m_instrumentListView->currentInstrument();
90  if (!currentInstrument) {
91  m_scrollArea->setWidget(new QWidget(m_scrollArea)); // blank widget
92  return;
93  }
94 
95  QWidget* w = new QWidget(m_scrollArea);
96  auto* layout = new QVBoxLayout(w);
97 
98  w->setAttribute(Qt::WA_StyledBackground, true);
99  w->setProperty("stylable", true); // for stylesheet addressing
100 
101  auto* g = new QGroupBox(m_scrollArea);
102  g->setTitle(QString("Information (%1 instrument)").arg(currentInstrument->instrumentType()));
103 
104  auto* formLayout = new QFormLayout(g);
105  formLayout->setMargin(17);
106  formLayout->setSpacing(8);
107  layout->addWidget(g);
108 
109  auto* nameEdit = new QLineEdit(g);
110  formLayout->addRow("Name:", nameEdit);
111  nameEdit->setText(currentInstrument->instrumentName());
112  connect(nameEdit, &QLineEdit::textEdited, this, &InstrumentView::onInstrumentNameEdited);
113 
114  auto* descriptionEdit = new QTextEdit(g);
115  descriptionEdit->setMinimumWidth(300);
116  descriptionEdit->setMaximumHeight(100);
117  descriptionEdit->setAcceptRichText(false);
118  descriptionEdit->setTabChangesFocus(true);
119  descriptionEdit->setPlainText(currentInstrument->description());
120  formLayout->addRow("Description:", descriptionEdit);
121  connect(descriptionEdit, &QTextEdit::textChanged,
122  [=]() { onInstrumentdescriptionEdited(descriptionEdit->toPlainText()); });
123 
125 
126  if (auto* sp = dynamic_cast<SpecularInstrumentItem*>(currentInstrument)) {
127  auto* editor =
129  connect(editor, &SpecularInstrumentEditor::dataChanged, this,
131  layout->addWidget(editor);
132  } else if (auto* os = dynamic_cast<OffspecInstrumentItem*>(currentInstrument)) {
133  auto* editor = new OffspecInstrumentEditor(m_scrollArea, os);
134  connect(editor, &OffspecInstrumentEditor::dataChanged, this,
136  layout->addWidget(editor);
137  } else if (auto* gisas = dynamic_cast<GISASInstrumentItem*>(currentInstrument)) {
138  auto* editor = new GISASInstrumentEditor(m_scrollArea, gisas);
139  connect(editor, &GISASInstrumentEditor::dataChanged, this,
141  layout->addWidget(editor);
142  } else if (auto* dp = dynamic_cast<DepthProbeInstrumentItem*>(currentInstrument)) {
143  auto* editor = new DepthProbeInstrumentEditor(m_scrollArea, dp);
144  connect(editor, &DepthProbeInstrumentEditor::dataChanged, this,
146  layout->addWidget(editor);
147  } else
148  ASSERT(false);
149 
150  m_scrollArea->setWidget(w);
151 }
Editor for GISAS instruments.
static GroupBoxCollapser * installIntoGroupBox(QGroupBox *groupBox, bool expanded=true)
InstrumentItem * currentInstrument() const
void onInstrumentdescriptionEdited(const QString &t)
void onInstrumentNameEdited(const QString &newName)
void onInstrumentChangedByEditor()
InstrumentsEditController * instrumentsEditController()
The edit controller for the instruments in this project document.

References InstrumentListView::currentInstrument(), DepthProbeInstrumentEditor::dataChanged(), GISASInstrumentEditor::dataChanged(), OffspecInstrumentEditor::dataChanged(), SpecularInstrumentEditor::dataChanged(), GroupBoxCollapser::installIntoGroupBox(), ProjectDocument::instrumentsEditController(), m_document, m_instrumentListView, m_scrollArea, onInstrumentChangedByEditor(), onInstrumentdescriptionEdited(), and onInstrumentNameEdited().

Referenced by InstrumentView(), and onInstrumentChangedFromExternal().

Here is the call graph for this function:

◆ hideEvent()

void InstrumentView::hideEvent ( QHideEvent *  )
overrideprotected

Definition at line 79 of file InstrumentView.cpp.

80 {
81  // when the instrument view gets hidden (meaning another view is shown), it's necessary to
82  // listen to changes (e.g. performed by the LinkInstrumentManager).
85 }
void onInstrumentChangedFromExternal(const InstrumentItem *instrument)
void instrumentChanged(const InstrumentItem *instrument)
Signals any change in the settings of the given instrument.

References InstrumentsEditController::instrumentChanged(), ProjectDocument::instrumentsEditController(), m_document, and onInstrumentChangedFromExternal().

Here is the call graph for this function:

◆ onInstrumentChangedByEditor()

void InstrumentView::onInstrumentChangedByEditor ( )
private

Definition at line 169 of file InstrumentView.cpp.

170 {
173 }
void notifyInstrumentChanged(InstrumentItem *instrument)
Simply emits the instrumentChanged signal. Call this whenever you change an instrument's data without...

References InstrumentListView::currentInstrument(), ProjectDocument::instrumentsEditController(), m_document, m_instrumentListView, and InstrumentsEditController::notifyInstrumentChanged().

Referenced by createWidgetsForCurrentInstrument(), and onInstrumentdescriptionEdited().

Here is the call graph for this function:

◆ onInstrumentChangedFromExternal()

void InstrumentView::onInstrumentChangedFromExternal ( const InstrumentItem instrument)
private

Definition at line 175 of file InstrumentView.cpp.

176 {
177  if (instrument == m_instrumentListView->currentInstrument())
179 }

References createWidgetsForCurrentInstrument(), InstrumentListView::currentInstrument(), and m_instrumentListView.

Referenced by hideEvent(), and showEvent().

Here is the call graph for this function:

◆ onInstrumentdescriptionEdited()

void InstrumentView::onInstrumentdescriptionEdited ( const QString &  t)
private

Definition at line 160 of file InstrumentView.cpp.

161 {
162  auto* currentInstrument = m_instrumentListView->currentInstrument();
163  if (currentInstrument && currentInstrument->description() != t) {
164  currentInstrument->setDescription(t);
166  }
167 }
void setDescription(const QString &description)

References InstrumentListView::currentInstrument(), m_instrumentListView, onInstrumentChangedByEditor(), and InstrumentItem::setDescription().

Referenced by createWidgetsForCurrentInstrument().

Here is the call graph for this function:

◆ onInstrumentNameEdited()

void InstrumentView::onInstrumentNameEdited ( const QString &  newName)
private

Definition at line 153 of file InstrumentView.cpp.

154 {
155  auto* currentInstrument = m_instrumentListView->currentInstrument();
156  if (currentInstrument && currentInstrument->instrumentName() != newName)
157  m_document->instrumentsEditController()->setInstrumentName(currentInstrument, newName);
158 }
void setInstrumentName(InstrumentItem *instrument, const QString &name)
Set an instrument's name and emit the respective signal.

References InstrumentListView::currentInstrument(), ProjectDocument::instrumentsEditController(), m_document, m_instrumentListView, and InstrumentsEditController::setInstrumentName().

Referenced by createWidgetsForCurrentInstrument().

Here is the call graph for this function:

◆ showEvent()

void InstrumentView::showEvent ( QShowEvent *  )
overrideprotected

Definition at line 69 of file InstrumentView.cpp.

70 {
71  // disconnect because when this view is visible, no other instance is modifying instruments. By
72  // disconnecting, no additional logic is necessary to avoid recursive calls (recursive since
73  // this view also causes instrumentChanged to be emitted).
77 }

References InstrumentsEditController::instrumentChanged(), ProjectDocument::instrumentsEditController(), m_document, and onInstrumentChangedFromExternal().

Here is the call graph for this function:

◆ updateSingleInstrumentMode()

void InstrumentView::updateSingleInstrumentMode ( )
private

Definition at line 181 of file InstrumentView.cpp.

182 {
184 }
bool singleInstrumentMode() const

References m_document, m_instrumentListView, and ProjectDocument::singleInstrumentMode().

Referenced by InstrumentView().

Here is the call graph for this function:

Member Data Documentation

◆ m_document

◆ m_instrumentListView

◆ m_scrollArea

QScrollArea* InstrumentView::m_scrollArea
private

Definition at line 48 of file InstrumentView.h.

Referenced by InstrumentView(), and createWidgetsForCurrentInstrument().


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