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

Description

Definition at line 25 of file FitWorkerLauncher.h.

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

Public Slots

void interruptFitting ()
 

Signals

void fittingError (const QString &message)
 
void fittingFinished ()
 
void fittingStarted ()
 
void intern_interruptFittingWorker (QPrivateSignal)
 

Public Member Functions

 FitWorkerLauncher (QObject *parent)
 
const QDateTime & fitEnd () const
 
const QDateTime & fitStart () const
 
void runFitting (std::shared_ptr< FitObjectiveBuilder > suite)
 

Private Slots

void intern_error (const QString &mesg)
 
void intern_workerFinished ()
 
void intern_workerStarted ()
 

Private Attributes

QDateTime m_fit_end
 
QDateTime m_fit_start
 
std::atomic< bool > m_is_fit_running
 

Constructor & Destructor Documentation

◆ FitWorkerLauncher()

FitWorkerLauncher::FitWorkerLauncher ( QObject *  parent)

Definition at line 19 of file FitWorkerLauncher.cpp.

20  : QObject(parent)
21  , m_is_fit_running(false)
22 {
23 }
std::atomic< bool > m_is_fit_running

Member Function Documentation

◆ fitEnd()

const QDateTime & FitWorkerLauncher::fitEnd ( ) const

Definition at line 57 of file FitWorkerLauncher.cpp.

58 {
59  return m_fit_end;
60 }

References m_fit_end.

Referenced by FitSessionController::onFittingError(), and FitSessionController::onFittingFinished().

◆ fitStart()

const QDateTime & FitWorkerLauncher::fitStart ( ) const

Definition at line 52 of file FitWorkerLauncher.cpp.

53 {
54  return m_fit_start;
55 }

References m_fit_start.

Referenced by FitSessionController::onFittingStarted().

◆ fittingError

void FitWorkerLauncher::fittingError ( const QString &  message)
signal

◆ fittingFinished

void FitWorkerLauncher::fittingFinished ( )
signal

◆ fittingStarted

void FitWorkerLauncher::fittingStarted ( )
signal

◆ intern_error

void FitWorkerLauncher::intern_error ( const QString &  mesg)
privateslot

Definition at line 82 of file FitWorkerLauncher.cpp.

83 {
84  emit fittingError(mesg);
85 }
void fittingError(const QString &message)

References fittingError().

Referenced by runFitting().

◆ intern_interruptFittingWorker

void FitWorkerLauncher::intern_interruptFittingWorker ( QPrivateSignal  )
signal

Referenced by interruptFitting(), and runFitting().

◆ intern_workerFinished

void FitWorkerLauncher::intern_workerFinished ( )
privateslot

Definition at line 68 of file FitWorkerLauncher.cpp.

69 {
70  m_is_fit_running = false;
71  m_fit_end = QDateTime::currentDateTime();
72  emit fittingFinished();
73 }

References fittingFinished(), m_fit_end, and m_is_fit_running.

Referenced by runFitting().

◆ intern_workerStarted

void FitWorkerLauncher::intern_workerStarted ( )
privateslot

Definition at line 75 of file FitWorkerLauncher.cpp.

76 {
77  m_fit_start = QDateTime::currentDateTime();
78  m_fit_end = QDateTime();
79  emit fittingStarted();
80 }

References fittingStarted(), m_fit_end, and m_fit_start.

Referenced by runFitting().

◆ interruptFitting

void FitWorkerLauncher::interruptFitting ( )
slot

Definition at line 62 of file FitWorkerLauncher.cpp.

63 {
64  if (m_is_fit_running)
65  emit intern_interruptFittingWorker(QPrivateSignal());
66 }
void intern_interruptFittingWorker(QPrivateSignal)

References intern_interruptFittingWorker(), and m_is_fit_running.

Referenced by FitSessionController::onStopFittingRequest().

◆ runFitting()

void FitWorkerLauncher::runFitting ( std::shared_ptr< FitObjectiveBuilder suite)

Definition at line 25 of file FitWorkerLauncher.cpp.

26 {
27  if (!suite || m_is_fit_running)
28  return;
29 
30  auto* thread = new QThread();
31  auto* fw = new FitWorker(suite);
32  fw->moveToThread(thread);
33 
34  // start fitting when thread starts
35  connect(thread, &QThread::started, fw, &FitWorker::startFit);
37 
39  &FitWorker::interruptFitting, Qt::DirectConnection);
40 
43 
44  // delete fitting worker and thread when done
45  connect(fw, &FitWorker::finished, fw, &FitWorker::deleteLater);
46  connect(thread, &QThread::finished, thread, &QThread::deleteLater);
47 
48  m_is_fit_running = true;
49  thread->start();
50 }
void intern_error(const QString &mesg)
void interruptFitting()
Definition: FitWorker.cpp:30
void startFit()
Definition: FitWorker.cpp:19
void started()
void finished()
void error(const QString &message)

References FitWorker::error(), FitWorker::finished(), intern_error(), intern_interruptFittingWorker(), intern_workerFinished(), intern_workerStarted(), FitWorker::interruptFitting(), m_is_fit_running, FitWorker::started(), and FitWorker::startFit().

Referenced by FitSessionController::onStartFittingRequest().

Here is the call graph for this function:

Member Data Documentation

◆ m_fit_end

QDateTime FitWorkerLauncher::m_fit_end
private

Definition at line 56 of file FitWorkerLauncher.h.

Referenced by fitEnd(), intern_workerFinished(), and intern_workerStarted().

◆ m_fit_start

QDateTime FitWorkerLauncher::m_fit_start
private

Definition at line 55 of file FitWorkerLauncher.h.

Referenced by fitStart(), and intern_workerStarted().

◆ m_is_fit_running

std::atomic<bool> FitWorkerLauncher::m_is_fit_running
private

Definition at line 54 of file FitWorkerLauncher.h.

Referenced by intern_workerFinished(), interruptFitting(), and runFitting().


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