BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
UpdateTimer.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Tool/UpdateTimer.h
6 //! @brief Defines class UpdateTimer
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_VIEW_TOOL_UPDATETIMER_H
16 #define BORNAGAIN_GUI_VIEW_TOOL_UPDATETIMER_H
17 
18 #include <QObject>
19 
20 class QTimer;
21 
22 //! The UpdateTimer class accumulates update requests during certain period of time, and at
23 //! the end of this period emits special signal.
24 
25 //! Used in ColorMap plot to avoid often replot of CustomPlot.
26 
27 class UpdateTimer : public QObject {
28  Q_OBJECT
29 public:
30  explicit UpdateTimer(int timerInterval, QObject* parent = nullptr);
31 
32  void reset();
33 
34  void setWallclockTimer(int timerInterval);
35 
36 signals:
37  void timeToUpdate();
38 
39 public slots:
40  void scheduleUpdate();
41 
42 private slots:
43  void onTimerTimeout();
44 
45 private:
46  qint64 m_update_request_count; //!< Number of requests accumulated so far.
47  int m_timer_interval; //!< Timer in msec.
48  bool m_is_busy;
49  QTimer* m_timer;
50 };
51 
52 #endif // BORNAGAIN_GUI_VIEW_TOOL_UPDATETIMER_H
The UpdateTimer class accumulates update requests during certain period of time, and at the end of th...
Definition: UpdateTimer.h:27
UpdateTimer(int timerInterval, QObject *parent=nullptr)
Definition: UpdateTimer.cpp:18
void scheduleUpdate()
Definition: UpdateTimer.cpp:42
QTimer * m_timer
Definition: UpdateTimer.h:49
void timeToUpdate()
void setWallclockTimer(int timerInterval)
Definition: UpdateTimer.cpp:37
bool m_is_busy
Definition: UpdateTimer.h:48
qint64 m_update_request_count
Number of requests accumulated so far.
Definition: UpdateTimer.h:46
int m_timer_interval
Timer in msec.
Definition: UpdateTimer.h:47
void reset()
Definition: UpdateTimer.cpp:30
void onTimerTimeout()
Definition: UpdateTimer.cpp:53