BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
DetectorPresenter.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/DetectorPresenter.cpp
6 //! @brief Implements class DetectorPresenter
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 
20 
21 namespace {
22 const QString SphericalDetectorPresentation = "Spherical";
23 const QString RectangularDetectorPresentation = "Rectangular";
24 } // namespace
25 
27 {
28  registerWidget(SphericalDetectorPresentation, create_new<SphericalDetectorEditor>);
29  registerWidget(RectangularDetectorPresentation, create_new<RectangularDetectorEditor>);
30  setToolBarVisible(false);
31 }
32 
34 {
35  if (!currentItem())
36  return {};
37 
38  if (currentItem()->modelType() == "SphericalDetector")
39  return SphericalDetectorPresentation;
40  else if (currentItem()->modelType() == "RectangularDetector")
41  return RectangularDetectorPresentation;
42  else
43  throw GUIHelpers::Error("DetectorPresenter::itemPresentation() -> Error. Wrong item "
44  "type '"
45  + currentItem()->modelType() + "'");
46 }
47 
49 {
50  Q_UNUSED(item);
51  return QStringList() << SphericalDetectorPresentation << RectangularDetectorPresentation;
52 }
Defines class DetectorPresenter.
Defines class GUIHelpers functions.
Defines class RectangularDetectorEditor.
Defines class SessionItem.
Defines class SphericalDetectorEditor.
QStringList activePresentationList(SessionItem *item) override
Returns list of active presentations for given item.
QString itemPresentation() const override
Presentation which should be shown for current item.
DetectorPresenter(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()