BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
SimulationView.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Toplevel/SimulationView.h
6 //! @brief Defines class SimulationView
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 
15 #ifndef BORNAGAIN_GUI_VIEW_TOPLEVEL_SIMULATIONVIEW_H
16 #define BORNAGAIN_GUI_VIEW_TOPLEVEL_SIMULATIONVIEW_H
17 
18 #include <QWidget>
19 
20 class MainWindow;
21 class MultiLayerItem;
22 class InstrumentItem;
23 class RealDataItem;
24 class QComboBox;
26 class ProjectDocument;
27 
28 namespace Ui {
29 
30 class SimulationView;
31 }
32 
33 //! Widget to define a simulation.
34 //! Contains:
35 //! * Elements to select instrument, sample and real data.
36 //! * Elements to set options like number of threads.
37 //! * Buttons to run simulation or to export as a Python script
38 class SimulationView : public QWidget {
39  Q_OBJECT
40 
41 public:
42  SimulationView(QWidget* parent, ProjectDocument* document);
43 
44  void simulate();
45  void exportPythonScript();
46 
47 protected:
48  void showEvent(QShowEvent*) override;
49  void hideEvent(QHideEvent*) override;
50 
51 private:
52  //! Read the entries in the UI and store in OptionsItem.
53  void readOptionsFromUI();
54 
55  //! Write entries in OptionsItem to UI
56  void writeOptionsToUI();
57 
58  //! Update enabling of elements depending on other elements.
59  void updateEnabling();
60 
61  //! Returns selected sample (MultiLayerItem) taking into account that there might be several
62  //! samples with the same name.
63  const MultiLayerItem* selectedSample() const;
64 
65  //! Returns selected InstrumentItem taking into account that there might be several
66  //! instruments with the same name.
67  const InstrumentItem* selectedInstrument() const;
68 
69  //! Returns selected real data item taking into account that there might be several
70  //! items with the same name.
71  const RealDataItem* selectedRealData() const;
72 
73  //! Updates selection combo with string list while preserving previous selection.
74  //! If allowNone == true, additional "None" item will be added to the combo.
75  void updateSelection(QComboBox* comboBox, QStringList itemList, bool allowNone = false);
76 
77  //! Checks whether selection is correct for running a simulation.
78  //! Returns empty string if valid, otherwise the error text.
79  QString validateSimulationSetup(bool validateRealData) const;
80 
81  //! Show/hide UI elements according to settings in current project
83 
84  // Convenience methods for easier access
85  QVector<MultiLayerItem*> sampleItems() const;
86  QVector<InstrumentItem*> collectedItems() const;
87  QVector<RealDataItem*> realDataItems() const;
89 
90 private:
91  Ui::SimulationView* m_ui;
93 };
94 
95 #endif // BORNAGAIN_GUI_VIEW_TOPLEVEL_SIMULATIONVIEW_H
Abstract base class for instrument-specific item classes.
Project document class handles all data related to the opened project (sample, job,...
Provides access to experimental data, for display and fitting. Owns an AbstractDataLoader.
Definition: RealDataItem.h:33
The SimulationOptionsItem class holds simulation status (run policy, number of threads,...
Widget to define a simulation. Contains:
SimulationOptionsItem * optionsItem() const
QVector< MultiLayerItem * > sampleItems() const
QVector< RealDataItem * > realDataItems() const
Ui::SimulationView * m_ui
const RealDataItem * selectedRealData() const
Returns selected real data item taking into account that there might be several items with the same n...
const InstrumentItem * selectedInstrument() const
Returns selected InstrumentItem taking into account that there might be several instruments with the ...
const MultiLayerItem * selectedSample() const
Returns selected sample (MultiLayerItem) taking into account that there might be several samples with...
QVector< InstrumentItem * > collectedItems() const
void updateFunctionalityNarrowing()
Show/hide UI elements according to settings in current project.
ProjectDocument * m_document
void showEvent(QShowEvent *) override
void updateSelection(QComboBox *comboBox, QStringList itemList, bool allowNone=false)
Updates selection combo with string list while preserving previous selection. If allowNone == true,...
void writeOptionsToUI()
Write entries in OptionsItem to UI.
void hideEvent(QHideEvent *) override
SimulationView(QWidget *parent, ProjectDocument *document)
QString validateSimulationSetup(bool validateRealData) const
Checks whether selection is correct for running a simulation. Returns empty string if valid,...
void readOptionsFromUI()
Read the entries in the UI and store in OptionsItem.
void updateEnabling()
Update enabling of elements depending on other elements.