BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
FitComparisonWidget.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/PlotComparison/FitComparisonWidget.cpp
6 //! @brief Implements class FitComparisonWidget
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_realDataPlot(new ColorMapCanvas)
34  , m_simulatedDataPlot(new ColorMapCanvas)
35  , m_relativeDiffPlot(new ColorMapCanvas)
36  , m_fitFlowWidget(new FitFlowWidget)
37  , m_statusLabel(new PlotStatusLabel(nullptr, this))
38  , m_propertyWidget(new IntensityDataPropertyWidget(this))
39  , m_resetViewAction(new QAction(this))
40  , m_comparisonController(new FitComparisonController2D(this))
41 {
42  auto* vlayout = new QVBoxLayout;
43  vlayout->setMargin(0);
44  vlayout->setSpacing(0);
45 
46  m_propertyWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
47 
48  auto* gridLayout = new QGridLayout;
49  gridLayout->setMargin(0);
50  gridLayout->setSpacing(0);
51 
52  gridLayout->addWidget(m_realDataPlot, 0, 0);
53  gridLayout->addWidget(m_simulatedDataPlot, 0, 1);
54  gridLayout->addWidget(m_relativeDiffPlot, 1, 0);
55  gridLayout->addWidget(m_fitFlowWidget, 1, 1);
56 
57  vlayout->addLayout(gridLayout);
58  vlayout->addWidget(m_statusLabel);
59 
60  auto* hlayout = new QHBoxLayout;
61  hlayout->setMargin(0);
62  hlayout->setSpacing(0);
63  hlayout->addLayout(vlayout);
64  hlayout->addWidget(m_propertyWidget);
65  setLayout(hlayout);
66 
67  m_resetViewAction->setText("Center view");
68  m_resetViewAction->setIcon(QIcon(":/images/camera-metering-center.svg"));
69  m_resetViewAction->setToolTip("Reset View");
70  connect(m_resetViewAction, &QAction::triggered, this, &FitComparisonWidget::onResetViewAction);
71 
74 
75  m_propertyWidget->setVisible(false);
76 }
77 
79 
81 {
82  return QList<QAction*>() << m_resetViewAction << m_togglePropertiesAction;
83 }
84 
86 {
87  if (!jobItem()->isValidForFitting())
88  return;
89 
90  connect(jobItem(), &JobItem::jobStatusChanged, this, [=](const JobStatus) {
91  if (jobItem()->isCompleted())
93  });
94 
99  m_fitFlowWidget->setItem(jobItem()->fitSuiteItem());
100 
101  m_statusLabel->reset();
105 
107 }
108 
110 {
112 }
113 
115 {
116  if (auto* item = realDataItem())
117  item->resetView();
118 
120 }
121 
123 {
124  auto* jobItem = dynamic_cast<JobItem*>(currentItem());
125  return jobItem;
126 }
127 
129 {
130  return jobItem()->realDataItem()->intensityDataItem();
131 }
132 
134 {
135  return jobItem()->intensityDataItem();
136 }
137 
139 {
141 }
Defines class ActionFactory.
Defines class ColorMapCanvas.
Defines class ColorMap.
Defines class FitComparisonController.
Defines class FitComparisonWidget.
Defines class FitFlowWidget.
Defines class FitSuiteItem.
Defines class IntensityDataItem.
Defines class IntensityDataPropertyWidget.
Defines class JobItem.
JobStatus
The JobStatus enum lists the possible states of a job.
Definition: JobStatus.h:22
Defines class PlotStatusLabel.
Defines class RealDataItem.
static QAction * createTogglePropertiesPanelAction(QObject *parent, QWidget *toggledWidget=nullptr)
Create "toggle properties panel" action.
The ColorMapCanvas class contains ColorMap for intensity data presentation, and provide control of fo...
void setItem(SessionItem *intensityDataItem) override
ColorMap * colorMap()
Provides synchronization between certain properties of fit related IntensityDataItems....
void setItem(JobItem *job_item)
PlotStatusLabel * m_statusLabel
FitFlowWidget * m_fitFlowWidget
ColorMapCanvas * m_simulatedDataPlot
IntensityDataPropertyWidget * m_propertyWidget
IntensityDataItem * diffItem()
ColorMapCanvas * m_realDataPlot
FitComparisonWidget(QWidget *parent=nullptr)
QAction * m_togglePropertiesAction
IntensityDataItem * realDataItem()
IntensityDataItem * simulatedDataItem()
void subscribeToItem() override
FitComparisonController2D * m_comparisonController
~FitComparisonWidget() override
QList< QAction * > actionList() override
void unsubscribeFromItem() override
ColorMapCanvas * m_relativeDiffPlot
The FitFlowWidget class is intended for showing chi2 .vs interation count dependency....
Definition: FitFlowWidget.h:26
Widget to edit properties of an IntensityDataItem.
void setItem(IntensityDataItem *mainItem, IntensityDataItem *realItem=nullptr)
void jobStatusChanged(const JobStatus status)
RealDataItem * realDataItem()
Definition: JobItem.cpp:290
IntensityDataItem * intensityDataItem()
Definition: JobItem.cpp:96
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)
IntensityDataItem * intensityDataItem()
The SessionItemWidget class is a base for all widgets representing the content of SessionItem....
SessionItem * currentItem()
virtual void setItem(SessionItem *item)