AlgorithmProgressPresenter.h 2.42 KB
Newer Older
1
2
3
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2019 ISIS Rutherford Appleton Laboratory UKRI,
4
5
//   NScD Oak Ridge National Laboratory, European Spallation Source,
//   Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6
// SPDX - License - Identifier: GPL - 3.0 +
7
#pragma once
8

Nick Draper's avatar
Nick Draper committed
9
#include "MantidKernel/Timer.h"
10
11
#include "MantidQtWidgets/Common/AlgorithmProgress/AlgorithmProgressModel.h"
#include "MantidQtWidgets/Common/AlgorithmProgress/AlgorithmProgressPresenterBase.h"
12
13
#include "MantidQtWidgets/Common/AlgorithmProgress/IAlgorithmProgressWidget.h"
#include "MantidQtWidgets/Common/DllOption.h"
14

15
#include <QWidget>
16

17
/**
18
19
20
21
22
23
24
25
26
27
28
29
 * The AlgorithmProgressPresenter is the presenter for the progress bar always
 * visible on the Workbench. It will update the progress bar with the first
 * algorithm that has been run. If there are two or more running simultaneously,
 * only the first one's progress will be displayed.
 *
 * When the algorithm finishes, the ID is cleared, and the next algorithm that
 * starts will be tracked.
 *
 * Tracking only 1 algorithm at a time was done to allow the progress bar to
 * completely fill up, rather than be constantly reset by newly started
 * algorithms.
 *
30
 * More than one progress bar is handled by the AlgorithmProgressDialogWidget.
31
 */
32
33
namespace MantidQt {
namespace MantidWidgets {
34
class IAlgorithmProgressWidget;
35

36
37
class EXPORT_OPT_MANTIDQT_COMMON AlgorithmProgressPresenter
    : public AlgorithmProgressPresenterBase {
38
  Q_OBJECT
39

40
public:
41
  AlgorithmProgressPresenter(QWidget *parent, IAlgorithmProgressWidget *);
42

43
  void algorithmStartedSlot(Mantid::API::AlgorithmID) override;
44
45
  void updateProgressBarSlot(Mantid::API::AlgorithmID, const double,
                             const QString, const double, const int) override;
46
  void algorithmEndedSlot(Mantid::API::AlgorithmID) override;
47

48
  AlgorithmProgressModel &model() { return m_model; }
Dimitar Tasev's avatar
Dimitar Tasev committed
49

50
51
52
53
54
55
56
private:
  /// The model which observes events happening to the algorithms
  AlgorithmProgressModel m_model;
  /// The algorithm for which a progress bar is currently being controlled
  Mantid::API::AlgorithmID m_algorithm;
  /// The view that contains the progress widget.
  /// The creator of the view also owns the view (Python), not this presenter.
57
  IAlgorithmProgressWidget *m_view;
58
59
  /// Atimer to meaure how long since the last progress report
  Mantid::Kernel::Timer m_timer;
60
};
61
62
} // namespace MantidWidgets
} // namespace MantidQt