BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
InstrumentPresenter.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Views/InstrumentWidgets/InstrumentPresenter.cpp
6 //! @brief Implements class InstrumentPresenter
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
24 
25 namespace {
26 const QString GISASPresentation = "GISAS";
27 const QString OffSpecularPresentation = "OffSpecular";
28 const QString SpecularPresentation = "Specular";
29 const QString DepthProbePresentation = "DepthProbe";
30 } // namespace
31 
33 {
34  registerWidget(GISASPresentation, create_new<GISASInstrumentEditor>);
35  registerWidget(OffSpecularPresentation, create_new<OffSpecularInstrumentEditor>);
36  registerWidget(SpecularPresentation, create_new<SpecularInstrumentEditor>);
37  registerWidget(DepthProbePresentation, create_new<DepthProbeInstrumentEditor>);
38  setToolBarVisible(false);
39 }
40 
42 {
43  if (!currentItem())
44  return {};
45 
46  if (currentItem()->is<GISASInstrumentItem>())
47  return GISASPresentation;
48 
49  if (currentItem()->is<OffSpecularInstrumentItem>())
50  return OffSpecularPresentation;
51 
52  if (currentItem()->is<SpecularInstrumentItem>())
53  return SpecularPresentation;
54 
55  if (currentItem()->is<DepthProbeInstrumentItem>())
56  return DepthProbePresentation;
57 
58  throw GUIHelpers::Error("InstrumentPresenter::itemPresentation() -> Error. Wrong item "
59  "type '"
60  + currentItem()->modelType() + "'");
61 }
62 
64 {
65  Q_UNUSED(item);
66  return QStringList() << GISASPresentation << OffSpecularPresentation << SpecularPresentation
67  << DepthProbePresentation;
68 }
Defines class DepthProbeInstrumentEditor.
Defines DepthProbeInstrumentItem class.
Defines class GISASInstrumentEditor.
Defines class GUIHelpers functions.
Defines InstrumentItems classes.
Defines class InstrumentPresenter.
Defines class OffSpecularInstrumentEditor.
Defines class SessionItem.
Defines class SpecularInstrumentEditor.
QString itemPresentation() const override
Presentation which should be shown for current item.
QStringList activePresentationList(SessionItem *item) override
Returns list of active presentations for given item.
InstrumentPresenter(QWidget *parent=nullptr)
The ItemComboWidget class combines stack of widgets with QComboBox controller to switch between widge...
void setToolBarVisible(bool value)
void registerWidget(const QString &presentationType, factory_function_t)
SessionItem * currentItem()