BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
UpdateTimer Class Reference

Description

The UpdateTimer class accumulates update requests during certain period of time, and at the end of this period emits special signal.

Used in ColorMap plot to avoid often replot of CustomPlot.

Definition at line 27 of file UpdateTimer.h.

Inheritance diagram for UpdateTimer:
[legend]
Collaboration diagram for UpdateTimer:
[legend]

Public Slots

void scheduleUpdate ()
 

Signals

void timeToUpdate ()
 

Public Member Functions

 UpdateTimer (int timerInterval, QObject *parent=nullptr)
 
void reset ()
 
void setWallclockTimer (int timerInterval)
 

Private Slots

void onTimerTimeout ()
 

Private Attributes

bool m_is_busy
 
QTimer * m_timer
 
int m_timer_interval
 Timer in msec. More...
 
qint64 m_update_request_count
 Number of requests accumulated so far. More...
 

Constructor & Destructor Documentation

◆ UpdateTimer()

UpdateTimer::UpdateTimer ( int  timerInterval,
QObject *  parent = nullptr 
)
explicit

Definition at line 18 of file UpdateTimer.cpp.

19  : QObject(parent)
21  , m_timer_interval(timerInterval)
22  , m_is_busy(false)
23  , m_timer(new QTimer(this))
24 {
25  m_timer->setInterval(m_timer_interval);
26  m_timer->setSingleShot(true);
27  connect(m_timer, &QTimer::timeout, this, &UpdateTimer::onTimerTimeout);
28 }
QTimer * m_timer
Definition: UpdateTimer.h:49
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 onTimerTimeout()
Definition: UpdateTimer.cpp:53

References m_timer, m_timer_interval, and onTimerTimeout().

Here is the call graph for this function:

Member Function Documentation

◆ onTimerTimeout

void UpdateTimer::onTimerTimeout ( )
privateslot

Definition at line 53 of file UpdateTimer.cpp.

54 {
55  m_is_busy = true;
56 
57  if (m_update_request_count > 0) {
59  emit timeToUpdate();
60  }
61 
62  m_is_busy = false;
63 }
void timeToUpdate()

References m_is_busy, m_update_request_count, and timeToUpdate().

Referenced by UpdateTimer().

◆ reset()

void UpdateTimer::reset ( )

◆ scheduleUpdate

void UpdateTimer::scheduleUpdate ( )
slot

◆ setWallclockTimer()

void UpdateTimer::setWallclockTimer ( int  timerInterval)

Definition at line 37 of file UpdateTimer.cpp.

38 {
39  m_timer_interval = timerInterval;
40 }

References m_timer_interval.

Referenced by AutosaveController::setAutosaveTime().

◆ timeToUpdate

Member Data Documentation

◆ m_is_busy

bool UpdateTimer::m_is_busy
private

Definition at line 48 of file UpdateTimer.h.

Referenced by onTimerTimeout(), reset(), and scheduleUpdate().

◆ m_timer

QTimer* UpdateTimer::m_timer
private

Definition at line 49 of file UpdateTimer.h.

Referenced by UpdateTimer(), reset(), and scheduleUpdate().

◆ m_timer_interval

int UpdateTimer::m_timer_interval
private

Timer in msec.

Definition at line 47 of file UpdateTimer.h.

Referenced by UpdateTimer(), scheduleUpdate(), and setWallclockTimer().

◆ m_update_request_count

qint64 UpdateTimer::m_update_request_count
private

Number of requests accumulated so far.

Definition at line 46 of file UpdateTimer.h.

Referenced by onTimerTimeout(), reset(), and scheduleUpdate().


The documentation for this class was generated from the following files: