Mantid
Loading...
Searching...
No Matches
AlgorithmProgressPresenter.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2019 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
9
12 : AlgorithmProgressPresenterBase(parent), m_model{AlgorithmProgressModel(this)}, m_algorithm(nullptr), m_view(view),
13 m_timer() {}
14
16 // only allow the tracking of one algorithm at a time
17 // this makes the progress bar stutter less and it looks better overall
18 if (!m_algorithm) {
19 m_algorithm = alg;
21 }
22}
23
25 if (alg == this->m_algorithm) {
26 m_algorithm = nullptr;
28 }
29}
30
44 const QString message, const double estimatedTime,
45 const int progressPrecision) {
46 if (algorithm == this->m_algorithm) {
47 // this needs to be a call to the view
48 // so that it can be mocked out for testing
49 constexpr float maxRefreshInterval{0.1f};
50 float timeInterval = m_timer.elapsed_no_reset();
51 if (timeInterval > maxRefreshInterval) {
52 m_timer.reset();
53 m_view->updateProgress(progress, message, estimatedTime, progressPrecision);
54 }
55 }
56}
57
58} // namespace MantidQt::MantidWidgets
void algorithmEndedSlot(Mantid::API::AlgorithmID) override
Mantid::API::AlgorithmID m_algorithm
The algorithm for which a progress bar is currently being controlled.
void algorithmStartedSlot(Mantid::API::AlgorithmID) override
AlgorithmProgressPresenter(QWidget *parent, IAlgorithmProgressWidget *)
IAlgorithmProgressWidget * m_view
The view that contains the progress widget.
Mantid::Kernel::Timer m_timer
Atimer to meaure how long since the last progress report.
void updateProgressBarSlot(Mantid::API::AlgorithmID, const double, const QString, const double, const int) override
This slot is triggered whenever an algorithm reports progress.
virtual void updateProgress(const double progress, const QString &message, const double estimatedTime, const int progressPrecision)=0
float elapsed_no_reset() const
Returns the wall-clock time elapsed in seconds since the Timer object's creation, or the last call to...
Definition: Timer.cpp:40
void reset()
Explicitly reset the timer.
Definition: Timer.cpp:48
void * AlgorithmID
As we have multiple interfaces to the same logical algorithm we need a way of uniquely identifying ma...
Definition: IAlgorithm.h:28