BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
PySampleWidget.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Views/InfoWidgets/PySampleWidget.h
6 //! @brief Defines class PySampleWidget
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_VIEWS_INFOWIDGETS_PYSAMPLEWIDGET_H
16 #define BORNAGAIN_GUI_COREGUI_VIEWS_INFOWIDGETS_PYSAMPLEWIDGET_H
17 
18 #include <QWidget>
19 
20 class SampleModel;
21 class InstrumentModel;
22 class QTextEdit;
23 class QModelIndex;
25 class UpdateTimer;
26 class WarningSign;
27 class QShowEvent;
28 class QHideEvent;
29 
30 //! Displays Python script representing a MultiLayer at the bottom of SampleView.
31 
32 class PySampleWidget : public QWidget {
33  Q_OBJECT
34 
35 public:
36  PySampleWidget(QWidget* parent = nullptr);
37 
38  void setSampleModel(SampleModel* sampleModel);
39  void setInstrumentModel(InstrumentModel* instrumentModel);
40 
41 public slots:
42  void onModifiedRow(const QModelIndex&, int, int);
43  void onDataChanged(const QModelIndex&, const QModelIndex&);
44 
45  void updateEditor();
46  void setEditorConnected(bool isConnected);
47 
48 protected:
49  void showEvent(QShowEvent*);
50  void hideEvent(QHideEvent*);
51 
52 private:
53  QString generateCodeSnippet();
54 
55  QTextEdit* m_textEdit;
61 };
62 
63 #endif // BORNAGAIN_GUI_COREGUI_VIEWS_INFOWIDGETS_PYSAMPLEWIDGET_H
Displays Python script representing a MultiLayer at the bottom of SampleView.
void setEditorConnected(bool isConnected)
void onDataChanged(const QModelIndex &, const QModelIndex &)
QString generateCodeSnippet()
generates string representing code snippet for all multi layers in the model
void showEvent(QShowEvent *)
WarningSign * m_warningSign
QTextEdit * m_textEdit
void setInstrumentModel(InstrumentModel *instrumentModel)
InstrumentModel * m_instrumentModel
void hideEvent(QHideEvent *)
PySampleWidget(QWidget *parent=nullptr)
PythonSyntaxHighlighter * m_highlighter
void onModifiedRow(const QModelIndex &, int, int)
SampleModel * m_sampleModel
void updateEditor()
Update the editor with the script content.
void setSampleModel(SampleModel *sampleModel)
UpdateTimer * m_updateTimer
Implementation of highlighting for Python code.
Main model to hold sample items.
Definition: SampleModel.h:24
The UpdateTimer class accumulates update requests during certain period of time, and at the end of th...
Definition: UpdateTimer.h:27
The WarningSign controls appearance of WarningSignWidget on top of parent widget.
Definition: WarningSign.h:25