Skip to content

Commit 132d8ec

Browse files
committed
Add progress bar
1 parent 72f729c commit 132d8ec

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Framework/Algorithms/src/CreateMonteCarloWorkspace.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "MantidAlgorithms/CreateMonteCarloWorkspace.h"
1919
#include "MantidKernel/BoundedValidator.h"
2020
#include "MantidKernel/Logger.h"
21+
#include "MantidAPI/Progress.h"
2122

2223
namespace {
2324
Mantid::Kernel::Logger g_log("CreateMonteCarloWorkspace");
@@ -100,24 +101,43 @@ int CreateMonteCarloWorkspace::computeNumberOfIterations(const Mantid::Histogram
100101

101102
// Using Cumulative Distribution Function
102103
void CreateMonteCarloWorkspace::exec() {
104+
// Progress Bar set up
105+
int numSteps = 7;
106+
API::Progress progress(this, 0.0, 1.0, numSteps);
107+
108+
103109
MatrixWorkspace_sptr instWs = getProperty("InputWorkspace");
104110
int seed_input = getProperty("Seed");
111+
progress.report();
112+
std::this_thread::sleep_for(std::chrono::milliseconds(100));
105113

106114
const Mantid::HistogramData::HistogramY &yData = instWs->y(0); // Counts in each bin
115+
progress.report();
116+
std::this_thread::sleep_for(std::chrono::milliseconds(100));
107117

108118
int numIterations = computeNumberOfIterations(yData);
109119
std::vector<double> cdf = computeNormalizedCDF(yData);
120+
progress.report();
121+
std::this_thread::sleep_for(std::chrono::milliseconds(100));
110122

111123
MatrixWorkspace_sptr outputWs = WorkspaceFactory::Instance().create(instWs);
124+
progress.report();
125+
std::this_thread::sleep_for(std::chrono::milliseconds(100));
112126

113127
// Copy the bin boundaries (X-values) from the input to the output
114128
outputWs->setSharedX(0, instWs->sharedX(0));
129+
progress.report();
130+
std::this_thread::sleep_for(std::chrono::milliseconds(100));
115131

116132
std::mt19937 gen(seed_input);
117133

118134
Mantid::HistogramData::HistogramY outputY = fillHistogramWithRandomData(cdf, numIterations, gen);
135+
progress.report();
136+
std::this_thread::sleep_for(std::chrono::milliseconds(100));
119137

120138
outputWs->mutableY(0) = outputY;
139+
progress.report();
140+
std::this_thread::sleep_for(std::chrono::milliseconds(100));
121141

122142
setProperty("OutputWorkspace", outputWs);
123143
}

0 commit comments

Comments
 (0)