-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandomnoisecalculator.cpp
42 lines (38 loc) · 1.15 KB
/
randomnoisecalculator.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "randomnoisecalculator.h"
/*!
* \brief RandomNoiseCalculator::RandomNoiseCalculator
* \param mean
* \param deviation
* Constructs the object with the supplied generator and devation.
*/
RandomNoiseCalculator::RandomNoiseCalculator(int mean, int deviation) {
this->m_mean = static_cast<double>(mean);
this->m_dev = static_cast<double>(deviation);
}
/*!
* \brief RandomNoiseCalculator::generate
* This is called whenever the mean or the deviation is changed and emits
* to the object it is tied to the new generator and distrobution.
*/
void RandomNoiseCalculator::generate() {
std::normal_distribution<> d{m_mean, m_dev};
emit newRandomNoiseGeneration(d, *gen);
}
/*!
* \brief RandomNoiseCalculator::setMean
* \param mean
* On change of the mean in the UI the random is updated and generate is called
*/
void RandomNoiseCalculator::setMean(double mean) {
this->m_mean = mean;
this->generate();
}
/*!
* \brief RandomNoiseCalculator::setMean
* \param mean
* On change of the deviation in the UI the random is updated and generate is called
*/
void RandomNoiseCalculator::setDeviation(double dev) {
this->m_dev = dev;
this->generate();
}