BornAgain
1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
|
Assists in importing Python object to GUI models. More...
Public Member Functions | |
PyImportAssistant (MainWindow *mainwin) | |
void | exec () |
Private Member Functions | |
std::unique_ptr< MultiLayer > | createMultiLayer (const QString &snippet, const QString &funcName) |
Creates a multi-layer by executing a funcName in embedded Python. More... | |
QString | fileNameToOpen () |
Lets user to select Python file on disk. More... | |
QString | getPySampleFunctionName (const QString &snippet) |
Returns the name of function which might generate a MultiLayer in Python code snippet. More... | |
void | populateModels (const MultiLayer &multilayer, const QString &sampleName) |
Populates GUI models with domain multilayer. More... | |
QString | readFile (const QString &fileName) |
Read content of text file and returns it as a multi-line string. More... | |
void | saveImportDir (const QString &fileName) |
Saves file location as a future import dir. More... | |
QString | selectPySampleFunction (const QStringList &funcNames) |
Lets user select a function name which generates a MultiLayer. More... | |
Private Attributes | |
MainWindow * | m_mainWindow |
Assists in importing Python object to GUI models.
Definition at line 28 of file PyImportAssistant.h.
PyImportAssistant::PyImportAssistant | ( | MainWindow * | mainwin | ) |
Definition at line 65 of file PyImportAssistant.cpp.
|
private |
Creates a multi-layer by executing a funcName in embedded Python.
Function is supposed to be in code provided by 'snippet'.
Definition at line 189 of file PyImportAssistant.cpp.
References PyImport::createFromPython(), and m_mainWindow.
Referenced by exec().
void PyImportAssistant::exec | ( | ) |
Definition at line 69 of file PyImportAssistant.cpp.
References GUIHelpers::baseName(), createMultiLayer(), fileNameToOpen(), getPySampleFunctionName(), populateModels(), and readFile().
Referenced by ActionManager::onImportFromPythonScript().
|
private |
Lets user to select Python file on disk.
Definition at line 93 of file PyImportAssistant.cpp.
References m_mainWindow, AppSvc::projectManager(), saveImportDir(), and ProjectManager::userImportDir().
Referenced by exec().
|
private |
Returns the name of function which might generate a MultiLayer in Python code snippet.
Pop-ups dialog and asks user for help in the case of doubts.
Definition at line 137 of file PyImportAssistant.cpp.
References GUIHelpers::fromStdStrings(), PyImport::listOfFunctions(), m_mainWindow, and selectPySampleFunction().
Referenced by exec().
|
private |
Populates GUI models with domain multilayer.
Definition at line 212 of file PyImportAssistant.cpp.
References IParametricComponent::getName(), GUIHelpers::information(), m_mainWindow, MainWindow::materialModel(), RealSpace::Particles::name(), GUIObjectBuilder::populateSampleModel(), and MainWindow::sampleModel().
Referenced by exec().
|
private |
Read content of text file and returns it as a multi-line string.
Pop-ups warning dialog in the case of failure.
Definition at line 118 of file PyImportAssistant.cpp.
References m_mainWindow, ProjectUtils::readTextFile(), and GUIHelpers::warning().
Referenced by exec().
|
private |
Saves file location as a future import dir.
Definition at line 107 of file PyImportAssistant.cpp.
References GUIHelpers::fileDir(), AppSvc::projectManager(), and ProjectManager::setImportDir().
Referenced by fileNameToOpen().
|
private |
Lets user select a function name which generates a MultiLayer.
Definition at line 161 of file PyImportAssistant.cpp.
References ComboSelectorDialog::addItems(), ComboSelectorDialog::currentText(), m_mainWindow, ComboSelectorDialog::setTextBottom(), ComboSelectorDialog::setTextTop(), and GUIHelpers::warning().
Referenced by getPySampleFunctionName().
|
private |
Definition at line 44 of file PyImportAssistant.h.
Referenced by createMultiLayer(), fileNameToOpen(), getPySampleFunctionName(), populateModels(), readFile(), and selectPySampleFunction().