BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
FitComparisonWidget1D.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/PlotComparison/FitComparisonWidget1D.cpp
6 //! @brief Implements class FitComparisonWidget1D
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 
19 #include "GUI/Model/Job/JobItem.h"
20 #include "GUI/Util/ActionFactory.h"
27 #include <QAction>
28 #include <QGridLayout>
29 #include <QVBoxLayout>
30 
32  : SessionItemWidget(parent)
33  , m_data_plot(new Plot1DCanvas)
34  , m_diff_plot(new Plot1DCanvas)
35  , m_fitFlowWidget(new FitFlowWidget)
36  , m_statusLabel(new PlotStatusLabel(nullptr, this))
37  , m_propertyWidget(new SpecularDataPropertyWidget(this))
38  , m_resetViewAction(new QAction(this))
39  , m_comparisonController(new FitComparison1DViewController(this))
40 {
41  m_propertyWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding);
42 
43  auto* vlayout = new QVBoxLayout;
44  vlayout->setMargin(0);
45  vlayout->setSpacing(0);
46 
47  auto* gridLayout = new QGridLayout;
48  gridLayout->setMargin(0);
49  gridLayout->setSpacing(0);
50 
51  gridLayout->addWidget(m_data_plot, 0, 0, 1, -1);
52  gridLayout->addWidget(m_diff_plot, 1, 0, 1, 2);
53  gridLayout->addWidget(m_fitFlowWidget, 1, 2, 1, 1);
54 
55  vlayout->addLayout(gridLayout);
56  vlayout->addWidget(m_statusLabel);
57 
58  auto* hlayout = new QHBoxLayout;
59  hlayout->setMargin(0);
60  hlayout->setSpacing(0);
61  hlayout->addLayout(vlayout);
62  hlayout->addWidget(m_propertyWidget);
63  setLayout(hlayout);
64 
65  m_resetViewAction->setText("Center view");
66  m_resetViewAction->setIcon(QIcon(":/images/camera-metering-center.svg"));
67  m_resetViewAction->setToolTip("Reset View");
68  connect(m_resetViewAction, &QAction::triggered, this,
70 
73 
74  m_propertyWidget->setVisible(false);
75 }
76 
78 
80 {
81  return QList<QAction*>() << m_resetViewAction << m_togglePropertiesAction;
82 }
83 
85 {
86  if (!jobItem()->isValidForFitting())
87  return;
88 
89  connect(jobItem(), &JobItem::jobStatusChanged, this, [=](const JobStatus) {
90  if (jobItem()->isCompleted())
92  });
93 
95 
98  m_fitFlowWidget->setItem(jobItem()->fitSuiteItem());
99 
100  m_statusLabel->reset();
103 
105 }
106 
108 {
109  m_diff_plot->setItem(nullptr);
111 }
112 
114 {
115  viewItem()->resetView();
117 }
118 
120 {
121  auto* jobItem = dynamic_cast<JobItem*>(currentItem());
122  return jobItem;
123 }
124 
126 {
127  auto* view_item = dynamic_cast<Data1DViewItem*>(jobItem()->dataItemView());
128  ASSERT(view_item);
129  return view_item;
130 }
Defines class ActionFactory.
Defines class Data1DViewItem.
Defines classes DiffItemController, FitComparison1DViewController.
Defines class FitComparisonWidget1D.
Defines class FitFlowWidget.
Defines class FitSuiteItem.
Defines class JobItem.
JobStatus
The JobStatus enum lists the possible states of a job.
Definition: JobStatus.h:22
Defines class Plot1DCanvas.
Defines class Plot1D.
Defines class PlotStatusLabel.
Defines class RealDataItem.
Defines class SpecularDataPropertyWidget.
static QAction * createTogglePropertiesPanelAction(QObject *parent, QWidget *toggledWidget=nullptr)
Create "toggle properties panel" action.
View model for 1D DataItem. Can represent several items at once. In current implementation the first ...
void resetView()
Set axes viewport to original data.
FitComparison1DViewController * m_comparisonController
FitComparisonWidget1D(QWidget *parent=nullptr)
FitFlowWidget * m_fitFlowWidget
PlotStatusLabel * m_statusLabel
QList< QAction * > actionList() override
SpecularDataPropertyWidget * m_propertyWidget
~FitComparisonWidget1D() override
The FitFlowWidget class is intended for showing chi2 .vs interation count dependency....
Definition: FitFlowWidget.h:26
void jobStatusChanged(const JobStatus status)
Data1DViewItem * dataItemView()
Definition: JobItem.cpp:305
The Plot1DCanvas class contains SpecularPlotWithDataView for specular data presentation,...
Definition: Plot1DCanvas.h:29
Plot1D * plot1D()
void setItem(SessionItem *dataItemView) override
The PlotStatusLabel class shows status string as reported by DescriptedPlot in a frame....
void reset()
Disconnects all color maps from the label.
void addPlot(ScientificPlot *plot)
The SessionItemWidget class is a base for all widgets representing the content of SessionItem....
SessionItem * currentItem()
virtual void setItem(SessionItem *item)
Widget to edit properties of a SpecularDataItem or a Data1DViewItem.
void setItem(SpecularDataItem *item)