BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
JobRealTimeWidget.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Fit/JobRealTimeWidget.cpp
6 //! @brief Implements class JobRealTimeWidget
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 
16 #include "GUI/Model/Job/JobItem.h"
20 #include <QVBoxLayout>
21 
22 namespace {
23 
24 const bool reuse_widget = true;
25 }
26 
28  : QWidget(parent)
29  , m_stackedWidget(new ItemStackPresenter<ParameterTuningWidget>(reuse_widget))
30 {
32  setObjectName("JobRealTimeWidget");
33  setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
34 
35  auto* mainLayout = new QVBoxLayout;
36  mainLayout->setMargin(0);
37  mainLayout->setSpacing(0);
38  mainLayout->addWidget(m_stackedWidget);
39  setLayout(mainLayout);
40 
41  m_stackedWidget->setModel(jobModel);
42 }
43 
45 {
46  return m_stackedWidget->itemWidget(jobItem);
47 }
48 
50 {
52 }
53 
55 {
56  return QSize(100, 100);
57 }
58 
60 {
61  if (!isValidJobItem(jobItem)) {
63  return;
64  }
65  m_stackedWidget->setItem(jobItem);
66 }
67 
68 //! Returns true if JobItem is valid for real time simulation.
69 
71 {
72  return item && (item->isCompleted() || item->isCanceled() || item->isFailed());
73 }
Defines class JobItem.
Defines class JobModel.
Defines class JobRealTimeWidget.
Defines class ParameterTuningWidget.
The ItemStackPresenter templated class extends ItemStackWidget so it could operate with SesionItem ed...
void setItem(U *item, bool *isNew=nullptr)
Shows the widget for given item (and hides previous one). If no widget yet exists,...
T * itemWidget(SessionItem *item)
void setModel(SessionModel *model)
bool isFailed() const
Definition: JobItem.cpp:144
bool isCompleted() const
Definition: JobItem.cpp:134
bool isCanceled() const
Definition: JobItem.cpp:139
QSize minimumSizeHint() const override
void setItem(JobItem *jobItem)
JobRealTimeWidget(JobModel *jobModel, QWidget *parent=nullptr)
QSize sizeHint() const override
ItemStackPresenter< ParameterTuningWidget > * m_stackedWidget
ParameterTuningWidget * parameterTuningWidget(JobItem *jobItem)
bool isValidJobItem(JobItem *item)
Returns true if JobItem is valid for real time simulation.
Main widget for real time parameter tuning. Contains a tree for parameter tuning and the model to pro...
Defines namespace GUI::Constants.
const QString JobRealTimeWidgetName
const unsigned int REALTIME_WIDGET_WIDTH_HINT