BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
GUIFitObserver.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Views/FitWidgets/GUIFitObserver.h
6 //! @brief Implements class GUIFitObserver
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_FITWIDGETS_GUIFITOBSERVER_H
16 #define BORNAGAIN_GUI_COREGUI_VIEWS_FITWIDGETS_GUIFITOBSERVER_H
17 
19 #include <QObject>
20 #include <condition_variable>
21 #include <mutex>
22 
23 template <class T> class OutputData;
24 class IntensityDataItem;
25 class FitObjective;
26 
27 //! Serves as observer for FitObjective and saves fit iteration data for later display
28 //! in GUI widgets.
29 
30 class GUIFitObserver : public QObject {
31  Q_OBJECT
32 
33 public:
34  GUIFitObserver(QObject* parent = nullptr);
36 
37  void update(const FitObjective* subject);
38 
39  void finishedPlotting();
40 
42 
43 public slots:
44  void setInterval(int val);
45 
46 signals:
47  void updateReady();
48 
49 private:
50  bool is_suitable_iteration(const FitObjective* fitSuite) const;
51  bool is_obligatory_iteration(const FitObjective* fitSuite) const;
52 
54  std::mutex m_update_plot_mutex;
55  std::condition_variable m_on_finish_notifier;
58 };
59 
60 #endif // BORNAGAIN_GUI_COREGUI_VIEWS_FITWIDGETS_GUIFITOBSERVER_H
Defines class FitProgressInfo.
Holds vector of SimDataPairs (experimental data and simulation results) for use in fitting.
Definition: FitObjective.h:33
The FitProgressInfo class contains all essential information about fit progress.
Serves as observer for FitObjective and saves fit iteration data for later display in GUI widgets.
std::condition_variable m_on_finish_notifier
void setInterval(int val)
void finishedPlotting()
Informs observer that FitSuiteWidget has finished plotting and is ready for next plot.
bool is_suitable_iteration(const FitObjective *fitSuite) const
Returns true if data could be plotted, when there are resources for it.
bool is_obligatory_iteration(const FitObjective *fitSuite) const
Returns true if given iteration should be obligary plotted.
void updateReady()
FitProgressInfo m_iteration_info
FitProgressInfo progressInfo()
GUIFitObserver(QObject *parent=nullptr)
bool m_block_update_plots
void update(const FitObjective *subject)
std::mutex m_update_plot_mutex
Templated class to store data of type double or CumulativeValue in multi-dimensional space.
Definition: OutputData.h:32