BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
PyImportAssistant.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/mainwindow/PyImportAssistant.h
6 //! @brief Implements class PyImportAssistant
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_COREGUI_MAINWINDOW_PYIMPORTASSISTANT_H
16 #define BORNAGAIN_GUI_COREGUI_MAINWINDOW_PYIMPORTASSISTANT_H
17 
18 #ifdef BORNAGAIN_PYTHON
19 
20 #include <QObject>
21 #include <memory>
22 
23 class MainWindow;
24 class MultiLayer;
25 
26 //! Assists in importing Python object to GUI models.
27 
28 class PyImportAssistant : public QObject {
29  Q_OBJECT
30 public:
31  PyImportAssistant(MainWindow* mainwin);
32 
33  void exec();
34 
35 private:
36  QString fileNameToOpen();
37  void saveImportDir(const QString& fileName);
38  QString readFile(const QString& fileName);
39  QString getPySampleFunctionName(const QString& snippet);
40  QString selectPySampleFunction(const QStringList& funcNames);
41  std::unique_ptr<MultiLayer> createMultiLayer(const QString& snippet, const QString& funcName);
42  void populateModels(const MultiLayer& multilayer, const QString& sampleName);
43 
45 };
46 
47 #endif // BORNAGAIN_PYTHON
48 
49 #endif // BORNAGAIN_GUI_COREGUI_MAINWINDOW_PYIMPORTASSISTANT_H
Our sample model: a stack of layers one below the other.
Definition: MultiLayer.h:41
Assists in importing Python object to GUI models.
QString fileNameToOpen()
Lets user to select Python file on disk.
QString readFile(const QString &fileName)
Read content of text file and returns it as a multi-line string.
QString getPySampleFunctionName(const QString &snippet)
Returns the name of function which might generate a MultiLayer in Python code snippet.
void populateModels(const MultiLayer &multilayer, const QString &sampleName)
Populates GUI models with domain multilayer.
MainWindow * m_mainWindow
PyImportAssistant(MainWindow *mainwin)
void saveImportDir(const QString &fileName)
Saves file location as a future import dir.
std::unique_ptr< MultiLayer > createMultiLayer(const QString &snippet, const QString &funcName)
Creates a multi-layer by executing a funcName in embedded Python.
QString selectPySampleFunction(const QStringList &funcNames)
Lets user select a function name which generates a MultiLayer.